This commit is contained in:
aozhiwei 2023-10-13 16:53:48 +08:00
parent 80375b14e5
commit 06a3493db2
3 changed files with 35 additions and 10 deletions

View File

@ -2,6 +2,7 @@
#include "new_hero_agent.h"
#include "hero.h"
#include "room.h"
HeroAgent::HeroAgent():BaseAgent()
{
@ -19,7 +20,7 @@ void HeroAgent::Exec()
void HeroAgent::SetOwner(Creature* owner)
{
//room = owner->room;
room_agent = owner->room->GetRoomAgent();
owner_ = owner;
}

View File

@ -2,6 +2,8 @@
#include "target_agent.h"
#include "mt/Hero.h"
TargetAgent::TargetAgent():BaseAgent()
{
@ -13,45 +15,63 @@ TargetAgent::~TargetAgent()
int TargetAgent::GetUniId()
{
if (target_.Get()) {
return target_.Get()->GetUniId();
}
return 0;
}
bool TargetAgent::IsValid()
{
return target_.Get() && !target_.Get()->dead;
}
bool TargetAgent::IsDead()
{
if (target_.Get()) {
return target_.Get()->dead;
}
return true;
}
const glm::vec3 TargetAgent::GetPos()
{
return target_.Get()->GetPos().ToGlmVec3();
}
float TargetAgent::GetHp()
{
if (!target_.Get()) {
abort();
}
return target_.Get()->GetHP();
}
float TargetAgent::GetMaxHp()
{
if (!target_.Get()) {
abort();
}
return target_.Get()->GetMaxHP();
}
int TargetAgent::GetHeroId()
{
if (!target_.Get()) {
abort();
}
return target_.Get()->GetHeroMeta()->id();
}
int TargetAgent::GetLevel()
{
if (!target_.Get()) {
abort();
}
return target_.Get()->level;
}
void TargetAgent::Abandon()
{
target_.Reset();
}

View File

@ -2,6 +2,8 @@
#include "new_base_agent.h"
#include "creature.h"
class TargetAgent : public BaseAgent
{
public:
@ -21,4 +23,6 @@ public:
int GetLevel();
void Abandon();
private:
CreatureWeakPtr target_;
};