#pragma once #include "IBehavior.h" #include "ECS/Public/Entity.h" #include "GameObject/Public/Core.h" namespace AI { template class BehaviorBase : public IBehavior { protected: inline static std::function CreateLeaf( ECS::Entity* entity, std::function processFunction) { using namespace std::placeholders; Object* object = GetObjFromEntity(entity); return std::bind(processFunction, entity, object, _1); } inline static std::function CreateLeaf( ECS::Entity* entity, std::function processFunction) { using namespace std::placeholders; Object* object = GetObjFromEntity(entity); return std::bind(processFunction, entity, object, _1); } private: inline static Object* GetObjFromEntity(ECS::Entity* entity) { if (entity) { GameObj::ObjectRef& objectRef = entity->GetComponent(); return objectRef.GetObj(); } return nullptr; } }; }