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
LuaState.cpp
Go to the documentation of this file.
1
7
8#include <sol/sol.hpp>
9
10#include "galaxy/core/ServiceLocator.hpp"
12
13#include "Lua.hpp"
14
15namespace galaxy
16{
17 namespace lua
18 {
20 {
21 auto& lua = core::ServiceLocator<sol::state>::ref();
22
23 auto state_type = lua.new_usertype<state::State>("State", sol::no_constructor);
24 state_type["on_pop"] = &state::State::on_pop;
25 state_type["on_push"] = &state::State::on_push;
26 state_type["update"] = &state::State::update;
27
28 auto statemachine_type = lua.new_usertype<state::StateMachine>("StateMachine", sol::constructors<state::StateMachine()>());
29 // statemachine_type[""] = &state::StateMachine::add;
30 statemachine_type["pop"] = &state::StateMachine::pop;
31 statemachine_type["push"] = &state::StateMachine::push;
32 statemachine_type["update"] = &state::StateMachine::update;
33 }
34 } // namespace lua
35} // namespace galaxy
A finite state machine.
void push(const std::string &key)
Push a new state onto the stack.
void pop()
Pop the topmost state off the top of the stack.
void update()
Update topmost state.
A state to use in a finite state machine.
Definition State.hpp:19
virtual void update()=0
Handle state events / update state data.
virtual void on_pop()=0
Triggered when state is popped off the stack.
virtual void on_push()=0
Triggered when state is pushed onto the stack.
void inject_states()
Definition LuaState.cpp:19
Timer.hpp galaxy.
Definition Async.hpp:17