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
LuaComponents.cpp
Go to the documentation of this file.
1
7
8
#include <entt/locator/locator.hpp>
9
#include <sol/sol.hpp>
10
#include <entt_sol/registry/bond.hpp>
11
12
#include "
galaxy/components/Tag.hpp
"
13
14
#include "
../Lua.hpp
"
15
16
namespace
galaxy
17
{
18
void
Lua::inject_components
() noexcept
19
{
20
auto
& lua = entt::locator<sol::state>::value();
21
22
auto
tag_type = lua.new_usertype<
components::Tag
>(
"Tag"
, sol::constructors<components::Tag()>(),
"type_id"
, &entt::type_hash<components::Tag>::value);
23
tag_type[
"tag"
] = &
components::Tag::m_tag
;
24
25
entt_sol::register_meta_component<components::Tag>();
26
27
/*auto animated_type =
28
lua.new_usertype<components::Animated>("Animated", sol::constructors<components::Animated()>(), "type_id", &entt::type_hash<components::Animated>::value);
29
animated_type["animation"] = &components::Animated::m_anim;
30
animated_type["duration"] = &components::Animated::m_duration;
31
animated_type["paused"] = &components::Animated::m_paused;
32
33
auto circle_type = lua.new_usertype<components::Circle>("Circle", sol::constructors<components::Circle()>(), "type_id", &entt::type_hash<components::Circle>::value);
34
circle_type["shape"] = &components::Circle::m_shape;
35
36
auto ellipse_type =
37
lua.new_usertype<components::Ellipse>("Ellipse", sol::constructors<components::Ellipse()>(), "type_id", &entt::type_hash<components::Ellipse>::value);
38
ellipse_type["shape"] = &components::Ellipse::m_shape;
39
40
auto point_type = lua.new_usertype<components::Point>("Point", sol::constructors<components::Point()>(), "type_id", &entt::type_hash<components::Point>::value);
41
auto gui_type =
42
lua.new_usertype<components::GUI>("GUI", sol::constructors<components::GUI()>(), "type_id", &entt::type_hash<components::GUI>::value);
43
gui_type["file"] = &components::GUI::file;
44
gui_type["self"] = &components::GUI::m_self;
45
gui_type["update"] = &components::GUI::m_update;
46
47
point_type["shape"] = &components::Point::m_shape;
48
49
auto polygon_type =
50
lua.new_usertype<components::Polygon>("Polygon", sol::constructors<components::Polygon()>(), "type_id", &entt::type_hash<components::Polygon>::value);
51
polygon_type["shape"] = &components::Polygon::m_shape;
52
53
auto polyline_type =
54
lua.new_usertype<components::Polyline>("Polyline", sol::constructors<components::Polyline()>(), "type_id", &entt::type_hash<components::Polyline>::value);
55
polyline_type["shape"] = &components::Polyline::m_shape;
56
57
auto rigidbody_type =
58
lua.new_usertype<components::RigidBody>("RigidBody", sol::constructors<components::RigidBody()>(), "type_id", &entt::type_hash<components::RigidBody>::value);
59
rigidbody_type["get_density"] = &components::RigidBody::get_density;
60
rigidbody_type["get_friction"] = &components::RigidBody::get_friction;
61
rigidbody_type["get_restitution"] = &components::RigidBody::get_restitution;
62
rigidbody_type["get_restitution_threshold"] = &components::RigidBody::get_restitution_threshold;
63
rigidbody_type["get_shape"] = &components::RigidBody::get_shape;
64
rigidbody_type["get_type"] = &components::RigidBody::get_type;
65
rigidbody_type["is_bullet"] = &components::RigidBody::is_bullet;
66
rigidbody_type["is_rotation_fixed"] = &components::RigidBody::is_rotation_fixed;
67
rigidbody_type["set_bullet"] = &components::RigidBody::set_bullet;
68
rigidbody_type["set_density"] = &components::RigidBody::set_density;
69
rigidbody_type["set_fixed_rotation"] = &components::RigidBody::set_fixed_rotation;
70
rigidbody_type["set_friction"] = &components::RigidBody::set_friction;
71
rigidbody_type["set_restitution"] = &components::RigidBody::set_restitution;
72
rigidbody_type["set_restitution_threshold"] = &components::RigidBody::set_restitution_threshold;
73
rigidbody_type["set_shape"] = &components::RigidBody::set_shape;
74
rigidbody_type["set_type"] = &components::RigidBody::set_type;
75
76
auto script_type = lua.new_usertype<components::Script>("Script", sol::constructors<components::Script()>(), "type_id", &entt::type_hash<components::Script>::value);
77
script_type["file"] = &components::Script::file;
78
script_type["self"] = &components::Script::m_self;
79
script_type["update"] = &components::Script::m_update;
80
81
auto sprite_type = lua.new_usertype<components::Sprite>("Sprite", sol::constructors<components::Sprite()>(), "type_id", &entt::type_hash<components::Sprite>::value);
82
sprite_type["tint"] = &components::Sprite::m_tint;
83
sprite_type["set_texture"] = sol::resolve<void(const std::string&)>(&components::Sprite::set_texture);
84
sprite_type["set_texture_with_rect"] = sol::resolve<void(const std::string&, const math::fRect&)>(&components::Sprite::set_texture);
85
sprite_type["set_clip"] = &components::Sprite::set_clip;
86
sprite_type["get_clip"] = &components::Sprite::get_clip;
87
sprite_type["get_texture_name"] = &components::Sprite::get_texture_name;
88
89
90
91
auto text_type = lua.new_usertype<components::Text>("Text", sol::constructors<components::Text()>(), "type_id", &entt::type_hash<components::Text>::value);
92
text_type["text"] = &components::Text::m_text;
93
94
auto tilemap_type =
95
lua.new_usertype<components::TileMap>("TileMap", sol::constructors<components::TileMap()>(), "type_id", &entt::type_hash<components::TileMap>::value);
96
tilemap_type["get_texture"] = &components::TileMap::get_texture;
97
tilemap_type["set_texture"] = &components::TileMap::set_texture;
98
tilemap_type["render_layer"] = &components::TileMap::m_render_layer;
99
tilemap_type["tint"] = &components::TileMap::m_tint;
100
101
auto transform_type =
102
lua.new_usertype<components::Transform>("Transform", sol::constructors<components::Transform()>(), "type_id", &entt::type_hash<components::Transform>::value);
103
transform_type["tf"] = &components::Transform::m_tf;
104
105
entt_sol::register_meta_component<components::Animated>();
106
entt_sol::register_meta_component<components::Circle>();
107
entt_sol::register_meta_component<components::Ellipse>();
108
entt_sol::register_meta_component<components::GUI>();
109
entt_sol::register_meta_component<components::Point>();
110
entt_sol::register_meta_component<components::Polygon>();
111
entt_sol::register_meta_component<components::Polyline>();
112
entt_sol::register_meta_component<components::RigidBody>();
113
entt_sol::register_meta_component<components::Script>();
114
entt_sol::register_meta_component<components::Sprite>();
115
116
entt_sol::register_meta_component<components::Text>();
117
entt_sol::register_meta_component<components::TileMap>();
118
entt_sol::register_meta_component<components::Transform>();*/
119
}
120
}
// namespace galaxy
Lua.hpp
Tag.hpp
galaxy::Lua::inject_components
static void inject_components() noexcept
Injects galaxy components into Lua.
Definition
LuaComponents.cpp:18
galaxy::components::Tag
Tag an entity.
Definition
Tag.hpp:21
galaxy::components::Tag::m_tag
std::string m_tag
Tag.
Definition
Tag.hpp:87
galaxy
Tag.cpp galaxy.
Definition
Tag.cpp:13
galaxy
src
galaxy
lua
injects
LuaComponents.cpp
Generated on
for galaxy by
1.18.0