aozhiwei 00a20a41b2 1
2019-09-11 14:03:30 +08:00

150 lines
4.6 KiB
C++

#pragma once
#include <a8/xtimer.h>
#include <a8/timer_attacher.h>
#include "frameevent.h"
#include "framemaker.h"
#include "gridservice.h"
#include "mapservice.h"
namespace MetaData
{
struct Map;
struct SafeArea;
struct Building;
struct AirLine;
struct MapTplThing;
}
struct timer_list;
struct xtimer_list;
class Entity;
class Obstacle;
class Bullet;
class Human;
class Player;
class Building;
class Hero;
class AabbCollider;
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;
Plane plane;
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<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);
Hero* CreateHero(Human* hum);
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);
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);
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);
void CombineTeam();
void InitAirDrop();
void AirDrop(int appear_time, int box_id);
void ShuaPlane();
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<void (Obstacle*)> on_precreate);
void AddObjectLater(Entity* entity);
void OnGameOver();
void RandRemoveAndroid();
void NotifyWxVoip();
BornPoint* AllocBornPoint(Human* hum);
void CreateMapObject(MetaData::MapTplThing& thing_tpl);
void CreateMapSpawnPoint(MetaData::MapTplThing& thing_tpl);
private:
int elapsed_time_ = 0;
int alive_count_ = 0;
MetaData::AirLine* airline_ = nullptr;
a8::XTimerAttacher xtimer_attacher;
xtimer_list* auto_jump_timer_ = nullptr;
int current_teamid = 0;
int current_uniid = 0;
std::set<int> refreshed_robot_set_;
std::map<int, std::set<Human*>> team_hash_;
std::map<std::string, Player*> accountid_hash_;
std::map<int, Entity*> moveable_hash_;
std::map<int, Entity*> uniid_hash_;
std::map<int, Entity*> later_add_hash_;
std::map<int, Human*> human_hash_;
std::map<int, BornPoint> born_point_hash_;
std::map<int, CarObject> car_hash_;
std::map<int, Human*> removed_robot_hash_;
};