Merge remote-tracking branch 'origin/master' into FixNetworkBugs
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
#include "Game/Systems/AbilityCooldownHUDSystem.h"
|
||||
|
||||
void AbilityCooldownHUDSystem::Update(double dt)
|
||||
{
|
||||
//HUD element for tracking cooldown on the parent entity with Dashability TODO: Make sure it support other abilities when they are made.
|
||||
|
||||
auto abilityHUDs = m_World->GetComponents("AbilityCooldownHUD");
|
||||
if (abilityHUDs == nullptr)
|
||||
return;
|
||||
|
||||
for (auto& abilityHUDC : *abilityHUDs) {
|
||||
EntityWrapper entity = EntityWrapper(m_World, abilityHUDC.EntityID);
|
||||
EntityWrapper abilityEntity = entity.FirstParentWithComponent("DashAbility");
|
||||
if (!abilityEntity.Valid())
|
||||
return;
|
||||
EntityWrapper cooldownTextEntity = entity.FirstChildByName("Cooldown");
|
||||
if(cooldownTextEntity.Valid()) {
|
||||
if(cooldownTextEntity.HasComponent("Text"))
|
||||
{
|
||||
double maxAbilityCD = (double)abilityEntity["DashAbility"]["CoolDownMaxTimer"];
|
||||
double currentAbilityCD = (double)abilityEntity["DashAbility"]["CoolDownTimer"];
|
||||
currentAbilityCD = currentAbilityCD >= 0.0 ? currentAbilityCD : 0.0;
|
||||
std::string t = (std::string&)cooldownTextEntity["Text"]["Content"] = std::to_string(currentAbilityCD).substr(0, 3);
|
||||
if(entity.HasComponent("Fill")) {
|
||||
entity["Fill"]["Percentage"] = currentAbilityCD/maxAbilityCD; //TODO: current time needs to be in the component.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,16 +21,15 @@ void AmmoPickupSystem::Update(double dt)
|
||||
somePickup.DecreaseThisRespawnTimer -= dt;
|
||||
if (somePickup.DecreaseThisRespawnTimer < 0.0) {
|
||||
auto entityFile = ResourceManager::Load<EntityFile>("Schema/Entities/AmmoPickup.xml");
|
||||
EntityFileParser parser(entityFile);
|
||||
EntityID ammoPickupID = parser.MergeEntities(m_World);
|
||||
EntityWrapper ammoPickup = entityFile->MergeInto(m_World);
|
||||
|
||||
//let the world know a pickup has spawned
|
||||
Events::PickupSpawned ePickupSpawned;
|
||||
ePickupSpawned.Pickup = EntityWrapper(m_World, ammoPickupID);
|
||||
ePickupSpawned.Pickup = ammoPickup;
|
||||
m_EventBroker->Publish(ePickupSpawned);
|
||||
|
||||
//copy values from the old entity to the new entity
|
||||
auto& newAmmoPickupEntity = EntityWrapper(m_World, ammoPickupID);
|
||||
auto& newAmmoPickupEntity = ammoPickup;
|
||||
newAmmoPickupEntity["Transform"]["Position"] = somePickup.Pos;
|
||||
newAmmoPickupEntity["AmmoPickup"]["AmmoGain"] = somePickup.AmmoGain;
|
||||
newAmmoPickupEntity["AmmoPickup"]["RespawnTimer"] = somePickup.RespawnTimer;
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
#include "Game/Systems/BoostIconsHUDSystem.h"
|
||||
|
||||
void BoostIconsHUDSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& capturePoint, double dt)
|
||||
{
|
||||
EntityWrapper assaultEntity = entity.FirstChildByName("Assault");
|
||||
EntityWrapper defenderEntity = entity.FirstChildByName("Defender");
|
||||
EntityWrapper sniperEntity = entity.FirstChildByName("Sniper");
|
||||
|
||||
if(assaultEntity.Valid()) {
|
||||
if (assaultEntity.HasComponent("Fill")) {
|
||||
EntityWrapper parentWithAssaultBoost = assaultEntity.FirstParentWithComponent("BoostAssault");
|
||||
if (parentWithAssaultBoost.Valid()) {
|
||||
(double&)assaultEntity["Fill"]["Percentage"] = 1.0;
|
||||
} else {
|
||||
(double&)assaultEntity["Fill"]["Percentage"] = 0.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (defenderEntity.Valid()) {
|
||||
if (defenderEntity.HasComponent("Fill")) {
|
||||
EntityWrapper parentWithAssaultBoost = defenderEntity.FirstParentWithComponent("BoostDefender");
|
||||
if (parentWithAssaultBoost.Valid()) {
|
||||
(double&)defenderEntity["Fill"]["Percentage"] = 1.0;
|
||||
} else {
|
||||
(double&)defenderEntity["Fill"]["Percentage"] = 0.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (sniperEntity.Valid()) {
|
||||
if (sniperEntity.HasComponent("Fill")) {
|
||||
EntityWrapper parentWithAssaultBoost = sniperEntity.FirstParentWithComponent("BoostSniper");
|
||||
if (parentWithAssaultBoost.Valid()) {
|
||||
(double&)sniperEntity["Fill"]["Percentage"] = 1.0;
|
||||
} else {
|
||||
(double&)sniperEntity["Fill"]["Percentage"] = 0.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,10 +39,9 @@ bool BoostSystem::OnPlayerDamage(Events::PlayerDamage& e)
|
||||
}
|
||||
//load boost XML file, set it entity parented with the victim player
|
||||
auto entityFile = ResourceManager::Load<EntityFile>(classXML);
|
||||
EntityFileParser parser(entityFile);
|
||||
EntityID boostAssaultEntity = parser.MergeEntities(m_World);
|
||||
m_World->SetName(boostAssaultEntity, className);
|
||||
m_World->SetParent(boostAssaultEntity, e.Victim.ID);
|
||||
EntityWrapper boostAssaultEntity = entityFile->MergeInto(m_World);
|
||||
m_World->SetName(boostAssaultEntity.ID, className);
|
||||
m_World->SetParent(boostAssaultEntity.ID, e.Victim.ID);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ DamageIndicatorSystem::DamageIndicatorSystem(SystemParams params)
|
||||
|
||||
//load texture to cache
|
||||
auto texture = CommonFunctions::LoadTexture("Textures/DamageIndicator.png", false);
|
||||
auto entityFile = ResourceManager::Load<EntityFile>("Schema/Entities/DamageIndicator.xml");
|
||||
auto entityFile = ResourceManager::Load<EntityXMLFile>("Schema/Entities/DamageIndicator.xml");
|
||||
}
|
||||
|
||||
void DamageIndicatorSystem::Update(double dt) {
|
||||
@@ -50,15 +50,13 @@ bool DamageIndicatorSystem::OnPlayerDamage(Events::PlayerDamage& e)
|
||||
|
||||
//load & set the "2d" sprite
|
||||
auto entityFile = ResourceManager::Load<EntityFile>("Schema/Entities/DamageIndicator.xml");
|
||||
EntityFileParser parser(entityFile);
|
||||
EntityID spriteID = parser.MergeEntities(m_World);
|
||||
m_World->SetParent(spriteID, m_CurrentCamera);
|
||||
auto spriteWrapper = EntityWrapper(m_World, spriteID);
|
||||
EntityWrapper sprite = entityFile->MergeInto(m_World);
|
||||
m_World->SetParent(sprite.ID, m_CurrentCamera);
|
||||
//simply set the rotation z-wise to the angleBetweenVectors
|
||||
spriteWrapper["Transform"]["Orientation"] = glm::vec3(0, 0, angleBetweenVectors);
|
||||
sprite["Transform"]["Orientation"] = glm::vec3(0, 0, angleBetweenVectors);
|
||||
|
||||
if (!IsServer) {
|
||||
updateDamageIndicatorVector.emplace_back(spriteWrapper, inflictorPos);
|
||||
updateDamageIndicatorVector.emplace_back(sprite, inflictorPos);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -127,8 +125,8 @@ glm::vec3 DamageIndicatorSystem::DamageIndicatorTest(EntityWrapper player) {
|
||||
auto inflictorPos = glm::vec3(currentPos.x + testVar*6.0f, currentPos.y, currentPos.z + testVar2*6.0f);
|
||||
|
||||
//load the explosioneffect XML
|
||||
auto deathEffect = ResourceManager::Load<EntityFile>("Schema/Entities/PlayerDeathExplosionWithCamera.xml");
|
||||
EntityFileParser parser(deathEffect);
|
||||
auto deathEffect = ResourceManager::Load<EntityXMLFile>("Schema/Entities/PlayerDeathExplosionWithCamera.xml");
|
||||
EntityXMLFileParser parser(deathEffect);
|
||||
EntityID deathEffectID = parser.MergeEntities(m_World);
|
||||
EntityWrapper deathEffectEW = EntityWrapper(m_World, deathEffectID);
|
||||
|
||||
|
||||
@@ -19,16 +19,15 @@ void PickupSpawnSystem::Update(double dt)
|
||||
if (somePickup.DecreaseThisRespawnTimer < 0.0) {
|
||||
//spawn the new healthPickup
|
||||
auto entityFile = ResourceManager::Load<EntityFile>("Schema/Entities/HealthPickup.xml");
|
||||
EntityFileParser parser(entityFile);
|
||||
EntityID healthPickupID = parser.MergeEntities(m_World);
|
||||
EntityWrapper healthPickup = entityFile->MergeInto(m_World);
|
||||
|
||||
//let the world know a pickup has spawned (graphics effects, etc)
|
||||
Events::PickupSpawned ePickupSpawned;
|
||||
ePickupSpawned.Pickup = EntityWrapper(m_World, healthPickupID);
|
||||
ePickupSpawned.Pickup = healthPickup;
|
||||
m_EventBroker->Publish(ePickupSpawned);
|
||||
|
||||
//copy values from the old entity to the new entity
|
||||
auto& newHealthPickupEntity = EntityWrapper(m_World, healthPickupID);
|
||||
auto& newHealthPickupEntity = healthPickup;
|
||||
newHealthPickupEntity["Transform"]["Position"] = somePickup.Pos;
|
||||
newHealthPickupEntity["HealthPickup"]["HealthGain"] = somePickup.HealthGain;
|
||||
newHealthPickupEntity["HealthPickup"]["RespawnTimer"] = somePickup.RespawnTimer;
|
||||
|
||||
@@ -28,10 +28,8 @@ bool PlayerDeathSystem::OnPlayerDeath(Events::PlayerDeath& e)
|
||||
void PlayerDeathSystem::createDeathEffect(EntityWrapper player)
|
||||
{
|
||||
//load the explosioneffect XML
|
||||
auto deathEffect = ResourceManager::Load<EntityFile>("Schema/Entities/PlayerDeathExplosionWithCamera.xml");
|
||||
EntityFileParser parser(deathEffect);
|
||||
EntityID deathEffectID = parser.MergeEntities(m_World);
|
||||
EntityWrapper deathEffectEW = EntityWrapper(m_World, deathEffectID);
|
||||
auto entityFile = ResourceManager::Load<EntityFile>("Schema/Entities/PlayerDeathExplosionWithCamera.xml");
|
||||
EntityWrapper deathEffectEW = entityFile->MergeInto(m_World);
|
||||
|
||||
//components that we need from player
|
||||
auto playerModel = player.FirstChildByName("PlayerModel");
|
||||
|
||||
@@ -323,10 +323,8 @@ bool PlayerMovementSystem::OnDoubleJump(Events::DoubleJump & e)
|
||||
void PlayerMovementSystem::spawnHexagon(EntityWrapper target)
|
||||
{
|
||||
//put a hexagon at the entitys... feet?
|
||||
auto hexagonEffect = ResourceManager::Load<EntityFile>("Schema/Entities/DoubleJumpHexagon.xml");
|
||||
EntityFileParser parser(hexagonEffect);
|
||||
EntityID hexagonEffectID = parser.MergeEntities(m_World);
|
||||
EntityWrapper hexagonEW = EntityWrapper(m_World, hexagonEffectID);
|
||||
auto entityFile = ResourceManager::Load<EntityFile>("Schema/Entities/DoubleJumpHexagon.xml");
|
||||
EntityWrapper hexagonEW = entityFile->MergeInto(m_World);
|
||||
hexagonEW["Transform"]["Position"] = (glm::vec3)target["Transform"]["Position"];
|
||||
}
|
||||
|
||||
@@ -337,10 +335,8 @@ bool PlayerMovementSystem::OnDashAbility(Events::DashAbility & e)
|
||||
return false;
|
||||
}
|
||||
|
||||
auto dashEffectResource = ResourceManager::Load<EntityFile>("Schema/Entities/DashEffect.xml");
|
||||
EntityFileParser parser(dashEffectResource);
|
||||
EntityID dashEffectID = parser.MergeEntities(m_World);
|
||||
EntityWrapper dashEffect(m_World, dashEffectID);
|
||||
auto entityFile = ResourceManager::Load<EntityFile>("Schema/Entities/DashEffect.xml");
|
||||
EntityWrapper dashEffect = entityFile->MergeInto(m_World);
|
||||
auto playerModel = player.FirstChildByName("PlayerModel");
|
||||
auto playerEntityModel = playerModel["Model"];
|
||||
auto playerEntityAnimation = playerModel["Animation"];
|
||||
|
||||
@@ -17,15 +17,17 @@ EntityWrapper SpawnerSystem::Spawn(EntityWrapper spawner, EntityWrapper parent /
|
||||
|
||||
// Load the entity file and parse it
|
||||
const std::string& entityFilePath = spawner["Spawner"]["EntityFile"];
|
||||
auto entityFile = ResourceManager::Load<EntityFile>(entityFilePath);
|
||||
if (entityFile == nullptr) {
|
||||
EntityWrapper spawnedEntity;
|
||||
try {
|
||||
auto entityFile = ResourceManager::Load<EntityFile>(entityFilePath);
|
||||
spawnedEntity = entityFile->MergeInto(world);
|
||||
world->SetParent(spawnedEntity.ID, parent.ID);
|
||||
} catch (const Resource::FailedLoadingException& e) {
|
||||
return EntityWrapper::Invalid;
|
||||
}
|
||||
EntityFileParser parser(entityFile);
|
||||
EntityWrapper spawnedEntity(world, parser.MergeEntities(world, parent.ID));
|
||||
|
||||
//If the spawned entity is collideable, then we must not spawn it where it collides with something that
|
||||
//has a dontCollideComponent attached.
|
||||
// If the spawned entity is collidable, then we must not spawn it where it collides with something that
|
||||
// has a dontCollideComponent attached.
|
||||
bool spawnOnCollidable = dontCollideComponent.empty() || !spawnedEntity.HasComponent("Collidable");
|
||||
if (!spawnOnCollidable) {
|
||||
boost::optional<EntityAABB> optBox = Collision::EntityAbsoluteAABB(spawnedEntity);
|
||||
|
||||
Reference in New Issue
Block a user