P-button pauses, H-button does 0.3 second HitLag.
This commit is contained in:
@@ -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