198 lines
6.4 KiB
C++
198 lines
6.4 KiB
C++
#pragma once
|
|
|
|
#include "weakptr.h"
|
|
#include "moveableentity.h"
|
|
#include "buff.h"
|
|
|
|
#include "cs_proto.pb.h"
|
|
|
|
namespace MetaData
|
|
{
|
|
class Skill;
|
|
class SkillPhase;
|
|
}
|
|
|
|
struct SkillCasterState
|
|
{
|
|
CreatureWeakPtr caster;
|
|
a8::Vec2 caster_pos;
|
|
int caster_skill_id = 0;
|
|
int caster_skill_target_id = 0;
|
|
a8::Vec2 caster_skill_dir;
|
|
float caster_skill_distance = 0.0f;
|
|
float caster_skill_param1 = 0.0f;
|
|
};
|
|
|
|
struct xtimer_list;
|
|
class Skill;
|
|
class Obstacle;
|
|
class RoomObstacle;
|
|
class Creature : public MoveableEntity
|
|
{
|
|
public:
|
|
|
|
std::vector<Weapon> weapons;
|
|
long long last_shot_frameno_ = 0;
|
|
int status = 0;
|
|
bool downed = false;
|
|
bool dead = false;
|
|
bool real_dead = false;
|
|
int team_id = 0;
|
|
bool aiming = false;
|
|
a8::Vec2 attack_dir;
|
|
HumanAbility ability;
|
|
a8::Vec2 target_pos;
|
|
std::function<bool ()> on_move_collision;
|
|
bool poisoning = false;
|
|
long long poisoning_time = 0;
|
|
|
|
Weapon car_weapon;
|
|
|
|
bool need_sync_active_player = false;
|
|
std::function<void ()> on_loading_bullet;
|
|
|
|
Creature();
|
|
virtual ~Creature() override;
|
|
virtual void Initialize() override;
|
|
bool HasBuffEffect(int buff_effect_id);
|
|
Buff* GetBuffByEffectId(int effect_id);
|
|
Buff* GetBuffById(int buff_id);
|
|
void AddBuff(Creature* caster,
|
|
MetaData::Buff* buff_meta,
|
|
int skill_lv,
|
|
MetaData::Skill* buff_skill_meta = nullptr);
|
|
bool IsImmuneBuffEffect(int buff_effect);
|
|
void MustBeAddBuff(Creature* caster, int buff_id);
|
|
void RemoveBuffById(int buff_id);
|
|
void RecalcBuffAttr();
|
|
void RemoveBuffByEffectId(int buff_effect_id);
|
|
void ClearBuffList();
|
|
float GetBuffAttrAbs(int attr_id);
|
|
float GetBuffAttrRate(int attr_id);
|
|
void FillBuffList(::google::protobuf::RepeatedPtrField<::cs::MFBuff>* pb_buff_list);
|
|
void FillSkillList(::google::protobuf::RepeatedPtrField< cs::MFSkill >* pb_skill_list);
|
|
void TriggerBuff(Skill* skill, std::set<Creature*>& target_list, BuffTriggerType_e trigger_type);
|
|
Skill* GetSkill(int skill_id);
|
|
void AddSkill(int skill_id);
|
|
void ClearSkill();
|
|
void AddPassiveSkill(int skill_id);
|
|
void ClearPassiveSkill();
|
|
void UpdatePoisoning();
|
|
|
|
bool IsProperTarget(Creature* target);
|
|
bool IsEnemy(Creature* target);
|
|
virtual void SelectSkillTargets(Skill* skill,
|
|
const a8::Vec2& target_pos,
|
|
std::set<Creature*>& target_list);
|
|
virtual bool CanUseSkill(int skill_id);
|
|
void DoSkill(int skill_id,
|
|
int target_id,
|
|
const a8::Vec2& skill_dir,
|
|
float skill_distance,
|
|
const a8::Vec2& target_pos
|
|
);
|
|
void ResetSkill();
|
|
Skill* CurrentSkill();
|
|
MetaData::SkillPhase* GetCurrSkillPhase();
|
|
bool CanSee(const Creature* c) const;
|
|
virtual std::string GetName() { return "";};
|
|
virtual void SendDebugMsg(const std::string& debug_msg);
|
|
virtual void DropItems(Obstacle* obstacle) {};
|
|
bool IsPlayer() const;
|
|
bool IsAndroid() const;
|
|
bool IsHuman() const;
|
|
virtual void DecHP(float dec_hp, int killer_id, const std::string& killer_name, int weapon_id) {};
|
|
|
|
RaceType_e GetRace() { return race_; }
|
|
float GetAttrAbs(int attr_id);
|
|
float GetAttrRate(int attr_id);
|
|
|
|
void StartAction(ActionType_e action_type,
|
|
int action_duration,
|
|
int item_id,
|
|
int target_id);
|
|
void CancelAction();
|
|
void ResetAction();
|
|
int GetActionType() { return action_type; }
|
|
int GetActionTargetId() { return action_target_id; }
|
|
|
|
void TouchProperTargets(std::function<void (Creature*, bool&)> func);
|
|
CreatureWeakPtrChunk* GetWeakPtrChunk() { return &weak_ptr_chunk_; };
|
|
|
|
void Shot(a8::Vec2& target_dir, bool& shot_ok, float fly_distance);
|
|
|
|
void AutoLoadingBullet(bool manual = false);
|
|
int GetInventory(int slot_id);
|
|
void AddInventory(int slot_id, int num);
|
|
void DecInventory(int slot_id, int num);
|
|
std::array<int, IS_END>& GetInventoryData() { return inventory_; };
|
|
virtual void _UpdateMove(int speed) {};
|
|
|
|
void CheckSpecObject();
|
|
RoomObstacle* SummonObstacle(int id, const a8::Vec2& pos);
|
|
bool CollisonDetection();
|
|
void FillSkillCasterState(SkillCasterState* caster_state);
|
|
void RecoverSkillCasterState(SkillCasterState* caster_state);
|
|
CreatureWeakPtr AllocWeakPtr();
|
|
Weapon* AutoChgWeapon();
|
|
Weapon* ChooseNextWeapon(int curr_weapon_slot_id, int begin_slot_id, int end_slot_id);
|
|
Weapon* GetCurrWeapon() { return curr_weapon_; };
|
|
void SetCurrWeapon(Weapon* weapon);
|
|
|
|
private:
|
|
|
|
virtual void AddBuffPostProc(Creature* caster, Buff* buff);
|
|
virtual void OnBuffRemove(const Buff& buff);
|
|
virtual void DoSkillPreProc(int skill_id, int target_id, const a8::Vec2& target_pos);
|
|
virtual void DoSkillPostProc(bool used, int skill_id, int target_id, const a8::Vec2& target_pos);
|
|
|
|
void UpdateSkill();
|
|
void ProcSkillPhase(MetaData::SkillPhase* phase);
|
|
void ProcBuffEffect(Creature* caster, Buff* buff);
|
|
void TriggerOneObjectBuff(Skill* skill, Creature* target, BuffTriggerType_e trigger_type);
|
|
|
|
Skill* GetPassiveSkill(int skill_id);
|
|
void RemovePassiveSkill(int skill_id);
|
|
|
|
protected:
|
|
RaceType_e race_ = kHumanRace;
|
|
|
|
ActionType_e action_type = AT_None;
|
|
int action_duration = 0;
|
|
long long action_frameno = 0;
|
|
int action_item_id = 0;
|
|
int action_target_id = 0;
|
|
|
|
long long cell_flags_ = 0;
|
|
|
|
private:
|
|
Weapon* curr_weapon_ = nullptr;
|
|
CreatureWeakPtrChunk weak_ptr_chunk_;
|
|
std::array<float, kHAT_End> buff_attr_abs_ = {};
|
|
std::array<float, kHAT_End> buff_attr_rate_ = {};
|
|
std::array<Buff*, kBET_End> buff_effect_ = {};
|
|
std::list<Buff> buff_list_;
|
|
|
|
a8::Vec2 skill_dir_;
|
|
float skill_param1 = 0;
|
|
bool playing_skill = false;
|
|
size_t curr_skill_phase = 0;
|
|
Skill* curr_skill_ = nullptr;
|
|
int skill_target_id_ = 0;
|
|
a8::Vec2 skill_target_pos_;
|
|
float skill_distance_ = 0.0f;
|
|
std::map<int, Skill*> skill_hash_;
|
|
std::map<int, Skill*> passive_skill_hash_;
|
|
std::array<int, IS_END> inventory_ = {};
|
|
friend class Skill;
|
|
};
|
|
|
|
void InternalShot(Creature* sender,
|
|
MetaData::Equip* weapon_meta,
|
|
MetaData::EquipUpgrade* weapon_upgrade_meta,
|
|
MetaData::Equip* bullet_meta,
|
|
int weapon_lv,
|
|
int skill_id,
|
|
float fly_distance,
|
|
bool is_tank_skin);
|