Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6456df8ce1 | |||
| e43a7be7db |
@@ -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);
|
||||||
|
|||||||
@@ -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,6 +41,11 @@ 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
|
||||||
@@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user