This commit is contained in:
aozhiwei 2023-10-14 21:30:27 +08:00
parent 321765334f
commit b79c58cf30
4 changed files with 19 additions and 2 deletions

View File

@ -23,11 +23,13 @@
HeroAgent::HeroAgent():BaseAgent()
{
current_target_agent = behaviac::Agent::Create<TargetAgent>();
}
HeroAgent::~HeroAgent()
{
f8::BtMgr::Instance()->BtDestory(current_target_agent);
current_target_agent = nullptr;
}
void HeroAgent::Exec()
@ -48,6 +50,7 @@ void HeroAgent::Exec()
void HeroAgent::SetOwner(Creature* owner)
{
owner_ = owner;
current_target_agent->SetOwner(owner_);
room_agent = owner_->room->GetRoomAgent();
team_agent = owner_->GetTeam()->GetTeamAgent();
}

View File

@ -24,7 +24,7 @@ public:
bool IsGameOver();
void SetRoom(Room* room) { room_ = room; }
virtual Room* GetRoom() { return room_; }
virtual Room* GetRoom() override { return room_; }
private:
Room* room_ = nullptr;

View File

@ -75,3 +75,13 @@ void TargetAgent::Abandon()
{
target_.Reset();
}
void TargetAgent::SetOwner(Creature* owner)
{
owner_ = owner;
}
Room* TargetAgent::GetRoom()
{
return owner_->room;
}

View File

@ -23,6 +23,10 @@ public:
int GetLevel();
void Abandon();
void SetOwner(Creature* owner);
virtual Room* GetRoom() override;
private:
CreatureWeakPtr target_;
Creature* owner_ = nullptr;
};