#pragma once #include #include #include "frameevent.h" #include "framemaker.h" #include "gridservice.h" #include "mapservice.h" namespace MetaData { struct Map; struct SafeArea; struct Building; } struct timer_list; struct xtimer_list; class Entity; class Obstacle; class Bullet; class Human; class Player; class Building; class Hero; class Room { public: long long room_uuid = 0; MetaData::Map* map_meta = nullptr; std::string map_tpl_name; FrameEvent frame_event; FrameMaker frame_maker; long long frame_no = 0; GasData gas_data; bool game_over = false; long long game_over_frameno = 0; long long game_over_tick = 0; timer_list* game_over_timer = nullptr; a8::XTimer xtimer; GridService grid_service; MapService map_service; long long battle_start_frameno_ = 0; long long pending_request = 0; ~Room(); void Init(); void UnInit(); void Update(int delta_time); int GetPlayerNum(); int AliveCount(); Player* GetPlayerByAccountId(const std::string& accountid); Player* GetPlayerByUniId(int uniid); Entity* GetEntityByUniId(int uniid); void AddPlayer(Player* hum); Human* FindEnemy(Human* hum); void RemoveObjectLater(Entity* entity); void FetchBuilding(Human* hum); void FillSMJoinedNotify(Player* self_hum, cs::SMJoinedNotify& msg); void TouchPlayerList(a8::XParams param, std::function func); void TouchHumanList(a8::XParams param, std::function func); void TouchEntityList(a8::XParams param, std::function func); void ScatterDrop(a8::Vec2 center, int drop_id); void DropItem(a8::Vec2 pos, int item_id, int item_count, int item_lv); Hero* CreateHero(Human* hum); void 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); void OnHumanDie(Human* hum); bool OverBorder(const a8::Vec2 pos, float radius); Human* GetWatchWarTarget(Human* hum); bool BattleStarted(); int GetAliveTeamNum(); std::set* GetAliveTeam(); bool CanJoin(const std::string& accountid); void OnPlayerOffline(Player* hum); private: int AllocUniid(); void ShuaAndroid(); void CreateAndroid(int android_num); void UpdateGas(); bool GenSmallCircle(a8::Vec2 big_circle_pos, float big_circle_rad, float small_circle_rad, a8::Vec2& out_pos); void AutoMatchTeam(); void MatchTeam(Human* hum); int NewTeam(); Obstacle* CreateObstacle(int id, float x, float y); void CreateThings(); void CreateBuilding(int thing_id, float building_x, float building_y); Obstacle* InternalCreateObstacle(int id, float x, float y, std::function on_precreate); void AddObjectLater(Entity* entity); void OnGameOver(); void RandRemoveAndroid(); void NotifyUiUpdate(); void NotifyWxVoip(); private: int elapsed_time_ = 0; int alive_count_ = 0; a8::XTimerAttacher xtimer_attacher; int current_teamid = 0; int current_uniid = 0; std::set refreshed_robot_set_; std::map> team_hash_; std::map accountid_hash_; std::map moveable_hash_; std::map uniid_hash_; std::map later_add_hash_; std::map human_hash_; std::map removed_robot_hash_; };