Merge branch 'Movement' of github.com:teamfisk/TacticalZ into Movement

This commit is contained in:
Tleety
2016-03-12 17:04:00 +01:00
12 changed files with 182 additions and 209 deletions
@@ -163,6 +163,7 @@ bool FirstPersonInputController<EventContext>::OnCommand(const Events::InputComm
aeb.Duration = 0.1;
aeb.NodeName = "Run";
aeb.RootNode = firstPersonModel;
aeb.SingleLevelBlend = true;
aeb.Start = true;
m_EventBroker->Publish(aeb);
}
@@ -172,6 +173,7 @@ bool FirstPersonInputController<EventContext>::OnCommand(const Events::InputComm
aeb.Duration = 0.1;
aeb.NodeName = "Run";
aeb.RootNode = firstPersonModel;
aeb.SingleLevelBlend = true;
aeb.Start = true;
aeb.Reverse = true;
m_EventBroker->Publish(aeb);
@@ -211,10 +213,10 @@ bool FirstPersonInputController<EventContext>::OnCommand(const Events::InputComm
}
}
//Animation
if (glm::length2(m_Movement) < 0.25f) {
//Blend to Idle
if (m_PlayerEntity.Valid()) {
if (m_PlayerEntity.Valid()) {
glm::vec2 movementXZ = glm::vec2(m_Movement.x, m_Movement.z);
if (glm::length(movementXZ) < 0.1f) {
//Blend to Idle
EntityWrapper playerModel = m_PlayerEntity.FirstChildByName("PlayerModel");
if (playerModel.Valid()) {
Events::AutoAnimationBlend aeb;
@@ -233,10 +235,8 @@ bool FirstPersonInputController<EventContext>::OnCommand(const Events::InputComm
aeb.Start = true;
m_EventBroker->Publish(aeb);
}
}
} else {
//Blend to movement
if (m_PlayerEntity.Valid()) {
} else {
//Blend to movement
EntityWrapper playerModel = m_PlayerEntity.FirstChildByName("PlayerModel");
if (playerModel.Valid()) {
Events::AutoAnimationBlend aeb;
@@ -248,8 +248,7 @@ bool FirstPersonInputController<EventContext>::OnCommand(const Events::InputComm
}
}
if (glm::length2(m_Movement) > 0) {
if (glm::length(m_Movement) > 0) {
m_Movement = glm::normalize(m_Movement);
//Animation
+1 -2
View File
@@ -49,9 +49,7 @@ public:
next = next->Child[0];
}
}
return next;
}
};
@@ -82,6 +80,7 @@ public:
BlendTree::Node* FirstCommonParent(Node* node1, Node* node2);
EntityWrapper GetSubTreeRoot(std::string nodeName);
std::vector<EntityWrapper> GetSubTreeRoots(std::string nodeName);
std::vector<EntityWrapper> GetSingleLevelRoots(std::string name);
std::vector<EntityWrapper> GetEntitesByName(std::string name);
+3
View File
@@ -6,6 +6,7 @@
#include "Core/EntityFile.h"
#include "Core/EPlayerDamage.h"
#include "Common.h"
#include "SpawnerSystem.h"
class BoostSystem : public System
{
@@ -17,5 +18,7 @@ private:
bool OnPlayerDamage(Events::PlayerDamage& e);
std::string DetermineClass(EntityWrapper player);
void giveAmmo(EntityWrapper giver, EntityWrapper receiver);
};
#endif
@@ -37,7 +37,7 @@ private:
bool playerInFirstPerson(EntityWrapper player);
bool dealDamage(ComponentWrapper cWeapon, WeaponInfo& wi);
void giveAmmo(ComponentWrapper cWeapon, WeaponInfo& wi, EntityWrapper receiver);
// void giveAmmo(ComponentWrapper cWeapon, WeaponInfo& wi, EntityWrapper receiver);
void CheckAmmo(ComponentWrapper cWeapon, WeaponInfo& wi);
@@ -305,6 +305,8 @@ private:
wi.ThirdPersonEntity = thirdPersonWeapon;
wi.ThirdPersonPlayerModel = thirdPersonWeapon.FirstParentWithComponent("Model");
player["Player"]["CurrentWeapon"] = cWeapon.Info.Name;
OnEquip(cWeapon, wi);
}
+39 -86
View File
@@ -57,7 +57,7 @@
</Components>
<Children/>
</Entity>
<Entity name="HUDSpawner">
<Entity name="HUD">
<Components>
<c:Spawner>
<EntityFile>Schema/Entities/PlayerHUD.xml</EntityFile>
@@ -373,7 +373,7 @@
</c:Model>
<c:Transform>
<Position X="0" Y="0.198665127" Z="0"/>
<Orientation X="-0.031580139" Y="-2.13055706" Z="0"/>
<Orientation X="0.0531693883" Y="-2.13055706" Z="0"/>
<Scale X="0.0500000007" Y="0.0500000007" Z="0.0500000007"/>
</c:Transform>
</Components>
@@ -589,7 +589,6 @@
<c:HiddenForLocalPlayer/>
<c:Model>
<Resource>Models/Characters/Assault/AssaultBlue.mesh</Resource>
<Visible>false</Visible>
</c:Model>
<c:Transform/>
</Components>
@@ -603,8 +602,8 @@
<EntityFile>Schema/Entities/WeaponAssaultBlueWorld.xml</EntityFile>
</c:Spawner>
<c:Transform>
<Position X="0.108882263" Y="1.09243619" Z="-0.367516935"/>
<Orientation X="-0.0281659421" Y="-0.0316450335" Z="0.132674664"/>
<Position X="0.128669813" Y="1.08486295" Z="-0.361068189"/>
<Orientation X="-0.0353792347" Y="-0.0854677409" Z="0.133094937"/>
</c:Transform>
<c:WeaponAttachment>
<Weapon>AssaultWeapon</Weapon>
@@ -624,8 +623,8 @@
<EntityFile>Schema/Entities/SidearmWeaponBlueWorld.xml</EntityFile>
</c:Spawner>
<c:Transform>
<Position X="0.108882263" Y="1.09243619" Z="-0.367516935"/>
<Orientation X="-0.0281659421" Y="-0.0316450335" Z="0.132674664"/>
<Position X="0.128669813" Y="1.08486295" Z="-0.361068189"/>
<Orientation X="-0.0353792347" Y="-0.0854677409" Z="0.133094937"/>
</c:Transform>
<c:WeaponAttachment>
<Weapon>SidearmWeapon</Weapon>
@@ -692,7 +691,7 @@
<Components>
<c:Animation>
<AnimationName>CrouchStrafeLeftF</AnimationName>
<Time>0.47751323206761143</Time>
<Time>0.14513013667773755</Time>
<Play>true</Play>
</c:Animation>
<c:Transform/>
@@ -703,7 +702,7 @@
<Components>
<c:Animation>
<AnimationName>CrouchStrafeRightF</AnimationName>
<Time>0.021962400161406492</Time>
<Time>0.072451598628520131</Time>
<Play>true</Play>
</c:Animation>
<c:Transform/>
@@ -716,7 +715,7 @@
<Components>
<c:Animation>
<AnimationName>CrouchWalkF</AnimationName>
<Time>0.80033638533880946</Time>
<Time>0.8508255838059231</Time>
<Play>true</Play>
</c:Animation>
<c:Transform/>
@@ -729,7 +728,7 @@
<Components>
<c:Animation>
<AnimationName>CrouchF</AnimationName>
<Time>1.4735638822855002</Time>
<Time>1.5240530807526143</Time>
<Play>true</Play>
</c:Animation>
<c:Transform/>
@@ -772,7 +771,7 @@
<Components>
<c:Animation>
<AnimationName>WalkF</AnimationName>
<Time>0.4721928801537274</Time>
<Time>0.35598021321569639</Time>
<Play>true</Play>
</c:Animation>
<c:Transform/>
@@ -783,7 +782,7 @@
<Components>
<c:Animation>
<AnimationName>RunF</AnimationName>
<Time>0.54088538957005738</Time>
<Time>0.3084600556940007</Time>
<Speed>2</Speed>
<Play>true</Play>
</c:Animation>
@@ -807,7 +806,7 @@
<Components>
<c:Animation>
<AnimationName>StrafeLeftF</AnimationName>
<Time>0.1435940249715344</Time>
<Time>0.91116869109547771</Time>
<Speed>2</Speed>
<Play>true</Play>
</c:Animation>
@@ -819,7 +818,7 @@
<Components>
<c:Animation>
<AnimationName>StrafeRightF</AnimationName>
<Time>0.22100503380750069</Time>
<Time>0.98857969993144401</Time>
<Speed>2</Speed>
<Play>true</Play>
</c:Animation>
@@ -835,7 +834,7 @@
<Components>
<c:Animation>
<AnimationName>IdleF</AnimationName>
<Time>0.054403308784401361</Time>
<Time>0.85485929533452953</Time>
<Play>true</Play>
</c:Animation>
<c:Transform/>
@@ -924,10 +923,10 @@
<c:Transform/>
</Components>
<Children>
<Entity name="DashRight">
<Entity name="DashLeft">
<Components>
<c:Animation>
<AnimationName>DashRightF</AnimationName>
<AnimationName>DashLeftF</AnimationName>
<Time>1</Time>
<Speed>1.7999999523162842</Speed>
<Loop>false</Loop>
@@ -936,10 +935,10 @@
</Components>
<Children/>
</Entity>
<Entity name="DashLeft">
<Entity name="DashRight">
<Components>
<c:Animation>
<AnimationName>DashLeftF</AnimationName>
<AnimationName>DashRightF</AnimationName>
<Time>1</Time>
<Speed>1.7999999523162842</Speed>
<Loop>false</Loop>
@@ -979,7 +978,7 @@
<Entity name="WeaponBlend">
<Components>
<c:BlendAdditive>
<Adder>MovementBlend</Adder>
<Adder>IdleAssault</Adder>
<Receiver>ActionBlend</Receiver>
</c:BlendAdditive>
<c:Transform/>
@@ -1018,41 +1017,17 @@
</Entity>
</Children>
</Entity>
<Entity name="MovementBlend2">
<Entity name="IdleAssault">
<Components>
<c:Blend>
<Pose1>Idle</Pose1>
<Pose2>Run</Pose2>
<Weight>0</Weight>
</c:Blend>
<c:Animation>
<AnimationName>IdleAssaultRifleU</AnimationName>
<Time>1.9871198993639698</Time>
<Play>true</Play>
<Additive>true</Additive>
</c:Animation>
<c:Transform/>
</Components>
<Children>
<Entity name="Run">
<Components>
<c:Animation>
<AnimationName>IdleAssaultRifleU</AnimationName>
<Time>1.1033325663020008</Time>
<Play>true</Play>
<Additive>true</Additive>
</c:Animation>
<c:Transform/>
</Components>
<Children/>
</Entity>
<Entity name="Idle">
<Components>
<c:Animation>
<AnimationName>IdleAssaultRifleU</AnimationName>
<Time>1.1033325663020008</Time>
<Play>true</Play>
<Additive>true</Additive>
</c:Animation>
<c:Transform/>
</Components>
<Children/>
</Entity>
</Children>
<Children/>
</Entity>
</Children>
</Entity>
@@ -1083,44 +1058,12 @@
<Entity name="WeaponBlend">
<Components>
<c:BlendAdditive>
<Adder>MovementBlend2</Adder>
<Adder>IdleSidearm</Adder>
<Receiver>ActionBlend</Receiver>
</c:BlendAdditive>
<c:Transform/>
</Components>
<Children>
<Entity name="MovementBlend2">
<Components>
<c:Blend>
<Pose1>Idle</Pose1>
<Pose2>Run</Pose2>
<Weight>0</Weight>
</c:Blend>
<c:Transform/>
</Components>
<Children>
<Entity name="Idle">
<Components>
<c:Animation>
<AnimationName>IdleSecWepU</AnimationName>
<Additive>true</Additive>
</c:Animation>
<c:Transform/>
</Components>
<Children/>
</Entity>
<Entity name="Run">
<Components>
<c:Animation>
<AnimationName>IdleSecWepU</AnimationName>
<Additive>true</Additive>
</c:Animation>
<c:Transform/>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
<Entity name="ActionBlend">
<Components>
<c:Blend>
@@ -1153,6 +1096,16 @@
</Entity>
</Children>
</Entity>
<Entity name="IdleSidearm">
<Components>
<c:Animation>
<AnimationName>IdleSecWepU</AnimationName>
<Additive>true</Additive>
</c:Animation>
<c:Transform/>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
<Entity name="Aim">
@@ -30,7 +30,6 @@
<CurrentWeapon></CurrentWeapon>
</c:Player>
<c:Transform>
<Position X="0" Y="0.221111551" Z="0"/>
<Orientation X="0" Y="-0" Z="0"/>
</c:Transform>
</Components>
@@ -91,7 +90,7 @@
</Entity>
</Children>
</Entity>
<Entity name="HUDSpawner">
<Entity name="HUD">
<Components>
<c:Spawner>
<EntityFile>Schema/Entities/PlayerHUD.xml</EntityFile>
@@ -407,7 +406,7 @@
</c:Model>
<c:Transform>
<Position X="0" Y="0.198665127" Z="0"/>
<Orientation X="-0.0462424681" Y="-2.13055706" Z="0"/>
<Orientation X="0.0531693883" Y="-2.13055706" Z="0"/>
<Scale X="0.0500000007" Y="0.0500000007" Z="0.0500000007"/>
</c:Transform>
</Components>
@@ -592,7 +591,6 @@
<c:Shielded/>
<c:HiddenForLocalPlayer/>
<c:Model>
<GlowIntensity>1.7999999523162842</GlowIntensity>
<Resource>Models/Characters/Defender/DefenderBlue.mesh</Resource>
</c:Model>
<c:Transform/>
@@ -607,8 +605,8 @@
<EntityFile>Schema/Entities/WeaponDefenderBlueWorld.xml</EntityFile>
</c:Spawner>
<c:Transform>
<Position X="0.159374163" Y="1.04528129" Z="-0.296122819"/>
<Orientation X="-0.104885302" Y="-0.0685810521" Z="0.143936574"/>
<Position X="0.160437703" Y="1.04422736" Z="-0.295565188"/>
<Orientation X="-0.105441377" Y="-0.0721141845" Z="0.143959135"/>
</c:Transform>
<c:WeaponAttachment>
<Weapon>DefenderWeapon</Weapon>
@@ -628,8 +626,8 @@
<EntityFile>Schema/Entities/SidearmWeaponBlueWorld.xml</EntityFile>
</c:Spawner>
<c:Transform>
<Position X="0.159374163" Y="1.04528129" Z="-0.296122819"/>
<Orientation X="-0.104885302" Y="-0.0685810521" Z="0.143936574"/>
<Position X="0.160437703" Y="1.04422736" Z="-0.295565188"/>
<Orientation X="-0.105441377" Y="-0.0721141845" Z="0.143959135"/>
</c:Transform>
<c:WeaponAttachment>
<Weapon>SidearmWeapon</Weapon>
@@ -696,7 +694,7 @@
<Components>
<c:Animation>
<AnimationName>CrouchStrafeLeftF</AnimationName>
<Time>0.94903533204833757</Time>
<Time>0.89884525886057709</Time>
<Play>true</Play>
</c:Animation>
<c:Transform/>
@@ -707,7 +705,7 @@
<Components>
<c:Animation>
<AnimationName>CrouchStrafeRightF</AnimationName>
<Time>0.7265272838887622</Time>
<Time>0.82616672081135967</Time>
<Play>true</Play>
</c:Animation>
<c:Transform/>
@@ -720,7 +718,7 @@
<Components>
<c:Animation>
<AnimationName>CrouchWalkF</AnimationName>
<Time>0.40505409558886285</Time>
<Time>0.60454070598876264</Time>
<Play>true</Play>
</c:Animation>
<c:Transform/>
@@ -733,7 +731,7 @@
<Components>
<c:Animation>
<AnimationName>CrouchF</AnimationName>
<Time>1.0782815925355536</Time>
<Time>0.27776820293545335</Time>
<Play>true</Play>
</c:Animation>
<c:Transform/>
@@ -776,7 +774,7 @@
<Components>
<c:Animation>
<AnimationName>WalkF</AnimationName>
<Time>0.91020872499863614</Time>
<Time>0.10969533539853593</Time>
<Play>true</Play>
</c:Animation>
<c:Transform/>
@@ -787,7 +785,7 @@
<Components>
<c:Animation>
<AnimationName>RunF</AnimationName>
<Time>0.4169170792598802</Time>
<Time>0.81589030005967977</Time>
<Speed>2</Speed>
<Play>true</Play>
</c:Animation>
@@ -811,7 +809,7 @@
<Components>
<c:Animation>
<AnimationName>StrafeLeftF</AnimationName>
<Time>0.019625714661357208</Time>
<Time>0.41859893546115678</Time>
<Speed>2</Speed>
<Play>true</Play>
</c:Animation>
@@ -823,7 +821,7 @@
<Components>
<c:Animation>
<AnimationName>StrafeRightF</AnimationName>
<Time>0.097036723497323507</Time>
<Time>0.49600994429712308</Time>
<Speed>2</Speed>
<Play>true</Play>
</c:Animation>
@@ -839,7 +837,7 @@
<Components>
<c:Animation>
<AnimationName>IdleF</AnimationName>
<Time>0.70908179896927592</Time>
<Time>1.1919024261691025</Time>
<Play>true</Play>
</c:Animation>
<c:Transform/>
@@ -886,48 +884,12 @@
<Entity name="WeaponBlend">
<Components>
<c:BlendAdditive>
<Adder>MovementBlend2</Adder>
<Adder>IdleDefender</Adder>
<Receiver>FinalBlend</Receiver>
</c:BlendAdditive>
<c:Transform/>
</Components>
<Children>
<Entity name="MovementBlend2">
<Components>
<c:Blend>
<Pose1>Idle</Pose1>
<Pose2>Run</Pose2>
<Weight>0</Weight>
</c:Blend>
<c:Transform/>
</Components>
<Children>
<Entity name="Run">
<Components>
<c:Animation>
<AnimationName>IdleAssaultRifleU</AnimationName>
<Time>1.5413484111469096</Time>
<Play>true</Play>
<Additive>true</Additive>
</c:Animation>
<c:Transform/>
</Components>
<Children/>
</Entity>
<Entity name="Idle">
<Components>
<c:Animation>
<AnimationName>IdleAssaultRifleU</AnimationName>
<Time>1.5413484111469096</Time>
<Play>true</Play>
<Additive>true</Additive>
</c:Animation>
<c:Transform/>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
<Entity name="FinalBlend">
<Components>
<c:Blend>
@@ -998,7 +960,7 @@
<Components>
<c:Animation>
<AnimationName>ShieldFrontU</AnimationName>
<Time>0.22021105203482882</Time>
<Time>0.41969766243472861</Time>
<Play>true</Play>
</c:Animation>
<c:Transform/>
@@ -1009,6 +971,18 @@
</Entity>
</Children>
</Entity>
<Entity name="IdleDefender">
<Components>
<c:Animation>
<AnimationName>IdleAssaultRifleU</AnimationName>
<Time>0.74083502154680936</Time>
<Play>true</Play>
<Additive>true</Additive>
</c:Animation>
<c:Transform/>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
<Entity name="Aim">
@@ -1036,7 +1010,7 @@
<Entity name="WeaponBlend">
<Components>
<c:BlendAdditive>
<Adder>MovementBlend2</Adder>
<Adder>IdleSidearm</Adder>
<Receiver>ActionBlend</Receiver>
</c:BlendAdditive>
<c:Transform/>
@@ -1073,36 +1047,15 @@
</Entity>
</Children>
</Entity>
<Entity name="MovementBlend2">
<Entity name="IdleSidearm">
<Components>
<c:Blend>
<Pose1>Idle</Pose1>
<Pose2>Run</Pose2>
</c:Blend>
<c:Animation>
<AnimationName>IdleSecWepU</AnimationName>
<Additive>true</Additive>
</c:Animation>
<c:Transform/>
</Components>
<Children>
<Entity name="Idle">
<Components>
<c:Animation>
<AnimationName>IdleSecWepU</AnimationName>
<Additive>true</Additive>
</c:Animation>
<c:Transform/>
</Components>
<Children/>
</Entity>
<Entity name="Run">
<Components>
<c:Animation>
<AnimationName>IdleSecWepU</AnimationName>
<Additive>true</Additive>
</c:Animation>
<c:Transform/>
</Components>
<Children/>
</Entity>
</Children>
<Children/>
</Entity>
</Children>
</Entity>
+9 -3
View File
@@ -127,8 +127,8 @@ void AnimationSystem::UpdateAnimations(double dt)
void AnimationSystem::UpdateWeights(double dt)
{
for (auto it = m_AutoBlendQueues.begin(); it != m_AutoBlendQueues.end(); ) {
/* LOG_INFO("%s", it->first.Name().c_str());
it->second.PrintQueue();*/
//LOG_INFO("%s", it->first.Name().c_str());
//it->second.PrintQueue();
if(it->second.HasActiveBlendJob()) {
AutoBlendQueue::AutoBlendJob& blendJob = it->second.GetActiveBlendJob();
@@ -158,12 +158,13 @@ void AnimationSystem::UpdateWeights(double dt)
bool AnimationSystem::OnAutoAnimationBlend(Events::AutoAnimationBlend& e)
{
if (!e.RootNode.Valid()) {
LOG_ERROR("%s, RootNode invalid %s", e.NodeName, e.RootNode.Name().c_str());
return false;
}
if (!e.RootNode.HasComponent("Model")) {
LOG_ERROR("%s, RootNode has no model %s", e.NodeName, e.RootNode.Name().c_str());
return false;
}
@@ -171,11 +172,13 @@ bool AnimationSystem::OnAutoAnimationBlend(Events::AutoAnimationBlend& e)
try {
model = ResourceManager::Load<::Model, true>((std::string)e.RootNode["Model"]["Resource"]);
} catch (const std::exception&) {
LOG_ERROR("%s, RootNode model not finished loading %s", e.NodeName, e.RootNode.Name().c_str());
return false;
}
Skeleton* skeleton = model->m_RawModel->m_Skeleton;
if (skeleton == nullptr) {
LOG_ERROR("%s, RootNode skeleton invalid %s", e.NodeName, e.RootNode.Name().c_str());
return false;
}
@@ -183,6 +186,7 @@ bool AnimationSystem::OnAutoAnimationBlend(Events::AutoAnimationBlend& e)
if (skeleton->BlendTrees.find(e.RootNode) != skeleton->BlendTrees.end()) {
blendTree = skeleton->BlendTrees.at(e.RootNode);
} else {
LOG_ERROR("%s, No blendtree was found invalid %s", e.NodeName, e.RootNode.Name().c_str());
return false;
}
@@ -193,6 +197,7 @@ bool AnimationSystem::OnAutoAnimationBlend(Events::AutoAnimationBlend& e)
subTreeRoot = blendTree->GetSubTreeRoot(e.NodeName);
if (!subTreeRoot.Valid()) {
LOG_ERROR("%s, subTreeRoot invalid", e.NodeName);
return false;
}
@@ -237,6 +242,7 @@ bool AnimationSystem::OnAutoAnimationBlend(Events::AutoAnimationBlend& e)
subTreeRoot = entity;
if (!subTreeRoot.Valid()) {
LOG_ERROR("%s, subTreeRoot invalid", e.NodeName);
return false;
}
+75 -19
View File
@@ -35,19 +35,25 @@ bool BoostSystem::OnPlayerDamage(Events::PlayerDamage& e)
return false;
}
//get the XML file, example: "Schema/Entities/BoostclassName.xml"
std::string classXML = "Schema/Entities/" + className + ".xml";
//check if player already has a child with the component, if so delete that child
auto playerBoostAssaultEntity = e.Victim.FirstChildByName(className);
if (playerBoostAssaultEntity.Valid()) {
m_World->DeleteEntity(playerBoostAssaultEntity.ID);
LOG_INFO("intflictor: %s, vicitm: %s", e.Inflictor.Name().c_str(), e.Victim.Name().c_str());
if(className == "SidearmWeapon") { // give ammo
giveAmmo(e.Inflictor, e.Victim);
} else { //give boost
//get the XML file, example: "Schema/Entities/BoostclassName.xml"
std::string classXML = "Schema/Entities/" + className + ".xml";
//check if player already has a child with the component, if so delete that child
auto playerBoostAssaultEntity = e.Victim.FirstChildByName(className);
if (playerBoostAssaultEntity.Valid()) {
m_World->DeleteEntity(playerBoostAssaultEntity.ID);
}
//load boost XML file, set it entity parented with the victim player
auto entityFile = ResourceManager::Load<EntityFile>(classXML);
EntityWrapper boostAssaultEntity = entityFile->MergeInto(m_World);
m_World->SetName(boostAssaultEntity.ID, className);
m_World->SetParent(boostAssaultEntity.ID, e.Victim.ID);
}
//load boost XML file, set it entity parented with the victim player
auto entityFile = ResourceManager::Load<EntityFile>(classXML);
EntityWrapper boostAssaultEntity = entityFile->MergeInto(m_World);
m_World->SetName(boostAssaultEntity.ID, className);
m_World->SetParent(boostAssaultEntity.ID, e.Victim.ID);
return true;
}
@@ -55,14 +61,64 @@ bool BoostSystem::OnPlayerDamage(Events::PlayerDamage& e)
std::string BoostSystem::DetermineClass(EntityWrapper inflictorPlayer)
{
//determine the class based on what component the inflictor-player has
if (m_World->HasComponent(inflictorPlayer.ID, "DashAbility")) {
return "BoostAssault";
}
if (m_World->HasComponent(inflictorPlayer.ID, "ShieldAbility")) {
return "BoostDefender";
}
if (m_World->HasComponent(inflictorPlayer.ID, "SprintAbility")) {
return "BoostSniper";
if (inflictorPlayer.HasComponent("Player")) {
if ((std::string)inflictorPlayer["Player"]["CurrentWeapon"] == "AssaultWeapon") {
return "BoostAssault";
}
if ((std::string)inflictorPlayer["Player"]["CurrentWeapon"] == "DefenderWeapon") {
return "BoostDefender";
}
if ((std::string)inflictorPlayer["Player"]["CurrentWeapon"] == "SniperWeapon") {
return "BoostSniper";
}
if ((std::string)inflictorPlayer["Player"]["CurrentWeapon"] == "SidearmWeapon") {
return "SidearmWeapon";
}
}
return "";
}
void BoostSystem::giveAmmo(EntityWrapper giver, EntityWrapper receiver)
{
bool gaveAmmo = false;
if (receiver.HasComponent("AssaultWeapon")) {
int magazineSize = receiver["AssaultWeapon"]["MagazineSize"];
int& magazineAmmo = receiver["AssaultWeapon"]["MagazineAmmo"];
int maxAmmo = receiver["AssaultWeapon"]["MaxAmmo"];
int& ammo = receiver["AssaultWeapon"]["Ammo"];
if (magazineAmmo < magazineSize) {
magazineAmmo += 1;
gaveAmmo = true;
} else if (ammo < maxAmmo) {
ammo += 1;
gaveAmmo = true;
}
} else if (receiver.HasComponent("DefenderWeapon")) {
int magazineSize = receiver["DefenderWeapon"]["MagazineSize"];
int& magazineAmmo = receiver["DefenderWeapon"]["MagazineAmmo"];
int maxAmmo = receiver["DefenderWeapon"]["MaxAmmo"];
int& ammo = receiver["DefenderWeapon"]["Ammo"];
if (magazineAmmo < magazineSize) {
magazineAmmo += 1;
gaveAmmo = true;
} else if (ammo < maxAmmo) {
ammo += 1;
gaveAmmo = true;
}
}
if (gaveAmmo) {
EntityWrapper effectSpawner = giver.FirstChildByName("AmmoShareEffectSpawner");
if (effectSpawner.Valid()) {
if (effectSpawner.HasComponent("Spawner")) {
SpawnerSystem::Spawn(effectSpawner, effectSpawner);
}
}
}
}
@@ -24,6 +24,8 @@ void PlayerMovementSystem::Update(double dt)
if (LocalPlayer.Valid()){
updateVelocity(LocalPlayer, dt);
}
m_SprintEffectTimer += dt;
if (m_SprintEffectTimer < 0.016f) {
return;
@@ -74,7 +74,7 @@ void AssaultWeaponBehaviour::UpdateWeapon(ComponentWrapper cWeapon, WeaponInfo&
float animationWeight = glm::min(speed, movementSpeed) / movementSpeed;
EntityWrapper rootNode = wi.FirstPersonEntity;
if (rootNode.Valid()) {
EntityWrapper blend = rootNode.FirstChildByName("MovementBlend");
EntityWrapper blend = rootNode.FirstChildByName("MovementBlendAssault");
if (blend.Valid()) {
(double&)blend["Blend"]["Weight"] = animationWeight;
}
@@ -14,7 +14,6 @@ void SidearmWeaponBehaviour::UpdateComponent(EntityWrapper& entity, ComponentWra
void SidearmWeaponBehaviour::UpdateWeapon(ComponentWrapper cWeapon, WeaponInfo& wi, double dt)
{
CheckAmmo(cWeapon, wi);
// Start reloading automatically if at 0 mag ammo
@@ -64,7 +63,7 @@ void SidearmWeaponBehaviour::UpdateWeapon(ComponentWrapper cWeapon, WeaponInfo&
float animationWeight = glm::min(speed, movementSpeed) / movementSpeed;
EntityWrapper rootNode = wi.FirstPersonEntity;
if (rootNode.Valid()) {
EntityWrapper blend = rootNode.FirstChildByName("MovementBlend");
EntityWrapper blend = rootNode.FirstChildByName("MovementBlendSidearm");
if (blend.Valid()) {
(double&)blend["Blend"]["Weight"] = animationWeight;
}
@@ -282,7 +281,7 @@ bool SidearmWeaponBehaviour::dealDamage(ComponentWrapper cWeapon, WeaponInfo& wi
// If friendly fire, reduce damage to 0 (needed to make Boosts, Ammosharing work)
if ((ComponentInfo::EnumType)victim["Team"]["Team"] == (ComponentInfo::EnumType)wi.Player["Team"]["Team"]) {
damage = 0;
giveAmmo(cWeapon, wi, victim);
//giveAmmo(cWeapon, wi, victim);
}
// Deal damage!
@@ -294,6 +293,7 @@ bool SidearmWeaponBehaviour::dealDamage(ComponentWrapper cWeapon, WeaponInfo& wi
return damage > 0;
}
/*
void SidearmWeaponBehaviour::giveAmmo(ComponentWrapper cWeapon, WeaponInfo& wi, EntityWrapper receiver)
{
@@ -338,7 +338,7 @@ void SidearmWeaponBehaviour::giveAmmo(ComponentWrapper cWeapon, WeaponInfo& wi,
}
}
}
}
}*/
void SidearmWeaponBehaviour::CheckAmmo(ComponentWrapper cWeapon, WeaponInfo& wi)
{