diff --git a/assets b/assets index c8e631f4..a0d1615e 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit c8e631f449515cdbe3647b96ce472839748e28f9 +Subproject commit a0d1615e515a4d7db0073cc987d1d593ca942471 diff --git a/include/Game/Game.h b/include/Game/Game.h index de45c558..728070f3 100644 --- a/include/Game/Game.h +++ b/include/Game/Game.h @@ -15,8 +15,6 @@ #include "Core/EKeyDown.h" #include "Core/EntityFilePreprocessor.h" #include "Core/SystemPipeline.h" -#include "RaptorCopterSystem.h" -#include "PlayerSystem.h" #include "Editor/EditorSystem.h" #include "Core/EntityFile.h" #include "Core/EntityFileParser.h" diff --git a/include/Game/HealthSystem.h b/include/Game/Systems/HealthSystem.h similarity index 89% rename from include/Game/HealthSystem.h rename to include/Game/Systems/HealthSystem.h index 234244c2..0db3ec41 100644 --- a/include/Game/HealthSystem.h +++ b/include/Game/Systems/HealthSystem.h @@ -6,9 +6,9 @@ #include "Common.h" #include "Core/System.h" -#include "Core\EPlayerDamage.h"; -#include "Core\EPlayerHealthPickup.h"; -#include "Core\EPlayerDeath.h"; +#include "Core/EPlayerDamage.h" +#include "Core/EPlayerHealthPickup.h" +#include "Core/EPlayerDeath.h" #include #include diff --git a/include/Game/PlayerMovementSystem.h b/include/Game/Systems/PlayerMovementSystem.h similarity index 77% rename from include/Game/PlayerMovementSystem.h rename to include/Game/Systems/PlayerMovementSystem.h index 35f8a22c..6dc2dc31 100644 --- a/include/Game/PlayerMovementSystem.h +++ b/include/Game/Systems/PlayerMovementSystem.h @@ -1,11 +1,13 @@ #include "Common.h" +#include "GLM.h" #include "Core/System.h" class PlayerMovementSystem : public PureSystem { public: PlayerMovementSystem(EventBroker* eventBroker) - : PureSystem(eventBroker, "Player") + : System(eventBroker) + , PureSystem("Player") { } virtual void UpdateComponent(World* world, EntityWrapper& entity, ComponentWrapper& component, double dt); diff --git a/include/Game/PlayerSystem.h b/include/Game/Systems/PlayerSystem.h similarity index 100% rename from include/Game/PlayerSystem.h rename to include/Game/Systems/PlayerSystem.h diff --git a/include/Game/RaptorCopterSystem.h b/include/Game/Systems/RaptorCopterSystem.h similarity index 100% rename from include/Game/RaptorCopterSystem.h rename to include/Game/Systems/RaptorCopterSystem.h diff --git a/resources/Schema/Components.xsd b/resources/Schema/Components.xsd index 4f32b477..e1440b69 100644 --- a/resources/Schema/Components.xsd +++ b/resources/Schema/Components.xsd @@ -2,6 +2,7 @@ + diff --git a/resources/Schema/Components/Collidable.xml b/resources/Schema/Components/Collidable.xml index 0d1bb9b3..4f9c9033 100644 --- a/resources/Schema/Components/Collidable.xml +++ b/resources/Schema/Components/Collidable.xml @@ -1,3 +1,2 @@ - true \ No newline at end of file diff --git a/resources/Schema/Components/Collidable.xsd b/resources/Schema/Components/Collidable.xsd index f835d9a6..84c66f11 100644 --- a/resources/Schema/Components/Collidable.xsd +++ b/resources/Schema/Components/Collidable.xsd @@ -4,10 +4,5 @@ - - - - - \ No newline at end of file diff --git a/resources/Schema/Components/Physics.xml b/resources/Schema/Components/Physics.xml new file mode 100644 index 00000000..1ad81de0 --- /dev/null +++ b/resources/Schema/Components/Physics.xml @@ -0,0 +1,3 @@ + + + diff --git a/resources/Schema/Components/Physics.xsd b/resources/Schema/Components/Physics.xsd new file mode 100644 index 00000000..001dd2c8 --- /dev/null +++ b/resources/Schema/Components/Physics.xsd @@ -0,0 +1,16 @@ + + + + + + + + Physics stuff + + + + + + + + diff --git a/resources/Schema/Components/Transform.xsd b/resources/Schema/Components/Transform.xsd index b8d24777..f0db2472 100644 --- a/resources/Schema/Components/Transform.xsd +++ b/resources/Schema/Components/Transform.xsd @@ -17,4 +17,4 @@ - \ No newline at end of file + diff --git a/resources/Schema/Entities/MovementTest.xml b/resources/Schema/Entities/MovementTest.xml new file mode 100644 index 00000000..08e05417 --- /dev/null +++ b/resources/Schema/Entities/MovementTest.xml @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + Models/Core/UnitCube.obj + + + + + + + + + + + + + + + + + + + Models/Assault.obj + + + + + + + + + + + + + + + + + + Models/Core/UnitCube.obj + + + + + + + + + + + + + diff --git a/resources/Schema/Entities/Player.xml b/resources/Schema/Entities/Player.xml new file mode 100644 index 00000000..6406a795 --- /dev/null +++ b/resources/Schema/Entities/Player.xml @@ -0,0 +1,17 @@ + + + + + + + + Models/Core/UnitSphere.obj + + + + + + + + + diff --git a/resources/Schema/Types/Entity.xsd b/resources/Schema/Types/Entity.xsd index 8790d8a9..88237697 100644 --- a/resources/Schema/Types/Entity.xsd +++ b/resources/Schema/Types/Entity.xsd @@ -11,6 +11,7 @@ + diff --git a/src/Engine/Collision/CollisionSystem.cpp b/src/Engine/Collision/CollisionSystem.cpp index 92b7f7db..96e49153 100644 --- a/src/Engine/Collision/CollisionSystem.cpp +++ b/src/Engine/Collision/CollisionSystem.cpp @@ -4,6 +4,11 @@ void CollisionSystem::UpdateComponent(World* world, EntityWrapper& entity, ComponentWrapper& component, double dt) { + if (!entity.HasComponent("Physics")) { + return; + } + ComponentWrapper& cPhysics = entity["Physics"]; + boost::optional boundingBox = Collision::EntityAbsoluteAABB(entity); if (!boundingBox) { return; @@ -25,7 +30,10 @@ void CollisionSystem::UpdateComponent(World* world, EntityWrapper& entity, Compo continue; } if (Collision::AABBVsAABB(boxA, boxB, resolutionVector)) { - (glm::vec3&)cTransform["Position"] += resolutionVector; + if (entity.HasComponent("Physics")) { + (glm::vec3&)cTransform["Position"] += resolutionVector; + cPhysics["Velocity"] = glm::vec3(0, 0, 0); + } } } diff --git a/src/Game/CMakeLists.txt b/src/Game/CMakeLists.txt index 04146670..4be61127 100644 --- a/src/Game/CMakeLists.txt +++ b/src/Game/CMakeLists.txt @@ -11,16 +11,15 @@ include_directories( ) file(GLOB SOURCE_FILES - "${INCLUDE_PATH}/*.h" - #"*.cpp" + "${INCLUDE_PATH}/Systems/*.h" + "Systems/*.cpp" ) -#source_group(Core FILES ${SOURCE_FILES}) +source_group(Systems FILES ${SOURCE_FILES_Systems}) set(SOURCE_FILES ${SOURCE_FILES} "Game.cpp" - "HealthSystem.cpp" - "PlayerSystem.cpp" + ${SOURCE_FILES_Systems} ) set(LIBRARIES diff --git a/src/Game/Game.cpp b/src/Game/Game.cpp index 1865dd6c..29b9316b 100644 --- a/src/Game/Game.cpp +++ b/src/Game/Game.cpp @@ -2,7 +2,10 @@ #include "Collision/CollidableOctreeSystem.h" #include "Collision/TriggerSystem.h" #include "Collision/CollisionSystem.h" -#include "Game/HealthSystem.h" +#include "Systems/RaptorCopterSystem.h" +#include "Systems/PlayerSystem.h" +#include "Systems/HealthSystem.h" +#include "Systems/PlayerMovementSystem.h" #include "Core/EntityFileWriter.h" Game::Game(int argc, char* argv[]) @@ -69,6 +72,7 @@ Game::Game(int argc, char* argv[]) m_SystemPipeline->AddSystem(updateOrderLevel); m_SystemPipeline->AddSystem(updateOrderLevel, m_Renderer); m_SystemPipeline->AddSystem(updateOrderLevel); + m_SystemPipeline->AddSystem(updateOrderLevel); // Populate Octree with collidables ++updateOrderLevel; m_SystemPipeline->AddSystem(updateOrderLevel, m_OctreeCollision); diff --git a/src/Game/PlayerMovementSystem.cpp b/src/Game/PlayerMovementSystem.cpp deleted file mode 100644 index c0946134..00000000 --- a/src/Game/PlayerMovementSystem.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include "RaptorCopterSystem.h" - -void PlayerMovementSystem::UpdateComponent(World* world, EntityWrapper& entity, ComponentWrapper& component, double dt) -{ - ComponentWrapper& transform = world->GetComponent(component.EntityID); -} \ No newline at end of file diff --git a/src/Game/HealthSystem.cpp b/src/Game/Systems/HealthSystem.cpp similarity index 98% rename from src/Game/HealthSystem.cpp rename to src/Game/Systems/HealthSystem.cpp index 7986db9d..b6d46dc9 100644 --- a/src/Game/HealthSystem.cpp +++ b/src/Game/Systems/HealthSystem.cpp @@ -1,5 +1,4 @@ -#include "HealthSystem.h" -#include +#include "Systems/HealthSystem.h" HealthSystem::HealthSystem(EventBroker* eventBroker) : System(eventBroker) diff --git a/src/Game/Systems/PlayerMovementSystem.cpp b/src/Game/Systems/PlayerMovementSystem.cpp new file mode 100644 index 00000000..536624b3 --- /dev/null +++ b/src/Game/Systems/PlayerMovementSystem.cpp @@ -0,0 +1,16 @@ +#include "Systems/PlayerMovementSystem.h" + +void PlayerMovementSystem::UpdateComponent(World* world, EntityWrapper& entity, ComponentWrapper& component, double dt) +{ + ComponentWrapper& cTransform = entity["Transform"]; + if (!entity.HasComponent("Physics")) { + return; + } + ComponentWrapper& cPhysics = entity["Physics"]; + + glm::vec3& velocity = cPhysics["Velocity"]; + velocity.y -= 9.82 * dt; + + glm::vec3& position = cTransform["Position"]; + position += velocity * (float)dt; +} \ No newline at end of file diff --git a/src/Game/PlayerSystem.cpp b/src/Game/Systems/PlayerSystem.cpp similarity index 97% rename from src/Game/PlayerSystem.cpp rename to src/Game/Systems/PlayerSystem.cpp index 2d4d83c6..8cdddf84 100644 --- a/src/Game/PlayerSystem.cpp +++ b/src/Game/Systems/PlayerSystem.cpp @@ -1,4 +1,4 @@ -#include "PlayerSystem.h" +#include "Systems/PlayerSystem.h" void PlayerSystem::UpdateComponent(World* world, EntityWrapper& entity, ComponentWrapper& component, double dt) {