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
12
13#include "../Lua.hpp"
14
15namespace galaxy
16{
17 void add_wrapper(const std::string& key)
18 {
19 }
20
21 void Lua::inject_scene() noexcept
22 {
23 auto& lua = entt::locator<sol::state>::value();
24
25 auto scene_type = lua.new_usertype<Scene>("Scene", sol::no_constructor);
26 scene_type["add_system"] = &Scene::add_system;
27 scene_type["clear"] = &Scene::clear;
28 scene_type["load"] = &Scene::on_push;
29 scene_type["name"] = &Scene::name;
30 scene_type["unload"] = &Scene::on_pop;
31
32 auto world_type = lua.new_usertype<World>("World", sol::no_constructor);
33 world_type["add"] = [](World& self, const std::string& key) {
34 self.add(key);
35 };
36 world_type["clear"] = &World::clear;
37 world_type["get"] = &World::get;
38 world_type["has"] = &World::has;
39 world_type["pop"] = &World::pop;
40 world_type["pop_all"] = &World::pop_all;
41 world_type["push"] = &World::push;
42 world_type["remove"] = &World::remove;
43 world_type["stack"] = &World::stack;
44 world_type["storage"] = &World::storage;
45 world_type["top"] = &World::top;
46 }
47} // namespace galaxy
static void inject_scene() noexcept
Injects galaxy scene management into lua.
Definition LuaScene.cpp:21
Represents a scene in a game.
Definition Scene.hpp:23
void on_push() override
When scene is pushed to the stack.
Definition Scene.cpp:36
void on_pop() override
When scene is popped from the stack.
Definition Scene.cpp:40
void clear()
Remove all scene data.
Definition Scene.cpp:84
void add_system(const std::string &system)
Add a system to operate on entities in this scene.
Definition Scene.cpp:89
std::shared_ptr< Stored > add(const std::string &key, Args &&... args)
Add a new state.
void remove(const std::string &key)
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
Scene, Entity and global game management.
Definition World.hpp:20
void clear()
Removes all data.
Definition World.cpp:53
Animated.cpp galaxy.
Definition Animated.cpp:16
void add_wrapper(const std::string &key)
Definition LuaScene.cpp:17