Crimson Engine 1.0.0
A high-performance C++20 game engine prototype showcasing a custom ECS, Vulkan renderer, and ImGui editor.
Loading...
Searching...
No Matches
Scene.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <string>
4#include <vector>
5#include "ecs/Entity.hpp"
6#include "ecs/Registry.hpp"
7
9
14class Scene {
15public:
25 virtual ~Scene();
26
30 virtual void load() = 0;
35 virtual void update(float dt) = 0;
39 virtual void unload();
40
41 // Builtin default implementations of editor-called functions
47 virtual bool saveToFile(const std::string& path);
53 virtual bool loadFromFile(const std::string& path);
59 virtual Entity createPrimitiveEntity(const std::string& primitiveType);
65 virtual Entity createEntityOfType(const std::string& entityType);
71 virtual Entity duplicateEntity(Entity entity);
77 virtual bool deleteEntity(Entity entity);
78
89 void untrackEntity(Entity entity);
95 std::string makeUniqueEntityName(const std::string& baseName) const;
96
97protected:
98
104 Entity findEntityByName(const std::string& name) const;
105
110
111private:
113 std::vector<Entity> ownedEntities;
114};
Lightweight identifier representing a game object in the Entity Component System.
Definition Entity.hpp:11
Coordinates entities and components, providing creation, removal, lookup, and views.
Definition Registry.hpp:30
std::string makeUniqueEntityName(const std::string &baseName) const
Generates a unique name for an entity by appending indices if duplicate.
Definition Scene.cpp:331
virtual void update(float dt)=0
Pure virtual method called every frame to update scene logic.
Entity trackEntity(Entity entity)
Tracks an entity under scene ownership.
Definition Scene.cpp:296
VulkanRenderer & renderer
Reference to Vulkan renderer.
Definition Scene.hpp:109
Scene(Registry &registry, VulkanRenderer &renderer)
Construct a new Scene object.
Definition Scene.cpp:18
virtual Entity createPrimitiveEntity(const std::string &primitiveType)
Helper to spawn primitive geometric entities.
Definition Scene.cpp:90
virtual void load()=0
Pure virtual method called to load scene assets and entities.
virtual void unload()
Method called to clean up scene state and entities.
Definition Scene.cpp:31
virtual ~Scene()
Destroy the Scene object, unloading remaining entities.
Definition Scene.cpp:25
virtual bool deleteEntity(Entity entity)
Destroys an entity and removes it from scene tracking.
Definition Scene.cpp:260
Entity findEntityByName(const std::string &name) const
Locates an entity by its Name component.
Definition Scene.cpp:317
virtual Entity duplicateEntity(Entity entity)
Duplicates an existing entity.
Definition Scene.cpp:242
std::vector< Entity > ownedEntities
List of entities owned by this scene.
Definition Scene.hpp:113
virtual bool saveToFile(const std::string &path)
Serializes scene entities to a JSON file.
Definition Scene.cpp:43
void untrackEntity(Entity entity)
Stops tracking an entity.
Definition Scene.cpp:305
virtual Entity createEntityOfType(const std::string &entityType)
Helper to spawn complex predefined entities (Camera, Grid).
Definition Scene.cpp:122
virtual bool loadFromFile(const std::string &path)
Deserializes scene entities from a JSON file.
Definition Scene.cpp:71
Registry & registry
Reference to registry.
Definition Scene.hpp:107
Manages core Vulkan pipeline states, device interaction, frames, buffers, and command submissions.
Definition VulkanRenderer.hpp:127
const char * name
Definition ufbx.cpp:9020