Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| bdcb33d992 | |||
| f26b24ef6b | |||
| 5e747f53db | |||
| 012420b4da | |||
| 50b0a091ec | |||
| 727b6ba871 | |||
| e11cdaa662 |
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include "Core/System.h"
|
#include "Core/System.h"
|
||||||
#include "Input/EInputCommand.h"
|
#include "Input/EInputCommand.h"
|
||||||
|
#include "Network/EPlayerDisconnected.h"
|
||||||
|
|
||||||
class SpectatorCameraSystem : public ImpureSystem
|
class SpectatorCameraSystem : public ImpureSystem
|
||||||
{
|
{
|
||||||
@@ -17,6 +18,8 @@ private:
|
|||||||
|
|
||||||
EventRelay<SpectatorCameraSystem, Events::InputCommand> m_EInputCommand;
|
EventRelay<SpectatorCameraSystem, Events::InputCommand> m_EInputCommand;
|
||||||
bool OnInputCommand(const Events::InputCommand& e);
|
bool OnInputCommand(const Events::InputCommand& e);
|
||||||
|
EventRelay<SpectatorCameraSystem, Events::PlayerDisconnected> m_EDisconnect;
|
||||||
|
bool OnDisconnect(const Events::PlayerDisconnected& e);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -29,4 +29,6 @@ K=TakeDamage,1500
|
|||||||
F2=PerformanceTimingResetAllTimers
|
F2=PerformanceTimingResetAllTimers
|
||||||
F3=PerformanceTimingCreateExcelData
|
F3=PerformanceTimingCreateExcelData
|
||||||
Comma=SwapToClassPick
|
Comma=SwapToClassPick
|
||||||
Period=SwapToTeamPick
|
Period=SwapToTeamPick
|
||||||
|
Enter=PickClass,1
|
||||||
|
F5=DisconnectFromServer
|
||||||
@@ -24,7 +24,7 @@ glm::vec3 Transform::AbsolutePosition(World* world, EntityID entity)
|
|||||||
while (entity != EntityID_Invalid) {
|
while (entity != EntityID_Invalid) {
|
||||||
ComponentWrapper transform = world->GetComponent(entity, "Transform");
|
ComponentWrapper transform = world->GetComponent(entity, "Transform");
|
||||||
EntityID parent = world->GetParent(entity);
|
EntityID parent = world->GetParent(entity);
|
||||||
position += Transform::AbsoluteOrientation(world, parent) * (glm::vec3)transform["Position"];
|
position += Transform::AbsoluteScale(world, parent) * (Transform::AbsoluteOrientation(world, parent) * (glm::vec3)transform["Position"]);
|
||||||
entity = parent;
|
entity = parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,12 +89,12 @@ glm::mat4 Transform::ModelMatrix(EntityID entity, World* world)
|
|||||||
{
|
{
|
||||||
return AbsoluteTransformation(EntityWrapper(world, entity));
|
return AbsoluteTransformation(EntityWrapper(world, entity));
|
||||||
|
|
||||||
glm::vec3 position = Transform::AbsolutePosition(world, entity);
|
//glm::vec3 position = Transform::AbsolutePosition(world, entity);
|
||||||
glm::quat orientation = Transform::AbsoluteOrientation(world, entity);
|
//glm::quat orientation = Transform::AbsoluteOrientation(world, entity);
|
||||||
glm::vec3 scale = Transform::AbsoluteScale(world, entity);
|
//glm::vec3 scale = Transform::AbsoluteScale(world, entity);
|
||||||
|
|
||||||
glm::mat4 modelMatrix = glm::translate(glm::mat4(), position) * glm::toMat4(orientation) * glm::scale(scale);
|
//glm::mat4 modelMatrix = glm::translate(glm::mat4(), position) * glm::toMat4(orientation) * glm::scale(scale);
|
||||||
return modelMatrix;
|
//return modelMatrix;
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec3 Transform::TransformPoint(const glm::vec3& point, const glm::mat4& matrix)
|
glm::vec3 Transform::TransformPoint(const glm::vec3& point, const glm::mat4& matrix)
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ EditorRenderSystem::EditorRenderSystem(SystemParams params, IRenderer* renderer,
|
|||||||
{
|
{
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_ESetCamera, &EditorRenderSystem::OnSetCamera);
|
EVENT_SUBSCRIBE_MEMBER(m_ESetCamera, &EditorRenderSystem::OnSetCamera);
|
||||||
auto resolution = Rectangle::Rectangle(1280, 720);
|
auto resolution = Rectangle::Rectangle(1280, 720);
|
||||||
m_EditorCamera = new Camera((float)resolution.Width / resolution.Height, glm::radians(45.f), 0.01f, 5000.f);
|
m_EditorCamera = new Camera((float)resolution.Width / resolution.Height, glm::radians(45.f), 0.001f, 500.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorRenderSystem::Update(double dt)
|
void EditorRenderSystem::Update(double dt)
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ EditorSystem::EditorSystem(SystemParams params, IRenderer* renderer, RenderFrame
|
|||||||
Enable();
|
Enable();
|
||||||
} else {
|
} else {
|
||||||
Disable();
|
Disable();
|
||||||
|
m_EventBroker->Publish(Events::UnlockMouse());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -204,14 +205,21 @@ bool EditorSystem::OnWidgetDelta(const Events::WidgetDelta& e)
|
|||||||
if (m_CurrentSelection.Valid()) {
|
if (m_CurrentSelection.Valid()) {
|
||||||
if (m_WidgetSpace == EditorGUI::WidgetSpace::Global) {
|
if (m_WidgetSpace == EditorGUI::WidgetSpace::Global) {
|
||||||
glm::quat parentOrientation;
|
glm::quat parentOrientation;
|
||||||
|
glm::vec3 parentScale(1.f);
|
||||||
EntityWrapper parent = m_CurrentSelection.Parent();
|
EntityWrapper parent = m_CurrentSelection.Parent();
|
||||||
if (parent.Valid()) {
|
if (parent.Valid()) {
|
||||||
parentOrientation = glm::inverse(Transform::AbsoluteOrientation(parent));
|
parentOrientation = glm::inverse(Transform::AbsoluteOrientation(parent));
|
||||||
|
parentScale = Transform::AbsoluteScale(parent);
|
||||||
}
|
}
|
||||||
(glm::vec3&)m_CurrentSelection["Transform"]["Position"] += parentOrientation * e.Translation;
|
(glm::vec3&)m_CurrentSelection["Transform"]["Position"] += parentOrientation * e.Translation / parentScale;
|
||||||
} else if (m_WidgetSpace == EditorGUI::WidgetSpace::Local) {
|
} else if (m_WidgetSpace == EditorGUI::WidgetSpace::Local) {
|
||||||
|
glm::vec3 parentScale(1.f);
|
||||||
|
EntityWrapper parent = m_CurrentSelection.Parent();
|
||||||
|
if (parent.Valid()) {
|
||||||
|
parentScale = Transform::AbsoluteScale(parent);
|
||||||
|
}
|
||||||
glm::quat selectionOri = glm::quat((glm::vec3)m_CurrentSelection["Transform"]["Orientation"]);
|
glm::quat selectionOri = glm::quat((glm::vec3)m_CurrentSelection["Transform"]["Orientation"]);
|
||||||
glm::vec3 localTranslation = selectionOri * e.Translation;
|
glm::vec3 localTranslation = selectionOri * e.Translation / parentScale;
|
||||||
(glm::vec3&)m_CurrentSelection["Transform"]["Position"] += localTranslation;
|
(glm::vec3&)m_CurrentSelection["Transform"]["Position"] += localTranslation;
|
||||||
}
|
}
|
||||||
m_EditorGUI->SetDirty(m_CurrentSelection);
|
m_EditorGUI->SetDirty(m_CurrentSelection);
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
#include "Network/Client.h"
|
#include "Network/Client.h"
|
||||||
|
#include "Network/EPlayerDisconnected.h"
|
||||||
using namespace boost::asio::ip;
|
using namespace boost::asio::ip;
|
||||||
|
|
||||||
Client::Client(World* world, EventBroker* eventBroker)
|
Client::Client(World* world, EventBroker* eventBroker)
|
||||||
@@ -224,7 +225,7 @@ void Client::parseServerlist(Packet& packet)
|
|||||||
void Client::parseKick()
|
void Client::parseKick()
|
||||||
{
|
{
|
||||||
LOG_WARNING("You have been kicked from the server.");
|
LOG_WARNING("You have been kicked from the server.");
|
||||||
m_IsConnected = false;
|
disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::parseSpawnEvents()
|
void Client::parseSpawnEvents()
|
||||||
@@ -464,6 +465,10 @@ void Client::disconnect()
|
|||||||
Packet packet(MessageType::Disconnect, m_SendPacketID);
|
Packet packet(MessageType::Disconnect, m_SendPacketID);
|
||||||
m_Reliable.Send(packet);
|
m_Reliable.Send(packet);
|
||||||
m_Reliable.Disconnect();
|
m_Reliable.Disconnect();
|
||||||
|
Events::PlayerDisconnected e;
|
||||||
|
e.Entity = m_LocalPlayer.ID;
|
||||||
|
e.PlayerID = -1;
|
||||||
|
m_EventBroker->Publish(e);
|
||||||
createMainMenu();
|
createMainMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -208,18 +208,6 @@ bool PlayerSpawnSystem::OnPlayerSpawned(Events::PlayerSpawned& e)
|
|||||||
m_EventBroker->Publish(lock);
|
m_EventBroker->Publish(lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
// HACK: Set the player model color to team color
|
|
||||||
EntityWrapper playerModel = e.Player.FirstChildByName("PlayerModel");
|
|
||||||
if (playerModel.Valid() && e.Player.HasComponent("Team")) {
|
|
||||||
ComponentWrapper cTeam = e.Player["Team"];
|
|
||||||
ComponentWrapper cModel = playerModel["Model"];
|
|
||||||
if ((ComponentInfo::EnumType)cTeam["Team"] == cTeam["Team"].Enum("Red")) {
|
|
||||||
cModel["Color"] = glm::vec3(1.f, 0.f, 0.f);
|
|
||||||
} else if ((ComponentInfo::EnumType)cTeam["Team"] == cTeam["Team"].Enum("Blue")) {
|
|
||||||
cModel["Color"] = glm::vec3(0.f, 0.25f, 1.f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ SpectatorCameraSystem::SpectatorCameraSystem(SystemParams params)
|
|||||||
, m_PickedTeam(-1)
|
, m_PickedTeam(-1)
|
||||||
{
|
{
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &SpectatorCameraSystem::OnInputCommand);
|
EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &SpectatorCameraSystem::OnInputCommand);
|
||||||
|
EVENT_SUBSCRIBE_MEMBER(m_EDisconnect, &SpectatorCameraSystem::OnDisconnect);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpectatorCameraSystem::Update(double dt)
|
void SpectatorCameraSystem::Update(double dt)
|
||||||
@@ -87,4 +88,17 @@ bool SpectatorCameraSystem::OnInputCommand(const Events::InputCommand& e)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SpectatorCameraSystem::OnDisconnect(const Events::PlayerDisconnected& e)
|
||||||
|
{
|
||||||
|
// If local player gets disconnected, they should be set to
|
||||||
|
// the spectator camera next time a map loads that has one.
|
||||||
|
if (e.Entity == LocalPlayer.ID) {
|
||||||
|
m_CamSetToTeamPick = false;
|
||||||
|
// They will also be set to menu, so unlock mouse just in case they were in game with locked mouse.
|
||||||
|
Events::UnlockMouse unlock;
|
||||||
|
m_EventBroker->Publish(unlock);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user