// http://www.apache.org/licenses/LICENSE-2.0 // Copyright 2014 Perttu Ahola #include "entitysync/api.h" #include "core/log.h" #include "interface/module.h" #include "interface/server.h" #include "interface/event.h" #include "interface/tcpsocket.h" #include "interface/packet_stream.h" #include "interface/magic_event.h" #include #include #include #include #include #include #include #include #include #include #include using interface::Event; namespace magic = Urho3D; namespace entitysync { struct Module: public interface::Module, public entitysync::Interface { interface::Server *m_server; Module(interface::Server *server): interface::Module("entitysync"), m_server(server) { log_v(MODULE, "entitysync construct"); } ~Module() { log_v(MODULE, "entitysync destruct"); } void init() { log_v(MODULE, "entitysync init"); m_server->sub_event(this, Event::t("core:start")); m_server->sub_event(this, Event::t("core:unload")); m_server->sub_event(this, Event::t("core:continue")); /*m_server->sub_magic_event(this, magic::E_NODEADDED, Event::t("entitysync:node_added"));*/ m_server->access_scene([&](magic::Scene *scene) { magic::Context *context = scene->GetContext(); /*magic::ResourceCache* cache = m_context->GetSubsystem(); Node* plane_node = m_scene->CreateChild("Plane"); plane_node->SetScale(Vector3(100.0f, 1.0f, 100.0f)); StaticModel* plane_object = plane_node->CreateComponent(); plane_object->SetModel(cache->GetResource("Models/Plane.mdl")); plane_object->SetMaterial(cache->GetResource("Materials/StoneTiled.xml"));*/ }); } void event(const Event::Type &type, const Event::Private *p) { EVENT_VOIDN("core:start", on_start) EVENT_VOIDN("core:unload", on_unload) EVENT_VOIDN("core:continue", on_continue) EVENT_TYPEN("entitysync:node_added", on_node_added, interface::MagicEvent) } void on_start() { } void on_unload() { } void on_continue() { } void on_node_added(const interface::MagicEvent &event) { log_w(MODULE, "Node added"); /*m_server->access_scene([&](magic::Scene *scene) { });*/ } // Interface void* get_interface() { return dynamic_cast(this); } }; extern "C" { EXPORT void* createModule_entitysync(interface::Server *server){ return (void*)(new Module(server)); } } } // vim: set noet ts=4 sw=4: