This commit is contained in:
aozhiwei 2023-10-14 22:01:11 +08:00
parent b79c58cf30
commit 3e4456644a
4 changed files with 113 additions and 1 deletions

View File

@ -101,6 +101,7 @@ class Creature : public MoveableEntity
int level = 1;
int hero_level = 1;
int revive_count = 0;
CreatureWeakPtr master;
Weapon second_weapon;
glm::vec3 skill_pos;

View File

@ -12,7 +12,6 @@ class HeroAgent;
class Hero : public Creature
{
public:
CreatureWeakPtr master;
const mt::Hero* meta = nullptr;
bool is_pve_boss = false;
list_head entry;

View File

@ -0,0 +1,82 @@
#include "precompile.h"
#include "master_agent.h"
#include "mt/Hero.h"
MasterAgent::MasterAgent():BaseAgent()
{
}
MasterAgent::~MasterAgent()
{
}
int MasterAgent::GetUniId()
{
if (owner_->master.Get()) {
return owner_->master.Get()->GetUniId();
}
return 0;
}
bool MasterAgent::IsValid()
{
return owner_->master.Get() && !owner_->master.Get()->dead;
}
bool MasterAgent::IsDead()
{
if (owner_->master.Get()) {
return owner_->master.Get()->dead;
}
return true;
}
const glm::vec3 MasterAgent::GetPos()
{
return owner_->master.Get()->GetPos().ToGlmVec3();
}
float MasterAgent::GetHp()
{
if (!owner_->master.Get()) {
abort();
}
return owner_->master.Get()->GetHP();
}
float MasterAgent::GetMaxHp()
{
if (!owner_->master.Get()) {
abort();
}
return owner_->master.Get()->GetMaxHP();
}
int MasterAgent::GetHeroId()
{
if (!owner_->master.Get()) {
abort();
}
return owner_->master.Get()->GetHeroMeta()->id();
}
int MasterAgent::GetLevel()
{
if (!owner_->master.Get()) {
abort();
}
return owner_->master.Get()->level;
}
void MasterAgent::SetOwner(Creature* owner)
{
owner_ = owner;
}
Room* MasterAgent::GetRoom()
{
return owner_->room;
}

View File

@ -0,0 +1,30 @@
#pragma once
#include "new_base_agent.h"
#include "creature.h"
class MasterAgent : public BaseAgent
{
public:
MasterAgent();
virtual ~MasterAgent();
BEHAVIAC_DECLARE_AGENTTYPE(MasterAgent, BaseAgent)
int GetUniId();
bool IsValid();
bool IsDead();
const glm::vec3 GetPos();
float GetHp();
float GetMaxHp();
int GetHeroId();
int GetLevel();
void SetOwner(Creature* owner);
virtual Room* GetRoom() override;
private:
Creature* owner_ = nullptr;
};