This commit is contained in:
aozhiwei 2021-07-23 03:46:12 +00:00
parent e1970a647a
commit bf5e70c166
4 changed files with 10 additions and 5 deletions

View File

@ -17,6 +17,7 @@ class AIComponent
{
public:
MoveableEntity* owner = nullptr;
MetaData::AI* ai_meta = nullptr;
virtual ~AIComponent();
virtual void Update(int delta_time);

View File

@ -47,7 +47,6 @@ private:
OldAiData* old_ai_data_ = nullptr;
MetaData::AI* ai_meta = nullptr;
AINode* node_ = nullptr;
bool moving_ = false;
};

View File

@ -14,7 +14,7 @@ public:
virtual void Update(int delta_time) override;
float GetAttackRate();
private:
protected:
void UpdateAI();
void UpdateIdle();
void UpdateThinking();
@ -30,8 +30,7 @@ private:
float GetAttackRange();
int GetAttackTimes();
private:
MetaData::AI* ai_meta = nullptr;
protected:
HeroAINode* node_ = nullptr;
bool moving_ = false;
};

View File

@ -254,6 +254,12 @@ void Hero::InitAI()
if (!ai_meta) {
abort();
}
if (ai_meta->i->ai_kind() == kAI_MineSweeper) {
ai = new MineSweeperAI;
ai->ai_meta = ai_meta;
} else {
ai = new HeroAI;
ai->ai_meta = ai_meta;
}
ai->owner = this;
}