StartMenu system now sets the main menu camera to active as long as it exists.

This commit is contained in:
Tleety
2016-03-09 15:29:42 +01:00
parent a76a04260f
commit 49040e9c4b
4 changed files with 36 additions and 4 deletions
+5
View File
@@ -5,6 +5,7 @@
#include "Core/ResourceManager.h"
#include "Core/Event.h"
#include "Core/EventBroker.h"
#include "Rendering/ESetCamera.h"
class StartSystem : public ImpureSystem
{
@@ -13,6 +14,10 @@ public:
virtual void Update(double dt) override;
private:
EntityWrapper m_activeCamera = EntityWrapper::Invalid;
EventRelay<StartSystem, Events::SetCamera> m_ECameraActivated;
bool OnCameraActivated(const Events::SetCamera& e);
};
#endif
+3 -3
View File
@@ -34,7 +34,7 @@
<Axis X="0" Y="1" Z="0"/>
</c:RaptorCopter>
<c:Transform>
<Orientation X="0" Y="74.1606216" Z="0"/>
<Orientation X="0" Y="75.6741409" Z="0"/>
</c:Transform>
</Components>
<Children>
@@ -46,11 +46,11 @@
</c:RaptorCopter>
<c:Transform>
<Position X="0" Y="26" Z="40"/>
<Orientation X="0" Y="-65.2195206" Z="0"/>
<Orientation X="0" Y="-68.2463989" Z="0"/>
</c:Transform>
</Components>
<Children>
<Entity name="Overview_Camera">
<Entity name="Overview_Camera_Start_Menu">
<Components>
<c:Camera/>
<c:Transform>
+2
View File
@@ -39,6 +39,7 @@
#include "GUI/ButtonSystem.h"
#include "Game/Systems/MainMenuSystem.h"
#include "Game/Systems/ServerListSystem.h"
#include "Game/Systems/StartSystem.h"
Game::Game(int argc, char* argv[])
@@ -153,6 +154,7 @@ Game::Game(int argc, char* argv[])
m_SystemPipeline->AddSystem<ScoreScreenSystem>(updateOrderLevel);
m_SystemPipeline->AddSystem<SpectatorCameraSystem>(updateOrderLevel);
m_SystemPipeline->AddSystem<ServerListSystem>(updateOrderLevel, m_Renderer);
m_SystemPipeline->AddSystem<StartSystem>(updateOrderLevel);
// Populate Octree with collidables
++updateOrderLevel;
m_SystemPipeline->AddSystem<FillOctreeSystem>(updateOrderLevel, m_OctreeCollision, "Collidable");
+26 -1
View File
@@ -4,5 +4,30 @@ StartSystem::StartSystem(SystemParams params)
: System(params)
, ImpureSystem()
{
EVENT_SUBSCRIBE_MEMBER(m_ECameraActivated, &StartSystem::OnCameraActivated);
}
}
void StartSystem::Update(double dt)
{
auto cameras = m_World->GetComponents("Camera");
if(cameras == nullptr) {
return;
}
for(auto& cCamera: *cameras) {
EntityWrapper cameraEntity = EntityWrapper(m_World, cCamera.EntityID);
if(cameraEntity == m_activeCamera){
return;
}
if(cameraEntity.Name() == "Overview_Camera_Start_Menu") {
Events::SetCamera event;
event.CameraEntity = cameraEntity;
m_EventBroker->Publish(event);
}
}
}
bool StartSystem::OnCameraActivated(const Events::SetCamera& e)
{
m_activeCamera = e.CameraEntity;
return 1;
}