youhua entity_type entity_subtype
This commit is contained in:
parent
02f25a5ebb
commit
9daa4a1330
@ -8,8 +8,8 @@
|
|||||||
|
|
||||||
Android::Android():Human()
|
Android::Android():Human()
|
||||||
{
|
{
|
||||||
entity_type = ET_Player;
|
entity_type_ = ET_Player;
|
||||||
entity_subtype = EST_Android;
|
entity_subtype_ = EST_Android;
|
||||||
ai = new AndroidAI;
|
ai = new AndroidAI;
|
||||||
ai->owner = this;
|
ai->owner = this;
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
Building::Building():Entity()
|
Building::Building():Entity()
|
||||||
{
|
{
|
||||||
entity_type = ET_Building;
|
entity_type_ = ET_Building;
|
||||||
++App::Instance()->perf.entity_num[ET_Building];
|
++App::Instance()->perf.entity_num[ET_Building];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
Bullet::Bullet():MoveableEntity()
|
Bullet::Bullet():MoveableEntity()
|
||||||
{
|
{
|
||||||
entity_type = ET_Bullet;
|
entity_type_ = ET_Bullet;
|
||||||
++App::Instance()->perf.entity_num[ET_Bullet];
|
++App::Instance()->perf.entity_num[ET_Bullet];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,7 +51,7 @@ void Bullet::RecalcSelfCollider()
|
|||||||
void Bullet::OnHit(std::set<Entity*>& objects)
|
void Bullet::OnHit(std::set<Entity*>& objects)
|
||||||
{
|
{
|
||||||
for (auto& target : objects) {
|
for (auto& target : objects) {
|
||||||
switch (target->entity_type) {
|
switch (target->GetEntityType()) {
|
||||||
case ET_Player:
|
case ET_Player:
|
||||||
{
|
{
|
||||||
Human* hum = (Human*)target;
|
Human* hum = (Human*)target;
|
||||||
@ -129,20 +129,20 @@ void Bullet::ProcBomb()
|
|||||||
(
|
(
|
||||||
[this, &objects] (Entity* entity, bool& stop)
|
[this, &objects] (Entity* entity, bool& stop)
|
||||||
{
|
{
|
||||||
switch (entity->entity_type) {
|
switch (entity->GetEntityType()) {
|
||||||
case ET_Obstacle:
|
case ET_Obstacle:
|
||||||
case ET_Building:
|
case ET_Building:
|
||||||
{
|
{
|
||||||
if (TestCollision(room, entity)) {
|
if (TestCollision(room, entity)) {
|
||||||
objects.insert(entity);
|
objects.insert(entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
switch (meta->i->_inventory_slot()) {
|
switch (meta->i->_inventory_slot()) {
|
||||||
|
@ -18,8 +18,6 @@ class Entity
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
int entity_uniid = 0;
|
int entity_uniid = 0;
|
||||||
EntityType_e entity_type = ET_None;
|
|
||||||
EntitySubType_e entity_subtype = EST_None;
|
|
||||||
|
|
||||||
int grid_id = 0;
|
int grid_id = 0;
|
||||||
|
|
||||||
@ -34,6 +32,10 @@ class Entity
|
|||||||
virtual bool IsDead(Room* room) { return false;};
|
virtual bool IsDead(Room* room) { return false;};
|
||||||
virtual long long GetDeadFrameNo(Room* room) { return 0;};
|
virtual long long GetDeadFrameNo(Room* room) { return 0;};
|
||||||
virtual void OnPreCollision(Room* room) {};
|
virtual void OnPreCollision(Room* room) {};
|
||||||
|
EntityType_e GetEntityType() { return entity_type_; }
|
||||||
|
EntitySubType_e GetEntitySubType() { return entity_subtype_; }
|
||||||
|
virtual bool IsEntityType(EntityType_e type) { return type == entity_type_;}
|
||||||
|
virtual bool IsEntitySubType(EntitySubType_e subtype) { return subtype == entity_subtype_;}
|
||||||
bool TestCollision(Room* room, Entity* b);
|
bool TestCollision(Room* room, Entity* b);
|
||||||
bool TestCollision(Room* room, ColliderComponent* b);
|
bool TestCollision(Room* room, ColliderComponent* b);
|
||||||
bool TestCollisionEx(Room* room, const a8::Vec2& aabb_pos, AabbCollider& aabb_box);
|
bool TestCollisionEx(Room* room, const a8::Vec2& aabb_pos, AabbCollider& aabb_box);
|
||||||
@ -71,11 +73,14 @@ class Entity
|
|||||||
pos_.y = y;
|
pos_.y = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
void ClearColliders();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::list<ColliderComponent*> colliders_;
|
std::list<ColliderComponent*> colliders_;
|
||||||
|
EntityType_e entity_type_ = ET_None;
|
||||||
|
EntitySubType_e entity_subtype_ = EST_None;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
a8::Vec2 pos_;
|
a8::Vec2 pos_;
|
||||||
|
|
||||||
void ClearColliders();
|
|
||||||
};
|
};
|
||||||
|
@ -206,7 +206,7 @@ void GridService::DelBullet(Bullet* bullet)
|
|||||||
|
|
||||||
void GridService::AddRoomEntity(Room* room, Entity* entity)
|
void GridService::AddRoomEntity(Room* room, Entity* entity)
|
||||||
{
|
{
|
||||||
assert(entity->entity_type != ET_Player);
|
assert(!entity->IsEntityType(ET_Player));
|
||||||
int x = (int)entity->GetX() + cell_width_;
|
int x = (int)entity->GetX() + cell_width_;
|
||||||
int y = (int)entity->GetY() + cell_width_;
|
int y = (int)entity->GetY() + cell_width_;
|
||||||
if (BroderOverFlow(x, y)) {
|
if (BroderOverFlow(x, y)) {
|
||||||
@ -227,7 +227,7 @@ void GridService::DelRoomEntity(Room* room, Entity* entity)
|
|||||||
|
|
||||||
void GridService::AddPermanentEntity(Entity* entity)
|
void GridService::AddPermanentEntity(Entity* entity)
|
||||||
{
|
{
|
||||||
assert(entity->entity_type != ET_Player);
|
assert(!entity->IsEntityType(ET_Player));
|
||||||
int x = (int)entity->GetX() + cell_width_;
|
int x = (int)entity->GetX() + cell_width_;
|
||||||
int y = (int)entity->GetY() + cell_width_;
|
int y = (int)entity->GetY() + cell_width_;
|
||||||
if (BroderOverFlow(x, y)) {
|
if (BroderOverFlow(x, y)) {
|
||||||
|
@ -459,7 +459,7 @@ bool Human::IsCollisionInMapService()
|
|||||||
AabbCollider aabb_box;
|
AabbCollider aabb_box;
|
||||||
GetAabbBox(aabb_box);
|
GetAabbBox(aabb_box);
|
||||||
for (ColliderComponent* collider : colliders) {
|
for (ColliderComponent* collider : colliders) {
|
||||||
switch (collider->owner->entity_type) {
|
switch (collider->owner->GetEntityType()) {
|
||||||
case ET_Obstacle:
|
case ET_Obstacle:
|
||||||
{
|
{
|
||||||
Obstacle* obstacle = (Obstacle*)collider->owner;
|
Obstacle* obstacle = (Obstacle*)collider->owner;
|
||||||
@ -655,7 +655,7 @@ void Human::UpdatePoisoning()
|
|||||||
}
|
}
|
||||||
poisoning_time -= 1000;
|
poisoning_time -= 1000;
|
||||||
}
|
}
|
||||||
if (need_notify && entity_subtype == EST_Player) {
|
if (need_notify && IsEntitySubType(EST_Player)) {
|
||||||
SyncAroundPlayers(__FILE__, __LINE__, __func__);
|
SyncAroundPlayers(__FILE__, __LINE__, __func__);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -769,7 +769,7 @@ void Human::CancelAction()
|
|||||||
{
|
{
|
||||||
if (action_type == AT_Relive) {
|
if (action_type == AT_Relive) {
|
||||||
Entity* entity = room->GetEntityByUniId(action_target_id);
|
Entity* entity = room->GetEntityByUniId(action_target_id);
|
||||||
if (entity->entity_type != ET_Player) {
|
if (!entity->IsEntityType(ET_Player)) {
|
||||||
Human* hum = (Human*)entity;
|
Human* hum = (Human*)entity;
|
||||||
if (hum->action_type == AT_Rescue) {
|
if (hum->action_type == AT_Rescue) {
|
||||||
hum->CancelAction();
|
hum->CancelAction();
|
||||||
@ -857,7 +857,7 @@ void Human::BeKill(int killer_id, const std::string& killer_name, int weapon_id)
|
|||||||
if (!dead && !room->IsGameOver() && !real_dead) {
|
if (!dead && !room->IsGameOver() && !real_dead) {
|
||||||
lethal_weapon = weapon_id;
|
lethal_weapon = weapon_id;
|
||||||
Entity* hum = room->GetEntityByUniId(killer_id);
|
Entity* hum = room->GetEntityByUniId(killer_id);
|
||||||
if (hum && hum->entity_type == ET_Player) {
|
if (hum && hum->IsEntityType(ET_Player)) {
|
||||||
if (killer_id == entity_uniid) {
|
if (killer_id == entity_uniid) {
|
||||||
std::string msg = a8::Format("%s 自杀",
|
std::string msg = a8::Format("%s 自杀",
|
||||||
{
|
{
|
||||||
@ -948,7 +948,7 @@ void Human::BeKill(int killer_id, const std::string& killer_name, int weapon_id)
|
|||||||
if (weapon_id != VW_Spectate &&
|
if (weapon_id != VW_Spectate &&
|
||||||
dead_times <= max_revive_times &&
|
dead_times <= max_revive_times &&
|
||||||
room->AliveCount() >= 5 &&
|
room->AliveCount() >= 5 &&
|
||||||
entity_subtype == EST_Player) {
|
IsEntitySubType(EST_Player)) {
|
||||||
Revive();
|
Revive();
|
||||||
} else {
|
} else {
|
||||||
real_dead = true;
|
real_dead = true;
|
||||||
@ -1130,7 +1130,7 @@ void Human::DoSkill()
|
|||||||
skill_target_id = entity_uniid;
|
skill_target_id = entity_uniid;
|
||||||
#endif
|
#endif
|
||||||
Entity* entity = room->GetEntityByUniId(skill_target_id);
|
Entity* entity = room->GetEntityByUniId(skill_target_id);
|
||||||
if (entity && entity->entity_type == ET_Player) {
|
if (entity && entity->IsEntityType(ET_Player)) {
|
||||||
Human* hum = (Human*)entity;
|
Human* hum = (Human*)entity;
|
||||||
std::set<Entity*> target_list;
|
std::set<Entity*> target_list;
|
||||||
skill_target_pos = hum->GetPos();
|
skill_target_pos = hum->GetPos();
|
||||||
@ -1161,7 +1161,7 @@ void Human::DoGetDown()
|
|||||||
if (car_.car_id != 0) {
|
if (car_.car_id != 0) {
|
||||||
int entity_uniid = room->CreateLoot(car_.car_id, GetPos(), 1, 1);
|
int entity_uniid = room->CreateLoot(car_.car_id, GetPos(), 1, 1);
|
||||||
Entity* loot_entity = room->GetEntityByUniId(entity_uniid);
|
Entity* loot_entity = room->GetEntityByUniId(entity_uniid);
|
||||||
if (loot_entity && loot_entity->entity_type == ET_Loot) {
|
if (loot_entity && loot_entity->IsEntityType(ET_Loot)) {
|
||||||
((Loot*)loot_entity)->bullet_num = 0;
|
((Loot*)loot_entity)->bullet_num = 0;
|
||||||
((Loot*)loot_entity)->param1 = 0;
|
((Loot*)loot_entity)->param1 = 0;
|
||||||
((Loot*)loot_entity)->param2 = 0;
|
((Loot*)loot_entity)->param2 = 0;
|
||||||
@ -1185,7 +1185,7 @@ void Human::FindLocation()
|
|||||||
(
|
(
|
||||||
[this, &target] (Entity* entity, bool& stop)
|
[this, &target] (Entity* entity, bool& stop)
|
||||||
{
|
{
|
||||||
switch (entity->entity_type) {
|
switch (entity->GetEntityType()) {
|
||||||
case ET_Obstacle:
|
case ET_Obstacle:
|
||||||
{
|
{
|
||||||
if (!target) {
|
if (!target) {
|
||||||
@ -1197,13 +1197,13 @@ void Human::FindLocation()
|
|||||||
break;
|
break;
|
||||||
case ET_Building:
|
case ET_Building:
|
||||||
{
|
{
|
||||||
if (!target || target->entity_type != ET_Building) {
|
if (!target || !target->IsEntityType(ET_Building)) {
|
||||||
AabbCollider aabb_box;
|
AabbCollider aabb_box;
|
||||||
entity->GetAabbBox(aabb_box);
|
entity->GetAabbBox(aabb_box);
|
||||||
if (TestCollision(room, &aabb_box)) {
|
if (TestCollision(room, &aabb_box)) {
|
||||||
target = entity;
|
target = entity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -1232,7 +1232,7 @@ void Human::RefreshView()
|
|||||||
(
|
(
|
||||||
[this] (Entity* entity, bool& stop)
|
[this] (Entity* entity, bool& stop)
|
||||||
{
|
{
|
||||||
switch (entity->entity_type) {
|
switch (entity->GetEntityType()) {
|
||||||
case ET_Building:
|
case ET_Building:
|
||||||
case ET_Obstacle:
|
case ET_Obstacle:
|
||||||
case ET_Loot:
|
case ET_Loot:
|
||||||
@ -1494,7 +1494,7 @@ void Human::SendUpdateMsg()
|
|||||||
|
|
||||||
void Human::SendGameOver()
|
void Human::SendGameOver()
|
||||||
{
|
{
|
||||||
if (entity_subtype == EST_Player) {
|
if (IsEntitySubType(EST_Player)) {
|
||||||
//!!!必须要在SendNotifyMsg之前注意哦
|
//!!!必须要在SendNotifyMsg之前注意哦
|
||||||
if (!sent_battlereport_) {
|
if (!sent_battlereport_) {
|
||||||
SendBattleReport();
|
SendBattleReport();
|
||||||
@ -1664,7 +1664,7 @@ void Human::UpdateAction()
|
|||||||
case AT_Relive:
|
case AT_Relive:
|
||||||
{
|
{
|
||||||
Entity* entity = room->GetEntityByUniId(action_target_id);
|
Entity* entity = room->GetEntityByUniId(action_target_id);
|
||||||
if (entity->entity_type != ET_Player) {
|
if (!entity->IsEntityType(ET_Player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Human* hum = (Human*)entity;
|
Human* hum = (Human*)entity;
|
||||||
@ -1803,7 +1803,7 @@ void Human::ClearFrameData()
|
|||||||
Entity* entity = room->GetEntityByUniId(itr);
|
Entity* entity = room->GetEntityByUniId(itr);
|
||||||
if (entity) {
|
if (entity) {
|
||||||
RemovePartObjects(entity);
|
RemovePartObjects(entity);
|
||||||
if (entity->entity_type == ET_Player) {
|
if (entity->IsEntityType(ET_Player)) {
|
||||||
((Human*)entity)->RemovePartObjects(this);
|
((Human*)entity)->RemovePartObjects(this);
|
||||||
}
|
}
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
@ -1821,7 +1821,7 @@ void Human::ClearFrameData()
|
|||||||
Human* hum = (Human*)entity;
|
Human* hum = (Human*)entity;
|
||||||
if (entity) {
|
if (entity) {
|
||||||
RemovePartObjects(entity);
|
RemovePartObjects(entity);
|
||||||
if (entity->entity_type == ET_Player) {
|
if (entity->IsEntityType(ET_Player)) {
|
||||||
((Human*)entity)->RemovePartObjects(this);
|
((Human*)entity)->RemovePartObjects(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2141,7 +2141,7 @@ void Human::ProcLootOldSkin(Loot* entity, MetaData::Equip* item_meta)
|
|||||||
if (skin_tank.skin_id != 0) {
|
if (skin_tank.skin_id != 0) {
|
||||||
int entity_uniid = room->CreateLoot(skin_tank.skin_id, GetPos(), 1, 1);
|
int entity_uniid = room->CreateLoot(skin_tank.skin_id, GetPos(), 1, 1);
|
||||||
Entity* loot_entity = room->GetEntityByUniId(entity_uniid);
|
Entity* loot_entity = room->GetEntityByUniId(entity_uniid);
|
||||||
if (loot_entity && loot_entity->entity_type == ET_Loot) {
|
if (loot_entity && loot_entity->IsEntityType(ET_Loot)) {
|
||||||
((Loot*)loot_entity)->bullet_num = tank_weapon.ammo;
|
((Loot*)loot_entity)->bullet_num = tank_weapon.ammo;
|
||||||
((Loot*)loot_entity)->param1 = tank_oil_value;
|
((Loot*)loot_entity)->param1 = tank_oil_value;
|
||||||
((Loot*)loot_entity)->param2 = tank_oil_max;
|
((Loot*)loot_entity)->param2 = tank_oil_max;
|
||||||
@ -2257,7 +2257,7 @@ void Human::ProcLootCar(Loot* entity, MetaData::Equip* item_meta)
|
|||||||
if (car_.car_id != 0) {
|
if (car_.car_id != 0) {
|
||||||
int entity_uniid = room->CreateLoot(car_.car_id, GetPos(), 1, 1);
|
int entity_uniid = room->CreateLoot(car_.car_id, GetPos(), 1, 1);
|
||||||
Entity* loot_entity = room->GetEntityByUniId(entity_uniid);
|
Entity* loot_entity = room->GetEntityByUniId(entity_uniid);
|
||||||
if (loot_entity && loot_entity->entity_type == ET_Loot) {
|
if (loot_entity && loot_entity->IsEntityType(ET_Loot)) {
|
||||||
((Loot*)loot_entity)->bullet_num = 0;
|
((Loot*)loot_entity)->bullet_num = 0;
|
||||||
((Loot*)loot_entity)->param1 = 0;
|
((Loot*)loot_entity)->param1 = 0;
|
||||||
((Loot*)loot_entity)->param2 = 0;
|
((Loot*)loot_entity)->param2 = 0;
|
||||||
@ -2317,18 +2317,18 @@ void Human::FindLocationWithTarget(Entity* target)
|
|||||||
tmp_grids,
|
tmp_grids,
|
||||||
[this, &building] (Entity* entity, bool& stop)
|
[this, &building] (Entity* entity, bool& stop)
|
||||||
{
|
{
|
||||||
switch (entity->entity_type) {
|
switch (entity->GetEntityType()) {
|
||||||
case ET_Building:
|
case ET_Building:
|
||||||
{
|
{
|
||||||
if (TestCollision(room, entity)) {
|
if (TestCollision(room, entity)) {
|
||||||
building = entity;
|
building = entity;
|
||||||
stop = true;
|
stop = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!building) {
|
if (!building) {
|
||||||
@ -2500,7 +2500,7 @@ float Human::GetSkillAtkAdd(int skill_id)
|
|||||||
|
|
||||||
void Human::TriggerOneObjectBuff(Entity* target, BuffTriggerType_e trigger_type)
|
void Human::TriggerOneObjectBuff(Entity* target, BuffTriggerType_e trigger_type)
|
||||||
{
|
{
|
||||||
if (target->entity_type != ET_Player) {
|
if (!target->IsEntityType(ET_Player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Human* hum = (Human*)target;
|
Human* hum = (Human*)target;
|
||||||
@ -2740,18 +2740,18 @@ float Human::GetBuffAttrRate(int attr_type)
|
|||||||
|
|
||||||
bool Human::IsPlayer()
|
bool Human::IsPlayer()
|
||||||
{
|
{
|
||||||
return entity_subtype == EST_Player;
|
return IsEntitySubType(EST_Player);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Human::IsAndroid()
|
bool Human::IsAndroid()
|
||||||
{
|
{
|
||||||
return entity_subtype == EST_Android;
|
return IsEntitySubType(EST_Android);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Human::DropItems(Obstacle* obstacle)
|
void Human::DropItems(Obstacle* obstacle)
|
||||||
{
|
{
|
||||||
bool is_treasure_box = false;
|
bool is_treasure_box = false;
|
||||||
if (obstacle->entity_subtype == EST_RoomObstacle) {
|
if (obstacle->IsEntitySubType(EST_RoomObstacle)) {
|
||||||
is_treasure_box = ((RoomObstacle*)obstacle)->is_treasure_box;
|
is_treasure_box = ((RoomObstacle*)obstacle)->is_treasure_box;
|
||||||
}
|
}
|
||||||
int drop_id = obstacle->meta->i->drop();
|
int drop_id = obstacle->meta->i->drop();
|
||||||
@ -2912,7 +2912,7 @@ void Human::SelectSkillTargets(const a8::Vec2& target_pos, std::set<Entity*>& ta
|
|||||||
case kST_EnemySingle:
|
case kST_EnemySingle:
|
||||||
{
|
{
|
||||||
Entity* entity = room->GetEntityByUniId(skill_target_id);
|
Entity* entity = room->GetEntityByUniId(skill_target_id);
|
||||||
if (entity && entity->entity_type == ET_Player) {
|
if (entity && entity->IsEntityType(ET_Player)) {
|
||||||
Human* hum = (Human*)entity;
|
Human* hum = (Human*)entity;
|
||||||
if (hum->team_id != team_id) {
|
if (hum->team_id != team_id) {
|
||||||
target_list.insert(hum);
|
target_list.insert(hum);
|
||||||
@ -2962,7 +2962,7 @@ void Human::SelectSkillTargets(const a8::Vec2& target_pos, std::set<Entity*>& ta
|
|||||||
case kST_SingleEnemyAndSelf:
|
case kST_SingleEnemyAndSelf:
|
||||||
{
|
{
|
||||||
Entity* entity = room->GetEntityByUniId(skill_target_id);
|
Entity* entity = room->GetEntityByUniId(skill_target_id);
|
||||||
if (entity && entity->entity_type == ET_Player) {
|
if (entity && entity->IsEntityType(ET_Player)) {
|
||||||
Human* hum = (Human*)entity;
|
Human* hum = (Human*)entity;
|
||||||
if (hum->team_id != team_id) {
|
if (hum->team_id != team_id) {
|
||||||
target_list.insert(hum);
|
target_list.insert(hum);
|
||||||
@ -3106,19 +3106,19 @@ void Human::GetViewObjects(std::set<Entity*>& view_objects)
|
|||||||
(
|
(
|
||||||
[&view_objects] (Entity* entity, bool& stop)
|
[&view_objects] (Entity* entity, bool& stop)
|
||||||
{
|
{
|
||||||
switch (entity->entity_type) {
|
switch (entity->GetEntityType()) {
|
||||||
case ET_Building:
|
case ET_Building:
|
||||||
case ET_Obstacle:
|
case ET_Obstacle:
|
||||||
case ET_Loot:
|
case ET_Loot:
|
||||||
{
|
{
|
||||||
view_objects.insert(entity);
|
view_objects.insert(entity);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3186,7 +3186,7 @@ void Human::ProcIncGridList(std::set<GridCell*>& old_grids,
|
|||||||
inc_grids,
|
inc_grids,
|
||||||
[this] (Entity* entity, bool& stop)
|
[this] (Entity* entity, bool& stop)
|
||||||
{
|
{
|
||||||
switch (entity->entity_type) {
|
switch (entity->GetEntityType()) {
|
||||||
case ET_Building:
|
case ET_Building:
|
||||||
case ET_Obstacle:
|
case ET_Obstacle:
|
||||||
case ET_Loot:
|
case ET_Loot:
|
||||||
@ -3232,20 +3232,20 @@ void Human::ProcDecGridList(std::set<GridCell*>& old_grids,
|
|||||||
[this] (Entity* entity, bool& stop)
|
[this] (Entity* entity, bool& stop)
|
||||||
{
|
{
|
||||||
if (!room->grid_service->EntityInGridList(room, entity, GetGridList())) {
|
if (!room->grid_service->EntityInGridList(room, entity, GetGridList())) {
|
||||||
switch (entity->entity_type) {
|
switch (entity->GetEntityType()) {
|
||||||
case ET_Building:
|
case ET_Building:
|
||||||
case ET_Obstacle:
|
case ET_Obstacle:
|
||||||
case ET_Loot:
|
case ET_Loot:
|
||||||
{
|
{
|
||||||
AddOutObjects(entity);
|
AddOutObjects(entity);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
Loot::Loot():RoomEntity()
|
Loot::Loot():RoomEntity()
|
||||||
{
|
{
|
||||||
entity_type = ET_Loot;
|
entity_type_ = ET_Loot;
|
||||||
++App::Instance()->perf.entity_num[ET_Loot];
|
++App::Instance()->perf.entity_num[ET_Loot];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,8 +69,8 @@ void MapService::UnInit()
|
|||||||
|
|
||||||
void MapService::AddCollider(ColliderComponent* collider)
|
void MapService::AddCollider(ColliderComponent* collider)
|
||||||
{
|
{
|
||||||
if (!(collider->owner->entity_type == ET_Obstacle ||
|
if (!(collider->owner->IsEntityType(ET_Obstacle) ||
|
||||||
collider->owner->entity_type == ET_Building)) {
|
collider->owner->IsEntityType(ET_Building))) {
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
CellNode* top_node = nullptr;
|
CellNode* top_node = nullptr;
|
||||||
@ -184,10 +184,10 @@ void MapService::GetColliders(Room* room,
|
|||||||
}
|
}
|
||||||
struct CellNode *node, *tmp;
|
struct CellNode *node, *tmp;
|
||||||
list_for_each_entry_safe(node, tmp, head, entry) {
|
list_for_each_entry_safe(node, tmp, head, entry) {
|
||||||
switch (node->collider->owner->entity_type) {
|
switch (node->collider->owner->GetEntityType()) {
|
||||||
case ET_Obstacle:
|
case ET_Obstacle:
|
||||||
{
|
{
|
||||||
switch (node->collider->owner->entity_subtype) {
|
switch (node->collider->owner->GetEntitySubType()) {
|
||||||
case EST_PermanentObstacle:
|
case EST_PermanentObstacle:
|
||||||
{
|
{
|
||||||
colliders.insert(node->collider);
|
colliders.insert(node->collider);
|
||||||
|
@ -17,8 +17,8 @@ enum ObstacleDataFlags_e
|
|||||||
|
|
||||||
Obstacle::Obstacle():Entity()
|
Obstacle::Obstacle():Entity()
|
||||||
{
|
{
|
||||||
entity_type = ET_Obstacle;
|
entity_type_ = ET_Obstacle;
|
||||||
entity_subtype = EST_PermanentObstacle;
|
entity_subtype_ = EST_PermanentObstacle;
|
||||||
++App::Instance()->perf.entity_num[ET_Obstacle];
|
++App::Instance()->perf.entity_num[ET_Obstacle];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -245,7 +245,7 @@ void Obstacle::Explosion(Bullet* bullet)
|
|||||||
tmp_grids,
|
tmp_grids,
|
||||||
[this, room, &objects] (Entity* entity, bool& stop)
|
[this, room, &objects] (Entity* entity, bool& stop)
|
||||||
{
|
{
|
||||||
switch (entity->entity_type) {
|
switch (entity->GetEntityType()) {
|
||||||
case ET_Obstacle:
|
case ET_Obstacle:
|
||||||
case ET_Building:
|
case ET_Building:
|
||||||
{
|
{
|
||||||
@ -263,7 +263,7 @@ void Obstacle::Explosion(Bullet* bullet)
|
|||||||
a8::Vec2 bomb_pos = GetPos();
|
a8::Vec2 bomb_pos = GetPos();
|
||||||
room->frame_event.AddExplosion(bullet, meta->i->thing_id(), bomb_pos);
|
room->frame_event.AddExplosion(bullet, meta->i->thing_id(), bomb_pos);
|
||||||
for (auto& target : objects) {
|
for (auto& target : objects) {
|
||||||
switch (target->entity_type) {
|
switch (target->GetEntityType()) {
|
||||||
case ET_Player:
|
case ET_Player:
|
||||||
{
|
{
|
||||||
Human* hum = (Human*)target;
|
Human* hum = (Human*)target;
|
||||||
|
@ -19,8 +19,8 @@ const int kREVIVE_BUFF_ID = 1005;
|
|||||||
|
|
||||||
Player::Player():Human()
|
Player::Player():Human()
|
||||||
{
|
{
|
||||||
entity_type = ET_Player;
|
entity_type_ = ET_Player;
|
||||||
entity_subtype = EST_Player;
|
entity_subtype_ = EST_Player;
|
||||||
++App::Instance()->perf.entity_num[ET_Player];
|
++App::Instance()->perf.entity_num[ET_Player];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -458,7 +458,7 @@ void Player::ProcInteraction()
|
|||||||
for (auto obj_id : interaction_objids) {
|
for (auto obj_id : interaction_objids) {
|
||||||
Entity* entity = room->GetEntityByUniId(obj_id);
|
Entity* entity = room->GetEntityByUniId(obj_id);
|
||||||
if (entity) {
|
if (entity) {
|
||||||
switch (entity->entity_type) {
|
switch (entity->GetEntityType()) {
|
||||||
case ET_Obstacle:
|
case ET_Obstacle:
|
||||||
{
|
{
|
||||||
ObstacleInteraction((Obstacle*)entity);
|
ObstacleInteraction((Obstacle*)entity);
|
||||||
|
@ -131,7 +131,10 @@ Player* Room::GetPlayerByAccountId(const std::string& accountid)
|
|||||||
Player* Room::GetPlayerByUniId(int uniid)
|
Player* Room::GetPlayerByUniId(int uniid)
|
||||||
{
|
{
|
||||||
Entity* entity = GetEntityByUniId(uniid);
|
Entity* entity = GetEntityByUniId(uniid);
|
||||||
return entity && entity->entity_type == ET_Player && entity->entity_subtype == EST_Player ?
|
if (!entity) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
return entity->IsEntityType(ET_Player) && entity->IsEntitySubType(EST_Player) ?
|
||||||
(Player*)entity : nullptr;
|
(Player*)entity : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -303,7 +306,7 @@ Human* Room::FindEnemy(Human* hum)
|
|||||||
(
|
(
|
||||||
[&enemys, hum, sub_type] (Human* target, bool& stop)
|
[&enemys, hum, sub_type] (Human* target, bool& stop)
|
||||||
{
|
{
|
||||||
if (target->entity_subtype == sub_type &&
|
if (target->IsEntitySubType(sub_type) &&
|
||||||
!target->dead) {
|
!target->dead) {
|
||||||
if (hum->GetPos().Distance(target->GetPos()) < 300.0f) {
|
if (hum->GetPos().Distance(target->GetPos()) < 300.0f) {
|
||||||
if (target->team_id == 0 ||
|
if (target->team_id == 0 ||
|
||||||
@ -440,37 +443,38 @@ void Room::CreateBullet(Human* hum, Weapon* weapon,
|
|||||||
|
|
||||||
void Room::RemoveObjectLater(RoomEntity* entity)
|
void Room::RemoveObjectLater(RoomEntity* entity)
|
||||||
{
|
{
|
||||||
auto remove_func = [] (const a8::XParams& param)
|
auto remove_func =
|
||||||
{
|
[] (const a8::XParams& param)
|
||||||
RoomEntity* entity = (RoomEntity*)param.sender.GetUserData();
|
{
|
||||||
switch (entity->entity_type) {
|
RoomEntity* entity = (RoomEntity*)param.sender.GetUserData();
|
||||||
case ET_Bullet:
|
switch (entity->GetEntityType()) {
|
||||||
{
|
case ET_Bullet:
|
||||||
entity->room->RemoveFromMoveableHash((Bullet*)entity);
|
{
|
||||||
entity->room->grid_service->DelBullet((Bullet*)entity);
|
entity->room->RemoveFromMoveableHash((Bullet*)entity);
|
||||||
}
|
entity->room->grid_service->DelBullet((Bullet*)entity);
|
||||||
break;
|
}
|
||||||
case ET_Loot:
|
break;
|
||||||
{
|
case ET_Loot:
|
||||||
entity->BroadcastDeleteState(entity->room);
|
{
|
||||||
entity->room->grid_service->DelRoomEntity(entity->room, entity);
|
entity->BroadcastDeleteState(entity->room);
|
||||||
}
|
entity->room->grid_service->DelRoomEntity(entity->room, entity);
|
||||||
break;
|
}
|
||||||
case ET_Player:
|
break;
|
||||||
{
|
case ET_Player:
|
||||||
entity->room->RemoveFromMoveableHash((Human*)entity);
|
{
|
||||||
entity->room->RemoveFromHuamnHash((Human*)entity);
|
entity->room->RemoveFromMoveableHash((Human*)entity);
|
||||||
}
|
entity->room->RemoveFromHuamnHash((Human*)entity);
|
||||||
break;
|
}
|
||||||
default:
|
break;
|
||||||
{
|
default:
|
||||||
abort();
|
{
|
||||||
}
|
abort();
|
||||||
break;
|
}
|
||||||
}
|
break;
|
||||||
entity->room->RemoveFromEntityHash(entity);
|
}
|
||||||
delete entity;
|
entity->room->RemoveFromEntityHash(entity);
|
||||||
};
|
delete entity;
|
||||||
|
};
|
||||||
xtimer.AddDeadLineTimerAndAttach(0,
|
xtimer.AddDeadLineTimerAndAttach(0,
|
||||||
a8::XParams()
|
a8::XParams()
|
||||||
.SetSender(entity),
|
.SetSender(entity),
|
||||||
@ -599,32 +603,32 @@ Entity* Room::FindFirstCollisonEntity(const a8::Vec2& aabb_pos, AabbCollider& aa
|
|||||||
tmp_grids,
|
tmp_grids,
|
||||||
[this, &target, &aabb_pos, &aabb_box] (Entity* entity, bool& stop)
|
[this, &target, &aabb_pos, &aabb_box] (Entity* entity, bool& stop)
|
||||||
{
|
{
|
||||||
switch (entity->entity_type) {
|
switch (entity->GetEntityType()) {
|
||||||
case ET_Obstacle:
|
case ET_Obstacle:
|
||||||
{
|
{
|
||||||
if (!target) {
|
if (!target) {
|
||||||
if (entity->TestCollisionEx(this, aabb_pos, aabb_box)) {
|
if (entity->TestCollisionEx(this, aabb_pos, aabb_box)) {
|
||||||
target = entity;
|
target = entity;
|
||||||
stop = true;
|
stop = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ET_Building:
|
case ET_Building:
|
||||||
{
|
{
|
||||||
if (!target || target->entity_type != ET_Building) {
|
if (!target || !target->IsEntityType(ET_Building)) {
|
||||||
AabbCollider building_aabb_box;
|
AabbCollider building_aabb_box;
|
||||||
entity->GetAabbBox(building_aabb_box);
|
entity->GetAabbBox(building_aabb_box);
|
||||||
if (building_aabb_box.IntersectEx(aabb_pos, &aabb_box)) {
|
if (building_aabb_box.IntersectEx(aabb_pos, &aabb_box)) {
|
||||||
target = entity;
|
target = entity;
|
||||||
stop = true;
|
stop = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
@ -1219,7 +1223,7 @@ void Room::AddObjectLater(RoomEntity* entity)
|
|||||||
auto add_func = [] (const a8::XParams& param)
|
auto add_func = [] (const a8::XParams& param)
|
||||||
{
|
{
|
||||||
RoomEntity* entity = (RoomEntity*)param.sender.GetUserData();
|
RoomEntity* entity = (RoomEntity*)param.sender.GetUserData();
|
||||||
if (entity->entity_type == ET_Bullet) {
|
if (entity->IsEntityType(ET_Bullet)) {
|
||||||
MoveableEntity* moveableentity = (MoveableEntity*)entity;
|
MoveableEntity* moveableentity = (MoveableEntity*)entity;
|
||||||
entity->room->AddToMoveableHash(moveableentity);
|
entity->room->AddToMoveableHash(moveableentity);
|
||||||
}
|
}
|
||||||
@ -1448,7 +1452,7 @@ void Room::CreateLoots()
|
|||||||
);
|
);
|
||||||
if (entity_uniid && equip_meta->i->equip_type() == EQUIP_TYPE_CAR) {
|
if (entity_uniid && equip_meta->i->equip_type() == EQUIP_TYPE_CAR) {
|
||||||
Entity* loot_entity = GetEntityByUniId(entity_uniid);
|
Entity* loot_entity = GetEntityByUniId(entity_uniid);
|
||||||
if (loot_entity && loot_entity->entity_type == ET_Loot) {
|
if (loot_entity && loot_entity->IsEntityType(ET_Loot)) {
|
||||||
((Loot*)loot_entity)->bullet_num = equip_meta->i->clip_volume();
|
((Loot*)loot_entity)->bullet_num = equip_meta->i->clip_volume();
|
||||||
((Loot*)loot_entity)->param1 = MetaMgr::Instance()->max_oil;
|
((Loot*)loot_entity)->param1 = MetaMgr::Instance()->max_oil;
|
||||||
((Loot*)loot_entity)->param2 = MetaMgr::Instance()->max_oil;
|
((Loot*)loot_entity)->param2 = MetaMgr::Instance()->max_oil;
|
||||||
@ -1481,7 +1485,7 @@ void Room::CreateDropObjs()
|
|||||||
|
|
||||||
void Room::IncBornPointHumanNum(BornPoint* point, Human* hum)
|
void Room::IncBornPointHumanNum(BornPoint* point, Human* hum)
|
||||||
{
|
{
|
||||||
switch (hum->entity_subtype) {
|
switch (hum->GetEntitySubType()) {
|
||||||
case EST_Player:
|
case EST_Player:
|
||||||
{
|
{
|
||||||
++point->player_num;
|
++point->player_num;
|
||||||
@ -1501,7 +1505,7 @@ void Room::IncBornPointHumanNum(BornPoint* point, Human* hum)
|
|||||||
|
|
||||||
void Room::DecBornPointHumanNum(BornPoint* point, Human* hum)
|
void Room::DecBornPointHumanNum(BornPoint* point, Human* hum)
|
||||||
{
|
{
|
||||||
switch (hum->entity_subtype) {
|
switch (hum->GetEntitySubType()) {
|
||||||
case EST_Player:
|
case EST_Player:
|
||||||
{
|
{
|
||||||
--point->player_num;
|
--point->player_num;
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
RoomObstacle::RoomObstacle():Obstacle()
|
RoomObstacle::RoomObstacle():Obstacle()
|
||||||
{
|
{
|
||||||
entity_subtype = EST_RoomObstacle;
|
entity_subtype_ = EST_RoomObstacle;
|
||||||
}
|
}
|
||||||
|
|
||||||
RoomObstacle::~RoomObstacle()
|
RoomObstacle::~RoomObstacle()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user