Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6456df8ce1 | |||
| e43a7be7db | |||
| 3436ba6656 | |||
| fc3a3a8f2e |
@@ -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);
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
@@ -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,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");
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user