This commit is contained in:
aozhiwei 2023-10-16 12:15:42 +08:00
parent 8f31bb8f2a
commit 40bf09f833
5 changed files with 16 additions and 18 deletions

View File

@ -18,6 +18,7 @@
#include "btcontext.h" #include "btcontext.h"
#include "team.h" #include "team.h"
#include "master_agent.h" #include "master_agent.h"
#include "team_agent.h"
#include "mt/Hero.h" #include "mt/Hero.h"
#include "mt/Equip.h" #include "mt/Equip.h"
@ -26,6 +27,7 @@ HeroAgent::HeroAgent():BaseAgent()
{ {
current_target_agent = behaviac::Agent::Create<TargetAgent>(); current_target_agent = behaviac::Agent::Create<TargetAgent>();
master_agent = behaviac::Agent::Create<MasterAgent>(); master_agent = behaviac::Agent::Create<MasterAgent>();
team_agent = behaviac::Agent::Create<TeamAgent>();
} }
HeroAgent::~HeroAgent() HeroAgent::~HeroAgent()
@ -38,6 +40,10 @@ HeroAgent::~HeroAgent()
f8::BtMgr::Instance()->BtDestory(master_agent); f8::BtMgr::Instance()->BtDestory(master_agent);
master_agent = nullptr; master_agent = nullptr;
} }
{
f8::BtMgr::Instance()->BtDestory(team_agent);
team_agent = nullptr;
}
} }
void HeroAgent::Exec() void HeroAgent::Exec()
@ -60,8 +66,7 @@ void HeroAgent::SetOwner(Creature* owner)
owner_ = owner; owner_ = owner;
current_target_agent->SetOwner(owner_); current_target_agent->SetOwner(owner_);
room_agent = owner_->room->GetRoomAgent(); room_agent = owner_->room->GetRoomAgent();
team_agent = owner_->GetTeam()->GetTeamAgent(); }
}
int HeroAgent::GetUniId() int HeroAgent::GetUniId()
{ {

View File

@ -15,7 +15,6 @@
#include "jsondatamgr.h" #include "jsondatamgr.h"
#include "httpproxy.h" #include "httpproxy.h"
#include "roommgr.h" #include "roommgr.h"
#include "team_agent.h"
#include "mt/Param.h" #include "mt/Param.h"
#include "mt/Map.h" #include "mt/Map.h"
@ -26,14 +25,10 @@
Team::Team() Team::Team()
{ {
team_agent_ = behaviac::Agent::Create<TeamAgent>();
team_agent_->SetTeam(this);
} }
Team::~Team() Team::~Team()
{ {
f8::BtMgr::Instance()->BtDestory(team_agent_);
team_agent_ = nullptr;
} }
void Team::TraverseMembers(std::function<bool (Human*)> func) void Team::TraverseMembers(std::function<bool (Human*)> func)

View File

@ -12,7 +12,6 @@ namespace a8
class Room; class Room;
class Human; class Human;
class TeamAgent;
class Team class Team
{ {
public: public:
@ -60,7 +59,6 @@ class Team
void IncKillCount(); void IncKillCount();
int GetKillCount(); int GetKillCount();
long long GetLastKillFrameNo() { return last_kill_frameno_; } long long GetLastKillFrameNo() { return last_kill_frameno_; }
TeamAgent* GetTeamAgent() { return team_agent_; }
private: private:
int team_id_ = 0; int team_id_ = 0;
@ -72,5 +70,4 @@ class Team
bool auto_fill_ = false; bool auto_fill_ = false;
int kill_count_ = 0; int kill_count_ = 0;
long long last_kill_frameno_ = 0; long long last_kill_frameno_ = 0;
TeamAgent* team_agent_ = nullptr;
}; };

View File

@ -3,6 +3,7 @@
#include "team_agent.h" #include "team_agent.h"
#include "team.h" #include "team.h"
#include "creature.h"
TeamAgent::TeamAgent():BaseAgent() TeamAgent::TeamAgent():BaseAgent()
{ {
@ -15,25 +16,25 @@ TeamAgent::~TeamAgent()
int TeamAgent::GetMemberNum() int TeamAgent::GetMemberNum()
{ {
return team_->GetMemberNum(); return owner_->GetTeam()->GetMemberNum();
} }
int TeamAgent::GetPlayerNum() int TeamAgent::GetPlayerNum()
{ {
return team_->GetPlayerNum(); return owner_->GetTeam()->GetPlayerNum();
} }
int TeamAgent::GetAlivePlayerNum() int TeamAgent::GetAlivePlayerNum()
{ {
return team_->GetAlivePlayerNum(); return owner_->GetTeam()->GetAlivePlayerNum();
} }
void TeamAgent::SetTeam(Team* team) void TeamAgent::SetOwner(Creature* owner)
{ {
team_ = team; owner_ = owner;
} }
Room* TeamAgent::GetRoom() Room* TeamAgent::GetRoom()
{ {
return team_->room; return owner_->GetTeam()->room;
} }

View File

@ -17,9 +17,9 @@ public:
int GetPlayerNum(); int GetPlayerNum();
int GetAlivePlayerNum(); int GetAlivePlayerNum();
void SetTeam(Team* team); void SetOwner(Creature* owner);
Room* GetRoom(); Room* GetRoom();
private: private:
Team* team_ = nullptr; Creature* owner_ = nullptr;
}; };