miscellaneous tests

This commit is contained in:
verysecrethero
2016-02-24 17:43:24 +01:00
parent 9bba9e493c
commit cca237b33f
14 changed files with 4526 additions and 28 deletions
+1
View File
@@ -26,6 +26,7 @@ private:
double AmmoGain;
double RespawnTimer;
double DecreaseThisRespawnTimer;
EntityID parentID;
};
std::vector<NewAmmoPickup> m_ETriggerTouchVector;
};
+1 -1
View File
@@ -42,6 +42,6 @@ private:
//for tests
int m_TestVar = 0;
bool m_Testing = true;
bool m_Testing = false;
};
#endif
+11 -1
View File
@@ -27,7 +27,7 @@ public:
private:
bool m_NetworkEnabled;
// methods which will take care of specific events
// methods which will take care of specific events
EventRelay<HealthSystem, Events::PlayerDamage> m_EPlayerDamage;
bool HealthSystem::OnPlayerDamaged(Events::PlayerDamage& e);
EventRelay<HealthSystem, Events::PlayerHealthPickup> m_EPlayerHealthPickup;
@@ -37,6 +37,16 @@ private:
//vector which will keep track of health changes
std::vector<std::tuple<EntityID, double>> m_DeltaHealthVector;
struct DeadPlayers {
EntityWrapper playerEntity;
double timeSinceDeath;
DeadPlayers(EntityWrapper entity) : playerEntity(entity) {
timeSinceDeath = 0.0;
}
};
std::vector<DeadPlayers> m_DeadPlayers;
};
#endif
+1
View File
@@ -27,6 +27,7 @@ private:
double HealthGain;
double RespawnTimer;
double DecreaseThisRespawnTimer;
EntityID parentID;
};
std::vector<NewHealthPickup> m_ETriggerTouchVector;
};
+4
View File
@@ -21,6 +21,7 @@ private:
{
int PlayerID;
ComponentInfo::EnumType Team;
double timeSinceDeath;
};
bool m_NetworkEnabled = false;
@@ -40,4 +41,7 @@ private:
bool OnPlayerSpawned(Events::PlayerSpawned& e);
EventRelay<PlayerSpawnSystem, Events::PlayerDeath> m_OnPlayerDeath;
bool OnPlayerDeath(Events::PlayerDeath& e);
std::vector<SpawnRequest> m_LatePlayersVector;
void CheckForLatePlayers(double dt);
};
+5 -5
View File
@@ -2,18 +2,18 @@
<Entity xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
<Components>
<c:AABB/>
<c:AmmoPickup/>
<c:Model>
<Resource>Models/Props/PickUps/AmmoPickUp.mesh</Resource>
</c:Model>
<c:RaptorCopter>
<Speed>0.1</Speed>
<Axis X="0" Y="1" Z="0"/>
<Speed>8</Speed>
<Axis X="0" Y="0.100000001" Z="0"/>
</c:RaptorCopter>
<c:Transform>
<Position X="0" Y="1" Z="0"/>
<Scale X="0.3" Y="0.3" Z="0.3"/>
<Position X="0" Y="2.36784196" Z="0"/>
<Scale X="0.600000024" Y="0.600000024" Z="0.600000024"/>
<Orientation X="0" Y="18717.9453" Z="0"/>
</c:Transform>
<c:Trigger/>
</Components>
+5 -5
View File
@@ -2,18 +2,18 @@
<Entity xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
<Components>
<c:AABB/>
<c:HealthPickup/>
<c:Model>
<Resource>Models/Props/PickUps/HealthPickUp.mesh</Resource>
</c:Model>
<c:RaptorCopter>
<Speed>0.1</Speed>
<Axis X="0" Y="1" Z="0"/>
<Speed>8</Speed>
<Axis X="0" Y="0.100000001" Z="0"/>
</c:RaptorCopter>
<c:Transform>
<Position X="0" Y="1" Z="0"/>
<Scale X="0.3" Y="0.3" Z="0.3"/>
<Position X="0" Y="2.36784196" Z="0"/>
<Scale X="0.600000024" Y="0.600000024" Z="0.600000024"/>
<Orientation X="0" Y="18767.0273" Z="0"/>
</c:Transform>
<c:Trigger/>
</Components>
File diff suppressed because it is too large Load Diff
+3 -2
View File
@@ -29,6 +29,7 @@ void AmmoPickupSystem::Update(double dt)
newAmmoPickupEntity["Transform"]["Position"] = ammoPickupPosition.Pos;
newAmmoPickupEntity["AmmoPickup"]["AmmoGain"] = ammoPickupPosition.AmmoGain;
newAmmoPickupEntity["AmmoPickup"]["RespawnTimer"] = ammoPickupPosition.RespawnTimer;
m_World->SetParent(newAmmoPickupEntity.ID, ammoPickupPosition.parentID);
//erase the current element (AmmoPickupPosition)
m_ETriggerTouchVector.erase(it);
@@ -69,8 +70,8 @@ bool AmmoPickupSystem::OnTriggerTouch(Events::TriggerTouch& e)
//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"] });
m_ETriggerTouchVector.push_back({ e.Trigger["Transform"]["Position"], e.Trigger["AmmoPickup"]["AmmoGain"],
e.Trigger["AmmoPickup"]["RespawnTimer"], e.Trigger["AmmoPickup"]["RespawnTimer"], m_World->GetParent(e.Trigger.ID) });
//delete the ammopickup
m_World->DeleteEntity(e.Trigger.ID);
+3 -1
View File
@@ -123,7 +123,7 @@ glm::vec3 DamageIndicatorSystem::DamageIndicatorTest(EntityWrapper player) {
}
m_TestVar++;
auto inflictorPos = glm::vec3(currentPos.x + testVar*6.0f, currentPos.y, currentPos.z + testVar2*6.0f);
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");
@@ -143,5 +143,7 @@ glm::vec3 DamageIndicatorSystem::DamageIndicatorTest(EntityWrapper player) {
//copy the models position,orientation
deathEffectEW["Transform"]["Position"] = inflictorPos;
deathEffectEW["Transform"]["Orientation"] = (glm::vec3)player["Transform"]["Orientation"];
deathEffectEW["Lifetime"]["Lifetime"] = 8.0f;
deathEffectEW["ExplosionEffect"]["ExplosionDuration"] = 8.0f;
return inflictorPos;
}
+17 -2
View File
@@ -13,14 +13,29 @@ HealthSystem::HealthSystem(SystemParams params)
void HealthSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& cHealth, double dt)
{
//LOG_INFO("<- health updatecomponent");
double& health = cHealth["Health"];
int healthInt = (int)health;
if (healthInt <= 0 && !entity.HasComponent("Lifetime")) {
//update struct
for (auto& iter = m_DeadPlayers.begin(); iter < m_DeadPlayers.end(); iter++)
{
iter->timeSinceDeath += dt;
if (iter->timeSinceDeath > 2.0f || !iter->playerEntity.Valid()) {
m_DeadPlayers.erase(iter);
break;
}
}
if (healthInt <= 0) {
for (auto deadPlayer : m_DeadPlayers)
{
if (deadPlayer.playerEntity.ID == entity.ID) {
return;
}
}
LOG_INFO("-> health <= 0");
Events::PlayerDeath ePlayerDeath;
ePlayerDeath.Player = entity;
m_EventBroker->Publish(ePlayerDeath);
m_DeadPlayers.emplace_back(entity);
//Note: we will delete the entity in PlayerDeathSystem
}
}
+2 -1
View File
@@ -29,6 +29,7 @@ void PickupSpawnSystem::Update(double dt)
newHealthPickupEntity["Transform"]["Position"] = healthPickupPosition.Pos;
newHealthPickupEntity["HealthPickup"]["HealthGain"] = healthPickupPosition.HealthGain;
newHealthPickupEntity["HealthPickup"]["RespawnTimer"] = healthPickupPosition.RespawnTimer;
m_World->SetParent(newHealthPickupEntity.ID, healthPickupPosition.parentID);
//erase the current element (healthPickupPosition)
m_ETriggerTouchVector.erase(it);
@@ -58,7 +59,7 @@ bool PickupSpawnSystem::OnTriggerTouch(Events::TriggerTouch& e)
//copy position, healthgain, 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 healthPickup
m_ETriggerTouchVector.push_back({ (glm::vec3)e.Trigger["Transform"]["Position"] ,e.Trigger["HealthPickup"]["HealthGain"],
e.Trigger["HealthPickup"]["RespawnTimer"],e.Trigger["HealthPickup"]["RespawnTimer"] });
e.Trigger["HealthPickup"]["RespawnTimer"],e.Trigger["HealthPickup"]["RespawnTimer"], m_World->GetParent(e.Trigger.ID) });
//delete the healthpickup
m_World->DeleteEntity(e.Trigger.ID);
+2 -6
View File
@@ -26,12 +26,8 @@ bool PlayerDeathSystem::OnPlayerDeath(Events::PlayerDeath& e)
LOG_INFO("-> create effect");
// Delete player - only the clients will delete themselves.
if (IsServer && !e.Player.HasComponent("Lifetime")) {
// m_World->DeleteEntity(e.Player.ID);
//m_PlayersToBeDeletedVector.emplace_back(e.Player.ID, 0.25);
e.Player.AttachComponent("Lifetime");
e.Player["Lifetime"]["Lifetime"] = 0.45;
if (!IsClient || !ResourceManager::Load<ConfigFile>("Config.ini")->Get("Networking.StartNetwork", false)) {
m_World->DeleteEntity(e.Player.ID);
}
return true;
+55 -4
View File
@@ -15,6 +15,11 @@ PlayerSpawnSystem::PlayerSpawnSystem(SystemParams params)
void PlayerSpawnSystem::Update(double dt)
{
CheckForLatePlayers(dt);
for (auto& spawnReqs : m_SpawnRequests)
{
spawnReqs.timeSinceDeath += dt;
}
//Increase timer.
m_Timer += dt;
if (m_Timer < m_RespawnTime) {
@@ -35,6 +40,10 @@ void PlayerSpawnSystem::Update(double dt)
int numSpawnedPlayers = 0;
for (auto& req : m_SpawnRequests) {
if (req.timeSinceDeath < 2.5f) {
m_LatePlayersVector.push_back(req);
continue;
}
for (auto& cPlayerSpawn : *playerSpawns) {
EntityWrapper spawner(m_World, cPlayerSpawn.EntityID);
if (!spawner.HasComponent("Spawner")) {
@@ -111,6 +120,8 @@ bool PlayerSpawnSystem::OnInputCommand(Events::InputCommand& e)
SpawnRequest req;
req.PlayerID = e.PlayerID;
req.Team = (ComponentInfo::EnumType)e.Value;
//set timeSinceDeath > 2.5f since we are force-spawning
req.timeSinceDeath = 3.0f;
m_SpawnRequests.push_back(req);
} else {
return false;
@@ -173,10 +184,6 @@ bool PlayerSpawnSystem::OnPlayerDeath(Events::PlayerDeath& e)
if (!e.Player.HasComponent("Team")) {
return false;
}
if (!e.Player.HasComponent("Lifetime")) {
LOG_INFO("<- spawnsystem death FALSE");
return false;
}
ComponentWrapper cTeam = e.Player["Team"];
//A spectator can't die anyway
if ((ComponentInfo::EnumType)cTeam["Team"] == cTeam["Team"].Enum("Spectator")) {
@@ -192,8 +199,52 @@ bool PlayerSpawnSystem::OnPlayerDeath(Events::PlayerDeath& e)
SpawnRequest req;
req.PlayerID = m_PlayerIDs.at(e.Player.ID);
req.Team = cTeam["Team"];
req.timeSinceDeath = 0.0f;
m_SpawnRequests.push_back(req);
LOG_INFO("-> spawnsystem death");
return true;
}
void PlayerSpawnSystem::CheckForLatePlayers(double dt) {
for (size_t i = 0; i < m_LatePlayersVector.size(); i++)
{
auto& req = m_SpawnRequests[i];
req.timeSinceDeath += dt;
if (req.timeSinceDeath > 2.5f) {
//good but, this will only spawn them in the next cycle - i.e. not immediately
//m_SpawnRequests.push_back(spawnReq);
//insta spawn
auto playerSpawns = m_World->GetComponents("PlayerSpawn");
for (auto& cPlayerSpawn : *playerSpawns) {
EntityWrapper spawner(m_World, cPlayerSpawn.EntityID);
if (!spawner.HasComponent("Spawner")) {
continue;
}
// If the spawner has a team affiliation, check it
if (spawner.HasComponent("Team")) {
if ((int)spawner["Team"]["Team"] != req.Team) {
continue;
}
}
// Spawn the player!
EntityWrapper player = SpawnerSystem::Spawn(spawner, EntityWrapper::Invalid, "Player");
// Set the player team affiliation
player["Team"]["Team"] = req.Team;
// Publish a PlayerSpawned event
Events::PlayerSpawned e;
e.PlayerID = req.PlayerID;
e.Player = player;
e.Spawner = spawner;
m_EventBroker->Publish(e);
break;
}
//end insta spawn
m_LatePlayersVector.erase(m_LatePlayersVector.begin() + i);
break;
}
}
}