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