component.DamagedEntity = true;
- var afterProjectileHitEvent = new AfterProjectileHitEvent(component.Damage, target, args.OtherFixture);
- RaiseLocalEvent(uid, ref afterProjectileHitEvent);
-
if (component.DeleteOnCollide)
QueueDel(uid);
base.Initialize();
SubscribeLocalEvent<ProjectileComponent, PreventCollideEvent>(PreventCollision);
- SubscribeLocalEvent<ProjectileComponent, AfterProjectileHitEvent>(AfterProjectileHit);
SubscribeLocalEvent<EmbeddableProjectileComponent, ProjectileHitEvent>(OnEmbedProjectileHit);
SubscribeLocalEvent<EmbeddableProjectileComponent, ThrowDoHitEvent>(OnEmbedThrowDoHit);
SubscribeLocalEvent<EmbeddableProjectileComponent, ActivateInWorldEvent>(OnEmbedActivate);
{
args.Cancel("pacified-cannot-throw-embed");
}
-
- /// <summary>
- /// Checks if the projectile is allowed to penetrate the target it hit.
- /// </summary>
- private void AfterProjectileHit(EntityUid uid, ProjectileComponent component, ref AfterProjectileHitEvent args)
- {
- //Overrides the original DeleteOnCollide if the projectile passes all penetration checks.
- //This is to prevent having to set DeleteOnCollide to false on every prototype
- //you want to give the ability to penetrate entities.
- if(component.DeleteOnCollide)
- component.DeleteOnCollide = false;
- }
}
[Serializable, NetSerializable]
/// </summary>
[ByRefEvent]
public record struct ProjectileHitEvent(DamageSpecifier Damage, EntityUid Target, EntityUid? Shooter = null);
-
-/// <summary>
-/// Raised after a projectile has dealt it's damage.
-/// </summary>
-[ByRefEvent]
-public record struct AfterProjectileHitEvent(DamageSpecifier Damage, EntityUid Target, Fixture Fixture);