Lifebuoy created on brick transform after a small delay.
This commit is contained in:
@@ -47,6 +47,10 @@ public:
|
|||||||
private:
|
private:
|
||||||
bool m_Pause = false;
|
bool m_Pause = false;
|
||||||
EntityID m_Template;
|
EntityID m_Template;
|
||||||
|
Events::Lifebuoy m_SavedEvent;
|
||||||
|
bool m_Lifebuoy = false;
|
||||||
|
float m_Timer;
|
||||||
|
float m_WaitingTime = 0.4;
|
||||||
|
|
||||||
dd::EventRelay<LifebuoySystem, dd::Events::Contact> m_EContact;
|
dd::EventRelay<LifebuoySystem, dd::Events::Contact> m_EContact;
|
||||||
dd::EventRelay<LifebuoySystem, dd::Events::Pause> m_EPause;
|
dd::EventRelay<LifebuoySystem, dd::Events::Pause> m_EPause;
|
||||||
@@ -58,6 +62,7 @@ private:
|
|||||||
bool OnPause(const dd::Events::Pause &event);
|
bool OnPause(const dd::Events::Pause &event);
|
||||||
bool OnResume(const dd::Events::Resume &event);
|
bool OnResume(const dd::Events::Resume &event);
|
||||||
bool OnLifebuoy(const dd::Events::Lifebuoy &event);
|
bool OnLifebuoy(const dd::Events::Lifebuoy &event);
|
||||||
|
bool Lifebuoy(const dd::Events::Lifebuoy &event);
|
||||||
bool OnLifebuoyHit(const dd::Events::LifebuoyHit &event);
|
bool OnLifebuoyHit(const dd::Events::LifebuoyHit &event);
|
||||||
|
|
||||||
struct LifebuoyInfo
|
struct LifebuoyInfo
|
||||||
|
|||||||
@@ -792,7 +792,7 @@ void dd::Systems::LevelSystem::GetBrickSet(int set, int setCluster) // These are
|
|||||||
if (set == 1) {
|
if (set == 1) {
|
||||||
level = // The Butterfly
|
level = // The Butterfly
|
||||||
{4, 0, 0, 1, 0, 0, 1,
|
{4, 0, 0, 1, 0, 0, 1,
|
||||||
1, 6, 0, 1, 0, 6, 1,
|
1, 6, 0, 1, 0, 1, 1,
|
||||||
1, 1, 1, 6, 1, 1, 1,
|
1, 1, 1, 6, 1, 1, 1,
|
||||||
1, 1, 0, 1, 0, 1, 1,
|
1, 1, 0, 1, 0, 1, 1,
|
||||||
1, 0, 0, 1, 0, 0, 1,
|
1, 0, 0, 1, 0, 0, 1,
|
||||||
@@ -841,7 +841,7 @@ void dd::Systems::LevelSystem::GetBrickSet(int set, int setCluster) // These are
|
|||||||
0, 0, 0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0, 0, 0,
|
||||||
1, 6, 1, 1, 1, 1, 1,
|
1, 6, 1, 1, 1, 1, 1,
|
||||||
0, 0, 0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0, 0, 0,
|
||||||
1, 3, 1, 1, 1, 1, 5 };
|
1, 3, 1, 1, 1, 1, 1 };
|
||||||
color =
|
color =
|
||||||
{m, m, m, m, m, m, m,
|
{m, m, m, m, m, m, m,
|
||||||
m, m, m, m, m, m, m,
|
m, m, m, m, m, m, m,
|
||||||
|
|||||||
@@ -76,6 +76,19 @@ void dd::Systems::LifebuoySystem::Update(double dt)
|
|||||||
++it;
|
++it;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (IsPaused()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_Lifebuoy) {
|
||||||
|
m_Timer += dt;
|
||||||
|
if (m_Timer > m_WaitingTime) {
|
||||||
|
m_Timer = 0;
|
||||||
|
m_Lifebuoy = false;
|
||||||
|
Lifebuoy(m_SavedEvent);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void dd::Systems::LifebuoySystem::UpdateEntity(double dt, EntityID entity, EntityID parent)
|
void dd::Systems::LifebuoySystem::UpdateEntity(double dt, EntityID entity, EntityID parent)
|
||||||
@@ -113,7 +126,14 @@ bool dd::Systems::LifebuoySystem::OnContact(const dd::Events::Contact &event)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool dd::Systems::LifebuoySystem::OnLifebuoy(const dd::Events::Lifebuoy &event)
|
bool dd::Systems::LifebuoySystem::OnLifebuoy(const dd::Events::Lifebuoy &event)
|
||||||
|
{
|
||||||
|
m_Lifebuoy = true;
|
||||||
|
m_SavedEvent = event;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool dd::Systems::LifebuoySystem::Lifebuoy(const dd::Events::Lifebuoy &event)
|
||||||
{
|
{
|
||||||
auto ent = m_World->CloneEntity(m_Template);
|
auto ent = m_World->CloneEntity(m_Template);
|
||||||
m_World->SetProperty(ent, "Name", "Lifebuoy");
|
m_World->SetProperty(ent, "Name", "Lifebuoy");
|
||||||
@@ -121,7 +141,8 @@ bool dd::Systems::LifebuoySystem::OnLifebuoy(const dd::Events::Lifebuoy &event)
|
|||||||
auto transform = m_World->GetComponent<Components::Transform>(ent);
|
auto transform = m_World->GetComponent<Components::Transform>(ent);
|
||||||
auto physics = m_World->GetComponent<Components::Physics>(ent);
|
auto physics = m_World->GetComponent<Components::Physics>(ent);
|
||||||
physics->CollisionType = CollisionType::Type::Dynamic;
|
physics->CollisionType = CollisionType::Type::Dynamic;
|
||||||
transform->Position = glm::vec3(0.f, 0.f, -10.f);
|
//transform->Position = glm::vec3(0.f, 0.f, -10.f);
|
||||||
|
transform->Position = event.Transform->Position;
|
||||||
transform->Velocity = glm::vec3(20.f, 3.f, 0.f);
|
transform->Velocity = glm::vec3(20.f, 3.f, 0.f);
|
||||||
LifebuoyInfo info;
|
LifebuoyInfo info;
|
||||||
info.Entity = ent;
|
info.Entity = ent;
|
||||||
|
|||||||
Reference in New Issue
Block a user