10 return std::shared_ptr<Scene>(
new Scene(std::move(name)));
13 Scene::Scene(std::string name) : m_Name(std::move(name)) {
32 if (m_EntityCache.contains(key)) {
33 return std::unexpected(
Core::CoriError(
"Entry with the given key already exists, make sure you're not reusing the key. It's also possible (but very unlikely), that you got a hash collision, try to change the key a bit."));
42 if (!m_EntityCache.contains(key)) {
43 return std::unexpected(
Core::CoriError(
"No entity with the specified key found in scene local cache."));
45 if (!
m_Registry.valid(m_EntityCache.at(key))) {
46 m_EntityCache.erase(key);
47 return std::unexpected(
Core::CoriError(
"Entity at the specified key is invalid, removing this entry."));
53 if (m_EntityCache.contains(key)) {
55 m_EntityCache.erase(key);
62 if (!entity.
IsValid()) {
return; }
67 m_UUIDToEntity.erase(uuidComp.m_UUID);
74 for (
auto type : m_SystemPriority | std::views::values) {
75 m_RegisteredSystems[type]->OnUpdate(gameTimer);
78 Graphics::Renderer2D::SubmitScene(
this);
82 for (
auto type : m_SystemPriority | std::views::values) {
83 m_RegisteredSystems[type]->OnTickUpdate(gameTimer);
88 for (
auto type : m_SystemPriority | std::views::values) {
89 m_RegisteredSystems[type]->OnImGuiRender(gameTimer);
#define CORI_CORE_DEBUG_TAGGED(...)
#define CORI_CORE_WARN_TAGGED(...)
#define CORI_CORE_INFO_TAGGED(...)
#define CORI_PROFILE_FUNCTION()
Custom error class mainly used in std::expected.
A GameTimer is responsible for managing everything that is connected with time, ticks,...
static void BeginScene(const World::Components::Scene::Camera &camera)
Entities are the essential part of WorldSystem.
void UnlinkFromParent()
Unlinks the entity from its parent if it has one.
bool IsValid() const
Checks if the actual entity behind this handle is valid.
bool HasComponents() const
Checks if the entity has all the specified components.
T & AddComponent(Args &&... args)
Adds a component to the entity.
std::string GetDebugData(bool showUUID=false) const
Gets the debuting string for logging.
decltype(auto) GetComponents()
Retries the references to the requested components of the entity.
entt::entity GetRawEntity() const
Gets a raw entt::entity if you need to interact with entt directly.
std::expected< void, Core::CoriError<> > AddEntityToCache(const Entity entity, const Utility::StringHash32 key)
T & AddContextComponent(Args &&... args)
static std::shared_ptr< Scene > Create(std::string name)
entt::registry m_Registry
void OnTickUpdate(Core::GameTimer &gameTimer)
T & GetContextComponent()
void RemoveEntityFromCache(const Utility::StringHash32 key)
Entity CreateBlankEntity()
void DestroyEntity(Entity entity)
void OnUpdate(Core::GameTimer &gameTimer)
std::expected< Entity, Core::CoriError<> > GetEntityFromCache(const Utility::StringHash32 key)
void OnImGuiRender(Core::GameTimer &gameTimer)
entt::hashed_string::hash_type StringHash32
Anything connected to WorldSystem (ECS) is in this namespace.
Every Entity has a hierarchy component by default, it's essential for entity hierarchy system.
Every Entity by default has a UUID component, mostly unused for now.