From f9f20535ba6038a142ea3efd310a81201aa8ec1f Mon Sep 17 00:00:00 2001 From: ViktorLjung Date: Wed, 4 Jun 2014 05:47:17 +0200 Subject: [PATCH 1/6] Jeep and tank tuning --- assets | 2 +- src/Components/JeepSteering.h | 14 + src/Components/Vehicle.h | 4 +- src/Events/JeepSteer.h | 19 + src/GameWorld.cpp | 3 +- src/GameWorld.h | 1 + src/Systems/JeepSteeringSystem.cpp | 312 +++++++ src/Systems/JeepSteeringSystem.h | 92 ++ src/Systems/PhysicsSystem.cpp | 122 +-- src/Systems/PhysicsSystem.h | 3 + src/Systems/TankSteeringSystem.cpp | 16 +- vs11/Returngeance/Returngeance.vcxproj | 4 + .../Returngeance/Returngeance.vcxproj.filters | 822 ++++-------------- 13 files changed, 715 insertions(+), 699 deletions(-) create mode 100644 src/Components/JeepSteering.h create mode 100644 src/Events/JeepSteer.h create mode 100644 src/Systems/JeepSteeringSystem.cpp create mode 100644 src/Systems/JeepSteeringSystem.h diff --git a/assets b/assets index 588da9c..e09ebf5 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 588da9ca0d0e6a3dd08f4373e03468f79082b359 +Subproject commit e09ebf5a29f007cb8ee884f48dc600926f0665bc diff --git a/src/Components/JeepSteering.h b/src/Components/JeepSteering.h new file mode 100644 index 0000000..763745f --- /dev/null +++ b/src/Components/JeepSteering.h @@ -0,0 +1,14 @@ +#ifndef JeepSteering_h__ +#define JeepSteering_h__ + +#include "Component.h" + +namespace Components +{ + struct JeepSteering : Component + { + JeepSteering* Clone() const override { return new JeepSteering(*this); } + }; +} + +#endif // JeepSteering_h__ \ No newline at end of file diff --git a/src/Components/Vehicle.h b/src/Components/Vehicle.h index 9f6cfac..8d9dfed 100644 --- a/src/Components/Vehicle.h +++ b/src/Components/Vehicle.h @@ -10,8 +10,8 @@ namespace Components struct Vehicle : Component { Vehicle() - : MaxTorque(1000.0f), MinRPM(200.0f), OptimalRPM(3000.0f), MaxRPM(6000.0f), MaxSteeringAngle(35), TopSpeed(90.0f), - MaxSpeedFullSteeringAngle(40.0f), SpringDamping(1.f), UpshiftRPM(5500.0f), DownshiftRPM(1000.0f), + : MaxTorque(1000.0f), MinRPM(200.0f), OptimalRPM(2500.0f), MaxRPM(4000.0f), MaxSteeringAngle(35), TopSpeed(90.0f), + MaxSpeedFullSteeringAngle(40.0f), SpringDamping(1.f), UpshiftRPM(3500.0f), DownshiftRPM(1000.0f), gearsRatio0(3.0f), gearsRatio1(2.25f), gearsRatio2(1.5f), gearsRatio3(1.0f){ } float MaxTorque; float MinRPM; diff --git a/src/Events/JeepSteer.h b/src/Events/JeepSteer.h new file mode 100644 index 0000000..03189ec --- /dev/null +++ b/src/Events/JeepSteer.h @@ -0,0 +1,19 @@ +#ifndef Events_JeepSteer_h__ +#define Events_JeepSteer_h__ +#include "Entity.h" +#include "EventBroker.h" + +namespace Events +{ + + struct JeepSteer : Event + { + EntityID Entity; + float PositionX; + float PositionY; + bool Handbrake; + }; + +} + +#endif // Events_JeepSteer_h__ \ No newline at end of file diff --git a/src/GameWorld.cpp b/src/GameWorld.cpp index ed130c7..d8dee4c 100755 --- a/src/GameWorld.cpp +++ b/src/GameWorld.cpp @@ -413,7 +413,6 @@ void GameWorld::Initialize() } CommitEntity(gateBase); } - } void GameWorld::Update(double dt) @@ -444,6 +443,7 @@ void GameWorld::RegisterSystems() //m_SystemFactory.Register([this]() { return new Systems::PlayerSystem(this); }); m_SystemFactory.Register([this]() { return new Systems::FreeSteeringSystem(this, EventBroker, ResourceManager); }); m_SystemFactory.Register([this]() { return new Systems::TankSteeringSystem(this, EventBroker, ResourceManager); }); + m_SystemFactory.Register([this]() { return new Systems::JeepSteeringSystem(this, EventBroker, ResourceManager); }); m_SystemFactory.Register([this]() { return new Systems::WheelPairSystem(this, EventBroker, ResourceManager); }); m_SystemFactory.Register([this]() { return new Systems::SoundSystem(this, EventBroker, ResourceManager); }); m_SystemFactory.Register([this]() { return new Systems::PhysicsSystem(this, EventBroker, ResourceManager); }); @@ -467,6 +467,7 @@ void GameWorld::AddSystems() //AddSystem(); AddSystem(); AddSystem(); + AddSystem(); AddSystem(); AddSystem(); AddSystem(); diff --git a/src/GameWorld.h b/src/GameWorld.h index 66dde65..cb5ec94 100755 --- a/src/GameWorld.h +++ b/src/GameWorld.h @@ -24,6 +24,7 @@ #include "Systems/FollowSystem.h" #include "Systems/WallSystem.h" #include "Systems/GarageSystem.h" +#include "Systems/JeepSteeringSystem.h" #include "Components/Camera.h" #include "Components/DirectionalLight.h" diff --git a/src/Systems/JeepSteeringSystem.cpp b/src/Systems/JeepSteeringSystem.cpp new file mode 100644 index 0000000..d5c501b --- /dev/null +++ b/src/Systems/JeepSteeringSystem.cpp @@ -0,0 +1,312 @@ +#include "PrecompiledHeader.h" +#include "JeepSteeringSystem.h" +#include "World.h" + +void Systems::JeepSteeringSystem::RegisterComponents(ComponentFactory* cf) +{ + cf->Register([]() { return new Components::JeepSteering(); }); +} + +void Systems::JeepSteeringSystem::Initialize() +{ + EVENT_SUBSCRIBE_MEMBER(m_ESpawnVehicle, &Systems::JeepSteeringSystem::OnSpawnVehicle); + + for (int i = 0; i < 4; i++) + { + m_JeepInputControllers[i] = std::shared_ptr(new JeepSteeringInputController(EventBroker, i + 1)); + } +} + +void Systems::JeepSteeringSystem::Update(double dt) +{ + for (int i = 0; i < 4; i++) + { + m_JeepInputControllers[i]->Update(dt); + } +} + +void Systems::JeepSteeringSystem::UpdateEntity(double dt, EntityID entity, EntityID parent) +{ + auto tankSteeringComponent = m_World->GetComponent(entity); + if(!tankSteeringComponent) + return; + + auto playerComponent = m_World->GetComponent(entity); + if (!playerComponent) + return; + + if (playerComponent->ID == 0) + return; + + auto inputController = m_JeepInputControllers[playerComponent->ID - 1]; + + + Events::JeepSteer eSteering; + eSteering.Entity = entity; + eSteering.PositionX = inputController->PositionX; + eSteering.PositionY = inputController->PositionY; + eSteering.Handbrake = inputController->Handbrake; + EventBroker->Publish(eSteering); +} + +bool Systems::JeepSteeringSystem::OnSpawnVehicle(const Events::SpawnVehicle &event) +{ + + if (event.VehicleType != "Jeep") + return false; + + auto spawnPointComponents = m_World->GetComponentsOfType(); + if (!spawnPointComponents) + { + LOG_ERROR("Found no spawn points!"); + return false; + } + + for (auto &spawnPointComponent : *spawnPointComponents) + { + auto spawnPoint = spawnPointComponent->Entity; + auto spawnPointBaseParent = m_World->GetEntityBaseParent(spawnPoint); + auto playerComponent = m_World->GetComponent(spawnPointBaseParent); + if (!playerComponent || playerComponent->ID != event.PlayerID) + continue; + + Components::Transform absoluteTransform = m_World->GetSystem()->AbsoluteTransform(spawnPoint); + + // Create a tank + EntityID Jeep = CreateJeep(event.PlayerID); + auto tankTransform = m_World->GetComponent(Jeep); + tankTransform->Position = glm::vec3(0, 50, 0);//absoluteTransform.Position; +// tankTransform->Orientation = absoluteTransform.Orientation; + // Set the viewport correctly + Events::SetViewportCamera e; + e.CameraEntity = m_World->GetProperty(Jeep, "Camera"); + if (event.PlayerID == 1) + e.ViewportFrame = "Viewport1"; + else if (event.PlayerID == 2) + e.ViewportFrame = "Viewport2"; + EventBroker->Publish(e); + } + + return true; +} + +EntityID Systems::JeepSteeringSystem::CreateJeep(int playerID) +{ + auto jeep = m_World->CreateEntity(); + auto transform = m_World->AddComponent(jeep); + transform->Position = glm::vec3(0, 5, 0); + //transform->Orientation = glm::angleAxis(0.f, glm::vec3(0, 1, 0)); + auto physics = m_World->AddComponent(jeep); + physics->Mass = 1600; + physics->MotionType = Components::Physics::MotionTypeEnum::Dynamic; + auto vehicle = m_World->AddComponent(jeep); + vehicle->MaxTorque = 400.f; + vehicle->MaxSteeringAngle = 50.f; + vehicle->MaxSpeedFullSteeringAngle = 20.f; + vehicle->MinRPM = 1000.0f; + vehicle->OptimalRPM = 4000.0f, + vehicle->MaxRPM = 6000.0f; + vehicle->TopSpeed = 90.0f; + vehicle->SpringDamping = 1.f; + vehicle->UpshiftRPM = 5500.0f; + vehicle->DownshiftRPM = 1500.0f; + vehicle->gearsRatio0 = 3.0f; + vehicle->gearsRatio1 = 2.25f; + vehicle->gearsRatio2 = 1.5f; + vehicle->gearsRatio3 = 1.0f; + + auto player = m_World->AddComponent(jeep); + player->ID = playerID; + auto tankSteering = m_World->AddComponent(jeep); + m_World->AddComponent(jeep); + auto health = m_World->AddComponent(jeep); + health->Amount = 100.f; + + { + auto shape = m_World->CreateEntity(jeep); + auto transform = m_World->AddComponent(shape); + auto meshShape = m_World->AddComponent(shape); + meshShape->ResourceName = "Models/Jeep/Chassi/ChassiCollision.obj"; + m_World->CommitEntity(shape); + } + + { + auto chassis = m_World->CreateEntity(jeep); + auto transform = m_World->AddComponent(chassis); + transform->Position = glm::vec3(0, 0, 0); + auto model = m_World->AddComponent(chassis); + model->ModelFile = "Models/Jeep/Chassi/Chassi.OBJ"; + } + + + auto cameraTower = m_World->CreateEntity(jeep); + { + auto transform = m_World->AddComponent(cameraTower); + transform->Position.z = 16.f; + transform->Position.y = 4.f; + transform->Orientation = glm::quat(glm::vec3(-glm::radians(5.f), 0.f, 0.f)); + auto cameraComp = m_World->AddComponent(cameraTower); + cameraComp->FarClip = 2000.f; + m_World->SetProperty(jeep, "Camera", cameraTower); + } + + + + + + +#pragma region Wheels + //Create wheels + float wheelOffset = 0.f;//-0.83f; + const float suspensionStrength = 15.f; + const float springLength = 0.3f; + + AddJeepWheels(jeep); +#pragma endregion + + { + auto entity = m_World->CreateEntity(jeep); + auto transformComponent = m_World->AddComponent(entity); + transformComponent->Position = glm::vec3(-2, -1.7, 2.0); + transformComponent->Scale = glm::vec3(3, 3, 3); + transformComponent->Orientation = glm::angleAxis(glm::pi() / 2, glm::vec3(1, 0, 0)); + auto emitterComponent = m_World->AddComponent(entity); + emitterComponent->SpawnCount = 2; + emitterComponent->SpawnFrequency = 0.005; + emitterComponent->SpreadAngle = glm::pi(); + emitterComponent->UseGoalVelocity = false; + emitterComponent->LifeTime = 0.5; + //emitterComponent->AngularVelocitySpectrum.push_back(glm::pi() / 100); + emitterComponent->ScaleSpectrum.push_back(glm::vec3(0.05)); + m_World->CommitEntity(entity); + + auto particleEntity = m_World->CreateEntity(entity); + auto TEMP = m_World->AddComponent(particleEntity); + TEMP->Scale = glm::vec3(0); + auto spriteComponent = m_World->AddComponent(particleEntity); + spriteComponent->SpriteFile = "Models/Textures/Sprites/Dust.png"; + emitterComponent->ParticleTemplate = particleEntity; + + m_World->CommitEntity(particleEntity); + } + + m_World->CommitEntity(jeep); + + return jeep; +} + +void Systems::JeepSteeringSystem::AddJeepWheels(EntityID jeepEntity) +{ + //Create wheels + float wheelOffset = 0.4f; + float springLength = 0.3f; + float suspensionStrength = 45.f; + { + auto wheel = m_World->CreateEntity(jeepEntity); + auto transform = m_World->AddComponent(wheel); + transform->Position = glm::vec3(1.9f, 0.5546f - wheelOffset, -0.9242f); + transform->Scale = glm::vec3(1.0f); + auto model = m_World->AddComponent(wheel); + model->ModelFile = "Models/Jeep/WheelFront/wheelFront.obj"; + auto Wheel = m_World->AddComponent(wheel); + Wheel->Hardpoint = transform->Position + glm::vec3(0.f, springLength, 0.f); + Wheel->AxleID = 0; + Wheel->Mass = 50; + Wheel->Radius = 0.837f; + Wheel->Steering = true; + Wheel->SuspensionStrength = suspensionStrength; + Wheel->Friction = 4.f; + Wheel->ConnectedToHandbrake = true; + m_World->CommitEntity(wheel); + } + + { + auto wheel = m_World->CreateEntity(jeepEntity); + auto transform = m_World->AddComponent(wheel); + transform->Position = glm::vec3(-1.9f, 0.5546f - wheelOffset, -0.9242f); + transform->Scale = glm::vec3(1.0f); + transform->Orientation = glm::angleAxis(glm::pi(), glm::vec3(0, 0, 1)); + auto model = m_World->AddComponent(wheel); + model->ModelFile = "Models/Jeep/WheelFront/wheelFront.obj"; + auto Wheel = m_World->AddComponent(wheel); + Wheel->Hardpoint = transform->Position + glm::vec3(0.f, springLength, 0.f); + Wheel->AxleID = 0; + Wheel->Mass = 50; + Wheel->Radius = 0.837f; + Wheel->Steering = true; + Wheel->SuspensionStrength = suspensionStrength; + Wheel->Friction = 4.f; + Wheel->ConnectedToHandbrake = true; + m_World->CommitEntity(wheel); + } + + { + auto wheel = m_World->CreateEntity(jeepEntity); + auto transform = m_World->AddComponent(wheel); + transform->Position = glm::vec3(0.2726f, 0.2805f - wheelOffset, 1.9307f); + auto model = m_World->AddComponent(wheel); + model->ModelFile = "Models/Jeep/WheelBack/wheelBack.obj"; + auto Wheel = m_World->AddComponent(wheel); + Wheel->Hardpoint = transform->Position + glm::vec3(0.f, springLength, 0.f); + Wheel->AxleID = 1; + Wheel->Mass = 50; + Wheel->Radius = 0.737f; + Wheel->Steering = false; + Wheel->SuspensionStrength = suspensionStrength; + Wheel->Friction = 4.f; + Wheel->ConnectedToHandbrake = true; + m_World->CommitEntity(wheel); + } + + { + auto wheel = m_World->CreateEntity(jeepEntity); + auto transform = m_World->AddComponent(wheel); + transform->Position = glm::vec3(-0.2726f, 0.2805f - wheelOffset, 1.9307f); + transform->Orientation = glm::angleAxis(glm::pi(), glm::vec3(0, 0, 1)); + auto model = m_World->AddComponent(wheel); + model->ModelFile = "Models/Jeep/WheelBack/wheelBack.obj"; + auto Wheel = m_World->AddComponent(wheel); + Wheel->Hardpoint = transform->Position + glm::vec3(0.f, springLength, 0.f); + Wheel->AxleID = 1; + Wheel->Mass = 50; + Wheel->Radius = 0.737f; + Wheel->Steering = false; + Wheel->SuspensionStrength = suspensionStrength; + Wheel->Friction = 4.f; + Wheel->ConnectedToHandbrake = true; + m_World->CommitEntity(wheel); + } + + +} + +void Systems::JeepSteeringSystem::JeepSteeringInputController::Update( double dt ) +{ + PositionX = m_Horizontal; + PositionY = m_Vertical; +} + +bool Systems::JeepSteeringSystem::JeepSteeringInputController::OnCommand(const Events::InputCommand &event) +{ + if (event.PlayerID != this->PlayerID) + return false; + + float val = event.Value; + + // Tank + if (event.Command == "horizontal") + { + m_Horizontal = val; + } + else if (event.Command == "vertical") + { + m_Vertical = -val; + } + + else if (event.Command == "handbrake") + { + Handbrake = val > 0; + } + return true; +} + diff --git a/src/Systems/JeepSteeringSystem.h b/src/Systems/JeepSteeringSystem.h new file mode 100644 index 0000000..0a786be --- /dev/null +++ b/src/Systems/JeepSteeringSystem.h @@ -0,0 +1,92 @@ +#include + +#include "System.h" +#include "Components/Transform.h" +#include "Components/Physics.h" +#include "Components/Vehicle.h" +#include "Components/Player.h" +#include "Components/Model.h" +#include "Systems/TransformSystem.h" +#include "Systems/ParticleSystem.h" +#include "InputController.h" + +#include "Components/Health.h" + +#include "Components/Trigger.h" + +#include "Components/Vehicle.h" +#include "Components/Player.h" + +#include "Events/SpawnVehicle.h" +#include "Components/SpawnPoint.h" + +#include "Components/Wheel.h" +#include "Components/MeshShape.h" +#include "Components/Camera.h" +#include "Components/BoxShape.h" +#include "Components/WheelPair.h" +#include "Components/Input.h" +#include "Components/JeepSteering.h" +#include "Events/JeepSteer.h" + +#include "Events/SetViewportCamera.h" + +namespace Systems +{ + + class JeepSteeringSystem : public System + { + public: + JeepSteeringSystem(World* world, std::shared_ptr<::EventBroker> eventBroker, std::shared_ptr<::ResourceManager> resourceManager) + : System(world, eventBroker, resourceManager) + { } + + void RegisterComponents(ComponentFactory* cf) override; + void Initialize() override; + + void Update(double dt) override; + void UpdateEntity(double dt, EntityID entity, EntityID parent) override; + + private: + std::map m_TimeSinceLastShot; + EventRelay m_ESpawnVehicle; + bool OnSpawnVehicle(const Events::SpawnVehicle &e); + + class JeepSteeringInputController; + std::array, 4> m_JeepInputControllers; + + EntityID CreateJeep(int playerID); + void AddJeepWheels(EntityID jeepEntity); + }; + + class JeepSteeringSystem::JeepSteeringInputController : InputController + { + public: + JeepSteeringInputController(std::shared_ptr<::EventBroker> eventBroker, int playerID) + : InputController(eventBroker) + { + PlayerID = playerID; + + m_Horizontal = 0.f; + m_Vertical = 0.f; + PositionX = 0; + PositionY = 0; + Handbrake = false; + } + + int PlayerID; + + float PositionY; + float PositionX; + bool Handbrake; + + void Update(double dt); + protected: + virtual bool OnCommand(const Events::InputCommand &event); + //virtual bool OnMouseMove(const Events::MouseMove &event); + + private: + float m_Horizontal; + float m_Vertical; + }; +} \ No newline at end of file diff --git a/src/Systems/PhysicsSystem.cpp b/src/Systems/PhysicsSystem.cpp index 1e8e2dd..f03709a 100644 --- a/src/Systems/PhysicsSystem.cpp +++ b/src/Systems/PhysicsSystem.cpp @@ -33,6 +33,7 @@ void Systems::PhysicsSystem::Initialize() // Events EVENT_SUBSCRIBE_MEMBER(m_ETankSteer, &Systems::PhysicsSystem::OnTankSteer); + EVENT_SUBSCRIBE_MEMBER(m_EJeepSteer, &Systems::PhysicsSystem::OnJeepSteer); EVENT_SUBSCRIBE_MEMBER(m_ESetVelocity, &Systems::PhysicsSystem::OnSetVelocity); EVENT_SUBSCRIBE_MEMBER(m_EApplyForce, &Systems::PhysicsSystem::OnApplyForce); EVENT_SUBSCRIBE_MEMBER(m_EApplyPointImpulse, &Systems::PhysicsSystem::OnApplyPointImpulse); @@ -274,27 +275,10 @@ void Systems::PhysicsSystem::UpdateEntity(double dt, EntityID entity, EntityID p else if(m_RigidBodies.find(entity) != m_RigidBodies.end()) { auto transformComponentParent = m_World->GetComponent(parent); - - /* if(transformComponentParent) - { - auto absoluteTransformParent = m_World->GetSystem()->AbsoluteTransform(parent); - transformComponent->Position = HKVECTOR4_TO_GLMVEC3(m_RigidBodies[entity]->getPosition()); - transformComponent->Orientation = glm::inverse(HKQUATERNION_TO_GLMQUAT(m_RigidBodies[entity]->getRotation())) * absoluteTransformParent.Orientation; - transformComponent->Velocity = HKVECTOR4_TO_GLMVEC3(m_RigidBodies[entity]->getLinearVelocity()); - } - else - { - auto transformComponentParent = m_World->GetComponent(parent); - transformComponent->Position = HKVECTOR4_TO_GLMVEC3(m_RigidBodies[entity]->getPosition()); - transformComponent->Orientation = HKQUATERNION_TO_GLMQUAT(m_RigidBodies[entity]->getRotation()); - transformComponent->Velocity = HKVECTOR4_TO_GLMVEC3(m_RigidBodies[entity]->getLinearVelocity()); - }*/ - transformComponent->Position = HKVECTOR4_TO_GLMVEC3(m_RigidBodies[entity]->getPosition()); transformComponent->Orientation = HKQUATERNION_TO_GLMQUAT(m_RigidBodies[entity]->getRotation()); transformComponent->Velocity = HKVECTOR4_TO_GLMVEC3(m_RigidBodies[entity]->getLinearVelocity()); - // HACK: WTF IS THIS? if (transformComponentParent) { auto absoluteTransformParent = m_World->GetSystem()->AbsoluteTransform(parent); @@ -758,47 +742,6 @@ void HK_CALL Systems::PhysicsSystem::HavokErrorReport(const char* msg, void*) LOG_INFO("%s", msg); } -bool Systems::PhysicsSystem::OnTankSteer(const Events::TankSteer &event) -{ - auto vehicleComponent = m_World->GetComponent(event.Entity); - - if (vehicleComponent && m_Vehicles.find(event.Entity) != m_Vehicles.end() && m_RigidBodies.find(event.Entity) != m_RigidBodies.end()) - { - hkpVehicleDriverInputAnalogStatus* deviceStatus = (hkpVehicleDriverInputAnalogStatus*)m_Vehicles[event.Entity]->m_deviceStatus; - auto transformComponent = m_World->GetComponent(event.Entity); - - float steeringX = event.PositionX; - - glm::vec3 velocityNormalized = glm::normalize(HKVECTOR4_TO_GLMVEC3(m_RigidBodies[event.Entity]->getLinearVelocity())); - glm::vec3 forward = glm::normalize(transformComponent->Orientation * glm::vec3(0, 0, -1)); - float dotProduct = glm::dot(forward, velocityNormalized); - - if(dotProduct < 0) - { - steeringX = (1 - (glm::clamp(abs(m_Vehicles[event.Entity]->calcKMPH() /vehicleComponent->TopSpeed), 0.f, 0.7f))) * steeringX; - } - - if(abs(m_Vehicles[event.Entity]->calcKMPH()) < 2 && abs(m_Vehicles[event.Entity]->m_mainSteeringAngle) > 80.f * (HK_REAL_PI / 180)) - { - deviceStatus->m_positionY = -0.4f; - deviceStatus->m_positionX = steeringX; - } - else - { - deviceStatus->m_positionX = event.PositionX; - deviceStatus->m_positionY = event.PositionY; - } - - if(event.PositionY > 0) - { - deviceStatus->m_reverseButtonPressed = true; - } - deviceStatus->m_handbrakeButtonPressed = event.Handbrake; - } - - return true; -} - bool Systems::PhysicsSystem::OnSetVelocity( const Events::SetVelocity &event ) { if(m_RigidBodies.find(event.Entity) != m_RigidBodies.end()) @@ -894,3 +837,66 @@ bool Systems::PhysicsSystem::OnDisableCollisions( const Events::DisableCollision m_PhysicsWorld->unmarkForWrite(); return true; } + + +bool Systems::PhysicsSystem::OnTankSteer(const Events::TankSteer &event) +{ + auto vehicleComponent = m_World->GetComponent(event.Entity); + + if (vehicleComponent && m_Vehicles.find(event.Entity) != m_Vehicles.end() && m_RigidBodies.find(event.Entity) != m_RigidBodies.end()) + { + hkpVehicleDriverInputAnalogStatus* deviceStatus = (hkpVehicleDriverInputAnalogStatus*)m_Vehicles[event.Entity]->m_deviceStatus; + auto transformComponent = m_World->GetComponent(event.Entity); + + float steeringX = event.PositionX; + + glm::vec3 velocityNormalized = glm::normalize(HKVECTOR4_TO_GLMVEC3(m_RigidBodies[event.Entity]->getLinearVelocity())); + glm::vec3 forward = glm::normalize(transformComponent->Orientation * glm::vec3(0, 0, -1)); + float dotProduct = glm::dot(forward, velocityNormalized); + + if(dotProduct < 0) + { + steeringX = (1 - (glm::clamp(abs(m_Vehicles[event.Entity]->calcKMPH() /vehicleComponent->TopSpeed), 0.f, 0.7f))) * steeringX; + } + + if(abs(m_Vehicles[event.Entity]->calcKMPH()) < 2 && abs(m_Vehicles[event.Entity]->m_mainSteeringAngle) > 80.f * (HK_REAL_PI / 180)) + { + deviceStatus->m_positionY = -0.4f; + deviceStatus->m_positionX = steeringX; + } + else + { + deviceStatus->m_positionX = event.PositionX; + deviceStatus->m_positionY = event.PositionY; + } + + if(event.PositionY > 0) + { + deviceStatus->m_reverseButtonPressed = true; + } + deviceStatus->m_handbrakeButtonPressed = event.Handbrake; + } + + return true; +} + + +bool Systems::PhysicsSystem::OnJeepSteer( const Events::JeepSteer &event ) +{ + auto vehicleComponent = m_World->GetComponent(event.Entity); + + if (vehicleComponent && m_Vehicles.find(event.Entity) != m_Vehicles.end() && m_RigidBodies.find(event.Entity) != m_RigidBodies.end()) + { + hkpVehicleDriverInputAnalogStatus* deviceStatus = (hkpVehicleDriverInputAnalogStatus*)m_Vehicles[event.Entity]->m_deviceStatus; + deviceStatus->m_positionX = event.PositionX; + deviceStatus->m_positionY = event.PositionY; + + if(event.PositionY > 0) + { + deviceStatus->m_reverseButtonPressed = true; + } + deviceStatus->m_handbrakeButtonPressed = event.Handbrake; + } + + return true; +} diff --git a/src/Systems/PhysicsSystem.h b/src/Systems/PhysicsSystem.h index a1df46a..cdfac8a 100644 --- a/src/Systems/PhysicsSystem.h +++ b/src/Systems/PhysicsSystem.h @@ -88,6 +88,7 @@ #include "Components/Template.h" #include "Events/EnterTrigger.h" +#include "Events/JeepSteer.h" namespace Systems { @@ -178,6 +179,8 @@ private: // Events EventRelay m_ETankSteer; bool OnTankSteer(const Events::TankSteer &event); + EventRelay m_EJeepSteer; + bool OnJeepSteer(const Events::JeepSteer &event); EventRelay m_ESetVelocity; bool OnSetVelocity(const Events::SetVelocity &event); EventRelay m_EApplyForce; diff --git a/src/Systems/TankSteeringSystem.cpp b/src/Systems/TankSteeringSystem.cpp index e140f49..6f37005 100644 --- a/src/Systems/TankSteeringSystem.cpp +++ b/src/Systems/TankSteeringSystem.cpp @@ -313,8 +313,8 @@ bool Systems::TankSteeringSystem::OnSpawnVehicle(const Events::SpawnVehicle &eve // Create a tank EntityID tank = CreateTank(event.PlayerID); auto tankTransform = m_World->GetComponent(tank); - tankTransform->Position = absoluteTransform.Position; - tankTransform->Orientation = absoluteTransform.Orientation; + tankTransform->Position = glm::vec3(0, 50, 0);//absoluteTransform.Position; +// tankTransform->Orientation = absoluteTransform.Orientation; // Set the viewport correctly Events::SetViewportCamera e; e.CameraEntity = m_World->GetProperty(tank, "Camera"); @@ -341,6 +341,18 @@ EntityID Systems::TankSteeringSystem::CreateTank(int playerID) vehicle->MaxTorque = 8000.f; vehicle->MaxSteeringAngle = 90.f; vehicle->MaxSpeedFullSteeringAngle = 4.f; + vehicle->MinRPM = 200.0f; + vehicle->OptimalRPM = 2500.0f, + vehicle->MaxRPM = 4000.0f; + vehicle->TopSpeed = 90.0f; + vehicle->SpringDamping = 1.f; + vehicle->UpshiftRPM = 3500.0f; + vehicle->DownshiftRPM = 1000.0f; + vehicle->gearsRatio0 = 3.0f; + vehicle->gearsRatio1 = 2.25f; + vehicle->gearsRatio2 = 1.5f; + vehicle->gearsRatio3 = 1.0f; + auto player = m_World->AddComponent(tank); player->ID = playerID; auto tankSteering = m_World->AddComponent(tank); diff --git a/vs11/Returngeance/Returngeance.vcxproj b/vs11/Returngeance/Returngeance.vcxproj index 4f89884..8121c25 100755 --- a/vs11/Returngeance/Returngeance.vcxproj +++ b/vs11/Returngeance/Returngeance.vcxproj @@ -109,6 +109,7 @@ + @@ -142,6 +143,7 @@ + @@ -195,6 +197,7 @@ + @@ -237,6 +240,7 @@ + diff --git a/vs11/Returngeance/Returngeance.vcxproj.filters b/vs11/Returngeance/Returngeance.vcxproj.filters index 24209c6..1ccb35d 100755 --- a/vs11/Returngeance/Returngeance.vcxproj.filters +++ b/vs11/Returngeance/Returngeance.vcxproj.filters @@ -1,649 +1,201 @@  - - - - - - - Rendering\Systems - - - Rendering - - - Rendering - - - Rendering - - - Rendering - - - Rendering - - - Rendering - - - Rendering - - - Physics\Systems - - - Base\Systems - - - Base\Systems - - - Audio\Systems - - - Input\Systems - - - Input\Systems - - - - Particle System\Systems - + + - - Physics - - - Input - - - Physics\Systems - - - Game\Vehicles\Helicopter\Systems - - - Physics\Systems - - - Base\Systems - - - Game\Systems - + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - Game\Systems - - - Gameplay\Systems - - - Game\Systems - - - Audio - + + + - - {ce43847c-9745-46d2-b000-069af4882886} - - - {8974329a-5c12-4b94-86e7-5931555bc129} - - - {aca514ec-84de-423c-a270-ec4399904c5a} - - - {fcbc3469-7049-4c07-9d76-f8f1e872f042} - - - {f6c5fd1d-7180-42b7-b973-a91bfc3ea189} - - - {d08cc18b-b7d8-47a7-91af-7283052e4c97} - - - {1c5d571e-55f4-498b-b64a-2f28ac2cd9b0} - - - {635843f6-c94e-4798-8201-db64d11e2a03} - - - {3bd82924-397c-4c5a-959c-971612269374} - - - {c17ff66a-f9f5-4329-a05d-e7bf8a140dd3} - - - {caa1e07f-fa19-4706-bf59-de74a0290763} - - - {444e18d8-8ab6-413b-b9b0-59a6309e0511} - - - {a2db813b-1d08-4d48-97ac-2faaff29a1cc} - - - {44c41b41-b706-4d88-8d50-abdeb2a828fe} - - - {30c6d948-459c-4fc7-b44d-ecbe5f34203e} - - - {8bcc0a31-3e0d-4342-8d10-ec8edfa03abd} - - - {93ce6550-7614-46b4-a554-0eec26e6fbf6} - - - {0bb544bb-1b0a-487f-88d6-f8ab8a2795f4} - - - {a6ca6194-3aa5-46cc-ac05-206f9a400dec} - - - {9f45f029-46c8-4c0d-b44c-dc9bffd3c6a6} - - - {6e633434-4aed-453d-b2f9-8c51ca7f78db} - - - {85692f3a-5241-4780-a3ca-f4d8a2851392} - - - {ee125b77-b275-4841-abc9-374957a89916} - - - {42ae084f-ade8-402c-87ba-f03f6b846bc8} - - - {a025d51e-594d-4844-983b-f683726bf1bf} - - - {ffab6cc2-2fbf-400f-9398-a6741b6cc95c} - - - {5b992473-73e6-485e-8f13-17e0801fb2ca} - - - {8a78be3a-a3c5-4054-a2f1-1456f3fcbab0} - - - {8ccc0abe-5bdd-4656-ab11-5708a39c71ae} - - - {b2416d05-a49e-4fef-a5c4-cd03d8cc2efd} - - - {b34c0c95-a887-4cf4-af24-cf7c1f459aa8} - - - {cb06b441-90b8-46ed-b347-4190dac7185b} - - - {ddd3c442-7c2f-4690-9308-fcef62deee0b} - - - {3c2ea0e5-41a1-4b11-a891-1d59ead7223c} - - - {3cbe68d9-2446-45ee-8637-ffb805997dcd} - - - {9702064a-02a2-4b3c-a2ab-47c23a9cf49c} - - - - - - - - - - - Util - - - Util - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - Rendering\Components - - - Rendering\Components - - - Rendering - - - Rendering - - - Rendering - - - Rendering - - - Rendering - - - Rendering - - - Rendering - - - Physics\Components - - - Physics\Systems - - - Base\Components - - - Base\Components - - - Rendering\Components - - - Base\Systems - - - Base\Systems - - - Audio\Systems - - - Audio\Components - - - Rendering\Systems - - - Input\Systems - - - Input\Systems - - - Input\Components - - - Input\Components - - - Particle System\Components - - - Rendering\Components - - - Rendering\Components - - - - Audio - - - Physics\Components - - - Physics\Components - - - Physics - - - Physics\Components - - - Physics\Components - - - Physics\Components - - - Util - - - Physics\Components - - - Physics\Components - - - Physics\Components - - - Particle System\Systems - - - Particle System\Components - - - GUI - - - Util - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - Input\Events - - - Input\Events - - - Input - - - Input\Events - - - Input\Events - - - Input\Events - - - Input\Events - - - Input\Events - - - Input\Events - - - Input - - - Rendering - - - GUI - - - Physics - - - Physics\Components - - - Physics\Events - - - Physics\Systems - - - Physics\Components - - - Physics\Components - - - Physics\Events - - - Input\Events - - - Input\Events - - - Input\Events - - - Input\Events - - - Physics\Components - - - Physics\Components - - - Input\Events - - - Game\Vehicles\Helicopter\Components - - - Game\Vehicles\Helicopter\Systems - - - Physics\Events - - - Physics\Events - - - Game\Components - - - Particle System\Events - - - Physics\Events - - - Gameplay\Components - - - Audio\Components - - - Base\Events - - - Audio\Events - - - Audio\Events - - - Audio\Events - - - Physics\Components - - - Physics\Events - - - Physics\Events - - - Physics\Components - - - Physics\Systems - - - Physics\Components - - - Physics\Events - - - Base\Systems - - - Base\Components - - - Base\Components - - - Game\Systems - - - Game\Events - - - Game\Components - - - GUI - - - GUI - - - Rendering\Events - - - GUI - - - GUI - - - GUI - - - Physics\Systems - - - Base\Events - - - Rendering\Components - - - Gameplay\Systems - - - Physics\Events - - - Game\Components - - - Game\Systems - - - Base\Events - - - Physics\Components - - - Physics\Components - - - Game\Systems - - - Game\Components - - - Base\Components - - - Base\Components - - - GUI - - - Gameplay\Events - - - Game\Events - - - Game\Components - - - Game\Components - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From 70960c9eba585d896956cffc0b5b47b898216f38 Mon Sep 17 00:00:00 2001 From: ViktorLjung Date: Wed, 4 Jun 2014 15:43:20 +0200 Subject: [PATCH 2/6] Jeep working --- assets | 2 +- src/GameWorld.cpp | 113 ++++++++++++++++++++++++++-- src/Physics/VehicleSetup.cpp | 2 +- src/Systems/JeepSteeringSystem.cpp | 114 +++++++++++++++++++---------- src/Systems/TankSteeringSystem.cpp | 4 +- 5 files changed, 186 insertions(+), 49 deletions(-) diff --git a/assets b/assets index e09ebf5..cb920fb 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit e09ebf5a29f007cb8ee884f48dc600926f0665bc +Subproject commit cb920fb0deaa4214d111e62d00d97b674ee4c207 diff --git a/src/GameWorld.cpp b/src/GameWorld.cpp index aa182bc..9e25c5e 100755 --- a/src/GameWorld.cpp +++ b/src/GameWorld.cpp @@ -43,6 +43,8 @@ void GameWorld::Initialize() BindKey(GLFW_KEY_Z, "shoot", 1.f); BindGamepadAxis(Gamepad::Axis::RightTrigger, "shoot", 1.f); + BindGamepadAxis(Gamepad::Axis::RightTrigger, "jeep_vertical", 1.f); + BindGamepadAxis(Gamepad::Axis::LeftTrigger, "jeep_vertical", -1.f); BindKey(GLFW_KEY_X, "use", 1.f); BindGamepadButton(Gamepad::Button::X, "use", 1.f); @@ -1011,14 +1013,69 @@ void GameWorld::CreateBase(glm::quat orientation, int playerID) { auto shape = CreateEntity(bridge_middle); - auto transformshape = AddComponent(shape); - auto meshShape = AddComponent(shape); - meshShape->ResourceName = "Models/TerrainFiveIstles/Bridges/MiddleBridgeCollision.obj"; + auto transform = AddComponent(shape); + transform->Position = glm::vec3(70.31883f, 26.42735f, 0.50379f); + auto box = AddComponent(shape); + box->Width = 26.324f; + box->Height = 2.727f; + box->Depth = 6.798f; + CommitEntity(shape); + } + { + auto shape = CreateEntity(bridge_middle); + auto transform = AddComponent(shape); + transform->Position = glm::vec3(70.43447f, 29.23594f, 7.37155f); + auto box = AddComponent(shape); + box->Width = 27.724f; + box->Height = 1.334f; + box->Depth = 0.571f; + CommitEntity(shape); + } + { + auto shape = CreateEntity(bridge_middle); + auto transform = AddComponent(shape); + transform->Position = glm::vec3(70.43447f, 29.26906f, -6.68171f); + auto box = AddComponent(shape); + box->Width = 27.724f; + box->Height = 1.334f; + box->Depth = 0.571f; + CommitEntity(shape); + } + { + auto shape = CreateEntity(bridge_middle); + auto transform = AddComponent(shape); + transform->Position = glm::vec3(70.36976f, 33.56011f, 9.68543f); + auto box = AddComponent(shape); + box->Width = 1.8f; + box->Height = 15.984f; + box->Depth = 1.456f; + CommitEntity(shape); + } + { + auto shape = CreateEntity(bridge_middle); + auto transform = AddComponent(shape); + transform->Position = glm::vec3(70.36976f, 33.56011f, -8.67785f); + auto box = AddComponent(shape); + box->Width = 1.799f; + box->Height = 15.983f; + box->Depth = 1.456f; + CommitEntity(shape); + } + { + auto shape = CreateEntity(bridge_middle); + auto transform = AddComponent(shape); + transform->Position = glm::vec3(99.16043f, 25.0318f, 0.54486f); + transform->Orientation = glm::angleAxis(glm::radians(-9.087f), glm::vec3(0, 0, 1)); + auto box = AddComponent(shape); + box->Width = 3.566f; + box->Height = 3.566f; + box->Depth = 7.632f; CommitEntity(shape); } CommitEntity(bridge_middle); } + { auto terrain_base = CreateEntity(base); auto transform = AddComponent(terrain_base); @@ -1099,11 +1156,55 @@ void GameWorld::CreateBase(glm::quat orientation, int playerID) { auto shape = CreateEntity(bridge_base); - auto transformshape = AddComponent(shape); - auto meshShape = AddComponent(shape); - meshShape->ResourceName = "Models/TerrainFiveIstles/Bridges/BaseBridge.obj"; + auto transform = AddComponent(shape); + transform->Position = glm::vec3(166.19089f, 25.99645f, -0.50379f); + auto box = AddComponent(shape); + box->Width = 27.723f; + box->Height = 2.727f; + box->Depth = 6.798f; CommitEntity(shape); } + { + auto shape = CreateEntity(bridge_base); + auto transform = AddComponent(shape); + transform->Position = glm::vec3(166.19089f, 28.37571f, -6.68171f); + auto box = AddComponent(shape); + box->Width = 27.724f; + box->Height = 1.334f; + box->Depth = 0.571f; + CommitEntity(shape); + } + { + auto shape = CreateEntity(bridge_base); + auto transform = AddComponent(shape); + transform->Position = glm::vec3(166.19089f, 28.37571f, 7.68929f); + auto box = AddComponent(shape); + box->Width = 27.724f; + box->Height = 1.334f; + box->Depth = 0.571f; + CommitEntity(shape); + } + { + auto shape = CreateEntity(bridge_base); + auto transform = AddComponent(shape); + transform->Position = glm::vec3(166.12617f, 33.56011f, -8.67785f); + auto box = AddComponent(shape); + box->Width = 1.8; + box->Height = 15.984f; + box->Depth = 1.456f; + CommitEntity(shape); + } + { + auto shape = CreateEntity(bridge_base); + auto transform = AddComponent(shape); + transform->Position = glm::vec3(166.12617f, 33.56011f, 9.68543f); + auto box = AddComponent(shape); + box->Width = 1.8; + box->Height = 15.984f; + box->Depth = 1.456f; + CommitEntity(shape); + } + CommitEntity(bridge_base); } #pragma endregion Terrain diff --git a/src/Physics/VehicleSetup.cpp b/src/Physics/VehicleSetup.cpp index 893ced8..d06f4ba 100644 --- a/src/Physics/VehicleSetup.cpp +++ b/src/Physics/VehicleSetup.cpp @@ -114,7 +114,7 @@ void VehicleSetup::setupVehicleData(const hkpWorld* world, hkpVehicleData& data data.m_chassisUnitInertiaYaw = 0.8f; data.m_chassisUnitInertiaRoll = 1.0f; - data.m_chassisUnitInertiaPitch = 1.0f; + data.m_chassisUnitInertiaPitch = 2.0f; // Adds or removes torque around the yaw axis // based on the current steering angle. This will diff --git a/src/Systems/JeepSteeringSystem.cpp b/src/Systems/JeepSteeringSystem.cpp index d5c501b..62f2705 100644 --- a/src/Systems/JeepSteeringSystem.cpp +++ b/src/Systems/JeepSteeringSystem.cpp @@ -51,7 +51,7 @@ void Systems::JeepSteeringSystem::UpdateEntity(double dt, EntityID entity, Entit bool Systems::JeepSteeringSystem::OnSpawnVehicle(const Events::SpawnVehicle &event) { - + if (event.VehicleType != "Jeep") return false; @@ -62,21 +62,21 @@ bool Systems::JeepSteeringSystem::OnSpawnVehicle(const Events::SpawnVehicle &eve return false; } - for (auto &spawnPointComponent : *spawnPointComponents) + for (auto &component : *spawnPointComponents) { - auto spawnPoint = spawnPointComponent->Entity; - auto spawnPointBaseParent = m_World->GetEntityBaseParent(spawnPoint); - auto playerComponent = m_World->GetComponent(spawnPointBaseParent); + auto spawnPoint = component->Entity; + auto spawnPointComponent = std::dynamic_pointer_cast(component); + auto playerComponent = m_World->GetComponent(spawnPointComponent->Player); if (!playerComponent || playerComponent->ID != event.PlayerID) continue; - + Components::Transform absoluteTransform = m_World->GetSystem()->AbsoluteTransform(spawnPoint); - // Create a tank + // Create a Jeep EntityID Jeep = CreateJeep(event.PlayerID); auto tankTransform = m_World->GetComponent(Jeep); - tankTransform->Position = glm::vec3(0, 50, 0);//absoluteTransform.Position; -// tankTransform->Orientation = absoluteTransform.Orientation; + tankTransform->Position = absoluteTransform.Position; + tankTransform->Orientation = absoluteTransform.Orientation; // Set the viewport correctly Events::SetViewportCamera e; e.CameraEntity = m_World->GetProperty(Jeep, "Camera"); @@ -97,19 +97,20 @@ EntityID Systems::JeepSteeringSystem::CreateJeep(int playerID) transform->Position = glm::vec3(0, 5, 0); //transform->Orientation = glm::angleAxis(0.f, glm::vec3(0, 1, 0)); auto physics = m_World->AddComponent(jeep); - physics->Mass = 1600; + physics->Mass = 2000; physics->MotionType = Components::Physics::MotionTypeEnum::Dynamic; + physics->CenterOfMass = glm::vec3(0, 0, 0); auto vehicle = m_World->AddComponent(jeep); - vehicle->MaxTorque = 400.f; - vehicle->MaxSteeringAngle = 50.f; - vehicle->MaxSpeedFullSteeringAngle = 20.f; + vehicle->MaxTorque = 500.0f; + vehicle->MaxSteeringAngle = 40.f; + vehicle->MaxSpeedFullSteeringAngle = 12.f; vehicle->MinRPM = 1000.0f; - vehicle->OptimalRPM = 4000.0f, - vehicle->MaxRPM = 6000.0f; + vehicle->OptimalRPM = 5500.0f, + vehicle->MaxRPM = 7500.0f; vehicle->TopSpeed = 90.0f; - vehicle->SpringDamping = 1.f; - vehicle->UpshiftRPM = 5500.0f; - vehicle->DownshiftRPM = 1500.0f; + vehicle->SpringDamping = 5.f; + vehicle->UpshiftRPM = 6500.0f; + vehicle->DownshiftRPM = 3500.0f; vehicle->gearsRatio0 = 3.0f; vehicle->gearsRatio1 = 2.25f; vehicle->gearsRatio2 = 1.5f; @@ -117,19 +118,18 @@ EntityID Systems::JeepSteeringSystem::CreateJeep(int playerID) auto player = m_World->AddComponent(jeep); player->ID = playerID; - auto tankSteering = m_World->AddComponent(jeep); + auto jeepSteering = m_World->AddComponent(jeep); m_World->AddComponent(jeep); auto health = m_World->AddComponent(jeep); health->Amount = 100.f; - { + /*{ auto shape = m_World->CreateEntity(jeep); auto transform = m_World->AddComponent(shape); auto meshShape = m_World->AddComponent(shape); meshShape->ResourceName = "Models/Jeep/Chassi/ChassiCollision.obj"; m_World->CommitEntity(shape); - } - + }*/ { auto chassis = m_World->CreateEntity(jeep); auto transform = m_World->AddComponent(chassis); @@ -138,6 +138,47 @@ EntityID Systems::JeepSteeringSystem::CreateJeep(int playerID) model->ModelFile = "Models/Jeep/Chassi/Chassi.OBJ"; } + + { + auto shape = m_World->CreateEntity(jeep); + auto transform = m_World->AddComponent(shape); + transform->Position = glm::vec3(-0.0219f ,0.88937f, -0.48469f); + auto box = m_World->AddComponent(shape); + box->Width = 0.993f; + box->Height = 0.626f; + box->Depth = 1.316f; + m_World->CommitEntity(shape); + } + { + auto shape = m_World->CreateEntity(jeep); + auto transform = m_World->AddComponent(shape); + transform->Position = glm::vec3(-0.02551f ,0.55419f, 1.78935f); + auto box = m_World->AddComponent(shape); + box->Width = 0.849f; + box->Height = 0.415f; + box->Depth = 1.058f; + m_World->CommitEntity(shape); + } + { + auto shape = m_World->CreateEntity(jeep); + auto transform = m_World->AddComponent(shape); + transform->Position = glm::vec3(-1.63274f ,0.98825f, -0.89907f); + auto box = m_World->AddComponent(shape); + box->Width = 0.697f; + box->Height = 0.401f; + box->Depth = 0.868f; + m_World->CommitEntity(shape); + } + { + auto shape = m_World->CreateEntity(jeep); + auto transform = m_World->AddComponent(shape); + transform->Position = glm::vec3(1.63274f ,0.98825f, -0.89907f); + auto box = m_World->AddComponent(shape); + box->Width = 0.697f; + box->Height = 0.401f; + box->Depth = 0.868f; + m_World->CommitEntity(shape); + } auto cameraTower = m_World->CreateEntity(jeep); { @@ -150,11 +191,6 @@ EntityID Systems::JeepSteeringSystem::CreateJeep(int playerID) m_World->SetProperty(jeep, "Camera", cameraTower); } - - - - - #pragma region Wheels //Create wheels float wheelOffset = 0.f;//-0.83f; @@ -198,9 +234,9 @@ EntityID Systems::JeepSteeringSystem::CreateJeep(int playerID) void Systems::JeepSteeringSystem::AddJeepWheels(EntityID jeepEntity) { //Create wheels - float wheelOffset = 0.4f; - float springLength = 0.3f; - float suspensionStrength = 45.f; + float wheelOffset = 0.5f; + float springLength = 0.2f; + float suspensionStrength = 35.f; { auto wheel = m_World->CreateEntity(jeepEntity); auto transform = m_World->AddComponent(wheel); @@ -215,7 +251,7 @@ void Systems::JeepSteeringSystem::AddJeepWheels(EntityID jeepEntity) Wheel->Radius = 0.837f; Wheel->Steering = true; Wheel->SuspensionStrength = suspensionStrength; - Wheel->Friction = 4.f; + Wheel->Friction = 2.5f; Wheel->ConnectedToHandbrake = true; m_World->CommitEntity(wheel); } @@ -235,7 +271,7 @@ void Systems::JeepSteeringSystem::AddJeepWheels(EntityID jeepEntity) Wheel->Radius = 0.837f; Wheel->Steering = true; Wheel->SuspensionStrength = suspensionStrength; - Wheel->Friction = 4.f; + Wheel->Friction = 2.5f; Wheel->ConnectedToHandbrake = true; m_World->CommitEntity(wheel); } @@ -243,17 +279,17 @@ void Systems::JeepSteeringSystem::AddJeepWheels(EntityID jeepEntity) { auto wheel = m_World->CreateEntity(jeepEntity); auto transform = m_World->AddComponent(wheel); - transform->Position = glm::vec3(0.2726f, 0.2805f - wheelOffset, 1.9307f); + transform->Position = glm::vec3(0.2726f, 0.2805f - (wheelOffset/2), 1.9307f); auto model = m_World->AddComponent(wheel); model->ModelFile = "Models/Jeep/WheelBack/wheelBack.obj"; auto Wheel = m_World->AddComponent(wheel); Wheel->Hardpoint = transform->Position + glm::vec3(0.f, springLength, 0.f); Wheel->AxleID = 1; - Wheel->Mass = 50; + Wheel->Mass = 150; Wheel->Radius = 0.737f; Wheel->Steering = false; Wheel->SuspensionStrength = suspensionStrength; - Wheel->Friction = 4.f; + Wheel->Friction = 2.5f; Wheel->ConnectedToHandbrake = true; m_World->CommitEntity(wheel); } @@ -261,18 +297,18 @@ void Systems::JeepSteeringSystem::AddJeepWheels(EntityID jeepEntity) { auto wheel = m_World->CreateEntity(jeepEntity); auto transform = m_World->AddComponent(wheel); - transform->Position = glm::vec3(-0.2726f, 0.2805f - wheelOffset, 1.9307f); + transform->Position = glm::vec3(-0.2726f, 0.2805f - (wheelOffset/2), 1.9307f); transform->Orientation = glm::angleAxis(glm::pi(), glm::vec3(0, 0, 1)); auto model = m_World->AddComponent(wheel); model->ModelFile = "Models/Jeep/WheelBack/wheelBack.obj"; auto Wheel = m_World->AddComponent(wheel); Wheel->Hardpoint = transform->Position + glm::vec3(0.f, springLength, 0.f); Wheel->AxleID = 1; - Wheel->Mass = 50; + Wheel->Mass = 150; Wheel->Radius = 0.737f; Wheel->Steering = false; Wheel->SuspensionStrength = suspensionStrength; - Wheel->Friction = 4.f; + Wheel->Friction = 2.5f; Wheel->ConnectedToHandbrake = true; m_World->CommitEntity(wheel); } @@ -298,7 +334,7 @@ bool Systems::JeepSteeringSystem::JeepSteeringInputController::OnCommand(const E { m_Horizontal = val; } - else if (event.Command == "vertical") + else if (event.Command == "jeep_vertical") { m_Vertical = -val; } diff --git a/src/Systems/TankSteeringSystem.cpp b/src/Systems/TankSteeringSystem.cpp index edc92c8..f1c9caa 100644 --- a/src/Systems/TankSteeringSystem.cpp +++ b/src/Systems/TankSteeringSystem.cpp @@ -365,8 +365,8 @@ bool Systems::TankSteeringSystem::OnSpawnVehicle(const Events::SpawnVehicle &eve // Create a tank EntityID tank = CreateTank(event.PlayerID); auto tankTransform = m_World->GetComponent(tank); - tankTransform->Position = glm::vec3(0, 50, 0);//absoluteTransform.Position; -// tankTransform->Orientation = absoluteTransform.Orientation; + tankTransform->Position = absoluteTransform.Position; + tankTransform->Orientation = absoluteTransform.Orientation; // Set the viewport correctly Events::SetViewportCamera e; e.CameraEntity = m_World->GetProperty(tank, "Camera"); From 5f1feffe0da22f9172a32dc8008065f29ca4ded4 Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Wed, 4 Jun 2014 16:59:30 +0200 Subject: [PATCH 3/6] Main menu finished --- assets | 2 +- src/Events/FlagCaptured.h | 15 +++ src/Events/FlagDropped.h | 15 +++ src/Events/FlagPickup.h | 15 +++ src/Events/FlagReturned.h | 15 +++ src/Events/GameOver.h | 15 +++ src/Events/GameStart.h | 15 +++ src/GUI/Frame.h | 60 ++++++++--- src/GUI/GameFrame.h | 46 ++++++-- src/GUI/GameOverFrame.h | 41 +++++++ src/GUI/MainMenuFrame.h | 100 ++++++++++++++++++ src/GUI/PlayerHUD.h | 48 +++++++++ src/GUI/VehicleSelection.h | 13 ++- src/GUI/WorldFrame.h | 2 +- src/InputController.h | 40 ++++++- src/Model.cpp | 2 +- src/Systems/GameStateSystem.cpp | 19 ++++ src/Systems/GameStateSystem.h | 37 +++++++ src/Systems/TankSteeringSystem.h | 1 + vs11/Returngeance/Returngeance.vcxproj | 10 ++ .../Returngeance/Returngeance.vcxproj.filters | 40 +++++-- 21 files changed, 506 insertions(+), 45 deletions(-) create mode 100644 src/Events/FlagCaptured.h create mode 100644 src/Events/FlagDropped.h create mode 100644 src/Events/FlagPickup.h create mode 100644 src/Events/FlagReturned.h create mode 100644 src/Events/GameOver.h create mode 100644 src/Events/GameStart.h create mode 100644 src/GUI/GameOverFrame.h create mode 100644 src/GUI/MainMenuFrame.h create mode 100644 src/Systems/GameStateSystem.cpp create mode 100644 src/Systems/GameStateSystem.h diff --git a/assets b/assets index e09ebf5..26839b6 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit e09ebf5a29f007cb8ee884f48dc600926f0665bc +Subproject commit 26839b66e2dd3e867332fde0bd20ec138a2a0247 diff --git a/src/Events/FlagCaptured.h b/src/Events/FlagCaptured.h new file mode 100644 index 0000000..fbb0a85 --- /dev/null +++ b/src/Events/FlagCaptured.h @@ -0,0 +1,15 @@ +#ifndef Events_FlagCaptured_h__ +#define Events_FlagCaptured_h__ + +#include "Entity.h" +#include "EventBroker.h" + +namespace Events +{ + struct FlagCaptured : Event + { + EntityID Player; + }; +} + +#endif // Events_FlagCaptured_h__ \ No newline at end of file diff --git a/src/Events/FlagDropped.h b/src/Events/FlagDropped.h new file mode 100644 index 0000000..eee5bbf --- /dev/null +++ b/src/Events/FlagDropped.h @@ -0,0 +1,15 @@ +#ifndef Events_FlagDropped_h__ +#define Events_FlagDropped_h__ + +#include "Entity.h" +#include "EventBroker.h" + +namespace Events +{ + struct FlagDropped : Event + { + EntityID Player; + }; +} + +#endif // Events_FlagDropped_h__ \ No newline at end of file diff --git a/src/Events/FlagPickup.h b/src/Events/FlagPickup.h new file mode 100644 index 0000000..d1ad727 --- /dev/null +++ b/src/Events/FlagPickup.h @@ -0,0 +1,15 @@ +#ifndef Events_FlagPickup_h__ +#define Events_FlagPickup_h__ + +#include "Entity.h" +#include "EventBroker.h" + +namespace Events +{ + struct FlagPickup : Event + { + EntityID Player; + }; +} + +#endif // Events_FlagPickup_h__ \ No newline at end of file diff --git a/src/Events/FlagReturned.h b/src/Events/FlagReturned.h new file mode 100644 index 0000000..9bdc55e --- /dev/null +++ b/src/Events/FlagReturned.h @@ -0,0 +1,15 @@ +#ifndef Events_FlagReturned_h__ +#define Events_FlagReturned_h__ + +#include "Entity.h" +#include "EventBroker.h" + +namespace Events +{ + struct FlagReturned : Event + { + EntityID Player; + }; +} + +#endif // Events_FlagReturned_h__ \ No newline at end of file diff --git a/src/Events/GameOver.h b/src/Events/GameOver.h new file mode 100644 index 0000000..b544954 --- /dev/null +++ b/src/Events/GameOver.h @@ -0,0 +1,15 @@ +#ifndef Events_GameOver_h__ +#define Events_GameOver_h__ + +#include "Entity.h" +#include "EventBroker.h" + +namespace Events +{ + struct GameOver : Event + { + EntityID Winner; + }; +} + +#endif // Events_GameOver_h__ \ No newline at end of file diff --git a/src/Events/GameStart.h b/src/Events/GameStart.h new file mode 100644 index 0000000..3d54dd1 --- /dev/null +++ b/src/Events/GameStart.h @@ -0,0 +1,15 @@ +#ifndef Events_GameStart_h__ +#define Events_GameStart_h__ + +#include "Entity.h" +#include "EventBroker.h" + +namespace Events +{ + struct GameStart : Event + { + + }; +} + +#endif // Events_GameStart_h__ \ No newline at end of file diff --git a/src/GUI/Frame.h b/src/GUI/Frame.h index ba99851..ae28f1f 100644 --- a/src/GUI/Frame.h +++ b/src/GUI/Frame.h @@ -36,6 +36,7 @@ public: : EventBroker(eventBroker) , ResourceManager(resourceManager) , Rectangle() + , m_Parent(nullptr) , m_Name("UIParent") , m_Layer(0) , m_Hidden(false) @@ -46,12 +47,28 @@ public: : m_Name(name) , m_Layer(0) , m_Hidden(false) - { SetParent(std::shared_ptr(parent)); Initialize(); } + { SetParent(parent); Initialize(); } + + ~Frame() + { + /*for (auto layer : m_Children) + { + for (auto child : layer.second) + { + delete child.second; + } + } + + if (m_Parent) + { + m_Parent->RemoveChild(this); + }*/ + } ::RenderQueuePair RenderQueue; - std::shared_ptr Parent() const { return m_Parent; } - void SetParent(std::shared_ptr parent) + Frame* Parent() const { return m_Parent; } + void SetParent(Frame* parent) { if (parent == nullptr) { @@ -62,13 +79,13 @@ public: Width = parent->Width; Height = parent->Height; m_Layer = parent->Layer() + 1; - parent->AddChild(std::shared_ptr(this)); + parent->AddChild(this); m_Parent = parent; EventBroker = parent->EventBroker; ResourceManager = parent->ResourceManager; } - void AddChild(std::shared_ptr child) + void AddChild(Frame* child) { m_Children[child->m_Layer].insert(std::make_pair(child->Name(), child)); if (m_Parent) @@ -77,7 +94,19 @@ public: } } - typedef std::map>::const_iterator FrameChildrenIterator; + void RemoveChild(Frame* child) + { + auto it = m_Children.find(child->m_Layer); + if (it != m_Children.end()) + { + m_Children.erase(it); + } + + if (m_Parent) + { + m_Parent->RemoveChild(child); + } + } std::string Name() const { return m_Name; } void SetName(std::string val) { m_Name = val; } @@ -89,8 +118,14 @@ public: else return m_Hidden; } - void Hide() { m_Hidden = true; } - void Show() { m_Hidden = false; } + + bool Visible() const + { + return !Hidden(); + } + + virtual void Hide() { m_Hidden = true; } + virtual void Show() { m_Hidden = false; } int Left() const override { @@ -144,9 +179,6 @@ public: void UpdateLayered(double dt) { - if (this->Hidden()) - return; - // Update ourselves this->Update(dt); @@ -157,8 +189,6 @@ public: for (auto &pairChild : children) { auto child = pairChild.second; - if (child->Hidden()) - continue; child->Update(dt); } } @@ -200,8 +230,8 @@ protected: int m_Layer; bool m_Hidden; - std::shared_ptr m_Parent; - typedef std::multimap> Children_t; // name -> frame + Frame* m_Parent; + typedef std::multimap Children_t; // name -> frame std::map m_Children; // layer -> Children_t virtual bool OnKeyDown(const Events::KeyDown &event) { return false; } diff --git a/src/GUI/GameFrame.h b/src/GUI/GameFrame.h index b0d446a..4f66f6d 100644 --- a/src/GUI/GameFrame.h +++ b/src/GUI/GameFrame.h @@ -2,13 +2,15 @@ #define GUI_GameFrame_h__ #include "GUI/Frame.h" +#include "GUI/MainMenuFrame.h" #include "GUI/WorldFrame.h" #include "GUI/Viewport.h" #include "GUI/TextureFrame.h" #include "GUI/PlayerHUD.h" -#include "VehicleSelection.h" #include "GameWorld.h" +#include "Events/GameStart.h" +#include "Events/GameOver.h" namespace GUI { @@ -18,37 +20,59 @@ class GameFrame : public Frame public: GameFrame(Frame* parent, std::string name) : Frame(parent, name) + , m_GameOver(false) { + EVENT_SUBSCRIBE_MEMBER(m_EGameStart, &GUI::GameFrame::OnGameStart); + EVENT_SUBSCRIBE_MEMBER(m_EGameOver, &GUI::GameFrame::OnGameOver); + m_World = std::make_shared(EventBroker, ResourceManager); - auto worldFrame = new WorldFrame(this, "GameWorldFrame", m_World); + m_WorldFrame = new WorldFrame(this, "GameWorldFrame", m_World); { - vp1 = new Viewport(worldFrame, "Viewport1", m_World); + vp1 = new Viewport(m_WorldFrame, "Viewport1", m_World); vp1->X = 0; vp1->Width = this->Width / 2.f; - //new PlayerHUD(vp1, "PlayerHUD", m_World, 1); - new VehicleSelection(vp1, "VehicleSelection", m_World, 1); + new PlayerHUD(vp1, "PlayerHUD", m_World, 1); - vp2 = new Viewport(worldFrame, "Viewport2", m_World); + vp2 = new Viewport(m_WorldFrame, "Viewport2", m_World); vp2->X = vp1->Right(); vp2->Width = this->Width / 2.f; - //new PlayerHUD(vp2, "PlayerHUD", m_World, 2); - new VehicleSelection(vp2, "VehicleSelection", m_World, 2); + new PlayerHUD(vp2, "PlayerHUD", m_World, 2); - - m_FreeCamViewport = new Viewport(worldFrame, "ViewportFreeCam", m_World); + m_FreeCamViewport = new Viewport(m_WorldFrame, "ViewportFreeCam", m_World); m_FreeCamViewport->Hide(); } + m_WorldFrame->Hide(); + m_MainMenuFrame = new MainMenuFrame(this, "MainMenu"); + m_World->Initialize(); } private: - EventRelay m_EKeyUp; + EventRelay m_EGameStart; + bool OnGameStart(const Events::GameStart &event) + { + m_WorldFrame->Show(); + + return true; + } + EventRelay m_EGameOver; + bool OnGameOver(const Events::GameOver &event) + { + m_GameOver = true; + + return true; + } std::shared_ptr m_World; + + MainMenuFrame* m_MainMenuFrame; + WorldFrame* m_WorldFrame; Viewport* vp1; Viewport* vp2; Viewport* m_FreeCamViewport; + bool m_GameOver; + bool OnKeyUp(const Events::KeyUp &event) override { if (event.KeyCode == GLFW_KEY_1) diff --git a/src/GUI/GameOverFrame.h b/src/GUI/GameOverFrame.h new file mode 100644 index 0000000..7d943fd --- /dev/null +++ b/src/GUI/GameOverFrame.h @@ -0,0 +1,41 @@ +#ifndef GUI_GameOverFrame_h__ +#define GUI_GameOverFrame_h__ + +#include "GUI/Frame.h" +#include "GUI/HealthOverlay.h" + +namespace GUI +{ + + class GameOverFrame : public Frame + { + public: + GameOverFrame(Frame* parent, std::string name) + : Frame(parent, name) + { + //Hide(); + m_Background = new TextureFrame(this, "Background"); + m_Background->SetTexture("Textures/GUI/black.png"); + m_Background->SetColor(glm::vec4(1.f, 1.f, 1.f, 0.6f)); + m_Text = new TextureFrame(this, "Message"); + m_Text->SetTexture("Textures/GUI/GloriousVictory.png"); + } + + void Show(bool victory) + { + if (victory) + m_Text->SetTexture("Textures/GUI/GloriousVictory.png"); + else + m_Text->SetTexture("Textures/GUI/ShamefulDefeat.png"); + + Frame::Show(); + } + + protected: + bool m_Victory; + TextureFrame* m_Background; + TextureFrame* m_Text; + }; +} + +#endif // GUI_GameOverFrame_h__ diff --git a/src/GUI/MainMenuFrame.h b/src/GUI/MainMenuFrame.h new file mode 100644 index 0000000..ff43254 --- /dev/null +++ b/src/GUI/MainMenuFrame.h @@ -0,0 +1,100 @@ +#ifndef GUI_MainMenuFrame_h__ +#define GUI_MainMenuFrame_h__ + +#include "GUI/Frame.h" +#include "GUI/HealthOverlay.h" + +#include "Events/GameStart.h" + +namespace GUI +{ + +class MainMenuFrame : public Frame +{ +public: + MainMenuFrame(Frame* parent, std::string name) + : Frame(parent, name) + { + m_CurrentSelection = 0; + + //Hide(); + m_Background = new TextureFrame(this, "Background"); + m_Background->SetTexture("Textures/GUI/MainMenu/BackGround.png"); + + m_Buttons = new TextureFrame(this, "Message"); + m_Buttons->SetTexture("Textures/GUI/MainMenu/Buttons.png"); + m_CurrentCoordinate = -m_SelectionCoordinates[0] * Scale(); + m_TargetCoordinate = m_CurrentCoordinate; + m_Buttons->X = m_CurrentCoordinate.x; + m_Buttons->Y = m_CurrentCoordinate.y; + } + + void Update(double dt) override + { + if (Hidden()) + return; + + glm::vec2 posDiff = m_TargetCoordinate - m_CurrentCoordinate; + m_CurrentCoordinate += posDiff * 4.f * (float)dt; + + m_Buttons->X = m_CurrentCoordinate.x; + m_Buttons->Y = m_CurrentCoordinate.y; + } + +protected: + bool m_Victory; + TextureFrame* m_Background; + TextureFrame* m_Buttons; + + int m_CurrentSelection; + static glm::vec2 m_SelectionCoordinates[2]; + glm::vec2 m_CurrentCoordinate; + glm::vec2 m_TargetCoordinate; + + bool OnCommand(const Events::InputCommand &event) override + { + if (Hidden()) + return false; + + const float deadzone = 0.5f; + + if (event.Command == "interface_horizontal") + { + if (event.Value > deadzone) + m_CurrentSelection++; + else if (event.Value < -deadzone) + m_CurrentSelection--; + } + m_CurrentSelection = (m_CurrentSelection < 0) ? 0 : ((m_CurrentSelection > 1) ? 1 : m_CurrentSelection); + m_TargetCoordinate = -m_SelectionCoordinates[m_CurrentSelection] * Scale(); + + if (event.Command == "interface_confirm" && event.Value > 0) + { + // Play + if (m_CurrentSelection == 0) + { + Hide(); + Events::GameStart e; + EventBroker->Publish(e); + } + // Quit + else if (m_CurrentSelection == 1) + { + exit(EXIT_SUCCESS); + } + } + + return false; + } + + +}; + +glm::vec2 MainMenuFrame::m_SelectionCoordinates[2] = { + glm::vec2(0, 0), + glm::vec2(193, 0), +}; + +} + +#endif // GUI_MainMenuFrame_h__ diff --git a/src/GUI/PlayerHUD.h b/src/GUI/PlayerHUD.h index 7ea4dda..63aaf14 100644 --- a/src/GUI/PlayerHUD.h +++ b/src/GUI/PlayerHUD.h @@ -3,6 +3,11 @@ #include "GUI/Frame.h" #include "GUI/HealthOverlay.h" +#include "GUI/VehicleSelection.h" +#include "GUI/GameOverFrame.h" + +#include "Events/GameOver.h" +#include "Components/Player.h" namespace GUI { @@ -15,7 +20,10 @@ namespace GUI , m_World(world) , m_PlayerID(playerID) { + EVENT_SUBSCRIBE_MEMBER(m_EGameOver, &GUI::PlayerHUD::OnGameOver) + m_HealthOverlay = new HealthOverlay(this, "HealthOverlay", m_World, m_PlayerID); + m_Crosshair = new TextureFrame(this, "Crosshair"); m_Crosshair->Width = 45; m_Crosshair->Height = 45; @@ -23,6 +31,10 @@ namespace GUI m_Crosshair->Y = this->Height / 2.f - m_Crosshair->Height / 2.f; m_Crosshair->SetTexture("Textures/GUI/crosshair.png"); m_Crosshair->SetColor(glm::vec4(1.f, 1.f, 1.f, 0.75f)); + + m_VehicleSelection = new VehicleSelection(this, "VehicleSelection", m_World, m_PlayerID); + + m_GameOverFrame = new GameOverFrame(this, "GameOver"); } protected: @@ -31,6 +43,42 @@ namespace GUI HealthOverlay* m_HealthOverlay; TextureFrame* m_Crosshair; + VehicleSelection* m_VehicleSelection; + GameOverFrame* m_GameOverFrame; + + EventRelay m_EGameOver; + bool OnGameOver(const Events::GameOver &event) + { + auto playerComponent = m_World->GetComponent(event.Winner); + if (!playerComponent) + { + LOG_ERROR("Winner is not a valid player!"); + return false; + } + + if (m_PlayerID == playerComponent->ID) + m_GameOverFrame->Show(true); + else + m_GameOverFrame->Show(false); + + return true; + } + + bool OnCommand(const Events::InputCommand &event) + { + if (event.PlayerID != m_PlayerID) + return false; + + if (event.Command == "interface_confirm" && event.Value > 0) + { + if (m_GameOverFrame->Visible()) + { + m_GameOverFrame->Hide(); + } + } + + return true; + } }; } diff --git a/src/GUI/VehicleSelection.h b/src/GUI/VehicleSelection.h index 9a2ec18..add2122 100644 --- a/src/GUI/VehicleSelection.h +++ b/src/GUI/VehicleSelection.h @@ -40,6 +40,9 @@ namespace GUI void Update(double dt) override { + if (Hidden()) + return; + glm::vec2 posDiff = m_TargetCoordinate - m_CurrentCoordinate; m_CurrentCoordinate += posDiff * 2.f * (float)dt; @@ -77,28 +80,30 @@ namespace GUI if (event.PlayerID != m_PlayerID) return false; + const float deadzone = 0.5f; + // Menu movement if (event.Command == "interface_horizontal" || event.Command == "interface_vertical") { // Horizontal scrolling if (event.Command == "interface_horizontal") { - if (event.Value > 0) + if (event.Value > deadzone) m_CurrentSelection++; - else if (event.Value < 0) + else if (event.Value < -deadzone) m_CurrentSelection--; } // Vertical scrolling to switch between "rows" in an intuitive way else if (event.Command == "interface_vertical") { - if (event.Value > 0) + if (event.Value > deadzone) { if (m_CurrentSelection == 0) m_CurrentSelection++; else if (m_CurrentSelection == 3) m_CurrentSelection--; } - else if (event.Value < 0) + else if (event.Value < -deadzone) { if (m_CurrentSelection == 1) m_CurrentSelection--; diff --git a/src/GUI/WorldFrame.h b/src/GUI/WorldFrame.h index 03b9708..ca69fb1 100644 --- a/src/GUI/WorldFrame.h +++ b/src/GUI/WorldFrame.h @@ -145,7 +145,7 @@ private: auto itpair = m_Children[m_Layer + 1].equal_range(event.ViewportFrame); for (auto it = itpair.first; it != itpair.second; ++it) { - auto viewportFrame = std::dynamic_pointer_cast(it->second); + auto viewportFrame = dynamic_cast(it->second); if (!viewportFrame) continue; diff --git a/src/InputController.h b/src/InputController.h index 39c26b1..1f3fa81 100644 --- a/src/InputController.h +++ b/src/InputController.h @@ -6,29 +6,63 @@ #include "EventBroker.h" #include "Events/InputCommand.h" #include "Events/MouseMove.h" +#include "Events/GameStart.h" +#include "Events/GameOver.h" template class InputController { public: InputController(std::shared_ptr<::EventBroker> eventBroker) - : EventBroker(eventBroker) { Initialize(); } + : EventBroker(eventBroker) + , InGame(true) + { Initialize(); } virtual void Initialize() { - EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &InputController::OnCommand); - EVENT_SUBSCRIBE_MEMBER(m_EMouseMove, &InputController::OnMouseMove); + EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &InputController::_OnCommand); + EVENT_SUBSCRIBE_MEMBER(m_EMouseMove, &InputController::_OnMouseMove); + EVENT_SUBSCRIBE_MEMBER(m_EGameStart, &InputController::OnGameStart); + EVENT_SUBSCRIBE_MEMBER(m_EGameOver, &InputController::OnGameOver); } virtual bool OnCommand(const Events::InputCommand &event) { return false; } virtual bool OnMouseMove(const Events::MouseMove &event) { return false; } + virtual bool OnGameStart(const Events::GameStart &event) + { + InGame = true; + return true; + } + virtual bool OnGameOver(const Events::GameOver &event) + { + InGame = false; + return true; + } protected: std::shared_ptr<::EventBroker> EventBroker; + bool InGame; private: EventRelay m_EInputCommand; EventRelay m_EMouseMove; + EventRelay m_EGameStart; + EventRelay m_EGameOver; + + virtual bool _OnCommand(const Events::InputCommand &event) + { + if (InGame || event.Value == 0) + return OnCommand(event); + else + return false; + } + virtual bool _OnMouseMove(const Events::MouseMove &event) + { + if (InGame) + return OnMouseMove(event); + else + return false; + } }; #endif // InputController_h__ diff --git a/src/Model.cpp b/src/Model.cpp index 352c7f6..776e5a1 100755 --- a/src/Model.cpp +++ b/src/Model.cpp @@ -93,7 +93,7 @@ Model::Model(std::shared_ptr rm, OBJ &obj) if (Vertices.size() > 0) { CreateTangents(); - getSimilarVertexIndex(); + //getSimilarVertexIndex(); CreateBuffers(Vertices, Normals, TangentNormals, BiTangentNormals, TextureCoords); } else diff --git a/src/Systems/GameStateSystem.cpp b/src/Systems/GameStateSystem.cpp new file mode 100644 index 0000000..ca17bd3 --- /dev/null +++ b/src/Systems/GameStateSystem.cpp @@ -0,0 +1,19 @@ +#include "PrecompiledHeader.h" +#include "GameStateSystem.h" +#include "World.h" + +void Systems::GameStateSystem::Initialize() +{ + EVENT_SUBSCRIBE_MEMBER(m_EFlagCaptured, &Systems::GameStateSystem::OnFlagCaptured); +} + +bool Systems::GameStateSystem::OnFlagCaptured(const Events::FlagCaptured &event) +{ + m_InGame = false; + + Events::GameOver e; + e.Winner = event.Player; + EventBroker->Publish(e); + + return true; +} \ No newline at end of file diff --git a/src/Systems/GameStateSystem.h b/src/Systems/GameStateSystem.h new file mode 100644 index 0000000..ac9d46e --- /dev/null +++ b/src/Systems/GameStateSystem.h @@ -0,0 +1,37 @@ +#ifndef GameStateSystem_h__ +#define GameStateSystem_h__ + +#include + +#include "System.h" +#include "Components/Transform.h" +#include "Components/Player.h" +#include "Events/FlagCaptured.h" +#include "Events/GameOver.h" + +namespace Systems +{ + +class GameStateSystem : public System +{ +public: + + GameStateSystem(World* world, std::shared_ptr<::EventBroker> eventBroker, std::shared_ptr<::ResourceManager> resourceManager) + : System(world, eventBroker, resourceManager) + , m_InGame(true) + { } + + void Initialize() override; + + bool InGame() const { return m_InGame; } + +private: + bool m_InGame; + + EventRelay m_EFlagCaptured; + bool OnFlagCaptured(const Events::FlagCaptured &event); +}; + +} + +#endif // GameStateSystem_h__ diff --git a/src/Systems/TankSteeringSystem.h b/src/Systems/TankSteeringSystem.h index 3f2ee51..6b940b3 100644 --- a/src/Systems/TankSteeringSystem.h +++ b/src/Systems/TankSteeringSystem.h @@ -48,6 +48,7 @@ #include "Components/Input.h" #include "Events/SetViewportCamera.h" +#include "Events/GameOver.h" namespace Systems { diff --git a/vs11/Returngeance/Returngeance.vcxproj b/vs11/Returngeance/Returngeance.vcxproj index 4f89884..8329afb 100755 --- a/vs11/Returngeance/Returngeance.vcxproj +++ b/vs11/Returngeance/Returngeance.vcxproj @@ -113,6 +113,7 @@ + @@ -192,8 +193,14 @@ + + + + + + @@ -218,7 +225,9 @@ + + @@ -241,6 +250,7 @@ + diff --git a/vs11/Returngeance/Returngeance.vcxproj.filters b/vs11/Returngeance/Returngeance.vcxproj.filters index fed4ecf..f36ebe3 100755 --- a/vs11/Returngeance/Returngeance.vcxproj.filters +++ b/vs11/Returngeance/Returngeance.vcxproj.filters @@ -78,15 +78,14 @@ Game\Systems - - Gameplay\Systems - Game\Systems Audio + + @@ -526,9 +525,6 @@ Rendering\Components - - Gameplay\Systems - Physics\Events @@ -565,9 +561,6 @@ GUI - - Gameplay\Events - Game\Events @@ -577,6 +570,35 @@ Game\Components + + + + GUI + + + Game\Systems + + + Game\Events + + + Game\Events + + + Game\Events + + + Game\Events + + + Game\Events + + + GUI + + + Game\Events + From 8b2fc8615909d5fd10faf34e8d8fd6493c2d922d Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Wed, 4 Jun 2014 17:06:08 +0200 Subject: [PATCH 4/6] Main menu hidden for your debugging pleasure --- src/GUI/GameFrame.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/GUI/GameFrame.h b/src/GUI/GameFrame.h index 4f66f6d..56d0391 100644 --- a/src/GUI/GameFrame.h +++ b/src/GUI/GameFrame.h @@ -41,8 +41,8 @@ public: m_FreeCamViewport = new Viewport(m_WorldFrame, "ViewportFreeCam", m_World); m_FreeCamViewport->Hide(); } - m_WorldFrame->Hide(); - m_MainMenuFrame = new MainMenuFrame(this, "MainMenu"); + //m_WorldFrame->Hide(); + //m_MainMenuFrame = new MainMenuFrame(this, "MainMenu"); m_World->Initialize(); } From 1b20204897d142ffff1f38362f8dcff311cca56c Mon Sep 17 00:00:00 2001 From: ViktorLjung Date: Wed, 4 Jun 2014 18:12:58 +0200 Subject: [PATCH 5/6] Player/Team specific triggers --- src/Components/SpawnPoint.h | 2 - src/Components/Team.h | 18 +++ src/Components/Trigger.h | 1 + src/GameWorld.cpp | 149 +++--------------- src/GameWorld.h | 5 +- src/Systems/GarageSystem.cpp | 33 +++- src/Systems/GarageSystem.h | 1 + src/Systems/JeepSteeringSystem.cpp | 12 +- src/Systems/JeepSteeringSystem.h | 1 + src/Systems/TankSteeringSystem.cpp | 13 +- src/Systems/TankSteeringSystem.h | 1 + src/Systems/TriggerSystem.cpp | 21 ++- src/Systems/TriggerSystem.h | 1 + vs11/Returngeance/Returngeance.vcxproj | 1 + .../Returngeance/Returngeance.vcxproj.filters | 23 +-- 15 files changed, 127 insertions(+), 155 deletions(-) create mode 100644 src/Components/Team.h diff --git a/src/Components/SpawnPoint.h b/src/Components/SpawnPoint.h index 74aaaf9..c29230d 100644 --- a/src/Components/SpawnPoint.h +++ b/src/Components/SpawnPoint.h @@ -8,8 +8,6 @@ namespace Components struct SpawnPoint : Component { - EntityID Player; - virtual SpawnPoint* Clone() const override { return new SpawnPoint(*this); } }; diff --git a/src/Components/Team.h b/src/Components/Team.h new file mode 100644 index 0000000..6bbf105 --- /dev/null +++ b/src/Components/Team.h @@ -0,0 +1,18 @@ +#ifndef Components_Team_h__ +#define Components_Team_h__ + +#include "Component.h" +#include "Entity.h" + +namespace Components +{ + + struct Team : Component + { + unsigned int TeamID; + + virtual Team* Clone() const override { return new Team(*this); } + }; + +} +#endif // !Components_Team_h__ \ No newline at end of file diff --git a/src/Components/Trigger.h b/src/Components/Trigger.h index ec7cfc4..6373259 100644 --- a/src/Components/Trigger.h +++ b/src/Components/Trigger.h @@ -9,6 +9,7 @@ namespace Components struct Trigger : Component { bool TriggerOnce; + int TeamID; virtual Trigger* Clone() const override { return new Trigger(*this); } }; diff --git a/src/GameWorld.cpp b/src/GameWorld.cpp index c324f3d..d407693 100755 --- a/src/GameWorld.cpp +++ b/src/GameWorld.cpp @@ -421,6 +421,7 @@ void GameWorld::RegisterComponents() m_ComponentFactory.Register([]() { return new Components::Flag(); }); m_ComponentFactory.Register([]() { return new Components::Move(); }); m_ComponentFactory.Register([]() { return new Components::Rotate(); }); + m_ComponentFactory.Register([]() { return new Components::Team(); }); } void GameWorld::RegisterSystems() @@ -507,7 +508,7 @@ void GameWorld::BindGamepadButton(Gamepad::Button button, std::string command, f EventBroker->Publish(e); } -void GameWorld::CreateGate(EntityID parent, glm::vec3 position, glm::quat orientation) +void GameWorld::CreateGate(EntityID parent, glm::vec3 position, glm::quat orientation, int teamID) { auto gateParent = CreateEntity(parent); auto transform = AddComponent(gateParent); @@ -614,9 +615,11 @@ void GameWorld::CreateGate(EntityID parent, glm::vec3 position, glm::quat orient auto transform = AddComponent(gateTrigger); transform->Position = glm::vec3(0, 2.8241, 0); auto trigger = AddComponent(gateTrigger); + trigger->TeamID = teamID; auto triggerMove = AddComponent(gateTrigger); triggerMove->Entity = gate; - + auto teamComponent = AddComponent(gateTrigger); + teamComponent->TeamID = teamID; { auto shape = CreateEntity(gateTrigger); auto transform = AddComponent(shape); @@ -663,126 +666,6 @@ EntityID GameWorld::CreateWall(EntityID parent, glm::vec3 pos, glm::quat orienta } -EntityID GameWorld::CreateJeep(int playerID) -{ - auto jeep = CreateEntity(); - auto transform = AddComponent(jeep); - transform->Position = glm::vec3(0, 5, 0); - transform->Orientation = glm::angleAxis(glm::pi() / 2, glm::vec3(0, 1, 0)); - auto physics = AddComponent(jeep); - physics->Mass = 1800; - physics->MotionType = Components::Physics::MotionTypeEnum::Dynamic; - auto vehicle = AddComponent(jeep); - vehicle->DownshiftRPM = 3500.f; - vehicle->UpshiftRPM = 6000.f; - - AddComponent(jeep); - auto player = AddComponent(jeep); - player->ID = playerID; - auto health = AddComponent(jeep); - health->Amount = 100.f; - - { - auto shape = CreateEntity(jeep); - auto transform = AddComponent(shape); - auto meshShape = AddComponent(shape); - meshShape->ResourceName = "Models/Jeep/Chassi/ChassiCollision.obj"; - CommitEntity(shape); - } - - { - auto chassis = CreateEntity(jeep); - auto transform = AddComponent(chassis); - transform->Position = glm::vec3(0, 0, 0); // 0.6577f - auto model = AddComponent(chassis); - model->ModelFile = "Models/Jeep/Chassi/chassi.obj"; - } - - //Create wheels - float wheelOffset = 0.4f; - float springLength = 0.3f; - float suspensionStrength = 35.f; - { - auto wheel = CreateEntity(jeep); - auto transform = AddComponent(wheel); - transform->Position = glm::vec3(1.9f, 0.5546f - wheelOffset, -0.9242f); - transform->Scale = glm::vec3(1.0f); - auto model = AddComponent(wheel); - model->ModelFile = "Models/Jeep/WheelFront/wheelFront.obj"; - auto Wheel = AddComponent(wheel); - Wheel->Hardpoint = transform->Position + glm::vec3(0.f, springLength, 0.f); - Wheel->AxleID = 0; - Wheel->Mass = 50; - Wheel->Radius = 0.837f; - Wheel->Steering = true; - Wheel->SuspensionStrength = suspensionStrength; - Wheel->Friction = 4.f; - Wheel->ConnectedToHandbrake = true; - CommitEntity(wheel); - } - - { - auto wheel = CreateEntity(jeep); - auto transform = AddComponent(wheel); - transform->Position = glm::vec3(-1.9f, 0.5546f - wheelOffset, -0.9242f); - transform->Scale = glm::vec3(1.0f); - transform->Orientation = glm::angleAxis(glm::pi(), glm::vec3(0, 0, 1)); - auto model = AddComponent(wheel); - model->ModelFile = "Models/Jeep/WheelFront/wheelFront.obj"; - auto Wheel = AddComponent(wheel); - Wheel->Hardpoint = transform->Position + glm::vec3(0.f, springLength, 0.f); - Wheel->AxleID = 0; - Wheel->Mass = 50; - Wheel->Radius = 0.837f; - Wheel->Steering = true; - Wheel->SuspensionStrength = suspensionStrength; - Wheel->Friction = 4.f; - Wheel->ConnectedToHandbrake = true; - CommitEntity(wheel); - } - - { - auto wheel = CreateEntity(jeep); - auto transform = AddComponent(wheel); - transform->Position = glm::vec3(0.2726f, 0.2805f - wheelOffset, 1.9307f); - auto model = AddComponent(wheel); - model->ModelFile = "Models/Jeep/WheelBack/wheelBack.obj"; - auto Wheel = AddComponent(wheel); - Wheel->Hardpoint = transform->Position + glm::vec3(0.f, springLength, 0.f); - Wheel->AxleID = 1; - Wheel->Mass = 50; - Wheel->Radius = 0.737f; - Wheel->Steering = false; - Wheel->SuspensionStrength = suspensionStrength; - Wheel->Friction = 4.f; - Wheel->ConnectedToHandbrake = true; - CommitEntity(wheel); - } - - { - auto wheel = CreateEntity(jeep); - auto transform = AddComponent(wheel); - transform->Position = glm::vec3(-0.2726f, 0.2805f - wheelOffset, 1.9307f); - transform->Orientation = glm::angleAxis(glm::pi(), glm::vec3(0, 0, 1)); - auto model = AddComponent(wheel); - model->ModelFile = "Models/Jeep/WheelBack/wheelBack.obj"; - auto Wheel = AddComponent(wheel); - Wheel->Hardpoint = transform->Position + glm::vec3(0.f, springLength, 0.f); - Wheel->AxleID = 1; - Wheel->Mass = 50; - Wheel->Radius = 0.737f; - Wheel->Steering = false; - Wheel->SuspensionStrength = suspensionStrength; - Wheel->Friction = 4.f; - Wheel->ConnectedToHandbrake = true; - CommitEntity(wheel); - } - - CommitEntity(jeep); - - return jeep; -} - void GameWorld::CreateTerrain() { { @@ -938,7 +821,7 @@ void GameWorld::CreateTerrain() } } -void GameWorld::CreateBase(glm::quat orientation, int playerID) +void GameWorld::CreateBase(glm::quat orientation, int teamID) { auto base = CreateEntity(); auto transform = AddComponent(base); @@ -1200,7 +1083,7 @@ void GameWorld::CreateBase(glm::quat orientation, int playerID) } #pragma endregion Terrain - CreateGate(base, glm::vec3(273.f, 40.185f, 0.06f), glm::quat(glm::vec3(0, glm::pi() / 2.f, 0))); + CreateGate(base, glm::vec3(273.f, 40.185f, 0.06f), glm::quat(glm::vec3(0, glm::pi() / 2.f, 0)), teamID); CreateWall(base, glm::vec3(273.f, 40.3f, -55.f), glm::quat(glm::vec3(0, glm::pi() / 2.f, 0))); CreateWall(base, glm::vec3(273.f, 40.3f, -45.f), glm::quat(glm::vec3(0, glm::pi() / 2.f, 0))); @@ -1210,19 +1093,16 @@ void GameWorld::CreateBase(glm::quat orientation, int playerID) CreateWall(base, glm::vec3(273.f, 40.3f, 15.f), glm::quat(glm::vec3(0, glm::pi() / 2.f, 0))); CreateWall(base, glm::vec3(273.f, 40.3f, 25.f), glm::quat(glm::vec3(0, glm::pi() / 2.f, 0))); - CreateGarage(base, glm::vec3(323.2f, 41.4f, -10.2f), glm::quat(glm::vec3(0, glm::pi() / 2.f, 0)), playerID); + CreateGarage(base, glm::vec3(323.2f, 41.4f, -10.2f), glm::quat(glm::vec3(0, glm::pi() / 2.f, 0)), teamID); } -EntityID GameWorld::CreateGarage(EntityID parent, glm::vec3 Position, glm::quat orientation, int playerID) + +EntityID GameWorld::CreateGarage(EntityID parent, glm::vec3 Position, glm::quat orientation, int teamID) { auto garage = CreateEntity(parent); auto transform = AddComponent(garage); transform->Position = Position; transform->Orientation = orientation; - auto player = CreateEntity(garage); - auto playerComponent = AddComponent(player); - playerComponent->ID = playerID; - auto ElevatorBase = CreateEntity(garage); { auto transform = AddComponent(ElevatorBase); @@ -1334,7 +1214,8 @@ EntityID GameWorld::CreateGarage(EntityID parent, glm::vec3 Position, glm::quat auto transform = AddComponent(spawnPoint); transform->Position.y = 1.f; auto spawnPointComponent = AddComponent(spawnPoint); - spawnPointComponent->Player = player; + auto teamComponent = AddComponent(spawnPoint); + teamComponent->TeamID = teamID; } CommitEntity(spawnPoint); } @@ -1352,6 +1233,9 @@ EntityID GameWorld::CreateGarage(EntityID parent, glm::vec3 Position, glm::quat auto transform = AddComponent(trigger); transform->Position = glm::vec3(0, 44.87521f, 0); auto triggerComponent = AddComponent(trigger); + triggerComponent->TeamID = teamID; + auto teamComponent = AddComponent(trigger); + teamComponent->TeamID = teamID; { auto shape = CreateEntity(trigger); auto transform = AddComponent(shape); @@ -1371,6 +1255,9 @@ EntityID GameWorld::CreateGarage(EntityID parent, glm::vec3 Position, glm::quat auto transform = AddComponent(trigger); transform->Position = glm::vec3(0.69385f, -6.7997f, -2.0f); auto triggerComponent = AddComponent(trigger); + triggerComponent->TeamID = teamID; + auto teamComponent = AddComponent(trigger); + teamComponent->TeamID = teamID; { auto shape = CreateEntity(trigger); auto transform = AddComponent(shape); diff --git a/src/GameWorld.h b/src/GameWorld.h index e8decde..0b2bcfa 100755 --- a/src/GameWorld.h +++ b/src/GameWorld.h @@ -57,6 +57,7 @@ #include "Components/TriggerRotate.h" #include "Components/Move.h" #include "Components/Rotate.h" +#include "Components/Team.h" class GameWorld : public World { @@ -79,11 +80,11 @@ private: void BindGamepadAxis(Gamepad::Axis axis, std::string command, float value); void BindGamepadButton(Gamepad::Button button, std::string command, float value); - void CreateGate(EntityID parent, glm::vec3 position, glm::quat orientation); + void CreateGate(EntityID parent, glm::vec3 position, glm::quat orientation, int teamID); void AddTankWheelPair(EntityID tankEntity, glm::vec3 position, int axleID, bool steering); EntityID CreateJeep(int playerID); EntityID CreateWall(EntityID parent, glm::vec3 pos, glm::quat orientation); - EntityID CreateGarage(EntityID parent, glm::vec3 Position, glm::quat orientation, int playerID); + EntityID CreateGarage(EntityID parent, glm::vec3 Position, glm::quat orientation, int teamID); void CreateTerrain(); void CreateBase(glm::quat orientation, int playerID); std::vector m_WallDebrisTemplates; diff --git a/src/Systems/GarageSystem.cpp b/src/Systems/GarageSystem.cpp index d019b27..9d805c5 100644 --- a/src/Systems/GarageSystem.cpp +++ b/src/Systems/GarageSystem.cpp @@ -34,6 +34,14 @@ bool Systems::GarageSystem::OnEnterTrigger(const Events::EnterTrigger &event) if (!garageComponent) return false; + auto teamComponent = m_World->GetComponent(event.Trigger); + auto playerComponent = m_World->GetComponent(event.Entity); + + if(!teamComponent || !playerComponent) + return false; + if (teamComponent->TeamID != playerComponent->ID) + return false; + std::string name = m_World->GetProperty(event.Trigger, "Name"); if (name == "BoundsTrigger") @@ -56,6 +64,15 @@ bool Systems::GarageSystem::OnLeaveTrigger(const Events::LeaveTrigger &event) if (!garageComponent) return false; + auto teamComponent = m_World->GetComponent(event.Trigger); + auto playerComponent = m_World->GetComponent(event.Entity); + + if(!teamComponent || !playerComponent) + return false; + if (teamComponent->TeamID != playerComponent->ID) + return false; + + std::string name = m_World->GetProperty(event.Trigger, "Name"); if (name == "BoundsTrigger") @@ -76,18 +93,24 @@ bool Systems::GarageSystem::OnCommand(const Events::InputCommand &event) { EntityID trigger = pair.first; auto entities = pair.second; - std::string name = m_World->GetProperty(trigger, "Name"); if (name != "ElevatorShaftTrigger") continue; - auto triggerBaseParent = m_World->GetEntityBaseParent(trigger); - auto triggerPlayerComponent = m_World->GetComponent(triggerBaseParent); + auto triggerTeamComponent = m_World->GetComponent(trigger); + if (!triggerTeamComponent) + continue; for (EntityID entity : entities) { - auto entityPlayerComponent = m_World->GetComponent(triggerBaseParent); - if (triggerPlayerComponent == entityPlayerComponent) + auto entityPlayerComponent = m_World->GetComponent(entity); + if(!entityPlayerComponent) + continue; + + if (entityPlayerComponent->ID != event.PlayerID) + continue; + + if (triggerTeamComponent->TeamID == entityPlayerComponent->ID) { EntityID garage = m_World->GetEntityParent(trigger); auto garageComponent = m_World->GetComponent(garage); diff --git a/src/Systems/GarageSystem.h b/src/Systems/GarageSystem.h index aca5673..af0f4cf 100644 --- a/src/Systems/GarageSystem.h +++ b/src/Systems/GarageSystem.h @@ -18,6 +18,7 @@ #include "Events/Rotate.h" #include "Components/Move.h" #include "Components/Rotate.h" +#include "Components/Team.h" namespace Systems { diff --git a/src/Systems/JeepSteeringSystem.cpp b/src/Systems/JeepSteeringSystem.cpp index 62f2705..0121a43 100644 --- a/src/Systems/JeepSteeringSystem.cpp +++ b/src/Systems/JeepSteeringSystem.cpp @@ -66,9 +66,17 @@ bool Systems::JeepSteeringSystem::OnSpawnVehicle(const Events::SpawnVehicle &eve { auto spawnPoint = component->Entity; auto spawnPointComponent = std::dynamic_pointer_cast(component); - auto playerComponent = m_World->GetComponent(spawnPointComponent->Player); - if (!playerComponent || playerComponent->ID != event.PlayerID) + auto teamComponent = m_World->GetComponent(spawnPoint); + + if(!teamComponent) + { + LOG_ERROR("SpawnPoint has no TeamComponent"); continue; + } + + if (teamComponent->TeamID != event.PlayerID) + continue; + Components::Transform absoluteTransform = m_World->GetSystem()->AbsoluteTransform(spawnPoint); diff --git a/src/Systems/JeepSteeringSystem.h b/src/Systems/JeepSteeringSystem.h index 0a786be..9ece58b 100644 --- a/src/Systems/JeepSteeringSystem.h +++ b/src/Systems/JeepSteeringSystem.h @@ -28,6 +28,7 @@ #include "Components/Input.h" #include "Components/JeepSteering.h" #include "Events/JeepSteer.h" +#include "Components/Team.h" #include "Events/SetViewportCamera.h" diff --git a/src/Systems/TankSteeringSystem.cpp b/src/Systems/TankSteeringSystem.cpp index d886550..f20279a 100644 --- a/src/Systems/TankSteeringSystem.cpp +++ b/src/Systems/TankSteeringSystem.cpp @@ -375,7 +375,7 @@ bool Systems::TankSteeringSystem::OnSpawnVehicle(const Events::SpawnVehicle &eve { if (event.VehicleType != "Tank") return false; - + auto spawnPointComponents = m_World->GetComponentsOfType(); if (!spawnPointComponents) { @@ -387,8 +387,15 @@ bool Systems::TankSteeringSystem::OnSpawnVehicle(const Events::SpawnVehicle &eve { auto spawnPoint = component->Entity; auto spawnPointComponent = std::dynamic_pointer_cast(component); - auto playerComponent = m_World->GetComponent(spawnPointComponent->Player); - if (!playerComponent || playerComponent->ID != event.PlayerID) + auto teamComponent = m_World->GetComponent(spawnPoint); + + if(!teamComponent) + { + LOG_ERROR("SpawnPoint has no TeamComponent"); + continue; + } + + if (teamComponent->TeamID != event.PlayerID) continue; Components::Transform absoluteTransform = m_World->GetSystem()->AbsoluteTransform(spawnPoint); diff --git a/src/Systems/TankSteeringSystem.h b/src/Systems/TankSteeringSystem.h index 3f2ee51..a237026 100644 --- a/src/Systems/TankSteeringSystem.h +++ b/src/Systems/TankSteeringSystem.h @@ -15,6 +15,7 @@ #include "Components/Vehicle.h" #include "Components/Player.h" #include "Components/Model.h" +#include "Components/Team.h" #include "Systems/TransformSystem.h" #include "Systems/ParticleSystem.h" #include "InputController.h" diff --git a/src/Systems/TriggerSystem.cpp b/src/Systems/TriggerSystem.cpp index b6fbe65..b087354 100644 --- a/src/Systems/TriggerSystem.cpp +++ b/src/Systems/TriggerSystem.cpp @@ -44,10 +44,18 @@ void Systems::TriggerSystem::OnEntityRemoved( EntityID entity ) bool Systems::TriggerSystem::OnEnterTrigger( const Events::EnterTrigger &event ) { - + + auto teamComponent = m_World->GetComponent(event.Trigger); + auto playerComponent = m_World->GetComponent(event.Entity); + + if(!teamComponent || !playerComponent) + return false; + if (teamComponent->TeamID != playerComponent->ID) + return false; auto flagComponent1 = m_World->GetComponent(event.Trigger); auto flagComponent2 = m_World->GetComponent(event.Entity); + //HACK: SIMON IS DISSING AMERICA if(flagComponent1) { @@ -77,6 +85,17 @@ bool Systems::TriggerSystem::OnEnterTrigger( const Events::EnterTrigger &event ) bool Systems::TriggerSystem::OnLeaveTrigger( const Events::LeaveTrigger &event ) { + auto teamComponent = m_World->GetComponent(event.Trigger); + auto playerComponent = m_World->GetComponent(event.Entity); + + if(!teamComponent || !playerComponent) + return false; + if (teamComponent->TeamID != playerComponent->ID) + return false; + + auto flagComponent1 = m_World->GetComponent(event.Trigger); + auto flagComponent2 = m_World->GetComponent(event.Entity); + auto triggerMoveComponent = m_World->GetComponent(event.Trigger); if (triggerMoveComponent) { diff --git a/src/Systems/TriggerSystem.h b/src/Systems/TriggerSystem.h index d158557..8891c9e 100644 --- a/src/Systems/TriggerSystem.h +++ b/src/Systems/TriggerSystem.h @@ -21,6 +21,7 @@ #include "Components/Move.h" #include "Components/Rotate.h" #include "Components/Player.h" +#include "Components/Team.h" #include "Events/Move.h" #include "Events/Rotate.h" #include diff --git a/vs11/Returngeance/Returngeance.vcxproj b/vs11/Returngeance/Returngeance.vcxproj index 8121c25..e8bee55 100755 --- a/vs11/Returngeance/Returngeance.vcxproj +++ b/vs11/Returngeance/Returngeance.vcxproj @@ -146,6 +146,7 @@ + diff --git a/vs11/Returngeance/Returngeance.vcxproj.filters b/vs11/Returngeance/Returngeance.vcxproj.filters index fed4ecf..410c86e 100755 --- a/vs11/Returngeance/Returngeance.vcxproj.filters +++ b/vs11/Returngeance/Returngeance.vcxproj.filters @@ -78,15 +78,16 @@ Game\Systems - - Gameplay\Systems - Game\Systems Audio + + + Physics\Systems + @@ -526,9 +527,6 @@ Rendering\Components - - Gameplay\Systems - Physics\Events @@ -565,9 +563,6 @@ GUI - - Gameplay\Events - Game\Events @@ -577,6 +572,16 @@ Game\Components + + + + + + Game\Components + + + Physics\Systems + From 56e6545f0fc19463c3f837d53882fc72b6116ee2 Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Wed, 4 Jun 2014 23:54:52 +0200 Subject: [PATCH 6/6] Direct damage and VulnerableToSplash flag on Health component --- src/Components/DamageModel.h | 27 +++++ src/Components/Health.h | 5 +- src/GameWorld.cpp | 17 +-- src/GameWorld.h | 1 + src/Systems/DamageSystem.cpp | 1 + src/Systems/DamageSystem.h | 1 + src/Systems/TankSteeringSystem.cpp | 103 ++++++++++-------- src/Systems/WallSystem.cpp | 13 +++ src/Systems/WallSystem.h | 1 + vs11/Returngeance/Returngeance.vcxproj | 1 + .../Returngeance/Returngeance.vcxproj.filters | 31 ++++-- 11 files changed, 141 insertions(+), 60 deletions(-) create mode 100644 src/Components/DamageModel.h diff --git a/src/Components/DamageModel.h b/src/Components/DamageModel.h new file mode 100644 index 0000000..6e34cf9 --- /dev/null +++ b/src/Components/DamageModel.h @@ -0,0 +1,27 @@ +#ifndef Components_DamageModel_h__ +#define Components_DamageModel_h__ + +#include + +#include "Component.h" + +namespace Components +{ + + struct DamageModel : Component + { + DamageModel() + : Color(glm::vec4(1.0f, 1.0f, 1.0f, 1.0f)) + , ShadowCaster(true) + , Transparent(false) + { } + std::string ModelFile; + glm::vec4 Color; + bool ShadowCaster; + bool Transparent; + + virtual DamageModel* Clone() const override { return new DamageModel(*this); } + }; + +} +#endif // !Components_DamageModel_h__ \ No newline at end of file diff --git a/src/Components/Health.h b/src/Components/Health.h index ca8daee..c52fae2 100644 --- a/src/Components/Health.h +++ b/src/Components/Health.h @@ -9,9 +9,12 @@ namespace Components struct Health : Component { Health() - : Amount(1.0f) { } + : Amount(1.0f) + , VulnerableToSplash(true) + { } float Amount; + bool VulnerableToSplash; virtual Health* Clone() const override { return new Health(*this); } }; diff --git a/src/GameWorld.cpp b/src/GameWorld.cpp index f18ef16..07bab79 100755 --- a/src/GameWorld.cpp +++ b/src/GameWorld.cpp @@ -650,9 +650,12 @@ EntityID GameWorld::CreateWall(EntityID parent, glm::vec3 pos, glm::quat orienta auto model = AddComponent(wall); model->ModelFile = "Models/Wall/WallWhole/Wall.obj"; + auto damageModel = AddComponent(wall); + damageModel->ModelFile = "Models/Wall/WallWhole/WallCracks.obj"; auto health = AddComponent(wall); health->Amount = 50.f; + health->VulnerableToSplash = false; auto shape = CreateEntity(wall); auto shapetransform = AddComponent(shape); @@ -752,7 +755,7 @@ void GameWorld::CreateTerrain() } CreateBase(glm::quat(), 1); - //CreateBase(glm::quat(glm::vec3(0, glm::pi(), 0)), 2); + CreateBase(glm::quat(glm::vec3(0, glm::pi(), 0)), 2); { auto tree = CreateEntity(); @@ -1085,12 +1088,12 @@ void GameWorld::CreateBase(glm::quat orientation, int teamID) CreateGate(base, glm::vec3(273.f, 40.185f, 0.06f), glm::quat(glm::vec3(0, glm::pi() / 2.f, 0)), teamID); CreateWall(base, glm::vec3(273.f, 40.3f, -55.f), glm::quat(glm::vec3(0, glm::pi() / 2.f, 0))); - //CreateWall(base, glm::vec3(273.f, 40.3f, -45.f), glm::quat(glm::vec3(0, glm::pi() / 2.f, 0))); - //CreateWall(base, glm::vec3(273.f, 40.3f, -35.f), glm::quat(glm::vec3(0, glm::pi() / 2.f, 0))); - //CreateWall(base, glm::vec3(273.f, 40.3f, -25.f), glm::quat(glm::vec3(0, glm::pi() / 2.f, 0))); - //CreateWall(base, glm::vec3(273.f, 40.3f, -15.f), glm::quat(glm::vec3(0, glm::pi() / 2.f, 0))); - //CreateWall(base, glm::vec3(273.f, 40.3f, 15.f), glm::quat(glm::vec3(0, glm::pi() / 2.f, 0))); - //CreateWall(base, glm::vec3(273.f, 40.3f, 25.f), glm::quat(glm::vec3(0, glm::pi() / 2.f, 0))); + CreateWall(base, glm::vec3(273.f, 40.3f, -45.f), glm::quat(glm::vec3(0, glm::pi() / 2.f, 0))); + CreateWall(base, glm::vec3(273.f, 40.3f, -35.f), glm::quat(glm::vec3(0, glm::pi() / 2.f, 0))); + CreateWall(base, glm::vec3(273.f, 40.3f, -25.f), glm::quat(glm::vec3(0, glm::pi() / 2.f, 0))); + CreateWall(base, glm::vec3(273.f, 40.3f, -15.f), glm::quat(glm::vec3(0, glm::pi() / 2.f, 0))); + CreateWall(base, glm::vec3(273.f, 40.3f, 15.f), glm::quat(glm::vec3(0, glm::pi() / 2.f, 0))); + CreateWall(base, glm::vec3(273.f, 40.3f, 25.f), glm::quat(glm::vec3(0, glm::pi() / 2.f, 0))); CreateGarage(base, glm::vec3(323.2f, 41.4f, -10.2f), glm::quat(glm::vec3(0, glm::pi() / 2.f, 0)), teamID); } diff --git a/src/GameWorld.h b/src/GameWorld.h index 0b2bcfa..85539ca 100755 --- a/src/GameWorld.h +++ b/src/GameWorld.h @@ -30,6 +30,7 @@ #include "Components/DirectionalLight.h" #include "Components/Input.h" #include "Components/Model.h" +#include "Components/DamageModel.h" #include "Components/ParticleEmitter.h" #include "Components/Particle.h" #include "Components/PointLight.h" diff --git a/src/Systems/DamageSystem.cpp b/src/Systems/DamageSystem.cpp index 53be57c..ffbce89 100644 --- a/src/Systems/DamageSystem.cpp +++ b/src/Systems/DamageSystem.cpp @@ -4,6 +4,7 @@ void Systems::DamageSystem::RegisterComponents( ComponentFactory* cf ) { cf->Register([]() { return new Components::Health(); }); + cf->Register([]() { return new Components::DamageModel(); }); } void Systems::DamageSystem::Initialize() diff --git a/src/Systems/DamageSystem.h b/src/Systems/DamageSystem.h index a77a600..2b1a43a 100644 --- a/src/Systems/DamageSystem.h +++ b/src/Systems/DamageSystem.h @@ -4,6 +4,7 @@ #include "System.h" #include "Components/Health.h" +#include "Components/DamageModel.h" #include "Events/Damage.h" #include "Events/OnDead.h" diff --git a/src/Systems/TankSteeringSystem.cpp b/src/Systems/TankSteeringSystem.cpp index f20279a..c9c1022 100644 --- a/src/Systems/TankSteeringSystem.cpp +++ b/src/Systems/TankSteeringSystem.cpp @@ -50,7 +50,6 @@ void Systems::TankSteeringSystem::UpdateEntity(double dt, EntityID entity, Entit eSteering.Handbrake = inputController->Handbrake; EventBroker->Publish(eSteering); - auto towerSteeringComponent = m_World->GetComponent(tankSteeringComponent->Turret); auto barrelSteeringComponent = m_World->GetComponent(tankSteeringComponent->Barrel); @@ -65,7 +64,7 @@ void Systems::TankSteeringSystem::UpdateEntity(double dt, EntityID entity, Entit { auto tankTransform = m_World->GetComponent(entity); auto transformComponent = m_World->GetComponent(tankSteeringComponent->Barrel); - auto absoluteTransform = m_World->GetSystem()->AbsoluteTransform(tankSteeringComponent->Barrel); + glm::quat orientation = glm::angleAxis(barrelSteeringComponent->TurnSpeed * inputController->BarrelDirection * (float)dt, barrelSteeringComponent->Axis); transformComponent->Orientation *= orientation; @@ -81,7 +80,7 @@ void Systems::TankSteeringSystem::UpdateEntity(double dt, EntityID entity, Entit transformComponent->Orientation = glm::quat(angles); } - + auto absoluteTransform = m_World->GetSystem()->AbsoluteTransform(tankSteeringComponent->Barrel); if(inputController->Shoot && m_TimeSinceLastShot[tankSteeringComponent->Barrel] > 0.5) { @@ -138,7 +137,7 @@ void Systems::TankSteeringSystem::UpdateEntity(double dt, EntityID entity, Entit auto clonePhysicsComponent = m_World->GetComponent(clone); //1,670m/s //25kg - Events::ApplyPointImpulse ePointImpulse ; + Events::ApplyPointImpulse ePointImpulse; ePointImpulse.Entity = entity; ePointImpulse.Position = absoluteTransform.Position; ePointImpulse.Impulse = glm::normalize(absoluteTransform.Orientation * glm::vec3(0, 0, 1)) * clonePhysicsComponent->Mass * 6.f * 1670.f; @@ -194,39 +193,39 @@ bool Systems::TankSteeringSystem::OnCollision(const Events::Collision &e) //auto otherTransform = m_World->GetComponent(otherEntity); { -// Events::CreateExplosion e; -// e.LifeTime = 3; -// e.ParticleScale.push_back(8); -// e.ParticlesToSpawn = 20; -// e.Position = shellTransform->Position; -// e.RelativeUpOrientation = glm::angleAxis(glm::pi() / 2, glm::vec3(1,0,0)); -// e.Speed = 3; -// e.SpreadAngle = glm::pi(); -// e.spritePath = "Textures/Sprites/Smoke1.png"; -// e.Color = glm::vec4(0.6,0.6,0.6,1); -// EventBroker->Publish(e); -// e.LifeTime = 0.7; -// e.ParticleScale.push_back(12); -// e.ParticlesToSpawn = 10; -// e.Position = shellTransform->Position; -// e.RelativeUpOrientation = glm::angleAxis(glm::pi() / 2, glm::vec3(1,0,0)); -// e.Speed = 17; -// e.SpreadAngle = glm::pi(); -// e.spritePath = "Textures/Sprites/Fire.png"; -// EventBroker->Publish(e); -// e.LifeTime = 0.2; -// e.ParticleScale.push_back(1); -// e.ParticleScale.push_back(15); -// e.ParticlesToSpawn = 5; -// e.Position = shellTransform->Position; -// e.RelativeUpOrientation = glm::angleAxis(glm::pi() / 2, glm::vec3(1,0,0)); -// e.Speed = 6; -// e.SpreadAngle = glm::pi(); -// e.spritePath = "Textures/Sprites/Blast1.png"; -// e.Color = glm::vec4(2, 2, 2, 0.2); -// EventBroker->Publish(e); - Events::CreateExplosion e; + e.LifeTime = 3; + e.ParticleScale.push_back(8); + e.ParticlesToSpawn = 20; + e.Position = shellTransform->Position; + e.RelativeUpOrientation = glm::angleAxis(glm::pi() / 2, glm::vec3(1, 0, 0)); + e.Speed = 3; + e.SpreadAngle = glm::pi(); + e.spritePath = "Textures/Sprites/Smoke1.png"; + e.Color = glm::vec4(0.6, 0.6, 0.6, 1); + EventBroker->Publish(e); + e.LifeTime = 0.7; + e.ParticleScale.push_back(12); + e.ParticlesToSpawn = 10; + e.Position = shellTransform->Position; + e.RelativeUpOrientation = glm::angleAxis(glm::pi() / 2, glm::vec3(1, 0, 0)); + e.Speed = 17; + e.SpreadAngle = glm::pi(); + e.spritePath = "Textures/Sprites/Fire.png"; + EventBroker->Publish(e); + e.LifeTime = 0.2; + e.ParticleScale.push_back(1); + e.ParticleScale.push_back(15); + e.ParticlesToSpawn = 5; + e.Position = shellTransform->Position; + e.RelativeUpOrientation = glm::angleAxis(glm::pi() / 2, glm::vec3(1, 0, 0)); + e.Speed = 6; + e.SpreadAngle = glm::pi(); + e.spritePath = "Textures/Sprites/Blast1.png"; + e.Color = glm::vec4(2, 2, 2, 0.2); + EventBroker->Publish(e); + + /*Events::CreateExplosion e; e.LifeTime = 1.5; e.ParticleScale.push_back(1); e.ParticleScale.push_back(6); @@ -253,7 +252,7 @@ bool Systems::TankSteeringSystem::OnCollision(const Events::Collision &e) e.Speed = 12; e.spritePath = "Textures/Sprites/Splash.png"; e.Color = glm::vec4(1.f,1.f,1.f,1); - EventBroker->Publish(e); + EventBroker->Publish(e);*/ } { Events::PlaySFX e; @@ -263,27 +262,41 @@ bool Systems::TankSteeringSystem::OnCollision(const Events::Collision &e) EventBroker->Publish(e); } + // Direct damage + auto health = m_World->GetComponent(otherEntity); + if (health) + { + Events::Damage d; + d.Entity = otherEntity; + d.Amount = shellComponent->Damage; + EventBroker->Publish(d); + } + + // Splash damage for (auto &physComponent : *physicsComponents) { - EntityID physicsEntity = std::dynamic_pointer_cast(physComponent)->Entity; - auto physEntityTransform = m_World->GetComponent(physicsEntity); + EntityID physicsEntity = physComponent->Entity; + // No splash damage to the direct hit target + if (physicsEntity == otherEntity) + continue; + auto physEntityTransform = m_World->GetSystem()->AbsoluteTransform(physicsEntity); - float distance = glm::distance(physEntityTransform->Position, shellTransform->Position); + float distance = glm::distance(physEntityTransform.Position, shellTransform->Position); if (distance <= shellComponent->ExplosionRadius) { // DO STUFF! :D float radius = shellComponent->ExplosionRadius; float strength = (1.f - pow(distance / radius, 2)) * shellComponent->ExplosionStrength; - glm::vec3 direction = glm::normalize(physEntityTransform->Position - shellTransform->Position); + glm::vec3 direction = glm::normalize(physEntityTransform.Position - shellTransform->Position); Events::ApplyPointImpulse e; e.Entity = physicsEntity; e.Impulse = direction * strength; - e.Position = physEntityTransform->Position; + e.Position = physEntityTransform.Position; EventBroker->Publish(e); auto health = m_World->GetComponent(physicsEntity); - if(health) + if (health && health->VulnerableToSplash) { Events::Damage d; d.Entity = physicsEntity; @@ -513,8 +526,8 @@ EntityID Systems::TankSteeringSystem::CreateTank(int playerID) modelComponent->ModelFile = "Models/Placeholders/rocket/Rocket.obj"; auto tankShellComponent = m_World->AddComponent(shot); tankShellComponent->Damage = 20.f; - tankShellComponent->ExplosionRadius = 30.f; - tankShellComponent->ExplosionStrength = 300000.f; + tankShellComponent->ExplosionRadius = 20.f; + tankShellComponent->ExplosionStrength = 140.f; { auto shape = m_World->CreateEntity(shot); auto transform = m_World->AddComponent(shape); diff --git a/src/Systems/WallSystem.cpp b/src/Systems/WallSystem.cpp index 73f1eaa..c9d794b 100644 --- a/src/Systems/WallSystem.cpp +++ b/src/Systems/WallSystem.cpp @@ -20,6 +20,18 @@ bool Systems::WallSystem::Damage( const Events::Damage &event ) return false; } LOG_INFO("WallSystem::Damage"); + + // Change to damage model + auto modelComponent = m_World->GetComponent(event.Entity); + auto damageModel = m_World->GetComponent(event.Entity); + if (modelComponent) + { + modelComponent->ModelFile = damageModel->ModelFile; + modelComponent->Color = damageModel->Color; + modelComponent->ShadowCaster = damageModel->ShadowCaster; + modelComponent->Transparent = damageModel->Transparent; + } + auto wallhealthcomponent = m_World->GetComponent(event.Entity); if(wallhealthcomponent->Amount > 0) { @@ -29,6 +41,7 @@ bool Systems::WallSystem::Damage( const Events::Damage &event ) //auto transformComponent = m_World->GetComponent(event.Entity); Components::Transform transformComponent = m_World->GetSystem()->AbsoluteTransform(event.Entity); + // Spawn debris for(auto d : wallComponent->Walldebris) { auto debris = m_World->CloneEntity(d); diff --git a/src/Systems/WallSystem.h b/src/Systems/WallSystem.h index 84e5972..6dbdea6 100644 --- a/src/Systems/WallSystem.h +++ b/src/Systems/WallSystem.h @@ -8,6 +8,7 @@ #include "Events/Damage.h" #include "Events/ApplyPointImpulse.h" #include "Components/Model.h" +#include "Components/DamageModel.h" #include "Components/Wall.h" #include "Components/Transform.h" #include "Components/Physics.h" diff --git a/vs11/Returngeance/Returngeance.vcxproj b/vs11/Returngeance/Returngeance.vcxproj index a7ddc7e..eddc0a6 100755 --- a/vs11/Returngeance/Returngeance.vcxproj +++ b/vs11/Returngeance/Returngeance.vcxproj @@ -139,6 +139,7 @@ + diff --git a/vs11/Returngeance/Returngeance.vcxproj.filters b/vs11/Returngeance/Returngeance.vcxproj.filters index 6219aaf..71d2baf 100755 --- a/vs11/Returngeance/Returngeance.vcxproj.filters +++ b/vs11/Returngeance/Returngeance.vcxproj.filters @@ -74,7 +74,6 @@ Game\Systems - Game\Systems @@ -84,11 +83,18 @@ Audio - - Physics\Systems + + Game\Systems + + + Physics\Systems + + + Game\Systems + @@ -573,10 +579,6 @@ Game\Components - - - - Game\Components @@ -612,6 +614,21 @@ Game\Events + + Game\Events + + + Physics\Events + + + Physics\Components + + + Game\Systems + + + Rendering\Components +