33 template <
class T,
class Value>
46 template <
class Value>
47 bool operator()(Value
const& left, Value
const& right)
const
56 template <
class AI,
class T>
59 static_assert(std::is_same<AI, CreatureAI>::value || std::is_same<AI, GameObjectAI>::value,
"Invalid template parameter");
60 static_assert(std::is_same<AI, CreatureAI>::value == std::is_same<T, Creature>::value,
"Incompatible AI for type");
61 static_assert(std::is_same<AI, GameObjectAI>::value == std::is_same<T, GameObject>::value,
"Incompatible AI for type");
66 std::string
const& aiName = obj->GetAIName();
71 typename AIRegistry::RegistryMapType
const& items = AIRegistry::instance()->GetRegisteredItems();
74 return itr->second.get();
84 if (creature->
IsPet())
95 TC_LOG_ERROR(
"entities.unit",
"Exception trying to assign script '{}' to Creature (Entry: {}), this Creature will have a default AI. Exception message: {}",
99 return SelectFactory<CreatureAI>(creature)->Create(creature);
106 if (!creature->GetCharmerOrSelfPlayer())
107 type = creature->GetDefaultMovementType();
119 return SelectFactory<GameObjectAI>(go)->Create(go);
#define sCreatureAIRegistry
#define ASSERT_NOTNULL(pointer)
#define TC_LOG_ERROR(filterType__,...)
#define sMovementGeneratorRegistry
std::string GetScriptName() const
virtual T * Create(O *object=nullptr) const =0
Abstract Factory create method.
char const * what() const noexcept override
T const * GetRegistryItem(Key const &key) const
Returns a registry item.
static Creature * ToCreature(Object *o)
virtual int32 Permit(T const *) const =0
virtual MovementGeneratorType GetDefaultMovementType() const
MovementGenerator * SelectMovementGenerator(Unit *unit)
CreatureAI * SelectAI(Creature *creature)
GameObjectAI * SelectGameObjectAI(GameObject *go)
int32 GetPermitFor(T const *obj, Value const &value)
FactoryHolder< AI, T > const * SelectFactory(T *obj)
PermissibleOrderPred(T const *obj)
bool operator()(Value const &left, Value const &right) const