This commit is contained in:
aozhiwei 2021-04-08 20:12:30 +08:00
parent d5bd6e9966
commit fb01de9b2e
4 changed files with 64 additions and 4 deletions

View File

@ -461,3 +461,58 @@ bool Obstacle::Throughable()
return meta->i->attack_type() == 2; return meta->i->attack_type() == 2;
} }
int Obstacle::GetTeamId(Room* room)
{
if (IsPermanent()) {
ObstacleData* p = room->GetPermanentObstacleData(GetEntityUniId());
if (!a8::HasBitFlag(p->flags, kHealth)) {
p->health = health_;
a8::SetBitFlag(p->flags, kHealth);
}
return p->team_id;
} else {
return team_id_;
}
}
void Obstacle::GetTeamId(Room* room, int team_id)
{
if (IsPermanent()) {
ObstacleData* p = room->GetPermanentObstacleData(GetEntityUniId());
if (!a8::HasBitFlag(p->flags, kHealth)) {
p->health = health_;
a8::SetBitFlag(p->flags, kHealth);
}
p->team_id = team_id;
} else {
team_id_ = team_id;
}
}
int Obstacle::GetMasterId(Room* room)
{
if (IsPermanent()) {
ObstacleData* p = room->GetPermanentObstacleData(GetEntityUniId());
if (!a8::HasBitFlag(p->flags, kHealth)) {
p->health = health_;
a8::SetBitFlag(p->flags, kHealth);
}
return p->master_id;
} else {
return master_id_;
}
}
void Obstacle::SetMasterId(Room* room, int master_id)
{
if (IsPermanent()) {
ObstacleData* p = room->GetPermanentObstacleData(GetEntityUniId());
if (!a8::HasBitFlag(p->flags, kHealth)) {
p->health = health_;
a8::SetBitFlag(p->flags, kHealth);
}
p->master_id = master_id;
} else {
master_id_ = master_id;
}
}

View File

@ -54,6 +54,10 @@ class Obstacle : public Entity
float GetHealth(Room* room); float GetHealth(Room* room);
void SetHealth(Room* room, float value); void SetHealth(Room* room, float value);
void Die(Room* room); void Die(Room* room);
int GetTeamId(Room* room);
void GetTeamId(Room* room, int team_id);
int GetMasterId(Room* room);
void SetMasterId(Room* room, int master_id);
bool IsPermanent(); bool IsPermanent();
bool Attackable(); bool Attackable();
bool Throughable(); bool Throughable();
@ -76,5 +80,8 @@ protected:
bool dead_ = false; bool dead_ = false;
long long dead_frameno_ = 0; long long dead_frameno_ = 0;
int team_id_ = 0;
int master_id_ = 0;
friend class EntityFactory; friend class EntityFactory;
}; };

View File

@ -97,10 +97,6 @@ bool RoomObstacle::CanThroughable(Human* hum)
void RoomObstacle::ActiveTimerFunc() void RoomObstacle::ActiveTimerFunc()
{ {
if (meta->i->thing_type() == kObstacleSelfExplosion) {
room->xtimer.DeleteTimer(room->xtimer.GetRunningTimer());
return;
}
if (!master.Get()) { if (!master.Get()) {
room->xtimer.DeleteTimer(room->xtimer.GetRunningTimer()); room->xtimer.DeleteTimer(room->xtimer.GetRunningTimer());
return; return;

View File

@ -137,6 +137,8 @@ struct ObstacleData
float health = 0.0f; float health = 0.0f;
bool dead = false; bool dead = false;
long long dead_frameno = 0; long long dead_frameno = 0;
int team_id = 0;
int master_id = 0;
int door_open_times = 0; int door_open_times = 0;
DoorState_e door_state = DoorStateClose; DoorState_e door_state = DoorStateClose;