Compare commits

..

4 Commits

20 changed files with 38 additions and 41 deletions
@@ -15,6 +15,7 @@
#include "Rendering/Util/CommonFunctions.h" #include "Rendering/Util/CommonFunctions.h"
//#define INDICATOR_TEST //#define INDICATOR_TEST
#include "Core/ConfigFile.h"
class DamageIndicatorSystem : public ImpureSystem class DamageIndicatorSystem : public ImpureSystem
{ {
@@ -40,6 +41,8 @@ private:
std::vector<DamageIndicatorStruct> updateDamageIndicatorVector; std::vector<DamageIndicatorStruct> updateDamageIndicatorVector;
float CalculateAngle(EntityWrapper player, glm::vec3 enemyPos); float CalculateAngle(EntityWrapper player, glm::vec3 enemyPos);
bool m_NetworkEnabled;
//for tests //for tests
#ifdef INDICATOR_TEST #ifdef INDICATOR_TEST
glm::vec3 DamageIndicatorTest(EntityWrapper player); glm::vec3 DamageIndicatorTest(EntityWrapper player);
-1
View File
@@ -65,5 +65,4 @@
<xs:include schemaLocation="Components/InputCmdButton.xsd"/> <xs:include schemaLocation="Components/InputCmdButton.xsd"/>
<xs:include schemaLocation="Components/ScoreScreen.xsd"/> <xs:include schemaLocation="Components/ScoreScreen.xsd"/>
<xs:include schemaLocation="Components/ScoreIdentity.xsd"/> <xs:include schemaLocation="Components/ScoreIdentity.xsd"/>
<xs:include schemaLocation="Components/NetworkComponent.xsd"/>
</xs:schema> </xs:schema>
@@ -1,3 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<NetworkComponent xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="NetworkComponent.xsd">
</NetworkComponent>
@@ -1,10 +0,0 @@
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:t="types">
<xs:import schemaLocation="../Types.xsd" namespace="types"/>
<xs:element name="NetworkComponent">
<xs:annotation>
<xs:documentation>If an entity has this component, it will be broadcasted to clients in a snapshot.</xs:documentation>
</xs:annotation>
</xs:element>
</xs:schema>
-1
View File
@@ -2,7 +2,6 @@
<Entity xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd"> <Entity xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
<Components> <Components>
<c:NetworkComponent/>
<c:AmmoPickup/> <c:AmmoPickup/>
<c:Model> <c:Model>
<Resource>Models/Props/PickUps/AmmoPickUp.mesh</Resource> <Resource>Models/Props/PickUps/AmmoPickUp.mesh</Resource>
@@ -2,7 +2,6 @@
<Entity xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd"> <Entity xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
<Components> <Components>
<c:NetworkComponent/>
<c:HealthPickup/> <c:HealthPickup/>
<c:Model> <c:Model>
<Resource>Models/Props/PickUps/HealthPickUp.mesh</Resource> <Resource>Models/Props/PickUps/HealthPickUp.mesh</Resource>
-1
View File
@@ -2,7 +2,6 @@
<Entity name="Player" xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd"> <Entity name="Player" xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
<Components> <Components>
<c:NetworkComponent/>
<c:AABB> <c:AABB>
<Origin X="0" Y="0.772000015" Z="0"/> <Origin X="0" Y="0.772000015" Z="0"/>
<Size X="1" Y="1.60000002" Z="1"/> <Size X="1" Y="1.60000002" Z="1"/>
@@ -2,7 +2,6 @@
<Entity name="PlayerAssault" xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd"> <Entity name="PlayerAssault" xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
<Components> <Components>
<c:NetworkComponent/>
<c:AABB> <c:AABB>
<Origin X="0" Y="0.772000015" Z="0"/> <Origin X="0" Y="0.772000015" Z="0"/>
<Size X="1" Y="1.60000002" Z="1"/> <Size X="1" Y="1.60000002" Z="1"/>
@@ -2,7 +2,6 @@
<Entity name="Player" xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd"> <Entity name="Player" xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
<Components> <Components>
<c:NetworkComponent/>
<c:AABB> <c:AABB>
<Origin X="0" Y="0.772000015" Z="0"/> <Origin X="0" Y="0.772000015" Z="0"/>
<Size X="1" Y="1.60000002" Z="1"/> <Size X="1" Y="1.60000002" Z="1"/>
@@ -2,7 +2,6 @@
<Entity name="Player" xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd"> <Entity name="Player" xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
<Components> <Components>
<c:NetworkComponent/>
<c:AABB> <c:AABB>
<Origin X="0" Y="0.772000015" Z="0"/> <Origin X="0" Y="0.772000015" Z="0"/>
<Size X="1" Y="1.60000002" Z="1"/> <Size X="1" Y="1.60000002" Z="1"/>
@@ -2,7 +2,6 @@
<Entity name="PlayerAssault" xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd"> <Entity name="PlayerAssault" xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
<Components> <Components>
<c:NetworkComponent/>
<c:AABB> <c:AABB>
<Origin X="0" Y="0.772000015" Z="0"/> <Origin X="0" Y="0.772000015" Z="0"/>
<Size X="1" Y="1.60000002" Z="1"/> <Size X="1" Y="1.60000002" Z="1"/>
@@ -2,7 +2,6 @@
<Entity name="PlayerDefender" xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd"> <Entity name="PlayerDefender" xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
<Components> <Components>
<c:NetworkComponent/>
<c:AABB> <c:AABB>
<Origin X="0" Y="0.772000015" Z="0"/> <Origin X="0" Y="0.772000015" Z="0"/>
<Size X="1" Y="1.60000002" Z="1"/> <Size X="1" Y="1.60000002" Z="1"/>
-1
View File
@@ -2,7 +2,6 @@
<Entity name="Player" xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd"> <Entity name="Player" xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
<Components> <Components>
<c:NetworkComponent/>
<c:AABB> <c:AABB>
<Origin X="0" Y="0.772000015" Z="0"/> <Origin X="0" Y="0.772000015" Z="0"/>
<Size X="1" Y="1.60000002" Z="1"/> <Size X="1" Y="1.60000002" Z="1"/>
-1
View File
@@ -2,7 +2,6 @@
<Entity name="ScoreBoardOrigin" xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd"> <Entity name="ScoreBoardOrigin" xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
<Components> <Components>
<c:NetworkComponent/>
<c:Transform> <c:Transform>
<Position X="66.4319992" Y="37.9560013" Z="0"/> <Position X="66.4319992" Y="37.9560013" Z="0"/>
<Orientation X="0" Y="4.71199989" Z="0"/> <Orientation X="0" Y="4.71199989" Z="0"/>
-1
View File
@@ -68,7 +68,6 @@
<xs:element ref="c:InputCmdButton" minOccurs="0"/> <xs:element ref="c:InputCmdButton" minOccurs="0"/>
<xs:element ref="c:ScoreScreen" minOccurs="0"/> <xs:element ref="c:ScoreScreen" minOccurs="0"/>
<xs:element ref="c:ScoreIdentity" minOccurs="0"/> <xs:element ref="c:ScoreIdentity" minOccurs="0"/>
<xs:element ref="c:NetworkComponent" minOccurs="0"/>
</xs:all> </xs:all>
</xs:complexType> </xs:complexType>
</xs:element> </xs:element>
+16 -1
View File
@@ -641,7 +641,22 @@ void Server::parsePlayerTransform(Packet& packet)
bool Server::shouldSendToClient(EntityWrapper childEntity) bool Server::shouldSendToClient(EntityWrapper childEntity)
{ {
return childEntity.HasComponent("NetworkComponent") || childEntity.FirstParentWithComponent("NetworkComponent").Valid(); auto children = m_World->GetDirectChildren(childEntity.ID);
for (auto it = children.first; it != children.second; it++) {
EntityWrapper child(m_World, it->second);
if (child.HasComponent("CapturePoint") || child.HasComponent("HealthPickup")
|| child.HasComponent("AmmoPickup")) {
return true;
}
}
return childEntity.HasComponent("Player")
|| childEntity.FirstParentWithComponent("Player").Valid()
|| childEntity.HasComponent("CapturePoint")
|| childEntity.HasComponent("HealthPickup")
|| childEntity.HasComponent("AmmoPickup")
|| childEntity.HasComponent("ScoreScreen")
|| childEntity.FirstParentWithComponent("ScoreScreen").Valid()
|| childEntity.FirstParentWithComponent("CapturePoint").Valid();
} }
PlayerID Server::getPlayerIDFromEndpoint() PlayerID Server::getPlayerIDFromEndpoint()
-7
View File
@@ -137,20 +137,13 @@ Game::Game(int argc, char* argv[])
m_SystemPipeline->AddSystem<LifetimeSystem>(updateOrderLevel); m_SystemPipeline->AddSystem<LifetimeSystem>(updateOrderLevel);
m_SystemPipeline->AddSystem<CapturePointSystem>(updateOrderLevel); m_SystemPipeline->AddSystem<CapturePointSystem>(updateOrderLevel);
m_SystemPipeline->AddSystem<CapturePointHUDSystem>(updateOrderLevel); m_SystemPipeline->AddSystem<CapturePointHUDSystem>(updateOrderLevel);
m_SystemPipeline->AddSystem<PickupSpawnSystem>(updateOrderLevel);
m_SystemPipeline->AddSystem<AmmoPickupSystem>(updateOrderLevel);
m_SystemPipeline->AddSystem<DamageIndicatorSystem>(updateOrderLevel);
m_SystemPipeline->AddSystem<TextFieldReader>(updateOrderLevel); m_SystemPipeline->AddSystem<TextFieldReader>(updateOrderLevel);
m_SystemPipeline->AddSystem<AbilityCooldownHUDSystem>(updateOrderLevel); m_SystemPipeline->AddSystem<AbilityCooldownHUDSystem>(updateOrderLevel);
m_SystemPipeline->AddSystem<CapturePointArrowHUDSystem>(updateOrderLevel); m_SystemPipeline->AddSystem<CapturePointArrowHUDSystem>(updateOrderLevel);
m_SystemPipeline->AddSystem<KillFeedSystem>(updateOrderLevel); m_SystemPipeline->AddSystem<KillFeedSystem>(updateOrderLevel);
m_SystemPipeline->AddSystem<CapturePointSystem>(updateOrderLevel);
m_SystemPipeline->AddSystem<CapturePointHUDSystem>(updateOrderLevel);
m_SystemPipeline->AddSystem<PickupSpawnSystem>(updateOrderLevel); m_SystemPipeline->AddSystem<PickupSpawnSystem>(updateOrderLevel);
m_SystemPipeline->AddSystem<AmmoPickupSystem>(updateOrderLevel); m_SystemPipeline->AddSystem<AmmoPickupSystem>(updateOrderLevel);
m_SystemPipeline->AddSystem<DamageIndicatorSystem>(updateOrderLevel); m_SystemPipeline->AddSystem<DamageIndicatorSystem>(updateOrderLevel);
m_SystemPipeline->AddSystem<TextFieldReader>(updateOrderLevel);
m_SystemPipeline->AddSystem<KillFeedSystem>(updateOrderLevel);
m_SystemPipeline->AddSystem<BoostSystem>(updateOrderLevel); m_SystemPipeline->AddSystem<BoostSystem>(updateOrderLevel);
m_SystemPipeline->AddSystem<ButtonSystem>(updateOrderLevel, m_Renderer); m_SystemPipeline->AddSystem<ButtonSystem>(updateOrderLevel, m_Renderer);
m_SystemPipeline->AddSystem<MainMenuSystem>(updateOrderLevel, m_Renderer); m_SystemPipeline->AddSystem<MainMenuSystem>(updateOrderLevel, m_Renderer);
+5 -4
View File
@@ -96,6 +96,7 @@ bool AmmoPickupSystem::OnAmmoPickup(Events::AmmoPickup & e)
} }
currentAmmo = std::min(currentAmmo + e.AmmoGain, maxWeaponAmmo); currentAmmo = std::min(currentAmmo + e.AmmoGain, maxWeaponAmmo);
return false; return false;
} }
@@ -114,8 +115,11 @@ bool AmmoPickupSystem::OnTriggerLeave(Events::TriggerLeave& e) {
} }
void AmmoPickupSystem::DoPickup(EntityWrapper &player, EntityWrapper &trigger) { void AmmoPickupSystem::DoPickup(EntityWrapper &player, EntityWrapper &trigger) {
//trigger should be valid but if it isnt we just return (to avoid crash)
if (!trigger.Valid()) {
return;
}
int maxWeaponAmmo = (int)player["AssaultWeapon"]["MaxAmmo"]; int maxWeaponAmmo = (int)player["AssaultWeapon"]["MaxAmmo"];
int& currentAmmo = (int)player["AssaultWeapon"]["Ammo"];
int ammoGiven = 0.01*(double)trigger["AmmoPickup"]["AmmoGain"] * maxWeaponAmmo; int ammoGiven = 0.01*(double)trigger["AmmoPickup"]["AmmoGain"] * maxWeaponAmmo;
Events::AmmoPickup ePlayerAmmoPickup; Events::AmmoPickup ePlayerAmmoPickup;
@@ -123,9 +127,6 @@ void AmmoPickupSystem::DoPickup(EntityWrapper &player, EntityWrapper &trigger) {
ePlayerAmmoPickup.Player = player; ePlayerAmmoPickup.Player = player;
m_EventBroker->Publish(ePlayerAmmoPickup); m_EventBroker->Publish(ePlayerAmmoPickup);
//immediately give the player the ammo (on server)
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) //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 //we need to copy all values since each value can be different for each ammoPickup
m_ETriggerTouchVector.push_back({ (glm::vec3)trigger["Transform"]["Position"], trigger["AmmoPickup"]["AmmoGain"], m_ETriggerTouchVector.push_back({ (glm::vec3)trigger["Transform"]["Position"], trigger["AmmoPickup"]["AmmoGain"],
+10 -4
View File
@@ -10,10 +10,11 @@ DamageIndicatorSystem::DamageIndicatorSystem(SystemParams params)
//load texture to cache //load texture to cache
auto texture = CommonFunctions::LoadTexture("Textures/DamageIndicator.png", false); auto texture = CommonFunctions::LoadTexture("Textures/DamageIndicator.png", false);
auto entityFile = ResourceManager::Load<EntityXMLFile>("Schema/Entities/DamageIndicator.xml"); auto entityFile = ResourceManager::Load<EntityXMLFile>("Schema/Entities/DamageIndicator.xml");
m_NetworkEnabled = ResourceManager::Load<ConfigFile>("Config.ini")->Get("Networking.StartNetwork", false);
} }
void DamageIndicatorSystem::Update(double dt) { void DamageIndicatorSystem::Update(double dt) {
if (!IsServer && LocalPlayer.Valid()) { if ((!IsServer || !m_NetworkEnabled) && LocalPlayer.Valid()) {
for (auto& iter = updateDamageIndicatorVector.begin(); iter != updateDamageIndicatorVector.end(); iter++) { for (auto& iter = updateDamageIndicatorVector.begin(); iter != updateDamageIndicatorVector.end(); iter++) {
if (!iter->spriteEntity.Valid()) { if (!iter->spriteEntity.Valid()) {
updateDamageIndicatorVector.erase(iter); updateDamageIndicatorVector.erase(iter);
@@ -40,10 +41,15 @@ bool DamageIndicatorSystem::OnPlayerDamage(Events::PlayerDamage& e)
return false; return false;
} }
//friendly fire - return
if (e.Damage < 0.1f) {
return false;
}
glm::vec3 inflictorPos = e.Inflictor["Transform"]["Position"]; glm::vec3 inflictorPos = e.Inflictor["Transform"]["Position"];
//if testing //if testing
#ifdef INDICATOR_TEST #ifdef INDICATOR_TEST
inflictorPos = DamageIndicatorTest(e.Victim); inflictorPos = DamageIndicatorTest(e.Victim);
#endif #endif
float angleBetweenVectors = CalculateAngle(e.Victim, inflictorPos); float angleBetweenVectors = CalculateAngle(e.Victim, inflictorPos);
@@ -55,7 +61,7 @@ bool DamageIndicatorSystem::OnPlayerDamage(Events::PlayerDamage& e)
//simply set the rotation z-wise to the angleBetweenVectors //simply set the rotation z-wise to the angleBetweenVectors
sprite["Transform"]["Orientation"] = glm::vec3(0, 0, angleBetweenVectors); sprite["Transform"]["Orientation"] = glm::vec3(0, 0, angleBetweenVectors);
if (!IsServer) { if (!IsServer || !m_NetworkEnabled) {
updateDamageIndicatorVector.emplace_back(sprite, inflictorPos); updateDamageIndicatorVector.emplace_back(sprite, inflictorPos);
} }
@@ -122,7 +128,7 @@ glm::vec3 DamageIndicatorSystem::DamageIndicatorTest(EntityWrapper player) {
} }
m_TestVar++; 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 //load the explosioneffect XML
auto deathEffect = ResourceManager::Load<EntityXMLFile>("Schema/Entities/PlayerDeathExplosionWithCamera.xml"); auto deathEffect = ResourceManager::Load<EntityXMLFile>("Schema/Entities/PlayerDeathExplosionWithCamera.xml");
+4
View File
@@ -83,6 +83,10 @@ bool PickupSpawnSystem::OnTriggerLeave(Events::TriggerLeave& e)
} }
void PickupSpawnSystem::DoPickup(EntityWrapper &player, EntityWrapper &trigger) void PickupSpawnSystem::DoPickup(EntityWrapper &player, EntityWrapper &trigger)
{ {
//trigger should be valid but if it isnt we just return (to avoid crash)
if (!trigger.Valid()) {
return;
}
double healthGiven = 0.01*(double)trigger["HealthPickup"]["HealthGain"] * (double)player["Health"]["MaxHealth"]; double healthGiven = 0.01*(double)trigger["HealthPickup"]["HealthGain"] * (double)player["Health"]["MaxHealth"];
//only the server will increase the players hp and set it in the next delta //only the server will increase the players hp and set it in the next delta