SP3-5 ECS #27

Merged
XiaoQiDigipen merged 16 commits from SP3-5-ECS into main 2022-09-16 14:15:23 +08:00
4 changed files with 27 additions and 9 deletions
Showing only changes of commit 51fc65b825 - Show all commits

View File

@ -11,6 +11,8 @@ typedef uint16_t EntityIndex;
typedef uint32_t ComponentTypeID;
const EntityIndex MAX_EID = 51000;

View File

@ -25,6 +25,10 @@
namespace SHADE
{
typedef SHFamilyID<SHComponent> ComponentFamily;
class SHComponentManager
{
private:
@ -36,6 +40,8 @@ namespace SHADE
friend struct SHSceneNode;
/**************************************************************************
@ -225,7 +231,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));
@ -277,7 +283,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;
/*!*************************************************************************
@ -362,7 +368,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;
@ -385,7 +391,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();
}
@ -402,9 +408,9 @@ namespace SHADE
static void SetActive(EntityID entityID, bool active) noexcept;
template<typename... T>
static std::enable_if_t<(... && std::is_base_of_v<SHComponent, T>), uint32_t> CreateComponentGroup(uint32_t numOwningComponents)
static std::enable_if_t<(... && std::is_base_of_v<SHComponent, T>), uint32_t> CreateComponentGroup(ComponentTypeID numOwningComponents)
{
std::vector<uint32_t> templateIDs{ (SHFamilyID<SHComponent>::GetID<T>())... };
std::vector<ComponentTypeID> templateIDs{ (ComponentFamily::GetID<T>())... };
for (auto& g : componentGroups)
{
@ -421,11 +427,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]);
}

View File

@ -11,8 +11,13 @@
#ifndef SH_SYSTEM_H
#define SH_SYSTEM_H
namespace SHADE
{
class SHSystem
{
protected:

View File

@ -20,11 +20,16 @@
#include <string>
#include <cassert>
#include "../System/SHSystem.h"
#include "../General/SHFamily.h"
namespace SHADE
{
typedef uint32_t SystemTypeID;
typedef uint32_t SystemVersionID;
typedef uint64_t SystemID;
typedef SHFamilyID<SHSystem> SystemFamily;
class SHSystemManager
{
//type definition for the container we use to store our system