Put all LifeStuff into a new LifeSystem. Appears to be working.

This commit is contained in:
PlatinumSkink
2015-10-22 10:34:22 +02:00
parent 1a6f18da94
commit 59c23026d2
6 changed files with 186 additions and 70 deletions
+4
View File
@@ -55,6 +55,7 @@
#include "Game/CTravels.h"
#include "Game/CStickyAim.h"
#include "Game/BallSystem.h"
#include "Game/LifeSystem.h"
#include "Game/HitLagSystem.h"
#include "Game/TravellingSystem.h"
#include "Game/LifebuoySystem.h"
@@ -199,6 +200,9 @@ public:
m_World->SystemFactory.Register<Systems::WaterSystem>(
[this]() { return new Systems::WaterSystem(m_World.get(), m_EventBroker); });
m_World->AddSystem<Systems::WaterSystem>();
m_World->SystemFactory.Register<Systems::LifeSystem>(
[this]() { return new Systems::LifeSystem(m_World.get(), m_EventBroker); });
m_World->AddSystem<Systems::LifeSystem>();
m_World->ComponentFactory.Register<Components::Model>();
m_World->ComponentFactory.Register<Components::Template>();
+4 -10
View File
@@ -10,14 +10,17 @@
#include "Core/CTemplate.h"
#include "Core/ResourceManager.h"
#include "Core/ConfigFile.h"
#include "Physics/CPhysics.h"
#include "Physics/CCircleShape.h"
#include "Physics/CRectangleShape.h"
#include "Physics/EContact.h"
#include "Rendering/CModel.h"
#include "Rendering/CSprite.h"
#include "Rendering/CPointLight.h"
#include "Rendering/CAnimation.h"
#include "Game/CBall.h"
#include "Game/CPowerUp.h"
#include "Game/CLife.h"
@@ -43,6 +46,7 @@
#include "Game/EHitLag.h"
#include "Game/EActionButton.h"
#include "Game/ELifebuoyHit.h"
#include "Physics/ECreateParticleSequence.h"
#include "Sound/CCollisionSound.h"
@@ -79,7 +83,6 @@ public:
void OnEntityRemoved(EntityID entity) override;
EntityID CreateBall();
void CreateLife(int);
EntityID Ball() { return m_Ball; };
void SetBall(const EntityID& ball) { m_Ball = ball; }
@@ -91,10 +94,6 @@ public:
void SetEdgeY(const float& edgeY) { m_EdgeY = edgeY; }
int& MultiBalls() { return m_MultiBalls; }
void SetMultiBalls(const int& multiBalls) { m_MultiBalls = multiBalls; }
int& Lives() { return m_Lives; }
void SetLives(const int& lives) { m_Lives = lives; }
int& PastLives() { return m_PastLives; }
void SetPastLives(const int& pastLives) { m_PastLives = pastLives; }
bool ReplaceBall() const { return m_ReplaceBall; }
void SetReplaceBall(const bool& replaceBall) { m_ReplaceBall = replaceBall; }
bool IsPaused() const { return m_Pause; }
@@ -107,8 +106,6 @@ private:
float m_EdgeX = 3.4f; //Actually 3.2, but anyways.
float m_EdgeY = 5.2f;
int m_MultiBalls = 0;
int m_Lives = 3;
int m_PastLives = 3;
bool m_ReplaceBall = false;
bool m_Pause = false;
bool m_Waiting = true;
@@ -120,7 +117,6 @@ private:
double m_KrakenCharge = 0;
bool m_Restarting = false;
int m_StickyCounter = 3;
bool m_GodMode = false;
bool m_First = true;
@@ -134,7 +130,6 @@ private:
std::unordered_map<EntityID, std::list<glm::vec2>> m_Contacts;
void ResolveContacts();
dd::EventRelay<BallSystem, dd::Events::LifeLost> m_ELifeLost;
dd::EventRelay<BallSystem, dd::Events::MultiBallLost> m_EMultiBallLost;
dd::EventRelay<BallSystem, dd::Events::ResetBall> m_EResetBall;
dd::EventRelay<BallSystem, dd::Events::MultiBall> m_EMultiBall;
@@ -151,7 +146,6 @@ private:
dd::EventRelay<BallSystem, dd::Events::ArrivedAtNewStage> m_EArrivedAtNewStage;
bool Contact(const Events::Contact &event);
bool OnLifeLost(const dd::Events::LifeLost &event);
bool OnMultiBallLost(const dd::Events::MultiBallLost &event);
bool OnResetBall(const dd::Events::ResetBall &event);
bool OnMultiBall(const dd::Events::MultiBall &event);
+1 -1
View File
@@ -144,7 +144,7 @@ private:
bool m_Initialized = false;
bool m_Pause = false;
int m_LooseBricks = 0;
int m_CurrentCluster = 0;
int m_CurrentCluster = 1;
int m_CurrentLevel = 1;
int m_MultiBalls = 0;
int m_PowerUps = 0;
+75
View File
@@ -0,0 +1,75 @@
//
// Created by Adniklastrator on 2015-10-22.
//
#ifndef DAYDREAM_LIFESYSTEM_H
#define DAYDREAM_LIFESYSTEM_H
#include "Core/System.h"
#include "Core/CTransform.h"
#include "Core/CTemplate.h"
#include "Core/EventBroker.h"
#include "Core/World.h"
#include "Core/ConfigFile.h"
#include "Transform/EMove.h"
#include "Rendering/CModel.h"
#include "Game/CLife.h"
#include "Game/EPause.h"
#include "Game/EResume.h"
#include "Game/ELifeLost.h"
#include "Game/EGameOver.h"
#include "Game/EKrakenAttackEnd.h"
namespace dd
{
namespace Systems
{
class LifeSystem : public System
{
public:
LifeSystem(World* world, std::shared_ptr<dd::EventBroker> eventBroker)
: System(world, eventBroker)
{ }
void Initialize() override;
void Update(double dt) override;
void UpdateEntity(double dt, EntityID entity, EntityID parent) override;
bool IsPaused() const { return m_Pause; }
void SetPause(const bool& pause) { m_Pause = pause; }
int& Lives() { return m_Lives; }
void SetLives(const int& lives) { m_Lives = lives; }
int& PastLives() { return m_PastLives; }
void SetPastLives(const int& pastLives) { m_PastLives = pastLives; }
private:
bool m_Pause = false;
int m_Lives = 3;
int m_PastLives = 3;
bool m_GodMode = false;
void CreateLife(int);
dd::EventRelay<LifeSystem, dd::Events::Pause> m_EPause;
dd::EventRelay<LifeSystem, dd::Events::Resume> m_EResume;
dd::EventRelay<LifeSystem, dd::Events::LifeLost> m_ELifeLost;
bool OnPause(const dd::Events::Pause &event);
bool OnResume(const dd::Events::Resume &event);
bool OnLifeLost(const dd::Events::LifeLost &event);
};
}
}
#endif //DAYDREAM_LIFESYSTEM_H