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"
11
#include "
galaxy/state/StateMachine.hpp
"
12
13
#include "
Lua.hpp
"
14
15
namespace
galaxy
16
{
17
namespace
lua
18
{
19
void
inject_states
()
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
Lua.hpp
StateMachine.hpp
galaxy::state::StateMachine
A finite state machine.
Definition
StateMachine.hpp:26
galaxy::state::StateMachine::push
void push(const std::string &key)
Push a new state onto the stack.
Definition
StateMachine.cpp:30
galaxy::state::StateMachine::pop
void pop()
Pop the topmost state off the top of the stack.
Definition
StateMachine.cpp:45
galaxy::state::StateMachine::update
void update()
Update topmost state.
Definition
StateMachine.cpp:55
galaxy::state::State
A state to use in a finite state machine.
Definition
State.hpp:19
galaxy::state::State::update
virtual void update()=0
Handle state events / update state data.
galaxy::state::State::on_pop
virtual void on_pop()=0
Triggered when state is popped off the stack.
galaxy::state::State::on_push
virtual void on_push()=0
Triggered when state is pushed onto the stack.
galaxy::lua::inject_states
void inject_states()
Definition
LuaState.cpp:19
galaxy
Timer.hpp galaxy.
Definition
Async.hpp:17
galaxy
src
galaxy
scripting
lua
LuaState.cpp
Generated on Sat Mar 1 2025 14:49:36 for galaxy by
1.12.0