chore(Core/GameObjectAI): Cleanup register macro (#19409)

This commit is contained in:
Kitzunu 2024-07-17 00:17:49 +02:00 committed by GitHub
parent bdf204f1eb
commit f0e6b0f1ab
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 2 additions and 5 deletions

View file

@ -66,23 +66,21 @@ public:
virtual GameObjectAI* GetAI(GameObject* /*go*/) const { return nullptr; }
};
// Cannot be used due gob scripts not working like this
template <class AI>
class GenericGameObjectScript : public GameObjectScript
{
public:
GenericGameObjectScript(char const* name) : GameObjectScript(name) { }
GameObjectAI* GetAI(GameObject* me) const override { return new AI(me); }
GameObjectAI* GetAI(GameObject* go) const override { return new AI(go); }
};
#define RegisterGameObjectAI(ai_name) new GenericGameObjectScript<ai_name>(#ai_name)
// Cannot be used due gob scripts not working like this
template <class AI, AI* (*AIFactory)(GameObject*)> class FactoryGameObjectScript : public GameObjectScript
{
public:
FactoryGameObjectScript(char const* name) : GameObjectScript(name) {}
GameObjectAI* GetAI(GameObject* me) const override { return AIFactory(me); }
GameObjectAI* GetAI(GameObject* go) const override { return AIFactory(go); }
};
#define RegisterGameObjectAIWithFactory(ai_name, factory_fn) new FactoryGameObjectScript<ai_name, &factory_fn>(#ai_name)

View file

@ -83,6 +83,5 @@ inline AI* GetAhnKahetAI(T* obj)
}
#define RegisterAhnKahetCreatureAI(ai_name) RegisterCreatureAIWithFactory(ai_name, GetAhnKahetAI)
#define RegisterAhnKahetGameObjectAI(ai_name) RegisterGameObjectAIWithFactory(ai_name, GetAhnKahetAI)
#endif // DEF_AHNKAHET_H