AmmunitionHUDSystem now really working
This commit is contained in:
+1
-1
Submodule assets updated: dfa0fc61ab...4d36fdced7
@@ -274,7 +274,7 @@
|
||||
<Components>
|
||||
<c:Animation>
|
||||
<AnimationName1>Idle</AnimationName1>
|
||||
<Time1>0.14471987707210765</Time1>
|
||||
<Time1>1.9901368826444736</Time1>
|
||||
<Speed1>1</Speed1>
|
||||
</c:Animation>
|
||||
<c:Model>
|
||||
@@ -293,8 +293,8 @@
|
||||
<Resource>Models/Weapons/Blue/AssaultWeaponBlue.mesh</Resource>
|
||||
</c:Model>
|
||||
<c:Transform>
|
||||
<Position X="0.120748006" Y="-0.22884047" Z="-0.151475668"/>
|
||||
<Orientation X="0.0104047209" Y="-0.00268167304" Z="0.0428441539"/>
|
||||
<Position X="0.1204307" Y="-0.228444979" Z="-0.181454539"/>
|
||||
<Orientation X="0.0104046259" Y="-0.00268158666" Z="0.042844139"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children>
|
||||
@@ -313,8 +313,9 @@
|
||||
<Components>
|
||||
<c:AmmunitionHUD/>
|
||||
<c:Transform>
|
||||
<Position X="-0.0778689086" Y="0.131501317" Z="-0.102981597"/>
|
||||
<Scale X="0.5" Y="0.5" Z="0.5"/>
|
||||
<Position X="-0.0430000015" Y="0.131501317" Z="-0.0670000017"/>
|
||||
<Scale X="0.400000006" Y="0.400000006" Z="0.400000006"/>
|
||||
<Orientation X="0" Y="5.96400023" Z="0"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children>
|
||||
@@ -371,7 +372,7 @@
|
||||
<Components>
|
||||
<c:Animation>
|
||||
<AnimationName1>Idle</AnimationName1>
|
||||
<Time1>1.7139414005989018</Time1>
|
||||
<Time1>0.22602443705505681</Time1>
|
||||
<Speed1>1</Speed1>
|
||||
</c:Animation>
|
||||
<c:AnimationOffset>
|
||||
@@ -395,8 +396,8 @@
|
||||
<Resource>Models/Weapons/Blue/AssaultWeaponBlue.mesh</Resource>
|
||||
</c:Model>
|
||||
<c:Transform>
|
||||
<Position X="0.159483925" Y="1.02719605" Z="-0.215205371"/>
|
||||
<Orientation X="-0.0627003834" Y="-0.0396405011" Z="0.119765028"/>
|
||||
<Position X="0.158905044" Y="1.03055489" Z="-0.216114596"/>
|
||||
<Orientation X="-0.0626663715" Y="-0.0375495031" Z="0.119906023"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children>
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
#include "Game/Systems/AmmunitionHUDSystem.h"
|
||||
|
||||
void AmmunitionHUDSystem::Update(double dt)
|
||||
{
|
||||
//Hud element for tracking ammunition from parent with AssaultWeapon component.Child with the name "MagazineAmmo" tracks clip ammunition.Child with the name "Ammo" tracks ammo.</xs:documentation>
|
||||
|
||||
auto ammunitionHUDs = m_World->GetComponents("AmmunitionHUD");
|
||||
if (ammunitionHUDs == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (auto& ammunitionHUDComponent : *ammunitionHUDs) {
|
||||
EntityWrapper entity = EntityWrapper(m_World, ammunitionHUDComponent.EntityID);
|
||||
|
||||
EntityWrapper playerEntity = entity.FirstParentWithComponent("AssaultWeapon");
|
||||
|
||||
if (!playerEntity.Valid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
EntityWrapper magazineAmmo = entity.FirstChildByName("MagazineAmmo");
|
||||
if(magazineAmmo.Valid()) {
|
||||
if(magazineAmmo.HasComponent("Text")) {
|
||||
(std::string&)magazineAmmo["Text"]["Content"] = std::to_string((int)playerEntity["AssaultWeapon"]["MagazineAmmo"]);
|
||||
}
|
||||
}
|
||||
|
||||
EntityWrapper ammo = entity.FirstChildByName("Ammo");
|
||||
if (ammo.Valid()) {
|
||||
if (ammo.HasComponent("Text")) {
|
||||
(std::string&)ammo["Text"]["Content"] = std::to_string((int)playerEntity["AssaultWeapon"]["Ammo"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user