diff --git a/include/Game/Systems/DamageIndicatorSystem.h b/include/Game/Systems/DamageIndicatorSystem.h index 9c88ba78..f3a95817 100644 --- a/include/Game/Systems/DamageIndicatorSystem.h +++ b/include/Game/Systems/DamageIndicatorSystem.h @@ -15,6 +15,7 @@ #include "Rendering/Util/CommonFunctions.h" //#define INDICATOR_TEST +#include "Core/ConfigFile.h" class DamageIndicatorSystem : public ImpureSystem { @@ -40,6 +41,8 @@ private: std::vector updateDamageIndicatorVector; float CalculateAngle(EntityWrapper player, glm::vec3 enemyPos); + bool m_NetworkEnabled; + //for tests #ifdef INDICATOR_TEST glm::vec3 DamageIndicatorTest(EntityWrapper player); diff --git a/src/Engine/Rendering/BoneAttachmentSystem.cpp b/src/Engine/Rendering/BoneAttachmentSystem.cpp index 43dc8634..c1cdf0f2 100644 --- a/src/Engine/Rendering/BoneAttachmentSystem.cpp +++ b/src/Engine/Rendering/BoneAttachmentSystem.cpp @@ -50,13 +50,15 @@ void BoneAttachmentSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapp glm::vec4 perspective; glm::decompose(boneTransform, scale, rotation, translation, skew, perspective); - glm::vec3 angles = glm::vec3(-glm::pitch(rotation), -glm::yaw(rotation), -glm::roll(rotation)); + rotation = glm::quat((glm::vec3)entity["BoneAttachment"]["OrientationOffset"]) * rotation; + rotation = glm::inverse(rotation); + glm::vec3 angles = glm::eulerAngles(rotation); if ((bool)entity["BoneAttachment"]["InheritPosition"]) { (glm::vec3&)entity["Transform"]["Position"] = translation + (glm::vec3)entity["BoneAttachment"]["PositionOffset"]; } if ((bool)entity["BoneAttachment"]["InheritOrientation"]) { - (glm::vec3&)entity["Transform"]["Orientation"] = angles + (glm::vec3)entity["BoneAttachment"]["OrientationOffset"]; + (glm::vec3&)entity["Transform"]["Orientation"] = angles; } if ((bool)entity["BoneAttachment"]["InheritScale"]) { (glm::vec3&)entity["Transform"]["Scale"] = scale * (glm::vec3)entity["BoneAttachment"]["ScaleOffset"]; diff --git a/src/Game/Systems/DamageIndicatorSystem.cpp b/src/Game/Systems/DamageIndicatorSystem.cpp index e68f741d..7e22a0d6 100644 --- a/src/Game/Systems/DamageIndicatorSystem.cpp +++ b/src/Game/Systems/DamageIndicatorSystem.cpp @@ -10,10 +10,11 @@ DamageIndicatorSystem::DamageIndicatorSystem(SystemParams params) //load texture to cache auto texture = CommonFunctions::LoadTexture("Textures/DamageIndicator.png", false); auto entityFile = ResourceManager::Load("Schema/Entities/DamageIndicator.xml"); + m_NetworkEnabled = ResourceManager::Load("Config.ini")->Get("Networking.StartNetwork", false); } void DamageIndicatorSystem::Update(double dt) { - if (!IsServer && LocalPlayer.Valid()) { + if ((!IsServer || !m_NetworkEnabled) && LocalPlayer.Valid()) { for (auto& iter = updateDamageIndicatorVector.begin(); iter != updateDamageIndicatorVector.end(); iter++) { if (!iter->spriteEntity.Valid()) { updateDamageIndicatorVector.erase(iter); @@ -40,10 +41,15 @@ bool DamageIndicatorSystem::OnPlayerDamage(Events::PlayerDamage& e) return false; } + //friendly fire - return + if (e.Damage < 0.1f) { + return false; + } + glm::vec3 inflictorPos = e.Inflictor["Transform"]["Position"]; //if testing #ifdef INDICATOR_TEST - inflictorPos = DamageIndicatorTest(e.Victim); + inflictorPos = DamageIndicatorTest(e.Victim); #endif 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 sprite["Transform"]["Orientation"] = glm::vec3(0, 0, angleBetweenVectors); - if (!IsServer) { + if (!IsServer || !m_NetworkEnabled) { updateDamageIndicatorVector.emplace_back(sprite, inflictorPos); } @@ -122,7 +128,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("Schema/Entities/PlayerDeathExplosionWithCamera.xml");