Weapon RayZ
Weapon RayZ
This commit is contained in:
+1
-1
Submodule assets updated: 7577819337...e4dc9529f2
@@ -35,6 +35,9 @@ struct EntityWrapper
|
|||||||
bool operator!=(const EntityWrapper& e) const;
|
bool operator!=(const EntityWrapper& e) const;
|
||||||
explicit operator EntityID() const;
|
explicit operator EntityID() const;
|
||||||
operator bool();
|
operator bool();
|
||||||
|
|
||||||
|
private:
|
||||||
|
EntityWrapper firstChildByNameRecursive(const std::string& name, EntityID parent);
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace std
|
namespace std
|
||||||
|
|||||||
@@ -8,8 +8,10 @@
|
|||||||
namespace Transform
|
namespace Transform
|
||||||
{
|
{
|
||||||
|
|
||||||
|
glm::mat4 AbsoluteTransformation(EntityWrapper entity);
|
||||||
glm::vec3 AbsolutePosition(EntityWrapper entity);
|
glm::vec3 AbsolutePosition(EntityWrapper entity);
|
||||||
glm::vec3 AbsolutePosition(World* world, EntityID entity);
|
glm::vec3 AbsolutePosition(World* world, EntityID entity);
|
||||||
|
glm::vec3 AbsoluteOrientationEuler(EntityWrapper entity);
|
||||||
glm::quat AbsoluteOrientation(EntityWrapper entity);
|
glm::quat AbsoluteOrientation(EntityWrapper entity);
|
||||||
glm::quat AbsoluteOrientation(World* world, EntityID entity);
|
glm::quat AbsoluteOrientation(World* world, EntityID entity);
|
||||||
glm::vec3 AbsoluteScale(EntityWrapper entity);
|
glm::vec3 AbsoluteScale(EntityWrapper entity);
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
#ifndef LifetimeSystem_h__
|
||||||
|
#define LifetimeSystem_h__
|
||||||
|
|
||||||
|
#include "Core/System.h"
|
||||||
|
|
||||||
|
class LifetimeSystem : public ImpureSystem, PureSystem
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
LifetimeSystem(World* world, EventBroker* eventBroker)
|
||||||
|
: System(world, eventBroker)
|
||||||
|
, PureSystem("Lifetime")
|
||||||
|
{ }
|
||||||
|
|
||||||
|
virtual void Update(double dt) override;
|
||||||
|
virtual void UpdateComponent(EntityWrapper& entity, ComponentWrapper& cLifetime, double dt) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::vector<EntityWrapper> m_Deletions;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -11,6 +11,8 @@
|
|||||||
#include "Core/EShoot.h"
|
#include "Core/EShoot.h"
|
||||||
#include "Core/EPlayerSpawned.h"
|
#include "Core/EPlayerSpawned.h"
|
||||||
#include "Input/EInputCommand.h"
|
#include "Input/EInputCommand.h"
|
||||||
|
#include "Core/EntityFile.h"
|
||||||
|
#include "Core/EntityFileParser.h"
|
||||||
|
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@@ -33,7 +35,7 @@ private:
|
|||||||
EventRelay<WeaponSystem, Events::PlayerSpawned> m_EPlayerSpawned;
|
EventRelay<WeaponSystem, Events::PlayerSpawned> m_EPlayerSpawned;
|
||||||
bool WeaponSystem::OnPlayerSpawned(const Events::PlayerSpawned& e);
|
bool WeaponSystem::OnPlayerSpawned(const Events::PlayerSpawned& e);
|
||||||
EventRelay<WeaponSystem, Events::Shoot> m_EShoot;
|
EventRelay<WeaponSystem, Events::Shoot> m_EShoot;
|
||||||
bool WeaponSystem::OnShoot(const Events::Shoot& e);
|
bool WeaponSystem::OnShoot(Events::Shoot& e);
|
||||||
EventRelay<WeaponSystem, Events::InputCommand> m_EInputCommand;
|
EventRelay<WeaponSystem, Events::InputCommand> m_EInputCommand;
|
||||||
bool WeaponSystem::OnInputCommand(const Events::InputCommand& e);
|
bool WeaponSystem::OnInputCommand(const Events::InputCommand& e);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -26,4 +26,5 @@
|
|||||||
<xs:include schemaLocation="Components/HealthHUD.xsd"/>
|
<xs:include schemaLocation="Components/HealthHUD.xsd"/>
|
||||||
<xs:include schemaLocation="Components/Animation.xsd"/>
|
<xs:include schemaLocation="Components/Animation.xsd"/>
|
||||||
<xs:include schemaLocation="Components/Fill.xsd"/>
|
<xs:include schemaLocation="Components/Fill.xsd"/>
|
||||||
|
<xs:include schemaLocation="Components/Lifetime.xsd"/>
|
||||||
</xs:schema>
|
</xs:schema>
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||||
|
<Lifetime xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Animation.xsd">
|
||||||
|
<Lifetime>0</Lifetime>
|
||||||
|
</Animation>
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
<?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="Lifetime">
|
||||||
|
<xs:complexType>
|
||||||
|
<xs:all>
|
||||||
|
<xs:element name="Lifetime" type="t:double" minOccurs="0"/>
|
||||||
|
</xs:all>
|
||||||
|
</xs:complexType>
|
||||||
|
</xs:element>
|
||||||
|
</xs:schema>
|
||||||
@@ -8,7 +8,9 @@
|
|||||||
<Size X="1" Y="1.60000002" Z="1"/>
|
<Size X="1" Y="1.60000002" Z="1"/>
|
||||||
</c:AABB>
|
</c:AABB>
|
||||||
<c:Collidable/>
|
<c:Collidable/>
|
||||||
<c:Physics/>
|
<c:Physics>
|
||||||
|
<Velocity X="2.30999646e-23" Y="0" Z="1.05272533e-23"/>
|
||||||
|
</c:Physics>
|
||||||
<c:Player>
|
<c:Player>
|
||||||
<MovementSpeed>5</MovementSpeed>
|
<MovementSpeed>5</MovementSpeed>
|
||||||
</c:Player>
|
</c:Player>
|
||||||
@@ -17,8 +19,10 @@
|
|||||||
<Red/>
|
<Red/>
|
||||||
</Team>
|
</Team>
|
||||||
</c:Team>
|
</c:Team>
|
||||||
<c:Transform/>
|
<c:Transform>
|
||||||
<Position X="-0.246963501" Y="0.0264999941" Z="3.01600003"/>
|
<Position X="-7.12165165" Y="0.0265000015" Z="6.04289007"/>
|
||||||
|
<Orientation X="0" Y="2.24449515" Z="0"/>
|
||||||
|
</c:Transform>
|
||||||
</Components>
|
</Components>
|
||||||
|
|
||||||
<Children>
|
<Children>
|
||||||
@@ -27,6 +31,7 @@
|
|||||||
<c:Camera/>
|
<c:Camera/>
|
||||||
<c:Transform>
|
<c:Transform>
|
||||||
<Position X="0" Y="1.37700009" Z="0"/>
|
<Position X="0" Y="1.37700009" Z="0"/>
|
||||||
|
<Orientation X="0.122173041" Y="0" Z="0"/>
|
||||||
</c:Transform>
|
</c:Transform>
|
||||||
</Components>
|
</Components>
|
||||||
<Children>
|
<Children>
|
||||||
@@ -67,11 +72,11 @@
|
|||||||
<Children>
|
<Children>
|
||||||
<Entity name="HealthBar">
|
<Entity name="HealthBar">
|
||||||
<Components>
|
<Components>
|
||||||
<c:HealthHUD/>
|
|
||||||
<c:Fill>
|
<c:Fill>
|
||||||
<Percentage>1</Percentage>
|
<Percentage>1</Percentage>
|
||||||
<Color A="0" B="1" G="0" R="0"/>
|
<Color A="0" B="1" G="0" R="0"/>
|
||||||
</c:Fill>
|
</c:Fill>
|
||||||
|
<c:HealthHUD/>
|
||||||
<c:Model>
|
<c:Model>
|
||||||
<Resource>Models/Core/UnitHexagon.mesh</Resource>
|
<Resource>Models/Core/UnitHexagon.mesh</Resource>
|
||||||
<Color A="1" B="0.70588237" G="0.70588237" R="0.70588237"/>
|
<Color A="1" B="0.70588237" G="0.70588237" R="0.70588237"/>
|
||||||
@@ -84,6 +89,52 @@
|
|||||||
</Components>
|
</Components>
|
||||||
<Children/>
|
<Children/>
|
||||||
</Entity>
|
</Entity>
|
||||||
|
<Entity name="Crosshair">
|
||||||
|
<Components>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/CrosshairQuad.mesh</Resource>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="0" Y="0" Z="0.200000003"/>
|
||||||
|
<Scale X="0.00600000005" Y="1" Z="0.00600000005"/>
|
||||||
|
<Orientation X="1.57000005" Y="0" Z="0"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
<Entity name="Weapon">
|
||||||
|
<Components>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/AssaultWeapon.mesh</Resource>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="0.180000007" Y="-0.183000013" Z="0"/>
|
||||||
|
<Orientation X="0" Y="4.64700031" Z="0"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
<Entity name="WeaponMuzzle">
|
||||||
|
<Components>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="0.215000004" Y="-0.153000012" Z="-0.266000003"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children>
|
||||||
|
<Entity>
|
||||||
|
<Components>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/CylinderBullet.mesh</Resource>
|
||||||
|
<Color A="1" B="0" G="0.525490224" R="39.2156868"/>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform>
|
||||||
|
<Scale X="0.0110000009" Y="0.029000001" Z="1"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
</Children>
|
||||||
|
</Entity>
|
||||||
</Children>
|
</Children>
|
||||||
</Entity>
|
</Entity>
|
||||||
</Children>
|
</Children>
|
||||||
@@ -106,11 +157,13 @@
|
|||||||
<Components>
|
<Components>
|
||||||
<c:Animation>
|
<c:Animation>
|
||||||
<Name>Hold Pos</Name>
|
<Name>Hold Pos</Name>
|
||||||
|
<Time>0.86791076003269829</Time>
|
||||||
<Speed>1</Speed>
|
<Speed>1</Speed>
|
||||||
</c:Animation>
|
</c:Animation>
|
||||||
<c:Model>
|
<c:Model>
|
||||||
<Resource>Models/AssaultAnimated.mesh</Resource>
|
<Resource>Models/AssaultAnimated.mesh</Resource>
|
||||||
<Color A="1" B="0" G="0" R="1"/>
|
<Color A="1" B="0" G="0" R="1"/>
|
||||||
|
<Visible>false</Visible>
|
||||||
</c:Model>
|
</c:Model>
|
||||||
<c:Transform/>
|
<c:Transform/>
|
||||||
</Components>
|
</Components>
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||||
|
<Entity xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
|
||||||
|
|
||||||
|
<Components>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/Core/UnitCylinder.mesh</Resource>
|
||||||
|
<Color A="0" B="0" G="0" R="39.2156868"/>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform>
|
||||||
|
<Scale X="0.0400000028" Y="26.2000008" Z="0.0400000028"/>
|
||||||
|
<Orientation X="1.57070005" Y="0" Z="0"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
|
||||||
|
<Children/>
|
||||||
|
|
||||||
|
</Entity>
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||||
|
<Entity xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
|
||||||
|
|
||||||
|
<Components>
|
||||||
|
<c:Lifetime>
|
||||||
|
<Lifetime>0.25</Lifetime>
|
||||||
|
</c:Lifetime>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/CylinderBullet.mesh</Resource>
|
||||||
|
<Color A="1" B="39.2156868" G="7.84313726" R="0"/>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform>
|
||||||
|
<Scale X="0.0109999999" Y="0.0289999992" Z="100"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
|
||||||
|
<Children/>
|
||||||
|
|
||||||
|
</Entity>
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||||
|
<Entity xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
|
||||||
|
|
||||||
|
<Components>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/Core/UnitCylinder.mesh</Resource>
|
||||||
|
<Color A="0" B="0" G="0" R="39.2156868"/>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform>
|
||||||
|
<Scale X="0.0400000028" Y="26.2000008" Z="0.0400000028"/>
|
||||||
|
<Orientation X="1.57070005" Y="0" Z="0"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
|
||||||
|
<Children/>
|
||||||
|
|
||||||
|
</Entity>
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||||
|
<Entity xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
|
||||||
|
|
||||||
|
<Components>
|
||||||
|
<c:Lifetime>
|
||||||
|
<Lifetime>0.25</Lifetime>
|
||||||
|
</c:Lifetime>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/CylinderBullet.mesh</Resource>
|
||||||
|
<Color A="1" B="0" G="0.525490224" R="39.2156868"/>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform>
|
||||||
|
<Scale X="0.0110000009" Y="0.029000001" Z="100"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
|
||||||
|
<Children/>
|
||||||
|
|
||||||
|
</Entity>
|
||||||
@@ -32,6 +32,7 @@
|
|||||||
<xs:element ref="c:DirectionalLight" minOccurs="0"/>
|
<xs:element ref="c:DirectionalLight" minOccurs="0"/>
|
||||||
<xs:element ref="c:UniformScale" minOccurs="0"/>
|
<xs:element ref="c:UniformScale" minOccurs="0"/>
|
||||||
<xs:element ref="c:EditorWidget" minOccurs="0"/>
|
<xs:element ref="c:EditorWidget" minOccurs="0"/>
|
||||||
|
<xs:element ref="c:Lifetime" minOccurs="0"/>
|
||||||
</xs:all>
|
</xs:all>
|
||||||
</xs:complexType>
|
</xs:complexType>
|
||||||
</xs:element>
|
</xs:element>
|
||||||
|
|||||||
@@ -22,18 +22,7 @@ EntityWrapper EntityWrapper::Parent()
|
|||||||
|
|
||||||
EntityWrapper EntityWrapper::FirstChildByName(const std::string& name)
|
EntityWrapper EntityWrapper::FirstChildByName(const std::string& name)
|
||||||
{
|
{
|
||||||
auto itPair = this->World->GetChildren(this->ID);
|
return firstChildByNameRecursive(name, this->ID);
|
||||||
if (itPair.first == itPair.second) {
|
|
||||||
return EntityWrapper::Invalid;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (auto it = itPair.first; it != itPair.second; ++it) {
|
|
||||||
if (this->World->GetName(it->second) == name) {
|
|
||||||
return EntityWrapper(this->World, it->second);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return EntityWrapper::Invalid;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EntityWrapper EntityWrapper::FirstParentWithComponent(const std::string& componentType)
|
EntityWrapper EntityWrapper::FirstParentWithComponent(const std::string& componentType)
|
||||||
@@ -108,3 +97,25 @@ EntityWrapper::operator bool()
|
|||||||
return this->Valid();
|
return this->Valid();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EntityWrapper EntityWrapper::firstChildByNameRecursive(const std::string& name, EntityID parent)
|
||||||
|
{
|
||||||
|
auto itPair = this->World->GetChildren(parent);
|
||||||
|
if (itPair.first == itPair.second) {
|
||||||
|
return EntityWrapper::Invalid;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto it = itPair.first; it != itPair.second; ++it) {
|
||||||
|
std::string itName = this->World->GetName(it->second);
|
||||||
|
if (itName == name) {
|
||||||
|
return EntityWrapper(this->World, it->second);
|
||||||
|
} else if (it->second != EntityID_Invalid) {
|
||||||
|
EntityWrapper result = firstChildByNameRecursive(name, it->second);
|
||||||
|
if (result != EntityWrapper::Invalid) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return EntityWrapper::Invalid;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,17 @@
|
|||||||
#include "Core/Transform.h"
|
#include "Core/Transform.h"
|
||||||
|
|
||||||
|
glm::mat4 Transform::AbsoluteTransformation(EntityWrapper entity)
|
||||||
|
{
|
||||||
|
glm::mat4 t = glm::mat4(1.f);
|
||||||
|
|
||||||
|
while (entity.Valid()) {
|
||||||
|
t = glm::translate((glm::vec3&)entity["Transform"]["Position"]) * glm::toMat4(glm::quat((glm::vec3&)entity["Transform"]["Orientation"])) * glm::scale((glm::vec3&)entity["Transform"]["Scale"]) * t;
|
||||||
|
entity = entity.Parent();
|
||||||
|
}
|
||||||
|
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
|
||||||
glm::vec3 Transform::AbsolutePosition(EntityWrapper entity)
|
glm::vec3 Transform::AbsolutePosition(EntityWrapper entity)
|
||||||
{
|
{
|
||||||
return AbsolutePosition(entity.World, entity.ID);
|
return AbsolutePosition(entity.World, entity.ID);
|
||||||
@@ -19,6 +31,19 @@ glm::vec3 Transform::AbsolutePosition(World* world, EntityID entity)
|
|||||||
return position;
|
return position;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glm::vec3 Transform::AbsoluteOrientationEuler(EntityWrapper entity)
|
||||||
|
{
|
||||||
|
glm::vec3 orientation;
|
||||||
|
|
||||||
|
while (entity.Valid()) {
|
||||||
|
ComponentWrapper transform = entity["Transform"];
|
||||||
|
orientation += (glm::vec3)transform["Orientation"];
|
||||||
|
entity = entity.Parent();
|
||||||
|
}
|
||||||
|
|
||||||
|
return orientation;
|
||||||
|
}
|
||||||
|
|
||||||
glm::quat Transform::AbsoluteOrientation(EntityWrapper entity)
|
glm::quat Transform::AbsoluteOrientation(EntityWrapper entity)
|
||||||
{
|
{
|
||||||
return AbsoluteOrientation(entity.World, entity.ID);
|
return AbsoluteOrientation(entity.World, entity.ID);
|
||||||
@@ -62,6 +87,8 @@ glm::mat4 Transform::ModelMatrix(EntityWrapper entity)
|
|||||||
|
|
||||||
glm::mat4 Transform::ModelMatrix(EntityID entity, World* world)
|
glm::mat4 Transform::ModelMatrix(EntityID entity, World* world)
|
||||||
{
|
{
|
||||||
|
return AbsoluteTransformation(EntityWrapper(world, entity));
|
||||||
|
|
||||||
glm::vec3 position = Transform::AbsolutePosition(world, entity);
|
glm::vec3 position = Transform::AbsolutePosition(world, entity);
|
||||||
glm::quat orientation = Transform::AbsoluteOrientation(world, entity);
|
glm::quat orientation = Transform::AbsoluteOrientation(world, entity);
|
||||||
glm::vec3 scale = Transform::AbsoluteScale(world, entity);
|
glm::vec3 scale = Transform::AbsoluteScale(world, entity);
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ void RenderSystem::fillModels(std::list<std::shared_ptr<RenderJob>>& jobs)
|
|||||||
// Don't render the local player
|
// Don't render the local player
|
||||||
if (entity == m_LocalPlayer || entity.IsChildOf(m_LocalPlayer)) {
|
if (entity == m_LocalPlayer || entity.IsChildOf(m_LocalPlayer)) {
|
||||||
if (!entity.HasComponent("HealthHUD")) { //Should work but needs to be fixed. Should only render the things "childed" to the local player camera
|
if (!entity.HasComponent("HealthHUD")) { //Should work but needs to be fixed. Should only render the things "childed" to the local player camera
|
||||||
continue;
|
//continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
#include "Game/Systems/CapturePointSystem.h"
|
#include "Game/Systems/CapturePointSystem.h"
|
||||||
#include "Game/Systems/WeaponSystem.h"
|
#include "Game/Systems/WeaponSystem.h"
|
||||||
#include "Game/Systems/PlayerHUD.h"
|
#include "Game/Systems/PlayerHUD.h"
|
||||||
|
#include "Game/Systems/LifetimeSystem.h"
|
||||||
#include "../Engine/Rendering/AnimationSystem.h"
|
#include "../Engine/Rendering/AnimationSystem.h"
|
||||||
|
|
||||||
Game::Game(int argc, char* argv[])
|
Game::Game(int argc, char* argv[])
|
||||||
@@ -85,6 +86,7 @@ Game::Game(int argc, char* argv[])
|
|||||||
m_SystemPipeline->AddSystem<SpawnerSystem>(updateOrderLevel);
|
m_SystemPipeline->AddSystem<SpawnerSystem>(updateOrderLevel);
|
||||||
m_SystemPipeline->AddSystem<PlayerSpawnSystem>(updateOrderLevel);
|
m_SystemPipeline->AddSystem<PlayerSpawnSystem>(updateOrderLevel);
|
||||||
m_SystemPipeline->AddSystem<WeaponSystem>(updateOrderLevel, m_Renderer);
|
m_SystemPipeline->AddSystem<WeaponSystem>(updateOrderLevel, m_Renderer);
|
||||||
|
m_SystemPipeline->AddSystem<LifetimeSystem>(updateOrderLevel);
|
||||||
// Populate Octree with collidables
|
// Populate Octree with collidables
|
||||||
++updateOrderLevel;
|
++updateOrderLevel;
|
||||||
m_SystemPipeline->AddSystem<CollidableOctreeSystem>(updateOrderLevel, m_OctreeCollision);
|
m_SystemPipeline->AddSystem<CollidableOctreeSystem>(updateOrderLevel, m_OctreeCollision);
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
#include "Systems/LifetimeSystem.h"
|
||||||
|
|
||||||
|
void LifetimeSystem::Update(double dt)
|
||||||
|
{
|
||||||
|
for (auto& e : m_Deletions) {
|
||||||
|
m_World->DeleteEntity(e.ID);
|
||||||
|
}
|
||||||
|
m_Deletions.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void LifetimeSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& cLifetime, double dt)
|
||||||
|
{
|
||||||
|
if (dt == 0.0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!entity.Valid()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
double& lifetime = cLifetime["Lifetime"];
|
||||||
|
lifetime -= dt;
|
||||||
|
|
||||||
|
if (lifetime <= 0.0) {
|
||||||
|
m_Deletions.push_back(entity);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -39,10 +39,51 @@ bool WeaponSystem::OnInputCommand(const Events::InputCommand& e)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WeaponSystem::OnShoot(const Events::Shoot& eShoot)
|
bool WeaponSystem::OnShoot(Events::Shoot& eShoot)
|
||||||
{
|
{
|
||||||
// TODO: Weapon firing effects here
|
// TODO: Weapon firing effects here
|
||||||
|
|
||||||
|
auto rayRed = ResourceManager::Load<EntityFile>("Schema/Entities/RayRed.xml");
|
||||||
|
auto rayBlue = ResourceManager::Load<EntityFile>("Schema/Entities/RayBlue.xml");
|
||||||
|
|
||||||
|
EntityWrapper weapon = eShoot.Player.FirstChildByName("WeaponMuzzle");
|
||||||
|
if (weapon.Valid()) {
|
||||||
|
EntityWrapper ray;
|
||||||
|
if ((ComponentInfo::EnumType)eShoot.Player["Team"]["Team"] == eShoot.Player["Team"]["Team"].Enum("Red")) {
|
||||||
|
EntityFileParser parser(rayRed);
|
||||||
|
EntityID rayID = parser.MergeEntities(m_World);
|
||||||
|
ray = EntityWrapper(m_World, rayID);
|
||||||
|
} else {
|
||||||
|
EntityFileParser parser(rayBlue);
|
||||||
|
EntityID rayID = parser.MergeEntities(m_World);
|
||||||
|
ray = EntityWrapper(m_World, rayID);
|
||||||
|
}
|
||||||
|
|
||||||
|
glm::mat4 transformation = Transform::AbsoluteTransformation(weapon);
|
||||||
|
glm::vec3 scale;
|
||||||
|
glm::vec3 translation;
|
||||||
|
glm::quat orientation;
|
||||||
|
glm::vec3 skew;
|
||||||
|
glm::vec4 perspective;
|
||||||
|
glm::decompose(transformation, scale, orientation, translation, skew, perspective);
|
||||||
|
|
||||||
|
// Matrix to euler angles
|
||||||
|
glm::vec3 euler;
|
||||||
|
euler.y = glm::asin(-transformation[0][2]);
|
||||||
|
if (cos(euler.y) != 0) {
|
||||||
|
euler.x = atan2(transformation[1][2], transformation[2][2]);
|
||||||
|
euler.z = atan2(transformation[0][1], transformation[0][0]);
|
||||||
|
} else {
|
||||||
|
euler.x = atan2(-transformation[2][0], transformation[1][1]);
|
||||||
|
euler.z = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//LOG_DEBUG("rotation: %f %f %f", euler.x, euler.y, euler.z);
|
||||||
|
(glm::vec3&)ray["Transform"]["Position"] = translation;
|
||||||
|
(glm::vec3&)ray["Transform"]["Orientation"] = euler;
|
||||||
|
//(glm::vec3&)ray["Transform"]["Orientation"] = Transform::AbsoluteOrientationEuler(weapon);
|
||||||
|
}
|
||||||
|
|
||||||
// Only run further picking code client-side!
|
// Only run further picking code client-side!
|
||||||
if (eShoot.Player != m_LocalPlayer) {
|
if (eShoot.Player != m_LocalPlayer) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user