#ifndef PLAYERACTIONMODULE_H #define PLAYERACTIONMODULE_H #include #include #include #include namespace ECS { struct ActionNodeList { struct indexObject; struct ActionNode { Ogre::String action; Ogre::String action_text; Ogre::Vector3 position; Ogre::Quaternion rotation; float height; float radius; nlohmann::json props; }; struct UIData { std::shared_ptr mutex; int selected; std::vector points; std::vector distances; UIData() : mutex(std::make_shared()) , selected(-1) { } }; private: bool dirty; bool busy; std::shared_ptr indexObj; struct UIData uidata; bool _query(const Ogre::Vector3 &position, std::vector &points, std::vector &distances); public: std::shared_ptr nodeMutex; std::vector nodes, dynamicNodes; void updateDynamicNodes(); void build(); bool query_ai(const Ogre::Vector3 &position, float distance, std::vector &points, std::vector &distances); int addNode(struct ActionNodeList::ActionNode &node); void removeNode(int index); const UIData &getUIData(); void setUISelected(int selected); void setUIPoints(const std::vector &points, const std::vector &distances); void UIquery(const Ogre::Vector3 &position); void setDirty(); // node was added or removed void setReady(); void setBusy(); bool isBusy(); }; struct PlayerActionModule { struct ActionWordHandler { virtual void operator()(flecs::entity town, int index, const Ogre::String &word) = 0; }; std::multimap actionWords; PlayerActionModule(flecs::world &ecs); void addWordHandler(const Ogre::String &word, ActionWordHandler *handler); void removeWordHandler(const Ogre::String &word, ActionWordHandler *handler); void addLuaWordHandler(const Ogre::String &word, lua_State *L, int ref); void removeLuaWordHandler(const Ogre::String &word, lua_State *L, int ref); int setupLuaActionHandler(lua_State *L); }; } #endif // PLAYERACTIONMODULE_H