8.草无法被子弹命中无法被消除,需要支持被指定子弹或爆炸消灭

This commit is contained in:
aozhiwei 2021-06-18 21:14:13 +08:00
parent 75b928cef1
commit 42700cbd63
7 changed files with 45 additions and 10 deletions

View File

@ -295,7 +295,14 @@ void Bullet::Check(float distance)
std::set<ColliderComponent*> colliders; std::set<ColliderComponent*> colliders;
room->map_service->GetColliders(room, GetX(), GetY(), colliders); room->map_service->GetColliders(room, GetX(), GetY(), colliders);
for (ColliderComponent* collider : colliders) { for (ColliderComponent* collider : colliders) {
if (TestCollision(room, collider) && !a8::HasBitFlag(collider->tag, kHalfWallTag)) { if (TestCollision(room, collider) &&
!a8::HasBitFlag(collider->tag, kHalfWallTag)) {
if (collider->owner->IsEntityType(ET_Obstacle)) {
Obstacle* obstacle = (Obstacle*)collider->owner;
if (obstacle->CanThroughable(this)) {
continue;
}
}
objects.insert(collider->owner); objects.insert(collider->owner);
} }
} }

View File

@ -78,7 +78,7 @@ void FragMiTask::Done()
} }
Obstacle* obstacle = (Obstacle*)target; Obstacle* obstacle = (Obstacle*)target;
if (!obstacle->IsDead(room) && if (!obstacle->IsDead(room) &&
obstacle->Attackable() && obstacle->Attackable(sender.Get()) &&
!obstacle->IsTerminatorAirDropBox(room)) { !obstacle->IsTerminatorAirDropBox(room)) {
float dmg = GetAtk() * (1 + sender.Get()->GetAttrRate(kHAT_Atk)) + float dmg = GetAtk() * (1 + sender.Get()->GetAttrRate(kHAT_Atk)) +
sender.Get()->GetAttrAbs(kHAT_Atk); sender.Get()->GetAttrAbs(kHAT_Atk);

View File

@ -165,7 +165,7 @@ bool Hero::IsCollisionInMapService()
return true; return true;
} }
if (!obstacle->IsDead(room) && if (!obstacle->IsDead(room) &&
obstacle->Attackable() && obstacle->Attackable(this) &&
obstacle->meta->i->drop() != 0 && obstacle->meta->i->drop() != 0 &&
obstacle->IsTouchInteraction() && obstacle->IsTouchInteraction() &&
room->GetGasData().gas_mode != GasInactive && room->GetGasData().gas_mode != GasInactive &&

View File

@ -525,7 +525,7 @@ bool Human::IsCollisionInMapService()
return true; return true;
} }
if (!obstacle->IsDead(room) && if (!obstacle->IsDead(room) &&
obstacle->Attackable() && obstacle->Attackable(this) &&
obstacle->meta->i->drop() != 0 && obstacle->meta->i->drop() != 0 &&
obstacle->IsTouchInteraction() && obstacle->IsTouchInteraction() &&
room->GetGasData().gas_mode != GasInactive && room->GetGasData().gas_mode != GasInactive &&

View File

@ -355,7 +355,7 @@ void Obstacle::Explosion(Bullet* bullet)
{ {
Obstacle* obstacle = (Obstacle*)target; Obstacle* obstacle = (Obstacle*)target;
if (!obstacle->IsDead(room) && if (!obstacle->IsDead(room) &&
obstacle->Attackable() && obstacle->Attackable(this) &&
!obstacle->IsTerminatorAirDropBox(room)) { !obstacle->IsTerminatorAirDropBox(room)) {
float dmg = meta->i->damage(); float dmg = meta->i->damage();
float def = 0; float def = 0;
@ -497,9 +497,30 @@ bool Obstacle::IsPermanent()
return is_permanent; return is_permanent;
} }
bool Obstacle::Attackable() bool Obstacle::Attackable(Entity* sender)
{ {
return meta->i->attack_type() == 1; switch (meta->i->attack_type()) {
case 1:
{
return true;
}
break;
case 3:
{
//只有特定子弹
if (sender->IsEntityType(ET_Bullet)) {
Bullet* bullet = (Bullet*)sender;
return ((bullet->gun_meta->special_damage_type & meta->receive_special_damage_type) != 0);
}
return false;
}
break;
default:
{
return false;
}
break;
}
} }
bool Obstacle::Throughable() bool Obstacle::Throughable()
@ -566,7 +587,7 @@ void Obstacle::SetMasterId(Room* room, int master_id)
void Obstacle::OnBulletHit(Bullet* bullet) void Obstacle::OnBulletHit(Bullet* bullet)
{ {
if (!IsDead(bullet->room) && if (!IsDead(bullet->room) &&
Attackable() && Attackable(bullet) &&
!IsTerminatorAirDropBox(bullet->room)) { !IsTerminatorAirDropBox(bullet->room)) {
if (meta->receive_special_damage_type != 0 && if (meta->receive_special_damage_type != 0 &&
((bullet->gun_meta->special_damage_type & meta->receive_special_damage_type) == 0)) { ((bullet->gun_meta->special_damage_type & meta->receive_special_damage_type) == 0)) {
@ -627,11 +648,18 @@ void Obstacle::OnBulletHit(Bullet* bullet)
bool Obstacle::CanThroughable(Creature* c) bool Obstacle::CanThroughable(Creature* c)
{ {
if (meta->i->attack_type() == 3) {
return true;
}
return false; return false;
} }
bool Obstacle::CanThroughable(Bullet* bullet) bool Obstacle::CanThroughable(Bullet* bullet)
{ {
if (meta->i->attack_type() == 3) {
return meta->receive_special_damage_type != 0 &&
((bullet->gun_meta->special_damage_type & meta->receive_special_damage_type) == 0);
}
return false; return false;
} }

View File

@ -67,7 +67,7 @@ class Obstacle : public Entity
int GetMasterId(Room* room); int GetMasterId(Room* room);
void SetMasterId(Room* room, int master_id); void SetMasterId(Room* room, int master_id);
bool IsPermanent(); bool IsPermanent();
bool Attackable(); bool Attackable(Entity* sender);
bool Throughable(); bool Throughable();
bool IsTouchInteraction(); bool IsTouchInteraction();
bool IsOpenInteraction(); bool IsOpenInteraction();

View File

@ -241,7 +241,7 @@ void RoomObstacle::Explosion()
{ {
Obstacle* obstacle = (Obstacle*)target; Obstacle* obstacle = (Obstacle*)target;
if (!obstacle->IsDead(room) && if (!obstacle->IsDead(room) &&
obstacle->Attackable() && obstacle->Attackable(this) &&
!obstacle->IsTerminatorAirDropBox(room)) { !obstacle->IsTerminatorAirDropBox(room)) {
float dmg = meta->i->damage(); float dmg = meta->i->damage();
float def = 0; float def = 0;