102 lines
1.5 KiB
C++
102 lines
1.5 KiB
C++
#include "precompile.h"
|
|
|
|
#include "target_agent.h"
|
|
|
|
#include "mt/Hero.h"
|
|
#include "mt/Equip.h"
|
|
|
|
TargetAgent::TargetAgent():BaseAgent()
|
|
{
|
|
|
|
}
|
|
|
|
TargetAgent::~TargetAgent()
|
|
{
|
|
}
|
|
|
|
int TargetAgent::GetUniId()
|
|
{
|
|
if (target_.Get()) {
|
|
return target_.Get()->GetUniId();
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
bool TargetAgent::IsValid()
|
|
{
|
|
return target_.Get() && !target_.Get()->dead && target_.Get()->team_id != owner_->team_id;
|
|
}
|
|
|
|
bool TargetAgent::IsDead()
|
|
{
|
|
if (target_.Get()) {
|
|
return target_.Get()->dead;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
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();
|
|
}
|
|
|
|
void TargetAgent::SetOwner(Creature* owner)
|
|
{
|
|
owner_ = owner;
|
|
}
|
|
|
|
Room* TargetAgent::GetRoom()
|
|
{
|
|
return owner_->room;
|
|
}
|
|
|
|
float TargetAgent::GetShotRange()
|
|
{
|
|
if (target_.Get() && target_.Get()->GetCurrWeapon()) {
|
|
return target_.Get()->GetCurrWeapon()->meta->range();
|
|
}
|
|
return 0.0f;
|
|
}
|
|
|
|
void TargetAgent::SetTarget(Creature* target)
|
|
{
|
|
target_ = target->GetWeakPtrRef();
|
|
}
|