diff --git a/Escape-the-Dawn/Components/Bounds.h b/Escape-the-Dawn/Components/Bounds.h index 591165b..3845485 100644 --- a/Escape-the-Dawn/Components/Bounds.h +++ b/Escape-the-Dawn/Components/Bounds.h @@ -4,15 +4,14 @@ #include "Component.h" #include - namespace Components { struct Bounds : Component { - //Axis Aligned Bounding Box - glm::vec3 origin; - glm::vec3 volumeVector; //The vector that defines the volume of the BB, it goes from one corner to the opposite one + //Axis Aligned Bounding Box + glm::vec3 Origin; + glm::vec3 VolumeVector; //The vector that defines the volume of the BB, it goes from one corner to the opposite one }; } diff --git a/Escape-the-Dawn/Escape-the-Dawn.vcxproj b/Escape-the-Dawn/Escape-the-Dawn.vcxproj index b4ee946..04d7205 100644 --- a/Escape-the-Dawn/Escape-the-Dawn.vcxproj +++ b/Escape-the-Dawn/Escape-the-Dawn.vcxproj @@ -40,17 +40,14 @@ - $(SolutionDir)\Libraries\openal-soft-1.15.1-bin\lib\Win32;$(SolutionDir)\Libraries\glew-1.10.0\lib\Debug\Win32;$(SolutionDir)\Libraries\glfw-3.0.4\lib\Debug;$(LibraryPath) - $(SolutionDir)\Libraries\SOIL\lib\Debug;$(SolutionDir)\Libraries\glew-1.10.0\lib\Debug\Win32;$(SolutionDir)\Libraries\glfw-3.0.4\lib\Debug;$(LibraryPath) + $(SolutionDir)\Libraries\openal-soft-1.15.1-bin\lib\Win32;$(SolutionDir)\Libraries\SOIL\lib\Debug;$(SolutionDir)\Libraries\glew-1.10.0\lib\Debug\Win32;$(SolutionDir)\Libraries\glfw-3.0.4\lib\Debug;$(LibraryPath) $(SolutionDir)bin\ $(SolutionDir)obj\$(ProjectName)\ $(ProjectName)-$(Configuration) - $(SolutionDir)\Libraries\openal-soft-1.15.1-bin\include;$(ProjectDir);$(SolutionDir)\Libraries;$(SolutionDir)\Libraries\glew-1.10.0\include;$(SolutionDir)\Libraries\glfw-3.0.4\include;$(SolutionDir)\Libraries\glm-0.9.5.2;$(IncludePath) - $(SolutionDir)\Libraries\SOIL\src;\Libraries\SOIL\src;$(ProjectDir);$(SolutionDir)\Libraries;$(SolutionDir)\Libraries\glew-1.10.0\include;$(SolutionDir)\Libraries\glfw-3.0.4\include;$(SolutionDir)\Libraries\glm-0.9.5.2;$(IncludePath) + $(BOOST_ROOT);$(SolutionDir)\Libraries\openal-soft-1.15.1-bin\include;$(SolutionDir)\Libraries\SOIL\src;$(ProjectDir);$(SolutionDir)\Libraries;$(SolutionDir)\Libraries\glew-1.10.0\include;$(SolutionDir)\Libraries\glfw-3.0.4\include;$(SolutionDir)\Libraries\glm-0.9.5.2;$(IncludePath) - $(SolutionDir)\Libraries\SOIL\src;\Libraries\SOIL\src;$(ProjectDir);$(SolutionDir)\Libraries;$(SolutionDir)\Libraries\glew-1.10.0\include;$(SolutionDir)\Libraries\glfw-3.0.4\include;$(SolutionDir)\Libraries\glm-0.9.5.2;$(IncludePath) - $(ProjectDir);$(SolutionDir)\Libraries;$(SolutionDir)\Libraries\glew-1.10.0\include;$(SolutionDir)\Libraries\glfw-3.0.4\include;$(SolutionDir)\Libraries\glm-0.9.5.2;$(IncludePath) + $(BOOST_ROOT);$(SolutionDir)\Libraries\openal-soft-1.15.1-bin\include;$(SolutionDir)\Libraries\SOIL\src;$(ProjectDir);$(SolutionDir)\Libraries;$(SolutionDir)\Libraries\glew-1.10.0\include;$(SolutionDir)\Libraries\glfw-3.0.4\include;$(SolutionDir)\Libraries\glm-0.9.5.2;$(IncludePath) $(SolutionDir)\Libraries\SOIL\lib\Release;$(SolutionDir)\Libraries\glew-1.10.0\lib\Release\Win32;$(SolutionDir)\Libraries\glfw-3.0.4\lib\Release;$(LibraryPath) @@ -101,11 +98,16 @@ + + + + + @@ -133,9 +135,13 @@ + + + + @@ -148,6 +154,7 @@ + diff --git a/Escape-the-Dawn/Systems/SoundSystem.h b/Escape-the-Dawn/Systems/SoundSystem.h index 45a77cd..0adeaa9 100644 --- a/Escape-the-Dawn/Systems/SoundSystem.h +++ b/Escape-the-Dawn/Systems/SoundSystem.h @@ -1,24 +1,25 @@ #ifndef SoundEmitter_h__ #define SoundEmitter_h__ +#include "AL/al.h" +#include "AL/alc.h" + #include "System.h" #include "Components/SoundEmitter.h" #include #include #include -namespace System +namespace Systems { class SoundSystem : public System { public: - SoundSystem(World* world) : System(world) - { + SoundSystem(World* world); - } void Update(double dt) override; - void Update(double dt, EntityID entity, EntityID parent) override; + void UpdateEntity(double dt, EntityID entity, EntityID parent) override; void OnComponentCreated(std::string type, std::shared_ptr component) override; void PlaySound(std::shared_ptr emitter, std::string fileName); void LoadFile(const char* fileName); diff --git a/Escape-the-Dawn/Systems/SoundsSystem.cpp b/Escape-the-Dawn/Systems/SoundsSystem.cpp index e9e01af..f88d0d2 100644 --- a/Escape-the-Dawn/Systems/SoundsSystem.cpp +++ b/Escape-the-Dawn/Systems/SoundsSystem.cpp @@ -3,7 +3,8 @@ //#include -System::SoundSystem::SoundSystem(World* world) +Systems::SoundSystem::SoundSystem(World* world) + : System(world) { //initialize OpenAL @@ -18,12 +19,12 @@ System::SoundSystem::SoundSystem(World* world) } -void System::SoundSystem::Update(double dt) +void Systems::SoundSystem::Update(double dt) { } -void System::SoundSystem::Update(double dt, EntityID entity, EntityID parent) +void Systems::SoundSystem::UpdateEntity(double dt, EntityID entity, EntityID parent) { auto soundEmitter = m_World->GetComponent(entity, "SoundEmitter"); if(soundEmitter == nullptr) @@ -32,7 +33,7 @@ void System::SoundSystem::Update(double dt, EntityID entity, EntityID parent) } -void System::SoundSystem::PlaySound(std::shared_ptr emitter, std::string fileName) +void Systems::SoundSystem::PlaySound(std::shared_ptr emitter, std::string fileName) { //LoadFile(fileName); } diff --git a/Escape-the-Dawn/World.h b/Escape-the-Dawn/World.h index c8803e5..7f46c7f 100644 --- a/Escape-the-Dawn/World.h +++ b/Escape-the-Dawn/World.h @@ -2,10 +2,13 @@ #define World_h__ #include +#include #include #include #include +#include + #include "logging.h" #include "Factory.h" @@ -36,6 +39,17 @@ public: EntityID GetEntityParent(EntityID entity); + template + T GetProperty(EntityID entity, std::string property) + { + return boost::any_cast(m_EntityProperties[entity][property]); + } + + void SetProperty(EntityID entity, std::string property, boost::any value) + { + m_EntityProperties[entity][property] = value; + } + template std::shared_ptr AddComponent(EntityID entity, std::string componentType); std::shared_ptr AddComponent(EntityID entity, std::string componentType); @@ -59,6 +73,8 @@ protected: // A bottom to top tree. A map of child entities to parent entities. std::unordered_map m_EntityParents; + std::unordered_map> m_EntityProperties; + std::unordered_map>> m_ComponentsOfType; std::unordered_map>> m_EntityComponents; diff --git a/Executable/Executable.vcxproj b/Executable/Executable.vcxproj index e63646d..8ce4c7f 100644 --- a/Executable/Executable.vcxproj +++ b/Executable/Executable.vcxproj @@ -39,13 +39,13 @@ - $(SolutionDir)\Escape-the-Dawn;$(SolutionDir)\Libraries\SOIL\src;\Libraries\SOIL\src;$(ProjectDir);$(SolutionDir)\Libraries;$(SolutionDir)\Libraries\glew-1.10.0\include;$(SolutionDir)\Libraries\glfw-3.0.4\include;$(SolutionDir)\Libraries\glm-0.9.5.2;$(IncludePath) + $(SolutionDir)\Escape-the-Dawn;$(BOOST_ROOT);$(SolutionDir)\Libraries\openal-soft-1.15.1-bin\include;$(SolutionDir)\Libraries\SOIL\src;$(ProjectDir);$(SolutionDir)\Libraries;$(SolutionDir)\Libraries\glew-1.10.0\include;$(SolutionDir)\Libraries\glfw-3.0.4\include;$(SolutionDir)\Libraries\glm-0.9.5.2;$(IncludePath) $(SolutionDir)bin\ $(SolutionName)-$(Configuration) $(SolutionDir)obj\$(ProjectName)\ - $(SolutionDir)\Escape-the-Dawn;$(SolutionDir)\Libraries\SOIL\src;\Libraries\SOIL\src;$(ProjectDir);$(SolutionDir)\Libraries;$(SolutionDir)\Libraries\glew-1.10.0\include;$(SolutionDir)\Libraries\glfw-3.0.4\include;$(SolutionDir)\Libraries\glm-0.9.5.2;$(IncludePath) + $(SolutionDir)\Escape-the-Dawn;$(BOOST_ROOT);$(SolutionDir)\Libraries\openal-soft-1.15.1-bin\include;$(SolutionDir)\Libraries\SOIL\src;$(ProjectDir);$(SolutionDir)\Libraries;$(SolutionDir)\Libraries\glew-1.10.0\include;$(SolutionDir)\Libraries\glfw-3.0.4\include;$(SolutionDir)\Libraries\glm-0.9.5.2;$(IncludePath) $(SolutionDir)bin\ $(SolutionName)-$(Configuration) $(SolutionDir)obj\$(ProjectName)\ diff --git a/Tests/Tests.vcxproj b/Tests/Tests.vcxproj index 1f1fed7..18b7ec3 100644 --- a/Tests/Tests.vcxproj +++ b/Tests/Tests.vcxproj @@ -39,13 +39,13 @@ - $(BOOST_ROOT);$(SolutionDir)\Escape-the-Dawn;$(SolutionDir)\Libraries\SOIL\src;\Libraries\SOIL\src;$(ProjectDir);$(SolutionDir)\Libraries;$(SolutionDir)\Libraries\glew-1.10.0\include;$(SolutionDir)\Libraries\glfw-3.0.4\include;$(SolutionDir)\Libraries\glm-0.9.5.2;$(IncludePath) + $(SolutionDir)\Escape-the-Dawn;$(BOOST_ROOT);$(SolutionDir)\Libraries\openal-soft-1.15.1-bin\include;$(SolutionDir)\Libraries\SOIL\src;$(ProjectDir);$(SolutionDir)\Libraries;$(SolutionDir)\Libraries\glew-1.10.0\include;$(SolutionDir)\Libraries\glfw-3.0.4\include;$(SolutionDir)\Libraries\glm-0.9.5.2;$(IncludePath) $(BOOST_ROOT)\lib32-msvc-11.0;$(LibraryPath) $(ProjectDir)$(Configuration)\ $(SolutionDir)obj\$(ProjectName)\ - $(BOOST_ROOT);$(SolutionDir)\Escape-the-Dawn;$(SolutionDir)\Libraries\SOIL\src;\Libraries\SOIL\src;$(ProjectDir);$(SolutionDir)\Libraries;$(SolutionDir)\Libraries\glew-1.10.0\include;$(SolutionDir)\Libraries\glfw-3.0.4\include;$(SolutionDir)\Libraries\glm-0.9.5.2;$(IncludePath) + $(SolutionDir)\Escape-the-Dawn;$(BOOST_ROOT);$(SolutionDir)\Libraries\openal-soft-1.15.1-bin\include;$(SolutionDir)\Libraries\SOIL\src;$(ProjectDir);$(SolutionDir)\Libraries;$(SolutionDir)\Libraries\glew-1.10.0\include;$(SolutionDir)\Libraries\glfw-3.0.4\include;$(SolutionDir)\Libraries\glm-0.9.5.2;$(IncludePath) $(BOOST_ROOT)\lib32-msvc-11.0;$(LibraryPath) $(ProjectDir)$(Configuration)\ $(SolutionDir)obj\$(ProjectName)\ @@ -65,7 +65,7 @@ - $(OutDir)$(TargetName)$(TargetExt) --log_level=test_suite + "$(OutDir)$(TargetName)$(TargetExt)" --log_level=test_suite Running tests @@ -87,7 +87,7 @@ - $(OutDir)$(TargetName)$(TargetExt) --log_level=test_suite + "$(OutDir)$(TargetName)$(TargetExt)" --log_level=test_suite Running tests diff --git a/Tests/main.cpp b/Tests/main.cpp index 027263d..fdbaa18 100644 --- a/Tests/main.cpp +++ b/Tests/main.cpp @@ -1,6 +1,7 @@ #include "logging.h" #include "World.h" +#include "GameWorld.h" #include "Components/Transform.h" #define BOOST_TEST_MODULE World @@ -24,15 +25,19 @@ BOOST_AUTO_TEST_CASE(Parenting) BOOST_AUTO_TEST_CASE(SceneGraphTraversal) { - World world; + std::shared_ptr renderer(new Renderer()); + renderer->Initialize(); + GameWorld world(renderer); EntityID ent1 = world.CreateEntity(); auto t1 = world.AddComponent(ent1, "Transform"); + BOOST_REQUIRE(t1 != nullptr); t1->Position[0] = 1.0f; t1->Position[1] = 1.0f; t1->Position[2] = 1.0f; EntityID ent2 = world.CreateEntity(ent1); auto t2 = world.AddComponent(ent2, "Transform"); + BOOST_REQUIRE(t2 != nullptr); t2->Position[0] = 1.0f; t2->Position[1] = 1.0f; t2->Position[2] = 1.0f; @@ -61,4 +66,19 @@ BOOST_AUTO_TEST_CASE(ComponentCreation) EntityID ent = world.CreateEntity(); BOOST_CHECK(world.AddComponent(ent, "Transform") != nullptr); BOOST_CHECK(world.AddComponent(ent, "Input") != nullptr); +} + +BOOST_AUTO_TEST_CASE(Properties) +{ + World world; + + EntityID ent = world.CreateEntity(); + + world.SetProperty(ent, "String", std::string("derpfish")); + world.SetProperty(ent, "Integer", 123); + world.SetProperty(ent, "Float", 0.04f); + + BOOST_CHECK(world.GetProperty(ent, "String") == "derpfish"); + BOOST_CHECK(world.GetProperty(ent, "Integer") == 123); + BOOST_CHECK(world.GetProperty(ent, "Float") == 0.04f); } \ No newline at end of file