Merge branch 'Cleanup'
# Conflicts: # src/Engine/Rendering/RenderSystem.cpp
This commit is contained in:
@@ -4,11 +4,12 @@
|
||||
#include "../Core/System.h"
|
||||
#include "../Core/Octree.h"
|
||||
#include "Collision.h"
|
||||
#include "EntityAABB.h"
|
||||
|
||||
class CollidableOctreeSystem : public ImpureSystem, public PureSystem
|
||||
{
|
||||
public:
|
||||
CollidableOctreeSystem(World* world, EventBroker* eventBroker, Octree<AABB>* octree)
|
||||
CollidableOctreeSystem(World* world, EventBroker* eventBroker, Octree<EntityAABB>* octree)
|
||||
: System(world, eventBroker)
|
||||
, PureSystem("Collidable")
|
||||
, m_Octree(octree)
|
||||
@@ -18,7 +19,7 @@ public:
|
||||
virtual void UpdateComponent(EntityWrapper& entity, ComponentWrapper& component, double dt) override;
|
||||
|
||||
private:
|
||||
Octree<AABB>* m_Octree;
|
||||
Octree<EntityAABB>* m_Octree;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "../Core/Transform.h"
|
||||
#include "../Core/Entity.h"
|
||||
#include "../Core/EntityWrapper.h"
|
||||
#include "EntityAABB.h"
|
||||
|
||||
class World;
|
||||
struct ComponentWrapper;
|
||||
@@ -61,7 +62,7 @@ bool AABBVsAABB(const AABB& a, const AABB& b, glm::vec3& minimumTranslation);
|
||||
bool IsSameBoxProbably(const AABB& first, const AABB& second, const float epsilon = 0.0001f);
|
||||
|
||||
// Calculates an absolute AABB from an entity AABB component
|
||||
boost::optional<AABB> EntityAbsoluteAABB(EntityWrapper& entity);
|
||||
boost::optional<EntityAABB> EntityAbsoluteAABB(EntityWrapper& entity);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -9,11 +9,12 @@
|
||||
#include "../Core/EventBroker.h"
|
||||
#include "../Core/EKeyUp.h"
|
||||
#include "../Core/Octree.h"
|
||||
#include "EntityAABB.h"
|
||||
|
||||
class CollisionSystem : public PureSystem
|
||||
{
|
||||
public:
|
||||
CollisionSystem(World* world, EventBroker* eventBroker, Octree<AABB>* octree)
|
||||
CollisionSystem(World* world, EventBroker* eventBroker, Octree<EntityAABB>* octree)
|
||||
: System(world, eventBroker)
|
||||
, PureSystem("Collidable")
|
||||
, m_Octree(octree)
|
||||
@@ -26,7 +27,7 @@ public:
|
||||
virtual void UpdateComponent(EntityWrapper& entity, ComponentWrapper& component, double dt) override;
|
||||
|
||||
private:
|
||||
Octree<AABB>* m_Octree;
|
||||
Octree<EntityAABB>* m_Octree;
|
||||
bool zPress;
|
||||
|
||||
EventRelay<CollisionSystem, Events::KeyUp> m_EKeyUp;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#define Events_TriggerEnter_h__
|
||||
|
||||
#include "../Core/EventBroker.h"
|
||||
#include "../Core/Entity.h"
|
||||
#include "../Core/EntityWrapper.h"
|
||||
|
||||
namespace Events
|
||||
{
|
||||
@@ -11,27 +11,27 @@ namespace Events
|
||||
struct TriggerTouch : Event
|
||||
{
|
||||
/** The id of the entity that touches the trigger. */
|
||||
EntityID Entity;
|
||||
EntityWrapper Entity;
|
||||
/** The id of the trigger entity. */
|
||||
EntityID Trigger;
|
||||
EntityWrapper Trigger;
|
||||
};
|
||||
|
||||
/** Thrown once, when an entity has completely left a trigger. */
|
||||
struct TriggerLeave : Event
|
||||
{
|
||||
/** The id of the entity that left the trigger. */
|
||||
EntityID Entity;
|
||||
EntityWrapper Entity;
|
||||
/** The id of the trigger entity. */
|
||||
EntityID Trigger;
|
||||
EntityWrapper Trigger;
|
||||
};
|
||||
|
||||
/** Thrown once, when an entity is completely contained inside a trigger. */
|
||||
struct TriggerEnter : Event
|
||||
{
|
||||
/** The id of the entity that entered the trigger. */
|
||||
EntityID Entity;
|
||||
EntityWrapper Entity;
|
||||
/** The id of the trigger entity. */
|
||||
EntityID Trigger;
|
||||
EntityWrapper Trigger;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
#ifndef EntityAABB_h__
|
||||
#define EntityAABB_h__
|
||||
|
||||
#include "../Core/AABB.h"
|
||||
#include "../Core/EntityWrapper.h"
|
||||
|
||||
struct EntityAABB : AABB
|
||||
{
|
||||
EntityAABB() = default;
|
||||
|
||||
EntityAABB(const glm::vec3& minPos, const glm::vec3& maxPos)
|
||||
: AABB(minPos, maxPos)
|
||||
{ }
|
||||
|
||||
EntityAABB(const AABB& aabb)
|
||||
: AABB(aabb)
|
||||
{ }
|
||||
|
||||
EntityWrapper Entity;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -8,13 +8,14 @@
|
||||
#include "../Core/EventBroker.h"
|
||||
#include "../Core/Octree.h"
|
||||
#include "ETrigger.h"
|
||||
#include "EntityAABB.h"
|
||||
|
||||
class AABB;
|
||||
|
||||
class TriggerSystem : public PureSystem
|
||||
{
|
||||
public:
|
||||
TriggerSystem(World* world, EventBroker* eventBroker, Octree<AABB>* octree)
|
||||
TriggerSystem(World* world, EventBroker* eventBroker, Octree<EntityAABB>* octree)
|
||||
: System(world, eventBroker)
|
||||
, PureSystem("Trigger")
|
||||
, m_Octree(octree)
|
||||
@@ -27,9 +28,10 @@ public:
|
||||
virtual void UpdateComponent(EntityWrapper& entity, ComponentWrapper& component, double dt) override;
|
||||
|
||||
private:
|
||||
Octree<AABB>* m_Octree;
|
||||
std::unordered_map<EntityID, std::unordered_set<EntityID>> m_EntitiesTouchingTrigger;
|
||||
std::unordered_map<EntityID, std::unordered_set<EntityID>> m_EntitiesCompletelyInTrigger;
|
||||
Octree<EntityAABB>* m_Octree;
|
||||
std::vector<EntityAABB> m_OctreeOut;
|
||||
std::unordered_map<EntityWrapper, std::unordered_set<EntityWrapper>> m_EntitiesTouchingTrigger;
|
||||
std::unordered_map<EntityWrapper, std::unordered_set<EntityWrapper>> m_EntitiesCompletelyInTrigger;
|
||||
|
||||
//TODO: Only exists for debug purposes, remove later.
|
||||
EventRelay<TriggerSystem, Events::TriggerEnter> m_EEnter;
|
||||
@@ -40,13 +42,13 @@ private:
|
||||
bool OnLeave(const Events::TriggerLeave &event);
|
||||
|
||||
//True if leave event was thrown.
|
||||
bool throwLeaveIfWasInTrigger(std::unordered_set<EntityID>& triggerSet, EntityID pId, EntityID tId);
|
||||
bool throwLeaveIfWasInTrigger(std::unordered_set<EntityWrapper>& triggerSet, EntityWrapper colliderENtity, EntityWrapper triggerEntity);
|
||||
template<typename Event>
|
||||
void publish(EntityID pId, EntityID tId)
|
||||
void publish(EntityWrapper collider, EntityWrapper trigger)
|
||||
{
|
||||
Event e;
|
||||
e.Trigger = tId;
|
||||
e.Entity = pId;
|
||||
e.Trigger = trigger;
|
||||
e.Entity = collider;
|
||||
m_EventBroker->Publish(e);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -9,7 +9,6 @@ public:
|
||||
AABB() = default;
|
||||
//No checks are made. Values in minPos must be less than values in maxPos, i.e. min.x < max.x, etc.
|
||||
AABB(const glm::vec3& minPos, const glm::vec3& maxPos);
|
||||
AABB(const glm::vec4& minPos, const glm::vec4& maxPos);
|
||||
//No checks are made. Size must consist of non-negative numbers.
|
||||
static AABB FromOriginSize(const glm::vec3& origin, const glm::vec3& size);
|
||||
virtual ~AABB();
|
||||
|
||||
@@ -35,7 +35,6 @@ struct EntityWrapper
|
||||
bool operator==(const EntityWrapper& e) const;
|
||||
bool operator!=(const EntityWrapper& e) const;
|
||||
explicit operator EntityID() const;
|
||||
operator bool();
|
||||
|
||||
private:
|
||||
EntityWrapper firstChildByNameRecursive(const std::string& name, EntityID parent);
|
||||
|
||||
@@ -149,7 +149,7 @@ template<typename T>
|
||||
template<typename Box>
|
||||
void Octree<T>::ObjectsInSameRegion(const Box& box, std::vector<T>& outObjects)
|
||||
{
|
||||
static_assert(std::is_base_of<AABB, Box>::value, "template argument type Box in Octree<T>::ObjectsInSameRegion must be a subclass of AABB.");
|
||||
//static_assert(std::is_base_of<AABB, Box>::value, "template argument type Box in Octree<T>::ObjectsInSameRegion must be a subclass of AABB.");
|
||||
falsifyObjectChecks();
|
||||
m_Root->ObjectsInSameRegion(box, outObjects);
|
||||
}
|
||||
|
||||
@@ -35,17 +35,19 @@ private:
|
||||
|
||||
EventRelay<RenderSystem, Events::SetCamera> m_ESetCamera;
|
||||
bool OnSetCamera(Events::SetCamera &event);
|
||||
EventRelay<RenderSystem, Events::InputCommand> m_EInputCommand;
|
||||
bool OnInputCommand(const Events::InputCommand& e);
|
||||
EventRelay<RenderSystem, Events::PlayerSpawned> m_EPlayerSpawned;
|
||||
bool OnPlayerSpawned(Events::PlayerSpawned& e);
|
||||
|
||||
void fillText(std::list<std::shared_ptr<RenderJob>>& jobs, World* world);
|
||||
void fillPointLights(std::list<std::shared_ptr<RenderJob>>& jobs, World* world);
|
||||
void fillDirectionalLights(std::list<std::shared_ptr<RenderJob>>& jobs, World* world);
|
||||
EventRelay<RenderSystem, Events::InputCommand> m_EInputCommand;
|
||||
bool OnInputCommand(const Events::InputCommand& e);
|
||||
|
||||
void fillModels(std::list<std::shared_ptr<RenderJob>>& jobs);
|
||||
void fillLight(std::list<std::shared_ptr<RenderJob>>& jobs);
|
||||
bool isChildOfACamera(EntityWrapper entity);
|
||||
bool isChildOfCurrentCamera(EntityWrapper entity);
|
||||
|
||||
EventRelay<RenderSystem, Events::PlayerSpawned> m_EPlayerSpawned;
|
||||
bool OnPlayerSpawned(Events::PlayerSpawned& e);
|
||||
};
|
||||
|
||||
#endif
|
||||
+3
-2
@@ -22,6 +22,7 @@
|
||||
#include "Core/Octree.h"
|
||||
#include "Rendering/Font.h"
|
||||
#include "Systems/InterpolationSystem.h"
|
||||
#include "Collision/EntityAABB.h"
|
||||
// Network
|
||||
#include <boost/thread.hpp>
|
||||
#include "Network/Network.h"
|
||||
@@ -49,8 +50,8 @@ private:
|
||||
InputProxy* m_InputProxy;
|
||||
GUI::Frame* m_FrameStack;
|
||||
World* m_World;
|
||||
Octree<AABB>* m_OctreeCollision;
|
||||
Octree<AABB>* m_OctreeFrustrumCulling;
|
||||
Octree<EntityAABB>* m_OctreeCollision;
|
||||
Octree<EntityAABB>* m_OctreeFrustrumCulling;
|
||||
SystemPipeline* m_SystemPipeline;
|
||||
RenderFrame* m_RenderFrame;
|
||||
// Network variables
|
||||
|
||||
@@ -40,7 +40,7 @@ private:
|
||||
int m_BlueTeamHomeCapturePoint = m_NotACapturePoint;
|
||||
|
||||
int m_NumberOfCapturePoints = 0;
|
||||
std::map<int, EntityID> m_CapturePointNumberToEntityIDMap;
|
||||
std::map<int, EntityWrapper> m_CapturePointNumberToEntityMap;
|
||||
|
||||
//std::vector<ComponentWrapper>
|
||||
|
||||
@@ -48,8 +48,8 @@ private:
|
||||
bool m_ResetTimers = false;
|
||||
|
||||
//vectors which will keep track of enter/leave changes
|
||||
std::vector<std::tuple<EntityID, EntityID>> m_ETriggerTouchVector;
|
||||
std::vector<std::tuple<EntityID, EntityID>> m_ETriggerLeaveVector;
|
||||
std::vector<std::tuple<EntityWrapper, EntityWrapper>> m_ETriggerTouchVector;
|
||||
std::vector<std::tuple<EntityWrapper, EntityWrapper>> m_ETriggerLeaveVector;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -28,4 +28,5 @@
|
||||
<xs:include schemaLocation="Components/Animation.xsd"/>
|
||||
<xs:include schemaLocation="Components/Fill.xsd"/>
|
||||
<xs:include schemaLocation="Components/Lifetime.xsd"/>
|
||||
<xs:include schemaLocation="Components/HiddenForLocalPlayer.xsd"/>
|
||||
</xs:schema>
|
||||
@@ -0,0 +1,2 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||
<HiddenForLocalPlayer xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="HiddenForLocalPlayer.xsd"/>
|
||||
@@ -0,0 +1,11 @@
|
||||
<?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="HiddenForLocalPlayer">
|
||||
<xs:annotation>
|
||||
<xs:documentation>Used to make the entity invisible if it's parented to the current local player entity (for first person player model and such)</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:element>
|
||||
</xs:schema>
|
||||
@@ -1,4 +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 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Lifetime.xsd">
|
||||
<Lifetime>0</Lifetime>
|
||||
</Animation>
|
||||
</Lifetime>
|
||||
@@ -16,7 +16,7 @@
|
||||
<xs:annotation><xs:documentation>Color tint</xs:documentation></xs:annotation>
|
||||
</xs:element>
|
||||
<xs:element name="Visible" type="t:bool" minOccurs="0">
|
||||
<xs:annotation><xs:documentation>Wether the model is visible or not</xs:documentation></xs:annotation>
|
||||
<xs:annotation><xs:documentation>Whether the model is visible or not</xs:documentation></xs:annotation>
|
||||
</xs:element>
|
||||
</xs:all>
|
||||
</xs:complexType>
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
</Team>
|
||||
</c:Team>
|
||||
<c:Transform>
|
||||
<Orientation X="0" Y="2.24449515" Z="0"/>
|
||||
<Position X="8.60201447e-23" Y="0" Z="3.9201616e-23"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
|
||||
@@ -141,9 +141,10 @@
|
||||
<Components>
|
||||
<c:Animation>
|
||||
<Name>Hold Pos</Name>
|
||||
<Time>0.9779997896222552</Time>
|
||||
<Time>0.73515426169631848</Time>
|
||||
<Speed>1</Speed>
|
||||
</c:Animation>
|
||||
<c:HiddenForLocalPlayer/>
|
||||
<c:Model>
|
||||
<Resource>Models/AssaultAnimated.mesh</Resource>
|
||||
<Color A="1" B="0" G="0" R="1"/>
|
||||
|
||||
@@ -34,6 +34,9 @@
|
||||
<xs:element ref="c:UniformScale" minOccurs="0"/>
|
||||
<xs:element ref="c:EditorWidget" minOccurs="0"/>
|
||||
<xs:element ref="c:Lifetime" minOccurs="0"/>
|
||||
<xs:element ref="c:HiddenForLocalPlayer" minOccurs="0"/>
|
||||
<xs:element ref="c:Fill" minOccurs="0"/>
|
||||
<xs:element ref="c:Animation" minOccurs="0"/>
|
||||
</xs:all>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
||||
@@ -8,7 +8,7 @@ void CollidableOctreeSystem::Update(double dt)
|
||||
void CollidableOctreeSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& component, double dt)
|
||||
{
|
||||
if (entity.HasComponent("AABB")) {
|
||||
boost::optional<AABB> absoluteAABB = Collision::EntityAbsoluteAABB(entity);
|
||||
boost::optional<EntityAABB> absoluteAABB = Collision::EntityAbsoluteAABB(entity);
|
||||
if (absoluteAABB) {
|
||||
m_Octree->AddDynamicObject(*absoluteAABB);
|
||||
}
|
||||
|
||||
@@ -283,7 +283,7 @@ bool attachAABBComponentFromModel(World* world, EntityID id)
|
||||
return true;
|
||||
}
|
||||
|
||||
boost::optional<AABB> EntityAbsoluteAABB(EntityWrapper& entity)
|
||||
boost::optional<EntityAABB> EntityAbsoluteAABB(EntityWrapper& entity)
|
||||
{
|
||||
if (!entity.HasComponent("AABB")) {
|
||||
return boost::none;
|
||||
@@ -294,7 +294,11 @@ boost::optional<AABB> EntityAbsoluteAABB(EntityWrapper& entity)
|
||||
glm::vec3 absScale = Transform::AbsoluteScale(entity.World, entity.ID);
|
||||
glm::vec3 origin = absPosition + (glm::vec3)cAABB["Origin"];
|
||||
glm::vec3 size = (glm::vec3)cAABB["Size"] * absScale;
|
||||
return AABB::FromOriginSize(origin, size);
|
||||
|
||||
EntityAABB aabb = EntityAABB::FromOriginSize(origin, size);
|
||||
aabb.Entity = entity;
|
||||
|
||||
return aabb;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -9,12 +9,12 @@ void CollisionSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& c
|
||||
}
|
||||
ComponentWrapper& cPhysics = entity["Physics"];
|
||||
|
||||
boost::optional<AABB> boundingBox = Collision::EntityAbsoluteAABB(entity);
|
||||
boost::optional<EntityAABB> boundingBox = Collision::EntityAbsoluteAABB(entity);
|
||||
if (!boundingBox) {
|
||||
return;
|
||||
}
|
||||
ComponentWrapper& cTransform = entity["Transform"];
|
||||
AABB& boxA = *boundingBox;
|
||||
EntityAABB& boxA = *boundingBox;
|
||||
|
||||
//Press 'Z' to enable/disable collision.
|
||||
if (zPress) {
|
||||
@@ -22,7 +22,7 @@ void CollisionSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& c
|
||||
}
|
||||
|
||||
// Collide against octree
|
||||
std::vector<AABB> octreeResult;
|
||||
std::vector<EntityAABB> octreeResult;
|
||||
m_Octree->ObjectsInSameRegion(*boundingBox, octreeResult);
|
||||
for (auto& boxB : octreeResult) {
|
||||
glm::vec3 resolutionVector;
|
||||
|
||||
@@ -3,79 +3,72 @@
|
||||
#include "Core/AABB.h"
|
||||
#include "Rendering/Model.h"
|
||||
|
||||
void TriggerSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& component, double dt)
|
||||
void TriggerSystem::UpdateComponent(EntityWrapper& triggerEntity, ComponentWrapper& cTrigger, double dt)
|
||||
{
|
||||
//Currently only players can trigger things.
|
||||
auto players = m_World->GetComponents("Player");
|
||||
if (players == nullptr) {
|
||||
return;
|
||||
}
|
||||
EntityID tId = component.EntityID;
|
||||
boost::optional<AABB> triggerBox = Collision::EntityAbsoluteAABB(entity);
|
||||
//The trigger *should* have a bounding box, or something, to test against so it can be triggered.
|
||||
// The trigger *should* have a bounding box, or something, to test against so it can be triggered.
|
||||
boost::optional<EntityAABB> triggerBox = Collision::EntityAbsoluteAABB(triggerEntity);
|
||||
if (!triggerBox) {
|
||||
return;
|
||||
}
|
||||
for (auto& pc : *players) {
|
||||
EntityID pId = pc.EntityID;
|
||||
boost::optional<AABB> playerBox = Collision::EntityAbsoluteAABB(EntityWrapper(m_World, pId));
|
||||
//The player can't trigger anything without an AABB.
|
||||
if (!playerBox) {
|
||||
continue;
|
||||
}
|
||||
if (!Collision::AABBVsAABB(*triggerBox, *playerBox)) {
|
||||
//Entity is not touching the trigger,
|
||||
//Throw event if it was previously.
|
||||
if (throwLeaveIfWasInTrigger(m_EntitiesTouchingTrigger[tId], pId, tId)) {
|
||||
continue;
|
||||
}
|
||||
//This only occurs if the entity was completely inside the trigger one frame,
|
||||
//then completely outside the trigger, e.g. when dying and respawning.
|
||||
throwLeaveIfWasInTrigger(m_EntitiesCompletelyInTrigger[tId], pId, tId);
|
||||
} else {
|
||||
//Entity is at least touching the trigger.
|
||||
|
||||
m_OctreeOut.clear();
|
||||
m_Octree->ObjectsInSameRegion(*triggerBox, m_OctreeOut);
|
||||
|
||||
for (EntityAABB& colliderBox : m_OctreeOut) {
|
||||
EntityWrapper colliderEntity = colliderBox.Entity;
|
||||
|
||||
if (Collision::AABBVsAABB(*triggerBox, colliderBox)) {
|
||||
AABB completelyInsideBox;
|
||||
bool playerFitsInTrigger = glm::all(glm::greaterThan((*triggerBox).Size(), (*playerBox).Size()));
|
||||
if (playerFitsInTrigger) {
|
||||
completelyInsideBox = AABB::FromOriginSize((*triggerBox).Origin(), (*triggerBox).Size() - 2.0f * (*playerBox).Size());
|
||||
bool colliderFitsInTrigger = glm::all(glm::greaterThan((*triggerBox).Size(), colliderBox.Size()));
|
||||
if (colliderFitsInTrigger) {
|
||||
completelyInsideBox = AABB::FromOriginSize((*triggerBox).Origin(), (*triggerBox).Size() - 2.0f * colliderBox.Size());
|
||||
}
|
||||
if (playerFitsInTrigger && Collision::AABBVsAABB(completelyInsideBox, *playerBox)) {
|
||||
//Entity is completely inside the trigger.
|
||||
//If it was only touching before, it is erased.
|
||||
m_EntitiesTouchingTrigger[tId].erase(pId);
|
||||
std::unordered_set<EntityID>& completeSet = m_EntitiesCompletelyInTrigger[tId];
|
||||
if (completeSet.count(pId) == 0) {
|
||||
//If it wasn't completely in the trigger, throw Enter and add to the set.
|
||||
completeSet.insert(pId);
|
||||
publish<Events::TriggerEnter>(pId, tId);
|
||||
if (colliderFitsInTrigger && Collision::AABBVsAABB(completelyInsideBox, colliderBox)) {
|
||||
// Entity is completely inside the trigger.
|
||||
// If it was only touching before, it is erased.
|
||||
m_EntitiesTouchingTrigger[triggerEntity].erase(colliderEntity);
|
||||
auto& completeSet = m_EntitiesCompletelyInTrigger[triggerEntity];
|
||||
if (completeSet.count(colliderEntity) == 0) {
|
||||
// If it wasn't completely in the trigger, throw Enter and add to the set.
|
||||
completeSet.insert(colliderEntity);
|
||||
publish<Events::TriggerEnter>(colliderEntity, triggerEntity);
|
||||
}
|
||||
} else {
|
||||
//Entity is only touching the trigger.
|
||||
std::unordered_set<EntityID>& touchSet = m_EntitiesTouchingTrigger[tId];
|
||||
std::unordered_set<EntityID>& completeSet = m_EntitiesCompletelyInTrigger[tId];
|
||||
const auto& it = completeSet.find(pId);
|
||||
// Entity is only touching the trigger.
|
||||
auto& touchSet = m_EntitiesTouchingTrigger[triggerEntity];
|
||||
auto& completeSet = m_EntitiesCompletelyInTrigger[triggerEntity];
|
||||
const auto& it = completeSet.find(colliderEntity);
|
||||
//If it was completely inside before.
|
||||
if (it != completeSet.end()) {
|
||||
completeSet.erase(it);
|
||||
touchSet.insert(pId);
|
||||
touchSet.insert(colliderEntity);
|
||||
//If it was completely outside before.
|
||||
} else if (touchSet.count(pId) == 0) {
|
||||
publish<Events::TriggerTouch>(pId, tId);
|
||||
touchSet.insert(pId);
|
||||
} else if (touchSet.count(colliderEntity) == 0) {
|
||||
publish<Events::TriggerTouch>(colliderEntity, triggerEntity);
|
||||
touchSet.insert(colliderEntity);
|
||||
}
|
||||
//Else, it was touching the trigger last frame too and nothing is done.
|
||||
// Else, it was touching the trigger last frame too and nothing is done.
|
||||
}
|
||||
} else {
|
||||
// Entity is not touching the trigger,
|
||||
// Throw event if it was previously.
|
||||
if (throwLeaveIfWasInTrigger(m_EntitiesTouchingTrigger[triggerEntity], colliderEntity, triggerEntity)) {
|
||||
continue;
|
||||
}
|
||||
// This only occurs if the entity was completely inside the trigger one frame,
|
||||
// then completely outside the trigger, e.g. when dying and respawning.
|
||||
throwLeaveIfWasInTrigger(m_EntitiesCompletelyInTrigger[triggerEntity], colliderEntity, triggerEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool TriggerSystem::throwLeaveIfWasInTrigger(std::unordered_set<EntityID>& triggerSet, EntityID pId, EntityID tId)
|
||||
bool TriggerSystem::throwLeaveIfWasInTrigger(std::unordered_set<EntityWrapper>& triggerSet, EntityWrapper colliderEntity, EntityWrapper triggerEntity)
|
||||
{
|
||||
const auto& it = triggerSet.find(pId);
|
||||
const auto& it = triggerSet.find(colliderEntity);
|
||||
if (it != triggerSet.end()) {
|
||||
//If it was in the trigger, but not anymore, throw leaveEvent and erase from the set.
|
||||
triggerSet.erase(it);
|
||||
publish<Events::TriggerLeave>(pId, tId);
|
||||
publish<Events::TriggerLeave>(colliderEntity, triggerEntity);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -20,10 +20,6 @@ AABB::AABB(const glm::vec3& minPos, const glm::vec3& maxPos)
|
||||
}
|
||||
}
|
||||
|
||||
AABB::AABB(const glm::vec4& minPos, const glm::vec4& maxPos)
|
||||
: AABB(glm::vec3(minPos), glm::vec3(maxPos))
|
||||
{ }
|
||||
|
||||
AABB AABB::FromOriginSize(const glm::vec3& origin, const glm::vec3& size)
|
||||
{
|
||||
return AABB(origin - (size/2.f), origin + (size/2.f));
|
||||
|
||||
@@ -65,6 +65,7 @@ void EntityFilePreprocessor::parseComponentInfo()
|
||||
|
||||
// Name
|
||||
compInfo.Name = XS::ToString(element->getName());
|
||||
bool brk = compInfo.Name == "HiddenForLocalPlayer";
|
||||
// Known allocation
|
||||
compInfo.Meta->Allocation = m_ComponentCounts[compInfo.Name];
|
||||
// Annotation
|
||||
@@ -90,7 +91,7 @@ void EntityFilePreprocessor::parseComponentInfo()
|
||||
// <xs:all>
|
||||
auto modelGroupParticle = complexTypeDefinition->getParticle();
|
||||
if (modelGroupParticle == nullptr || modelGroupParticle->getTermType() != XSParticle::TERM_MODELGROUP) {
|
||||
//LOG_ERROR("Failed to parse component definition for \"%s\": Model group particle was null or wasn't TERM_MODELGROUP!", compInfo.Name.c_str());
|
||||
LOG_ERROR("Failed to parse component definition for \"%s\": Model group particle was null or wasn't TERM_MODELGROUP!", compInfo.Name.c_str());
|
||||
continue;
|
||||
}
|
||||
auto modelGroup = modelGroupParticle->getModelGroupTerm();
|
||||
|
||||
@@ -97,11 +97,6 @@ EntityWrapper::operator EntityID() const
|
||||
return this->ID;
|
||||
}
|
||||
|
||||
EntityWrapper::operator bool()
|
||||
{
|
||||
return this->Valid();
|
||||
}
|
||||
|
||||
EntityWrapper EntityWrapper::firstChildByNameRecursive(const std::string& name, EntityID parent)
|
||||
{
|
||||
if (!this->World->ValidEntity(parent)) {
|
||||
|
||||
@@ -54,8 +54,12 @@ ComponentWrapper World::AttachComponent(EntityID entity, const std::string& comp
|
||||
|
||||
bool World::HasComponent(EntityID entity, const std::string& componentType) const
|
||||
{
|
||||
ComponentPool* pool = m_ComponentPools.at(componentType);
|
||||
return pool->KnowsEntity(entity);
|
||||
auto it = m_ComponentPools.find(componentType);
|
||||
if (it == m_ComponentPools.end()) {
|
||||
return false;
|
||||
} else {
|
||||
return it->second->KnowsEntity(entity);
|
||||
}
|
||||
}
|
||||
|
||||
ComponentWrapper World::GetComponent(EntityID entity, const std::string& componentType)
|
||||
|
||||
@@ -12,7 +12,7 @@ EditorRenderSystem::EditorRenderSystem(World* m_World, EventBroker* eventBroker,
|
||||
|
||||
void EditorRenderSystem::Update(double dt)
|
||||
{
|
||||
if (m_CurrentCamera) {
|
||||
if (m_CurrentCamera.Valid()) {
|
||||
ComponentWrapper cameraTransform = m_CurrentCamera["Transform"];
|
||||
m_EditorCamera->SetPosition(cameraTransform["Position"]);
|
||||
m_EditorCamera->SetOrientation(glm::quat((const glm::vec3&)cameraTransform["Orientation"]));
|
||||
|
||||
@@ -31,6 +31,16 @@ bool RenderSystem::OnSetCamera(Events::SetCamera& e)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RenderSystem::isChildOfACamera(EntityWrapper entity)
|
||||
{
|
||||
return entity.FirstParentWithComponent("Camera").Valid();
|
||||
}
|
||||
|
||||
bool RenderSystem::isChildOfCurrentCamera(EntityWrapper entity)
|
||||
{
|
||||
return entity == m_CurrentCamera || entity.IsChildOf(m_CurrentCamera);
|
||||
}
|
||||
|
||||
void RenderSystem::fillModels(std::list<std::shared_ptr<RenderJob>>& jobs)
|
||||
{
|
||||
auto models = m_World->GetComponents("Model");
|
||||
@@ -38,26 +48,25 @@ void RenderSystem::fillModels(std::list<std::shared_ptr<RenderJob>>& jobs)
|
||||
return;
|
||||
}
|
||||
|
||||
for (auto& modelComponent : *models) {
|
||||
bool visible = modelComponent["Visible"];
|
||||
for (auto& cModel : *models) {
|
||||
bool visible = cModel["Visible"];
|
||||
if (!visible) {
|
||||
continue;
|
||||
}
|
||||
std::string resource = modelComponent["Resource"];
|
||||
std::string resource = cModel["Resource"];
|
||||
if (resource.empty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
EntityWrapper entity(m_World, modelComponent.EntityID);
|
||||
EntityWrapper entity(m_World, cModel.EntityID);
|
||||
|
||||
// Don't render the local player
|
||||
if (entity == m_LocalPlayer || entity.IsChildOf(m_LocalPlayer)) {
|
||||
if (!entity.HasComponent("HealthHUD") && entity.Name() != "Crosshair" && entity.Name() != "Weapon") { //Should work but needs to be fixed. Should only render the things "childed" to the local player camera
|
||||
continue;
|
||||
}
|
||||
// Only render children of a camera if that camera is currently active
|
||||
if (isChildOfACamera(entity) && !isChildOfCurrentCamera(entity)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((entity.Name() == "Weapon" || entity.HasComponent("HealthHUD")) && !entity.IsChildOf(m_LocalPlayer)) {
|
||||
// Hide things parented to local player if they have the HiddenFromLocalPlayer component
|
||||
if (entity.HasComponent("HiddenForLocalPlayer") && (entity == m_LocalPlayer || entity.IsChildOf(m_LocalPlayer))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -78,23 +87,23 @@ void RenderSystem::fillModels(std::list<std::shared_ptr<RenderJob>>& jobs)
|
||||
|
||||
float fillPercentage = 0.f;
|
||||
glm::vec4 fillColor = glm::vec4(0);
|
||||
if(m_World->HasComponent(modelComponent.EntityID, "Fill")) {
|
||||
auto fillComponent = m_World->GetComponent(modelComponent.EntityID, "Fill");
|
||||
if(m_World->HasComponent(cModel.EntityID, "Fill")) {
|
||||
auto fillComponent = m_World->GetComponent(cModel.EntityID, "Fill");
|
||||
fillPercentage = (float)(double)fillComponent["Percentage"];
|
||||
fillColor = (glm::vec4)fillComponent["Color"];
|
||||
}
|
||||
|
||||
glm::mat4 modelMatrix = Transform::ModelMatrix(modelComponent.EntityID, m_World);
|
||||
glm::mat4 modelMatrix = Transform::ModelMatrix(cModel.EntityID, m_World);
|
||||
for (auto matGroup : model->MaterialGroups()) {
|
||||
if (m_World->HasComponent(modelComponent.EntityID, "ExplosionEffect")) {
|
||||
auto explosionEffectComponent = m_World->GetComponent(modelComponent.EntityID, "ExplosionEffect");
|
||||
if (m_World->HasComponent(cModel.EntityID, "ExplosionEffect")) {
|
||||
auto explosionEffectComponent = m_World->GetComponent(cModel.EntityID, "ExplosionEffect");
|
||||
std::shared_ptr<ExplosionEffectJob> explosionEffectJob = std::shared_ptr<ExplosionEffectJob>(new ExplosionEffectJob(
|
||||
explosionEffectComponent,
|
||||
model,
|
||||
m_Camera,
|
||||
modelMatrix,
|
||||
matGroup,
|
||||
modelComponent,
|
||||
cModel,
|
||||
m_World,
|
||||
fillColor,
|
||||
fillPercentage
|
||||
@@ -106,7 +115,7 @@ void RenderSystem::fillModels(std::list<std::shared_ptr<RenderJob>>& jobs)
|
||||
m_Camera,
|
||||
modelMatrix,
|
||||
matGroup,
|
||||
modelComponent,
|
||||
cModel,
|
||||
m_World,
|
||||
fillColor,
|
||||
fillPercentage
|
||||
|
||||
+4
-3
@@ -1,5 +1,6 @@
|
||||
#include "Game.h"
|
||||
#include "Collision/CollidableOctreeSystem.h"
|
||||
#include "Collision/EntityAABB.h"
|
||||
#include "Collision/TriggerSystem.h"
|
||||
#include "Collision/CollisionSystem.h"
|
||||
#include "Systems/RaptorCopterSystem.h"
|
||||
@@ -42,7 +43,7 @@ Game::Game(int argc, char* argv[])
|
||||
0,
|
||||
m_Config->Get<int>("Video.Width", 1280),
|
||||
m_Config->Get<int>("Video.Height", 720)
|
||||
));
|
||||
));
|
||||
m_Renderer->Initialize();
|
||||
//m_Renderer->Camera()->SetFOV(glm::radians(m_Config->Get<float>("Video.FOV", 90.f)));
|
||||
m_RenderFrame = new RenderFrame();
|
||||
@@ -72,8 +73,8 @@ Game::Game(int argc, char* argv[])
|
||||
|
||||
|
||||
// Create Octrees
|
||||
m_OctreeCollision = new Octree<AABB>(AABB(glm::vec3(-100), glm::vec3(100)), 4);
|
||||
m_OctreeFrustrumCulling = new Octree<AABB>(AABB(glm::vec3(-100), glm::vec3(100)), 4);
|
||||
m_OctreeCollision = new Octree<EntityAABB>(AABB(glm::vec3(-100), glm::vec3(100)), 4);
|
||||
m_OctreeFrustrumCulling = new Octree<EntityAABB>(AABB(glm::vec3(-100), glm::vec3(100)), 4);
|
||||
// Create system pipeline
|
||||
m_SystemPipeline = new SystemPipeline(m_World, m_EventBroker);
|
||||
|
||||
|
||||
@@ -13,27 +13,27 @@ CapturePointSystem::CapturePointSystem(World* world, EventBroker* eventBroker)
|
||||
|
||||
//here all capturepoints will update their component
|
||||
//NOTE: needs to run each frame, since we're possibly modifying the captureTimer for the capturePoints by dt
|
||||
void CapturePointSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& capturePoint, double dt)
|
||||
void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, ComponentWrapper& cCapturePoint, double dt)
|
||||
{
|
||||
if (m_WinnerWasFound) {
|
||||
return;
|
||||
}
|
||||
const int capturePointNumber = capturePoint["CapturePointNumber"];
|
||||
const bool hasTeamComponent = m_World->HasComponent(capturePoint.EntityID, "Team");
|
||||
const int capturePointNumber = cCapturePoint["CapturePointNumber"];
|
||||
const bool hasTeamComponent = capturePointEntity.HasComponent("Team");
|
||||
|
||||
//if point doesnt have a teamComponent yet, add one. since:
|
||||
//what if capture point has no team -> we cant get/use the team enum from it...
|
||||
if (!hasTeamComponent) {
|
||||
m_World->AttachComponent(capturePoint.EntityID, "Team");
|
||||
ComponentWrapper& teamComponent = m_World->GetComponent(capturePoint.EntityID, "Team");
|
||||
m_World->AttachComponent(cCapturePoint.EntityID, "Team");
|
||||
ComponentWrapper& teamComponent = capturePointEntity["Team"];
|
||||
teamComponent["Team"] = (int)teamComponent["Team"].Enum("Spectator");
|
||||
}
|
||||
ComponentWrapper& teamComponent = m_World->GetComponent(capturePoint.EntityID, "Team");
|
||||
ComponentWrapper& teamComponent = capturePointEntity["Team"];
|
||||
const int redTeam = (int)teamComponent["Team"].Enum("Red");
|
||||
const int blueTeam = (int)teamComponent["Team"].Enum("Blue");
|
||||
const int spectatorTeam = (int)teamComponent["Team"].Enum("Spectator");
|
||||
|
||||
int homePointForTeam = (int)capturePoint["HomePointForTeam"];
|
||||
int homePointForTeam = (int)cCapturePoint["HomePointForTeam"];
|
||||
if (m_NumberOfCapturePoints == 0 && capturePointNumber != 0 && (homePointForTeam == redTeam || homePointForTeam == blueTeam)) {
|
||||
m_NumberOfCapturePoints = capturePointNumber + 1;//ex 2 -> 0,1,2 = 3
|
||||
if (homePointForTeam == redTeam) {
|
||||
@@ -46,8 +46,8 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper
|
||||
}
|
||||
|
||||
//if we havent received all capturepoints yet, just return
|
||||
if (m_NumberOfCapturePoints == 0 || m_NumberOfCapturePoints != m_CapturePointNumberToEntityIDMap.size()) {
|
||||
m_CapturePointNumberToEntityIDMap.insert(std::make_pair(capturePointNumber, capturePoint.EntityID));
|
||||
if (m_NumberOfCapturePoints == 0 || m_NumberOfCapturePoints != m_CapturePointNumberToEntityMap.size()) {
|
||||
m_CapturePointNumberToEntityMap.insert(std::make_pair(capturePointNumber, capturePointEntity));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -55,9 +55,9 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper
|
||||
int ownedBy = teamComponent["Team"];
|
||||
int redTeamPlayersStandingInside = 0;
|
||||
int blueTeamPlayersStandingInside = 0;
|
||||
if (entity.HasComponent("Model")) {
|
||||
if (capturePointEntity.HasComponent("Model")) {
|
||||
//Now sets team color to the capturepoint, or white if it is uncaptured.
|
||||
entity["Model"]["Color"] = ownedBy == blueTeam ? glm::vec4(0, 0.2f, 1, 1) : ownedBy == redTeam ? glm::vec4(1, 0.2f, 0, 1) : glm::vec4(1, 1, 1, 1);
|
||||
capturePointEntity["Model"]["Color"] = ownedBy == blueTeam ? glm::vec4(0, 0.2f, 1, 1) : ownedBy == redTeam ? glm::vec4(1, 0.2f, 0, 1) : glm::vec4(1, 1, 1, 1);
|
||||
}
|
||||
|
||||
//calculate next possible capturePoint for both teams
|
||||
@@ -66,10 +66,10 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper
|
||||
nextPossibleCapturePoint["Blue"] = -1;
|
||||
for (size_t i = 0; i < m_NumberOfCapturePoints; i++)
|
||||
{
|
||||
if (!m_World->HasComponent(m_CapturePointNumberToEntityIDMap[i], "Team")) {
|
||||
if (m_CapturePointNumberToEntityMap[i].HasComponent("Team")) {
|
||||
continue;
|
||||
}
|
||||
ComponentWrapper& capturePointOwnedBy = m_World->GetComponent(m_CapturePointNumberToEntityIDMap[i], "Team");
|
||||
ComponentWrapper& capturePointOwnedBy = m_CapturePointNumberToEntityMap[i]["Team"];
|
||||
if ((int)capturePointOwnedBy["Team"] == redTeam && m_RedTeamHomeCapturePoint == 0) {
|
||||
nextPossibleCapturePoint["Red"] = i + 1;
|
||||
}
|
||||
@@ -79,10 +79,10 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper
|
||||
}
|
||||
for (int i = m_NumberOfCapturePoints - 1; i >= 0; i--)
|
||||
{
|
||||
if (!m_World->HasComponent(m_CapturePointNumberToEntityIDMap[i], "Team")) {
|
||||
if (!m_CapturePointNumberToEntityMap[i].HasComponent("Team")) {
|
||||
continue;
|
||||
}
|
||||
ComponentWrapper& capturePointOwnedBy = m_World->GetComponent(m_CapturePointNumberToEntityIDMap[i], "Team");
|
||||
ComponentWrapper& capturePointOwnedBy = m_CapturePointNumberToEntityMap[i]["Team"];
|
||||
if ((int)capturePointOwnedBy["Team"] == redTeam && m_RedTeamHomeCapturePoint != 0) {
|
||||
nextPossibleCapturePoint["Red"] = i - 1;
|
||||
}
|
||||
@@ -95,7 +95,7 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper
|
||||
if (m_ResetTimers) {
|
||||
for (size_t i = 0; i < m_NumberOfCapturePoints; i++)
|
||||
{
|
||||
ComponentWrapper& capturePoint = m_World->GetComponent(m_CapturePointNumberToEntityIDMap[i], "CapturePoint");
|
||||
ComponentWrapper& capturePoint = m_CapturePointNumberToEntityMap[i]["CapturePoint"];
|
||||
if ((int)capturePoint["CapturePointNumber"] != nextPossibleCapturePoint["Red"] &&
|
||||
(int)capturePoint["CapturePointNumber"] != nextPossibleCapturePoint["Blue"]) {
|
||||
capturePoint["CaptureTimer"] = 0.0;
|
||||
@@ -106,34 +106,34 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper
|
||||
|
||||
//colorize next possible capturepoint
|
||||
if (nextPossibleCapturePoint["Red"] == capturePointNumber) {
|
||||
entity["Model"]["Color"] = glm::vec4(1, 1, 0, 1);
|
||||
capturePointEntity["Model"]["Color"] = glm::vec4(1, 1, 0, 1);
|
||||
}
|
||||
if (nextPossibleCapturePoint["Blue"] == capturePointNumber) {
|
||||
entity["Model"]["Color"] = glm::vec4(0, 1, 1, 1);
|
||||
capturePointEntity["Model"]["Color"] = glm::vec4(0, 1, 1, 1);
|
||||
}
|
||||
|
||||
//check how many players are standing inside and are healthy
|
||||
for (size_t i = m_ETriggerTouchVector.size(); i > 0; i--)
|
||||
{
|
||||
auto triggerTouched = m_ETriggerTouchVector[i - 1];
|
||||
if (std::get<1>(triggerTouched) == capturePoint.EntityID) {
|
||||
if (std::get<1>(triggerTouched) == capturePointEntity) {
|
||||
//some player has touched this - lets figure out: what team, health
|
||||
EntityID playerID = std::get<0>(triggerTouched);
|
||||
if (!m_World->HasComponent(playerID, "Player")) {
|
||||
EntityWrapper player = std::get<0>(triggerTouched);
|
||||
if (!player.HasComponent("Player")) {
|
||||
//if a non-player has entered the capturePoint, just erase that event and continue
|
||||
m_ETriggerTouchVector.erase(m_ETriggerTouchVector.begin() + i - 1);
|
||||
continue;
|
||||
}
|
||||
bool hasHealthComponent = m_World->HasComponent(playerID, "Health");
|
||||
bool hasHealthComponent = player.HasComponent("Health");
|
||||
if (hasHealthComponent) {
|
||||
double currentHealth = m_World->GetComponent(playerID, "Health")["Health"];
|
||||
double currentHealth = player["Health"]["Health"];
|
||||
//check if player is dead
|
||||
if ((int)currentHealth == 0) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
//check team - spectatorNumber = "no team"
|
||||
int teamNumber = m_World->GetComponent(playerID, "Team")["Team"];
|
||||
int teamNumber = player["Team"]["Team"];
|
||||
if (teamNumber == redTeam) {
|
||||
redTeamPlayersStandingInside++;
|
||||
} else if (teamNumber == blueTeam) {
|
||||
@@ -169,24 +169,24 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper
|
||||
//B. at most one of the teams have players inside
|
||||
//if capturePoint is not owned by the take-over team, just modify the CaptureTimer accordingly
|
||||
if (ownedBy != currentTeam && canCapture) {
|
||||
if (abs((double)capturePoint["CaptureTimer"]) < 0.001f) {
|
||||
if (abs((double)cCapturePoint["CaptureTimer"]) < 0.001f) {
|
||||
LOG_DEBUG("Point is being captured by team %i", currentTeam); //Remove when we tested sufficiently.
|
||||
}
|
||||
capturePoint["CaptureTimer"] = (double)capturePoint["CaptureTimer"] + timerDeltaChange;
|
||||
cCapturePoint["CaptureTimer"] = (double)cCapturePoint["CaptureTimer"] + timerDeltaChange;
|
||||
}
|
||||
//if capturePoint is owned by the team, and the other team has been trying to take it, then increase/decrease the timer towards 0.0
|
||||
if ((ownedBy == currentTeam && currentTeam == redTeam && (double)capturePoint["CaptureTimer"] < 0.0) ||
|
||||
(ownedBy == currentTeam && currentTeam == blueTeam && (double)capturePoint["CaptureTimer"] > 0.0)) {
|
||||
capturePoint["CaptureTimer"] = (double)capturePoint["CaptureTimer"] + timerDeltaChange;
|
||||
if ((ownedBy == currentTeam && currentTeam == redTeam && (double)cCapturePoint["CaptureTimer"] < 0.0) ||
|
||||
(ownedBy == currentTeam && currentTeam == blueTeam && (double)cCapturePoint["CaptureTimer"] > 0.0)) {
|
||||
cCapturePoint["CaptureTimer"] = (double)cCapturePoint["CaptureTimer"] + timerDeltaChange;
|
||||
}
|
||||
//check if captureTimer > m_CaptureTimeToTakeOver and if so change owner and publish the eCaptured event
|
||||
if (abs((double)capturePoint["CaptureTimer"]) > abs(m_CaptureTimeToTakeOver) && canCapture) {
|
||||
if (abs((double)cCapturePoint["CaptureTimer"]) > abs(m_CaptureTimeToTakeOver) && canCapture) {
|
||||
teamComponent["Team"] = currentTeam;
|
||||
capturePoint["CaptureTimer"] = 0.0;
|
||||
cCapturePoint["CaptureTimer"] = 0.0;
|
||||
//publish Captured event
|
||||
LOG_DEBUG("Point is captured by team %i!", currentTeam); //Remove when we tested sufficiently.
|
||||
Events::Captured e;
|
||||
e.CapturePointID = capturePoint.EntityID;
|
||||
e.CapturePointID = cCapturePoint.EntityID;
|
||||
e.TeamNumberThatCapturedCapturePoint = currentTeam;
|
||||
m_EventBroker->Publish(e);
|
||||
//NextPossibleCapturePoint will be calculated in the next update...
|
||||
|
||||
Reference in New Issue
Block a user