diff --git a/include/Engine/Input/FirstPersonInputController.h b/include/Engine/Input/FirstPersonInputController.h index 30d1f945..68c8a430 100644 --- a/include/Engine/Input/FirstPersonInputController.h +++ b/include/Engine/Input/FirstPersonInputController.h @@ -163,6 +163,7 @@ bool FirstPersonInputController::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::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::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::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::OnCommand(const Events::InputComm } } - - if (glm::length2(m_Movement) > 0) { + if (glm::length(m_Movement) > 0) { m_Movement = glm::normalize(m_Movement); //Animation diff --git a/include/Engine/Rendering/BlendTree.h b/include/Engine/Rendering/BlendTree.h index 502a1cc9..46ea7f0c 100644 --- a/include/Engine/Rendering/BlendTree.h +++ b/include/Engine/Rendering/BlendTree.h @@ -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 GetSubTreeRoots(std::string nodeName); std::vector GetSingleLevelRoots(std::string name); std::vector GetEntitesByName(std::string name); diff --git a/include/Game/Systems/BoostSystem.h b/include/Game/Systems/BoostSystem.h index f02e9472..925ef438 100644 --- a/include/Game/Systems/BoostSystem.h +++ b/include/Game/Systems/BoostSystem.h @@ -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 \ No newline at end of file diff --git a/include/Game/Systems/Weapon/SidearmWeaponBehaviour.h b/include/Game/Systems/Weapon/SidearmWeaponBehaviour.h index 7aa20025..3123b460 100644 --- a/include/Game/Systems/Weapon/SidearmWeaponBehaviour.h +++ b/include/Game/Systems/Weapon/SidearmWeaponBehaviour.h @@ -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); diff --git a/include/Game/Systems/Weapon/WeaponBehaviour.h b/include/Game/Systems/Weapon/WeaponBehaviour.h index cd067f36..6d13e741 100644 --- a/include/Game/Systems/Weapon/WeaponBehaviour.h +++ b/include/Game/Systems/Weapon/WeaponBehaviour.h @@ -305,6 +305,8 @@ private: wi.ThirdPersonEntity = thirdPersonWeapon; wi.ThirdPersonPlayerModel = thirdPersonWeapon.FirstParentWithComponent("Model"); + player["Player"]["CurrentWeapon"] = cWeapon.Info.Name; + OnEquip(cWeapon, wi); } diff --git a/resources/Schema/Entities/PlayerAssaultBlue.xml b/resources/Schema/Entities/PlayerAssaultBlue.xml index 33f1df73..c73a4c46 100644 --- a/resources/Schema/Entities/PlayerAssaultBlue.xml +++ b/resources/Schema/Entities/PlayerAssaultBlue.xml @@ -57,7 +57,7 @@ - + Schema/Entities/PlayerHUD.xml @@ -373,7 +373,7 @@ - + @@ -589,7 +589,6 @@ Models/Characters/Assault/AssaultBlue.mesh - false @@ -603,8 +602,8 @@ Schema/Entities/WeaponAssaultBlueWorld.xml - - + + AssaultWeapon @@ -624,8 +623,8 @@ Schema/Entities/SidearmWeaponBlueWorld.xml - - + + SidearmWeapon @@ -692,7 +691,7 @@ CrouchStrafeLeftF - + true @@ -703,7 +702,7 @@ CrouchStrafeRightF - + true @@ -716,7 +715,7 @@ CrouchWalkF - + true @@ -729,7 +728,7 @@ CrouchF - + true @@ -772,7 +771,7 @@ WalkF - + true @@ -783,7 +782,7 @@ RunF - + 2 true @@ -807,7 +806,7 @@ StrafeLeftF - + 2 true @@ -819,7 +818,7 @@ StrafeRightF - + 2 true @@ -835,7 +834,7 @@ IdleF - + true @@ -924,10 +923,10 @@ - + - DashRightF + DashLeftF 1.7999999523162842 false @@ -936,10 +935,10 @@ - + - DashLeftF + DashRightF 1.7999999523162842 false @@ -979,7 +978,7 @@ - MovementBlend + IdleAssault ActionBlend @@ -1018,41 +1017,17 @@ - + - - Idle - Run - 0 - + + IdleAssaultRifleU + + true + true + - - - - - IdleAssaultRifleU - - true - true - - - - - - - - - IdleAssaultRifleU - - true - true - - - - - - + @@ -1083,44 +1058,12 @@ - MovementBlend2 + IdleSidearm ActionBlend - - - - Idle - Run - 0 - - - - - - - - IdleSecWepU - true - - - - - - - - - IdleSecWepU - true - - - - - - - @@ -1153,6 +1096,16 @@ + + + + IdleSecWepU + true + + + + + diff --git a/resources/Schema/Entities/PlayerDefenderBlue.xml b/resources/Schema/Entities/PlayerDefenderBlue.xml index 30b0a3a1..c75f50fd 100644 --- a/resources/Schema/Entities/PlayerDefenderBlue.xml +++ b/resources/Schema/Entities/PlayerDefenderBlue.xml @@ -30,7 +30,6 @@ - @@ -91,7 +90,7 @@ - + Schema/Entities/PlayerHUD.xml @@ -407,7 +406,7 @@ - + @@ -592,7 +591,6 @@ - 1.7999999523162842 Models/Characters/Defender/DefenderBlue.mesh @@ -607,8 +605,8 @@ Schema/Entities/WeaponDefenderBlueWorld.xml - - + + DefenderWeapon @@ -628,8 +626,8 @@ Schema/Entities/SidearmWeaponBlueWorld.xml - - + + SidearmWeapon @@ -696,7 +694,7 @@ CrouchStrafeLeftF - + true @@ -707,7 +705,7 @@ CrouchStrafeRightF - + true @@ -720,7 +718,7 @@ CrouchWalkF - + true @@ -733,7 +731,7 @@ CrouchF - + true @@ -776,7 +774,7 @@ WalkF - + true @@ -787,7 +785,7 @@ RunF - + 2 true @@ -811,7 +809,7 @@ StrafeLeftF - + 2 true @@ -823,7 +821,7 @@ StrafeRightF - + 2 true @@ -839,7 +837,7 @@ IdleF - + true @@ -886,48 +884,12 @@ - MovementBlend2 + IdleDefender FinalBlend - - - - Idle - Run - 0 - - - - - - - - IdleAssaultRifleU - - true - true - - - - - - - - - IdleAssaultRifleU - - true - true - - - - - - - @@ -998,7 +960,7 @@ ShieldFrontU - + true @@ -1009,6 +971,18 @@ + + + + IdleAssaultRifleU + + true + true + + + + + @@ -1036,7 +1010,7 @@ - MovementBlend2 + IdleSidearm ActionBlend @@ -1073,36 +1047,15 @@ - + - - Idle - Run - + + IdleSecWepU + true + - - - - - IdleSecWepU - true - - - - - - - - - IdleSecWepU - true - - - - - - + diff --git a/src/Engine/Rendering/AnimationSystem.cpp b/src/Engine/Rendering/AnimationSystem.cpp index e30c2e9f..3895dc4a 100644 --- a/src/Engine/Rendering/AnimationSystem.cpp +++ b/src/Engine/Rendering/AnimationSystem.cpp @@ -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; } diff --git a/src/Game/Systems/BoostSystem.cpp b/src/Game/Systems/BoostSystem.cpp index c3dc1f2b..2ebfff73 100644 --- a/src/Game/Systems/BoostSystem.cpp +++ b/src/Game/Systems/BoostSystem.cpp @@ -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(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(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); + } + } + } +} diff --git a/src/Game/Systems/PlayerMovementSystem.cpp b/src/Game/Systems/PlayerMovementSystem.cpp index b86d4140..51d7bcef 100644 --- a/src/Game/Systems/PlayerMovementSystem.cpp +++ b/src/Game/Systems/PlayerMovementSystem.cpp @@ -24,6 +24,8 @@ void PlayerMovementSystem::Update(double dt) if (LocalPlayer.Valid()){ updateVelocity(LocalPlayer, dt); } + + m_SprintEffectTimer += dt; if (m_SprintEffectTimer < 0.016f) { return; diff --git a/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp b/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp index cf2aa9c5..0662cbaa 100644 --- a/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp +++ b/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp @@ -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; } diff --git a/src/Game/Systems/Weapon/SidearmWeaponBehaviour.cpp b/src/Game/Systems/Weapon/SidearmWeaponBehaviour.cpp index 9c12bb2c..517d17fb 100644 --- a/src/Game/Systems/Weapon/SidearmWeaponBehaviour.cpp +++ b/src/Game/Systems/Weapon/SidearmWeaponBehaviour.cpp @@ -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) {