public override CollisionResponse CanCollide(WorldBody projectedBody) { if (PendingDestruction) { return(new CollisionResponse(false)); } // ship-to-ship collisions /*if (projectedBody is Ship ship) * if (ship.Fleet != null && this.Fleet != null && this.Fleet != ship.Fleet) * return new CollisionResponse(true, true);*/ if (projectedBody is ShipWeaponBullet bullet) { //if (projectedBody is ShipWeaponSeeker && this.Abandoned) // return new CollisionResponse(false); if (bullet.Consumed) { return(new CollisionResponse(false)); } // if it came from this fleet if (bullet.OwnedByFleet == this?.Fleet) { return(new CollisionResponse(false)); } // if it came from this fleet if (bullet.OwnedByFleet == this?.AbandonedByFleet && World.Time < (this.AbandonedTime + World.Hook.AbandonBuffer)) { return(new CollisionResponse(false)); } // team mode ensures that bullets of like colors do no harm if (World.Hook.TeamMode && bullet.Color == this.Color) { return(new CollisionResponse(false)); } return(new CollisionResponse(true, false)); } if (!this.Abandoned) { // TODO: do we still need this beast? if (projectedBody is PickupBase || projectedBody is HasteToken) { return(new CollisionResponse(true, false)); } } return(base.CanCollide(projectedBody)); }
public override void CollisionExecute(WorldBody projectedBody) { if (projectedBody is ShipWeaponBullet bullet) { if (!bullet.Consumed) { bullet.Consumed = true; } } }
public override CollisionResponse CanCollide(WorldBody projectedBody) { if (projectedBody is ShipWeaponBullet bullet) { return(new CollisionResponse(true, true, frictionCoefficient: 0.3f)); } if (projectedBody is Ship) { return(new CollisionResponse(true, true, frictionCoefficient: 0.3f)); } if (projectedBody is Obstacle) { return(new CollisionResponse(true, true, frictionCoefficient: 0.3f)); } return(base.CanCollide(projectedBody)); }
public override void CollisionExecute(WorldBody projectedBody) { if (projectedBody is ShipWeaponBullet bullet) { if (this.PendingDestruction) { return; } if (bullet.Consumed || this.PendingDestruction) { return; } bullet.Consumed = true; var fleet = bullet?.OwnedByFleet; var player = fleet?.Owner; var takesDamage = !Fleet?.Owner?.IsInvulnerable ?? true; if (takesDamage && ShieldStrength > 0) { if (projectedBody is ShipWeaponSeeker) { ShieldStrength = 0; } else { ShieldStrength--; } takesDamage = false; } if (takesDamage) { Die(player, fleet, bullet); } } }
public override CollisionResponse CanCollide(WorldBody projectedBody) { return(new CollisionResponse(true, true)); }
public override void CollisionExecute(WorldBody projectedBody) { }