DamageIndicatorSystem now works for singleplayer again. Friendly fire DamageIndicator is now black color.
This commit is contained in:
@@ -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);
|
||||||
@@ -43,7 +44,7 @@ bool DamageIndicatorSystem::OnPlayerDamage(Events::PlayerDamage& e)
|
|||||||
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);
|
||||||
@@ -54,8 +55,12 @@ bool DamageIndicatorSystem::OnPlayerDamage(Events::PlayerDamage& e)
|
|||||||
m_World->SetParent(sprite.ID, m_CurrentCamera);
|
m_World->SetParent(sprite.ID, m_CurrentCamera);
|
||||||
//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);
|
||||||
|
//friendly fire - change color of the marker
|
||||||
|
if (e.Damage < 0.1f) {
|
||||||
|
sprite["Sprite"]["Color"] = glm::vec4(0.0, 1.0f, 1.0f, 1.0f);
|
||||||
|
}
|
||||||
|
|
||||||
if (!IsServer) {
|
if (!IsServer || !m_NetworkEnabled) {
|
||||||
updateDamageIndicatorVector.emplace_back(sprite, inflictorPos);
|
updateDamageIndicatorVector.emplace_back(sprite, inflictorPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,7 +127,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");
|
||||||
|
|||||||
Reference in New Issue
Block a user