277 lines
8.0 KiB
C++
277 lines
8.0 KiB
C++
#pragma once
|
|
|
|
#include "entity.h"
|
|
#include "cs_proto.pb.h"
|
|
#include "GGListener.h"
|
|
#include "buff.h"
|
|
|
|
namespace MetaData
|
|
{
|
|
struct Player;
|
|
struct Equip;
|
|
struct Dress;
|
|
struct Skill;
|
|
struct Tank;
|
|
struct SkillPhase;
|
|
struct Driver;
|
|
}
|
|
|
|
enum HumanStatus
|
|
{
|
|
HS_InGrass = 1,
|
|
HS_Assaulting = 2,
|
|
HS_End
|
|
};
|
|
|
|
struct xtimer_list;
|
|
class CircleCollider;
|
|
class AabbCollider;
|
|
class Obstacle;
|
|
class Human : public Entity
|
|
{
|
|
public:
|
|
int socket_handle = 0;
|
|
long ip_saddr = 0;
|
|
int team_id = 0;
|
|
std::string account_id;
|
|
std::string session_id;
|
|
std::string from_appid;
|
|
std::string team_uuid;
|
|
int account_registertime = 0;
|
|
MetaData::Player* meta = nullptr;
|
|
MetaData::Equip* helmet_meta = nullptr;
|
|
MetaData::Equip* chest_meta = nullptr;
|
|
MetaData::Tank* tank_meta = nullptr;
|
|
MetaData::Skill* skill_meta = nullptr;
|
|
MetaData::Driver* driver_meta = nullptr;
|
|
HumanAbility ability;
|
|
int born_point = 0;
|
|
int last_attacker_id = 0;
|
|
std::string last_attacker_name;
|
|
int last_attacker_weapon_id = 0;
|
|
|
|
a8::Vec2 move_dir;
|
|
a8::Vec2 attack_dir;
|
|
|
|
std::string name;
|
|
std::string avatar_url;
|
|
bool dead = false;
|
|
bool disconnected = false;
|
|
ActionType_e action_type = AT_None;
|
|
long long action_frameno = 0;
|
|
int action_duration = 0;
|
|
int action_item_id = 0;
|
|
int action_target_id = 0;
|
|
Skin tankskin;
|
|
Driver driver;
|
|
int backpack = 0;
|
|
int helmet = 0;
|
|
int chest = 0;
|
|
int vip = 0;
|
|
int sdmg = 0;
|
|
int lethal_weapon = 0;
|
|
long long dead_frameno = 0;
|
|
long long join_frameno = 0;
|
|
long long status = 0;
|
|
|
|
Weapon default_weapon;
|
|
std::vector<Weapon> weapons;
|
|
Weapon* curr_weapon = nullptr;
|
|
|
|
int curr_scope_idx = 0;
|
|
|
|
bool need_sync_team_data = false;
|
|
bool need_sync_teammate_data = false;
|
|
bool need_sync_active_player = false;
|
|
|
|
PlayerStats stats;
|
|
|
|
int pain_killer_frameno = 0;
|
|
int pain_killer_lastingtime = 0;
|
|
xtimer_list* pain_killer_timer = nullptr;
|
|
|
|
std::set<Human*>* team_members = nullptr;
|
|
std::set<Human*> kill_humans;
|
|
|
|
bool shot_start = false;
|
|
bool shot_hold = false;
|
|
int shot_target_id = 0;
|
|
int series_shot_frames = 0;
|
|
float fly_distance = 0.0f;
|
|
|
|
long long send_msg_times = 0;
|
|
|
|
std::map<int, int> weapon_configs;
|
|
std::map<int, int> skin_configs;
|
|
|
|
bool use_skill = false;
|
|
size_t curr_skill_phase = 0;
|
|
int skill_target_id = 0;
|
|
a8::Vec2 skill_dir;
|
|
a8::Vec2 skill_target_pos;
|
|
float skill_param1 = 0;
|
|
bool playing_skill = false;
|
|
|
|
Human();
|
|
virtual ~Human() override;
|
|
virtual void Initialize() override;
|
|
virtual float GetSpeed() override;
|
|
virtual float GetSpeed4();
|
|
virtual void FillMFObjectPart(cs::MFObjectPart* part_data) override;
|
|
virtual void FillMFObjectFull(cs::MFObjectFull* full_data) override;
|
|
virtual void GetAabbBox(AabbCollider& aabb_box);
|
|
void FillMFTeamData(cs::MFTeamData* team_data);
|
|
void Shot();
|
|
void DirectShot(MetaData::Equip* bullet_meta, int skill_id);
|
|
void RecalcSelfCollider();
|
|
bool IsCollisionInMapService();
|
|
void FindPath();
|
|
void FindPathInMapService();
|
|
float GetRadius();
|
|
float GetHP();
|
|
float GetMaxHP();
|
|
void UpdateSkill();
|
|
void SyncAroundPlayers();
|
|
void AutoLoadingBullet(bool manual = false);
|
|
void StartAction(ActionType_e action_type,
|
|
int action_duration,
|
|
int item_id,
|
|
int target_id);
|
|
void CancelAction();
|
|
void ResetAction();
|
|
void BeKill(int killer_id, const std::string& killer_name, int weapon_id);
|
|
void DecHP(float dec_hp, int killer_id, const std::string& killer_name, int weapon_id);
|
|
void AddToNewObjects(Entity* entity);
|
|
void AddToPartObjects(Entity* entity);
|
|
void RemovePartObjects(Entity* entity);
|
|
void RemoveObjects(Entity* entity);
|
|
void AddOutObjects(Entity* entity);
|
|
void RemoveOutObjects(Entity* entity);
|
|
bool HasLiveTeammate();
|
|
void DoSkill();
|
|
void FindLocation();
|
|
void RefreshView();
|
|
void OnGridListChange(std::set<GridCell*>& old_grid_list,
|
|
std::set<GridCell*>& inc_grid_list,
|
|
std::set<GridCell*>& dec_grid_list
|
|
);
|
|
void FillMFActivePlayerData(cs::MFActivePlayerData* player_data);
|
|
void FillMFGasData(cs::MFGasData* gas_data);
|
|
bool CanSee(const Human* hum) const;
|
|
void RecalcVolume();
|
|
int GetInventory(int slot_id);
|
|
void AddInventory(int slot_id, int num);
|
|
void DecInventory(int slot_id, int num);
|
|
int GetVolume(int slot_id);
|
|
void RecoverHp(int inc_hp);
|
|
void SummonHero();
|
|
void AddObserver(Human* observer);
|
|
void RemoveObserver(Human* observer);
|
|
void SendUpdateMsg();
|
|
template <typename T>
|
|
void SendNotifyMsg(T& msg)
|
|
{
|
|
GGListener::Instance()->SendToClient(socket_handle, 0, msg);
|
|
}
|
|
void FollowTarget(Human* target);
|
|
void SendDebugMsg(const std::string& debug_msg);
|
|
void SendRollMsg(const std::string& roll_msg);
|
|
void UpdateAction();
|
|
void DirectReload();
|
|
void SendUIUpdate();
|
|
void SendWxVoip();
|
|
int GetWeaponConfigLv(int weapon_id);
|
|
int GetSkinConfigLv(int skin_id);
|
|
void SetSkinInfo(int skin_id);
|
|
const Skin& GetTank();
|
|
int TankId();
|
|
int TankLv();
|
|
int GetSkillLeftTime();
|
|
int GetSkillCd();
|
|
void TriggerBuff(MetaData::Skill* sender_skill_meta,
|
|
std::set<Entity*>& target_list, BuffTriggerType_e trigger_type);
|
|
void AddBuff(MetaData::Buff* buff_meta);
|
|
void RemoveBuffById(int buff_id);
|
|
void RemoveBuffByEffectId(int buff_effect_id);
|
|
bool HasBuffEffect(int buff_effect_id);
|
|
Buff* GetBuffByEffectId(int effect_id);
|
|
void RecalcBuffAttr();
|
|
void ProcBuffEffect(Buff* buff);
|
|
void OnAttack();
|
|
void OnHit();
|
|
void OnSkillHit(MetaData::Skill* skill_meta);
|
|
void OnEnterGrass();
|
|
void OnLeaveGrass();
|
|
void CheckGrass();
|
|
void GrassTempShow();
|
|
float* GetAbilityById(int attr_id);
|
|
void RecalcBaseAttr();
|
|
|
|
protected:
|
|
void _UpdateMove(int speed);
|
|
void _UpdateAssaultMove();
|
|
void PullHuman(const a8::Vec2& pull_dir, float distance);
|
|
|
|
private:
|
|
void ClearFrameData();
|
|
void DeadDrop();
|
|
void Revive();
|
|
void SelectSkillTargets(const a8::Vec2& target_pos, std::set<Entity*>& target_list);
|
|
Buff* GetBuffById(int buff_id);
|
|
void ProcSkillPhase(MetaData::SkillPhase* phase);
|
|
void InternalShot(MetaData::Equip* bullet_meta, int skill_id, size_t offset_idx);
|
|
|
|
protected:
|
|
long long last_shot_frameno_ = 0;
|
|
long long last_use_skill_frameno_ = 0;
|
|
long long hide_frameno_ = 0;
|
|
long long accelerate_frameno_ = 0;
|
|
long long damageadd_frameno_ = 0;
|
|
long long defadd_frameno_ = 0;
|
|
long long recover_hp_frameno_ = 0;
|
|
long long reflect_damage_frameno_ = 0;
|
|
long long summon_hero_frameno_ = 0;
|
|
a8::XTimerAttacher skill_xtimer_attacher_;
|
|
bool leave_ = false;
|
|
long long leave_frameno_ = 0;
|
|
|
|
std::array<int, IS_END - 1> inventory_ = {};
|
|
std::array<int, IS_END> volume_ = {};
|
|
std::set<Entity*> new_objects;
|
|
std::set<Entity*> part_objects;
|
|
std::set<int> del_objects;
|
|
std::set<int> out_objects;
|
|
std::vector<int> shots_;
|
|
std::vector<int> emotes_;
|
|
std::vector<int> bullets_;
|
|
std::vector<int> smokes_;
|
|
std::vector<int> explosions_;
|
|
std::vector<int> chged_buffs_;
|
|
std::vector<int> revive_objs_;
|
|
std::vector<int> dead_objs_;
|
|
std::set<Human*> property_chged_humans_;
|
|
std::set<Human*> observers_;
|
|
Human* follow_target_ = nullptr;
|
|
bool follow_synced_active_player = false;
|
|
|
|
private:
|
|
CircleCollider* self_collider_ = nullptr;
|
|
long long last_sync_gas_frameno = 0;
|
|
std::list<Buff> buff_list_;
|
|
std::array<Buff*, BET_End> buff_effect_ = {};
|
|
|
|
std::array<float, HAT_End> buff_attr_abs_ = {};
|
|
std::array<float, HAT_End> buff_attr_rate_ = {};
|
|
|
|
bool already_report_battle_ = false;
|
|
bool sent_game_end_ = false;
|
|
|
|
Skin tank;
|
|
|
|
xtimer_list* grass_hide_timer_list_ = nullptr;
|
|
xtimer_list* leave_grass_timer_list_ = nullptr;
|
|
|
|
friend class FrameMaker;
|
|
friend class FrameEvent;
|
|
};
|