/* * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it * and/or modify it under version 2 of the License, or (at your option), any later version. */ #ifndef _PLAYERBOT_AIOBJECTCONTEXT_H #define _PLAYERBOT_AIOBJECTCONTEXT_H #include #include #include "Common.h" #include "DynamicObject.h" #include "NamedObjectContext.h" #include "PlayerbotAIAware.h" #include "Strategy.h" #include "Trigger.h" #include "Value.h" class PlayerbotAI; typedef Strategy* (*StrategyCreator)(PlayerbotAI* botAI); typedef Action* (*ActionCreator)(PlayerbotAI* botAI); typedef Trigger* (*TriggerCreator)(PlayerbotAI* botAI); typedef UntypedValue* (*ValueCreator)(PlayerbotAI* botAI); class AiObjectContext : public PlayerbotAIAware { public: static BoolCalculatedValue* custom_glyphs(PlayerbotAI* ai); // Added for cutom glyphs AiObjectContext(PlayerbotAI* botAI, SharedNamedObjectContextList& sharedStrategyContext = sharedStrategyContexts, SharedNamedObjectContextList& sharedActionContext = sharedActionContexts, SharedNamedObjectContextList& sharedTriggerContext = sharedTriggerContexts, SharedNamedObjectContextList& sharedValueContext = sharedValueContexts); virtual ~AiObjectContext() {} virtual Strategy* GetStrategy(std::string const name); virtual std::set GetSiblingStrategy(std::string const name); virtual Trigger* GetTrigger(std::string const name); virtual Action* GetAction(std::string const name); virtual UntypedValue* GetUntypedValue(std::string const name); template Value* GetValue(std::string const name) { return dynamic_cast*>(GetUntypedValue(name)); } template Value* GetValue(std::string const name, std::string const param) { return GetValue((std::string(name) + "::" + param)); } template Value* GetValue(std::string const name, int32 param) { std::ostringstream out; out << param; return GetValue(name, out.str()); } std::set GetValues(); std::set GetSupportedStrategies(); std::set GetSupportedActions(); std::string const FormatValues(); std::vector Save(); void Load(std::vector data); std::vector performanceStack; static void BuildAllSharedContexts(); static void BuildSharedContexts(); static void BuildSharedStrategyContexts(SharedNamedObjectContextList& strategyContexts); static void BuildSharedActionContexts(SharedNamedObjectContextList& actionContexts); static void BuildSharedTriggerContexts(SharedNamedObjectContextList& triggerContexts); static void BuildSharedValueContexts(SharedNamedObjectContextList& valueContexts); protected: NamedObjectContextList strategyContexts; NamedObjectContextList actionContexts; NamedObjectContextList triggerContexts; NamedObjectContextList valueContexts; private: static SharedNamedObjectContextList sharedStrategyContexts; static SharedNamedObjectContextList sharedActionContexts; static SharedNamedObjectContextList sharedTriggerContexts; static SharedNamedObjectContextList sharedValueContexts; }; #endif