倍镜ok
This commit is contained in:
parent
d442c60cf4
commit
ff1b987d33
@ -30,6 +30,7 @@ Human::Human()
|
||||
for (size_t i = 0; i < MAX_INVENTORY_NUM; ++i) {
|
||||
inventory.push_back(0);
|
||||
}
|
||||
inventory[12] = 1;
|
||||
}
|
||||
|
||||
Human::~Human()
|
||||
|
@ -50,6 +50,7 @@ class Human : public Entity
|
||||
std::vector<Weapon> weapons;
|
||||
Weapon* curr_weapon = nullptr;
|
||||
|
||||
int curr_scope_idx = 0;
|
||||
std::vector<int> inventory;
|
||||
|
||||
HumanFrameData frame_data;
|
||||
|
@ -84,6 +84,9 @@ void Player::Update(int delta_time)
|
||||
if (drop_weapon) {
|
||||
UpdateDropWeapon();
|
||||
}
|
||||
if (use_scope) {
|
||||
UpdateUseScope();
|
||||
}
|
||||
MakeUpdateMsg();
|
||||
SendNotifyMsg(*update_msg);
|
||||
{
|
||||
@ -142,6 +145,7 @@ void Player::UpdateSelectWeapon()
|
||||
Weapon* weapon = &weapons[selected_weapon_idx];
|
||||
if (weapon->weapon_id != 0) {
|
||||
curr_weapon = weapon;
|
||||
need_sync_active_player = true;
|
||||
for (auto& pair : room->human_hash_) {
|
||||
pair.second->new_objects.insert(this);
|
||||
}
|
||||
@ -360,6 +364,10 @@ void Player::_CMMove(f8::MsgHdr& hdr, const cs::CMMove& msg)
|
||||
drop_weapon = true;
|
||||
drop_weapon_idx = msg.drop_weapon();
|
||||
}
|
||||
if (msg.has_use_scope()) {
|
||||
use_scope = true;
|
||||
use_scope_idx = msg.use_scope();
|
||||
}
|
||||
}
|
||||
|
||||
void Player::UpdateDropWeapon()
|
||||
@ -430,7 +438,19 @@ void Player::UpdateDropWeapon()
|
||||
}
|
||||
}
|
||||
drop_weapon = false;
|
||||
drop_weapon_idx;
|
||||
drop_weapon_idx = 0;
|
||||
}
|
||||
|
||||
void Player::UpdateUseScope()
|
||||
{
|
||||
if (12 + use_scope_idx >= 12 && 12 + use_scope_idx < 16) {
|
||||
if (inventory[12 + use_scope_idx] > 0) {
|
||||
curr_scope_idx = use_scope_idx;
|
||||
need_sync_active_player = true;
|
||||
}
|
||||
}
|
||||
use_scope = false;
|
||||
use_scope_idx = 0;
|
||||
}
|
||||
|
||||
void Player::_CMEmote(f8::MsgHdr& hdr, const cs::CMEmote& msg)
|
||||
@ -463,6 +483,7 @@ void Player::FillMFActivePlayerData(cs::MFActivePlayerData* player_data)
|
||||
{
|
||||
player_data->set_has_action(false);
|
||||
player_data->set_cur_weapon_idx(curr_weapon->weapon_idx);
|
||||
player_data->set_cur_scope(curr_scope_idx);
|
||||
for (auto& weapon : weapons) {
|
||||
auto p = player_data->add_weapons();
|
||||
weapon.ToPB(p);
|
||||
|
@ -45,6 +45,9 @@ class Player : public Human
|
||||
bool drop_weapon = false;
|
||||
int drop_weapon_idx = 0;
|
||||
|
||||
bool use_scope = false;
|
||||
int use_scope_idx = 0;
|
||||
|
||||
bool need_sync_active_player = false;
|
||||
|
||||
::google::protobuf::RepeatedField< ::google::protobuf::int32 > interaction_objids;
|
||||
@ -63,6 +66,7 @@ class Player : public Human
|
||||
void UpdateShot();
|
||||
void UpdateSelectWeapon();
|
||||
void UpdateDropWeapon();
|
||||
void UpdateUseScope();
|
||||
void Shot();
|
||||
void ProcInteraction();
|
||||
void ObstacleInteraction(Obstacle* entity);
|
||||
|
@ -530,7 +530,7 @@ message CMMove
|
||||
optional bool portrait = 19; //zz
|
||||
|
||||
//use_item使用道具
|
||||
//use_scope视野
|
||||
optional int32 use_scope = 25; //使用倍镜 0-4
|
||||
|
||||
optional bool interaction = 9; //是否有交互
|
||||
repeated int32 interaction_objids = 23; //交互的对象id列表
|
||||
|
Loading…
x
Reference in New Issue
Block a user