galaxy 1.0.0
Real-Time C++23 Game Programming Framework. Built on data-driven design principles and agile software engineering.
Loading...
Searching...
No Matches
LuaScene.cpp
Go to the documentation of this file.
1
7
8#include <entt/locator/locator.hpp>
9#include <sol/sol.hpp>
10
13
14#include "../Lua.hpp"
15
16namespace galaxy
17{
18 void Lua::inject_scene() noexcept
19 {
20 auto& lua = entt::locator<sol::state>::value();
21
22 auto scene_type = lua.new_usertype<Scene>("Scene", sol::no_constructor);
23 scene_type["on_push"] = &Scene::on_push;
24 scene_type["name"] = &Scene::name;
25 scene_type["on_pop"] = &Scene::on_pop;
26 scene_type["sys_man"] = &Scene::sys_man;
27 scene_type["update"] = &Scene::update;
28 scene_type["render"] = &Scene::render;
29
30 auto sm_type = lua.new_usertype<SceneManager>("SceneManager", sol::no_constructor);
31 sm_type["add"] = [](SceneManager& self, const std::string& key) {
32 self.add(key);
33 };
34 sm_type["clear"] = &SceneManager::clear;
35 sm_type["get"] = &SceneManager::get;
36 sm_type["has"] = &SceneManager::has;
37 sm_type["pop"] = &SceneManager::pop;
38 sm_type["pop_all"] = &SceneManager::pop_all;
39 sm_type["push"] = &SceneManager::push;
40 sm_type["remove"] = &SceneManager::remove;
41 sm_type["render"] = &SceneManager::render;
42 sm_type["stack"] = &SceneManager::stack;
43 sm_type["storage"] = &SceneManager::storage;
44 sm_type["top"] = &SceneManager::top;
45 sm_type["update"] = &SceneManager::update;
46 }
47} // namespace galaxy
static void inject_scene() noexcept
Injects galaxy scene management into lua.
Definition LuaScene.cpp:18
State machine for managing scenes.
void update()
Process events and updates.
void clear()
Removes all data.
void render()
Render scenes.
Represents a scene in a game.
Definition Scene.hpp:27
void on_push() override
When scene is pushed to the stack.
Definition Scene.cpp:46
void update(EntityManager &em)
Process events and updates.
Definition Scene.cpp:250
void on_pop() override
When scene is popped from the stack.
Definition Scene.cpp:50
void render()
Render scene.
Definition Scene.cpp:261
SystemManager & sys_man() noexcept
Get system manager.
Definition Scene.cpp:289
void remove(const std::string &key)
std::shared_ptr< Stored > add(const std::string &key, Args &&... args)
Add a new state.
bool has(const std::string &key) noexcept
std::shared_ptr< Stored > get(const std::string &key) noexcept
void push(const std::string &key) noexcept
std::shared_ptr< Stored > top() const noexcept
const std::string & name() const noexcept
Get state name.
Definition State.cpp:17
Application.hpp galaxy.