添加表情
This commit is contained in:
parent
dbf0d5e8f8
commit
1faa08e1c0
@ -7,7 +7,7 @@ struct RoomFrameData
|
||||
std::set<unsigned short> deleted_objects;
|
||||
std::map<long long, ::google::protobuf::RepeatedPtrField<::cs::MFExplosion>> explosions_hash;
|
||||
std::map<long long, ::google::protobuf::RepeatedPtrField<::cs::MFSmoke>> smokes_hash;
|
||||
::google::protobuf::RepeatedPtrField<::cs::MFEmote> emotes;
|
||||
std::map<long long, ::google::protobuf::RepeatedPtrField<::cs::MFEmote>> emotes_hash;
|
||||
::google::protobuf::RepeatedPtrField<::cs::MFBullet> bullets;
|
||||
::google::protobuf::RepeatedPtrField<::cs::MFShot> shots;
|
||||
};
|
||||
|
@ -75,6 +75,9 @@ void Player::Update(int delta_time)
|
||||
if (spectate) {
|
||||
UpdateSpectate();
|
||||
}
|
||||
if (emote) {
|
||||
UpdateEmote();
|
||||
}
|
||||
MakeUpdateMsg();
|
||||
SendNotifyMsg(*update_msg);
|
||||
if (send_gameover) {
|
||||
@ -267,6 +270,26 @@ void Player::UpdateGameOver()
|
||||
send_gameover = false;
|
||||
}
|
||||
|
||||
void Player::UpdateEmote()
|
||||
{
|
||||
::google::protobuf::RepeatedPtrField<::cs::MFEmote>* emotes = nullptr;
|
||||
{
|
||||
auto itr = room->frame_data.emotes_hash.find(room->frame_no);
|
||||
if (itr == room->frame_data.emotes_hash.end()) {
|
||||
room->frame_data.emotes_hash[room->frame_no] = ::google::protobuf::RepeatedPtrField<::cs::MFEmote>();
|
||||
itr = room->frame_data.emotes_hash.find(room->frame_no);
|
||||
}
|
||||
emotes = &itr->second;
|
||||
}
|
||||
|
||||
cs::MFEmote* emote = emotes->Add();
|
||||
emote->set_emote_id(emote_id);
|
||||
emote->set_player_id(entity_uniid);
|
||||
|
||||
emote = false;
|
||||
emote_id = 0;
|
||||
}
|
||||
|
||||
void Player::Shot()
|
||||
{
|
||||
if (!curr_weapon->meta) {
|
||||
@ -599,6 +622,10 @@ void Player::_CMMove(f8::MsgHdr& hdr, const cs::CMMove& msg)
|
||||
if (msg.has_spectate()) {
|
||||
spectate = true;
|
||||
}
|
||||
if (msg.has_emote()) {
|
||||
emote = true;
|
||||
emote_id = msg.emote();
|
||||
}
|
||||
}
|
||||
|
||||
void Player::UpdateDropWeapon()
|
||||
@ -788,6 +815,13 @@ void Player::MakeUpdateMsg()
|
||||
}
|
||||
}
|
||||
}
|
||||
for (auto& pair : room->frame_data.emotes_hash) {
|
||||
if (pair.first <= room->frame_no) {
|
||||
for (auto& itr : pair.second) {
|
||||
*update_msg->add_emotes() = itr;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (updated_times == 0) {
|
||||
room->FetchBuilding(this);
|
||||
|
@ -55,6 +55,9 @@ class Player : public Human
|
||||
|
||||
bool spectate = false;
|
||||
|
||||
bool emote = false;
|
||||
int emote_id = 0;
|
||||
|
||||
::google::protobuf::RepeatedField< ::google::protobuf::int32 > interaction_objids;
|
||||
|
||||
template <typename T>
|
||||
@ -78,6 +81,7 @@ class Player : public Human
|
||||
void UpdateUseItemIdx();
|
||||
void UpdateSpectate();
|
||||
void UpdateGameOver();
|
||||
void UpdateEmote();
|
||||
void Shot();
|
||||
void ProcInteraction();
|
||||
void ObstacleInteraction(Obstacle* entity);
|
||||
|
@ -1,5 +1,7 @@
|
||||
#include "precompile.h"
|
||||
|
||||
#include <a8/timer.h>
|
||||
|
||||
#include "playermgr.h"
|
||||
#include "player.h"
|
||||
#include "cs_proto.pb.h"
|
||||
@ -20,6 +22,16 @@ const int ANDROID_NUM = 10;
|
||||
void Room::Initialize()
|
||||
{
|
||||
ShuaAndroid();
|
||||
#if 0
|
||||
a8::Timer::Instance()->AddRepeatTimer(
|
||||
1000 * 5,
|
||||
a8::XParams(),
|
||||
[] (const a8::XParams& param)
|
||||
{
|
||||
|
||||
}
|
||||
);
|
||||
#endif
|
||||
}
|
||||
|
||||
void Room::Update(int delta_time)
|
||||
@ -60,6 +72,17 @@ void Room::Update(int delta_time)
|
||||
frame_data.smokes_hash.erase(id);
|
||||
}
|
||||
}
|
||||
{
|
||||
std::vector<long long> del_ids;
|
||||
for (auto& pair : frame_data.emotes_hash) {
|
||||
if (pair.first < frame_no) {
|
||||
del_ids.push_back(pair.first);
|
||||
}
|
||||
}
|
||||
for (long long id : del_ids) {
|
||||
frame_data.emotes_hash.erase(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
++frame_no;
|
||||
@ -256,11 +279,11 @@ void Room::ResetFrameData()
|
||||
{
|
||||
frame_data.explosions_hash.clear();
|
||||
frame_data.smokes_hash.clear();
|
||||
frame_data.emotes_hash.Clear();
|
||||
}
|
||||
#endif
|
||||
frame_data.bullets.Clear();
|
||||
frame_data.shots.Clear();
|
||||
frame_data.emotes.Clear();
|
||||
}
|
||||
|
||||
void Room::ScatterDrop(Vector2D center, int drop_id)
|
||||
@ -684,3 +707,8 @@ bool Room::GenSmallCircle(Vector2D big_circle_pos, float big_circle_rad, float s
|
||||
out_pos = big_circle_pos + dir * rad;
|
||||
return true;
|
||||
}
|
||||
|
||||
void Room::OutputDebugLog()
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -69,6 +69,7 @@ private:
|
||||
void UpdateGas();
|
||||
bool GenSmallCircle(Vector2D big_circle_pos, float big_circle_rad, float small_circle_rad,
|
||||
Vector2D& out_pos);
|
||||
void OutputDebugLog();
|
||||
|
||||
private:
|
||||
a8::TimerAttacher timer_attacher_;
|
||||
|
@ -462,10 +462,8 @@ message MFSmoke
|
||||
//表情
|
||||
message MFEmote
|
||||
{
|
||||
optional int32 type = 1;
|
||||
optional int32 is_ping = 2;
|
||||
optional int32 emote_id = 1; //表情id
|
||||
optional int32 player_id = 3; //玩家id
|
||||
optional MFVector2D pos = 4; //位置
|
||||
optional string msg = 5;
|
||||
}
|
||||
|
||||
@ -545,6 +543,8 @@ message CMMove
|
||||
repeated int32 interaction_objids = 23; //交互的对象id列表
|
||||
|
||||
optional bool spectate = 30; //自杀
|
||||
|
||||
optional int32 emote = 31; //表情id
|
||||
}
|
||||
|
||||
//丢弃道具
|
||||
|
Loading…
x
Reference in New Issue
Block a user