diff --git a/src/Game/Systems/AmmoPickupSystem.cpp b/src/Game/Systems/AmmoPickupSystem.cpp index 26f31a3e..a4a8d76a 100644 --- a/src/Game/Systems/AmmoPickupSystem.cpp +++ b/src/Game/Systems/AmmoPickupSystem.cpp @@ -11,10 +11,10 @@ void AmmoPickupSystem::Update(double dt) { for (auto it = m_ETriggerTouchVector.begin(); it != m_ETriggerTouchVector.end(); ++it) { - auto& ammoPickupPosition = *it; + auto& somePickup = *it; //set the double timer value (value 3) - ammoPickupPosition.DecreaseThisRespawnTimer -= dt; - if (ammoPickupPosition.DecreaseThisRespawnTimer < 0.0) { + somePickup.DecreaseThisRespawnTimer -= dt; + if (somePickup.DecreaseThisRespawnTimer < 0.0) { //spawn and delete the vector item auto entityFile = ResourceManager::Load("Schema/Entities/AmmoPickup.xml"); EntityFileParser parser(entityFile); @@ -27,12 +27,12 @@ void AmmoPickupSystem::Update(double dt) //set values from the old entity to the new entity auto& newAmmoPickupEntity = EntityWrapper(m_World, ammoPickupID); - newAmmoPickupEntity["Transform"]["Position"] = ammoPickupPosition.Pos; - newAmmoPickupEntity["AmmoPickup"]["AmmoGain"] = ammoPickupPosition.AmmoGain; - newAmmoPickupEntity["AmmoPickup"]["RespawnTimer"] = ammoPickupPosition.RespawnTimer; - m_World->SetParent(newAmmoPickupEntity.ID, ammoPickupPosition.parentID); + newAmmoPickupEntity["Transform"]["Position"] = somePickup.Pos; + newAmmoPickupEntity["AmmoPickup"]["AmmoGain"] = somePickup.AmmoGain; + newAmmoPickupEntity["AmmoPickup"]["RespawnTimer"] = somePickup.RespawnTimer; + m_World->SetParent(newAmmoPickupEntity.ID, somePickup.parentID); - //erase the current element (AmmoPickupPosition) + //erase the current element (somePickup) m_ETriggerTouchVector.erase(it); break; } @@ -51,10 +51,8 @@ void AmmoPickupSystem::Update(double dt) } } - } - bool AmmoPickupSystem::OnTriggerTouch(Events::TriggerTouch& e) { if (e.Entity != LocalPlayer) { @@ -85,7 +83,6 @@ bool AmmoPickupSystem::OnTriggerLeave(Events::TriggerLeave& e) { break; } - } return true; } diff --git a/src/Game/Systems/DamageIndicatorSystem.cpp b/src/Game/Systems/DamageIndicatorSystem.cpp index 92fbe607..321cc0f2 100644 --- a/src/Game/Systems/DamageIndicatorSystem.cpp +++ b/src/Game/Systems/DamageIndicatorSystem.cpp @@ -19,6 +19,9 @@ void DamageIndicatorSystem::Update(double dt) { updateDamageIndicatorVector.erase(iter); break; } + if (!EntityWrapper(m_World,m_World->GetParent(LocalPlayer.ID)).Valid()) { + return; + } auto angleBetweenVectors = CalculateAngle(LocalPlayer, iter->enemyPosition); //simply set the rotation z-wise to the angleBetweenVectors iter->spriteEntity["Transform"]["Orientation"] = glm::vec3(0, 0, angleBetweenVectors); diff --git a/src/Game/Systems/HealthPickupSystem.cpp b/src/Game/Systems/HealthPickupSystem.cpp index 621fea37..14b2950c 100644 --- a/src/Game/Systems/HealthPickupSystem.cpp +++ b/src/Game/Systems/HealthPickupSystem.cpp @@ -11,10 +11,10 @@ void HealthPickupSystem::Update(double dt) { for (auto it = m_ETriggerTouchVector.begin(); it != m_ETriggerTouchVector.end(); ++it) { - auto& healthPickupPosition = *it; + auto& somePickup = *it; //set the double timer value (value 3) - healthPickupPosition.DecreaseThisRespawnTimer -= dt; - if (healthPickupPosition.DecreaseThisRespawnTimer < 0) { + somePickup.DecreaseThisRespawnTimer -= dt; + if (somePickup.DecreaseThisRespawnTimer < 0) { //spawn and delete the vector item auto entityFile = ResourceManager::Load("Schema/Entities/HealthPickup.xml"); EntityFileParser parser(entityFile); @@ -27,12 +27,13 @@ void HealthPickupSystem::Update(double dt) //set values from the old entity to the new entity auto& newHealthPickupEntity = EntityWrapper(m_World, healthPickupID); - newHealthPickupEntity["Transform"]["Position"] = healthPickupPosition.Pos; - newHealthPickupEntity["HealthPickup"]["HealthGain"] = healthPickupPosition.HealthGain; - newHealthPickupEntity["HealthPickup"]["RespawnTimer"] = healthPickupPosition.RespawnTimer; - m_World->SetParent(newHealthPickupEntity.ID, healthPickupPosition.parentID); - - //erase the current element (healthPickupPosition) + LOG_INFO("healthpickup id %i", healthPickupID); + newHealthPickupEntity["Transform"]["Position"] = somePickup.Pos; + newHealthPickupEntity["HealthPickup"]["HealthGain"] = somePickup.HealthGain; + newHealthPickupEntity["HealthPickup"]["RespawnTimer"] = somePickup.RespawnTimer; + m_World->SetParent(newHealthPickupEntity.ID, somePickup.parentID); + LOG_INFO("healthpickup parented to %i", somePickup.parentID); + //erase the current element (somePickup) m_ETriggerTouchVector.erase(it); break; } @@ -45,24 +46,27 @@ void HealthPickupSystem::Update(double dt) } if ((double)it->player["Health"]["Health"] < (double)it->player["Health"]["MaxHealth"]) { + LOG_INFO("maxhealth found in pickupmax.. yada yada"); DoPickup(it->player, it->pickup); m_PickupAtMaximum.erase(it); break; - } } } bool HealthPickupSystem::OnTriggerTouch(Events::TriggerTouch& e) { + LOG_INFO("OnTriggerTouch"); if (!e.Trigger.HasComponent("HealthPickup")) { return false; } //cant pick up healthpacks if you are already at MaxHealth if ((double)e.Entity["Health"]["Health"] >= (double)e.Entity["Health"]["MaxHealth"]) { + LOG_INFO("trigger enter at maxhealth"); m_PickupAtMaximum.push_back({ e.Entity, e.Trigger }); return false; } + LOG_INFO("touch doing pickup"); DoPickup(e.Entity, e.Trigger); return true; @@ -86,11 +90,13 @@ void HealthPickupSystem::DoPickup(EntityWrapper &player, EntityWrapper &trigger) ePlayerHealthPickup.HealthAmount = healthGiven; ePlayerHealthPickup.Player = player; m_EventBroker->Publish(ePlayerHealthPickup); + LOG_INFO("event published"); //copy position, healthgain, respawntimer (twice since one of the values will be counted down to 0, the other will be set in the new object) //we need to copy all values since each value can be different for each healthPickup m_ETriggerTouchVector.push_back({ (glm::vec3)trigger["Transform"]["Position"] ,trigger["HealthPickup"]["HealthGain"], trigger["HealthPickup"]["RespawnTimer"],trigger["HealthPickup"]["RespawnTimer"], m_World->GetParent(trigger.ID) }); + LOG_INFO("pickup set id to %i", trigger.ID); //delete the healthpickup m_World->DeleteEntity(trigger.ID);