diff --git a/headers/enduro2d/high/_all.hpp b/headers/enduro2d/high/_all.hpp index 8df00ff4..ab0f4180 100644 --- a/headers/enduro2d/high/_all.hpp +++ b/headers/enduro2d/high/_all.hpp @@ -31,6 +31,7 @@ #include "components/actor.hpp" #include "components/behaviour.hpp" #include "components/camera.hpp" +#include "components/colliders.hpp" #include "components/commands.hpp" #include "components/disabled.hpp" #include "components/events.hpp" diff --git a/headers/enduro2d/high/_high.hpp b/headers/enduro2d/high/_high.hpp index 9dbaadb8..7f7fb218 100644 --- a/headers/enduro2d/high/_high.hpp +++ b/headers/enduro2d/high/_high.hpp @@ -46,6 +46,9 @@ namespace e2d class actor; class behaviour; class camera; + class box_collider; + class circle_collider; + class polygon_collider; template < typename C > class commands; template < typename T > diff --git a/headers/enduro2d/high/components/colliders.hpp b/headers/enduro2d/high/components/colliders.hpp new file mode 100644 index 00000000..4a468e36 --- /dev/null +++ b/headers/enduro2d/high/components/colliders.hpp @@ -0,0 +1,74 @@ +/******************************************************************************* + * This file is part of the "Enduro2D" + * For conditions of distribution and use, see copyright notice in LICENSE.md + * Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com) + ******************************************************************************/ + +#pragma once + +#include "../_high.hpp" + +#include "../factory.hpp" + +namespace e2d +{ + class box_collider final { + public: + box_collider() = default; + }; + + class circle_collider final { + public: + circle_collider() = default; + }; + + class polygon_collider final { + public: + polygon_collider() = default; + }; +} + +namespace e2d +{ + template <> + class factory_loader final : factory_loader<> { + public: + static const char* schema_source; + + bool operator()( + box_collider& component, + const fill_context& ctx) const; + + bool operator()( + asset_dependencies& dependencies, + const collect_context& ctx) const; + }; + + template <> + class factory_loader final : factory_loader<> { + public: + static const char* schema_source; + + bool operator()( + circle_collider& component, + const fill_context& ctx) const; + + bool operator()( + asset_dependencies& dependencies, + const collect_context& ctx) const; + }; + + template <> + class factory_loader final : factory_loader<> { + public: + static const char* schema_source; + + bool operator()( + polygon_collider& component, + const fill_context& ctx) const; + + bool operator()( + asset_dependencies& dependencies, + const collect_context& ctx) const; + }; +} diff --git a/samples/bin/library/scripts/emmy/components/colliders.lua b/samples/bin/library/scripts/emmy/components/colliders.lua new file mode 100644 index 00000000..0dfdfae4 --- /dev/null +++ b/samples/bin/library/scripts/emmy/components/colliders.lua @@ -0,0 +1,20 @@ +---@class box_collider +local box_collider = { +} + +---@class circle_collider +local circle_collider = { +} + +---@class polygon_collider +local polygon_collider = { +} + +---@type box_collider +_G.box_collider = _G.box_collider or box_collider + +---@type circle_collider +_G.circle_collider = _G.circle_collider or circle_collider + +---@type polygon_collider +_G.polygon_collider = _G.polygon_collider or polygon_collider diff --git a/samples/bin/library/scripts/emmy/high/gobject.lua b/samples/bin/library/scripts/emmy/high/gobject.lua index 89f9c994..a50eeef5 100644 --- a/samples/bin/library/scripts/emmy/high/gobject.lua +++ b/samples/bin/library/scripts/emmy/high/gobject.lua @@ -15,6 +15,15 @@ local gobject = { ---@type camera camera = nil, + ---@type box_collider + box_collider = nil, + + ---@type circle_collider + circle_collider = nil, + + ---@type polygon_collider + polygon_collider = nil, + ---@type flipbook_player flipbook_player = nil, diff --git a/sources/enduro2d/high/bindings/high_binds/_high_binds.hpp b/sources/enduro2d/high/bindings/high_binds/_high_binds.hpp index 572f9c2f..675a6763 100644 --- a/sources/enduro2d/high/bindings/high_binds/_high_binds.hpp +++ b/sources/enduro2d/high/bindings/high_binds/_high_binds.hpp @@ -20,6 +20,7 @@ namespace e2d::bindings::high void bind_actor(sol::state& l); void bind_behaviour(sol::state& l); void bind_camera(sol::state& l); + void bind_colliders(sol::state& l); void bind_flipbook_player(sol::state& l); void bind_label(sol::state& l); void bind_model_renderer(sol::state& l); @@ -43,6 +44,7 @@ namespace e2d::bindings high::bind_actor(l); high::bind_behaviour(l); high::bind_camera(l); + high::bind_colliders(l); high::bind_flipbook_player(l); high::bind_label(l); high::bind_model_renderer(l); diff --git a/sources/enduro2d/high/bindings/high_binds/components/colliders_binds.cpp b/sources/enduro2d/high/bindings/high_binds/components/colliders_binds.cpp new file mode 100644 index 00000000..80e6ff71 --- /dev/null +++ b/sources/enduro2d/high/bindings/high_binds/components/colliders_binds.cpp @@ -0,0 +1,42 @@ +/******************************************************************************* + * This file is part of the "Enduro2D" + * For conditions of distribution and use, see copyright notice in LICENSE.md + * Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com) + ******************************************************************************/ + +#include "../_high_binds.hpp" + +#include +#include + +namespace +{ + using namespace e2d; + + void bind_box_collider(sol::state& l) { + l.new_usertype>("box_collider", + sol::no_constructor + ); + } + + void bind_circle_collider(sol::state& l) { + l.new_usertype>("circle_collider", + sol::no_constructor + ); + } + + void bind_polygon_collider(sol::state& l) { + l.new_usertype>("polygon_collider", + sol::no_constructor + ); + } +} + +namespace e2d::bindings::high +{ + void bind_colliders(sol::state& l) { + bind_box_collider(l); + bind_circle_collider(l); + bind_polygon_collider(l); + } +} diff --git a/sources/enduro2d/high/bindings/high_binds/gobject_binds.cpp b/sources/enduro2d/high/bindings/high_binds/gobject_binds.cpp index cff1428c..f3bb9b5f 100644 --- a/sources/enduro2d/high/bindings/high_binds/gobject_binds.cpp +++ b/sources/enduro2d/high/bindings/high_binds/gobject_binds.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -41,6 +42,9 @@ namespace e2d::bindings::high "actor", sol::property([](gobject& go){ return component_wrapper{go}; }), "behaviour", sol::property([](gobject& go){ return component_wrapper{go}; }), "camera", sol::property([](gobject& go){ return component_wrapper{go}; }), + "box_collider", sol::property([](gobject& go){ return component_wrapper{go}; }), + "circle_collider", sol::property([](gobject& go){ return component_wrapper{go}; }), + "polygon_collider", sol::property([](gobject& go){ return component_wrapper{go}; }), "flipbook_player", sol::property([](gobject& go){ return component_wrapper{go}; }), "label", sol::property([](gobject& go){ return component_wrapper