diff --git a/SHADE_Engine/src/ECS_Base/Components/SHComponent.h b/SHADE_Engine/src/ECS_Base/Components/SHComponent.h index edd8436c..aba3ba51 100644 --- a/SHADE_Engine/src/ECS_Base/Components/SHComponent.h +++ b/SHADE_Engine/src/ECS_Base/Components/SHComponent.h @@ -9,8 +9,7 @@ *********************************************************************/ -#ifndef SH_COMPONENT_H -#define SH_COMPONENT_H +#pragma once #include "SHpch.h" #include "../SHECSMacros.h" @@ -119,4 +118,3 @@ namespace SHADE }; } -#endif diff --git a/SHADE_Engine/src/ECS_Base/Components/SHComponentGroup.cpp b/SHADE_Engine/src/ECS_Base/Components/SHComponentGroup.cpp index 3ccb7778..2627d9fb 100644 --- a/SHADE_Engine/src/ECS_Base/Components/SHComponentGroup.cpp +++ b/SHADE_Engine/src/ECS_Base/Components/SHComponentGroup.cpp @@ -14,7 +14,7 @@ #include "SHpch.h" #include "SHComponentGroup.h" -#include "../System/SHComponentManager.h" +#include "../Managers/SHComponentManager.h" namespace SHADE diff --git a/SHADE_Engine/src/ECS_Base/Components/SHComponentGroup.h b/SHADE_Engine/src/ECS_Base/Components/SHComponentGroup.h index 3f67aff0..2b20ec13 100644 --- a/SHADE_Engine/src/ECS_Base/Components/SHComponentGroup.h +++ b/SHADE_Engine/src/ECS_Base/Components/SHComponentGroup.h @@ -12,9 +12,7 @@ consent of DigiPen Institute of Technology is prohibited. *********************************************************************/ - -#ifndef SH_COMPONENT_GROUP -#define SH_COMPONENT_GROUP +#pragma once #include "../SHECSMacros.h" #include "../General/SHFamily.h" @@ -180,6 +178,3 @@ namespace SHADE }; } - - -#endif diff --git a/SHADE_Engine/src/ECS_Base/Entity/SHEntity.cpp b/SHADE_Engine/src/ECS_Base/Entity/SHEntity.cpp index edf29ec7..2683a6e9 100644 --- a/SHADE_Engine/src/ECS_Base/Entity/SHEntity.cpp +++ b/SHADE_Engine/src/ECS_Base/Entity/SHEntity.cpp @@ -9,9 +9,9 @@ *********************************************************************/ #include "SHpch.h" #include "SHEntity.h" -#include "../System/SHEntityManager.h" +#include "../Managers/SHEntityManager.h" //#include "Scene/SHSceneGraph.h" -#include "../System/SHComponentManager.h" +#include "../Managers/SHComponentManager.h" namespace SHADE { @@ -39,6 +39,10 @@ namespace SHADE SHComponentManager::SetActive(entityID, active); } + bool SHEntity::GetActive(void) const noexcept + { + return isActive; + } void SHEntity::SetParent(SHEntity* newParent) noexcept @@ -53,20 +57,20 @@ namespace SHADE //TODO } - SHEntity* SHEntity::GetParent() noexcept + SHEntity* SHEntity::GetParent()const noexcept { //TODO return nullptr; } - std::vectorconst& SHEntity::GetChildren() noexcept + std::vectorconst& SHEntity::GetChildren()const noexcept { //TODO return std::vector{}; } - std::vectorconst& SHEntity::GetChildrenID() noexcept + std::vectorconst& SHEntity::GetChildrenID()const noexcept { return std::vector{}; } diff --git a/SHADE_Engine/src/ECS_Base/Entity/SHEntity.h b/SHADE_Engine/src/ECS_Base/Entity/SHEntity.h index 9077b0b9..e499e260 100644 --- a/SHADE_Engine/src/ECS_Base/Entity/SHEntity.h +++ b/SHADE_Engine/src/ECS_Base/Entity/SHEntity.h @@ -8,12 +8,11 @@ consent of DigiPen Institute of Technology is prohibited. *********************************************************************/ -#ifndef SH_ENTITY_H -#define SH_ENTITY_H +#pragma once #include "../SHECSMacros.h" #include "../Components/SHComponent.h" -#include "../System/SHComponentManager.h" +#include "../Managers/SHComponentManager.h" //#include "../../Scene/SHSceneNode.h" #include "SH_API.h" @@ -64,7 +63,7 @@ namespace SHADE * Returns nullptr if the entity does not have such Component. ***************************************************************************/ template - std::enable_if_t, T*> GetComponent() noexcept + std::enable_if_t, T*> GetComponent()const noexcept { return SHComponentManager::GetComponent_s(entityID); @@ -92,6 +91,7 @@ namespace SHADE ***************************************************************************/ virtual void SetActive(bool active) noexcept; + bool GetActive(void)const noexcept; /************************************************************************** @@ -125,7 +125,7 @@ namespace SHADE * Returns a pointer to the parent entity. * Returns a nullptr if the parent node is the root node. ***************************************************************************/ - SHEntity* GetParent() noexcept; + SHEntity* GetParent()const noexcept; /************************************************************************** @@ -134,7 +134,7 @@ namespace SHADE * \return * Return a vector of SHEntity pointers of the children belonging to this entity. ***************************************************************************/ - std::vectorconst& GetChildren() noexcept; + std::vectorconst& GetChildren()const noexcept; /************************************************************************** * \brief @@ -142,11 +142,13 @@ namespace SHADE * \return * return a vector of EntityID of the children belonging to this entity. ***************************************************************************/ - std::vectorconst& GetChildrenID() noexcept; - + std::vectorconst& GetChildrenID()const noexcept; + //Name of the entity. This name is non-unique and only used for the editor. std::string name; - bool isActive; + + + private: @@ -157,8 +159,10 @@ namespace SHADE EntityID entityID; + //Entity active state. This should only be set using the SetActive function which will + //set the active state of all components of this entity. + bool isActive; + + }; } - - -#endif diff --git a/SHADE_Engine/src/ECS_Base/General/SHFamily.h b/SHADE_Engine/src/ECS_Base/General/SHFamily.h index f97bbe0e..5815703f 100644 --- a/SHADE_Engine/src/ECS_Base/General/SHFamily.h +++ b/SHADE_Engine/src/ECS_Base/General/SHFamily.h @@ -11,8 +11,7 @@ consent of DigiPen Institute of Technology is prohibited. *********************************************************************/ -#ifndef SH_FAMILY_H -#define SH_FAMILY_H +#pragma once #include "../SHECSMacros.h" @@ -81,8 +80,4 @@ namespace SHADE template ComponentTypeID SHFamilyID::currentID = 0; -} - - - -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/SHADE_Engine/src/ECS_Base/General/SHHandleGenerator.h b/SHADE_Engine/src/ECS_Base/General/SHHandleGenerator.h index 48ae2132..7c68f66d 100644 --- a/SHADE_Engine/src/ECS_Base/General/SHHandleGenerator.h +++ b/SHADE_Engine/src/ECS_Base/General/SHHandleGenerator.h @@ -11,8 +11,7 @@ or disclosure of this file or its contents without the prior written consent of DigiPen Institute of Technology is prohibited. *********************************************************************/ -#ifndef SH_HANDLE_GENERATOR_H -#define SH_HANDLE_GENERATOR_H +#pragma once #include #include @@ -299,7 +298,4 @@ namespace SHADE typedef SHHandleGenerator EntityHandleGenerator; -} - - -#endif +} \ No newline at end of file diff --git a/SHADE_Engine/src/ECS_Base/General/SHSparseBase.h b/SHADE_Engine/src/ECS_Base/General/SHSparseBase.h index 2deebe74..913fca5a 100644 --- a/SHADE_Engine/src/ECS_Base/General/SHSparseBase.h +++ b/SHADE_Engine/src/ECS_Base/General/SHSparseBase.h @@ -10,8 +10,7 @@ consent of DigiPen Institute of Technology is prohibited. *********************************************************************/ -#ifndef SH_SPARSE_BASE_H -#define SH_SPARSE_BASE_H +#pragma once #include "../SHECSMacros.h" @@ -44,7 +43,4 @@ namespace SHADE }; -} - - -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/SHADE_Engine/src/ECS_Base/General/SHSparseSet.h b/SHADE_Engine/src/ECS_Base/General/SHSparseSet.h index 3473eb37..8e096a37 100644 --- a/SHADE_Engine/src/ECS_Base/General/SHSparseSet.h +++ b/SHADE_Engine/src/ECS_Base/General/SHSparseSet.h @@ -9,8 +9,7 @@ or disclosure of this file or its contents without the prior written consent of DigiPen Institute of Technology is prohibited. *********************************************************************/ -#ifndef SH_SPARSE_SET_H -#define SH_SPARSE_SET_H +#pragma once #include "../SHECSMacros.h" #include "../General/SHSparseBase.h" @@ -351,6 +350,4 @@ namespace SHADE } }; -} - -#endif +} \ No newline at end of file diff --git a/SHADE_Engine/src/ECS_Base/General/SHSparseSetContainer.h b/SHADE_Engine/src/ECS_Base/General/SHSparseSetContainer.h index 8698d1f5..8f8814f6 100644 --- a/SHADE_Engine/src/ECS_Base/General/SHSparseSetContainer.h +++ b/SHADE_Engine/src/ECS_Base/General/SHSparseSetContainer.h @@ -10,8 +10,7 @@ consent of DigiPen Institute of Technology is prohibited. *********************************************************************/ -#ifndef SH_SPARSE_SET_CONTAINER_H -#define SH_SPARSE_SET_CONTAINER_H +#pragma once #include "SHSparseSet.h" #include "SHFamily.h" @@ -243,6 +242,3 @@ namespace SHADE }; } - - -#endif diff --git a/SHADE_Engine/src/ECS_Base/System/SHComponentManager.cpp b/SHADE_Engine/src/ECS_Base/Managers/SHComponentManager.cpp similarity index 100% rename from SHADE_Engine/src/ECS_Base/System/SHComponentManager.cpp rename to SHADE_Engine/src/ECS_Base/Managers/SHComponentManager.cpp diff --git a/SHADE_Engine/src/ECS_Base/System/SHComponentManager.h b/SHADE_Engine/src/ECS_Base/Managers/SHComponentManager.h similarity index 95% rename from SHADE_Engine/src/ECS_Base/System/SHComponentManager.h rename to SHADE_Engine/src/ECS_Base/Managers/SHComponentManager.h index 75db35d5..20720760 100644 --- a/SHADE_Engine/src/ECS_Base/System/SHComponentManager.h +++ b/SHADE_Engine/src/ECS_Base/Managers/SHComponentManager.h @@ -12,8 +12,7 @@ consent of DigiPen Institute of Technology is prohibited. *********************************************************************/ -#ifndef SH_ENGINE_H -#define SH_ENGINE_H +#pragma once #include "../General/SHSparseSetContainer.h" #include "../Components/SHComponent.h" @@ -26,6 +25,8 @@ namespace SHADE { + typedef SHFamilyID ComponentFamily; + class SH_API SHComponentManager { private: @@ -37,6 +38,8 @@ namespace SHADE friend struct SHSceneNode; + + /************************************************************************** @@ -226,7 +229,7 @@ namespace SHADE * \return * none ***************************************************************************/ - static void AddComponent(EntityID entityID, uint32_t componentTypeID) noexcept + static void AddComponent(EntityID entityID, ComponentTypeID componentTypeID) noexcept { componentSet.GetSparseSet_ID(componentTypeID)->Add(EntityHandleGenerator::GetIndex(entityID)); @@ -278,7 +281,7 @@ namespace SHADE * \return bool * True if the entity has a component of specified type. ***************************************************************************/ - static bool HasComponent_ID(EntityID entityID, uint32_t componentTypeID) noexcept; + static bool HasComponent_ID(EntityID entityID, ComponentTypeID componentTypeID) noexcept; /*!************************************************************************* @@ -363,7 +366,7 @@ namespace SHADE * \return * ***************************************************************************/ - static void SwapInDenseByIndexHash_ID(EntityIndex index, EntityID hash, uint32_t componentTypeID) noexcept; + static void SwapInDenseByIndexHash_ID(EntityIndex index, EntityID hash, ComponentTypeID componentTypeID) noexcept; @@ -386,7 +389,7 @@ namespace SHADE * \return * The number of components in the component sparse set. ***************************************************************************/ - static EntityIndex ComponentCount_ID(uint32_t componentTypeID) + static EntityIndex ComponentCount_ID(ComponentTypeID componentTypeID) { return componentSet.GetSparseSet_ID(componentTypeID)->Count(); } @@ -403,9 +406,9 @@ namespace SHADE static void SetActive(EntityID entityID, bool active) noexcept; template - static std::enable_if_t<(... && std::is_base_of_v), uint32_t> CreateComponentGroup(uint32_t numOwningComponents) + static std::enable_if_t<(... && std::is_base_of_v), uint32_t> CreateComponentGroup(ComponentTypeID numOwningComponents) { - std::vector templateIDs{ (SHFamilyID::GetID())... }; + std::vector templateIDs{ (ComponentFamily::GetID())... }; for (auto& g : componentGroups) { @@ -422,11 +425,11 @@ namespace SHADE } SHComponentGroup grp; - for (uint32_t i = 0; i < numOwningComponents; ++i) + for (ComponentTypeID i = 0; i < numOwningComponents; ++i) { grp.ownedComponentTypes.push_back(templateIDs[i]); } - for (uint32_t i = 0; i < templateIDs.size(); ++i) + for (ComponentTypeID i = 0; i < templateIDs.size(); ++i) { grp.componentTypeIDs.push_back(templateIDs[i]); } @@ -472,7 +475,4 @@ namespace SHADE -} - - -#endif +} \ No newline at end of file diff --git a/SHADE_Engine/src/ECS_Base/System/SHEntityManager.cpp b/SHADE_Engine/src/ECS_Base/Managers/SHEntityManager.cpp similarity index 77% rename from SHADE_Engine/src/ECS_Base/System/SHEntityManager.cpp rename to SHADE_Engine/src/ECS_Base/Managers/SHEntityManager.cpp index 4aa38112..240c0b32 100644 --- a/SHADE_Engine/src/ECS_Base/System/SHEntityManager.cpp +++ b/SHADE_Engine/src/ECS_Base/Managers/SHEntityManager.cpp @@ -52,63 +52,20 @@ namespace SHADE return entityHandle.GetIndex(entityID); } - EntityID SHEntityManager::CreateEntity(std::vectorconst& componentTypeIDs, std::string const& name,EntityID parentEID) - { - EntityID eID = entityHandle.GetNewHandle(); - EntityIndex eIndex = entityHandle.GetIndex(eID); - if (eIndex > entityVec.size()) - { - assert("FATAL ERROR: EntityIndex out of range in Entity Creation"); - } - else if (eIndex == entityVec.size()) - { - entityVec.emplace_back(std::make_unique()); - } - else - { - if (!entityVec[eIndex]) - { - //There is still an entity stored there.Something went wrong - assert("FATAL ERROR: Entity Creation error. Entity Index Conflict"); - } - - //Reset it to a newly constructed entity - entityVec[eIndex].reset(new SHEntity()); - } - - - entityVec[eIndex]->entityID = eID; - entityVec[eIndex]->name = name; - for (auto& id : componentTypeIDs) - { - SHComponentManager::AddComponent(eID, id); - } - - //(SHComponentManager::AddComponent(eID), ...); - /*if (entityHandle.IsValid(parentEID) == false) - { - entityVec[eIndex]->sceneNode.ConnectToRoot(); - } - else - { - entityVec[eIndex]->SetParent(parentEID); - }*/ - - - //TODO Link to Scene graph. - - return eID; - - } - EntityID SHEntityManager::CreateEntity(std::vectorconst& componentTypeIDs, EntityID desiredEID, std::string const& name, EntityID parentEID) { - EntityID eID ; - - if (entityHandle.ClaimHandle(desiredEID) == true) - eID = desiredEID; - else + EntityID eID; + if (desiredEID == MAX_EID) + { eID = entityHandle.GetNewHandle(); + } + else + { + if (entityHandle.ClaimHandle(desiredEID) == true) + eID = desiredEID; + else + eID = entityHandle.GetNewHandle(); + } EntityIndex eIndex = entityHandle.GetIndex(eID); diff --git a/SHADE_Engine/src/ECS_Base/System/SHEntityManager.h b/SHADE_Engine/src/ECS_Base/Managers/SHEntityManager.h similarity index 72% rename from SHADE_Engine/src/ECS_Base/System/SHEntityManager.h rename to SHADE_Engine/src/ECS_Base/Managers/SHEntityManager.h index 802ef75d..2d8a3ce5 100644 --- a/SHADE_Engine/src/ECS_Base/System/SHEntityManager.h +++ b/SHADE_Engine/src/ECS_Base/Managers/SHEntityManager.h @@ -12,9 +12,7 @@ or disclosure of this file or its contents without the prior written consent of DigiPen Institute of Technology is prohibited. *********************************************************************/ - -#ifndef SH_ENTITY_MANAGER_H -#define SH_ENTITY_MANAGER_H +#pragma once #include #include @@ -82,55 +80,21 @@ namespace SHADE * EntityID of the new Entity ***************************************************************************/ template - static std::enable_if_t<(... && std::is_base_of_v), EntityID> CreateEntity(std::string const& name = "Default", EntityID parentEID = MAX_EID) - { - EntityID eID = entityHandle.GetNewHandle(); - EntityIndex eIndex = entityHandle.GetIndex(eID); - if (eIndex > entityVec.size()) - { - assert("FATAL ERROR: EntityIndex out of range in Entity Creation"); - } - else if (eIndex == entityVec.size()) - { - entityVec.emplace_back(std::make_unique()); - } - else - { - if (!entityVec[eIndex]) - { - //There is still an entity stored there.Something went wrong - assert("FATAL ERROR: Entity Creation error. Entity Index Conflict"); - } - - //Reset it to a newly constructed entity - entityVec[eIndex].reset(new SHEntity()); - } - entityVec[eIndex]->entityID = eID; - entityVec[eIndex]->name = name; - (SHComponentManager::AddComponent(eID),...); - - /*if (entityHandle.IsValid(parentEID) == false) - { - entityVec[eIndex]->sceneNode.ConnectToRoot(); - } - else - { - entityVec[eIndex]->SetParent(parentEID); - }*/ - - //TODO Link up with Scene graph - - return eID; - } - - template - static std::enable_if_t<(... && std::is_base_of_v), EntityID> CreateEntity(EntityID desiredEID, std::string const& name = "Default", EntityID parentEID = MAX_EID) + static std::enable_if_t<(... && std::is_base_of_v), EntityID> CreateEntity(EntityID desiredEID = MAX_EID, std::string const& name = "Default", EntityID parentEID = MAX_EID) { EntityID eID; - if (entityHandle.ClaimHandle(desiredEID) == true) - eID = desiredEID; - else + if (desiredEID == MAX_EID) + { eID = entityHandle.GetNewHandle(); + } + else + { + if (entityHandle.ClaimHandle(desiredEID) == true) + eID = desiredEID; + else + eID = entityHandle.GetNewHandle(); + } + EntityIndex eIndex = entityHandle.GetIndex(eID); if (eIndex > entityVec.size()) { @@ -180,21 +144,6 @@ namespace SHADE - /************************************************************************** - * \brief - * Create Entity using a vector of ComponentTypeIDs. - * \param componentTypeIDs - * Vector of ComponentTypeIDs. This assumes that CreateSparseSet is called - * for these ComponentTypes. - * \param name - * Name of the Entity (this is not unique) - * \param parentEID - * The entity ID of the parent. This does not call UpdateHierarchy hence - * the parent of the entity is not updated until UpdateHierarchy is called. - * \return - * EntityID of the new Entity - ***************************************************************************/ - static EntityID CreateEntity(std::vectorconst& componentTypeIDs,std::string const& name = "Default", EntityID parentEID = MAX_EID); /************************************************************************** * \brief @@ -210,7 +159,7 @@ namespace SHADE * \return * EntityID of the new Entity ***************************************************************************/ - static EntityID CreateEntity(std::vectorconst& componentTypeIDs, EntityID desiredEID, std::string const& name = "Default", EntityID parentEID = MAX_EID); + static EntityID CreateEntity(std::vectorconst& componentTypeIDs, EntityID desiredEID = MAX_EID, std::string const& name = "Default", EntityID parentEID = MAX_EID); /************************************************************************** * \brief @@ -248,7 +197,3 @@ namespace SHADE } - - - -#endif diff --git a/SHADE_Engine/src/ECS_Base/Managers/SHSystemManager.cpp b/SHADE_Engine/src/ECS_Base/Managers/SHSystemManager.cpp new file mode 100644 index 00000000..551233db --- /dev/null +++ b/SHADE_Engine/src/ECS_Base/Managers/SHSystemManager.cpp @@ -0,0 +1,77 @@ +/********************************************************************* + * \file SHSystemManager.cpp + * \author Daniel Chua Yee Chen + * \brief Implementation for the SHSystemManager class. + * SHSystemManager is the interface class where users of the engine create + * the systems that gives the components their functionality. This also + * ensures that the Init and Exit functions are ran at the appropriate time + * + * \copyright Copyright (c) 2021 DigiPen Institute of Technology. Reproduction + or disclosure of this file or its contents without the prior written + consent of DigiPen Institute of Technology is prohibited. + *********************************************************************/ +#include "SHpch.h" +#include "SHSystemManager.h" +#include + +#include +#include +#include + +namespace SHADE +{ + SHSystemManager::SystemContainer SHSystemManager::systemContainer; + SHSystemManager::SystemRoutineContainer SHSystemManager::systemRoutineContainer; + + void SHSystemManager::Init() noexcept + { + for (auto& system : systemContainer) + { + system.second->Init(); +#ifdef _DEBUG + std::cout << system.first << " Init" << std::endl; +#endif + } + } + + void SHSystemManager::RunRoutines(bool editorPause, double deltaTime) noexcept + { + for (auto& routine : systemRoutineContainer) + { + if (editorPause == true) + { + if (routine.get()->IsRunInEditorPause) + { + std::chrono::high_resolution_clock::time_point start = std::chrono::high_resolution_clock::now(); + routine.get()->Execute(deltaTime); + std::chrono::high_resolution_clock::time_point end = std::chrono::high_resolution_clock::now(); + routine.get()->stats.executionTime = std::chrono::duration(end - start).count(); + } + } + else + { + std::chrono::high_resolution_clock::time_point start = std::chrono::high_resolution_clock::now(); + routine.get()->Execute(deltaTime); + std::chrono::high_resolution_clock::time_point end = std::chrono::high_resolution_clock::now(); + routine.get()->stats.executionTime = std::chrono::duration(end - start).count(); + } + } + } + + + void SHSystemManager::Exit() noexcept + { + systemRoutineContainer.clear(); + + for (SystemContainer::reverse_iterator it = systemContainer.rbegin(); it != systemContainer.rend(); ++it) + { + (*it).second->Exit(); + //delete system.second; + } + + systemContainer.clear(); + + } + + +} diff --git a/SHADE_Engine/src/ECS_Base/System/SHSystemManager.h b/SHADE_Engine/src/ECS_Base/Managers/SHSystemManager.h similarity index 56% rename from SHADE_Engine/src/ECS_Base/System/SHSystemManager.h rename to SHADE_Engine/src/ECS_Base/Managers/SHSystemManager.h index d5a4866d..f97d98a2 100644 --- a/SHADE_Engine/src/ECS_Base/System/SHSystemManager.h +++ b/SHADE_Engine/src/ECS_Base/Managers/SHSystemManager.h @@ -10,29 +10,32 @@ consent of DigiPen Institute of Technology is prohibited. *********************************************************************/ - -#ifndef SH_SYSTEM_MANAGER_H -#define SH_SYSTEM_MANAGER_H +#pragma once -#include +#include #include #include #include +#include #include "../System/SHSystem.h" - +#include "../General/SHFamily.h" +#include "../System/SHSystemRoutine.h" namespace SHADE { + + typedef SHFamilyID SystemFamily; + class SHSystemManager { //type definition for the container we use to store our system - using SystemContainer = std::unordered_map>; - + using SystemContainer = std::map>; + using SystemRoutineContainer = std::vector>; private: static SystemContainer systemContainer; - + static SystemRoutineContainer systemRoutineContainer; public: /*!************************************************************************* @@ -43,45 +46,79 @@ namespace SHADE ~SHSystemManager() = delete; /************************************************************************** - * \brief + * \brief * Create a system of type T and map it to a name. * throws an error if a system with the same name already exists. * \param name * name of the system - * \return + * \return * none ***************************************************************************/ template - static std::enable_if_t, void> CreateSystem(std::string const& name) + static std::enable_if_t, SystemID> CreateSystem() { - if (systemContainer.find(name) != systemContainer.end()) + SystemTypeID typeID = SystemFamily::GetID(); + + SystemVersionID version = 0; + SystemID id = ((SystemID)version << sizeof(SystemVersionID) * CHAR_BIT) + typeID; + while (systemContainer.find(id) != systemContainer.end()) { - assert("System Creation Error: System with the same name already exist."); + ++version; + id = ((SystemID)version << sizeof(SystemVersionID) * CHAR_BIT) + typeID; } + systemContainer.emplace(id, std::make_unique()); + systemContainer[id].get()->systemID = id; - systemContainer.emplace(name, std::make_unique()); - + return id; } /************************************************************************** - * \brief + * \brief * Get a pointer to the System with a specified name. * \param name * Name of the system in the map - * \return + * \return * Base System pointer. ***************************************************************************/ - static SHSystem* GetSystem(std::string name); + template + static std::enable_if_t, T*> GetSystem(SystemVersionID version = 0) + { + SystemTypeID typeID = SystemFamily::GetID(); + + SystemID id = ((SystemID)version << sizeof(SystemVersionID) * CHAR_BIT) + typeID; + + if (systemContainer.find(id) == systemContainer.end()) + { + std::cout << "System Manager error: System Version " << version << " does not exit." << std::endl; + return nullptr; + } + + return (T*)systemContainer.find(id)->second.get(); + } /************************************************************************** - * \brief + * \brief * Call the Init function of all systems. - * \return + * \return * none ***************************************************************************/ static void Init() noexcept; + static void RunRoutines(bool editorPause, double deltaTime) noexcept; + + template + static void RegisterRoutine(SystemVersionID version = 0) noexcept + { + SHSystem* system = GetSystem(version); + if (system == nullptr) + return; + systemRoutineContainer.emplace_back(std::make_unique()); + systemRoutineContainer.back().get()->system = system; + + } + + /************************************************************************** * \brief * Call the Exit function of all systems. @@ -95,8 +132,4 @@ namespace SHADE }; -} - - - -#endif +} \ No newline at end of file diff --git a/SHADE_Engine/src/ECS_Base/SHECSMacros.h b/SHADE_Engine/src/ECS_Base/SHECSMacros.h index 5243e20f..02615ca4 100644 --- a/SHADE_Engine/src/ECS_Base/SHECSMacros.h +++ b/SHADE_Engine/src/ECS_Base/SHECSMacros.h @@ -9,6 +9,10 @@ typedef uint32_t EntityID; typedef uint16_t EntityIndex; typedef uint32_t ComponentTypeID; +typedef uint32_t SystemTypeID; +typedef uint32_t SystemVersionID; +typedef uint64_t SystemID; + const EntityIndex MAX_EID = 51000; diff --git a/SHADE_Engine/src/ECS_Base/System/SHFixedSystemRoutine.cpp b/SHADE_Engine/src/ECS_Base/System/SHFixedSystemRoutine.cpp new file mode 100644 index 00000000..fa34a5cf --- /dev/null +++ b/SHADE_Engine/src/ECS_Base/System/SHFixedSystemRoutine.cpp @@ -0,0 +1,21 @@ +#include "SHpch.h" +#include "SHFixedSystemRoutine.h" +#include "../SHECSMacros.h" + +namespace SHADE +{ + + void SHFixedSystemRoutine::Execute(double dt) noexcept + { + accumulatedTime += dt; + int counter = 0; + while (accumulatedTime >= fixedTimeStep) + { + ++counter; + accumulatedTime -= fixedTimeStep; + FixedExecute(fixedTimeStep); + } + stats.numSteps = counter; + } + +} \ No newline at end of file diff --git a/SHADE_Engine/src/ECS_Base/System/SHFixedSystemRoutine.h b/SHADE_Engine/src/ECS_Base/System/SHFixedSystemRoutine.h new file mode 100644 index 00000000..d9a2b510 --- /dev/null +++ b/SHADE_Engine/src/ECS_Base/System/SHFixedSystemRoutine.h @@ -0,0 +1,31 @@ +#pragma once + + +#include "SHSystemRoutine.h" +#define DEFAULT_FIXED_STEP 1.0/60.0 + +namespace SHADE +{ + class SHFixedSystemRoutine: public SHSystemRoutine + { + private: + double accumulatedTime; + double fixedTimeStep; + + protected: + SHFixedSystemRoutine(double timeStep = DEFAULT_FIXED_STEP, std::string routineName = "Default Fixed Routine Name", bool editorPause = false) + :SHSystemRoutine(routineName, editorPause), accumulatedTime(0.0), fixedTimeStep(timeStep){} + + + + public: + ~SHFixedSystemRoutine() = default; + + virtual void Execute(double dt) noexcept; + + virtual void FixedExecute(double dt) noexcept {}; + + }; + + +} \ No newline at end of file diff --git a/SHADE_Engine/src/ECS_Base/System/SHRoutineStats.h b/SHADE_Engine/src/ECS_Base/System/SHRoutineStats.h new file mode 100644 index 00000000..513358ee --- /dev/null +++ b/SHADE_Engine/src/ECS_Base/System/SHRoutineStats.h @@ -0,0 +1,28 @@ +#pragma once + +#include +#include + +namespace SHADE +{ + struct SHRoutineStats + { + SHRoutineStats(std::string name) + :name(name) + { + } + std::string name; + double executionTime; + int numSteps{1}; + + //friend std::ostream& operator<<(std::ostream& os, const SHRoutineStats& stats); + }; + + //std::ostream& operator<<(std::ostream& os, const SHRoutineStats& stats) + //{ + // os << stats.name << ": Execution Time: " << stats.executionTime << " Number of steps: " << stats.numSteps << std::endl; + // return os; + //} + + +} \ No newline at end of file diff --git a/SHADE_Engine/src/ECS_Base/System/SHSystem.h b/SHADE_Engine/src/ECS_Base/System/SHSystem.h index 1a304605..19b16f72 100644 --- a/SHADE_Engine/src/ECS_Base/System/SHSystem.h +++ b/SHADE_Engine/src/ECS_Base/System/SHSystem.h @@ -8,19 +8,29 @@ consent of DigiPen Institute of Technology is prohibited. *********************************************************************/ -#ifndef SH_SYSTEM_H -#define SH_SYSTEM_H +#pragma once + +#include "../SHECSMacros.h" namespace SHADE { + + class SHSystemManager; + class SHSystem { + private: + SystemID systemID; + protected: /*!************************************************************************* * \brief * Protected default constructor for SHSytem class ***************************************************************************/ SHSystem()= default; + + + public: /*!************************************************************************* @@ -35,13 +45,13 @@ namespace SHADE ***************************************************************************/ virtual void Init() = 0; - /*!************************************************************************* - * \brief - * Pure virtual Run function. Derived class must implement this - * \param dt - * Delta time - ***************************************************************************/ - virtual void Run(float dt) = 0; + ///*!************************************************************************* + // * \brief + // * Pure virtual Run function. Derived class must implement this + // * \param dt + // * Delta time + //***************************************************************************/ + //virtual void Run(float dt) = 0; /*!************************************************************************* * \brief @@ -49,7 +59,14 @@ namespace SHADE ***************************************************************************/ virtual void Exit() = 0; - }; -} + friend class SHSystemManager; -#endif \ No newline at end of file + inline SystemID GetSystemID(void) const noexcept { return systemID; } + inline SystemVersionID GetSystemVersion(void) const noexcept { return static_cast(systemID >> sizeof(SystemVersionID) * CHAR_BIT); } + + + }; + + + +} \ No newline at end of file diff --git a/SHADE_Engine/src/ECS_Base/System/SHSystemManager.cpp b/SHADE_Engine/src/ECS_Base/System/SHSystemManager.cpp deleted file mode 100644 index 67d6f781..00000000 --- a/SHADE_Engine/src/ECS_Base/System/SHSystemManager.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/********************************************************************* - * \file SHSystemManager.cpp - * \author Daniel Chua Yee Chen - * \brief Implementation for the SHSystemManager class. - * SHSystemManager is the interface class where users of the engine create - * the systems that gives the components their functionality. This also - * ensures that the Init and Exit functions are ran at the appropriate time - * - * \copyright Copyright (c) 2021 DigiPen Institute of Technology. Reproduction - or disclosure of this file or its contents without the prior written - consent of DigiPen Institute of Technology is prohibited. - *********************************************************************/ -#include "SHpch.h" -#include "SHSystemManager.h" -#include - -namespace SHADE -{ - SHSystemManager::SystemContainer SHSystemManager::systemContainer; - - - SHSystem* SHSystemManager::GetSystem(std::string name) - { - if (systemContainer.find(name) == systemContainer.end()) - { - assert("Get System Error: No system with such name exist."); - return nullptr; - } - - return systemContainer.find(name)->second.get(); - } - - void SHSystemManager::Init() noexcept - { - for (auto& system : systemContainer) - { - system.second->Init(); -#ifdef _DEBUG - std::cout << system.first << " Init" << std::endl; -#endif - } - } - - void SHSystemManager::Exit() noexcept - { - for (auto& system : systemContainer) - { - system.second->Exit(); - //delete system.second; - } - - systemContainer.clear(); - - } - - -} diff --git a/SHADE_Engine/src/ECS_Base/System/SHSystemRoutine.cpp b/SHADE_Engine/src/ECS_Base/System/SHSystemRoutine.cpp new file mode 100644 index 00000000..73157e8b --- /dev/null +++ b/SHADE_Engine/src/ECS_Base/System/SHSystemRoutine.cpp @@ -0,0 +1,23 @@ +#include "SHpch.h" +#include "SHSystemRoutine.h" + + +namespace SHADE +{ + + SHSystem* SHSystemRoutine::GetSystem() const noexcept + { + return system; + } + + std::string const SHSystemRoutine::GetName()const noexcept + { + return name; + } + + SHRoutineStats const& SHSystemRoutine::GetStats()const noexcept + { + return stats; + } + +} diff --git a/SHADE_Engine/src/ECS_Base/System/SHSystemRoutine.h b/SHADE_Engine/src/ECS_Base/System/SHSystemRoutine.h new file mode 100644 index 00000000..cdb62438 --- /dev/null +++ b/SHADE_Engine/src/ECS_Base/System/SHSystemRoutine.h @@ -0,0 +1,53 @@ + + + +#pragma once + +#include "../SHECSMacros.h" +#include "SHRoutineStats.h" +#include "SHSystem.h" +#include + + +namespace SHADE +{ + + class SHSystemManager; + + + class SHSystemRoutine + { + friend class SHSystemManager; + protected: + + SHSystemRoutine(std::string routineName = "Default Routine Name", bool editorPause = false) + :system(nullptr), name(routineName), stats(routineName),IsRunInEditorPause(editorPause){}; + + + SHSystem* system; + std::string name; + SHRoutineStats stats; + + //Whether or not this routine should run when the editor is still in pause + bool IsRunInEditorPause; + + + public: + ~SHSystemRoutine() = default; + + + SHSystem* GetSystem()const noexcept; + std::string const GetName() const noexcept; + SHRoutineStats const& GetStats()const noexcept; + + virtual void Execute(double dt) noexcept {}; + }; + + + + +} + + + + diff --git a/SHADE_Engine/src/ECS_Base/UnitTesting/SHECSUnitTest.cpp b/SHADE_Engine/src/ECS_Base/UnitTesting/SHECSUnitTest.cpp new file mode 100644 index 00000000..c9d8477b --- /dev/null +++ b/SHADE_Engine/src/ECS_Base/UnitTesting/SHECSUnitTest.cpp @@ -0,0 +1,181 @@ +#include "SHpch.h" +#include "SHECSUnitTest.h" +#include "../Managers/SHComponentManager.h" +#include "../Managers/SHEntityManager.h" +#include "../Managers/SHSystemManager.h" +#include "SHTestComponents.h" +#include "SHTestSystems.h" +#include "Tools/SHLogger.h" + + + +namespace SHADE +{ + void SHECSUnitTest::TestAll(void) noexcept + { + TestBasicEntityCreate(); + TestEntityCreateTemplate(); + TestEntityDestroy(); + TestSystemRoutine(); + } + + + void SHECSUnitTest::TestBasicEntityCreate(void) noexcept + { + + SHComponentManager::CreateComponentSparseSet(); + SHComponentManager::CreateComponentSparseSet(); + SHComponentManager::CreateComponentSparseSet(); + + SHLOG_INFO("Test for add and remove component") + + EntityID id1 = SHEntityManager::CreateEntity(); + EntityID id2 = SHEntityManager::CreateEntity(); + EntityID id3 = SHEntityManager::CreateEntity(); + + + SHComponentManager::AddComponent(id1); + } + + + void SHECSUnitTest::TestEntityCreateTemplate(void) noexcept + { + std::cout << "\nTest2" << std::endl; + //Test entity Creation. + + SHComponentManager::CreateComponentSparseSet(); + SHComponentManager::CreateComponentSparseSet(); + SHComponentManager::CreateComponentSparseSet(); + + + + for (size_t i = 0; i < 10000; ++i) + { + switch (i % 3) + { + case 0: + { + SHEntityManager::CreateEntity(); + }break; + case 1: + { + SHEntityManager::CreateEntity(); + }break; + + case 2: + { + SHEntityManager::CreateEntity(); + }break; + default: + break; + } + + + } + + + auto& denseA = SHComponentManager::GetDense(); + auto& denseB = SHComponentManager::GetDense(); + auto& denseC = SHComponentManager::GetDense(); + + std::cout << "Test Entity Creation" << std::endl; + std::cout << "dense A size: " << denseA.size() << ((denseA.size() == 10000) ? " Success" : " Failure") << std::endl; + std::cout << "dense B size: " << denseB.size() << ((denseB.size() == 3334) ? " Success" : " Failure") << std::endl; + std::cout << "dense C size: " << denseC.size() << ((denseC.size() == 3333) ? " Success" : " Failure") << std::endl; + std::cout << "Number of entities: " << SHEntityManager::GetEntityCount() << (SHEntityManager::GetEntityCount() == 10000 ? " Success" : " Failure") << std::endl; + + SHEntityManager::DestroyAllEntity(); + std::cout << std::endl << "Test Destroy All Entity" << std::endl; + std::cout << "dense A size: " << denseA.size() << ((denseA.size() == 0) ? " Success" : " Failure") << std::endl; + std::cout << "dense B size: " << denseB.size() << ((denseB.size() == 0) ? " Success" : " Failure") << std::endl; + std::cout << "dense C size: " << denseC.size() << ((denseC.size() == 0) ? " Success" : " Failure") << std::endl; + std::cout << "Number of entities: " << SHEntityManager::GetEntityCount() << (SHEntityManager::GetEntityCount() == 0 ? " Success" : " Failure") << std::endl; + + + } + + + void SHECSUnitTest::TestEntityDestroy(void) noexcept + { + std::cout << "\nTest3" << std::endl; + SHComponentManager::CreateComponentSparseSet(); + SHComponentManager::CreateComponentSparseSet(); + SHComponentManager::CreateComponentSparseSet(); + + + + for (size_t i = 0; i < 10000; ++i) + { + switch (i % 3) + { + case 0: + { + SHEntityManager::CreateEntity(); + }break; + case 1: + { + SHEntityManager::CreateEntity(); + }break; + + case 2: + { + SHEntityManager::CreateEntity(); + }break; + default: + break; + } + + + } + + SHEntityManager::DestroyEntity(5000); + SHEntityManager::DestroyEntity(5001); + + + + + auto& denseA = SHComponentManager::GetDense(); + auto& denseB = SHComponentManager::GetDense(); + auto& denseC = SHComponentManager::GetDense(); + + + std::cout << "Test Entity Deletion" << std::endl; + std::cout << "dense A size: " << denseA.size() << ((denseA.size() == 9998) ? " Success" : " Failure") << std::endl; + std::cout << "dense B size: " << denseB.size() << ((denseB.size() == 3333) ? " Success" : " Failure") << std::endl; + std::cout << "dense C size: " << denseC.size() << ((denseC.size() == 3333) ? " Success" : " Failure") << std::endl; + std::cout << "Number of entities: " << SHEntityManager::GetEntityCount() << (SHEntityManager::GetEntityCount() == 9998 ? " Success" : " Failure") << std::endl; + + + std::cout << std::endl << "Test Entity Recreation" << std::endl; + EntityID id = SHEntityManager::CreateEntity(); + std::cout << "dense A size: " << denseA.size() << ((denseA.size() == 9998) ? " Success" : " Failure") << std::endl; + std::cout << "dense B size: " << denseB.size() << ((denseB.size() == 3333) ? " Success" : " Failure") << std::endl; + std::cout << "dense C size: " << denseC.size() << ((denseC.size() == 3334) ? " Success" : " Failure") << std::endl; + std::cout << "Entity ID: " << id << " EntityIndex: " << EntityHandleGenerator::GetIndex(id) << (EntityHandleGenerator::GetIndex(id) == 5001 ? " Success" : " Failure") << std::endl; + std::cout << "Number of entities: " << SHEntityManager::GetEntityCount() << (SHEntityManager::GetEntityCount() == 9999 ? " Success" : " Failure") << std::endl; + + + SHEntityManager::DestroyAllEntity(); + std::cout << std::endl << "Check Destroy All Entity" << std::endl; + std::cout << "dense A size: " << denseA.size() << ((denseA.size() == 0) ? " Success" : " Failure") << std::endl; + std::cout << "dense B size: " << denseB.size() << ((denseB.size() == 0) ? " Success" : " Failure") << std::endl; + std::cout << "dense C size: " << denseC.size() << ((denseC.size() == 0) ? " Success" : " Failure") << std::endl; + std::cout << "Number of entities: " << SHEntityManager::GetEntityCount() << (SHEntityManager::GetEntityCount() == 0 ? " Success" : " Failure") << std::endl; + + } + + void SHECSUnitTest::TestSystemRoutine(void) noexcept + { + SHSystemManager::CreateSystem(); + SHSystemManager::CreateSystem(); + + + SHSystemManager::RegisterRoutine(1); + + SHSystemManager::RunRoutines(false, 1.0 / 120.0); + + SHSystemManager::Exit(); + } + + +} \ No newline at end of file diff --git a/SHADE_Engine/src/ECS_Base/UnitTesting/SHECSUnitTest.h b/SHADE_Engine/src/ECS_Base/UnitTesting/SHECSUnitTest.h new file mode 100644 index 00000000..938ba865 --- /dev/null +++ b/SHADE_Engine/src/ECS_Base/UnitTesting/SHECSUnitTest.h @@ -0,0 +1,22 @@ +#pragma once + +namespace SHADE +{ + class SHECSUnitTest + { + public: + SHECSUnitTest() = delete; + ~SHECSUnitTest() = delete; + + static void TestBasicEntityCreate(void) noexcept; + static void TestEntityCreateTemplate(void) noexcept; + static void TestEntityDestroy(void) noexcept; + static void TestSystemRoutine(void) noexcept; + + static void TestAll(void) noexcept; + + + + + }; +} \ No newline at end of file diff --git a/SHADE_Engine/src/ECS_Base/UnitTesting/SHTestComponents.h b/SHADE_Engine/src/ECS_Base/UnitTesting/SHTestComponents.h new file mode 100644 index 00000000..e2e53d6b --- /dev/null +++ b/SHADE_Engine/src/ECS_Base/UnitTesting/SHTestComponents.h @@ -0,0 +1,30 @@ +#pragma once + +#include "../Components/SHComponent.h" + +namespace SHADE +{ + + class SHComponent_A :public SHComponent + { + public: + int value{}; + + }; + + + class SHComponent_B :public SHComponent + { + public: + float x{}; + float y{}; + float z{}; + }; + + class SHComponent_C :public SHComponent + { + public: + std::string value{}; + }; + +} \ No newline at end of file diff --git a/SHADE_Engine/src/ECS_Base/UnitTesting/SHTestSystems.h b/SHADE_Engine/src/ECS_Base/UnitTesting/SHTestSystems.h new file mode 100644 index 00000000..7231b323 --- /dev/null +++ b/SHADE_Engine/src/ECS_Base/UnitTesting/SHTestSystems.h @@ -0,0 +1,40 @@ +#pragma once + + +#include +#include "../System/SHSystem.h" +#include "../System/SHSystemRoutine.h" + +namespace SHADE +{ + + class SHTestSystem : public SHSystem + { + public: + SHTestSystem() {}; + ~SHTestSystem() {}; + + + + std::string test{ "Test system" }; + + void Init() {}; + void Exit() {}; + + class SHTestRoutine : public SHSystemRoutine + { + public: + SHTestRoutine() + :SHSystemRoutine("Test System Routine", false) {} + + + virtual void Execute(double dt) noexcept + { + + std::cout << GetName() << " System Version: " << GetSystem()->GetSystemVersion() << std::endl; + } + }; + + + }; +} \ No newline at end of file diff --git a/SHADE_Engine/src/Scene/SHSceneGraph.cpp b/SHADE_Engine/src/Scene/SHSceneGraph.cpp index 9c99fb5a..9fddf10e 100644 --- a/SHADE_Engine/src/Scene/SHSceneGraph.cpp +++ b/SHADE_Engine/src/Scene/SHSceneGraph.cpp @@ -14,7 +14,7 @@ #include "SHSceneGraph.h" // Project Headers -#include "ECS_Base/System/SHEntityManager.h" +#include "ECS_Base/Managers/SHEntityManager.h" #include "Tools/SHLogger.h" #include "Tools/SHException.h" diff --git a/SHADE_Engine/src/Scene/SHSceneManager.cpp b/SHADE_Engine/src/Scene/SHSceneManager.cpp index a60df922..d5223af8 100644 --- a/SHADE_Engine/src/Scene/SHSceneManager.cpp +++ b/SHADE_Engine/src/Scene/SHSceneManager.cpp @@ -10,11 +10,11 @@ *********************************************************************/ #include "SHpch.h" #include "SHSceneManager.h" -#include "ECS_Base/System/SHComponentManager.h" +#include "ECS_Base/Managers/SHComponentManager.h" //#include "Input/SHInputManager.h" //#include "Rendering/Window/SHRenderingWindow.h" -#include "ECS_Base/System/SHEntityManager.h" -#include "ECS_Base/System/SHSystemManager.h" +#include "ECS_Base/Managers/SHEntityManager.h" +#include "ECS_Base/Managers/SHSystemManager.h" //#include "FRC/SHFrameRateController.h" //#include "ECS_Base/System/SHApplication.h" diff --git a/SHADE_Managed/src/Engine/ECS.cxx b/SHADE_Managed/src/Engine/ECS.cxx index 5aceceee..e4405006 100644 --- a/SHADE_Managed/src/Engine/ECS.cxx +++ b/SHADE_Managed/src/Engine/ECS.cxx @@ -20,7 +20,7 @@ of DigiPen Institute of Technology is prohibited. #include #include // External Dependencies -#include "ECS_Base/System/SHEntityManager.h" +#include "ECS_Base/Managers/SHEntityManager.h" // Project Headers #include "Utility/Convert.hxx" #include "Utility/Debug.hxx" diff --git a/SHADE_Managed/src/Engine/ECS.h++ b/SHADE_Managed/src/Engine/ECS.h++ index e5ede5f2..daaa859f 100644 --- a/SHADE_Managed/src/Engine/ECS.h++ +++ b/SHADE_Managed/src/Engine/ECS.h++ @@ -17,8 +17,8 @@ of DigiPen Institute of Technology is prohibited. // Primary Include #include "ECS.hxx" // External Dependencies -#include "ECS_Base/System/SHComponentManager.h" -#include "ECS_Base/System/SHEntityManager.h" +#include "ECS_Base/Managers/SHComponentManager.h" +#include "ECS_Base/Managers/SHEntityManager.h" namespace SHADE { diff --git a/SHADE_Managed/src/Engine/ECS.hxx b/SHADE_Managed/src/Engine/ECS.hxx index 72c88e11..da73f14c 100644 --- a/SHADE_Managed/src/Engine/ECS.hxx +++ b/SHADE_Managed/src/Engine/ECS.hxx @@ -15,7 +15,7 @@ of DigiPen Institute of Technology is prohibited. #pragma once // External Dependencies -#include "ECS_Base/System/SHComponentManager.h" +#include "ECS_Base/Managers/SHComponentManager.h" // Project Includes #include "Components/Component.hxx" diff --git a/SHADE_Managed/src/Engine/Entity.cxx b/SHADE_Managed/src/Engine/Entity.cxx index ba1a31c6..22e8a8c2 100644 --- a/SHADE_Managed/src/Engine/Entity.cxx +++ b/SHADE_Managed/src/Engine/Entity.cxx @@ -17,7 +17,7 @@ of DigiPen Institute of Technology is prohibited. // Primary Header #include "Entity.hxx" // External Dependencies -#include "ECS_Base/System/SHEntityManager.h" +#include "ECS_Base/Managers/SHEntityManager.h" namespace SHADE { diff --git a/SHADE_Managed/src/Engine/GameObject.cxx b/SHADE_Managed/src/Engine/GameObject.cxx index 3896fac5..1fbc3b4a 100644 --- a/SHADE_Managed/src/Engine/GameObject.cxx +++ b/SHADE_Managed/src/Engine/GameObject.cxx @@ -16,7 +16,7 @@ of DigiPen Institute of Technology is prohibited. // Primary Header #include "GameObject.hxx" // External Dependencies -#include "ECS_Base/System/SHEntityManager.h" +#include "ECS_Base/Managers/SHEntityManager.h" // Project Headers #include "ECS.hxx" #include "Scripts/ScriptStore.hxx" @@ -52,7 +52,7 @@ namespace SHADE } bool GameObject::IsActiveSelf::get() { - return GetNativeEntity().isActive; + return GetNativeEntity().GetActive(); } bool GameObject::IsActiveInHierarchy::get() { @@ -68,7 +68,7 @@ namespace SHADE } void GameObject::SetActive(bool active) { - GetNativeEntity().isActive = active; + GetNativeEntity().SetActive(active); } /*---------------------------------------------------------------------------------*/ diff --git a/SHADE_Managed/src/Scripts/ScriptStore.cxx b/SHADE_Managed/src/Scripts/ScriptStore.cxx index 9a9eff54..d30cad6b 100644 --- a/SHADE_Managed/src/Scripts/ScriptStore.cxx +++ b/SHADE_Managed/src/Scripts/ScriptStore.cxx @@ -19,7 +19,7 @@ of DigiPen Institute of Technology is prohibited. // Standard Libraries #include // External Dependencies -#include "ECS_Base/System/SHEntityManager.h" +#include "ECS_Base/Managers/SHEntityManager.h" // Project Headers #include "Utility/Debug.hxx" #include "Utility/Convert.hxx" @@ -668,6 +668,6 @@ namespace SHADE throw gcnew System::InvalidOperationException("Attempted to get native Component to an invalid Entity."); // Check active state - return nativeEntity->isActive; + return nativeEntity->GetActive(); } } diff --git a/SHADE_Managed/src/Utility/Convert.cxx b/SHADE_Managed/src/Utility/Convert.cxx index 8a8aff70..d222fbb3 100644 --- a/SHADE_Managed/src/Utility/Convert.cxx +++ b/SHADE_Managed/src/Utility/Convert.cxx @@ -17,7 +17,7 @@ of DigiPen Institute of Technology is prohibited. // Primary Header #include "Convert.hxx" // External Dependencies -#include "ECS_Base/System//SHEntityManager.h" +#include "ECS_Base/Managers/SHEntityManager.h" #include namespace SHADE