mirror of
https://github.com/enduro2d/enduro2d.git
synced 2025-12-15 08:15:38 +07:00
dummy rigid_body component
This commit is contained in:
@@ -40,6 +40,7 @@
|
||||
#include "components/model_renderer.hpp"
|
||||
#include "components/named.hpp"
|
||||
#include "components/renderer.hpp"
|
||||
#include "components/rigid_body.hpp"
|
||||
#include "components/scene.hpp"
|
||||
#include "components/spine_player.hpp"
|
||||
#include "components/sprite_renderer.hpp"
|
||||
|
||||
@@ -60,6 +60,7 @@ namespace e2d
|
||||
class model_renderer;
|
||||
class named;
|
||||
class renderer;
|
||||
class rigid_body;
|
||||
class scene;
|
||||
class spine_player;
|
||||
class sprite_renderer;
|
||||
|
||||
33
headers/enduro2d/high/components/rigid_body.hpp
Normal file
33
headers/enduro2d/high/components/rigid_body.hpp
Normal file
@@ -0,0 +1,33 @@
|
||||
/*******************************************************************************
|
||||
* 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 rigid_body final {
|
||||
public:
|
||||
rigid_body() = default;
|
||||
};
|
||||
|
||||
template <>
|
||||
class factory_loader<rigid_body> final : factory_loader<> {
|
||||
public:
|
||||
static const char* schema_source;
|
||||
|
||||
bool operator()(
|
||||
rigid_body& component,
|
||||
const fill_context& ctx) const;
|
||||
|
||||
bool operator()(
|
||||
asset_dependencies& dependencies,
|
||||
const collect_context& ctx) const;
|
||||
};
|
||||
}
|
||||
19
samples/bin/library/scripts/emmy/components/rigid_body.lua
Normal file
19
samples/bin/library/scripts/emmy/components/rigid_body.lua
Normal file
@@ -0,0 +1,19 @@
|
||||
---@class rigid_body
|
||||
local rigid_body = {
|
||||
---@type boolean
|
||||
enabled = true,
|
||||
|
||||
---@type boolean
|
||||
disabled = false
|
||||
}
|
||||
|
||||
---@overload fun(self: rigid_body)
|
||||
---@param self rigid_body
|
||||
function rigid_body.enable(self) end
|
||||
|
||||
---@overload fun(self: rigid_body)
|
||||
---@param self rigid_body
|
||||
function rigid_body.disable(self) end
|
||||
|
||||
---@type rigid_body
|
||||
_G.rigid_body = _G.rigid_body or rigid_body
|
||||
@@ -39,6 +39,9 @@ local gobject = {
|
||||
---@type renderer
|
||||
renderer = nil,
|
||||
|
||||
---@type rigid_body
|
||||
rigid_body = nil,
|
||||
|
||||
---@type scene
|
||||
scene = nil,
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ namespace e2d::bindings::high
|
||||
void bind_model_renderer(sol::state& l);
|
||||
void bind_named(sol::state& l);
|
||||
void bind_renderer(sol::state& l);
|
||||
void bind_rigid_body(sol::state& l);
|
||||
void bind_scene(sol::state& l);
|
||||
void bind_spine_player(sol::state& l);
|
||||
void bind_sprite_renderer(sol::state& l);
|
||||
@@ -51,6 +52,7 @@ namespace e2d::bindings
|
||||
high::bind_model_renderer(l);
|
||||
high::bind_named(l);
|
||||
high::bind_renderer(l);
|
||||
high::bind_rigid_body(l);
|
||||
high::bind_scene(l);
|
||||
high::bind_spine_player(l);
|
||||
high::bind_sprite_renderer(l);
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
/*******************************************************************************
|
||||
* 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 <enduro2d/high/gobject.hpp>
|
||||
#include <enduro2d/high/components/disabled.hpp>
|
||||
#include <enduro2d/high/components/rigid_body.hpp>
|
||||
|
||||
namespace e2d::bindings::high
|
||||
{
|
||||
void bind_rigid_body(sol::state& l) {
|
||||
l.new_usertype<gcomponent<rigid_body>>("rigid_body",
|
||||
sol::no_constructor,
|
||||
|
||||
"enable", [](gcomponent<rigid_body>& c){
|
||||
c.owner().component<disabled<rigid_body>>().remove();
|
||||
},
|
||||
|
||||
"disable", [](gcomponent<rigid_body>& c){
|
||||
c.owner().component<disabled<rigid_body>>().ensure();
|
||||
},
|
||||
|
||||
"enabled", sol::property(
|
||||
[](const gcomponent<rigid_body>& c) -> bool {
|
||||
return !c.owner().component<disabled<rigid_body>>().exists();
|
||||
},
|
||||
[](gcomponent<rigid_body>& c, bool yesno){
|
||||
if ( yesno ) {
|
||||
c.owner().component<disabled<rigid_body>>().remove();
|
||||
} else {
|
||||
c.owner().component<disabled<rigid_body>>().ensure();
|
||||
}
|
||||
}
|
||||
),
|
||||
|
||||
"disabled", sol::property(
|
||||
[](const gcomponent<rigid_body>& c) -> bool {
|
||||
return c.owner().component<disabled<rigid_body>>().exists();
|
||||
},
|
||||
[](gcomponent<rigid_body>& c, bool yesno){
|
||||
if ( yesno ) {
|
||||
c.owner().component<disabled<rigid_body>>().ensure();
|
||||
} else {
|
||||
c.owner().component<disabled<rigid_body>>().remove();
|
||||
}
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,7 @@
|
||||
#include <enduro2d/high/components/model_renderer.hpp>
|
||||
#include <enduro2d/high/components/named.hpp>
|
||||
#include <enduro2d/high/components/renderer.hpp>
|
||||
#include <enduro2d/high/components/rigid_body.hpp>
|
||||
#include <enduro2d/high/components/scene.hpp>
|
||||
#include <enduro2d/high/components/spine_player.hpp>
|
||||
#include <enduro2d/high/components/sprite_renderer.hpp>
|
||||
@@ -51,6 +52,7 @@ namespace e2d::bindings::high
|
||||
"model_renderer", sol::property([](gobject& go){ return component_wrapper<model_renderer>{go}; }),
|
||||
"named", sol::property([](gobject& go){ return component_wrapper<named>{go}; }),
|
||||
"renderer", sol::property([](gobject& go){ return component_wrapper<renderer>{go}; }),
|
||||
"rigid_body", sol::property([](gobject& go){ return component_wrapper<rigid_body>{go}; }),
|
||||
"scene", sol::property([](gobject& go){ return component_wrapper<scene>{go}; }),
|
||||
"spine_player", sol::property([](gobject& go){ return component_wrapper<spine_player>{go}; }),
|
||||
"sprite_renderer", sol::property([](gobject& go){ return component_wrapper<sprite_renderer>{go}; }),
|
||||
|
||||
34
sources/enduro2d/high/components/rigid_body.cpp
Normal file
34
sources/enduro2d/high/components/rigid_body.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
/*******************************************************************************
|
||||
* 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 <enduro2d/high/components/rigid_body.hpp>
|
||||
|
||||
namespace e2d
|
||||
{
|
||||
const char* factory_loader<rigid_body>::schema_source = R"json({
|
||||
"type" : "object",
|
||||
"required" : [],
|
||||
"additionalProperties" : false,
|
||||
"properties" : {
|
||||
}
|
||||
})json";
|
||||
|
||||
bool factory_loader<rigid_body>::operator()(
|
||||
rigid_body& component,
|
||||
const fill_context& ctx) const
|
||||
{
|
||||
E2D_UNUSED(component, ctx);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool factory_loader<rigid_body>::operator()(
|
||||
asset_dependencies& dependencies,
|
||||
const collect_context& ctx) const
|
||||
{
|
||||
E2D_UNUSED(dependencies, ctx);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,7 @@
|
||||
#include <enduro2d/high/components/model_renderer.hpp>
|
||||
#include <enduro2d/high/components/named.hpp>
|
||||
#include <enduro2d/high/components/renderer.hpp>
|
||||
#include <enduro2d/high/components/rigid_body.hpp>
|
||||
#include <enduro2d/high/components/scene.hpp>
|
||||
#include <enduro2d/high/components/spine_player.hpp>
|
||||
#include <enduro2d/high/components/sprite_renderer.hpp>
|
||||
@@ -195,6 +196,7 @@ namespace e2d
|
||||
.register_component<model_renderer>("model_renderer")
|
||||
.register_component<named>("named")
|
||||
.register_component<renderer>("renderer")
|
||||
.register_component<rigid_body>("rigid_body")
|
||||
.register_component<scene>("scene")
|
||||
.register_component<spine_player>("spine_player")
|
||||
.register_component<events<spine_player_events::event>>("spine_player_events")
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"components" : {
|
||||
"rigid_body" : {},
|
||||
"touchable" : {},
|
||||
|
||||
"rect_collider" : {
|
||||
|
||||
@@ -250,6 +250,7 @@ TEST_CASE("library"){
|
||||
ecs::registry w;
|
||||
ecs::entity e = w.create_entity(prefab_res->content().prototype());
|
||||
|
||||
REQUIRE(e.exists_component<rigid_body>());
|
||||
REQUIRE(e.exists_component<touchable>());
|
||||
|
||||
REQUIRE(e.exists_component<rect_collider>());
|
||||
|
||||
Reference in New Issue
Block a user