140 lines
3.9 KiB
C++

#pragma once
#include "human.h"
namespace cs
{
class CMReconnect;
class CMMove;
class CMDropItem;
class CMEmote;
class CMVoice;
class MFActivePlayerData;
class MFGasData;
class MFPair;
}
class Room;
class Loot;
class Obstacle;
class Player : public Human
{
public:
enum { HID = HID_Player };
public:
int team_mode = 0;
bool use_touch = false;
long long create_tick = 0;
int last_seq_id = 0;
bool moving = false;
int moved_frames = 0;
bool select_weapon = false;
size_t selected_weapon_idx = 0;
bool drop_weapon = false;
size_t drop_weapon_idx = 0;
bool cancel_action = false;
bool use_item = false;
int use_item_idx = 0;
bool has_use_item_id = false;
int use_item_id = 0;
bool use_scope = false;
int use_scope_idx = 0;
bool reload = false;
bool spectate = false;
bool emote = false;
int emote_id = 0;
bool jump = false;
bool use_skill = false;
int use_skill_id = 0;
int skill_target_id = 0;
a8::Vec2 skill_dir;
float skill_distance = 0.0f;
bool get_down = false;
int get_on = 0;
int switch_seat = 0;
::google::protobuf::RepeatedField< ::google::protobuf::int32 > interaction_objids;
virtual ~Player() override;
virtual void Initialize() override;
virtual void Update(int delta_time) override;
void UpdateMove();
void UpdateShot();
void UpdateSelectWeapon();
void UpdateDropWeapon();
void UpdateUseScope();
void UpdateReload();
void UpdateCancelAction();
void UpdateUseItemIdx();
void UpdateUseItemId();
void UpdateSpectate();
void UpdateEmote();
void UpdateJump();
void UpdateGetDown();
void UpdateGetOn();
void UpdateSwitchSeat();
void UpdateUseSkill();
void UpdateAiming();
void Shot();
void ProcInteraction();
void ObstacleInteraction(Obstacle* entity);
void LootInteraction(Loot* entity);
void HumanInteraction(Human* hum);
void ProcPrepareItems(const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >&
prepare_items);
void ProcPrepareItems2(const ::google::protobuf::RepeatedPtrField< cs::MFPair >&
prepare_items);
void ProcPreSettlementInfo(const std::string& pre_settlement_info);
void ProcSkillList(const ::google::protobuf::RepeatedPtrField< cs::MFPair >&
skill_list);
void PushJoinRoomMsg();
void _CMReconnect(f8::MsgHdr& hdr, const cs::CMReconnect& msg);
void _CMMove(f8::MsgHdr& hdr, const cs::CMMove& msg);
void _CMExecCommand(f8::MsgHdr& hdr, const cs::CMExecCommand& msg);
void _CMEmote(f8::MsgHdr& hdr, const cs::CMEmote& msg);
void _CMVoice(f8::MsgHdr& hdr, const cs::CMVoice& msg);
void _CMGameOver(f8::MsgHdr& hdr, const cs::CMGameOver& msg);
void _CMWatchWar(f8::MsgHdr& hdr, const cs::CMWatchWar& msg);
void _CMLeave(f8::MsgHdr& hdr, const cs::CMLeave& msg);
void _CMRevive(f8::MsgHdr& hdr, const cs::CMRevive& msg);
void _CMCancelRevive(f8::MsgHdr& hdr, const cs::CMCancelRevive& msg);
void _CMAdStart(f8::MsgHdr& hdr, const cs::CMAdStart& msg);
void _CMAdCancel(f8::MsgHdr& hdr, const cs::CMAdCancel& msg);
void _CMAdEnd(f8::MsgHdr& hdr, const cs::CMAdEnd& msg);
void _CMGetBoxInfo(f8::MsgHdr& hdr, const cs::CMGetBoxInfo& msg);
void _CMOpenBox(f8::MsgHdr& hdr, const cs::CMOpenBox& msg);
virtual void SetAttackDir(const a8::Vec2& attack_dir) override;
protected:
Player();
private:
void InternalAdCancel();
void InternalAdOk();
void InternalUpdate(int delta_time);
std::vector<std::tuple<int, int, int>>* GetBox(int box_id);
void CheckShotHoldState(Weapon* weapon);
private:
std::map<int, std::vector<std::tuple<int, int, int>>> box_hash_;
std::set<int> receved_box_hash_;
long long last_cmmove_frameno_ = 0;
friend class EntityFactory;
};