2019-04-18 16:50:59 +08:00

113 lines
3.1 KiB
C++

#pragma once
#include <a8/xtimer.h>
#include <a8/timer_attacher.h>
#include "framedata.h"
namespace MetaData
{
struct Map;
struct SafeArea;
struct Building;
struct AirLine;
}
struct RoomProfile
{
long long max_rundelay = 0;
};
struct timer_list;
class Entity;
class Bullet;
class Human;
class Player;
class Building;
class Room
{
public:
long long room_uuid = 0;
MetaData::Map* map_meta = nullptr;
RoomFrameData frame_data;
long long frame_no = 0;
GasData gas_data;
bool game_over = false;
long long game_over_frameno = 0;
RoomProfile profile;
a8::XTimer xtimer;
Plane plane;
~Room();
void Init();
void UnInit();
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);
Human* FindEnemy(Human* hum);
void CollisionDetection(Entity* sender, int detection_flags, std::vector<Entity*>& objects);
void AddDeletedObject(unsigned short obj_uniid, bool soft_delete);
void BeAddedObject(Entity* entity);
void FetchBuilding(Human* hum);
void FillSMJoinedNotify(Player* self_hum, cs::SMJoinedNotify& msg);
void FillSMMapInfo(cs::SMMapInfo& map_info);
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 ScatterDrop(Vector2D center, int drop_id);
void DropItem(Vector2D pos, int item_id, int item_count);
void CreateThings();
void CreateDoor(Building* building, int door_idx);
void CreateHouseObstacle(Building* building, int id, float x, float y);
void CreateObstacle(int id, float x, float y);
void CreateLoot(int equip_id, Vector2D pos, int count);
void CreateBullet(Human* hum, MetaData::Equip* gun_meta,
Vector2D pos, Vector2D dir, float fly_distance);
void OnHumanDie(Human* hum);
private:
unsigned short AllocUniid();
void ShuaAndroid();
void ResetFrameData();
void ClearDeletedObjects();
void ProcAddedObjects();
void UpdateGas();
bool GenSmallCircle(Vector2D big_circle_pos, float big_circle_rad, float small_circle_rad,
Vector2D& out_pos);
void OutputDebugLog();
void AutoMatchTeam();
void InitAirDrop();
void AirDrop(int appear_time, int box_id);
void ShuaPlane();
private:
timer_list* stats_timer_ = nullptr;
int elapsed_time_ = 0;
int alive_count_ = 0;
MetaData::AirLine* airline_ = nullptr;
a8::XTimerAttacher xtimer_attacher;
int current_teamid = 0;
unsigned short current_uniid = 0;
std::map<int, std::set<Human*>> team_hash_;
std::map<std::string, Player*> accountid_hash_;
std::map<unsigned short, Entity*> moveable_hash_;
std::map<unsigned short, Entity*> uniid_hash_;
std::map<unsigned short, Human*> human_hash_;
std::map<unsigned short, Entity*> be_added_hash_;
};