Made AmmunitionHUD into TextFieldReader which reads any component field on a parent and updates a Text component with the value!
This commit is contained in:
@@ -27,6 +27,7 @@ struct EntityWrapper
|
||||
bool HasComponent(const std::string& componentType);
|
||||
void AttachComponent(const char* componentName);
|
||||
EntityWrapper Parent();
|
||||
EntityWrapper FirstParentByName(const std::string& parentEntityName);
|
||||
EntityWrapper FirstChildByName(const std::string& name);
|
||||
EntityWrapper FirstParentWithComponent(const std::string& componentType);
|
||||
EntityWrapper Clone(EntityWrapper parent = EntityWrapper::Invalid);
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
#ifndef AmmunitionHUDSystem_h__
|
||||
#define AmmunitionHUDSystem_h__
|
||||
|
||||
#include "../../Engine/Core/System.h"
|
||||
#include "../../Engine/GLM.h"
|
||||
|
||||
class AmmunitionHUDSystem : public ImpureSystem
|
||||
{
|
||||
public:
|
||||
AmmunitionHUDSystem(SystemParams params)
|
||||
: System(params)
|
||||
{ }
|
||||
|
||||
virtual void Update(double dt) override;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,19 @@
|
||||
#ifndef AmmunitionHUDSystem_h__
|
||||
#define AmmunitionHUDSystem_h__
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include "../../Engine/Core/System.h"
|
||||
#include "../../Engine/GLM.h"
|
||||
|
||||
class TextFieldReader : public PureSystem
|
||||
{
|
||||
public:
|
||||
TextFieldReader(SystemParams params)
|
||||
: System(params)
|
||||
, PureSystem("TextFieldReader")
|
||||
{ }
|
||||
|
||||
virtual void UpdateComponent(EntityWrapper& entity, ComponentWrapper& cTextFieldReader, double dt) override;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -45,7 +45,7 @@
|
||||
<xs:include schemaLocation="Components/Sprite.xsd"/>
|
||||
<xs:include schemaLocation="Components/Shielded.xsd"/>
|
||||
<xs:include schemaLocation="Components/CapturePointHUD.xsd"/>
|
||||
<xs:include schemaLocation="Components/AmmunitionHUD.xsd"/>
|
||||
<xs:include schemaLocation="Components/TextFieldReader.xsd"/>
|
||||
<xs:include schemaLocation="Components/Menu.xsd"/>
|
||||
<xs:include schemaLocation="Components/KillFeed.xsd"/>
|
||||
<xs:include schemaLocation="Components/Page.xsd"/>
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||
<AmmunitionHUD xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="AmmunitionHUD.xsd">
|
||||
</AmmunitionHUD>
|
||||
@@ -1,10 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:t="types">
|
||||
<xs:import schemaLocation="../Types.xsd" namespace="types"/>
|
||||
<xs:include schemaLocation="../Types/TeamEnum.xsd"/>
|
||||
<xs:element name="AmmunitionHUD">
|
||||
<xs:annotation>
|
||||
<xs:documentation>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>
|
||||
</xs:annotation>
|
||||
</xs:element>
|
||||
</xs:schema>
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||
<TextFieldReader xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="TextFieldReader.xsd">
|
||||
<ParentEntityName></ParentEntityName>
|
||||
<ComponentType></ComponentType>
|
||||
<Field></Field>
|
||||
</TextFieldReader>
|
||||
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0"?>
|
||||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:t="types">
|
||||
<xs:import schemaLocation="../Types.xsd" namespace="types"/>
|
||||
|
||||
<xs:element name="TextFieldReader">
|
||||
<xs:annotation><xs:documentation>Reads a value from a specific field of a compoent of parent entity and writes it to the Text component on this entity.</xs:documentation></xs:annotation>
|
||||
<xs:complexType>
|
||||
<xs:all>
|
||||
<xs:element name="ParentEntityName" type="t:string" minOccurs="0">
|
||||
<xs:annotation><xs:documentation>The name of the parent entity to read the component field from. Leave empty to read from this entity.</xs:documentation></xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element name="ComponentType" type="t:string" minOccurs="0">
|
||||
<xs:annotation><xs:documentation>The component type to read the field value from.</xs:documentation></xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element name="Field" type="t:string" minOccurs="0">
|
||||
<xs:annotation><xs:documentation>The field name to read the value from.</xs:documentation></xs:annotation>
|
||||
</xs:element>
|
||||
</xs:all>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:schema>
|
||||
@@ -33,7 +33,6 @@
|
||||
</Entity>
|
||||
<Entity name="AmmunitionHUD">
|
||||
<Components>
|
||||
<c:AmmunitionHUD/>
|
||||
<c:Transform>
|
||||
<Position X="-0.0490000024" Y="0.0520000011" Z="-0.063000001"/>
|
||||
<Scale X="0.400000006" Y="0.400000006" Z="0.400000006"/>
|
||||
@@ -61,8 +60,13 @@
|
||||
<Children>
|
||||
<Entity name="MagazineAmmo">
|
||||
<Components>
|
||||
<c:TextFieldReader>
|
||||
<ParentEntityName>Player</ParentEntityName>
|
||||
<ComponentType>DefenderWeapon</ComponentType>
|
||||
<Field>MagazineAmmo</Field>
|
||||
</c:TextFieldReader>
|
||||
<c:Text>
|
||||
<Content>32</Content>
|
||||
<Content>0</Content>
|
||||
<Resource>Fonts/DroidSans.ttf,64</Resource>
|
||||
<Color A="1" B="3.92156863" G="1.17647064" R="0"/>
|
||||
</c:Text>
|
||||
@@ -74,8 +78,13 @@
|
||||
</Entity>
|
||||
<Entity name="Ammo">
|
||||
<Components>
|
||||
<c:TextFieldReader>
|
||||
<ParentEntityName>Player</ParentEntityName>
|
||||
<ComponentType>DefenderWeapon</ComponentType>
|
||||
<Field>Ammo</Field>
|
||||
</c:TextFieldReader>
|
||||
<c:Text>
|
||||
<Content>360</Content>
|
||||
<Content>0</Content>
|
||||
<Resource>Fonts/DroidSans.ttf,64</Resource>
|
||||
<Color A="1" B="3.92156863" G="1.17647064" R="0"/>
|
||||
</c:Text>
|
||||
|
||||
@@ -7,9 +7,7 @@
|
||||
<Size X="1" Y="1.60000002" Z="1"/>
|
||||
</c:AABB>
|
||||
<c:Collidable/>
|
||||
<c:DefenderWeapon>
|
||||
<TimeSinceLastFire>102.85760837900634</TimeSinceLastFire>
|
||||
</c:DefenderWeapon>
|
||||
<c:DefenderWeapon/>
|
||||
<c:DoubleJump/>
|
||||
<c:SidearmWeapon/>
|
||||
<c:Health/>
|
||||
@@ -26,7 +24,7 @@
|
||||
</Team>
|
||||
</c:Team>
|
||||
<c:Transform>
|
||||
<Position X="-1.42731023" Y="0.0288832653" Z="3.63052702"/>
|
||||
<Position X="0" Y="0.0288832188" Z="2.64144421"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
|
||||
@@ -66,8 +64,8 @@
|
||||
<Components>
|
||||
<c:Sprite>
|
||||
<DiffuseTexture>Textures/Weapons/Crosshair/SmallThickHoleDot.png</DiffuseTexture>
|
||||
<DepthSort>false</DepthSort>
|
||||
<GlowMap></GlowMap>
|
||||
<DepthSort>false</DepthSort>
|
||||
</c:Sprite>
|
||||
<c:Transform>
|
||||
<Position X="0" Y="0" Z="0.200000003"/>
|
||||
@@ -90,42 +88,22 @@
|
||||
<c:Transform/>
|
||||
</Components>
|
||||
<Children>
|
||||
<Entity name="HealthText">
|
||||
<Components>
|
||||
<c:Fill>
|
||||
<Percentage>1</Percentage>
|
||||
<Color A="1" B="1" G="0" R="0"/>
|
||||
</c:Fill>
|
||||
<c:Text>
|
||||
<Content>100/100</Content>
|
||||
<Resource>Fonts/DroidSans.ttf,64</Resource>
|
||||
<Color A="0.505882382" B="3.92156863" G="1.17647064" R="0"/>
|
||||
</c:Text>
|
||||
<c:HealthHUD/>
|
||||
<c:Transform>
|
||||
<Position X="-0.355000019" Y="-0.203000009" Z="0.0410000011"/>
|
||||
<Scale X="0.0350000001" Y="0.0350000001" Z="0.0350000001"/>
|
||||
<Orientation X="0" Y="0.410000026" Z="0"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
<Entity name="HealthBar">
|
||||
<Components>
|
||||
<c:Fill>
|
||||
<Percentage>1</Percentage>
|
||||
<Color A="0.301960796" B="1" G="0" R="0"/>
|
||||
</c:Fill>
|
||||
<c:HealthHUD/>
|
||||
<c:Sprite>
|
||||
<DiffuseTexture>Textures/HealthHUD3.png</DiffuseTexture>
|
||||
<GlowMap></GlowMap>
|
||||
<Color A="0.588235319" B="0" G="0" R="0"/>
|
||||
</c:Sprite>
|
||||
<c:HealthHUD/>
|
||||
<c:Transform>
|
||||
<Position X="-0.263000011" Y="-0.185000002" Z="0"/>
|
||||
<Scale X="0.106000006" Y="0.333000004" Z="0.150000006"/>
|
||||
<Orientation X="5.87300014" Y="0" Z="4.71200037"/>
|
||||
<Scale X="0.106000006" Y="0.333000004" Z="0.150000006"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children>
|
||||
@@ -142,8 +120,8 @@
|
||||
</c:Fill>
|
||||
<c:Sprite>
|
||||
<DiffuseTexture>Textures/Core/White.png</DiffuseTexture>
|
||||
<DepthSort>false</DepthSort>
|
||||
<GlowMap></GlowMap>
|
||||
<DepthSort>false</DepthSort>
|
||||
<Color A="0.588235319" B="0.0392156877" G="0.184313729" R="0"/>
|
||||
</c:Sprite>
|
||||
<c:Transform>
|
||||
@@ -160,8 +138,8 @@
|
||||
</c:Fill>
|
||||
<c:Sprite>
|
||||
<DiffuseTexture>Textures/Core/White.png</DiffuseTexture>
|
||||
<DepthSort>false</DepthSort>
|
||||
<GlowMap></GlowMap>
|
||||
<DepthSort>false</DepthSort>
|
||||
<Color A="0.588235319" B="0.34117648" G="0.192156866" R="0"/>
|
||||
</c:Sprite>
|
||||
<c:Transform>
|
||||
@@ -178,8 +156,8 @@
|
||||
</c:Fill>
|
||||
<c:Sprite>
|
||||
<DiffuseTexture>Textures/Core/White.png</DiffuseTexture>
|
||||
<DepthSort>false</DepthSort>
|
||||
<GlowMap></GlowMap>
|
||||
<DepthSort>false</DepthSort>
|
||||
<Color A="0.588235319" B="0.121568628" G="0" R="0.443137258"/>
|
||||
</c:Sprite>
|
||||
<c:Transform>
|
||||
@@ -193,6 +171,26 @@
|
||||
</Entity>
|
||||
</Children>
|
||||
</Entity>
|
||||
<Entity name="HealthText">
|
||||
<Components>
|
||||
<c:Fill>
|
||||
<Percentage>1</Percentage>
|
||||
<Color A="1" B="1" G="0" R="0"/>
|
||||
</c:Fill>
|
||||
<c:Text>
|
||||
<Content>100/100</Content>
|
||||
<Resource>Fonts/DroidSans.ttf,64</Resource>
|
||||
<Color A="0.505882382" B="3.92156863" G="1.17647064" R="0"/>
|
||||
</c:Text>
|
||||
<c:HealthHUD/>
|
||||
<c:Transform>
|
||||
<Position X="-0.355000019" Y="-0.203000009" Z="0.0410000011"/>
|
||||
<Orientation X="0" Y="0.410000026" Z="0"/>
|
||||
<Scale X="0.0350000001" Y="0.0350000001" Z="0.0350000001"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
</Children>
|
||||
</Entity>
|
||||
<Entity name="CapturePointHUD">
|
||||
@@ -229,8 +227,8 @@
|
||||
</c:Sprite>
|
||||
<c:Transform>
|
||||
<Position X="0" Y="0" Z="0.00999999978"/>
|
||||
<Scale X="0.800000012" Y="0.800000012" Z="0.800000012"/>
|
||||
<Orientation X="0" Y="0" Z="1.57079637"/>
|
||||
<Scale X="0.800000012" Y="0.800000012" Z="0.800000012"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children/>
|
||||
@@ -263,8 +261,8 @@
|
||||
</c:Sprite>
|
||||
<c:Transform>
|
||||
<Position X="0" Y="0" Z="0.00999999978"/>
|
||||
<Scale X="0.800000012" Y="0.800000012" Z="0.800000012"/>
|
||||
<Orientation X="0" Y="0" Z="1.57079637"/>
|
||||
<Scale X="0.800000012" Y="0.800000012" Z="0.800000012"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children/>
|
||||
@@ -298,8 +296,8 @@
|
||||
</c:Sprite>
|
||||
<c:Transform>
|
||||
<Position X="0" Y="0" Z="0.00999999978"/>
|
||||
<Scale X="0.800000012" Y="0.800000012" Z="0.800000012"/>
|
||||
<Orientation X="0" Y="0" Z="1.57079637"/>
|
||||
<Scale X="0.800000012" Y="0.800000012" Z="0.800000012"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children/>
|
||||
@@ -332,8 +330,8 @@
|
||||
</c:Sprite>
|
||||
<c:Transform>
|
||||
<Position X="0" Y="0" Z="0.00999999978"/>
|
||||
<Scale X="0.800000012" Y="0.800000012" Z="0.800000012"/>
|
||||
<Orientation X="0" Y="0" Z="1.57079637"/>
|
||||
<Scale X="0.800000012" Y="0.800000012" Z="0.800000012"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children/>
|
||||
@@ -365,8 +363,8 @@
|
||||
</c:Sprite>
|
||||
<c:Transform>
|
||||
<Position X="0" Y="0" Z="0.00999999978"/>
|
||||
<Scale X="0.800000012" Y="0.800000012" Z="0.800000012"/>
|
||||
<Orientation X="0" Y="0" Z="4.71238899"/>
|
||||
<Scale X="0.800000012" Y="0.800000012" Z="0.800000012"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children/>
|
||||
@@ -442,8 +440,8 @@
|
||||
</c:Team>
|
||||
<c:Transform>
|
||||
<Position X="0" Y="0.714000046" Z="-1.30000007"/>
|
||||
<Scale X="0.200000003" Y="0.200000003" Z="0.200000003"/>
|
||||
<Orientation X="0.405680239" Y="0.369605929" Z="0"/>
|
||||
<Scale X="0.200000003" Y="0.200000003" Z="0.200000003"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children/>
|
||||
@@ -490,9 +488,8 @@
|
||||
<BoneName>R_Arm_Weapon_Joint</BoneName>
|
||||
</c:BoneAttachment>
|
||||
<c:WeaponAttachment>
|
||||
<Weapon>AssaultWeapon</Weapon>
|
||||
</c:WeaponAttachment>
|
||||
<Weapon>SidearmWeapon</Weapon>
|
||||
</c:WeaponAttachment>
|
||||
<c:Spawner>
|
||||
<EntityFile>Schema/Entities/SidearmWeaponView.xml</EntityFile>
|
||||
</c:Spawner>
|
||||
@@ -575,7 +572,10 @@
|
||||
<c:Spawner>
|
||||
<EntityFile>Schema/Entities/SidearmWeaponWorld.xml</EntityFile>
|
||||
</c:Spawner>
|
||||
<c:Transform/>
|
||||
<c:Transform>
|
||||
<Position X="0.156846598" Y="1.03287792" Z="-0.216207206"/>
|
||||
<Orientation X="-0.0626498386" Y="-0.0301200207" Z="0.12067578"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
@@ -617,8 +617,8 @@
|
||||
</c:Text>
|
||||
<c:Transform>
|
||||
<Position X="0.100000001" Y="1.50176644" Z="-0.248000011"/>
|
||||
<Scale X="0.100000001" Y="0.113000005" Z="0.5"/>
|
||||
<Orientation X="0" Y="3.14199996" Z="0"/>
|
||||
<Scale X="0.100000001" Y="0.113000005" Z="0.5"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children/>
|
||||
@@ -627,8 +627,8 @@
|
||||
<Components>
|
||||
<c:Sprite>
|
||||
<DiffuseTexture>Textures/Icons/Arrow.png</DiffuseTexture>
|
||||
<DepthSort>false</DepthSort>
|
||||
<GlowMap></GlowMap>
|
||||
<DepthSort>false</DepthSort>
|
||||
<Color A="1" B="1" G="0.309803933" R="0"/>
|
||||
</c:Sprite>
|
||||
<c:HiddenForLocalPlayer/>
|
||||
|
||||
@@ -24,7 +24,11 @@
|
||||
</Entity>
|
||||
<Entity name="AmmunitionHUD">
|
||||
<Components>
|
||||
<c:AmmunitionHUD/>
|
||||
<c:TextFieldReader>
|
||||
<ParentEntityName></ParentEntityName>
|
||||
<ComponentType></ComponentType>
|
||||
<Field></Field>
|
||||
</c:TextFieldReader>
|
||||
<c:Transform>
|
||||
<Position X="-0.0300000012" Y="0.077000007" Z="-0.063000001"/>
|
||||
<Scale X="0.400000006" Y="0.400000006" Z="0.400000006"/>
|
||||
@@ -52,6 +56,11 @@
|
||||
<Children>
|
||||
<Entity name="MagazineAmmo">
|
||||
<Components>
|
||||
<c:TextFieldReader>
|
||||
<ParentEntityName>Player</ParentEntityName>
|
||||
<ComponentType>SidearmWeapon</ComponentType>
|
||||
<Field>MagazineAmmo</Field>
|
||||
</c:TextFieldReader>
|
||||
<c:Text>
|
||||
<Content>16</Content>
|
||||
<Resource>Fonts/DroidSans.ttf,64</Resource>
|
||||
@@ -73,8 +82,8 @@
|
||||
</c:Text>
|
||||
<c:Transform>
|
||||
<Position X="0.0150000006" Y="-0.029000001" Z="0"/>
|
||||
<Scale X="0.0399999991" Y="0.0399999991" Z="0.0399999991"/>
|
||||
<Orientation X="0" Y="0" Z="1.5710001"/>
|
||||
<Scale X="0.0399999991" Y="0.0399999991" Z="0.0399999991"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children/>
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
<xs:element ref="c:Shield" minOccurs="0"/>
|
||||
<xs:element ref="c:Shielded" minOccurs="0"/>
|
||||
<xs:element ref="c:CapturePointHUD" minOccurs="0"/>
|
||||
<xs:element ref="c:AmmunitionHUD" minOccurs="0"/>
|
||||
<xs:element ref="c:TextFieldReader" minOccurs="0"/>
|
||||
<xs:element ref="c:KillFeed" minOccurs="0"/>
|
||||
<xs:element ref="c:Sprite" minOccurs="0"/>
|
||||
<xs:element ref="c:AnimationOffset" minOccurs="0"/>
|
||||
|
||||
@@ -34,6 +34,18 @@ EntityWrapper EntityWrapper::Parent()
|
||||
}
|
||||
}
|
||||
|
||||
EntityWrapper EntityWrapper::FirstParentByName(const std::string& parentEntityName)
|
||||
{
|
||||
EntityWrapper entity = *this;
|
||||
while (entity.Parent().Valid()) {
|
||||
entity = entity.Parent();
|
||||
if (entity.Name() == parentEntityName) {
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
return EntityWrapper::Invalid;
|
||||
}
|
||||
|
||||
EntityWrapper EntityWrapper::FirstChildByName(const std::string& name)
|
||||
{
|
||||
return firstChildByNameRecursive(name, this->ID);
|
||||
|
||||
+3
-3
@@ -27,7 +27,7 @@
|
||||
#include "../Engine/Core/UniformScaleSystem.h"
|
||||
#include "Rendering/AnimationSystem.h"
|
||||
#include "Network/MultiplayerSnapshotFilter.h"
|
||||
#include "Game/Systems/AmmunitionHUDSystem.h"
|
||||
#include "Game/Systems/TextFieldReader.h"
|
||||
#include "Game/Systems/CapturePointArrowHUDSystem.h"
|
||||
#include "Game/Systems/KillFeedSystem.h"
|
||||
#include "Game/Systems/BoostSystem.h"
|
||||
@@ -136,7 +136,7 @@ Game::Game(int argc, char* argv[])
|
||||
m_SystemPipeline->AddSystem<PickupSpawnSystem>(updateOrderLevel);
|
||||
m_SystemPipeline->AddSystem<AmmoPickupSystem>(updateOrderLevel);
|
||||
m_SystemPipeline->AddSystem<DamageIndicatorSystem>(updateOrderLevel);
|
||||
m_SystemPipeline->AddSystem<AmmunitionHUDSystem>(updateOrderLevel);
|
||||
m_SystemPipeline->AddSystem<TextFieldReader>(updateOrderLevel);
|
||||
m_SystemPipeline->AddSystem<CapturePointArrowHUDSystem>(updateOrderLevel);
|
||||
m_SystemPipeline->AddSystem<KillFeedSystem>(updateOrderLevel);
|
||||
m_SystemPipeline->AddSystem<LifetimeSystem>(updateOrderLevel);
|
||||
@@ -145,7 +145,7 @@ Game::Game(int argc, char* argv[])
|
||||
m_SystemPipeline->AddSystem<PickupSpawnSystem>(updateOrderLevel);
|
||||
m_SystemPipeline->AddSystem<AmmoPickupSystem>(updateOrderLevel);
|
||||
m_SystemPipeline->AddSystem<DamageIndicatorSystem>(updateOrderLevel);
|
||||
m_SystemPipeline->AddSystem<AmmunitionHUDSystem>(updateOrderLevel);
|
||||
m_SystemPipeline->AddSystem<TextFieldReader>(updateOrderLevel);
|
||||
m_SystemPipeline->AddSystem<KillFeedSystem>(updateOrderLevel);
|
||||
m_SystemPipeline->AddSystem<BoostSystem>(updateOrderLevel);
|
||||
m_SystemPipeline->AddSystem<ButtonSystem>(updateOrderLevel, m_Renderer);
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
#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"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
#include "Game/Systems/TextFieldReader.h"
|
||||
|
||||
void TextFieldReader::UpdateComponent(EntityWrapper& entity, ComponentWrapper& cAmmunitionHUD, double dt)
|
||||
{
|
||||
if (!entity.HasComponent("Text")) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Find the entity to read from
|
||||
const std::string& parentEntityName = cAmmunitionHUD["ParentEntityName"];
|
||||
EntityWrapper readEntity = entity;
|
||||
if (!parentEntityName.empty()) {
|
||||
readEntity = entity.FirstParentByName(parentEntityName);
|
||||
if (!readEntity.Valid()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Find the component to read from
|
||||
const std::string& componentType = cAmmunitionHUD["ComponentType"];
|
||||
if (componentType.empty() || !readEntity.HasComponent(componentType)) {
|
||||
return;
|
||||
}
|
||||
ComponentWrapper component = readEntity[componentType];
|
||||
|
||||
// Find the field to read from
|
||||
const std::string& fieldName = cAmmunitionHUD["Field"];
|
||||
if (fieldName.empty() || component.Info.Fields.count(fieldName) == 0) {
|
||||
return;
|
||||
}
|
||||
const ComponentInfo::Field_t& field = component.Info.Fields.at(fieldName);
|
||||
|
||||
std::string& text = entity["Text"]["Content"];
|
||||
|
||||
if (field.Type == "int") {
|
||||
text = boost::lexical_cast<std::string>((const int&)component[fieldName]);
|
||||
} else if (field.Type == "float") {
|
||||
text = boost::lexical_cast<std::string>((const float&)component[fieldName]);
|
||||
} else if (field.Type == "double") {
|
||||
text = boost::lexical_cast<std::string>((const double&)component[fieldName]);
|
||||
} else if (field.Type == "bool") {
|
||||
text = boost::lexical_cast<std::string>((const bool&)component[fieldName]);
|
||||
} else if (field.Type == "string") {
|
||||
text = (const std::string&)component[fieldName];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user