diff --git a/assets b/assets index 0fd6b66b..078e014f 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 0fd6b66b599ab98a441f91d5cc53c603009f488c +Subproject commit 078e014f3d24a100c4cb544ac6807aa2b54149b2 diff --git a/include/Engine/Core/EAmmoPickup.h b/include/Engine/Core/EAmmoPickup.h new file mode 100644 index 00000000..6d854d48 --- /dev/null +++ b/include/Engine/Core/EAmmoPickup.h @@ -0,0 +1,18 @@ +#ifndef EAmmoPickup_h__ +#define EAmmoPickup_h__ + +#include "EventBroker.h" +#include "../Core/EntityWrapper.h" + +namespace Events +{ + + struct AmmoPickup : Event + { + EntityWrapper Player; + int AmmoGain; + }; + +} + +#endif \ No newline at end of file diff --git a/include/Game/Systems/AmmoPickupSystem.h b/include/Game/Systems/AmmoPickupSystem.h new file mode 100644 index 00000000..a54b8495 --- /dev/null +++ b/include/Game/Systems/AmmoPickupSystem.h @@ -0,0 +1,32 @@ +#ifndef AmmoPickupSystem_h__ +#define AmmoPickupSystem_h__ + +#include "Core/System.h" +#include "Core/Transform.h" +#include "Core/ResourceManager.h" +#include "Core/EntityFileParser.h" +#include "Core/EPickupSpawned.h" +#include "Core/EAmmoPickup.h" +#include "Engine/Collision/ETrigger.h" +#include "Common.h" + +class AmmoPickupSystem : public ImpureSystem +{ +public: + AmmoPickupSystem(SystemParams params); + + virtual void Update(double dt) override; + +private: + EventRelay m_ETriggerTouch; + bool OnTriggerTouch(Events::TriggerTouch& e); + + struct NewAmmoPickup { + glm::vec3 Pos; + double AmmoGain; + double RespawnTimer; + double DecreaseThisRespawnTimer; + }; + std::vector m_ETriggerTouchVector; +}; +#endif diff --git a/include/Game/Systems/HealthSystem.h b/include/Game/Systems/HealthSystem.h index b66d8eb0..21a52330 100644 --- a/include/Game/Systems/HealthSystem.h +++ b/include/Game/Systems/HealthSystem.h @@ -9,6 +9,7 @@ #include "Core/EPlayerDamage.h" #include "Core/EPlayerHealthPickup.h" #include "Core/EPlayerDeath.h" +#include "../Engine/Input/EInputCommand.h" #include #include @@ -28,7 +29,9 @@ private: bool HealthSystem::OnPlayerDamaged(Events::PlayerDamage& e); EventRelay m_EPlayerHealthPickup; bool HealthSystem::OnPlayerHealthPickup(Events::PlayerHealthPickup& e); - + EventRelay m_InputCommand; + bool HealthSystem::OnInputCommand(Events::InputCommand& e); + //vector which will keep track of health changes std::vector> m_DeltaHealthVector; diff --git a/include/Game/Systems/PlayerSpawnSystem.h b/include/Game/Systems/PlayerSpawnSystem.h index c68bb21f..bf87bef8 100644 --- a/include/Game/Systems/PlayerSpawnSystem.h +++ b/include/Game/Systems/PlayerSpawnSystem.h @@ -13,6 +13,8 @@ public: PlayerSpawnSystem(SystemParams params); virtual void Update(double dt) override; + + static void SetRespawnTime(float respawnTime) { m_RespawnTime = respawnTime; }; private: struct SpawnRequest @@ -23,10 +25,19 @@ private: bool m_NetworkEnabled = false; std::vector m_SpawnRequests; + + //Player ID -> EntityWrapper. std::map m_PlayerEntities; + //EntityWrapper ID -> Player ID. + std::map m_PlayerIDs; + + static float m_RespawnTime; + float m_Timer; EventRelay m_OnInputCommand; - bool OnInputCommand(const Events::InputCommand& e); + bool OnInputCommand(Events::InputCommand& e); EventRelay m_OnPlayerSpawnerd; bool OnPlayerSpawned(Events::PlayerSpawned& e); + EventRelay m_OnPlayerDeath; + bool OnPlayerDeath(Events::PlayerDeath& e); }; \ No newline at end of file diff --git a/resources/DefaultConfig.ini b/resources/DefaultConfig.ini index 6911632f..9c6dfd8f 100644 --- a/resources/DefaultConfig.ini +++ b/resources/DefaultConfig.ini @@ -4,6 +4,7 @@ LoadMap= ; if true -> Pool allocation is not used when calling Allocate/Free, just use regular dynamic allocation. ; if false -> Use pool allocation. DisableMemoryPool=false +RespawnTime = 8.0 EditorEnabled=false OutOfBodyExperience=false diff --git a/resources/DefaultInput.ini b/resources/DefaultInput.ini index 683d48e2..d5489c3a 100644 --- a/resources/DefaultInput.ini +++ b/resources/DefaultInput.ini @@ -24,4 +24,5 @@ F1=ToggleEditor C=ConnectToServer N=SwitchToServer M=SwitchToClient -P=SwitchToPlayer \ No newline at end of file +P=SwitchToPlayer +K=TakeDamage,1500 \ No newline at end of file diff --git a/resources/Schema/Components.xsd b/resources/Schema/Components.xsd index 2a1b67e0..ee4d7424 100644 --- a/resources/Schema/Components.xsd +++ b/resources/Schema/Components.xsd @@ -32,6 +32,7 @@ + diff --git a/resources/Schema/Components/AmmoPickup.xml b/resources/Schema/Components/AmmoPickup.xml new file mode 100644 index 00000000..6da0b6fa --- /dev/null +++ b/resources/Schema/Components/AmmoPickup.xml @@ -0,0 +1,5 @@ + + + 3 + 30 + \ No newline at end of file diff --git a/resources/Schema/Components/AmmoPickup.xsd b/resources/Schema/Components/AmmoPickup.xsd new file mode 100644 index 00000000..1970eb78 --- /dev/null +++ b/resources/Schema/Components/AmmoPickup.xsd @@ -0,0 +1,21 @@ + + + + + + + + An Ammo Pickup + + + + + The respawn timer for a ammo pickup + + + How much percent ammo gain the player will get + + + + + diff --git a/resources/Schema/Entities/AmmoPickup.xml b/resources/Schema/Entities/AmmoPickup.xml new file mode 100644 index 00000000..534b76e2 --- /dev/null +++ b/resources/Schema/Entities/AmmoPickup.xml @@ -0,0 +1,18 @@ + + + + + + + + Models/Core/UnitSphere.mesh + + + + + + + + + + diff --git a/resources/Schema/Entities/AmmoPickupTest.xml b/resources/Schema/Entities/AmmoPickupTest.xml new file mode 100644 index 00000000..22690c65 --- /dev/null +++ b/resources/Schema/Entities/AmmoPickupTest.xml @@ -0,0 +1,294 @@ + + + + + + + + + + + + Models/LevelBase/MapVersion1.mesh + + + + + + + + + 2 + + + Models/DirectionalLightWidget.mesh + false + + + + + + + + + + + + + 8 + 2.7999999523162842 + + + + + + + + + + + 8 + 2.7999999523162842 + + + + + + + + + + + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + Models/Core/UnitCube.mesh + false + + + Schema/Entities/Player.xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Models/Core/UnitCube.mesh + false + + + Schema/Entities/Player.xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + 22 + + + Models/Core/UnitSphere.mesh + + + + + + + + + + + + + 1 + 22 + + + Models/Core/UnitSphere.mesh + + + + + + + + + + + + + 4 + 44 + + + Models/Core/UnitSphere.mesh + + + + + + + + + + + diff --git a/resources/Schema/Entities/NewMap.xml b/resources/Schema/Entities/NewMap.xml index f4c768f0..d67540da 100644 --- a/resources/Schema/Entities/NewMap.xml +++ b/resources/Schema/Entities/NewMap.xml @@ -210,8 +210,7 @@ - Models/Props/Pillars/SciFiPillar1.mesh - + Models/Props/Pillars/SciFiPillar1Blue.mesh @@ -224,12 +223,11 @@ - Models/Props/Pillars/SciFiPillar1.mesh - + Models/Props/Pillars/SciFiPillar1Red.mesh - - + + @@ -263,7 +261,7 @@ - Models/Props/Pillars/SciFiPillar2.mesh + Models/Props/Pillars/SciFiPillar2Red.mesh @@ -276,7 +274,7 @@ - Models/Props/Pillars/SciFiPillar3.mesh + Models/Props/Pillars/SciFiPillar3Blue.mesh @@ -290,10 +288,10 @@ - Models/Props/Pillars/SciFiPillar1.mesh + Models/Props/Pillars/SciFiPillar1Blue.mesh - + @@ -304,10 +302,10 @@ - Models/Props/Pillars/SciFiPillar1.mesh + Models/Props/Pillars/SciFiPillar1Red.mesh - + @@ -318,7 +316,7 @@ - Models/Props/Pillars/SciFiPillar3.mesh + Models/Props/Pillars/SciFiPillar3Red.mesh @@ -360,8 +358,8 @@ Models/Props/Pillars/StonePillar.mesh - - + + @@ -386,7 +384,7 @@ Models/Props/Pillars/SciFiPillar2.mesh - + @@ -418,6 +416,141 @@ + + + + + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + @@ -429,7 +562,7 @@ - Models/Props/Walls/BigWall.mesh + Models/Props/Walls/BigWallBlue.mesh @@ -440,7 +573,7 @@ - Models/Props/Walls/BigWall.mesh + Models/Props/Walls/BigWallBlue.mesh @@ -455,10 +588,10 @@ - Models/Props/Walls/BigWall.mesh + Models/Props/Walls/BigWallBlue.mesh - + @@ -466,7 +599,7 @@ - Models/Props/Walls/BigWall.mesh + Models/Props/Walls/BigWallBlue.mesh @@ -480,10 +613,10 @@ - Models/Props/Walls/BigWall.mesh + Models/Props/Walls/BigWallRed.mesh - + @@ -492,9 +625,10 @@ - Models/Props/Walls/BigWall.mesh + Models/Props/Walls/BigWallRed.mesh + @@ -506,10 +640,10 @@ - Models/Props/Walls/BigWall.mesh + Models/Props/Walls/BigWallRed.mesh - + @@ -518,10 +652,11 @@ - Models/Props/Walls/BigWall.mesh + Models/Props/Walls/BigWallRed.mesh - + + @@ -532,7 +667,7 @@ - Models/Props/Walls/BigWall.mesh + Models/Props/Walls/BigWallRed.mesh @@ -544,7 +679,7 @@ - Models/Props/Walls/BigWall.mesh + Models/Props/Walls/BigWallRed.mesh @@ -558,7 +693,7 @@ - Models/Props/Walls/BigWall.mesh + Models/Props/Walls/BigWallRed.mesh @@ -574,7 +709,7 @@ - Models/Props/Walls/BigWall.mesh + Models/Props/Walls/BigWallBlue.mesh @@ -586,7 +721,7 @@ - Models/Props/Walls/BigWall.mesh + Models/Props/Walls/BigWallBlue.mesh @@ -599,7 +734,7 @@ - Models/Props/Walls/BigWall.mesh + Models/Props/Walls/BigWallBlue.mesh @@ -682,8 +817,8 @@ Models/Props/Walls/SmallWall2.mesh - - + + @@ -807,10 +942,10 @@ - Models/Props/Walls/MediumWall3.mesh + Models/Props/Walls/MediumWall1.mesh - + @@ -819,10 +954,10 @@ - Models/Props/Walls/MediumWall3.mesh + Models/Props/Walls/MediumWall1.mesh - + @@ -831,10 +966,10 @@ - Models/Props/Walls/MediumWall3.mesh + Models/Props/Walls/MediumWall1.mesh - + @@ -845,7 +980,7 @@ - Models/Props/Walls/BigWall.mesh + Models/Props/Walls/BigWallRed.mesh @@ -856,7 +991,7 @@ - Models/Props/Walls/BigWall.mesh + Models/Props/Walls/BigWallRed.mesh @@ -868,7 +1003,7 @@ - Models/Props/Walls/BigWall.mesh + Models/Props/Walls/BigWallRed.mesh @@ -879,7 +1014,7 @@ - Models/Props/Walls/BigWall.mesh + Models/Props/Walls/BigWallRed.mesh @@ -895,7 +1030,7 @@ - Models/Props/Walls/BigWall.mesh + Models/Props/Walls/BigWallRed.mesh @@ -908,7 +1043,7 @@ - Models/Props/Walls/BigWall.mesh + Models/Props/Walls/BigWallRed.mesh @@ -922,7 +1057,7 @@ - Models/Props/Walls/BigWall.mesh + Models/Props/Walls/BigWallBlue.mesh @@ -933,7 +1068,7 @@ - Models/Props/Walls/BigWall.mesh + Models/Props/Walls/BigWallBlue.mesh @@ -945,7 +1080,7 @@ - Models/Props/Walls/BigWall.mesh + Models/Props/Walls/BigWallBlue.mesh @@ -957,7 +1092,7 @@ - Models/Props/Walls/BigWall.mesh + Models/Props/Walls/BigWallBlue.mesh @@ -971,7 +1106,7 @@ - Models/Props/Walls/BigWall.mesh + Models/Props/Walls/BigWallBlue.mesh @@ -1061,10 +1196,11 @@ - Models/Props/Walls/BigWall.mesh + Models/Props/Walls/BigWallBlue.mesh - + + @@ -1072,10 +1208,10 @@ - Models/Props/Walls/BigWall.mesh + Models/Props/Walls/BigWallBlue.mesh - + @@ -1083,9 +1219,10 @@ - Models/Props/Walls/BigWall.mesh + Models/Props/Walls/BigWallBlue.mesh + @@ -1114,7 +1251,7 @@ Models/Props/Walls/SmallWall2.mesh - + @@ -1122,7 +1259,7 @@ - Models/Props/Walls/BigWall.mesh + Models/Props/Walls/BigWallBlue.mesh @@ -1133,7 +1270,7 @@ - Models/Props/Walls/BigWall.mesh + Models/Props/Walls/BigWallBlue.mesh @@ -1149,10 +1286,10 @@ - Models/Props/Walls/BigWall.mesh + Models/Props/Walls/BigWallBlue.mesh - + @@ -1160,10 +1297,10 @@ - Models/Props/Walls/BigWall.mesh + Models/Props/Walls/BigWallBlue.mesh - + @@ -1172,7 +1309,7 @@ - Models/Props/Walls/BigWall.mesh + Models/Props/Walls/BigWallBlue.mesh @@ -1184,7 +1321,7 @@ - Models/Props/Walls/BigWall.mesh + Models/Props/Walls/BigWallBlue.mesh @@ -1198,7 +1335,7 @@ - Models/Props/Walls/BigWall.mesh + Models/Props/Walls/BigWallBlue.mesh @@ -1210,7 +1347,7 @@ - Models/Props/Walls/BigWall.mesh + Models/Props/Walls/BigWallBlue.mesh @@ -1228,8 +1365,8 @@ Models/Props/Walls/MediumWall3.mesh - - + + @@ -1238,10 +1375,10 @@ - Models/Props/Walls/BigWall.mesh + Models/Props/Walls/BigWallRed.mesh - + @@ -1249,10 +1386,10 @@ - Models/Props/Walls/BigWall.mesh + Models/Props/Walls/BigWallRed.mesh - + @@ -1261,10 +1398,10 @@ - Models/Props/Walls/BigWall.mesh + Models/Props/Walls/BigWallRed.mesh - + @@ -1275,10 +1412,10 @@ - Models/Props/Walls/BigWall.mesh + Models/Props/Walls/BigWallRed.mesh - + @@ -1287,10 +1424,10 @@ - Models/Props/Walls/BigWall.mesh + Models/Props/Walls/BigWallRed.mesh - + @@ -1301,11 +1438,11 @@ - Models/Props/Walls/BigWall.mesh + Models/Props/Walls/BigWallRed.mesh - - + + @@ -1313,7 +1450,7 @@ - Models/Props/Walls/BigWall.mesh + Models/Props/Walls/BigWallRed.mesh @@ -1328,7 +1465,7 @@ Models/Props/Walls/SmallWall2.mesh - + @@ -1337,10 +1474,10 @@ - Models/Props/Walls/BigWall.mesh + Models/Props/Walls/BigWallRed.mesh - + @@ -1366,8 +1503,9 @@ Models/Props/Walls/SpecialWall1.mesh - - + + + @@ -1418,7 +1556,7 @@ Models/Props/Walls/MediumWall1.mesh - + @@ -1430,8 +1568,8 @@ Models/Props/Walls/MediumWall3.mesh - - + + @@ -1443,7 +1581,7 @@ Models/Props/Walls/MediumWall1.mesh - + @@ -1469,12 +1607,232 @@ Models/Props/Walls/SmallWall2.mesh - + + + + + + Models/Props/Walls/SmallWall2.mesh + + + + + + + + + + + + Models/Props/Walls/SmallWall2.mesh + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + Models/Props/Walls/SmallWall4.mesh + + + + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + @@ -1489,23 +1847,9 @@ Models/Props/Bridges/WoodenBridge.mesh - - - - - - - - - - - - Models/Props/Bridges/WoodenBridge.mesh - - - + - + @@ -1517,7 +1861,21 @@ Models/Props/Bridges/WoodenBridge.mesh - + + + + + + + + + + + + Models/Props/Bridges/WoodenBridge.mesh + + + @@ -1766,12 +2124,92 @@ - Models/Props/Flora/TreeLog.mesh + Models/Props/Pillars/SciFiBridgePillar1.mesh - - - + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge.mesh + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiBridgePillar1.mesh + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge.mesh + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge.mesh + + + + + + + + + + + + + Models/Props/Bridges/WoodenBridge.mesh + + + + + @@ -1869,8 +2307,7 @@ Models/Props/Pillars/SciFiBridgePillar1.mesh - - + @@ -1897,8 +2334,8 @@ Models/Props/Walls/MediumWall1.mesh - - + + @@ -1981,6 +2418,93 @@ + + + + Models/Core/UnitPlane.mesh + + true + + + + + + + + + + + + + Models/Core/UnitPlane.mesh + + true + + + + + + + + + + + + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + + + + Models/Props/Pillars/SciFiBridgePillar1.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiBridgePillar1.mesh + + + + + + + + + @@ -1995,59 +2519,11 @@ true - + + - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - + @@ -2155,7 +2631,7 @@ true - + @@ -2383,6 +2859,216 @@ + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + + + Models/Props/Flora/SpecialRoot.mesh + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + + + Models/Props/Flora/SpecialRoot.mesh + + + + + + + + @@ -2407,28 +3093,15 @@ - Models/Props/Stones/BigStone.mesh + Models/Props/Stones/MediumStone2.mesh - - + + + - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - + @@ -2443,149 +3116,6 @@ - - - - - Models/Props/Stones/MediumStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone1.mesh - - - - - - - - - - - - Models/Props/Stones/MediumStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone1.mesh - - - - - - - - - - - - Models/Props/Stones/MediumStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone1.mesh - - - - - - - - - - @@ -2593,8 +3123,9 @@ Models/Props/Stones/BigStone.mesh - - + + + @@ -2647,8 +3178,8 @@ Models/Props/Stones/BigStone.mesh - - + + @@ -2660,8 +3191,9 @@ Models/Props/Stones/MediumStone1.mesh - - + + + @@ -2670,11 +3202,12 @@ - Models/Props/Stones/MediumStone1.mesh + Models/Props/Stones/SmallStone1.mesh - - + + + @@ -2726,91 +3259,12 @@ Models/Props/Stones/MediumStone1.mesh - - + + + - - - - - - Models/Props/Stones/MediumStone1.mesh - - - - - - - - - - - - - - - Models/Props/Stones/MediumStone1.mesh - - - - - - - - - - - - Models/Props/Stones/MediumStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone1.mesh - - - - - - - - - - - - Models/Props/Stones/MediumStone1.mesh - - - - - - - - - - + @@ -2819,7 +3273,7 @@ Models/Props/Stones/BigStone.mesh - + @@ -2831,8 +3285,8 @@ Models/Props/Stones/BigStone.mesh - - + + @@ -2844,8 +3298,8 @@ Models/Props/Stones/BigStone.mesh - - + + @@ -2883,8 +3337,8 @@ Models/Props/Stones/BigStone.mesh - - + + @@ -2910,8 +3364,9 @@ Models/Props/Stones/BigStone.mesh - - + + + @@ -2925,8 +3380,8 @@ Models/Props/Stones/BigStone.mesh - - + + @@ -2973,38 +3428,12 @@ - Models/Props/Stones/MediumStone1.mesh + Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - Models/Props/Stones/MediumStone1.mesh - - - - - - - - - - - - - - - Models/Props/Stones/MediumStone1.mesh - - - - + + + @@ -3013,10 +3442,11 @@ - Models/Props/Stones/MediumStone1.mesh + Models/Props/Stones/MediumStone2.mesh - + + @@ -3025,10 +3455,11 @@ - Models/Props/Stones/ShinyStoneCrystal.mesh + Models/Props/Stones/ShinyStoneCrystalRed.mesh - + + @@ -3038,11 +3469,12 @@ - Models/Props/Stones/ShinyStoneCrystal.mesh + Models/Props/Stones/ShinyStoneCrystalRed.mesh - - + + + @@ -3051,11 +3483,12 @@ - Models/Props/Stones/ShinyStoneCrystal.mesh + Models/Props/Stones/ShinyStoneCrystalRed.mesh - - + + + @@ -3067,7 +3500,477 @@ Models/Props/Walls/MediumWall1.mesh - + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + @@ -3087,7 +3990,7 @@ - + @@ -3100,9 +4003,9 @@ Models/Props/PickUps/PickUpHolder.mesh - - - + + + @@ -3115,7 +4018,7 @@ - + @@ -3128,8 +4031,58 @@ Models/Props/PickUps/PickUpHolder.mesh - - + + + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + @@ -3141,9 +4094,9 @@ Models/Props/PickUps/PickUpHolder.mesh - - - + + + @@ -3155,8 +4108,23 @@ Models/Props/PickUps/PickUpHolder.mesh - - + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + @@ -3277,6 +4245,62 @@ + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + @@ -3304,8 +4328,8 @@ Models/Props/SciFiHolder1.mesh - - + + @@ -3336,6 +4360,299 @@ + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + @@ -3352,7 +4669,7 @@ Models/Props/CapturePoint/CapturePointBlue.mesh - + @@ -3365,7 +4682,7 @@ Models/Core/UnitCylinder.mesh - + true @@ -3401,7 +4718,7 @@ Models/Core/UnitCylinder.mesh - + true @@ -3461,11 +4778,12 @@ + 1.5498908015879351 3 Models/Core/UnitCylinder.mesh - + true @@ -3483,7 +4801,7 @@ - Models/Props/CapturePoint/CapturePointNeutral.mesh + Models/Props/CapturePoint/CapturePointRed.mesh @@ -3500,7 +4818,7 @@ Models/Core/UnitCylinder.mesh - + true @@ -3596,24 +4914,13 @@ 1 - + - - - - Models/Characters/Assault/AssaultTPose.mesh - - - - - - - @@ -3680,155 +4987,6 @@ - - - - - Models/Props/Stones/MediumStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone1.mesh - - - - - - - - - - - - Models/Props/Stones/MediumStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone1.mesh - - - - - - - - - - - - Models/Props/Stones/MediumStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone1.mesh - - - - - - - - - - - - - - - - diff --git a/src/Game/Game.cpp b/src/Game/Game.cpp index 693a67bb..e7e1eb48 100644 --- a/src/Game/Game.cpp +++ b/src/Game/Game.cpp @@ -14,6 +14,7 @@ #include "Game/Systems/CapturePointSystem.h" #include "Game/Systems/CapturePointHUDSystem.h" #include "Game/Systems/PickupSpawnSystem.h" +#include "Game/Systems/AmmoPickupSystem.h" #include "Game/Systems/DamageIndicatorSystem.h" #include "Game/Systems/Weapon/WeaponSystem.h" #include "Rendering/AnimationSystem.h" @@ -44,6 +45,7 @@ Game::Game(int argc, char* argv[]) ResourceManager::UseThreading = m_Config->Get("Multithreading.ResourceLoading", true); DisableMemoryPool::Value = m_Config->Get("Debug.DisableMemoryPool", false); LOG_LEVEL = static_cast<_LOG_LEVEL>(m_Config->Get("Debug.LogLevel", 1)); + PlayerSpawnSystem::SetRespawnTime(m_Config->Get("Debug.RespawnTime", 15.0f)); // Create the core event broker m_EventBroker = new EventBroker(); @@ -120,12 +122,12 @@ Game::Game(int argc, char* argv[]) m_SystemPipeline->AddSystem(updateOrderLevel); m_SystemPipeline->AddSystem(updateOrderLevel); m_SystemPipeline->AddSystem(updateOrderLevel); - m_SystemPipeline->AddSystem(updateOrderLevel); m_SystemPipeline->AddSystem(updateOrderLevel, m_Renderer, m_OctreeCollision); m_SystemPipeline->AddSystem(updateOrderLevel); m_SystemPipeline->AddSystem(updateOrderLevel); m_SystemPipeline->AddSystem(updateOrderLevel); m_SystemPipeline->AddSystem(updateOrderLevel); + m_SystemPipeline->AddSystem(updateOrderLevel); m_SystemPipeline->AddSystem(updateOrderLevel); m_SystemPipeline->AddSystem(updateOrderLevel); // Populate Octree with collidables @@ -136,6 +138,7 @@ Game::Game(int argc, char* argv[]) m_SystemPipeline->AddSystem(updateOrderLevel); m_SystemPipeline->AddSystem(updateOrderLevel); m_SystemPipeline->AddSystem(updateOrderLevel); + m_SystemPipeline->AddSystem(updateOrderLevel); // Collision and TriggerSystem should update after player. ++updateOrderLevel; m_SystemPipeline->AddSystem(updateOrderLevel); diff --git a/src/Game/Systems/AmmoPickupSystem.cpp b/src/Game/Systems/AmmoPickupSystem.cpp new file mode 100644 index 00000000..f6778fe4 --- /dev/null +++ b/src/Game/Systems/AmmoPickupSystem.cpp @@ -0,0 +1,78 @@ +#include "Systems/AmmoPickupSystem.h" + +AmmoPickupSystem::AmmoPickupSystem(SystemParams params) + : System(params) +{ + EVENT_SUBSCRIBE_MEMBER(m_ETriggerTouch, &AmmoPickupSystem::OnTriggerTouch); +} + +void AmmoPickupSystem::Update(double dt) +{ + for (auto it = m_ETriggerTouchVector.begin(); it != m_ETriggerTouchVector.end(); ++it) + { + auto& ammoPickupPosition = *it; + //set the double timer value (value 3) + ammoPickupPosition.DecreaseThisRespawnTimer -= dt; + if (ammoPickupPosition.DecreaseThisRespawnTimer < 0.0) { + //spawn and delete the vector item + auto entityFile = ResourceManager::Load("Schema/Entities/AmmoPickup.xml"); + EntityFileParser parser(entityFile); + EntityID ammoPickupID = parser.MergeEntities(m_World); + + //let the world know a pickup has spawned (graphics effects, etc) + Events::PickupSpawned ePickupSpawned; + ePickupSpawned.Pickup = EntityWrapper(m_World, ammoPickupID); + m_EventBroker->Publish(ePickupSpawned); + + //set values from the old entity to the new entity + auto& newAmmoPickupEntity = EntityWrapper(m_World, ammoPickupID); + newAmmoPickupEntity["Transform"]["Position"] = ammoPickupPosition.Pos; + newAmmoPickupEntity["AmmoPickup"]["AmmoGain"] = ammoPickupPosition.AmmoGain; + newAmmoPickupEntity["AmmoPickup"]["RespawnTimer"] = ammoPickupPosition.RespawnTimer; + + //erase the current element (AmmoPickupPosition) + m_ETriggerTouchVector.erase(it); + break; + } + } +} + + +bool AmmoPickupSystem::OnTriggerTouch(Events::TriggerTouch& e) +{ + if (e.Entity != LocalPlayer) { + return false; + } + //TODO: add other weapontypes + if (!e.Entity.HasComponent("AssaultWeapon")) { + return false; + } + if (!e.Trigger.HasComponent("AmmoPickup")) { + return false; + } + int maxWeaponAmmo = (int)e.Entity["AssaultWeapon"]["MaxAmmo"]; + int& currentAmmo = (int)e.Entity["AssaultWeapon"]["Ammo"]; + + int ammoGiven = 0.01*(double)e.Trigger["AmmoPickup"]["AmmoGain"] * maxWeaponAmmo; + //cant pick up ammopacks if you are already at MaxAmmo + if (currentAmmo >= maxWeaponAmmo) { + return false; + } + + //personEntered = e.Entity, thingEntered = e.Trigger + Events::AmmoPickup ePlayerAmmoPickup; + ePlayerAmmoPickup.AmmoGain = ammoGiven; + ePlayerAmmoPickup.Player = e.Entity; + m_EventBroker->Publish(ePlayerAmmoPickup); + //immediately give the player the ammo + currentAmmo = std::min(currentAmmo + ammoGiven, maxWeaponAmmo); + + //copy position, ammogain, respawntimer (twice since one of the values will be counted down to 0, the other will be set in the new object) + //we need to copy all values since each value can be different for each ammoPickup + m_ETriggerTouchVector.push_back({ (glm::vec3)e.Trigger["Transform"]["Position"] ,e.Trigger["AmmoPickup"]["AmmoGain"], + e.Trigger["AmmoPickup"]["RespawnTimer"],e.Trigger["AmmoPickup"]["RespawnTimer"] }); + + //delete the ammopickup + m_World->DeleteEntity(e.Trigger.ID); + return true; +} diff --git a/src/Game/Systems/DamageIndicatorSystem.cpp b/src/Game/Systems/DamageIndicatorSystem.cpp index a29309b5..8d586ac1 100644 --- a/src/Game/Systems/DamageIndicatorSystem.cpp +++ b/src/Game/Systems/DamageIndicatorSystem.cpp @@ -22,6 +22,10 @@ bool DamageIndicatorSystem::OnPlayerDamage(Events::PlayerDamage& e) return false; } + if (!e.Inflictor.Valid() || !e.Victim.Valid()) { + return false; + } + //grab players direction auto playerOrientation = glm::quat((glm::vec3)e.Victim["Transform"]["Orientation"]); diff --git a/src/Game/Systems/HealthSystem.cpp b/src/Game/Systems/HealthSystem.cpp index 29d8790d..0fc113b9 100644 --- a/src/Game/Systems/HealthSystem.cpp +++ b/src/Game/Systems/HealthSystem.cpp @@ -7,6 +7,7 @@ HealthSystem::HealthSystem(SystemParams params) //subscribe/listenTo playerdamage,healthpickup events (using the eventBroker) EVENT_SUBSCRIBE_MEMBER(m_EPlayerDamage, &HealthSystem::OnPlayerDamaged); EVENT_SUBSCRIBE_MEMBER(m_EPlayerHealthPickup, &HealthSystem::OnPlayerHealthPickup); + EVENT_SUBSCRIBE_MEMBER(m_InputCommand, &HealthSystem::OnInputCommand); } void HealthSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& component, double dt) @@ -29,6 +30,17 @@ bool HealthSystem::OnPlayerDamaged(Events::PlayerDamage& e) return true; } +bool HealthSystem::OnInputCommand(Events::InputCommand& e) +{ + if (e.Command == "TakeDamage" && e.Value > 0 && LocalPlayer.Valid()) { + Events::PlayerDamage ev; + ev.Victim = LocalPlayer; + ev.Damage = e.Value; + m_EventBroker->Publish(ev); + } + return true; +} + bool HealthSystem::OnPlayerHealthPickup(Events::PlayerHealthPickup& e) { ComponentWrapper cHealth = e.Player["Health"]; diff --git a/src/Game/Systems/PlayerDeathSystem.cpp b/src/Game/Systems/PlayerDeathSystem.cpp index 78e20490..40a98278 100644 --- a/src/Game/Systems/PlayerDeathSystem.cpp +++ b/src/Game/Systems/PlayerDeathSystem.cpp @@ -34,8 +34,15 @@ void PlayerDeathSystem::createDeathEffect(EntityWrapper player) //components that we need from player auto playerCamera = player.FirstChildByName("Camera"); - auto playerEntityModel = player.FirstChildByName("PlayerModel")["Model"]; - auto playerEntityAnimation = player.FirstChildByName("PlayerModel")["Animation"]; + auto playerModel = player.FirstChildByName("PlayerModel"); + if (!playerCamera.Valid() || !playerModel.Valid()) { + return; + } + if (!playerModel.HasComponent("Model") || !playerModel.HasComponent("Animation")) { + return; + } + auto playerEntityModel = playerModel["Model"]; + auto playerEntityAnimation = playerModel["Animation"]; //copy the data from player to explisioneffectmodel playerEntityModel.Copy(deathEffectEW["Model"]); diff --git a/src/Game/Systems/PlayerSpawnSystem.cpp b/src/Game/Systems/PlayerSpawnSystem.cpp index 444fc08f..ac0ecdf3 100644 --- a/src/Game/Systems/PlayerSpawnSystem.cpp +++ b/src/Game/Systems/PlayerSpawnSystem.cpp @@ -1,20 +1,39 @@ #include "Systems/PlayerSpawnSystem.h" +//This should be set by the config anyway. +float PlayerSpawnSystem::m_RespawnTime = 15.0f; + PlayerSpawnSystem::PlayerSpawnSystem(SystemParams params) : System(params) + , m_Timer(0.f) { EVENT_SUBSCRIBE_MEMBER(m_OnInputCommand, &PlayerSpawnSystem::OnInputCommand); EVENT_SUBSCRIBE_MEMBER(m_OnPlayerSpawnerd, &PlayerSpawnSystem::OnPlayerSpawned); + EVENT_SUBSCRIBE_MEMBER(m_OnPlayerDeath, &PlayerSpawnSystem::OnPlayerDeath); m_NetworkEnabled = ResourceManager::Load("Config.ini")->Get("Networking.StartNetwork", false); } void PlayerSpawnSystem::Update(double dt) { + //Increase timer. + m_Timer += dt; + if (m_Timer < m_RespawnTime) { + return; + } + //If respawn time has passed, we spawn all players that have requested to be spawned. + m_Timer = 0.f; + + //If there are no spawn requests, return immediately, if we are client the SpawnRequests should always be empty. + if (m_SpawnRequests.size() == 0) { + return; + } + auto playerSpawns = m_World->GetComponents("PlayerSpawn"); if (playerSpawns == nullptr) { return; } + int numSpawnedPlayers = 0; for (auto& req : m_SpawnRequests) { for (auto& cPlayerSpawn : *playerSpawns) { EntityWrapper spawner(m_World, cPlayerSpawn.EntityID); @@ -40,29 +59,61 @@ void PlayerSpawnSystem::Update(double dt) e.Player = player; e.Spawner = spawner; m_EventBroker->Publish(e); - + ++numSpawnedPlayers; + break; } } + if (numSpawnedPlayers != (int)m_SpawnRequests.size()) { + LOG_DEBUG("%i players were supposed to be spawned, but %i was spawned.", (int)m_SpawnRequests.size(), numSpawnedPlayers); + } else { + LOG_DEBUG("%i players were spawned.", numSpawnedPlayers); + } m_SpawnRequests.clear(); } -bool PlayerSpawnSystem::OnInputCommand(const Events::InputCommand& e) +bool PlayerSpawnSystem::OnInputCommand(Events::InputCommand& e) { if (e.Command != "PickTeam") { return false; } // Team picks should be processed ONLY server-side! - // Don't make a spawn request if PlayerID is -1, i.e. we're the client. - if (e.PlayerID == -1 && m_NetworkEnabled) { + // Don't make a spawn request if we're the client. + if (!IsServer && m_NetworkEnabled) { return false; } - if (e.Value != 0) { + if (e.Value == 0) { + return false; + } + + //TODO: Spectating? + //Right now, return if someone picks spectator. + //1 signifies spectator here, could not get Playerteam component since it may be invalid or without team comp. + if ((ComponentInfo::EnumType)e.Value == 1) { + return false; + } + + //Check if the player already requested spawn. + auto iter = m_SpawnRequests.begin(); + for (; iter != m_SpawnRequests.end(); ++iter) { + if (iter->PlayerID == e.PlayerID) { + break; + } + } + + if (iter != m_SpawnRequests.end()) { + //If player is in queue to spawn, then change their team affiliation in the request. + iter->Team = (ComponentInfo::EnumType)e.Value; + } else if (m_PlayerEntities.count(e.PlayerID) == 0 || !m_PlayerEntities[e.PlayerID].Valid()) { + //If player is not in queue to spawn, then create a spawn request, + //but only if they are spectating and/or just connected. SpawnRequest req; req.PlayerID = e.PlayerID; req.Team = (ComponentInfo::EnumType)e.Value; m_SpawnRequests.push_back(req); + } else { + return false; } return true; @@ -70,21 +121,15 @@ bool PlayerSpawnSystem::OnInputCommand(const Events::InputCommand& e) bool PlayerSpawnSystem::OnPlayerSpawned(Events::PlayerSpawned& e) { + // Store the player for future reference + m_PlayerEntities[e.PlayerID] = e.Player; + m_PlayerIDs[e.Player.ID] = e.PlayerID; + // When a player is actually spawned (since the actual spawning is handled on the server) if (!IsClient) { return false; } - // Check if a player already exists - if (m_PlayerEntities.count(e.PlayerID) != 0) { - // TODO: Disallow infinite respawning here - if (m_PlayerEntities[e.PlayerID].Valid()) { - m_World->DeleteEntity(m_PlayerEntities[e.PlayerID].ID); - } - } - - // Store the player for future reference - m_PlayerEntities[e.PlayerID] = e.Player; // Set the camera to the correct entity EntityWrapper cameraEntity = e.Player.FirstChildByName("Camera"); @@ -114,4 +159,24 @@ bool PlayerSpawnSystem::OnPlayerSpawned(Events::PlayerSpawned& e) } return true; -} \ No newline at end of file +} + +bool PlayerSpawnSystem::OnPlayerDeath(Events::PlayerDeath& e) +{ + //Only spawn request if network is disabled or we are server. + if (!IsServer && m_NetworkEnabled) { + return false; + } + if (!e.Player.HasComponent("Team")) { + return false; + } + ComponentWrapper cTeam = e.Player["Team"]; + //A spectator can't die anyway + if ((ComponentInfo::EnumType)cTeam["Team"] == cTeam["Team"].Enum("Spectator")) { + return false; + } + SpawnRequest req; + req.PlayerID = m_PlayerIDs.at(e.Player.ID); + req.Team = cTeam["Team"]; + m_SpawnRequests.push_back(req); +} diff --git a/src/Game/Systems/SoundSystem.cpp b/src/Game/Systems/SoundSystem.cpp index d6ac7dab..59fd4a7f 100644 --- a/src/Game/Systems/SoundSystem.cpp +++ b/src/Game/Systems/SoundSystem.cpp @@ -52,12 +52,6 @@ bool SoundSystem::OnInputCommand(const Events::InputCommand & e) return true; } } - if (e.Command == "TakeDamage" && e.Value > 0) { - Events::PlayerDamage ev; - ev.Victim = LocalPlayer; - ev.Damage = 1.0; - m_EventBroker->Publish(ev); - } return false; }