Player input properly separated from editor input and server

This commit is contained in:
2016-01-22 21:35:31 +01:00
parent 406b730ef3
commit 55ee2bb3bf
4 changed files with 54 additions and 25 deletions
+10 -2
View File
@@ -72,8 +72,8 @@ void EditorSystem::Update(double dt)
ComponentWrapper& cameraTransform = m_EditorCamera["Transform"];
glm::vec3& ori = cameraTransform["Orientation"];
ori.x = m_EditorCameraInputController->Orientation().x;
ori.y = m_EditorCameraInputController->Orientation().y;
ori.x = m_EditorCameraInputController->Rotation().x;
ori.y = m_EditorCameraInputController->Rotation().y;
glm::vec3& pos = cameraTransform["Position"];
pos += m_EditorCameraInputController->Movement() * glm::inverse(glm::quat(ori)) * (float)actualDelta;
}
@@ -81,6 +81,8 @@ void EditorSystem::Update(double dt)
void EditorSystem::Enable()
{
m_EditorCameraInputController->Enable();
m_EventBroker->Publish(Events::UnlockMouse());
Events::SetCamera e;
e.CameraEntity = m_EditorCamera;
m_EventBroker->Publish(e);
@@ -90,6 +92,8 @@ void EditorSystem::Enable()
void EditorSystem::Disable()
{
m_EditorCameraInputController->Disable();
m_EventBroker->Publish(Events::LockMouse());
Events::SetCamera e;
e.CameraEntity = m_ActualCamera;
m_EventBroker->Publish(e);
@@ -179,6 +183,10 @@ bool EditorSystem::OnWidgetDelta(const Events::WidgetDelta& e)
bool EditorSystem::OnInputCommand(const Events::InputCommand& e)
{
if (e.PlayerID != -1) {
return false;
}
if (e.Command == "ToggleEditor" && e.Value > 0) {
if (m_Enabled) {
Disable();
+4 -3
View File
@@ -27,16 +27,17 @@ void PlayerMovementSystem::Update(double dt)
EntityWrapper cameraEntity = player.FirstChildByName("Camera");
if (cameraEntity.Valid()) {
glm::vec3& cameraOrientation = cameraEntity["Transform"]["Orientation"];
cameraOrientation.x = controller->Orientation().x;
cameraOrientation.x += controller->Rotation().x;
}
ComponentWrapper& cTransform = player["Transform"];
glm::vec3& ori = cTransform["Orientation"];
ori.y = controller->Orientation().y;
ori.y += controller->Rotation().y;
glm::vec3& pos = cTransform["Position"];
pos += controller->Movement() * glm::inverse(glm::quat(ori)) * (float)player["Player"]["MovementSpeed"] * (float)dt;
controller->Reset();
}
}