Added some typedefs

This commit is contained in:
maverickdgg 2022-09-13 14:07:40 +08:00
parent 8b8f0a076d
commit 51fc65b825
4 changed files with 27 additions and 9 deletions

View File

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

View File

@ -25,6 +25,10 @@
namespace SHADE namespace SHADE
{ {
typedef SHFamilyID<SHComponent> ComponentFamily;
class SHComponentManager class SHComponentManager
{ {
private: private:
@ -36,6 +40,8 @@ namespace SHADE
friend struct SHSceneNode; friend struct SHSceneNode;
/************************************************************************** /**************************************************************************
@ -225,7 +231,7 @@ namespace SHADE
* \return * \return
* none * 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)); componentSet.GetSparseSet_ID(componentTypeID)->Add(EntityHandleGenerator::GetIndex(entityID));
@ -277,7 +283,7 @@ namespace SHADE
* \return bool * \return bool
* True if the entity has a component of specified type. * 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 * \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 * \return
* The number of components in the component sparse set. * 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(); return componentSet.GetSparseSet_ID(componentTypeID)->Count();
} }
@ -402,9 +408,9 @@ namespace SHADE
static void SetActive(EntityID entityID, bool active) noexcept; static void SetActive(EntityID entityID, bool active) noexcept;
template<typename... T> 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) for (auto& g : componentGroups)
{ {
@ -421,11 +427,11 @@ namespace SHADE
} }
SHComponentGroup grp; SHComponentGroup grp;
for (uint32_t i = 0; i < numOwningComponents; ++i) for (ComponentTypeID i = 0; i < numOwningComponents; ++i)
{ {
grp.ownedComponentTypes.push_back(templateIDs[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]); grp.componentTypeIDs.push_back(templateIDs[i]);
} }

View File

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

View File

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