#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; 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; TankSkin tankskin; Driver driver; int lethal_weapon = 0; long long dead_frameno = 0; long long join_frameno = 0; long long status = 0; Weapon default_weapon; std::vector 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; Entity* last_collision_door = nullptr; PlayerStats stats; std::set* team_members = nullptr; std::set 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 weapon_configs; std::map tank_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 SetMeta(MetaData::Player* hum_meta); 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& old_grid_list, std::set& inc_grid_list, std::set& 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 AddObserver(Human* observer); void RemoveObserver(Human* observer); void SendUpdateMsg(); template 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 GetTankConfigLv(int tank_id); void SetTankInfo(int tank_id); const Tank& GetTank(); int TankId(); int TankLv(); int GetSkillLeftTime(); int GetSkillCd(); void TriggerBuff(MetaData::Skill* sender_skill_meta, std::set& 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& 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; a8::XTimerAttacher skill_xtimer_attacher_; bool leave_ = false; long long leave_frameno_ = 0; std::array inventory_ = {}; std::array volume_ = {}; std::set new_objects_; std::set part_objects_; std::set del_objects_; std::set out_objects_; std::vector shots_; std::vector emotes_; std::vector bullets_; std::vector smokes_; std::vector explosions_; std::vector chged_buffs_; std::vector revive_objs_; std::vector dead_objs_; std::set property_chged_humans_; std::set observers_; Human* follow_target_ = nullptr; bool follow_synced_active_player_ = false; MetaData::Player* meta_ = nullptr; MetaData::Skill* skill_meta_ = nullptr; MetaData::Tank* tank_meta_ = nullptr; MetaData::Driver* driver_meta_ = nullptr; private: CircleCollider* self_collider_ = nullptr; long long last_sync_gas_frameno_ = 0; std::list buff_list_; std::array buff_effect_ = {}; std::array buff_attr_abs_ = {}; std::array buff_attr_rate_ = {}; bool already_report_battle_ = false; bool sent_game_end_ = false; Tank tank_; xtimer_list* grass_hide_timer_list_ = nullptr; xtimer_list* leave_grass_timer_list_ = nullptr; friend class FrameMaker; friend class FrameEvent; };