HitLagSystem implemented.
This commit is contained in:
@@ -45,6 +45,7 @@
|
|||||||
#include "Game/CPad.h"
|
#include "Game/CPad.h"
|
||||||
#include "Game/CBrick.h"
|
#include "Game/CBrick.h"
|
||||||
#include "Game/BallSystem.h"
|
#include "Game/BallSystem.h"
|
||||||
|
#include "Game/HitLagSystem.h"
|
||||||
#include "Game/Bricks/CPowerUpBrick.h"
|
#include "Game/Bricks/CPowerUpBrick.h"
|
||||||
|
|
||||||
#include "Physics/PhysicsSystem.h"
|
#include "Physics/PhysicsSystem.h"
|
||||||
@@ -120,6 +121,9 @@ public:
|
|||||||
m_World->SystemFactory.Register<Systems::BallSystem>(
|
m_World->SystemFactory.Register<Systems::BallSystem>(
|
||||||
[this]() { return new Systems::BallSystem(m_World.get(), m_EventBroker); });
|
[this]() { return new Systems::BallSystem(m_World.get(), m_EventBroker); });
|
||||||
m_World->AddSystem<Systems::BallSystem>();
|
m_World->AddSystem<Systems::BallSystem>();
|
||||||
|
m_World->SystemFactory.Register<Systems::HitLagSystem>(
|
||||||
|
[this]() { return new Systems::HitLagSystem(m_World.get(), m_EventBroker); });
|
||||||
|
m_World->AddSystem<Systems::HitLagSystem>();
|
||||||
m_World->SystemFactory.Register<Systems::PhysicsSystem>(
|
m_World->SystemFactory.Register<Systems::PhysicsSystem>(
|
||||||
[this]() { return new Systems::PhysicsSystem(m_World.get(), m_EventBroker); });
|
[this]() { return new Systems::PhysicsSystem(m_World.get(), m_EventBroker); });
|
||||||
m_World->AddSystem<Systems::PhysicsSystem>();
|
m_World->AddSystem<Systems::PhysicsSystem>();
|
||||||
|
|||||||
@@ -21,7 +21,6 @@
|
|||||||
#include "Game/EMultiBallLost.h"
|
#include "Game/EMultiBallLost.h"
|
||||||
#include "Game/EGameOver.h"
|
#include "Game/EGameOver.h"
|
||||||
#include "Game/EPause.h"
|
#include "Game/EPause.h"
|
||||||
#include "Game/EHitLag.h"
|
|
||||||
|
|
||||||
namespace dd
|
namespace dd
|
||||||
{
|
{
|
||||||
@@ -77,10 +76,8 @@ public:
|
|||||||
void SetReplaceBall(const bool& replaceBall) { m_ReplaceBall = replaceBall; }
|
void SetReplaceBall(const bool& replaceBall) { m_ReplaceBall = replaceBall; }
|
||||||
bool MultiBall() const { return m_MultiBall; }
|
bool MultiBall() const { return m_MultiBall; }
|
||||||
void SetMultiBall(const bool& multiBall) { m_MultiBall = multiBall; }
|
void SetMultiBall(const bool& multiBall) { m_MultiBall = multiBall; }
|
||||||
bool Pause() const { return m_Pause; }
|
bool IsPaused() const { return m_Pause; }
|
||||||
void SetPause(const bool& pause) { m_Pause = pause; }
|
void SetPause(const bool& pause) { m_Pause = pause; }
|
||||||
bool HitLag() const { return m_HitLag; }
|
|
||||||
void SetHitLag(const bool& hitLag) { m_HitLag = hitLag; }
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
float m_XMovementMultiplier = 2.f;
|
float m_XMovementMultiplier = 2.f;
|
||||||
@@ -93,12 +90,6 @@ private:
|
|||||||
bool m_MultiBall = false;
|
bool m_MultiBall = false;
|
||||||
bool m_Pause = false;
|
bool m_Pause = false;
|
||||||
|
|
||||||
bool m_HitLag = false;
|
|
||||||
float m_Time;
|
|
||||||
float m_SlowdownTime;
|
|
||||||
float m_HitLagTimer = 0;
|
|
||||||
float m_HitLagPlacement = 0;
|
|
||||||
|
|
||||||
EntityID m_Ball;
|
EntityID m_Ball;
|
||||||
|
|
||||||
dd::EventRelay<BallSystem, dd::Events::LifeLost> m_ELifeLost;
|
dd::EventRelay<BallSystem, dd::Events::LifeLost> m_ELifeLost;
|
||||||
@@ -106,14 +97,12 @@ private:
|
|||||||
dd::EventRelay<BallSystem, dd::Events::ResetBall> m_EResetBall;
|
dd::EventRelay<BallSystem, dd::Events::ResetBall> m_EResetBall;
|
||||||
dd::EventRelay<BallSystem, dd::Events::MultiBall> m_EMultiBall;
|
dd::EventRelay<BallSystem, dd::Events::MultiBall> m_EMultiBall;
|
||||||
dd::EventRelay<BallSystem, dd::Events::Pause> m_EPause;
|
dd::EventRelay<BallSystem, dd::Events::Pause> m_EPause;
|
||||||
dd::EventRelay<BallSystem, dd::Events::HitLag> m_EHitLag;
|
|
||||||
|
|
||||||
bool OnLifeLost(const dd::Events::LifeLost &event);
|
bool OnLifeLost(const dd::Events::LifeLost &event);
|
||||||
bool OnMultiBallLost(const dd::Events::MultiBallLost &event);
|
bool OnMultiBallLost(const dd::Events::MultiBallLost &event);
|
||||||
bool OnResetBall(const dd::Events::ResetBall &event);
|
bool OnResetBall(const dd::Events::ResetBall &event);
|
||||||
bool OnMultiBall(const dd::Events::MultiBall &event);
|
bool OnMultiBall(const dd::Events::MultiBall &event);
|
||||||
bool OnPause(const dd::Events::Pause &event);
|
bool OnPause(const dd::Events::Pause &event);
|
||||||
bool OnHitLag(const dd::Events::HitLag &event);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,83 @@
|
|||||||
|
//
|
||||||
|
// Created by Adniklastrator on 2015-09-30.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef DAYDREAM_HITLAGSYSTEM_H
|
||||||
|
#define DAYDREAM_HITLAGSYSTEM_H
|
||||||
|
|
||||||
|
|
||||||
|
#include "Core/System.h"
|
||||||
|
#include "Core/CTransform.h"
|
||||||
|
#include "Core/CTemplate.h"
|
||||||
|
#include "Core/EventBroker.h"
|
||||||
|
#include "Core/World.h"
|
||||||
|
#include "Rendering/CSprite.h"
|
||||||
|
#include "Rendering/CModel.h"
|
||||||
|
#include "Game/CBrick.h"
|
||||||
|
#include "Game/CBall.h"
|
||||||
|
#include "Game/CLife.h"
|
||||||
|
#include "Game/CPowerUp.h"
|
||||||
|
#include "Game/EStageCleared.h"
|
||||||
|
#include "Game/ELifeLost.h"
|
||||||
|
#include "Game/EResetBall.h"
|
||||||
|
#include "Game/EScoreEvent.h"
|
||||||
|
#include "Game/EComboEvent.h"
|
||||||
|
#include "Game/EMultiBall.h"
|
||||||
|
#include "Game/EMultiBallLost.h"
|
||||||
|
#include "Game/EPause.h"
|
||||||
|
#include "Game/EHitLag.h"
|
||||||
|
#include "Game/EGameOver.h"
|
||||||
|
#include "Game/ECreatePowerUp.h"
|
||||||
|
#include "Game/EPowerUpTaken.h"
|
||||||
|
#include "Game/Bricks/CPowerUpBrick.h"
|
||||||
|
#include "Physics/CPhysics.h"
|
||||||
|
#include "Physics/CCircleShape.h"
|
||||||
|
#include "Physics/CRectangleShape.h"
|
||||||
|
#include "Physics/ESetImpulse.h"
|
||||||
|
#include "Physics/EContact.h"
|
||||||
|
#include "Sound/CCollisionSound.h"
|
||||||
|
#include "Game/PadSystem.h"
|
||||||
|
#include <fstream>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
|
||||||
|
namespace dd
|
||||||
|
{
|
||||||
|
|
||||||
|
namespace Systems
|
||||||
|
{
|
||||||
|
|
||||||
|
class HitLagSystem : public System
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
HitLagSystem(World* world, std::shared_ptr<dd::EventBroker> eventBroker)
|
||||||
|
: System(world, eventBroker)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
void Initialize() override;
|
||||||
|
|
||||||
|
void Update(double dt) override;
|
||||||
|
|
||||||
|
bool IsPaused() const { return m_Pause; }
|
||||||
|
void SetPause(const bool& pause) { m_Pause = pause; }
|
||||||
|
bool HitLag() const { return m_HitLag; }
|
||||||
|
void SetHitLag(const bool& hitLag) { m_HitLag = hitLag; }
|
||||||
|
private:
|
||||||
|
bool m_Pause;
|
||||||
|
bool m_HitLag;
|
||||||
|
float m_HitLagDuration;
|
||||||
|
float m_HitLagTimer;
|
||||||
|
|
||||||
|
dd::EventRelay<HitLagSystem, dd::Events::Pause> m_EPause;
|
||||||
|
dd::EventRelay<HitLagSystem, dd::Events::HitLag> m_EHitLag;
|
||||||
|
|
||||||
|
bool OnPause(const dd::Events::Pause &event);
|
||||||
|
bool OnHitLag(const dd::Events::HitLag &event);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif //DAYDREAM_HITLAGSYSTEM_H
|
||||||
@@ -81,7 +81,7 @@ public:
|
|||||||
void SetRestarting(const bool& restarting) { m_Restarting = restarting; }
|
void SetRestarting(const bool& restarting) { m_Restarting = restarting; }
|
||||||
bool Initialized() const { return m_Initialized; }
|
bool Initialized() const { return m_Initialized; }
|
||||||
void SetInitialized(const bool& initialized) { m_Initialized = initialized; }
|
void SetInitialized(const bool& initialized) { m_Initialized = initialized; }
|
||||||
bool Pause() const { return m_Pause; }
|
bool IsPaused() const { return m_Pause; }
|
||||||
void SetPause(const bool& pause) { m_Pause = pause; }
|
void SetPause(const bool& pause) { m_Pause = pause; }
|
||||||
int& MultiBalls() { return m_MultiBalls; }
|
int& MultiBalls() { return m_MultiBalls; }
|
||||||
void SetMultiBalls(const int& multiBalls) { m_MultiBalls = multiBalls; }
|
void SetMultiBalls(const int& multiBalls) { m_MultiBalls = multiBalls; }
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ public:
|
|||||||
Components::Pad* Pad() const { return m_Pad; }
|
Components::Pad* Pad() const { return m_Pad; }
|
||||||
void SetPad(Components::Pad* pad) { m_Pad = pad; }
|
void SetPad(Components::Pad* pad) { m_Pad = pad; }
|
||||||
|
|
||||||
bool Pause() const { return m_Pause; }
|
bool IsPaused() const { return m_Pause; }
|
||||||
void SetPause(const bool& pause) { m_Pause = pause; }
|
void SetPause(const bool& pause) { m_Pause = pause; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -14,7 +14,6 @@
|
|||||||
#include "Physics/EContact.h"
|
#include "Physics/EContact.h"
|
||||||
#include "Physics/ESetImpulse.h"
|
#include "Physics/ESetImpulse.h"
|
||||||
#include "Game/EPause.h"
|
#include "Game/EPause.h"
|
||||||
#include "Game/EHitLag.h"
|
|
||||||
#include "Game/CPad.h"
|
#include "Game/CPad.h"
|
||||||
#include "Game/CBall.h"
|
#include "Game/CBall.h"
|
||||||
#include "Transform/TransformSystem.h"
|
#include "Transform/TransformSystem.h"
|
||||||
@@ -56,10 +55,8 @@ public:
|
|||||||
// Called when an entity is removed
|
// Called when an entity is removed
|
||||||
void OnEntityRemoved(EntityID entity) override;
|
void OnEntityRemoved(EntityID entity) override;
|
||||||
|
|
||||||
bool Pause() const { return m_Pause; }
|
bool IsPaused() const { return m_Pause; }
|
||||||
void SetPause(const bool& pause) { m_Pause = pause; }
|
void SetPause(const bool& pause) { m_Pause = pause; }
|
||||||
bool HitLag() const { return m_HitLag; }
|
|
||||||
void SetHitLag(const bool& hitLag) { m_HitLag = hitLag; }
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
b2Vec2 m_Gravity;
|
b2Vec2 m_Gravity;
|
||||||
@@ -68,16 +65,8 @@ private:
|
|||||||
double m_Accumulator;
|
double m_Accumulator;
|
||||||
bool m_Pause = false;
|
bool m_Pause = false;
|
||||||
|
|
||||||
bool m_HitLag = false;
|
|
||||||
float m_Time;
|
|
||||||
float m_SlowdownTime;
|
|
||||||
float m_HitLagTimer = 0;
|
|
||||||
float m_HitLagPlacement = 0;
|
|
||||||
|
|
||||||
dd::EventRelay<PhysicsSystem, dd::Events::Pause> m_EPause;
|
dd::EventRelay<PhysicsSystem, dd::Events::Pause> m_EPause;
|
||||||
dd::EventRelay<PhysicsSystem, dd::Events::HitLag> m_EHitLag;
|
|
||||||
bool OnPause(const dd::Events::Pause &event);
|
bool OnPause(const dd::Events::Pause &event);
|
||||||
bool OnHitLag(const dd::Events::HitLag &event);
|
|
||||||
|
|
||||||
int m_VelocityIterations, m_PositionIterations;
|
int m_VelocityIterations, m_PositionIterations;
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ void dd::Systems::BallSystem::Initialize()
|
|||||||
EVENT_SUBSCRIBE_MEMBER(m_EResetBall, &BallSystem::OnResetBall);
|
EVENT_SUBSCRIBE_MEMBER(m_EResetBall, &BallSystem::OnResetBall);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EMultiBall, &BallSystem::OnMultiBall);
|
EVENT_SUBSCRIBE_MEMBER(m_EMultiBall, &BallSystem::OnMultiBall);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EPause, &BallSystem::OnPause);
|
EVENT_SUBSCRIBE_MEMBER(m_EPause, &BallSystem::OnPause);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EHitLag, &BallSystem::OnHitLag);
|
|
||||||
|
|
||||||
//OctoBall
|
//OctoBall
|
||||||
{
|
{
|
||||||
@@ -68,27 +67,11 @@ void dd::Systems::BallSystem::Update(double dt)
|
|||||||
Events::GameOver e;
|
Events::GameOver e;
|
||||||
EventBroker->Publish(e);
|
EventBroker->Publish(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if (HitLag()) {
|
|
||||||
m_HitLagTimer += 0.1 * dt;
|
|
||||||
if (Pause()) {
|
|
||||||
if (m_HitLagTimer > 1) {
|
|
||||||
SetPause(false);
|
|
||||||
m_HitLagTimer = 0;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (m_HitLagTimer > m_HitLagPlacement) {
|
|
||||||
SetPause(true);
|
|
||||||
m_HitLagPlacement *= 0.9;
|
|
||||||
m_HitLagTimer = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void dd::Systems::BallSystem::UpdateEntity(double dt, EntityID entity, EntityID parent)
|
void dd::Systems::BallSystem::UpdateEntity(double dt, EntityID entity, EntityID parent)
|
||||||
{
|
{
|
||||||
if (Pause()) {
|
if (IsPaused()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,7 +153,7 @@ void dd::Systems::BallSystem::UpdateEntity(double dt, EntityID entity, EntityID
|
|||||||
|
|
||||||
bool dd::Systems::BallSystem::OnPause(const dd::Events::Pause &event)
|
bool dd::Systems::BallSystem::OnPause(const dd::Events::Pause &event)
|
||||||
{
|
{
|
||||||
if (Pause()) {
|
if (IsPaused()) {
|
||||||
SetPause(false);
|
SetPause(false);
|
||||||
} else {
|
} else {
|
||||||
SetPause(true);
|
SetPause(true);
|
||||||
@@ -178,19 +161,6 @@ bool dd::Systems::BallSystem::OnPause(const dd::Events::Pause &event)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool dd::Systems::BallSystem::OnHitLag(const dd::Events::HitLag &event)
|
|
||||||
{
|
|
||||||
if (HitLag()) {
|
|
||||||
SetHitLag(false);
|
|
||||||
} else {
|
|
||||||
SetHitLag(true);
|
|
||||||
m_Time = event.Time;
|
|
||||||
m_SlowdownTime = event.SlowdownTime;
|
|
||||||
m_HitLagTimer = m_SlowdownTime;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void dd::Systems::BallSystem::OnEntityCommit(EntityID entity)
|
void dd::Systems::BallSystem::OnEntityCommit(EntityID entity)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,48 @@
|
|||||||
|
//
|
||||||
|
// Created by Adniklastrator on 2015-09-30.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "PrecompiledHeader.h"
|
||||||
|
#include "Game/HitLagSystem.h"
|
||||||
|
|
||||||
|
void dd::Systems::HitLagSystem::Initialize()
|
||||||
|
{
|
||||||
|
EVENT_SUBSCRIBE_MEMBER(m_EPause, &HitLagSystem::OnPause);
|
||||||
|
EVENT_SUBSCRIBE_MEMBER(m_EHitLag, &HitLagSystem::OnHitLag);
|
||||||
|
}
|
||||||
|
|
||||||
|
void dd::Systems::HitLagSystem::Update(double dt)
|
||||||
|
{
|
||||||
|
if (IsPaused()) {
|
||||||
|
if (HitLag()) {
|
||||||
|
m_HitLagTimer += dt;
|
||||||
|
std::cout << m_HitLagTimer << std::endl;
|
||||||
|
if (m_HitLagDuration < m_HitLagTimer) {
|
||||||
|
m_HitLagTimer = 0;
|
||||||
|
SetHitLag(false);
|
||||||
|
Events::Pause e;
|
||||||
|
EventBroker->Publish(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool dd::Systems::HitLagSystem::OnPause(const dd::Events::Pause &event)
|
||||||
|
{
|
||||||
|
if (IsPaused()) {
|
||||||
|
SetPause(false);
|
||||||
|
} else {
|
||||||
|
SetPause(true);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool dd::Systems::HitLagSystem::OnHitLag(const dd::Events::HitLag &event)
|
||||||
|
{
|
||||||
|
SetHitLag(true);
|
||||||
|
Events::Pause e;
|
||||||
|
EventBroker->Publish(e);
|
||||||
|
m_HitLagDuration = event.Time;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
@@ -31,7 +31,7 @@ void dd::Systems::LevelSystem::Update(double dt)
|
|||||||
|
|
||||||
void dd::Systems::LevelSystem::UpdateEntity(double dt, EntityID entity, EntityID parent)
|
void dd::Systems::LevelSystem::UpdateEntity(double dt, EntityID entity, EntityID parent)
|
||||||
{
|
{
|
||||||
if (Pause()) {
|
if (IsPaused()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto templateCheck = m_World->GetComponent<Components::Template>(entity);
|
auto templateCheck = m_World->GetComponent<Components::Template>(entity);
|
||||||
@@ -77,7 +77,7 @@ void dd::Systems::LevelSystem::UpdateEntity(double dt, EntityID entity, EntityID
|
|||||||
|
|
||||||
bool dd::Systems::LevelSystem::OnPause(const dd::Events::Pause &event)
|
bool dd::Systems::LevelSystem::OnPause(const dd::Events::Pause &event)
|
||||||
{
|
{
|
||||||
if (Pause()) {
|
if (IsPaused()) {
|
||||||
SetPause(false);
|
SetPause(false);
|
||||||
} else {
|
} else {
|
||||||
SetPause(true);
|
SetPause(true);
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ void dd::Systems::PadSystem::UpdateEntity(double dt, EntityID entity, EntityID p
|
|||||||
|
|
||||||
void dd::Systems::PadSystem::Update(double dt)
|
void dd::Systems::PadSystem::Update(double dt)
|
||||||
{
|
{
|
||||||
if (Pause()) {
|
if (IsPaused()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Entity() == 0) {
|
if (Entity() == 0) {
|
||||||
@@ -111,7 +111,7 @@ void dd::Systems::PadSystem::Update(double dt)
|
|||||||
|
|
||||||
bool dd::Systems::PadSystem::OnPause(const dd::Events::Pause &event)
|
bool dd::Systems::PadSystem::OnPause(const dd::Events::Pause &event)
|
||||||
{
|
{
|
||||||
if (Pause()) {
|
if (IsPaused()) {
|
||||||
SetPause(false);
|
SetPause(false);
|
||||||
} else {
|
} else {
|
||||||
SetPause(true);
|
SetPause(true);
|
||||||
@@ -143,14 +143,10 @@ bool dd::Systems::PadSystem::OnKeyDown(const dd::Events::KeyDown &event)
|
|||||||
EventBroker->Publish(e);
|
EventBroker->Publish(e);
|
||||||
} else if (val == GLFW_KEY_P) {
|
} else if (val == GLFW_KEY_P) {
|
||||||
Events::Pause e;
|
Events::Pause e;
|
||||||
e.Time = 0;
|
|
||||||
e.SlowdownTime = 0;
|
|
||||||
e.Type = "All";
|
|
||||||
EventBroker->Publish(e);
|
EventBroker->Publish(e);
|
||||||
} else if (val == GLFW_KEY_H) {
|
} else if (val == GLFW_KEY_H) {
|
||||||
Events::HitLag e;
|
Events::HitLag e;
|
||||||
e.Time = 0.3;
|
e.Time = 0.3;
|
||||||
e.SlowdownTime = 10;
|
|
||||||
e.Type = "All";
|
e.Type = "All";
|
||||||
EventBroker->Publish(e);
|
EventBroker->Publish(e);
|
||||||
} else if (val == GLFW_KEY_D) {
|
} else if (val == GLFW_KEY_D) {
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ void dd::Systems::PhysicsSystem::Initialize()
|
|||||||
|
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_SetImpulse, &PhysicsSystem::SetImpulse);
|
EVENT_SUBSCRIBE_MEMBER(m_SetImpulse, &PhysicsSystem::SetImpulse);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EPause, &PhysicsSystem::OnPause);
|
EVENT_SUBSCRIBE_MEMBER(m_EPause, &PhysicsSystem::OnPause);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EHitLag, &PhysicsSystem::OnHitLag);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void dd::Systems::PhysicsSystem::InitializeWater()
|
void dd::Systems::PhysicsSystem::InitializeWater()
|
||||||
@@ -62,17 +61,7 @@ bool dd::Systems::PhysicsSystem::SetImpulse(const Events::SetImpulse &event)
|
|||||||
|
|
||||||
void dd::Systems::PhysicsSystem::Update(double dt)
|
void dd::Systems::PhysicsSystem::Update(double dt)
|
||||||
{
|
{
|
||||||
if (Pause()) {
|
if (IsPaused()) {
|
||||||
if (HitLag()) {
|
|
||||||
m_HitLagTimer += dt;
|
|
||||||
std::cout << m_HitLagTimer << std::endl;
|
|
||||||
if (m_HitLagPlacement < m_HitLagTimer) {
|
|
||||||
m_HitLagTimer = 0;
|
|
||||||
SetHitLag(false);
|
|
||||||
Events::Pause e;
|
|
||||||
EventBroker->Publish(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -190,7 +179,7 @@ void dd::Systems::PhysicsSystem::UpdateEntity(double dt, EntityID entity, Entity
|
|||||||
|
|
||||||
bool dd::Systems::PhysicsSystem::OnPause(const dd::Events::Pause &event)
|
bool dd::Systems::PhysicsSystem::OnPause(const dd::Events::Pause &event)
|
||||||
{
|
{
|
||||||
if (Pause()) {
|
if (IsPaused()) {
|
||||||
SetPause(false);
|
SetPause(false);
|
||||||
} else {
|
} else {
|
||||||
SetPause(true);
|
SetPause(true);
|
||||||
@@ -198,17 +187,6 @@ bool dd::Systems::PhysicsSystem::OnPause(const dd::Events::Pause &event)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool dd::Systems::PhysicsSystem::OnHitLag(const dd::Events::HitLag &event)
|
|
||||||
{
|
|
||||||
SetHitLag(true);
|
|
||||||
Events::Pause e;
|
|
||||||
EventBroker->Publish(e);
|
|
||||||
m_HitLagPlacement = event.Time + 10;
|
|
||||||
m_SlowdownTime = event.SlowdownTime;
|
|
||||||
m_HitLagTimer = m_SlowdownTime;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void dd::Systems::PhysicsSystem::OnEntityCommit(EntityID entity)
|
void dd::Systems::PhysicsSystem::OnEntityCommit(EntityID entity)
|
||||||
{
|
{
|
||||||
auto physicsComponent = m_World->GetComponent<Components::Physics>(entity);
|
auto physicsComponent = m_World->GetComponent<Components::Physics>(entity);
|
||||||
|
|||||||
Reference in New Issue
Block a user