Added BoostSystem, Added BoostAssault entity XML
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
#include "Network/MultiplayerSnapshotFilter.h"
|
||||
#include "Game/Systems/AmmunitionHUDSystem.h"
|
||||
#include "Game/Systems/KillFeedSystem.h"
|
||||
#include "Game/Systems/BoostSystem.h"
|
||||
|
||||
|
||||
Game::Game(int argc, char* argv[])
|
||||
@@ -132,6 +133,7 @@ Game::Game(int argc, char* argv[])
|
||||
m_SystemPipeline->AddSystem<DamageIndicatorSystem>(updateOrderLevel);
|
||||
m_SystemPipeline->AddSystem<AmmunitionHUDSystem>(updateOrderLevel);
|
||||
m_SystemPipeline->AddSystem<KillFeedSystem>(updateOrderLevel);
|
||||
m_SystemPipeline->AddSystem<BoostSystem>(updateOrderLevel);
|
||||
// Populate Octree with collidables
|
||||
++updateOrderLevel;
|
||||
m_SystemPipeline->AddSystem<FillOctreeSystem>(updateOrderLevel, m_OctreeCollision, "Collidable");
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
#include "Systems/BoostSystem.h"
|
||||
|
||||
BoostSystem::BoostSystem(SystemParams params)
|
||||
: System(params)
|
||||
{
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EPlayerDamage, &BoostSystem::OnPlayerDamage);
|
||||
}
|
||||
|
||||
bool BoostSystem::OnPlayerDamage(Events::PlayerDamage& e)
|
||||
{
|
||||
if (e.Victim.ID == e.Inflictor.ID) {
|
||||
return false;
|
||||
}
|
||||
if (!e.Victim.Valid() && e.Victim != LocalPlayer && !e.Victim.IsChildOf(LocalPlayer)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!e.Inflictor.Valid() || !e.Victim.Valid()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto teamInflictor = m_World->GetComponent(e.Inflictor.ID, "Team");
|
||||
auto teamVictim = m_World->GetComponent(e.Victim.ID, "Team");
|
||||
if ((int)teamInflictor["Team"] != (int)teamVictim["Team"]) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//friendly fire
|
||||
|
||||
auto className = determineClass(e.Inflictor);
|
||||
if (className == "") {
|
||||
return false;
|
||||
}
|
||||
//"Schema/Entities/BoostAssault.xml"
|
||||
std::string classXML = "Schema/Entities/" + className + ".xml";
|
||||
|
||||
//class
|
||||
|
||||
//load & set the BoostAssault Component
|
||||
auto entityFile = ResourceManager::Load<EntityFile>(classXML);
|
||||
EntityFileParser parser(entityFile);
|
||||
EntityID boostAssaultEntity = parser.MergeEntities(m_World);
|
||||
m_World->SetParent(boostAssaultEntity, e.Victim.ID);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string BoostSystem::determineClass(EntityWrapper player)
|
||||
{
|
||||
if (m_World->HasComponent(player.ID, "DashAbility")) {
|
||||
return "BoostAssault";
|
||||
}
|
||||
if (m_World->HasComponent(player.ID, "DefenderShield")) {
|
||||
return "BoostDefender";
|
||||
}
|
||||
if (m_World->HasComponent(player.ID, "SniperSprint")) {
|
||||
return "BoostSniper";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
@@ -384,10 +384,12 @@ bool AssaultWeaponBehaviour::shoot(double damage)
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check for friendly fire
|
||||
if ((ComponentInfo::EnumType)victim["Team"]["Team"] == (ComponentInfo::EnumType)m_Player["Team"]["Team"]) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Do Not Check for friendly fire
|
||||
//// Check for friendly fire
|
||||
//if ((ComponentInfo::EnumType)victim["Team"]["Team"] == (ComponentInfo::EnumType)m_Player["Team"]["Team"]) {
|
||||
// return false;
|
||||
//}
|
||||
|
||||
// Deal damage!
|
||||
Events::PlayerDamage ePlayerDamage;
|
||||
|
||||
Reference in New Issue
Block a user