230 lines
7.8 KiB
C++
230 lines
7.8 KiB
C++
#pragma once
|
|
|
|
#include <a8/xtimer.h>
|
|
|
|
#include "frameevent.h"
|
|
#include "framemaker.h"
|
|
#include "gridservice.h"
|
|
#include "mapservice.h"
|
|
|
|
namespace MetaData
|
|
{
|
|
struct Map;
|
|
struct Building;
|
|
struct AirLine;
|
|
struct MapTplThing;
|
|
struct MapThing;
|
|
}
|
|
|
|
namespace metatable
|
|
{
|
|
class DropObjJson;
|
|
}
|
|
|
|
struct xtimer_list;
|
|
class Entity;
|
|
class RoomEntity;
|
|
class MoveableEntity;
|
|
class Obstacle;
|
|
class RoomObstacle;
|
|
class Bullet;
|
|
class Human;
|
|
class Player;
|
|
class Building;
|
|
class AabbCollider;
|
|
class Android;
|
|
class Room
|
|
{
|
|
public:
|
|
FrameEvent frame_event;
|
|
FrameMaker frame_maker;
|
|
a8::XTimer xtimer;
|
|
a8::TimerAttacher timer_attacher;
|
|
GridService* grid_service = nullptr;
|
|
MapService* map_service = nullptr;
|
|
|
|
~Room();
|
|
void InitData(RoomInitInfo& init_info);
|
|
void Init();
|
|
void UnInit();
|
|
void Update(int delta_time);
|
|
|
|
inline long long GetFrameNo() { return frameno_; }
|
|
long long GetBattleStartFrameNo() { return battle_start_frameno_; }
|
|
bool IsGameOver() { return game_over_; }
|
|
const GasData& GetGasData() { return gas_data_; }
|
|
RoomType_e GetRoomType() { return room_type_; }
|
|
long long GetRoomUuid() { return room_uuid_; }
|
|
int GetRoomIdx() { return room_idx_; }
|
|
std::string GetMapTplName() { return map_tpl_name_; }
|
|
const MetaData::Map* GetMapMeta() { return map_meta_; }
|
|
bool IsWaitingStart() { return waiting_start_; }
|
|
|
|
int GetPlayerNum();
|
|
int AliveCount();
|
|
inline int RealAliveCount() { return alive_human_hash_.size(); }
|
|
Player* GetPlayerByAccountId(const std::string& accountid);
|
|
Player* GetPlayerByUniId(int uniid);
|
|
Entity* GetEntityByUniId(int uniid);
|
|
Human* GetFirstNewBie() { return first_newbie_; }
|
|
|
|
void AddPlayer(Player* hum);
|
|
Human* FindEnemy(Human* hum);
|
|
|
|
void RemoveObjectLater(RoomEntity* entity);
|
|
|
|
void FillSMJoinedNotify(Player* self_hum, cs::SMJoinedNotify& msg);
|
|
|
|
void TouchPlayerList(a8::XParams param,
|
|
std::function<void (Player*, a8::XParams&)> func);
|
|
void TouchHumanList(a8::XParams param,
|
|
std::function<bool (Human*, a8::XParams&)> func);
|
|
void TouchEntityList(a8::XParams param,
|
|
std::function<bool (Entity*, a8::XParams&)> func);
|
|
|
|
void ScatterDrop(a8::Vec2 center, int drop_id);
|
|
void DropItem(a8::Vec2 pos, int item_id, int item_count, int item_lv);
|
|
|
|
int CreateLoot(int equip_id, a8::Vec2 pos, int count, int equip_lv);
|
|
void CreateBullet(Human* hum, Weapon* weapon,
|
|
a8::Vec2 pos, a8::Vec2 dir, float fly_distance, bool is_tank_skin = false);
|
|
|
|
void OnHumanDie(Human* hum);
|
|
bool OverBorder(const a8::Vec2 pos, float radius);
|
|
Human* GetWatchWarTarget(Human* hum);
|
|
bool BattleStarted();
|
|
int GetAliveTeamNum();
|
|
std::set<Human*>* GetAliveTeam();
|
|
bool CanJoin(const std::string& accountid, RoomType_e self_roomm_type);
|
|
void OnPlayerOffline(Player* hum);
|
|
Entity* FindFirstCollisonEntity(const a8::Vec2& aabb_pos, AabbCollider& aabb_box);
|
|
void FindLocationWithAabb(Entity* target, const a8::Vec2& aabb_pos, AabbCollider* aabb_box,
|
|
float& new_x, float& new_y);
|
|
void FillSMUiUpdate(cs::SMUiUpdate& msg);
|
|
void NotifyUiUpdate();
|
|
void UpdateCarObject(int old_uniid, int new_uniid, a8::Vec2 pos);
|
|
void TakeOnCarObject(int car_uniid);
|
|
void TakeOffCarObject(int car_uniid, a8::Vec2 pos);
|
|
int CreateAndTakeonCar(int car_id, a8::Vec2 pos);
|
|
bool HaveMyTeam(const std::string& team_uuid);
|
|
ObstacleData* GetPermanentObstacleData(int entity_uniid);
|
|
long long GetGasInactiveTime();
|
|
void ShuaNewBieAndroid(Human* target);
|
|
void InitAirDrop();
|
|
void CheckPartObjects(Human* testa = nullptr, Human* testb = nullptr);
|
|
bool RuningInTimer();
|
|
|
|
private:
|
|
int AllocUniid();
|
|
void ShuaAndroid();
|
|
void ShowAndroid(Human* target, int num);
|
|
void CreateAndroid(int android_num);
|
|
void UpdateGas();
|
|
void UpdateGasInactive();
|
|
void UpdateGasWaiting();
|
|
void UpdateGasMoving();
|
|
bool GenSmallCircle(a8::Vec2 big_circle_pos, float big_circle_rad, float small_circle_rad,
|
|
a8::Vec2& out_pos);
|
|
void MatchTeam(Human* hum);
|
|
void CombineTeam();
|
|
void AirDrop(int appear_time, int box_id);
|
|
void AdjustAirDropPos(MetaData::MapThing* thing_meta, a8::Vec2& box_pos);
|
|
void ShuaPlane();
|
|
int NewTeam();
|
|
RoomObstacle* CreateObstacle(int id, float x, float y);
|
|
RoomObstacle* InternalCreateObstacle(int id, float x, float y,
|
|
std::function<void (Obstacle*)> on_precreate);
|
|
void AddObjectLater(RoomEntity* entity);
|
|
void OnGameOver();
|
|
void RandRemoveAndroid();
|
|
void NotifyWxVoip();
|
|
BornPoint* AllocBornPoint(Human* hum);
|
|
BornPoint* GetBornPoint(int point_uniid);
|
|
void CreateSpawnPoints();
|
|
void CreateLoots();
|
|
void CreateDropObjs();
|
|
void IncBornPointHumanNum(BornPoint* point, Human* hum);
|
|
void DecBornPointHumanNum(BornPoint* point, Human* hum);
|
|
void SecondRandPoint();
|
|
void NotifyGameStart();
|
|
void InitObstacleDatas();
|
|
void EnableHuman(Human* hum);
|
|
void DisableHuman(Human* hum);
|
|
void ShuaAndroidTimerFunc();
|
|
void DieAndroidTimerFunc();
|
|
void ProcShuaAndroid(int shua_time, int shua_num);
|
|
void ProcDieAndroid(int die_time, int die_num);
|
|
void CheckAutoDie(Human* hum, int autodie_time, int autodie_distance, int check_times);
|
|
bool HasPlayerInRound(const a8::Vec2& pos, float rad);
|
|
void ProcDisableHuman();
|
|
void OnHumanGridChg(Human* target);
|
|
void ShuaGridRound(Human* target);
|
|
void CheckAliveHuman(Human* hum, std::vector<Human*>& alive_humans);
|
|
a8::Vec2 GetDefaultBornPoint();
|
|
|
|
void AddToEntityHash(Entity* entity);
|
|
void AddToHumanHash(Human* hum);
|
|
void AddToAliveHumanHash(Human* hum);
|
|
void AddToMoveableHash(MoveableEntity* entity);
|
|
void AddToAccountHash(Player* hum);
|
|
void AddToLaterAddHash(RoomEntity* entity);
|
|
void AddToRemovedRobotHash(Human* hum);
|
|
void RemoveFromEntityHash(Entity* entity);
|
|
void RemoveFromMoveableHash(MoveableEntity* entity);
|
|
void RemoveFromHuamnHash(Human* hum);
|
|
void RemoveFromAliveHumanHash(Human* hum);
|
|
void RemoveFromLaterAddHash(RoomEntity* entity);
|
|
|
|
void AddPlayerPostProc(Player* hum);
|
|
void CombineTeamBornPoint();
|
|
void ForceSetBornPoint(Human* hum, BornPoint* born_point);
|
|
|
|
#ifdef DEBUG
|
|
void InitDebugInfo();
|
|
void UnInitDebugInfo();
|
|
#endif
|
|
|
|
private:
|
|
int room_idx_ = 0;
|
|
long long room_uuid_ = 0;
|
|
const MetaData::Map* map_meta_ = nullptr;
|
|
std::string map_tpl_name_;
|
|
RoomType_e room_type_ = RT_NewBrid;
|
|
const std::vector<MetaData::MapTplThing*>* spawn_points_ = nullptr;
|
|
const MetaData::MapTplThing* newbie_born_point_meta_ = nullptr;
|
|
const std::vector<MetaData::MapTplThing*>* loots_ = nullptr;
|
|
const std::vector<Building*>* buildings_ = nullptr;
|
|
Human* first_newbie_ = nullptr;
|
|
|
|
bool waiting_start_ = false;
|
|
GasData gas_data_;
|
|
long long frameno_ = 0;
|
|
long long battle_start_frameno_ = 0;
|
|
bool game_over_ = false;
|
|
long long game_over_frameno_ = 0;
|
|
int elapsed_time_ = 0;
|
|
int alive_count_ = 0;
|
|
MetaData::AirLine* airline_ = nullptr;
|
|
a8::XTimerAttacher xtimer_attacher_;
|
|
size_t airdrop_times_ = 0;
|
|
int newbie_born_point_uniid_ = 0;
|
|
|
|
int current_teamid_ = 0;
|
|
int current_uniid_ = FIXED_OBJECT_MAXID;
|
|
|
|
std::set<int> refreshed_robot_set_;
|
|
std::map<int, std::set<Human*>> team_hash_;
|
|
std::map<std::string, Player*> accountid_hash_;
|
|
std::map<int, MoveableEntity*> moveable_hash_;
|
|
std::map<int, Entity*> uniid_hash_;
|
|
std::map<int, RoomEntity*> later_add_hash_;
|
|
std::map<int, Human*> human_hash_;
|
|
std::map<int, Human*> alive_human_hash_;
|
|
std::map<int, BornPoint> born_point_hash_;
|
|
|
|
std::map<int, CarObject> car_hash_;
|
|
std::map<int, Human*> removed_robot_hash_;
|
|
|
|
std::vector<ObstacleData> obstacle_datas_;
|
|
};
|