mirror of
https://github.com/enduro2d/enduro2d.git
synced 2025-12-14 16:09:06 +07:00
add meta table to behaviour component
This commit is contained in:
@@ -14,13 +14,24 @@
|
||||
namespace e2d
|
||||
{
|
||||
class behaviour final {
|
||||
public:
|
||||
class started final {};
|
||||
class destroy final {};
|
||||
class disabled final {};
|
||||
public:
|
||||
behaviour() = default;
|
||||
behaviour(const script_asset::ptr& script);
|
||||
|
||||
behaviour& meta(sol::table&& value) noexcept;
|
||||
behaviour& meta(const sol::table& value);
|
||||
|
||||
[[nodiscard]] sol::table& meta() noexcept;
|
||||
[[nodiscard]] const sol::table& meta() const noexcept;
|
||||
|
||||
behaviour& script(const script_asset::ptr& value) noexcept;
|
||||
[[nodiscard]] const script_asset::ptr& script() const noexcept;
|
||||
private:
|
||||
sol::table meta_;
|
||||
script_asset::ptr script_;
|
||||
};
|
||||
|
||||
@@ -37,6 +48,48 @@ namespace e2d
|
||||
asset_dependencies& dependencies,
|
||||
const collect_context& ctx) const;
|
||||
};
|
||||
|
||||
template <>
|
||||
class factory_loader<behaviour::started> final : factory_loader<> {
|
||||
public:
|
||||
static const char* schema_source;
|
||||
|
||||
bool operator()(
|
||||
behaviour::started& component,
|
||||
const fill_context& ctx) const;
|
||||
|
||||
bool operator()(
|
||||
asset_dependencies& dependencies,
|
||||
const collect_context& ctx) const;
|
||||
};
|
||||
|
||||
template <>
|
||||
class factory_loader<behaviour::destroy> final : factory_loader<> {
|
||||
public:
|
||||
static const char* schema_source;
|
||||
|
||||
bool operator()(
|
||||
behaviour::destroy& component,
|
||||
const fill_context& ctx) const;
|
||||
|
||||
bool operator()(
|
||||
asset_dependencies& dependencies,
|
||||
const collect_context& ctx) const;
|
||||
};
|
||||
|
||||
template <>
|
||||
class factory_loader<behaviour::disabled> final : factory_loader<> {
|
||||
public:
|
||||
static const char* schema_source;
|
||||
|
||||
bool operator()(
|
||||
behaviour::disabled& component,
|
||||
const fill_context& ctx) const;
|
||||
|
||||
bool operator()(
|
||||
asset_dependencies& dependencies,
|
||||
const collect_context& ctx) const;
|
||||
};
|
||||
}
|
||||
|
||||
namespace e2d
|
||||
@@ -44,6 +97,24 @@ namespace e2d
|
||||
inline behaviour::behaviour(const script_asset::ptr& value)
|
||||
: script_(value) {}
|
||||
|
||||
inline behaviour& behaviour::meta(sol::table&& value) noexcept {
|
||||
meta_ = std::move(value);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline behaviour& behaviour::meta(const sol::table& value) {
|
||||
meta_ = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline sol::table& behaviour::meta() noexcept {
|
||||
return meta_;
|
||||
}
|
||||
|
||||
inline const sol::table& behaviour::meta() const noexcept {
|
||||
return meta_;
|
||||
}
|
||||
|
||||
inline behaviour& behaviour::script(const script_asset::ptr& value) noexcept {
|
||||
script_ = value;
|
||||
return *this;
|
||||
|
||||
@@ -50,3 +50,81 @@ namespace e2d
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
namespace e2d
|
||||
{
|
||||
const char* factory_loader<behaviour::started>::schema_source = R"json({
|
||||
"type" : "object",
|
||||
"required" : [],
|
||||
"additionalProperties" : false,
|
||||
"properties" : {}
|
||||
})json";
|
||||
|
||||
bool factory_loader<behaviour::started>::operator()(
|
||||
behaviour::started& component,
|
||||
const fill_context& ctx) const
|
||||
{
|
||||
E2D_UNUSED(component, ctx);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool factory_loader<behaviour::started>::operator()(
|
||||
asset_dependencies& dependencies,
|
||||
const collect_context& ctx) const
|
||||
{
|
||||
E2D_UNUSED(dependencies, ctx);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
namespace e2d
|
||||
{
|
||||
const char* factory_loader<behaviour::destroy>::schema_source = R"json({
|
||||
"type" : "object",
|
||||
"required" : [],
|
||||
"additionalProperties" : false,
|
||||
"properties" : {}
|
||||
})json";
|
||||
|
||||
bool factory_loader<behaviour::destroy>::operator()(
|
||||
behaviour::destroy& component,
|
||||
const fill_context& ctx) const
|
||||
{
|
||||
E2D_UNUSED(component, ctx);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool factory_loader<behaviour::destroy>::operator()(
|
||||
asset_dependencies& dependencies,
|
||||
const collect_context& ctx) const
|
||||
{
|
||||
E2D_UNUSED(dependencies, ctx);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
namespace e2d
|
||||
{
|
||||
const char* factory_loader<behaviour::disabled>::schema_source = R"json({
|
||||
"type" : "object",
|
||||
"required" : [],
|
||||
"additionalProperties" : false,
|
||||
"properties" : {}
|
||||
})json";
|
||||
|
||||
bool factory_loader<behaviour::disabled>::operator()(
|
||||
behaviour::disabled& component,
|
||||
const fill_context& ctx) const
|
||||
{
|
||||
E2D_UNUSED(component, ctx);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool factory_loader<behaviour::disabled>::operator()(
|
||||
asset_dependencies& dependencies,
|
||||
const collect_context& ctx) const
|
||||
{
|
||||
E2D_UNUSED(dependencies, ctx);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,6 +139,9 @@ namespace e2d
|
||||
safe_module_initialize<factory>()
|
||||
.register_component<actor>("actor")
|
||||
.register_component<behaviour>("behaviour")
|
||||
.register_component<behaviour::started>("behaviour.started")
|
||||
.register_component<behaviour::destroy>("behaviour.destroy")
|
||||
.register_component<behaviour::disabled>("behaviour.disabled")
|
||||
.register_component<camera>("camera")
|
||||
.register_component<flipbook_player>("flipbook_player")
|
||||
.register_component<label>("label")
|
||||
|
||||
Reference in New Issue
Block a user