1
This commit is contained in:
parent
5f5118905e
commit
c25560e035
@ -1154,3 +1154,41 @@ void Human::SummonHero()
|
|||||||
BroadcastFullState();
|
BroadcastFullState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Human::AddObserver(Human* observer)
|
||||||
|
{
|
||||||
|
observers_.insert(observer);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Human::RemoveObserver(Human* observer)
|
||||||
|
{
|
||||||
|
observers_.erase(observer);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Human::SendUpdateMsg()
|
||||||
|
{
|
||||||
|
if (!follow_) {
|
||||||
|
cs::SMUpdate* msg = room->frame_maker.MakeUpdateMsg(this);
|
||||||
|
if (msg) {
|
||||||
|
SendNotifyMsg(*msg);
|
||||||
|
delete msg;
|
||||||
|
msg = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (send_gameover) {
|
||||||
|
UpdateGameOver();
|
||||||
|
}
|
||||||
|
{
|
||||||
|
if (!new_objects.empty()) {
|
||||||
|
new_objects.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Human::UpdateGameOver()
|
||||||
|
{
|
||||||
|
cs::SMGameOver msg;
|
||||||
|
FillSMGameOver(msg);
|
||||||
|
SendNotifyMsg(msg);
|
||||||
|
send_gameover = false;
|
||||||
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include "entity.h"
|
#include "entity.h"
|
||||||
#include "cs_proto.pb.h"
|
#include "cs_proto.pb.h"
|
||||||
|
#include "GGListener.h"
|
||||||
|
|
||||||
namespace MetaData
|
namespace MetaData
|
||||||
{
|
{
|
||||||
@ -32,6 +33,7 @@ class Obstacle;
|
|||||||
class Human : public Entity
|
class Human : public Entity
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
int socket_handle = 0;
|
||||||
int team_id = 0;
|
int team_id = 0;
|
||||||
std::string account_id;
|
std::string account_id;
|
||||||
std::string team_uuid;
|
std::string team_uuid;
|
||||||
@ -152,6 +154,15 @@ class Human : public Entity
|
|||||||
void RecoverHp(int inc_hp);
|
void RecoverHp(int inc_hp);
|
||||||
void FillBodyState(::google::protobuf::RepeatedPtrField<::cs::MFBodyState>* states);
|
void FillBodyState(::google::protobuf::RepeatedPtrField<::cs::MFBodyState>* states);
|
||||||
void SummonHero();
|
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 UpdateGameOver();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
long long last_shot_frameno_ = 0;
|
long long last_shot_frameno_ = 0;
|
||||||
@ -175,7 +186,8 @@ protected:
|
|||||||
std::vector<int> bullets_;
|
std::vector<int> bullets_;
|
||||||
std::vector<int> smokes_;
|
std::vector<int> smokes_;
|
||||||
std::vector<int> explosions_;
|
std::vector<int> explosions_;
|
||||||
std::list<Human*> observers_;
|
std::set<Human*> observers_;
|
||||||
|
Human* follow_ = nullptr;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CircleCollider* self_collider_ = nullptr;
|
CircleCollider* self_collider_ = nullptr;
|
||||||
|
@ -378,14 +378,6 @@ void Player::UpdateSpectate()
|
|||||||
spectate = false;
|
spectate = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::UpdateGameOver()
|
|
||||||
{
|
|
||||||
cs::SMGameOver msg;
|
|
||||||
FillSMGameOver(msg);
|
|
||||||
SendNotifyMsg(msg);
|
|
||||||
send_gameover = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Player::UpdateEmote()
|
void Player::UpdateEmote()
|
||||||
{
|
{
|
||||||
if (a8::HasBitFlag(status, HS_Fly)) {
|
if (a8::HasBitFlag(status, HS_Fly)) {
|
||||||
@ -768,25 +760,6 @@ void Player::HumanInteraction(Human* hum)
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::SendUpdateMsg()
|
|
||||||
{
|
|
||||||
cs::SMUpdate* msg = room->frame_maker.MakeUpdateMsg(this);
|
|
||||||
if (msg) {
|
|
||||||
SendNotifyMsg(*msg);
|
|
||||||
delete msg;
|
|
||||||
msg = nullptr;
|
|
||||||
}
|
|
||||||
if (send_gameover) {
|
|
||||||
UpdateGameOver();
|
|
||||||
}
|
|
||||||
{
|
|
||||||
if (!new_objects.empty()) {
|
|
||||||
new_objects.clear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
++send_update_msg_times;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Player::_CMMove(f8::MsgHdr& hdr, const cs::CMMove& msg)
|
void Player::_CMMove(f8::MsgHdr& hdr, const cs::CMMove& msg)
|
||||||
{
|
{
|
||||||
bool has_move_dir = msg.has_move_dir();
|
bool has_move_dir = msg.has_move_dir();
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "human.h"
|
#include "human.h"
|
||||||
#include "GGListener.h"
|
|
||||||
|
|
||||||
namespace cs
|
namespace cs
|
||||||
{
|
{
|
||||||
@ -22,7 +21,6 @@ class Player : public Human
|
|||||||
enum { HID = HID_Player };
|
enum { HID = HID_Player };
|
||||||
|
|
||||||
public:
|
public:
|
||||||
int socket_handle = 0;
|
|
||||||
int team_mode = 0;
|
int team_mode = 0;
|
||||||
int player_count = 0;
|
int player_count = 0;
|
||||||
bool auto_fill = false;
|
bool auto_fill = false;
|
||||||
@ -64,12 +62,6 @@ class Player : public Human
|
|||||||
|
|
||||||
::google::protobuf::RepeatedField< ::google::protobuf::int32 > interaction_objids;
|
::google::protobuf::RepeatedField< ::google::protobuf::int32 > interaction_objids;
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
void SendNotifyMsg(T& msg)
|
|
||||||
{
|
|
||||||
GGListener::Instance()->SendToClient(socket_handle, 0, msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
Player();
|
Player();
|
||||||
virtual ~Player() override;
|
virtual ~Player() override;
|
||||||
virtual void Initialize() override;
|
virtual void Initialize() override;
|
||||||
@ -84,7 +76,6 @@ class Player : public Human
|
|||||||
void UpdateCancelAction();
|
void UpdateCancelAction();
|
||||||
void UpdateUseItemIdx();
|
void UpdateUseItemIdx();
|
||||||
void UpdateSpectate();
|
void UpdateSpectate();
|
||||||
void UpdateGameOver();
|
|
||||||
void UpdateEmote();
|
void UpdateEmote();
|
||||||
void UpdateJump();
|
void UpdateJump();
|
||||||
void UpdateUseSkill();
|
void UpdateUseSkill();
|
||||||
@ -93,11 +84,9 @@ class Player : public Human
|
|||||||
void ObstacleInteraction(Obstacle* entity);
|
void ObstacleInteraction(Obstacle* entity);
|
||||||
void LootInteraction(Loot* entity);
|
void LootInteraction(Loot* entity);
|
||||||
void HumanInteraction(Human* hum);
|
void HumanInteraction(Human* hum);
|
||||||
void SendUpdateMsg();
|
|
||||||
|
|
||||||
void _CMMove(f8::MsgHdr& hdr, const cs::CMMove& msg);
|
void _CMMove(f8::MsgHdr& hdr, const cs::CMMove& msg);
|
||||||
void _CMEmote(f8::MsgHdr& hdr, const cs::CMEmote& msg);
|
void _CMEmote(f8::MsgHdr& hdr, const cs::CMEmote& msg);
|
||||||
void _CMVoice(f8::MsgHdr& hdr, const cs::CMVoice& msg);
|
void _CMVoice(f8::MsgHdr& hdr, const cs::CMVoice& msg);
|
||||||
private:
|
|
||||||
int send_update_msg_times = 0;
|
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user