Merge branch 'deffered_rendering'
Conflicts: assets src/Components/Physics.h src/GameWorld.cpp src/GameWorld.h src/Systems/PhysicsSystem.cpp vs11/Returngeance/Returngeance.vcxproj vs11/Returngeance/Returngeance.vcxproj.filters
This commit is contained in:
+1
-1
Submodule assets updated: 3c4d81137f...75977fd865
@@ -16,13 +16,38 @@ struct Physics : Component
|
||||
EXPLOSION = 4,
|
||||
};
|
||||
|
||||
enum class MotionTypeEnum
|
||||
{
|
||||
Dynamic,
|
||||
Fixed,
|
||||
Keyframed
|
||||
};
|
||||
|
||||
Physics()
|
||||
: Mass(1.f), Static(false), Phantom(false), CalculateCenterOfMass(true), CenterOfMass(glm::vec3(0)), InitialLinearVelocity(glm::vec3(0)), InitialAngularVelocity(glm::vec3(0)),
|
||||
LinearDamping(0.f), AngularDamping(0.05f), GravityFactor(1.f), Friction(0.5f), Restitution(0.4f), MaxLinearVelocity(200.f), MaxAngularVelocity(200.f),
|
||||
CollisionLayer(0), CollisionSystemGroup(0), CollisionSubSystemId(0), CollisionSubSystemDontCollideWith(0), CollisionEvent(false){}
|
||||
: Mass(1.f)
|
||||
//, Static(false)
|
||||
, MotionType(MotionTypeEnum::Fixed)
|
||||
, Phantom(false)
|
||||
, CalculateCenterOfMass(true)
|
||||
, CenterOfMass(glm::vec3(0))
|
||||
, InitialLinearVelocity(glm::vec3(0))
|
||||
, InitialAngularVelocity(glm::vec3(0))
|
||||
, LinearDamping(0.f)
|
||||
, AngularDamping(0.05f)
|
||||
, GravityFactor(1.f)
|
||||
, Friction(0.5f)
|
||||
, Restitution(0.4f)
|
||||
, MaxLinearVelocity(200.f)
|
||||
, MaxAngularVelocity(200.f)
|
||||
, CollisionLayer(0)
|
||||
, CollisionSystemGroup(0)
|
||||
, CollisionSubSystemId(0)
|
||||
, CollisionSubSystemDontCollideWith(0)
|
||||
, CollisionEvent(false)
|
||||
{ }
|
||||
|
||||
float Mass;
|
||||
bool Static;
|
||||
MotionTypeEnum MotionType;
|
||||
bool Phantom;
|
||||
|
||||
bool CalculateCenterOfMass;
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
#ifndef Components_Wall_h__
|
||||
#define Components_Wall_h__
|
||||
|
||||
#include "Component.h"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace Components
|
||||
{
|
||||
|
||||
struct Wall : Component
|
||||
{
|
||||
std::vector<EntityID> Walldebris;
|
||||
|
||||
virtual Wall* Clone() const override { return new Wall(*this); }
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // Components_TankShell_h__
|
||||
@@ -0,0 +1,16 @@
|
||||
#ifndef Events_OnDead_h__
|
||||
#define Events_OnDead_h__
|
||||
#include "Entity.h"
|
||||
#include "EventBroker.h"
|
||||
|
||||
namespace Events
|
||||
{
|
||||
struct OnDead : Event
|
||||
{
|
||||
EntityID Entity;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif // Events_OnDead_h__
|
||||
+771
-195
File diff suppressed because it is too large
Load Diff
+4
-1
@@ -22,6 +22,7 @@
|
||||
#include "Systems/DamageSystem.h"
|
||||
#include "Systems/WheelPairSystem.h"
|
||||
#include "Systems/FollowSystem.h"
|
||||
#include "Systems/WallSystem.h"
|
||||
#include "Systems/GarageSystem.h"
|
||||
|
||||
#include "Components/Camera.h"
|
||||
@@ -77,10 +78,12 @@ private:
|
||||
void BindGamepadAxis(Gamepad::Axis axis, std::string command, float value);
|
||||
void BindGamepadButton(Gamepad::Button button, std::string command, float value);
|
||||
|
||||
EntityID CreateTank(int playerID);
|
||||
void CreateGate(glm::vec3 Position);
|
||||
void AddTankWheelPair(EntityID tankEntity, glm::vec3 position, int axleID, bool steering);
|
||||
EntityID CreateJeep(int playerID);
|
||||
EntityID CreateWall(glm::vec3 pos, glm::quat orientation);
|
||||
EntityID CreateGarage(glm::vec3 Position, int playerID);
|
||||
std::vector<EntityID> m_WallDebrisTemplates;
|
||||
};
|
||||
|
||||
#endif // GameWorld_h__
|
||||
|
||||
+1
-1
@@ -93,7 +93,7 @@ Model::Model(std::shared_ptr<ResourceManager> rm, OBJ &obj)
|
||||
if (Vertices.size() > 0)
|
||||
{
|
||||
CreateTangents();
|
||||
getSimilarVertexIndex();
|
||||
//getSimilarVertexIndex();
|
||||
CreateBuffers(Vertices, Normals, TangentNormals, BiTangentNormals, TextureCoords);
|
||||
}
|
||||
else
|
||||
|
||||
+10
-12
@@ -377,9 +377,9 @@ void Renderer::DrawWorld(RenderQueuePair &rq)
|
||||
for(auto job : rq.Forward)
|
||||
{
|
||||
glm::mat4 cameraProjection = m_Camera->ProjectionMatrix((float)m_Viewport.Width / m_Viewport.Height);
|
||||
glm::mat4 cameraMatrix = cameraProjection * m_Camera->ViewMatrix();
|
||||
glm::mat4 cameraMatrix = m_Camera->ViewMatrix();
|
||||
|
||||
glm::vec3 spritePos = glm::vec3(cameraMatrix * job->ModelMatrix * glm::vec4(1, 1, 1, 0));
|
||||
glm::vec3 spritePos = glm::vec3((cameraMatrix * job->ModelMatrix) * glm::vec4(1, 1, 1, 1));
|
||||
job->Depth = spritePos.z;
|
||||
}
|
||||
rq.Forward.Jobs.sort(Renderer::DepthSort);
|
||||
@@ -475,10 +475,10 @@ void Renderer::ForwardRendering(RenderQueue &rq)
|
||||
glScissor(m_Viewport.X, m_Height - m_Viewport.Y - m_Viewport.Height, m_Viewport.Width, m_Viewport.Height);
|
||||
|
||||
// Clear G-buffer
|
||||
GLenum attachments[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2, GL_COLOR_ATTACHMENT3 };
|
||||
GLenum attachments[] = { GL_COLOR_ATTACHMENT0, GL_NONE , GL_NONE , GL_NONE };
|
||||
glDrawBuffers(4, attachments);
|
||||
glClearColor(0.f, 0.f, 0.f, 0.f);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
//glClearColor(0.f, 0.f, 0.f, 1.f);
|
||||
//glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
@@ -512,7 +512,7 @@ void Renderer::ForwardRendering(RenderQueue &rq)
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, modelJob->DiffuseTexture);
|
||||
if (modelJob->NormalTexture != 0)
|
||||
/*if (modelJob->NormalTexture != 0)
|
||||
{
|
||||
glActiveTexture(GL_TEXTURE2);
|
||||
glBindTexture(GL_TEXTURE_2D, modelJob->NormalTexture);
|
||||
@@ -521,14 +521,12 @@ void Renderer::ForwardRendering(RenderQueue &rq)
|
||||
{
|
||||
glActiveTexture(GL_TEXTURE3);
|
||||
glBindTexture(GL_TEXTURE_2D, modelJob->SpecularTexture);
|
||||
}
|
||||
}*/
|
||||
glDrawArrays(GL_TRIANGLES, modelJob->StartIndex, modelJob->EndIndex - modelJob->StartIndex + 1);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
auto spriteJob = std::dynamic_pointer_cast<SpriteJob>(job);
|
||||
if (spriteJob)
|
||||
{
|
||||
@@ -559,9 +557,9 @@ void Renderer::ForwardRendering(RenderQueue &rq)
|
||||
glViewport(0, 0, m_Width, m_Height);
|
||||
glScissor(0, 0, m_Width, m_Height);
|
||||
|
||||
glDepthMask(GL_FALSE);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
m_FinalForwardPassProgram.Bind();
|
||||
//ShaderProgramHandle = m_FinalForwardPassProgram.GetHandle();
|
||||
@@ -947,7 +945,7 @@ void Renderer::FrameBufferTextures()
|
||||
//Generate and bind diffuse texture
|
||||
glGenTextures(1, &m_fDiffuseTexture);
|
||||
glBindTexture(GL_TEXTURE_2D, m_fDiffuseTexture);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, m_Width, m_Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_Width, m_Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
|
||||
+1
-1
@@ -219,7 +219,7 @@ private:
|
||||
void CreateNormalMapTangent();
|
||||
void ForwardRendering(RenderQueue &rq);
|
||||
|
||||
static bool DepthSort(const std::shared_ptr<RenderJob> &i, const std::shared_ptr<RenderJob> &j) { return (i->Depth > j->Depth); }
|
||||
static bool DepthSort(const std::shared_ptr<RenderJob> &i, const std::shared_ptr<RenderJob> &j) { return (i->Depth < j->Depth); }
|
||||
|
||||
GLuint CreateQuad();
|
||||
void DrawDebugShadowMap();
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#include "PrecompiledHeader.h"
|
||||
#include "DamageSystem.h"
|
||||
#include "World.h"
|
||||
|
||||
void Systems::DamageSystem::RegisterComponents( ComponentFactory* cf )
|
||||
{
|
||||
cf->Register<Components::Health>([]() { return new Components::Health(); });
|
||||
@@ -15,8 +14,16 @@ void Systems::DamageSystem::Initialize()
|
||||
|
||||
bool Systems::DamageSystem::OnDamage( const Events::Damage &event )
|
||||
{
|
||||
if(!m_World->ValidEntity(event.Entity))
|
||||
return false;
|
||||
auto health = m_World->GetComponent<Components::Health>(event.Entity);
|
||||
health->Amount -= event.Amount;
|
||||
if(health->Amount <= 0)
|
||||
{
|
||||
Events::OnDead e;
|
||||
e.Entity = event.Entity;
|
||||
EventBroker->Publish(e);
|
||||
}
|
||||
LOG_INFO("Damaged entity %i, Health left: %f", event.Entity, health->Amount);
|
||||
return true;
|
||||
}
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "System.h"
|
||||
#include "Components/Health.h"
|
||||
#include "Events/Damage.h"
|
||||
#include "Events/OnDead.h"
|
||||
|
||||
namespace Systems
|
||||
{
|
||||
|
||||
@@ -80,7 +80,7 @@ void Systems::PhysicsSystem::Initialize()
|
||||
worldInfo.m_broadPhaseBorderBehaviour = hkpWorldCinfo::BROADPHASE_BORDER_FIX_ENTITY;
|
||||
|
||||
// You must specify the size of the broad phase - objects should not be simulated outside this region
|
||||
worldInfo.setBroadPhaseWorldSize(1500.0f);
|
||||
worldInfo.setBroadPhaseWorldSize(500.0f);
|
||||
m_PhysicsWorld = new hkpWorld(worldInfo);
|
||||
|
||||
// When the simulation type is SIMULATION_TYPE_MULTITHREADED, in the debug build, the sdk performs checks
|
||||
@@ -151,6 +151,10 @@ void Systems::PhysicsSystem::Update(double dt)
|
||||
EntityID entity = pair.first;
|
||||
EntityID parent = pair.second;
|
||||
|
||||
auto templateComponent = m_World->GetComponent<Components::Template>(entity);
|
||||
if(templateComponent)
|
||||
continue;
|
||||
|
||||
if (m_RigidBodies.find(entity) == m_RigidBodies.end())
|
||||
continue;
|
||||
|
||||
@@ -218,6 +222,10 @@ void Systems::PhysicsSystem::Update(double dt)
|
||||
|
||||
void Systems::PhysicsSystem::UpdateEntity(double dt, EntityID entity, EntityID parent)
|
||||
{
|
||||
auto templateComponent = m_World->GetComponent<Components::Template>(entity);
|
||||
if(templateComponent)
|
||||
return;
|
||||
|
||||
auto transformComponent = m_World->GetComponent<Components::Transform>(entity);
|
||||
if (!transformComponent)
|
||||
return;
|
||||
@@ -297,14 +305,14 @@ void Systems::PhysicsSystem::OnEntityCommit( EntityID entity )
|
||||
auto physicsComponent = m_World->GetComponent<Components::Physics>(entity);
|
||||
if (physicsComponent && m_Shapes[entity].size() > 0)
|
||||
{
|
||||
if(entityParent != 0 && !physicsComponent->Static)
|
||||
if(entityParent != 0 && physicsComponent->MotionType == Components::Physics::MotionTypeEnum::Dynamic)
|
||||
{
|
||||
LOG_ERROR("Entity: %i, Only the baseparent can have a dynamic PhysicsComponent", entity);
|
||||
return;
|
||||
}
|
||||
|
||||
hkpShape* shape;
|
||||
if(! physicsComponent->Static) // Not static
|
||||
if(physicsComponent->MotionType == Components::Physics::MotionTypeEnum::Dynamic)
|
||||
{
|
||||
hkArray<hkpShape*> shapeArray;
|
||||
for (auto &shapeData : m_Shapes[entity])
|
||||
@@ -368,6 +376,7 @@ void Systems::PhysicsSystem::OnEntityCommit( EntityID entity )
|
||||
rigidBodyInfo.m_inertiaTensor = massProperties.m_inertiaTensor;
|
||||
if(physicsComponent->CalculateCenterOfMass)
|
||||
physicsComponent->CenterOfMass = HKVECTOR4_TO_GLMVEC3(massProperties.m_centerOfMass);
|
||||
|
||||
rigidBodyInfo.m_centerOfMass = GLMVEC3_TO_HKVECTOR4(physicsComponent->CenterOfMass);
|
||||
rigidBodyInfo.m_mass = massProperties.m_mass;
|
||||
rigidBodyInfo.m_linearVelocity = GLMVEC3_TO_HKVECTOR4(physicsComponent->InitialLinearVelocity);
|
||||
@@ -381,7 +390,7 @@ void Systems::PhysicsSystem::OnEntityCommit( EntityID entity )
|
||||
rigidBodyInfo.m_maxLinearVelocity = physicsComponent->MaxLinearVelocity;
|
||||
rigidBodyInfo.m_maxAngularVelocity = physicsComponent->MaxAngularVelocity;
|
||||
rigidBodyInfo.m_collisionFilterInfo = hkpGroupFilter::calcFilterInfo(physicsComponent->CollisionLayer, physicsComponent->CollisionSystemGroup, physicsComponent->CollisionSubSystemId, physicsComponent->CollisionSubSystemDontCollideWith);
|
||||
rigidBodyInfo.m_enableDeactivation = false;
|
||||
rigidBodyInfo.m_enableDeactivation = true;;
|
||||
}
|
||||
// Create RigidBody
|
||||
hkpRigidBody* rigidBody = new hkpRigidBody(rigidBodyInfo);
|
||||
@@ -438,7 +447,7 @@ void Systems::PhysicsSystem::OnEntityCommit( EntityID entity )
|
||||
rigidBody->removeReference();
|
||||
}
|
||||
}
|
||||
else // Static
|
||||
else if(physicsComponent->MotionType == Components::Physics::MotionTypeEnum::Fixed || physicsComponent->MotionType == Components::Physics::MotionTypeEnum::Keyframed)
|
||||
{
|
||||
// Create the hkpStaticCompoundShape and add the instances.
|
||||
// "meshShape" should not be modified by the user in any way after adding it as an instance.
|
||||
@@ -490,7 +499,15 @@ void Systems::PhysicsSystem::OnEntityCommit( EntityID entity )
|
||||
hkpRigidBodyCinfo rigidBodyInfo;
|
||||
{
|
||||
rigidBodyInfo.m_shape = shape;
|
||||
if(physicsComponent->MotionType == Components::Physics::MotionTypeEnum::Fixed)
|
||||
{
|
||||
rigidBodyInfo.m_motionType = hkpMotion::MOTION_FIXED;
|
||||
}
|
||||
else if(physicsComponent->MotionType == Components::Physics::MotionTypeEnum::Keyframed)
|
||||
{
|
||||
rigidBodyInfo.m_motionType = hkpMotion::MOTION_KEYFRAMED;
|
||||
}
|
||||
|
||||
auto absoluteTransform = m_World->GetSystem<Systems::TransformSystem>()->AbsoluteTransform(entity);
|
||||
hkVector4 position = GLMVEC3_TO_HKVECTOR4(absoluteTransform.Position);
|
||||
hkQuaternion rotation = GLMQUAT_TO_HKQUATERNION(absoluteTransform.Orientation);
|
||||
@@ -513,7 +530,7 @@ void Systems::PhysicsSystem::OnEntityCommit( EntityID entity )
|
||||
rigidBodyInfo.m_maxLinearVelocity = physicsComponent->MaxLinearVelocity;
|
||||
rigidBodyInfo.m_maxAngularVelocity = physicsComponent->MaxAngularVelocity;
|
||||
rigidBodyInfo.m_collisionFilterInfo = hkpGroupFilter::calcFilterInfo(physicsComponent->CollisionLayer, physicsComponent->CollisionSystemGroup, physicsComponent->CollisionSubSystemId, physicsComponent->CollisionSubSystemDontCollideWith);
|
||||
rigidBodyInfo.m_enableDeactivation = false;
|
||||
rigidBodyInfo.m_enableDeactivation = true;
|
||||
}
|
||||
// Create RigidBody
|
||||
hkpRigidBody* rigidBody = new hkpRigidBody(rigidBodyInfo);
|
||||
@@ -752,6 +769,7 @@ bool Systems::PhysicsSystem::OnSetVelocity( const Events::SetVelocity &event )
|
||||
{
|
||||
|
||||
m_PhysicsWorld->markForWrite();
|
||||
m_RigidBodies[event.Entity]->activate();
|
||||
m_RigidBodies[event.Entity]->setLinearVelocity(GLMVEC3_TO_HKVECTOR4(event.Velocity));
|
||||
auto transformComponent = m_World->GetComponent<Components::Transform>(event.Entity);
|
||||
transformComponent->Velocity = event.Velocity;
|
||||
@@ -795,7 +813,6 @@ void Systems::PhysicsSystem::OnComponentRemoved(EntityID entity, std::string typ
|
||||
m_RigidBodies.erase(entity);
|
||||
m_PhysicsWorld->unmarkForWrite();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -139,6 +139,9 @@ bool Systems::TankSteeringSystem::OnCollision(const Events::Collision &e)
|
||||
return false;
|
||||
}
|
||||
|
||||
if(m_World->GetComponent<Components::Template>(shellEntity))
|
||||
return false;
|
||||
|
||||
auto physicsComponents = m_World->GetComponentsOfType<Components::Physics>();
|
||||
auto shellTransform = m_World->GetComponent<Components::Transform>(shellEntity);
|
||||
//auto otherTransform = m_World->GetComponent<Components::Transform>(otherEntity);
|
||||
@@ -205,8 +208,6 @@ bool Systems::TankSteeringSystem::OnCollision(const Events::Collision &e)
|
||||
EventBroker->Publish(d);
|
||||
}
|
||||
|
||||
|
||||
|
||||
m_World->RemoveEntity(shellEntity);
|
||||
}
|
||||
}
|
||||
@@ -329,7 +330,7 @@ EntityID Systems::TankSteeringSystem::CreateTank(int playerID)
|
||||
//transform->Orientation = glm::angleAxis(0.f, glm::vec3(0, 1, 0));
|
||||
auto physics = m_World->AddComponent<Components::Physics>(tank);
|
||||
physics->Mass = 63000 - 16000;
|
||||
physics->Static = false;
|
||||
physics->MotionType = Components::Physics::MotionTypeEnum::Dynamic;
|
||||
auto vehicle = m_World->AddComponent<Components::Vehicle>(tank);
|
||||
vehicle->MaxTorque = 8000.f;
|
||||
vehicle->MaxSteeringAngle = 90.f;
|
||||
@@ -397,7 +398,7 @@ EntityID Systems::TankSteeringSystem::CreateTank(int playerID)
|
||||
m_World->AddComponent<Components::Template>(shot);
|
||||
auto physics = m_World->AddComponent<Components::Physics>(shot);
|
||||
physics->Mass = 25.f;
|
||||
physics->Static = false;
|
||||
physics->MotionType = Components::Physics::MotionTypeEnum::Dynamic;
|
||||
physics->CollisionEvent = true;
|
||||
auto modelComponent = m_World->AddComponent<Components::Model>(shot);
|
||||
modelComponent->ModelFile = "Models/Placeholders/rocket/Rocket.obj";
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
#include "PrecompiledHeader.h"
|
||||
#include "WallSystem.h"
|
||||
#include "World.h"
|
||||
|
||||
void Systems::WallSystem::RegisterComponents( ComponentFactory* cf )
|
||||
{
|
||||
cf->Register<Components::Wall>([]() { return new Components::Wall(); });
|
||||
}
|
||||
|
||||
void Systems::WallSystem::Initialize()
|
||||
{
|
||||
EVENT_SUBSCRIBE_MEMBER(m_eDamage, &Systems::WallSystem::Damage);
|
||||
}
|
||||
|
||||
bool Systems::WallSystem::Damage( const Events::Damage &event )
|
||||
{
|
||||
auto wallComponent = m_World->GetComponent<Components::Wall>(event.Entity);
|
||||
if(!wallComponent)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
LOG_INFO("WallSystem::Damage");
|
||||
auto wallhealthcomponent = m_World->GetComponent<Components::Health>(event.Entity);
|
||||
if(wallhealthcomponent->Amount > 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
LOG_INFO("You are dead");
|
||||
auto transformComponent = m_World->GetComponent<Components::Transform>(event.Entity);
|
||||
|
||||
for(auto d : wallComponent->Walldebris)
|
||||
{
|
||||
auto debris = m_World->CloneEntity(d);
|
||||
|
||||
auto transform = m_World->GetComponent<Components::Transform>(debris);
|
||||
transform->Position += transformComponent->Position;
|
||||
|
||||
// DO STUFF! :D
|
||||
float distance = glm::distance(transform->Position, transformComponent->Position);
|
||||
float radius = 5.f;
|
||||
float strength = (1.f - pow(distance / radius, 2)) * 500.f;
|
||||
glm::vec3 direction = glm::normalize(transformComponent->Position - transform->Position);
|
||||
|
||||
Events::ApplyPointImpulse e;
|
||||
e.Entity = debris;
|
||||
e.Impulse = direction * strength;
|
||||
e.Position = transformComponent->Position;
|
||||
EventBroker->Publish(e);
|
||||
|
||||
}
|
||||
|
||||
m_World->RemoveEntity(event.Entity);
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
#ifndef WallSystem_h__
|
||||
#define WallSystem_h__
|
||||
|
||||
|
||||
#include "System.h"
|
||||
#include "Events/OnDead.h"
|
||||
#include "Events/Damage.h"
|
||||
#include "Events/ApplyPointImpulse.h"
|
||||
#include "Components/Model.h"
|
||||
#include "Components/Wall.h"
|
||||
#include "Components/Transform.h"
|
||||
#include "Components/Physics.h"
|
||||
#include "Components/MeshShape.h"
|
||||
#include "Components/Tankshell.h"
|
||||
#include "Components/Health.h"
|
||||
|
||||
|
||||
|
||||
namespace Systems
|
||||
{
|
||||
class WallSystem : public System
|
||||
{
|
||||
public:
|
||||
|
||||
WallSystem(World* world, std::shared_ptr<::EventBroker> eventBroker, std::shared_ptr<::ResourceManager> resourceManager)
|
||||
: System(world, eventBroker, resourceManager) { }
|
||||
|
||||
|
||||
void Initialize() override;
|
||||
void RegisterComponents(ComponentFactory* cf) override;
|
||||
|
||||
|
||||
|
||||
EventRelay<WallSystem, Events::Damage> m_eDamage;
|
||||
bool Damage(const Events::Damage &event);
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
#endif // WallSystem_h__
|
||||
@@ -124,6 +124,7 @@
|
||||
<ClCompile Include="..\..\src\Systems\TimerSystem.cpp" />
|
||||
<ClCompile Include="..\..\src\Systems\TransformSystem.cpp" />
|
||||
<ClCompile Include="..\..\src\Systems\TriggerSystem.cpp" />
|
||||
<ClCompile Include="..\..\src\Systems\WallSystem.cpp" />
|
||||
<ClCompile Include="..\..\src\Systems\WheelPairSystem.cpp" />
|
||||
<ClCompile Include="..\..\src\Texture.cpp" />
|
||||
<ClCompile Include="..\..\src\World.cpp" />
|
||||
@@ -173,6 +174,7 @@
|
||||
<ClInclude Include="..\..\src\Components\Vehicle.h" />
|
||||
<ClInclude Include="..\..\src\Components\SpawnPoint.h" />
|
||||
<ClInclude Include="..\..\src\Components\Viewport.h" />
|
||||
<ClInclude Include="..\..\src\Components\Wall.h" />
|
||||
<ClInclude Include="..\..\src\Components\Wheel.h" />
|
||||
<ClInclude Include="..\..\src\Components\WheelPair.h" />
|
||||
<ClInclude Include="..\..\src\CubemapTexture.h" />
|
||||
@@ -200,6 +202,7 @@
|
||||
<ClInclude Include="..\..\src\Events\MouseMove.h" />
|
||||
<ClInclude Include="..\..\src\Events\MousePress.h" />
|
||||
<ClInclude Include="..\..\src\Events\MouseRelease.h" />
|
||||
<ClInclude Include="..\..\src\Events\OnDead.h" />
|
||||
<ClInclude Include="..\..\src\Events\Move.h" />
|
||||
<ClInclude Include="..\..\src\Events\PlayBGM.h" />
|
||||
<ClInclude Include="..\..\src\Events\PlaySFX.h" />
|
||||
@@ -249,6 +252,7 @@
|
||||
<ClInclude Include="..\..\src\Systems\TimerSystem.h" />
|
||||
<ClInclude Include="..\..\src\Systems\TransformSystem.h" />
|
||||
<ClInclude Include="..\..\src\Systems\TriggerSystem.h" />
|
||||
<ClInclude Include="..\..\src\Systems\WallSystem.h" />
|
||||
<ClInclude Include="..\..\src\Systems\WheelPairSystem.h" />
|
||||
<ClInclude Include="..\..\src\Texture.h" />
|
||||
<ClInclude Include="..\..\src\Util\GLError.h" />
|
||||
|
||||
@@ -78,6 +78,10 @@
|
||||
<ClCompile Include="..\..\src\Systems\FollowSystem.cpp">
|
||||
<Filter>Game\Systems</Filter>
|
||||
</ClCompile>
|
||||
|
||||
<ClCompile Include="..\..\src\Systems\WallSystem.cpp">
|
||||
<Filter>Gameplay\Systems</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\Systems\GarageSystem.cpp">
|
||||
<Filter>Game\Systems</Filter>
|
||||
</ClCompile>
|
||||
@@ -521,6 +525,10 @@
|
||||
<ClInclude Include="..\..\src\Components\BlendMap.h">
|
||||
<Filter>Rendering\Components</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\Systems\WallSystem.h">
|
||||
<Filter>Gameplay\Systems</Filter>
|
||||
</ClInclude>
|
||||
|
||||
<ClInclude Include="..\..\src\Events\LeaveTrigger.h">
|
||||
<Filter>Physics\Events</Filter>
|
||||
</ClInclude>
|
||||
@@ -554,9 +562,14 @@
|
||||
<ClInclude Include="..\..\src\GUI\VehicleSelection.h">
|
||||
<Filter>GUI</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\Events\OnDead.h">
|
||||
<Filter>Gameplay\Events</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\Events\SpawnVehicle.h">
|
||||
<Filter>Game\Events</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\Components\Wall.h">
|
||||
<Filter>Game\Components</Filter>
|
||||
<ClInclude Include="..\..\src\Components\SpawnPoint.h">
|
||||
<Filter>Game\Components</Filter>
|
||||
</ClInclude>
|
||||
|
||||
Reference in New Issue
Block a user