325 lines
12 KiB
C++
325 lines
12 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;
|
|
struct Player;
|
|
}
|
|
|
|
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 Car;
|
|
class Hero;
|
|
class RefreshRule;
|
|
class Room
|
|
{
|
|
public:
|
|
FrameEvent frame_event;
|
|
FrameMaker frame_maker;
|
|
a8::XTimer xtimer;
|
|
Plane plane;
|
|
a8::TimerAttacher timer_attacher;
|
|
GridService* grid_service = nullptr;
|
|
MapService* map_service = nullptr;
|
|
bool debug_trace = false;
|
|
bool added_to_over_room = false;
|
|
a8::Vec2 last_player_jump_pos;
|
|
|
|
~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_; }
|
|
bool IsGameTimeOut() { return game_timeout_; }
|
|
const GasData& GetGasData() { return gas_data_; }
|
|
RoomType_e GetRoomType() { return room_type_; }
|
|
RoomMode_e GetRoomMode() { return room_mode_; }
|
|
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_; }
|
|
#if 1
|
|
bool IsWaitingStart() { return false; }
|
|
#else
|
|
bool IsWaitingStart() { return waiting_start_; }
|
|
#endif
|
|
|
|
int GetPlayerNum();
|
|
int AliveCount();
|
|
long long AliveCountChgFrameNo() { return alive_count_chged_frameno_; };
|
|
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_; }
|
|
int GetRealPlayerNum() { return accountid_hash_.size();}
|
|
|
|
Player* NewPlayer();
|
|
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);
|
|
void DropItemEx(a8::Vec2 born_pos, a8::Vec2 pos, int item_id, int item_count, int item_lv, bool show_anim);
|
|
|
|
int CreateLoot(int equip_id, a8::Vec2 pos, int count, int equip_lv);
|
|
int CreateLootEx(int equip_id, a8::Vec2 born_pos, a8::Vec2 pos, int count, int equip_lv, bool show_anim);
|
|
void CreateBullet(Creature* sender,
|
|
MetaData::Equip* weapon_meta,
|
|
MetaData::EquipUpgrade* weapon_upgrade_meta,
|
|
MetaData::Equip* bullet_meta,
|
|
a8::Vec2 pos,
|
|
a8::Vec2 dir,
|
|
float fly_distance,
|
|
bool is_tank_skin = false);
|
|
Car* CreateCar(Human* driver,
|
|
int car_uniid,
|
|
MetaData::Equip* meta,
|
|
const a8::Vec2& pos);
|
|
Hero* CreateHero(Creature* master,
|
|
MetaData::Player* meta,
|
|
const a8::Vec2& pos,
|
|
const a8::Vec2& dir,
|
|
int team_id);
|
|
|
|
void OnHumanDie(Human* hum);
|
|
void OnHumanRevive(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,
|
|
RoomMode_e self_room_mode,
|
|
int self_proto_version,
|
|
int self_channel,
|
|
int init_map_id);
|
|
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 obstacle_uniid);
|
|
long long GetGasInactiveTime();
|
|
void ShuaGuideAndroid(Human* target);
|
|
void InitAirDrop();
|
|
void CheckPartObjects(Human* testa = nullptr, Human* testb = nullptr);
|
|
bool RuningInTimer();
|
|
Human* GetOneCanEnableAndroid();
|
|
void GetCanEnableAndroids(std::vector<Human*>& humans, size_t num);
|
|
void InstallCheckAutoDieTimer(Human* hum);
|
|
Player* GetOneAlivePlayer();
|
|
void GetAlivePlayers(std::vector<Player*>& humans, size_t num);
|
|
int GetCanShuaNum(int shua_num);
|
|
void AdjustPosInnerMap(a8::Vec2& pos, float radius);
|
|
bool IsMiniRoom();
|
|
void FillObjectPositions(Human* hum, cs::SMUpdate& msg);
|
|
void RemoveRescue(Human* hum);
|
|
void NotifyCountdown(const std::string& msg, int time);
|
|
void NotifySysPiao(const std::string& msg, int color, int duration);
|
|
void OnZombieAppear(Human* hum);
|
|
int GetAliveCountByRace(RaceType_e race);
|
|
int GetOnlinePlayerNum();
|
|
RoomObstacle* CreateObstacle(int id, float x, float y);
|
|
int AllocUniid();
|
|
|
|
private:
|
|
void ShuaAndroid();
|
|
void ShowAndroid(Human* target, int num);
|
|
void CreateAndroid(int android_num);
|
|
void UpdateGas();
|
|
void UpdateGasInactive();
|
|
void UpdateGasWaiting();
|
|
void UpdateGasMoving();
|
|
void UpdateGasJump();
|
|
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, int airdrop_id);
|
|
void AdjustAirDropPos(MetaData::MapThing* thing_meta, a8::Vec2& box_pos);
|
|
void ShuaPlane();
|
|
int NewTeam();
|
|
RoomObstacle* InternalCreateObstacle(int id, float x, float y,
|
|
std::function<void (Obstacle*)> on_precreate);
|
|
void AddObjectLater(RoomEntity* entity);
|
|
void OnGameOver();
|
|
void RandRemoveAndroid();
|
|
void NotifyWxVoip();
|
|
void BattleReport();
|
|
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 GetAliveHumans(std::vector<Human*>& alive_humans, size_t num, Human* exclude_hum);
|
|
void CheckAliveHuman(Human* hum, std::vector<Human*>& alive_humans);
|
|
void GetAliveHumansExcludeLastHuman(std::vector<Human*>& alive_humans, size_t num);
|
|
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);
|
|
BornPoint* ForceTakeBornPoint(Human* hum, BornPoint* reserve_born_point);
|
|
void NewBieRoomStart();
|
|
void ZombieModeStart();
|
|
void CreateLevel0RoomSpecThings();
|
|
bool CanAddToScene(Human* hum);
|
|
void SyncFrameData();
|
|
void CheckShowHand();
|
|
void ShowHand();
|
|
void ShuaLastGas();
|
|
size_t GetRoomMaxPlayerNum();
|
|
void InitAndroidAI();
|
|
|
|
#ifdef DEBUG
|
|
void InitDebugInfo();
|
|
void UnInitDebugInfo();
|
|
#endif
|
|
|
|
private:
|
|
int room_idx_ = 0;
|
|
RoomMode_e room_mode_ = kChiJiMode;
|
|
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*>* mini_room_spawn_points_ = nullptr;
|
|
const std::vector<MetaData::MapTplThing*>* normal_room_spawn_points_ = nullptr;
|
|
const std::vector<MetaData::MapTplThing*>* mini_room_monster_spawn_points_ = nullptr;
|
|
const std::vector<MetaData::MapTplThing*>* normal_room_monster_spawn_points_ = nullptr;
|
|
const MetaData::MapTplThing* level0room_born_point_meta_ = nullptr;
|
|
const MetaData::MapTplThing* level1room_born_point_meta_ = nullptr;
|
|
const std::vector<MetaData::MapTplThing*>* loots_ = nullptr;
|
|
const std::vector<Building*>* buildings_ = nullptr;
|
|
const std::vector<MetaData::MapTplThing*>* level0room_spec_things_ = nullptr;
|
|
Human* first_newbie_ = nullptr;
|
|
bool sent_zombie_boss_notify = false;
|
|
|
|
bool waiting_start_ = false;
|
|
GasData gas_data_;
|
|
long long frameno_ = 0;
|
|
long long battle_start_frameno_ = 0;
|
|
bool game_timeout_ = false;
|
|
bool game_over_ = false;
|
|
long long game_over_frameno_ = 0;
|
|
int elapsed_time_ = 0;
|
|
int alive_count_ = 0;
|
|
long long alive_count_chged_frameno_ = 0;
|
|
int zombie_alive_count_ = 0;
|
|
int human_alive_count_ = 0;
|
|
MetaData::AirLine* airline_ = nullptr;
|
|
a8::XTimerAttacher xtimer_attacher_;
|
|
size_t airdrop_times_ = 0;
|
|
int level0room_born_point_uniid_ = 0;
|
|
int level1room_born_point_uniid_ = 0;
|
|
bool show_handed_ = false;
|
|
int creator_game_times_ = 0;
|
|
int creator_register_time_ = 0;
|
|
int creator_proto_version_ = 0;
|
|
int creator_channel_ = 0;
|
|
bool force_entry_newbie_room_ = false;
|
|
xtimer_list* battle_report_timer_ = nullptr;
|
|
bool sent_terminator_airdrop = false;
|
|
|
|
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, Human*> last_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_;
|
|
|
|
xtimer_list* auto_jump_timer_ = nullptr;
|
|
|
|
RefreshRule* refresh_rule_ = nullptr;
|
|
};
|