P-button pauses, H-button does 0.3 second HitLag.
This commit is contained in:
@@ -130,31 +130,6 @@ public:
|
||||
m_World->ComponentFactory.Register<Components::WaterVolume>();
|
||||
m_World->Initialize();
|
||||
|
||||
|
||||
//OctoBall
|
||||
{
|
||||
auto ent = m_World->CreateEntity();
|
||||
std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(ent);
|
||||
transform->Position = glm::vec3(-0.f, 0.26f, -10.f);
|
||||
transform->Scale = glm::vec3(0.5f, 0.5f, 0.5f);
|
||||
transform->Velocity = glm::vec3(0.0f, -10.f, 0.f);
|
||||
auto model = m_World->AddComponent<Components::Model>(ent);
|
||||
model->ModelFile = "Models/Test/Ball/Ballopus.obj";
|
||||
std::shared_ptr<Components::CircleShape> circleShape = m_World->AddComponent<Components::CircleShape>(ent);
|
||||
std::shared_ptr<Components::Ball> ball = m_World->AddComponent<Components::Ball>(ent);
|
||||
ball->Speed = 5.f;
|
||||
std::shared_ptr<Components::Physics> physics = m_World->AddComponent<Components::Physics>(ent);
|
||||
physics->Static = false;
|
||||
physics->Category = CollisionLayer::Type::Ball;
|
||||
physics->Mask = CollisionLayer::Type::Pad | CollisionLayer::Type::Brick | CollisionLayer::Type::Wall;
|
||||
physics->Calculate = true;
|
||||
|
||||
//auto plight = m_World->AddComponent<Components::PointLight>(ent);
|
||||
//plight->Radius = 2.f;
|
||||
|
||||
m_World->CommitEntity(ent);
|
||||
}
|
||||
|
||||
//PointLightTest
|
||||
{
|
||||
auto t_Light = m_World->CreateEntity();
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
#include "Game/EMultiBall.h"
|
||||
#include "Game/EMultiBallLost.h"
|
||||
#include "Game/EGameOver.h"
|
||||
#include "Game/EPause.h"
|
||||
#include "Game/EHitLag.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
@@ -75,6 +77,10 @@ public:
|
||||
void SetReplaceBall(const bool& replaceBall) { m_ReplaceBall = replaceBall; }
|
||||
bool MultiBall() const { return m_MultiBall; }
|
||||
void SetMultiBall(const bool& multiBall) { m_MultiBall = multiBall; }
|
||||
bool Pause() 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:
|
||||
float m_XMovementMultiplier = 2.f;
|
||||
@@ -85,6 +91,13 @@ private:
|
||||
int m_PastLives = 3;
|
||||
bool m_ReplaceBall = false;
|
||||
bool m_MultiBall = 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;
|
||||
|
||||
@@ -92,11 +105,15 @@ private:
|
||||
dd::EventRelay<BallSystem, dd::Events::MultiBallLost> m_EMultiBallLost;
|
||||
dd::EventRelay<BallSystem, dd::Events::ResetBall> m_EResetBall;
|
||||
dd::EventRelay<BallSystem, dd::Events::MultiBall> m_EMultiBall;
|
||||
dd::EventRelay<BallSystem, dd::Events::Pause> m_EPause;
|
||||
dd::EventRelay<BallSystem, dd::Events::HitLag> m_EHitLag;
|
||||
|
||||
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);
|
||||
bool OnPause(const dd::Events::Pause &event);
|
||||
bool OnHitLag(const dd::Events::HitLag &event);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
//
|
||||
// Created by Administrator on 2015-09-30.
|
||||
//
|
||||
|
||||
#ifndef DAYDREAM_EHITLAG_H
|
||||
#define DAYDREAM_EHITLAG_H
|
||||
|
||||
#include "Core/EventBroker.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
namespace Events
|
||||
{
|
||||
|
||||
struct HitLag : Event
|
||||
{
|
||||
float Time;
|
||||
std::string Type;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif //DAYDREAM_EHITLAG_H
|
||||
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// Created by Adniklastrator on 2015-09-30.
|
||||
//
|
||||
|
||||
#ifndef DAYDREAM_EPAUSE_H
|
||||
#define DAYDREAM_EPAUSE_H
|
||||
|
||||
#include "Core/EventBroker.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
namespace Events
|
||||
{
|
||||
|
||||
struct Pause : Event
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif //DAYDREAM_EPAUSE_H
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "Game/EComboEvent.h"
|
||||
#include "Game/EMultiBall.h"
|
||||
#include "Game/EMultiBallLost.h"
|
||||
#include "Game/EPause.h"
|
||||
#include "Game/EGameOver.h"
|
||||
#include "Game/ECreatePowerUp.h"
|
||||
#include "Game/EPowerUpTaken.h"
|
||||
@@ -80,6 +81,8 @@ public:
|
||||
void SetRestarting(const bool& restarting) { m_Restarting = restarting; }
|
||||
bool Initialized() const { return m_Initialized; }
|
||||
void SetInitialized(const bool& initialized) { m_Initialized = initialized; }
|
||||
bool Pause() const { return m_Pause; }
|
||||
void SetPause(const bool& pause) { m_Pause = pause; }
|
||||
int& MultiBalls() { return m_MultiBalls; }
|
||||
void SetMultiBalls(const int& multiBalls) { m_MultiBalls = multiBalls; }
|
||||
int& PowerUps() { return m_PowerUps; }
|
||||
@@ -103,6 +106,7 @@ public:
|
||||
private:
|
||||
bool m_Restarting = false;
|
||||
bool m_Initialized = false;
|
||||
bool m_Pause = false;
|
||||
int m_MultiBalls = 0;
|
||||
int m_PowerUps = 0;
|
||||
int m_Score = 0;
|
||||
@@ -120,6 +124,7 @@ private:
|
||||
dd::EventRelay<LevelSystem, dd::Events::CreatePowerUp> m_ECreatePowerUp;
|
||||
dd::EventRelay<LevelSystem, dd::Events::PowerUpTaken> m_EPowerUpTaken;
|
||||
dd::EventRelay<LevelSystem, dd::Events::StageCleared> m_EStageCleared;
|
||||
dd::EventRelay<LevelSystem, dd::Events::Pause> m_EPause;
|
||||
|
||||
bool OnContact(const dd::Events::Contact &event);
|
||||
bool OnScoreEvent(const dd::Events::ScoreEvent &event);
|
||||
@@ -128,6 +133,7 @@ private:
|
||||
bool OnCreatePowerUp(const dd::Events::CreatePowerUp &event);
|
||||
bool OnPowerUpTaken(const dd::Events::PowerUpTaken &event);
|
||||
bool OnStageCleared(const dd::Events::StageCleared &event);
|
||||
bool OnPause(const dd::Events::Pause &event);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -28,6 +28,8 @@
|
||||
#include "Game/EMultiBall.h"
|
||||
#include "Game/EPowerUpTaken.h"
|
||||
#include "Game/EStageCleared.h"
|
||||
#include "Game/EPause.h"
|
||||
#include "Game/EHitLag.h"
|
||||
|
||||
|
||||
namespace dd
|
||||
@@ -63,6 +65,9 @@ public:
|
||||
Components::Pad* Pad() const { return m_Pad; }
|
||||
void SetPad(Components::Pad* pad) { m_Pad = pad; }
|
||||
|
||||
bool Pause() const { return m_Pause; }
|
||||
void SetPause(const bool& pause) { m_Pause = pause; }
|
||||
|
||||
private:
|
||||
EntityID m_Entity = 0;
|
||||
glm::vec3 m_Acceleration = glm::vec3(0.f, 0.f, 0.f);
|
||||
@@ -72,18 +77,21 @@ private:
|
||||
Components::Transform* m_Transform;
|
||||
Components::Pad* m_Pad;
|
||||
|
||||
bool m_Pause = false;
|
||||
|
||||
dd::EventRelay<PadSystem, dd::Events::KeyDown> m_EKeyDown;
|
||||
dd::EventRelay<PadSystem, dd::Events::KeyUp> m_EKeyUp;
|
||||
dd::EventRelay<PadSystem, dd::Events::Contact> m_EContact;
|
||||
dd::EventRelay<PadSystem, dd::Events::Contact> m_EContactPowerUp;
|
||||
dd::EventRelay<PadSystem, dd::Events::StageCleared> m_EStageCleared;
|
||||
dd::EventRelay<PadSystem, dd::Events::Pause> m_EPause;
|
||||
|
||||
bool OnKeyDown(const dd::Events::KeyDown &event);
|
||||
bool OnKeyUp(const dd::Events::KeyUp &event);
|
||||
|
||||
bool OnContact(const dd::Events::Contact &event);
|
||||
bool OnContactPowerUp(const dd::Events::Contact &event);
|
||||
bool OnStageCleared(const dd::Events::StageCleared &event);
|
||||
bool OnPause(const dd::Events::Pause &event);
|
||||
|
||||
class PadSteeringInputController;
|
||||
std::array<std::shared_ptr<PadSteeringInputController>, 4> m_PadInputControllers;
|
||||
|
||||
@@ -3,21 +3,23 @@
|
||||
|
||||
#include <unordered_map>
|
||||
|
||||
#include "Core/CTransform.h"
|
||||
#include "Core/System.h"
|
||||
#include "Core/World.h"
|
||||
#include "CRectangleShape.h"
|
||||
#include "Core/EventBroker.h"
|
||||
#include "Physics/CRectangleShape.h"
|
||||
#include "Physics/CCircleShape.h"
|
||||
#include "Physics/CPhysics.h"
|
||||
#include <Box2D/Box2D.h>
|
||||
#include "Core/CTransform.h"
|
||||
#include "Transform/TransformSystem.h"
|
||||
#include "Physics/CWaterVolume.h"
|
||||
#include "Physics/EContact.h"
|
||||
#include "Physics/ESetImpulse.h"
|
||||
#include "Physics/CCircleShape.h"
|
||||
#include "Core/EventBroker.h"
|
||||
#include "Game/EPause.h"
|
||||
#include "Game/EHitLag.h"
|
||||
#include "Game/CPad.h"
|
||||
#include "Physics/CWaterVolume.h"
|
||||
#include "Game/CBall.h"
|
||||
#include "Transform/TransformSystem.h"
|
||||
#include "Rendering/CSprite.h"
|
||||
#include <Box2D/Box2D.h>
|
||||
|
||||
|
||||
namespace dd
|
||||
@@ -54,11 +56,28 @@ public:
|
||||
// Called when an entity is removed
|
||||
void OnEntityRemoved(EntityID entity) override;
|
||||
|
||||
bool Pause() 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:
|
||||
b2Vec2 m_Gravity;
|
||||
b2World* m_PhysicsWorld;
|
||||
double m_TimeStep;
|
||||
double m_Accumulator;
|
||||
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::HitLag> m_EHitLag;
|
||||
bool OnPause(const dd::Events::Pause &event);
|
||||
bool OnHitLag(const dd::Events::HitLag &event);
|
||||
|
||||
int m_VelocityIterations, m_PositionIterations;
|
||||
|
||||
|
||||
@@ -18,26 +18,42 @@ void dd::Systems::BallSystem::Initialize()
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EMultiBallLost, &BallSystem::OnMultiBallLost);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EResetBall, &BallSystem::OnResetBall);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EMultiBall, &BallSystem::OnMultiBall);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EPause, &BallSystem::OnPause);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EHitLag, &BallSystem::OnHitLag);
|
||||
|
||||
auto ent = m_World->CreateEntity();
|
||||
std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(ent);
|
||||
transform->Position = glm::vec3(-0.f, 50.f, -10.f);
|
||||
transform->Scale = glm::vec3(0.5f, 0.5f, 0.5f);
|
||||
transform->Velocity = glm::vec3(0.0f, 0.f, 0.f);
|
||||
auto model = m_World->AddComponent<Components::Model>(ent);
|
||||
model->ModelFile = "Models/Test/Ball/Ballopus.obj";
|
||||
std::shared_ptr<Components::CircleShape> circleShape = m_World->AddComponent<Components::CircleShape>(ent);
|
||||
std::shared_ptr<Components::Ball> ball = m_World->AddComponent<Components::Ball>(ent);
|
||||
ball->Speed = 5.f;
|
||||
std::shared_ptr<Components::Physics> physics = m_World->AddComponent<Components::Physics>(ent);
|
||||
std::shared_ptr<Components::Template> ballTemplate = m_World->AddComponent<Components::Template>(ent);
|
||||
physics->Static = false;
|
||||
physics->Category = CollisionLayer::Type::Ball;
|
||||
physics->Mask = CollisionLayer::Type::Pad | CollisionLayer::Type::Brick | CollisionLayer::Type::Wall;
|
||||
physics->Calculate = true;
|
||||
m_World->CommitEntity(ent);
|
||||
//OctoBall
|
||||
{
|
||||
auto ent = m_World->CreateEntity();
|
||||
std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(ent);
|
||||
transform->Position = glm::vec3(-0.f, 50.26f, -10.f);
|
||||
transform->Scale = glm::vec3(0.5f, 0.5f, 0.5f);
|
||||
transform->Velocity = glm::vec3(0.f, 0.f, 0.f);
|
||||
auto model = m_World->AddComponent<Components::Model>(ent);
|
||||
model->ModelFile = "Models/Test/Ball/Ballopus.obj";
|
||||
std::shared_ptr<Components::CircleShape> circleShape = m_World->AddComponent<Components::CircleShape>(ent);
|
||||
std::shared_ptr<Components::Ball> ball = m_World->AddComponent<Components::Ball>(ent);
|
||||
ball->Speed = 5.f;
|
||||
std::shared_ptr<Components::Physics> physics = m_World->AddComponent<Components::Physics>(ent);
|
||||
std::shared_ptr<Components::Template> ballTemplate = m_World->AddComponent<Components::Template>(ent);
|
||||
physics->Static = false;
|
||||
physics->Category = CollisionLayer::Type::Ball;
|
||||
physics->Mask = CollisionLayer::Type::Pad | CollisionLayer::Type::Brick | CollisionLayer::Type::Wall;
|
||||
physics->Calculate = true;
|
||||
|
||||
SetBall(ent);
|
||||
//auto plight = m_World->AddComponent<Components::PointLight>(ent);
|
||||
//plight->Radius = 2.f;
|
||||
|
||||
m_World->CommitEntity(ent);
|
||||
|
||||
SetBall(ent);
|
||||
|
||||
auto ent2 = CreateBall();
|
||||
auto transform2 = m_World->GetComponent<Components::Transform>(ent2);
|
||||
transform2->Position = glm::vec3(-0.f, 0.26f, -10.f);
|
||||
transform2->Velocity = glm::vec3(0.0f, -10.f, 0.f);
|
||||
|
||||
m_World->CommitEntity(ent2);
|
||||
}
|
||||
|
||||
for (int i = 0; i < Lives(); i++) {
|
||||
CreateLife(i);
|
||||
@@ -52,10 +68,30 @@ void dd::Systems::BallSystem::Update(double dt)
|
||||
Events::GameOver 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)
|
||||
{
|
||||
if (Pause()) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto templateCheck = m_World->GetComponent<Components::Template>(entity);
|
||||
if (templateCheck != nullptr){ return; }
|
||||
auto ballComponent = m_World->GetComponent<Components::Ball>(entity);
|
||||
@@ -132,6 +168,29 @@ void dd::Systems::BallSystem::UpdateEntity(double dt, EntityID entity, EntityID
|
||||
}
|
||||
}
|
||||
|
||||
bool dd::Systems::BallSystem::OnPause(const dd::Events::Pause &event)
|
||||
{
|
||||
if (Pause()) {
|
||||
SetPause(false);
|
||||
} else {
|
||||
SetPause(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)
|
||||
{
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ void dd::Systems::LevelSystem::Initialize()
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EMultiBallLost, &LevelSystem::OnMultiBallLost);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EPowerUpTaken, &LevelSystem::OnPowerUpTaken);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EStageCleared, &LevelSystem::OnStageCleared);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EPause, &LevelSystem::OnPause);
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -30,6 +31,9 @@ void dd::Systems::LevelSystem::Update(double dt)
|
||||
|
||||
void dd::Systems::LevelSystem::UpdateEntity(double dt, EntityID entity, EntityID parent)
|
||||
{
|
||||
if (Pause()) {
|
||||
return;
|
||||
}
|
||||
auto templateCheck = m_World->GetComponent<Components::Template>(entity);
|
||||
if (templateCheck != nullptr){ return; }
|
||||
|
||||
@@ -71,6 +75,16 @@ void dd::Systems::LevelSystem::UpdateEntity(double dt, EntityID entity, EntityID
|
||||
}
|
||||
}
|
||||
|
||||
bool dd::Systems::LevelSystem::OnPause(const dd::Events::Pause &event)
|
||||
{
|
||||
if (Pause()) {
|
||||
SetPause(false);
|
||||
} else {
|
||||
SetPause(true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void dd::Systems::LevelSystem::CreateBasicLevel(int rows, int lines, glm::vec2 spacesBetweenBricks, float spaceToEdge)
|
||||
{
|
||||
SetNumberOfBricks(rows * lines);
|
||||
|
||||
@@ -27,6 +27,7 @@ void dd::Systems::PadSystem::Initialize()
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EContact, &PadSystem::OnContact);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EContactPowerUp, &PadSystem::OnContactPowerUp);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EStageCleared, &PadSystem::OnStageCleared);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EPause, &PadSystem::OnPause);
|
||||
|
||||
{
|
||||
auto ent = m_World->CreateEntity();
|
||||
@@ -58,6 +59,9 @@ void dd::Systems::PadSystem::UpdateEntity(double dt, EntityID entity, EntityID p
|
||||
|
||||
void dd::Systems::PadSystem::Update(double dt)
|
||||
{
|
||||
if (Pause()) {
|
||||
return;
|
||||
}
|
||||
if (Entity() == 0) {
|
||||
for (auto it = m_World->GetEntities()->begin(); it != m_World->GetEntities()->end(); it++) {
|
||||
if (m_World->GetProperty<std::string>(it->first, "Name") == "Pad") {
|
||||
@@ -105,6 +109,16 @@ void dd::Systems::PadSystem::Update(double dt)
|
||||
return;
|
||||
}
|
||||
|
||||
bool dd::Systems::PadSystem::OnPause(const dd::Events::Pause &event)
|
||||
{
|
||||
if (Pause()) {
|
||||
SetPause(false);
|
||||
} else {
|
||||
SetPause(true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dd::Systems::PadSystem::OnKeyDown(const dd::Events::KeyDown &event)
|
||||
{
|
||||
int val = event.KeyCode;
|
||||
@@ -127,6 +141,18 @@ bool dd::Systems::PadSystem::OnKeyDown(const dd::Events::KeyDown &event)
|
||||
Events::MultiBall e;
|
||||
e.padTransform = Transform();
|
||||
EventBroker->Publish(e);
|
||||
} else if (val == GLFW_KEY_P) {
|
||||
Events::Pause e;
|
||||
e.Time = 0;
|
||||
e.SlowdownTime = 0;
|
||||
e.Type = "All";
|
||||
EventBroker->Publish(e);
|
||||
} else if (val == GLFW_KEY_H) {
|
||||
Events::HitLag e;
|
||||
e.Time = 0.3;
|
||||
e.SlowdownTime = 10;
|
||||
e.Type = "All";
|
||||
EventBroker->Publish(e);
|
||||
} else if (val == GLFW_KEY_D) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -25,6 +25,8 @@ void dd::Systems::PhysicsSystem::Initialize()
|
||||
InitializeWater();
|
||||
|
||||
EVENT_SUBSCRIBE_MEMBER(m_SetImpulse, &PhysicsSystem::SetImpulse);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EPause, &PhysicsSystem::OnPause);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EHitLag, &PhysicsSystem::OnHitLag);
|
||||
}
|
||||
|
||||
void dd::Systems::PhysicsSystem::InitializeWater()
|
||||
@@ -60,6 +62,19 @@ bool dd::Systems::PhysicsSystem::SetImpulse(const Events::SetImpulse &event)
|
||||
|
||||
void dd::Systems::PhysicsSystem::Update(double dt)
|
||||
{
|
||||
if (Pause()) {
|
||||
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;
|
||||
}
|
||||
|
||||
m_Accumulator += dt;
|
||||
while(m_Accumulator >= m_TimeStep)
|
||||
@@ -173,6 +188,27 @@ void dd::Systems::PhysicsSystem::UpdateEntity(double dt, EntityID entity, Entity
|
||||
|
||||
}
|
||||
|
||||
bool dd::Systems::PhysicsSystem::OnPause(const dd::Events::Pause &event)
|
||||
{
|
||||
if (Pause()) {
|
||||
SetPause(false);
|
||||
} else {
|
||||
SetPause(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)
|
||||
{
|
||||
auto physicsComponent = m_World->GetComponent<Components::Physics>(entity);
|
||||
|
||||
Reference in New Issue
Block a user