78 lines
2.1 KiB
C++
78 lines
2.1 KiB
C++
#pragma once
|
|
|
|
#include "cs_proto.pb.h"
|
|
|
|
enum RoomState_e
|
|
{
|
|
RS_Inactive = 0,
|
|
RS_Waiting = 1,
|
|
RS_Moveing = 2
|
|
};
|
|
|
|
namespace MetaData
|
|
{
|
|
struct Map;
|
|
}
|
|
|
|
struct RoomFrameData
|
|
{
|
|
std::set<unsigned short> deleted_objects;
|
|
::google::protobuf::RepeatedPtrField<::cs::MFExplosion> explosions;
|
|
::google::protobuf::RepeatedPtrField<::cs::MFEmote> emotes;
|
|
::google::protobuf::RepeatedPtrField<::cs::MFBullet> bullets;
|
|
::google::protobuf::RepeatedPtrField<::cs::MFShot> shots;
|
|
};
|
|
|
|
class Entity;
|
|
class Bullet;
|
|
class Human;
|
|
class Player;
|
|
class Room
|
|
{
|
|
public:
|
|
long long room_uuid = 0;
|
|
MetaData::Map* map_meta = nullptr;
|
|
RoomFrameData frame_data;
|
|
long long frame_no = 0;
|
|
|
|
void Update(int delta_time);
|
|
bool IsFull();
|
|
int GetPlayerNum();
|
|
int AliveCount();
|
|
Player* GetPlayerByAccountId(const std::string& accountid);
|
|
Player* GetPlayerByUniId(unsigned short uniid);
|
|
Entity* GetEntityByUniId(unsigned short uniid);
|
|
void AddPlayer(Player* hum);
|
|
void AddBullet(Bullet* bullet);
|
|
unsigned short AllocUniid();
|
|
void ShuaAndroid();
|
|
void ShuaObstacle(Human* hum);
|
|
void ShuaBuilding(Human* hum);
|
|
bool RandomPos(Human* hum, float distance, Vector2D& out_pos);
|
|
Human* FindEnemy(Human* hum);
|
|
void CollisionDetection(Entity* sender, int detection_flags, std::vector<Entity*>& objects);
|
|
void AddDeletedObject(unsigned short obj_uniid);
|
|
void FillSMJoinedNotify(Player* self_hum, cs::SMJoinedNotify& msg);
|
|
void ResetFrameData();
|
|
void TouchPlayerList(a8::XParams param,
|
|
std::function<void (Player*, a8::XParams&)> func);
|
|
void BeAddedObject(Entity* entity);
|
|
void ProcDrop(Vector2D center, int drop_id);
|
|
|
|
private:
|
|
void ClearDeletedObjects();
|
|
void ProcAddedObjects();
|
|
|
|
public:
|
|
unsigned short current_uniid = 0;
|
|
RoomState_e state_ = RS_Inactive;
|
|
int elapsed_time_ = 0;
|
|
int alive_count_ = 0;
|
|
|
|
std::map<std::string, Player*> accountid_hash_;
|
|
std::map<unsigned short, Entity*> uniid_hash_;
|
|
std::map<unsigned short, Entity*> moveable_hash_;
|
|
std::map<unsigned short, Human*> human_hash_;
|
|
std::map<unsigned short, Entity*> be_added_hash_;
|
|
};
|