Walls are now destroyable!
This commit is contained in:
@@ -8,13 +8,19 @@ namespace Components
|
|||||||
|
|
||||||
struct Physics : Component
|
struct Physics : Component
|
||||||
{
|
{
|
||||||
|
enum class MotionTypeEnum
|
||||||
|
{
|
||||||
|
Dynamic,
|
||||||
|
Fixed,
|
||||||
|
Keyframed
|
||||||
|
};
|
||||||
Physics()
|
Physics()
|
||||||
: Mass(1.f), Static(false), Phantom(false), CalculateCenterOfMass(true), CenterOfMass(glm::vec3(0)), InitialLinearVelocity(glm::vec3(0)), InitialAngularVelocity(glm::vec3(0)),
|
: Mass(1.f), 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),
|
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){}
|
CollisionLayer(0), CollisionSystemGroup(0), CollisionSubSystemId(0), CollisionSubSystemDontCollideWith(0), CollisionEvent(false){}
|
||||||
|
|
||||||
float Mass;
|
float Mass;
|
||||||
bool Static;
|
MotionTypeEnum MotionType;
|
||||||
bool Phantom;
|
bool Phantom;
|
||||||
|
|
||||||
bool CalculateCenterOfMass;
|
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__
|
||||||
+414
-54
@@ -78,7 +78,7 @@ void GameWorld::Initialize()
|
|||||||
model->ModelFile = "Models/TerrainFiveIstles/Roads/BaseRoad.obj";
|
model->ModelFile = "Models/TerrainFiveIstles/Roads/BaseRoad.obj";
|
||||||
auto physics = AddComponent<Components::Physics>(road_base);
|
auto physics = AddComponent<Components::Physics>(road_base);
|
||||||
physics->Mass = 10;
|
physics->Mass = 10;
|
||||||
physics->Static = true;
|
physics->MotionType = Components::Physics::MotionTypeEnum::Fixed;
|
||||||
physics->CollisionLayer = 1;
|
physics->CollisionLayer = 1;
|
||||||
|
|
||||||
auto groundshape = CreateEntity(road_base);
|
auto groundshape = CreateEntity(road_base);
|
||||||
@@ -99,7 +99,7 @@ void GameWorld::Initialize()
|
|||||||
model->ModelFile = "Models/TerrainFiveIstles/Roads/MiddleRoad.obj";
|
model->ModelFile = "Models/TerrainFiveIstles/Roads/MiddleRoad.obj";
|
||||||
auto physics = AddComponent<Components::Physics>(road_middle);
|
auto physics = AddComponent<Components::Physics>(road_middle);
|
||||||
physics->Mass = 10;
|
physics->Mass = 10;
|
||||||
physics->Static = true;
|
physics->MotionType = Components::Physics::MotionTypeEnum::Fixed;
|
||||||
physics->CollisionLayer = 1;
|
physics->CollisionLayer = 1;
|
||||||
|
|
||||||
auto groundshape = CreateEntity(road_middle);
|
auto groundshape = CreateEntity(road_middle);
|
||||||
@@ -120,7 +120,7 @@ void GameWorld::Initialize()
|
|||||||
model->ModelFile = "Models/TerrainFiveIstles/Roads/SmallRoad.obj";
|
model->ModelFile = "Models/TerrainFiveIstles/Roads/SmallRoad.obj";
|
||||||
auto physics = AddComponent<Components::Physics>(road_small);
|
auto physics = AddComponent<Components::Physics>(road_small);
|
||||||
physics->Mass = 10;
|
physics->Mass = 10;
|
||||||
physics->Static = true;
|
physics->MotionType = Components::Physics::MotionTypeEnum::Fixed;
|
||||||
physics->CollisionLayer = 1;
|
physics->CollisionLayer = 1;
|
||||||
|
|
||||||
auto groundshape = CreateEntity(road_small);
|
auto groundshape = CreateEntity(road_small);
|
||||||
@@ -150,7 +150,7 @@ void GameWorld::Initialize()
|
|||||||
|
|
||||||
auto physics = AddComponent<Components::Physics>(water);
|
auto physics = AddComponent<Components::Physics>(water);
|
||||||
physics->Mass = 10;
|
physics->Mass = 10;
|
||||||
physics->Static = true;
|
physics->MotionType = Components::Physics::MotionTypeEnum::Fixed;
|
||||||
physics->CollisionLayer = 1;
|
physics->CollisionLayer = 1;
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -184,7 +184,7 @@ void GameWorld::Initialize()
|
|||||||
|
|
||||||
auto physics = AddComponent<Components::Physics>(ground_middle);
|
auto physics = AddComponent<Components::Physics>(ground_middle);
|
||||||
physics->Mass = 10;
|
physics->Mass = 10;
|
||||||
physics->Static = true;
|
physics->MotionType = Components::Physics::MotionTypeEnum::Fixed;
|
||||||
physics->CollisionLayer = 1;
|
physics->CollisionLayer = 1;
|
||||||
|
|
||||||
auto groundshape = CreateEntity(ground_middle);
|
auto groundshape = CreateEntity(ground_middle);
|
||||||
@@ -215,7 +215,7 @@ void GameWorld::Initialize()
|
|||||||
|
|
||||||
auto physics = AddComponent<Components::Physics>(ground_small);
|
auto physics = AddComponent<Components::Physics>(ground_small);
|
||||||
physics->Mass = 10;
|
physics->Mass = 10;
|
||||||
physics->Static = true;
|
physics->MotionType = Components::Physics::MotionTypeEnum::Fixed;
|
||||||
physics->CollisionLayer = 1;
|
physics->CollisionLayer = 1;
|
||||||
|
|
||||||
auto groundshape = CreateEntity(ground_small);
|
auto groundshape = CreateEntity(ground_small);
|
||||||
@@ -246,7 +246,7 @@ void GameWorld::Initialize()
|
|||||||
|
|
||||||
auto physics = AddComponent<Components::Physics>(ground_small_mirrored);
|
auto physics = AddComponent<Components::Physics>(ground_small_mirrored);
|
||||||
physics->Mass = 10;
|
physics->Mass = 10;
|
||||||
physics->Static = true;
|
physics->MotionType = Components::Physics::MotionTypeEnum::Fixed;
|
||||||
physics->CollisionLayer = 1;
|
physics->CollisionLayer = 1;
|
||||||
|
|
||||||
auto groundshape = CreateEntity(ground_small_mirrored);
|
auto groundshape = CreateEntity(ground_small_mirrored);
|
||||||
@@ -277,7 +277,7 @@ void GameWorld::Initialize()
|
|||||||
|
|
||||||
auto physics = AddComponent<Components::Physics>(ground_base);
|
auto physics = AddComponent<Components::Physics>(ground_base);
|
||||||
physics->Mass = 10;
|
physics->Mass = 10;
|
||||||
physics->Static = true;
|
physics->MotionType = Components::Physics::MotionTypeEnum::Fixed;
|
||||||
physics->CollisionLayer = 1;
|
physics->CollisionLayer = 1;
|
||||||
|
|
||||||
auto groundshape = CreateEntity(ground_base);
|
auto groundshape = CreateEntity(ground_base);
|
||||||
@@ -308,7 +308,7 @@ void GameWorld::Initialize()
|
|||||||
|
|
||||||
auto physics = AddComponent<Components::Physics>(ground_base_mirrored);
|
auto physics = AddComponent<Components::Physics>(ground_base_mirrored);
|
||||||
physics->Mass = 10;
|
physics->Mass = 10;
|
||||||
physics->Static = true;
|
physics->MotionType = Components::Physics::MotionTypeEnum::Fixed;
|
||||||
physics->CollisionLayer = 1;
|
physics->CollisionLayer = 1;
|
||||||
|
|
||||||
auto groundshape = CreateEntity(ground_base_mirrored);
|
auto groundshape = CreateEntity(ground_base_mirrored);
|
||||||
@@ -328,7 +328,8 @@ void GameWorld::Initialize()
|
|||||||
|
|
||||||
auto physics = AddComponent<Components::Physics>(tree);
|
auto physics = AddComponent<Components::Physics>(tree);
|
||||||
physics->Mass = 100.f;
|
physics->Mass = 100.f;
|
||||||
physics->Static = false;
|
physics->MotionType = Components::Physics::MotionTypeEnum::Dynamic;
|
||||||
|
physics->CollisionEvent = false;
|
||||||
//physics->LinearDamping = 3.f;
|
//physics->LinearDamping = 3.f;
|
||||||
physics->CalculateCenterOfMass = true;
|
physics->CalculateCenterOfMass = true;
|
||||||
|
|
||||||
@@ -360,6 +361,7 @@ void GameWorld::Initialize()
|
|||||||
CommitEntity(shape);
|
CommitEntity(shape);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*{
|
/*{
|
||||||
auto shape = CreateEntity(tree);
|
auto shape = CreateEntity(tree);
|
||||||
auto transform = AddComponent<Components::Transform>(shape);
|
auto transform = AddComponent<Components::Transform>(shape);
|
||||||
@@ -385,6 +387,362 @@ void GameWorld::Initialize()
|
|||||||
CommitEntity(tree);
|
CommitEntity(tree);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma region Wall_Debris_Template
|
||||||
|
|
||||||
|
{
|
||||||
|
auto debri = CreateEntity();
|
||||||
|
AddComponent<Components::Template>(debri);
|
||||||
|
auto transform = AddComponent<Components::Transform>(debri);
|
||||||
|
transform->Position = glm::vec3(3.43f, 2.287f, 0.f);
|
||||||
|
auto model = AddComponent<Components::Model>(debri);
|
||||||
|
model->ModelFile = "Models/Wall/WallDestroyed/WallDebris1.obj";
|
||||||
|
auto physics = AddComponent<Components::Physics>(debri);
|
||||||
|
physics->MotionType = Components::Physics::MotionTypeEnum::Dynamic;
|
||||||
|
physics->Mass = 200.f;
|
||||||
|
physics->Restitution = .04f;
|
||||||
|
physics->Friction = 0.9f;
|
||||||
|
|
||||||
|
auto shape = CreateEntity(debri);
|
||||||
|
auto shapetransform = AddComponent<Components::Transform>(shape);
|
||||||
|
auto shapemesh = AddComponent<Components::MeshShape>(shape);
|
||||||
|
shapemesh->ResourceName = "Models/Wall/WallDestroyed/WallDebris1.obj";
|
||||||
|
|
||||||
|
m_WallDebrisTemplates.push_back(debri);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
auto debri = CreateEntity();
|
||||||
|
AddComponent<Components::Template>(debri);
|
||||||
|
auto transform = AddComponent<Components::Transform>(debri);
|
||||||
|
transform->Position = glm::vec3(-3.744f, 1.508f, 0.f);
|
||||||
|
auto model = AddComponent<Components::Model>(debri);
|
||||||
|
model->ModelFile = "Models/Wall/WallDestroyed/WallDebris2.obj";
|
||||||
|
auto physics = AddComponent<Components::Physics>(debri);
|
||||||
|
physics->MotionType = Components::Physics::MotionTypeEnum::Dynamic;
|
||||||
|
physics->Mass = 200.f;
|
||||||
|
physics->Restitution = .04f;
|
||||||
|
physics->Friction = 0.9f;
|
||||||
|
|
||||||
|
auto shape = CreateEntity(debri);
|
||||||
|
auto shapetransform = AddComponent<Components::Transform>(shape);
|
||||||
|
auto shapemesh = AddComponent<Components::MeshShape>(shape);
|
||||||
|
shapemesh->ResourceName = "Models/Wall/WallDestroyed/WallDebris2.obj";
|
||||||
|
|
||||||
|
m_WallDebrisTemplates.push_back(debri);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
auto debri = CreateEntity();
|
||||||
|
AddComponent<Components::Template>(debri);
|
||||||
|
auto transform = AddComponent<Components::Transform>(debri);
|
||||||
|
transform->Position = glm::vec3(-3.592f, 4.664f, 0.f);
|
||||||
|
auto model = AddComponent<Components::Model>(debri);
|
||||||
|
model->ModelFile = "Models/Wall/WallDestroyed/WallDebris2.obj";
|
||||||
|
auto physics = AddComponent<Components::Physics>(debri);
|
||||||
|
physics->MotionType = Components::Physics::MotionTypeEnum::Dynamic;
|
||||||
|
physics->Mass = 200.f;
|
||||||
|
physics->Restitution = .04f;
|
||||||
|
physics->Friction = 0.9f;
|
||||||
|
|
||||||
|
auto shape = CreateEntity(debri);
|
||||||
|
auto shapetransform = AddComponent<Components::Transform>(shape);
|
||||||
|
auto shapemesh = AddComponent<Components::MeshShape>(shape);
|
||||||
|
shapemesh->ResourceName = "Models/Wall/WallDestroyed/WallDebris2.obj";
|
||||||
|
|
||||||
|
m_WallDebrisTemplates.push_back(debri);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
auto debri = CreateEntity();
|
||||||
|
AddComponent<Components::Template>(debri);
|
||||||
|
auto transform = AddComponent<Components::Transform>(debri);
|
||||||
|
transform->Position = glm::vec3(-2.535f, 2.879f, 0.f);
|
||||||
|
auto model = AddComponent<Components::Model>(debri);
|
||||||
|
model->ModelFile = "Models/Wall/WallDestroyed/WallDebris3.obj";
|
||||||
|
auto physics = AddComponent<Components::Physics>(debri);
|
||||||
|
physics->MotionType = Components::Physics::MotionTypeEnum::Dynamic;
|
||||||
|
physics->Mass = 200.f;
|
||||||
|
physics->Restitution = .04f;
|
||||||
|
physics->Friction = 0.9f;
|
||||||
|
|
||||||
|
auto shape = CreateEntity(debri);
|
||||||
|
auto shapetransform = AddComponent<Components::Transform>(shape);
|
||||||
|
auto shapemesh = AddComponent<Components::MeshShape>(shape);
|
||||||
|
shapemesh->ResourceName = "Models/Wall/WallDestroyed/WallDebris3.obj";
|
||||||
|
|
||||||
|
m_WallDebrisTemplates.push_back(debri);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
auto debri = CreateEntity();
|
||||||
|
AddComponent<Components::Template>(debri);
|
||||||
|
auto transform = AddComponent<Components::Transform>(debri);
|
||||||
|
transform->Position = glm::vec3(0.333f, 3.618f, 0.f);
|
||||||
|
auto model = AddComponent<Components::Model>(debri);
|
||||||
|
model->ModelFile = "Models/Wall/WallDestroyed/WallDebris4.obj";
|
||||||
|
auto physics = AddComponent<Components::Physics>(debri);
|
||||||
|
physics->MotionType = Components::Physics::MotionTypeEnum::Dynamic;
|
||||||
|
physics->Mass = 200.f;
|
||||||
|
physics->Restitution = .04f;
|
||||||
|
physics->Friction = 0.9f;
|
||||||
|
|
||||||
|
auto shape = CreateEntity(debri);
|
||||||
|
auto shapetransform = AddComponent<Components::Transform>(shape);
|
||||||
|
auto shapemesh = AddComponent<Components::MeshShape>(shape);
|
||||||
|
shapemesh->ResourceName = "Models/Wall/WallDestroyed/WallDebris4.obj";
|
||||||
|
|
||||||
|
m_WallDebrisTemplates.push_back(debri);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
auto debri = CreateEntity();
|
||||||
|
AddComponent<Components::Template>(debri);
|
||||||
|
auto transform = AddComponent<Components::Transform>(debri);
|
||||||
|
transform->Position = glm::vec3(2.586f, 4.333f, 0.f);
|
||||||
|
auto model = AddComponent<Components::Model>(debri);
|
||||||
|
model->ModelFile = "Models/Wall/WallDestroyed/WallDebris5.obj";
|
||||||
|
auto physics = AddComponent<Components::Physics>(debri);
|
||||||
|
physics->MotionType = Components::Physics::MotionTypeEnum::Dynamic;
|
||||||
|
physics->Mass = 200.f;
|
||||||
|
physics->Restitution = .04f;
|
||||||
|
physics->Friction = 0.9f;
|
||||||
|
|
||||||
|
auto shape = CreateEntity(debri);
|
||||||
|
auto shapetransform = AddComponent<Components::Transform>(shape);
|
||||||
|
auto shapemesh = AddComponent<Components::MeshShape>(shape);
|
||||||
|
shapemesh->ResourceName = "Models/Wall/WallDestroyed/WallDebris5.obj";
|
||||||
|
|
||||||
|
m_WallDebrisTemplates.push_back(debri);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
auto debri = CreateEntity();
|
||||||
|
AddComponent<Components::Template>(debri);
|
||||||
|
auto transform = AddComponent<Components::Transform>(debri);
|
||||||
|
transform->Position = glm::vec3(0.537f, 1.344f, 0.f);
|
||||||
|
auto model = AddComponent<Components::Model>(debri);
|
||||||
|
model->ModelFile = "Models/Wall/WallDestroyed/WallDebris6.obj";
|
||||||
|
auto physics = AddComponent<Components::Physics>(debri);
|
||||||
|
physics->MotionType = Components::Physics::MotionTypeEnum::Dynamic;
|
||||||
|
physics->Mass = 200.f;
|
||||||
|
physics->Restitution = .04f;
|
||||||
|
physics->Friction = 0.9f;
|
||||||
|
|
||||||
|
auto shape = CreateEntity(debri);
|
||||||
|
auto shapetransform = AddComponent<Components::Transform>(shape);
|
||||||
|
auto shapemesh = AddComponent<Components::MeshShape>(shape);
|
||||||
|
shapemesh->ResourceName = "Models/Wall/WallDestroyed/WallDebris6.obj";
|
||||||
|
|
||||||
|
m_WallDebrisTemplates.push_back(debri);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
auto debri = CreateEntity();
|
||||||
|
AddComponent<Components::Template>(debri);
|
||||||
|
auto transform = AddComponent<Components::Transform>(debri);
|
||||||
|
transform->Position = glm::vec3(0.f, 0.f, 0.f);
|
||||||
|
auto model = AddComponent<Components::Model>(debri);
|
||||||
|
model->ModelFile = "Models/Wall/WallDestroyed/WallDestroyed.obj";
|
||||||
|
auto physics = AddComponent<Components::Physics>(debri);
|
||||||
|
physics->MotionType = Components::Physics::MotionTypeEnum::Keyframed;
|
||||||
|
physics->Mass = 200.f;
|
||||||
|
physics->Restitution = .004f;
|
||||||
|
physics->Friction = 0.9f;
|
||||||
|
|
||||||
|
auto shape = CreateEntity(debri);
|
||||||
|
auto shapetransform = AddComponent<Components::Transform>(shape);
|
||||||
|
auto shapemesh = AddComponent<Components::MeshShape>(shape);
|
||||||
|
shapemesh->ResourceName = "Models/Wall/WallDestroyed/WallDestroyed.obj";
|
||||||
|
|
||||||
|
m_WallDebrisTemplates.push_back(debri);
|
||||||
|
}
|
||||||
|
#pragma endregion Region for wall debris
|
||||||
|
|
||||||
|
#pragma region Walls
|
||||||
|
|
||||||
|
#pragma region Wall1
|
||||||
|
{
|
||||||
|
auto wall = CreateEntity();
|
||||||
|
auto transform = AddComponent<Components::Transform>(wall);
|
||||||
|
transform->Position = glm::vec3(0, -16, 0);
|
||||||
|
|
||||||
|
auto physics = AddComponent<Components::Physics>(wall);
|
||||||
|
physics->Mass = 100.f;
|
||||||
|
physics->MotionType = Components::Physics::MotionTypeEnum::Fixed;
|
||||||
|
|
||||||
|
auto walldebris = AddComponent<Components::Wall>(wall);
|
||||||
|
walldebris->Walldebris = m_WallDebrisTemplates;
|
||||||
|
|
||||||
|
auto model = AddComponent<Components::Model>(wall);
|
||||||
|
model->ModelFile = "Models/Wall/WallWhole/Wall.obj";
|
||||||
|
|
||||||
|
auto health = AddComponent<Components::Health>(wall);
|
||||||
|
health->Amount = 50.f;
|
||||||
|
|
||||||
|
auto shape = CreateEntity(wall);
|
||||||
|
auto shapetransform = AddComponent<Components::Transform>(shape);
|
||||||
|
auto shapemesh = AddComponent<Components::MeshShape>(shape);
|
||||||
|
shapemesh->ResourceName = "Models/Wall/WallCollision/Collision.obj";
|
||||||
|
|
||||||
|
CommitEntity(shape);
|
||||||
|
CommitEntity(wall);
|
||||||
|
}
|
||||||
|
#pragma endregion Region for wall1
|
||||||
|
|
||||||
|
#pragma endregion Region for all walls
|
||||||
|
|
||||||
|
{
|
||||||
|
auto wall = CreateEntity();
|
||||||
|
auto transform = AddComponent<Components::Transform>(wall);
|
||||||
|
transform->Position = glm::vec3(20, 10, 30);
|
||||||
|
|
||||||
|
auto physics = AddComponent<Components::Physics>(wall);
|
||||||
|
physics->Mass = 100.f;
|
||||||
|
physics->MotionType = Components::Physics::MotionTypeEnum::Fixed;
|
||||||
|
|
||||||
|
auto model = AddComponent<Components::Model>(wall);
|
||||||
|
model->ModelFile = "Models/Wall/WallDestroyed/WallDestroyed.obj";
|
||||||
|
|
||||||
|
auto shape = CreateEntity(wall);
|
||||||
|
auto shapetransform = AddComponent<Components::Transform>(shape);
|
||||||
|
auto shapemesh = AddComponent<Components::MeshShape>(shape);
|
||||||
|
shapemesh->ResourceName = "Models/Wall/WallDestroyed/WallDestroyed.obj";
|
||||||
|
|
||||||
|
CommitEntity(shape);
|
||||||
|
CommitEntity(wall);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
auto wall_trash = CreateEntity();
|
||||||
|
auto transform = AddComponent<Components::Transform>(wall_trash);
|
||||||
|
transform->Position = glm::vec3(20, 12, 30);
|
||||||
|
|
||||||
|
auto physics = AddComponent<Components::Physics>(wall_trash);
|
||||||
|
physics->Mass = 100.f;
|
||||||
|
physics->MotionType = Components::Physics::MotionTypeEnum::Fixed;
|
||||||
|
|
||||||
|
auto model = AddComponent<Components::Model>(wall_trash);
|
||||||
|
model->ModelFile = "Models/Wall/WallDestroyed/WallDebris1.obj";
|
||||||
|
|
||||||
|
auto shape = CreateEntity(wall_trash);
|
||||||
|
auto shapetransform = AddComponent<Components::Transform>(shape);
|
||||||
|
auto shapemesh = AddComponent<Components::MeshShape>(shape);
|
||||||
|
shapemesh->ResourceName = "Models/Wall/WallDestroyed/WallDebris1.obj";
|
||||||
|
|
||||||
|
CommitEntity(shape);
|
||||||
|
CommitEntity(wall_trash);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
auto wall_trash = CreateEntity();
|
||||||
|
auto transform = AddComponent<Components::Transform>(wall_trash);
|
||||||
|
transform->Position = glm::vec3(20, 10, 45);
|
||||||
|
|
||||||
|
auto physics = AddComponent<Components::Physics>(wall_trash);
|
||||||
|
physics->Mass = 100.f;
|
||||||
|
physics->MotionType = Components::Physics::MotionTypeEnum::Keyframed;
|
||||||
|
|
||||||
|
auto model = AddComponent<Components::Model>(wall_trash);
|
||||||
|
model->ModelFile = "Models/Wall/WallDestroyed/WallDebris2.obj";
|
||||||
|
|
||||||
|
auto shape = CreateEntity(wall_trash);
|
||||||
|
auto shapetransform = AddComponent<Components::Transform>(shape);
|
||||||
|
auto shapemesh = AddComponent<Components::MeshShape>(shape);
|
||||||
|
shapemesh->ResourceName = "Models/Wall/WallDestroyed/WallDebris2.obj";
|
||||||
|
|
||||||
|
CommitEntity(shape);
|
||||||
|
CommitEntity(wall_trash);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
auto wall_trash = CreateEntity();
|
||||||
|
auto transform = AddComponent<Components::Transform>(wall_trash);
|
||||||
|
transform->Position = glm::vec3(23, 10, 45);
|
||||||
|
|
||||||
|
auto physics = AddComponent<Components::Physics>(wall_trash);
|
||||||
|
physics->Mass = 100.f;
|
||||||
|
physics->MotionType = Components::Physics::MotionTypeEnum::Keyframed;
|
||||||
|
|
||||||
|
auto model = AddComponent<Components::Model>(wall_trash);
|
||||||
|
model->ModelFile = "Models/Wall/WallDestroyed/WallDebris3.obj";
|
||||||
|
|
||||||
|
auto shape = CreateEntity(wall_trash);
|
||||||
|
auto shapetransform = AddComponent<Components::Transform>(shape);
|
||||||
|
auto shapemesh = AddComponent<Components::MeshShape>(shape);
|
||||||
|
shapemesh->ResourceName = "Models/Wall/WallDestroyed/WallDebris3.obj";
|
||||||
|
|
||||||
|
CommitEntity(shape);
|
||||||
|
CommitEntity(wall_trash);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
auto wall_trash = CreateEntity();
|
||||||
|
auto transform = AddComponent<Components::Transform>(wall_trash);
|
||||||
|
transform->Position = glm::vec3(20, 12, 30);
|
||||||
|
|
||||||
|
auto physics = AddComponent<Components::Physics>(wall_trash);
|
||||||
|
physics->Mass = 100.f;
|
||||||
|
physics->MotionType = Components::Physics::MotionTypeEnum::Fixed;
|
||||||
|
|
||||||
|
auto model = AddComponent<Components::Model>(wall_trash);
|
||||||
|
model->ModelFile = "Models/Wall/WallDestroyed/WallDebris4.obj";
|
||||||
|
|
||||||
|
auto shape = CreateEntity(wall_trash);
|
||||||
|
auto shapetransform = AddComponent<Components::Transform>(shape);
|
||||||
|
auto shapemesh = AddComponent<Components::MeshShape>(shape);
|
||||||
|
shapemesh->ResourceName = "Models/Wall/WallDestroyed/WallDebris4.obj";
|
||||||
|
|
||||||
|
CommitEntity(shape);
|
||||||
|
CommitEntity(wall_trash);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
auto wall_trash = CreateEntity();
|
||||||
|
auto transform = AddComponent<Components::Transform>(wall_trash);
|
||||||
|
transform->Position = glm::vec3(29, 10, 45);
|
||||||
|
|
||||||
|
auto physics = AddComponent<Components::Physics>(wall_trash);
|
||||||
|
physics->Mass = 100.f;
|
||||||
|
physics->MotionType = Components::Physics::MotionTypeEnum::Fixed;
|
||||||
|
|
||||||
|
auto model = AddComponent<Components::Model>(wall_trash);
|
||||||
|
model->ModelFile = "Models/Wall/WallDestroyed/WallDebris5.obj";
|
||||||
|
|
||||||
|
auto shape = CreateEntity(wall_trash);
|
||||||
|
auto shapetransform = AddComponent<Components::Transform>(shape);
|
||||||
|
auto shapemesh = AddComponent<Components::MeshShape>(shape);
|
||||||
|
shapemesh->ResourceName = "Models/Wall/WallDestroyed/WallDebris5.obj";
|
||||||
|
|
||||||
|
CommitEntity(shape);
|
||||||
|
CommitEntity(wall_trash);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
auto wall_trash = CreateEntity();
|
||||||
|
auto transform = AddComponent<Components::Transform>(wall_trash);
|
||||||
|
transform->Position = glm::vec3(32, 10, 45);
|
||||||
|
|
||||||
|
auto physics = AddComponent<Components::Physics>(wall_trash);
|
||||||
|
physics->Mass = 100.f;
|
||||||
|
physics->MotionType = Components::Physics::MotionTypeEnum::Fixed;
|
||||||
|
|
||||||
|
auto model = AddComponent<Components::Model>(wall_trash);
|
||||||
|
model->ModelFile = "Models/Wall/WallDestroyed/WallDebris6.obj";
|
||||||
|
|
||||||
|
auto shape = CreateEntity(wall_trash);
|
||||||
|
auto shapetransform = AddComponent<Components::Transform>(shape);
|
||||||
|
auto shapemesh = AddComponent<Components::MeshShape>(shape);
|
||||||
|
shapemesh->ResourceName = "Models/Wall/WallDestroyed/WallDebris6.obj";
|
||||||
|
|
||||||
|
CommitEntity(shape);
|
||||||
|
CommitEntity(wall_trash);
|
||||||
|
}
|
||||||
|
|
||||||
EntityID tank1 = CreateTank(1);
|
EntityID tank1 = CreateTank(1);
|
||||||
{
|
{
|
||||||
auto transform = GetComponent<Components::Transform>(tank1);
|
auto transform = GetComponent<Components::Transform>(tank1);
|
||||||
@@ -464,7 +822,7 @@ void GameWorld::Initialize()
|
|||||||
model->ModelFile = "Models/Gate/Lift/Lift.obj";
|
model->ModelFile = "Models/Gate/Lift/Lift.obj";
|
||||||
|
|
||||||
auto physics = AddComponent<Components::Physics>(gateBase);
|
auto physics = AddComponent<Components::Physics>(gateBase);
|
||||||
physics->Static = true;
|
physics->MotionType = Components::Physics::MotionTypeEnum::Fixed;
|
||||||
physics->CollisionLayer = 1; // Terrain-Layer
|
physics->CollisionLayer = 1; // Terrain-Layer
|
||||||
{
|
{
|
||||||
auto leftBaseShape = CreateEntity(gateBase);
|
auto leftBaseShape = CreateEntity(gateBase);
|
||||||
@@ -534,46 +892,6 @@ void GameWorld::RegisterComponents()
|
|||||||
m_ComponentFactory.Register<Components::Flag>([]() { return new Components::Flag(); });
|
m_ComponentFactory.Register<Components::Flag>([]() { return new Components::Flag(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameWorld::RegisterSystems()
|
|
||||||
{
|
|
||||||
m_SystemFactory.Register<Systems::TimerSystem>([this]() { return new Systems::TimerSystem(this, EventBroker, ResourceManager); });
|
|
||||||
m_SystemFactory.Register<Systems::DamageSystem>([this]() { return new Systems::DamageSystem(this, EventBroker, ResourceManager); });
|
|
||||||
m_SystemFactory.Register<Systems::TransformSystem>([this]() { return new Systems::TransformSystem(this, EventBroker, ResourceManager); });
|
|
||||||
//m_SystemFactory.Register<Systems::LevelGenerationSystem>([this]() { return new Systems::LevelGenerationSystem(this); });
|
|
||||||
m_SystemFactory.Register<Systems::InputSystem>([this]() { return new Systems::InputSystem(this, EventBroker, ResourceManager); });
|
|
||||||
m_SystemFactory.Register<Systems::DebugSystem>([this]() { return new Systems::DebugSystem(this, EventBroker, ResourceManager); });
|
|
||||||
//m_SystemFactory.Register<Systems::CollisionSystem>([this]() { return new Systems::CollisionSystem(this); });
|
|
||||||
m_SystemFactory.Register<Systems::ParticleSystem>([this]() { return new Systems::ParticleSystem(this, EventBroker, ResourceManager); });
|
|
||||||
//m_SystemFactory.Register<Systems::PlayerSystem>([this]() { return new Systems::PlayerSystem(this); });
|
|
||||||
m_SystemFactory.Register<Systems::FreeSteeringSystem>([this]() { return new Systems::FreeSteeringSystem(this, EventBroker, ResourceManager); });
|
|
||||||
m_SystemFactory.Register<Systems::TankSteeringSystem>([this]() { return new Systems::TankSteeringSystem(this, EventBroker, ResourceManager); });
|
|
||||||
m_SystemFactory.Register<Systems::WheelPairSystem>([this]() { return new Systems::WheelPairSystem(this, EventBroker, ResourceManager); });
|
|
||||||
m_SystemFactory.Register<Systems::SoundSystem>([this]() { return new Systems::SoundSystem(this, EventBroker, ResourceManager); });
|
|
||||||
m_SystemFactory.Register<Systems::PhysicsSystem>([this]() { return new Systems::PhysicsSystem(this, EventBroker, ResourceManager); });
|
|
||||||
m_SystemFactory.Register<Systems::TriggerSystem>([this]() { return new Systems::TriggerSystem(this, EventBroker, ResourceManager); });
|
|
||||||
m_SystemFactory.Register<Systems::RenderSystem>([this]() { return new Systems::RenderSystem(this, EventBroker, ResourceManager); });
|
|
||||||
}
|
|
||||||
|
|
||||||
void GameWorld::AddSystems()
|
|
||||||
{
|
|
||||||
AddSystem<Systems::TimerSystem>();
|
|
||||||
AddSystem<Systems::DamageSystem>();
|
|
||||||
AddSystem<Systems::TransformSystem>();
|
|
||||||
//AddSystem<Systems::LevelGenerationSystem>();
|
|
||||||
AddSystem<Systems::InputSystem>();
|
|
||||||
AddSystem<Systems::DebugSystem>();
|
|
||||||
//AddSystem<Systems::CollisionSystem>();
|
|
||||||
AddSystem<Systems::ParticleSystem>();
|
|
||||||
//AddSystem<Systems::PlayerSystem>();
|
|
||||||
AddSystem<Systems::FreeSteeringSystem>();
|
|
||||||
AddSystem<Systems::TankSteeringSystem>();
|
|
||||||
AddSystem<Systems::WheelPairSystem>();
|
|
||||||
AddSystem<Systems::SoundSystem>();
|
|
||||||
AddSystem<Systems::PhysicsSystem>();
|
|
||||||
AddSystem<Systems::TriggerSystem>();
|
|
||||||
AddSystem<Systems::RenderSystem>();
|
|
||||||
}
|
|
||||||
|
|
||||||
void GameWorld::BindKey(int keyCode, std::string command, float value)
|
void GameWorld::BindKey(int keyCode, std::string command, float value)
|
||||||
{
|
{
|
||||||
Events::BindKey e;
|
Events::BindKey e;
|
||||||
@@ -618,7 +936,7 @@ EntityID GameWorld::CreateTank(int playerID)
|
|||||||
//transform->Orientation = glm::angleAxis(0.f, glm::vec3(0, 1, 0));
|
//transform->Orientation = glm::angleAxis(0.f, glm::vec3(0, 1, 0));
|
||||||
auto physics = AddComponent<Components::Physics>(tank);
|
auto physics = AddComponent<Components::Physics>(tank);
|
||||||
physics->Mass = 63000 - 16000;
|
physics->Mass = 63000 - 16000;
|
||||||
physics->Static = false;
|
physics->MotionType = Components::Physics::MotionTypeEnum::Dynamic;
|
||||||
auto vehicle = AddComponent<Components::Vehicle>(tank);
|
auto vehicle = AddComponent<Components::Vehicle>(tank);
|
||||||
vehicle->MaxTorque = 36000.f;
|
vehicle->MaxTorque = 36000.f;
|
||||||
vehicle->MaxSteeringAngle = 90.f;
|
vehicle->MaxSteeringAngle = 90.f;
|
||||||
@@ -680,7 +998,7 @@ EntityID GameWorld::CreateTank(int playerID)
|
|||||||
AddComponent<Components::Template>(shot);
|
AddComponent<Components::Template>(shot);
|
||||||
auto physics = AddComponent<Components::Physics>(shot);
|
auto physics = AddComponent<Components::Physics>(shot);
|
||||||
physics->Mass = 25.f;
|
physics->Mass = 25.f;
|
||||||
physics->Static = false;
|
physics->MotionType = Components::Physics::MotionTypeEnum::Dynamic;
|
||||||
physics->CollisionEvent = true;
|
physics->CollisionEvent = true;
|
||||||
auto modelComponent = AddComponent<Components::Model>(shot);
|
auto modelComponent = AddComponent<Components::Model>(shot);
|
||||||
modelComponent->ModelFile = "Models/Placeholders/rocket/Rocket.obj";
|
modelComponent->ModelFile = "Models/Placeholders/rocket/Rocket.obj";
|
||||||
@@ -900,7 +1218,7 @@ EntityID GameWorld::CreateJeep(int playerID)
|
|||||||
transform->Orientation = glm::angleAxis(glm::pi<float>() / 2, glm::vec3(0, 1, 0));
|
transform->Orientation = glm::angleAxis(glm::pi<float>() / 2, glm::vec3(0, 1, 0));
|
||||||
auto physics = AddComponent<Components::Physics>(jeep);
|
auto physics = AddComponent<Components::Physics>(jeep);
|
||||||
physics->Mass = 1800;
|
physics->Mass = 1800;
|
||||||
physics->Static = false;
|
physics->MotionType = Components::Physics::MotionTypeEnum::Dynamic;
|
||||||
auto vehicle = AddComponent<Components::Vehicle>(jeep);
|
auto vehicle = AddComponent<Components::Vehicle>(jeep);
|
||||||
AddComponent<Components::Input>(jeep);
|
AddComponent<Components::Input>(jeep);
|
||||||
|
|
||||||
@@ -1020,3 +1338,45 @@ EntityID GameWorld::CreateJeep(int playerID)
|
|||||||
|
|
||||||
return jeep;
|
return jeep;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GameWorld::RegisterSystems()
|
||||||
|
{
|
||||||
|
m_SystemFactory.Register<Systems::TimerSystem>([this]() { return new Systems::TimerSystem(this, EventBroker, ResourceManager); });
|
||||||
|
m_SystemFactory.Register<Systems::DamageSystem>([this]() { return new Systems::DamageSystem(this, EventBroker, ResourceManager); });
|
||||||
|
m_SystemFactory.Register<Systems::TransformSystem>([this]() { return new Systems::TransformSystem(this, EventBroker, ResourceManager); });
|
||||||
|
//m_SystemFactory.Register<Systems::LevelGenerationSystem>([this]() { return new Systems::LevelGenerationSystem(this); });
|
||||||
|
m_SystemFactory.Register<Systems::InputSystem>([this]() { return new Systems::InputSystem(this, EventBroker, ResourceManager); });
|
||||||
|
m_SystemFactory.Register<Systems::DebugSystem>([this]() { return new Systems::DebugSystem(this, EventBroker, ResourceManager); });
|
||||||
|
//m_SystemFactory.Register<Systems::CollisionSystem>([this]() { return new Systems::CollisionSystem(this); });
|
||||||
|
m_SystemFactory.Register<Systems::ParticleSystem>([this]() { return new Systems::ParticleSystem(this, EventBroker, ResourceManager); });
|
||||||
|
//m_SystemFactory.Register<Systems::PlayerSystem>([this]() { return new Systems::PlayerSystem(this); });
|
||||||
|
m_SystemFactory.Register<Systems::FreeSteeringSystem>([this]() { return new Systems::FreeSteeringSystem(this, EventBroker, ResourceManager); });
|
||||||
|
m_SystemFactory.Register<Systems::TankSteeringSystem>([this]() { return new Systems::TankSteeringSystem(this, EventBroker, ResourceManager); });
|
||||||
|
m_SystemFactory.Register<Systems::WheelPairSystem>([this]() { return new Systems::WheelPairSystem(this, EventBroker, ResourceManager); });
|
||||||
|
m_SystemFactory.Register<Systems::SoundSystem>([this]() { return new Systems::SoundSystem(this, EventBroker, ResourceManager); });
|
||||||
|
m_SystemFactory.Register<Systems::PhysicsSystem>([this]() { return new Systems::PhysicsSystem(this, EventBroker, ResourceManager); });
|
||||||
|
m_SystemFactory.Register<Systems::TriggerSystem>([this]() { return new Systems::TriggerSystem(this, EventBroker, ResourceManager); });
|
||||||
|
m_SystemFactory.Register<Systems::RenderSystem>([this]() { return new Systems::RenderSystem(this, EventBroker, ResourceManager); });
|
||||||
|
m_SystemFactory.Register<Systems::WallSystem>([this]() { return new Systems::WallSystem(this, EventBroker, ResourceManager); });
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameWorld::AddSystems()
|
||||||
|
{
|
||||||
|
AddSystem<Systems::TimerSystem>();
|
||||||
|
AddSystem<Systems::DamageSystem>();
|
||||||
|
AddSystem<Systems::TransformSystem>();
|
||||||
|
//AddSystem<Systems::LevelGenerationSystem>();
|
||||||
|
AddSystem<Systems::InputSystem>();
|
||||||
|
AddSystem<Systems::DebugSystem>();
|
||||||
|
//AddSystem<Systems::CollisionSystem>();
|
||||||
|
AddSystem<Systems::ParticleSystem>();
|
||||||
|
//AddSystem<Systems::PlayerSystem>();
|
||||||
|
AddSystem<Systems::FreeSteeringSystem>();
|
||||||
|
AddSystem<Systems::TankSteeringSystem>();
|
||||||
|
AddSystem<Systems::WheelPairSystem>();
|
||||||
|
AddSystem<Systems::SoundSystem>();
|
||||||
|
AddSystem<Systems::PhysicsSystem>();
|
||||||
|
AddSystem<Systems::TriggerSystem>();
|
||||||
|
AddSystem<Systems::RenderSystem>();
|
||||||
|
AddSystem<Systems::WallSystem>();
|
||||||
|
}
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
#include "Systems/TimerSystem.h"
|
#include "Systems/TimerSystem.h"
|
||||||
#include "Systems/DamageSystem.h"
|
#include "Systems/DamageSystem.h"
|
||||||
#include "Systems/WheelPairSystem.h"
|
#include "Systems/WheelPairSystem.h"
|
||||||
|
#include "Systems/WallSystem.h"
|
||||||
|
|
||||||
#include "Components/Camera.h"
|
#include "Components/Camera.h"
|
||||||
#include "Components/DirectionalLight.h"
|
#include "Components/DirectionalLight.h"
|
||||||
@@ -74,6 +75,8 @@ private:
|
|||||||
EntityID CreateTank(int playerID);
|
EntityID CreateTank(int playerID);
|
||||||
void AddTankWheelPair(EntityID tankEntity, glm::vec3 position, int axleID, bool steering);
|
void AddTankWheelPair(EntityID tankEntity, glm::vec3 position, int axleID, bool steering);
|
||||||
EntityID CreateJeep(int playerID);
|
EntityID CreateJeep(int playerID);
|
||||||
|
|
||||||
|
std::vector<EntityID> m_WallDebrisTemplates;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // GameWorld_h__
|
#endif // GameWorld_h__
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
#include "PrecompiledHeader.h"
|
#include "PrecompiledHeader.h"
|
||||||
#include "DamageSystem.h"
|
#include "DamageSystem.h"
|
||||||
#include "World.h"
|
#include "World.h"
|
||||||
|
|
||||||
void Systems::DamageSystem::RegisterComponents( ComponentFactory* cf )
|
void Systems::DamageSystem::RegisterComponents( ComponentFactory* cf )
|
||||||
{
|
{
|
||||||
cf->Register<Components::Health>([]() { return new Components::Health(); });
|
cf->Register<Components::Health>([]() { return new Components::Health(); });
|
||||||
@@ -15,8 +14,16 @@ void Systems::DamageSystem::Initialize()
|
|||||||
|
|
||||||
bool Systems::DamageSystem::OnDamage( const Events::Damage &event )
|
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);
|
auto health = m_World->GetComponent<Components::Health>(event.Entity);
|
||||||
health->Amount -= event.Amount;
|
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);
|
LOG_INFO("Damaged entity %i, Health left: %f", event.Entity, health->Amount);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -5,6 +5,7 @@
|
|||||||
#include "System.h"
|
#include "System.h"
|
||||||
#include "Components/Health.h"
|
#include "Components/Health.h"
|
||||||
#include "Events/Damage.h"
|
#include "Events/Damage.h"
|
||||||
|
#include "Events/OnDead.h"
|
||||||
|
|
||||||
namespace Systems
|
namespace Systems
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -163,6 +163,10 @@ void Systems::PhysicsSystem::Update(double dt)
|
|||||||
EntityID entity = pair.first;
|
EntityID entity = pair.first;
|
||||||
EntityID parent = pair.second;
|
EntityID parent = pair.second;
|
||||||
|
|
||||||
|
auto templateComponent = m_World->GetComponent<Components::Template>(entity);
|
||||||
|
if(templateComponent)
|
||||||
|
continue;
|
||||||
|
|
||||||
if (m_RigidBodies.find(entity) == m_RigidBodies.end())
|
if (m_RigidBodies.find(entity) == m_RigidBodies.end())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -227,6 +231,10 @@ void Systems::PhysicsSystem::Update(double dt)
|
|||||||
|
|
||||||
void Systems::PhysicsSystem::UpdateEntity(double dt, EntityID entity, EntityID parent)
|
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);
|
auto transformComponent = m_World->GetComponent<Components::Transform>(entity);
|
||||||
if (!transformComponent)
|
if (!transformComponent)
|
||||||
return;
|
return;
|
||||||
@@ -312,7 +320,7 @@ void Systems::PhysicsSystem::OnEntityCommit( EntityID entity )
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
hkpShape* shape;
|
hkpShape* shape;
|
||||||
if(! physicsComponent->Static) // Not static
|
if(physicsComponent->MotionType == Components::Physics::MotionTypeEnum::Dynamic)
|
||||||
{
|
{
|
||||||
hkArray<hkpShape*> shapeArray;
|
hkArray<hkpShape*> shapeArray;
|
||||||
for (auto &shapeData : m_Shapes[entity])
|
for (auto &shapeData : m_Shapes[entity])
|
||||||
@@ -447,7 +455,7 @@ void Systems::PhysicsSystem::OnEntityCommit( EntityID entity )
|
|||||||
rigidBody->removeReference();
|
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.
|
// Create the hkpStaticCompoundShape and add the instances.
|
||||||
// "meshShape" should not be modified by the user in any way after adding it as an instance.
|
// "meshShape" should not be modified by the user in any way after adding it as an instance.
|
||||||
@@ -499,7 +507,15 @@ void Systems::PhysicsSystem::OnEntityCommit( EntityID entity )
|
|||||||
hkpRigidBodyCinfo rigidBodyInfo;
|
hkpRigidBodyCinfo rigidBodyInfo;
|
||||||
{
|
{
|
||||||
rigidBodyInfo.m_shape = shape;
|
rigidBodyInfo.m_shape = shape;
|
||||||
rigidBodyInfo.m_motionType = hkpMotion::MOTION_FIXED;
|
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);
|
auto absoluteTransform = m_World->GetSystem<Systems::TransformSystem>()->AbsoluteTransform(entity);
|
||||||
hkVector4 position = GLMVEC3_TO_HKVECTOR4(absoluteTransform.Position);
|
hkVector4 position = GLMVEC3_TO_HKVECTOR4(absoluteTransform.Position);
|
||||||
hkQuaternion rotation = GLMQUAT_TO_HKQUATERNION(absoluteTransform.Orientation);
|
hkQuaternion rotation = GLMQUAT_TO_HKQUATERNION(absoluteTransform.Orientation);
|
||||||
@@ -816,7 +832,6 @@ void Systems::PhysicsSystem::OnComponentRemoved(EntityID entity, std::string typ
|
|||||||
m_RigidBodies.erase(entity);
|
m_RigidBodies.erase(entity);
|
||||||
m_PhysicsWorld->unmarkForWrite();
|
m_PhysicsWorld->unmarkForWrite();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -124,6 +124,9 @@ bool Systems::TankSteeringSystem::OnCollision( const Events::Collision &e )
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(m_World->GetComponent<Components::Template>(shellEntity))
|
||||||
|
return false;
|
||||||
|
|
||||||
auto physicsComponents = m_World->GetComponentsOfType<Components::Physics>();
|
auto physicsComponents = m_World->GetComponentsOfType<Components::Physics>();
|
||||||
auto shellTransform = m_World->GetComponent<Components::Transform>(shellEntity);
|
auto shellTransform = m_World->GetComponent<Components::Transform>(shellEntity);
|
||||||
//auto otherTransform = m_World->GetComponent<Components::Transform>(otherEntity);
|
//auto otherTransform = m_World->GetComponent<Components::Transform>(otherEntity);
|
||||||
@@ -155,8 +158,6 @@ bool Systems::TankSteeringSystem::OnCollision( const Events::Collision &e )
|
|||||||
EventBroker->Publish(d);
|
EventBroker->Publish(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
m_World->RemoveEntity(shellEntity);
|
m_World->RemoveEntity(shellEntity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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)) * 400.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__
|
||||||
@@ -122,6 +122,7 @@
|
|||||||
<ClCompile Include="..\..\src\Systems\TimerSystem.cpp" />
|
<ClCompile Include="..\..\src\Systems\TimerSystem.cpp" />
|
||||||
<ClCompile Include="..\..\src\Systems\TransformSystem.cpp" />
|
<ClCompile Include="..\..\src\Systems\TransformSystem.cpp" />
|
||||||
<ClCompile Include="..\..\src\Systems\TriggerSystem.cpp" />
|
<ClCompile Include="..\..\src\Systems\TriggerSystem.cpp" />
|
||||||
|
<ClCompile Include="..\..\src\Systems\WallSystem.cpp" />
|
||||||
<ClCompile Include="..\..\src\Systems\WheelPairSystem.cpp" />
|
<ClCompile Include="..\..\src\Systems\WheelPairSystem.cpp" />
|
||||||
<ClCompile Include="..\..\src\Texture.cpp" />
|
<ClCompile Include="..\..\src\Texture.cpp" />
|
||||||
<ClCompile Include="..\..\src\World.cpp" />
|
<ClCompile Include="..\..\src\World.cpp" />
|
||||||
@@ -163,6 +164,7 @@
|
|||||||
<ClInclude Include="..\..\src\Components\Trigger.h" />
|
<ClInclude Include="..\..\src\Components\Trigger.h" />
|
||||||
<ClInclude Include="..\..\src\Components\Vehicle.h" />
|
<ClInclude Include="..\..\src\Components\Vehicle.h" />
|
||||||
<ClInclude Include="..\..\src\Components\Viewport.h" />
|
<ClInclude Include="..\..\src\Components\Viewport.h" />
|
||||||
|
<ClInclude Include="..\..\src\Components\Wall.h" />
|
||||||
<ClInclude Include="..\..\src\Components\Wheel.h" />
|
<ClInclude Include="..\..\src\Components\Wheel.h" />
|
||||||
<ClInclude Include="..\..\src\Components\WheelPair.h" />
|
<ClInclude Include="..\..\src\Components\WheelPair.h" />
|
||||||
<ClInclude Include="..\..\src\CubemapTexture.h" />
|
<ClInclude Include="..\..\src\CubemapTexture.h" />
|
||||||
@@ -187,6 +189,7 @@
|
|||||||
<ClInclude Include="..\..\src\Events\MouseMove.h" />
|
<ClInclude Include="..\..\src\Events\MouseMove.h" />
|
||||||
<ClInclude Include="..\..\src\Events\MousePress.h" />
|
<ClInclude Include="..\..\src\Events\MousePress.h" />
|
||||||
<ClInclude Include="..\..\src\Events\MouseRelease.h" />
|
<ClInclude Include="..\..\src\Events\MouseRelease.h" />
|
||||||
|
<ClInclude Include="..\..\src\Events\OnDead.h" />
|
||||||
<ClInclude Include="..\..\src\Events\PlaySound.h" />
|
<ClInclude Include="..\..\src\Events\PlaySound.h" />
|
||||||
<ClInclude Include="..\..\src\Events\SetVelocity.h" />
|
<ClInclude Include="..\..\src\Events\SetVelocity.h" />
|
||||||
<ClInclude Include="..\..\src\Events\SetViewportCamera.h" />
|
<ClInclude Include="..\..\src\Events\SetViewportCamera.h" />
|
||||||
@@ -228,6 +231,7 @@
|
|||||||
<ClInclude Include="..\..\src\Systems\TimerSystem.h" />
|
<ClInclude Include="..\..\src\Systems\TimerSystem.h" />
|
||||||
<ClInclude Include="..\..\src\Systems\TransformSystem.h" />
|
<ClInclude Include="..\..\src\Systems\TransformSystem.h" />
|
||||||
<ClInclude Include="..\..\src\Systems\TriggerSystem.h" />
|
<ClInclude Include="..\..\src\Systems\TriggerSystem.h" />
|
||||||
|
<ClInclude Include="..\..\src\Systems\WallSystem.h" />
|
||||||
<ClInclude Include="..\..\src\Systems\WheelPairSystem.h" />
|
<ClInclude Include="..\..\src\Systems\WheelPairSystem.h" />
|
||||||
<ClInclude Include="..\..\src\Texture.h" />
|
<ClInclude Include="..\..\src\Texture.h" />
|
||||||
<ClInclude Include="..\..\src\Util\GLError.h" />
|
<ClInclude Include="..\..\src\Util\GLError.h" />
|
||||||
|
|||||||
@@ -76,6 +76,9 @@
|
|||||||
<Filter>Gameplay\Systems</Filter>
|
<Filter>Gameplay\Systems</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\src\Systems\WheelPairSystem.cpp" />
|
<ClCompile Include="..\..\src\Systems\WheelPairSystem.cpp" />
|
||||||
|
<ClCompile Include="..\..\src\Systems\WallSystem.cpp">
|
||||||
|
<Filter>Gameplay\Systems</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Filter Include="Util">
|
<Filter Include="Util">
|
||||||
@@ -485,6 +488,15 @@
|
|||||||
<ClInclude Include="..\..\src\Components\BlendMap.h">
|
<ClInclude Include="..\..\src\Components\BlendMap.h">
|
||||||
<Filter>Rendering\Components</Filter>
|
<Filter>Rendering\Components</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\Systems\WallSystem.h">
|
||||||
|
<Filter>Gameplay\Systems</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\Events\OnDead.h">
|
||||||
|
<Filter>Gameplay\Events</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\Components\Wall.h">
|
||||||
|
<Filter>Gameplay\Components</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="..\..\src\Shaders\Fragment2.glsl">
|
<None Include="..\..\src\Shaders\Fragment2.glsl">
|
||||||
|
|||||||
Reference in New Issue
Block a user