init dummy high level table

This commit is contained in:
2019-10-23 11:52:42 +07:00
parent cfeca1a1aa
commit e67a2baa75
3 changed files with 97 additions and 6 deletions

View File

@@ -6,10 +6,70 @@
#include "bindings.hpp"
#include <enduro2d/high/library.hpp>
#include <enduro2d/high/luasol.hpp>
#include <enduro2d/high/world.hpp>
#include <enduro2d/high/node.hpp>
#include <enduro2d/high/gobject.hpp>
#include <enduro2d/high/components/actor.hpp>
#include <enduro2d/high/components/behaviour.hpp>
namespace
{
using namespace e2d;
void bind_library(sol::state& l) {
l.new_usertype<library>("library");
}
void bind_luasol(sol::state& l) {
l.new_usertype<luasol>("luasol");
}
void bind_world(sol::state& l) {
l.new_usertype<world>("world");
}
}
namespace
{
using namespace e2d;
void bind_node(sol::state& l) {
l.new_usertype<node>("node");
}
void bind_gobject(sol::state& l) {
l.new_usertype<gobject>("gobject");
}
}
namespace
{
using namespace e2d;
void bind_actor(sol::state& l) {
l.new_usertype<actor>("actor");
}
void bind_behaviour(sol::state& l) {
l.new_usertype<behaviour>("behaviour");
}
}
namespace e2d::bindings
{
void bind_high(sol::state& l) {
//TODO(BlackMat): implme
E2D_UNUSED(l);
bind_library(l);
bind_luasol(l);
bind_world(l);
bind_node(l);
bind_gobject(l);
bind_actor(l);
bind_behaviour(l);
}
}

View File

@@ -192,11 +192,11 @@ namespace e2d
.register_component<spine_player_evt>("spine_player_evt")
.register_component<sprite_renderer>("sprite_renderer");
safe_module_initialize<luasol>();
safe_module_initialize<library>(
params.library_params().root());
safe_module_initialize<luasol>();
safe_module_initialize<world>();
}
@@ -204,8 +204,8 @@ namespace e2d
the<luasol>().collect_garbage();
modules::shutdown<world>();
modules::shutdown<luasol>();
modules::shutdown<library>();
modules::shutdown<luasol>();
modules::shutdown<factory>();
modules::shutdown<engine>();
}

View File

@@ -6,6 +6,32 @@
#include <enduro2d/high/systems/script_system.hpp>
#include <enduro2d/high/library.hpp>
#include <enduro2d/high/luasol.hpp>
#include <enduro2d/high/world.hpp>
namespace
{
using namespace e2d;
void init_core_table(sol::state& s) {
auto e2d_table = s["e2d"].get_or_create<sol::table>();
e2d_table["core"] = s.create_table_with(
"debug", &the<debug>(),
"engine", &the<engine>(),
"input", &the<input>(),
"window", &the<window>());
}
void init_high_table(sol::state& s) {
auto e2d_table = s["e2d"].get_or_create<sol::table>();
e2d_table["high"] = s.create_table_with(
"library", &the<library>(),
"luasol", &the<luasol>(),
"world", &the<world>());
}
}
namespace e2d
{
//
@@ -14,7 +40,12 @@ namespace e2d
class script_system::internal_state final : private noncopyable {
public:
internal_state() = default;
internal_state() {
the<luasol>().with_state([](sol::state& s){
init_core_table(s);
init_high_table(s);
});
}
~internal_state() noexcept = default;
void update_process(ecs::registry& owner) {