VEX Engine
Retro looking game engine made in vulkan mostly because i wanted to understand it better.
Loading...
Searching...
No Matches
Scene.hpp
Go to the documentation of this file.
1
6
7#pragma once
8
11
12#include "Engine.hpp"
13
14
15#include "VEX/VEX_export.h"
16#include <algorithm>
17#include <memory>
18
19namespace vex {
20
22class VEX_EXPORT Scene {
23public:
27Scene(const std::string& path, Engine& engine);
28
29Scene(const Scene&) = delete;
30Scene& operator=(const Scene&) = delete;
31
32Scene(Scene&&) = default;
33Scene& operator=(Scene&&) = default;
34
36~Scene();
37
41void sceneBegin();
42
49void sceneUpdate(float deltaTime);
50
53void AddGameObject(std::unique_ptr<GameObject> gameObject);
54
58std::vector<GameObject*> GetAllGameObjectsByName(const std::string& name);
59
63std::vector<GameObject*> GetAllGameObjectsByClassName(const std::string& classname);
64
69
73void RegisterGameObject(GameObject* gameObject);
74
78void DestroyGameObject(GameObject* gameObject);
79
82const std::vector<std::shared_ptr<GameObject>>& GetAllObjects() const { return m_objects; }
83
86const std::vector<std::shared_ptr<GameObject>>& GetAllAddedObjects() const { return m_addedObjects; }
87
95void Save(const std::string& outputPath);
96
100void AddEditorGameObject(GameObject* gameObject);
101
102std::string GetScenePath(){
103 return m_path;
104}
105
108void FlushDestructionQueue();
109
110private:
111
119void load();
120
121std::vector<std::shared_ptr<GameObject>> m_objects;
122std::vector<std::shared_ptr<GameObject>> m_addedObjects;
123std::vector<GameObject*> m_pendingDestruction;
124std::string m_path;
125Engine* m_engine;
126bool m_creatingFromScene = false;
127};
128
129} // namespace vex
Contains main Engine class.
This file defines GameObjectFactory class used to auto register GameObjects.
This file defines the GameObject class.
Class for interaction with engine systems.
Definition Engine.hpp:47
Its base class for all game objects, eg. Player, Enemy, Weapon. Your Class needs to inherit from it.
Scene(const std::string &path, Engine &engine)
Constructor creates empty scene object.
Definition Scene.cpp:26
GameObject * GetGameObjectByEntity(vex::Entity &entity)
Function to get a game object by its entity ID.
Definition Scene.cpp:332
void RegisterGameObject(GameObject *gameObject)
Registers a game object into the scene's internal storage.
Definition Scene.cpp:256
std::vector< GameObject * > GetAllGameObjectsByClassName(const std::string &classname)
Function to get all game objects of a specific class type.
Definition Scene.cpp:317
void DestroyGameObject(GameObject *gameObject)
Marks a game object for destruction.
Definition Scene.cpp:267
const std::vector< std::shared_ptr< GameObject > > & GetAllAddedObjects() const
Function to get all added game objects in the scene.
Definition Scene.hpp:86
void AddGameObject(std::unique_ptr< GameObject > gameObject)
[Deprecated] Function to add a game object to the scene.
Definition Scene.cpp:250
std::vector< GameObject * > GetAllGameObjectsByName(const std::string &name)
Function to get all game objects with a specific name.
Definition Scene.cpp:302
void sceneBegin()
Calls BeginPlay on all objects in the scene.
Definition Scene.cpp:188
void sceneUpdate(float deltaTime)
Updates all objects in the scene.
Definition Scene.cpp:219
const std::vector< std::shared_ptr< GameObject > > & GetAllObjects() const
Function to get all game objects in the scene.
Definition Scene.hpp:82
uint32_t Entity
Type alias representing a unique entity identifier in the ECS system.
Definition Types.hpp:11