ExplosionEvents.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using Content.Shared.Damage;
  2. using Content.Shared.Inventory;
  3. namespace Content.Shared.Explosion;
  4. /// <summary>
  5. /// Raised directed at an entity to determine its explosion resistance, probably right before it is about to be
  6. /// damaged by one.
  7. /// </summary>
  8. [ByRefEvent]
  9. public record struct GetExplosionResistanceEvent(string ExplosionPrototype) : IInventoryRelayEvent
  10. {
  11. /// <summary>
  12. /// A coefficient applied to overall explosive damage.
  13. /// </summary>
  14. public float DamageCoefficient = 1;
  15. public readonly string ExplosionPrototype = ExplosionPrototype;
  16. SlotFlags IInventoryRelayEvent.TargetSlots => ~SlotFlags.POCKET;
  17. }
  18. /// <summary>
  19. /// This event is raised directed at an entity that is about to receive damage from an explosion. It can be used to
  20. /// recursively add contained/child entities that should also receive damage. E.g., entities in a player's inventory
  21. /// or backpack. This event will be raised recursively so a matchbox in a backpack in a player's inventory
  22. /// will also receive this event.
  23. /// </summary>
  24. [ByRefEvent]
  25. public record struct BeforeExplodeEvent(DamageSpecifier Damage, string Id, List<EntityUid> Contents)
  26. {
  27. /// <summary>
  28. /// The damage that will be received by this entity. Note that the entity's explosion resistance has already been
  29. /// used to modify this damage.
  30. /// </summary>
  31. public readonly DamageSpecifier Damage = Damage;
  32. /// <summary>
  33. /// ID of the explosion prototype.
  34. /// </summary>
  35. public readonly string Id = Id;
  36. /// <summary>
  37. /// Damage multiplier for modifying the damage that will get dealt to contained entities.
  38. /// </summary>
  39. public float DamageCoefficient = 1;
  40. /// <summary>
  41. /// Contained/child entities that should receive recursive explosion damage.
  42. /// </summary>
  43. public readonly List<EntityUid> Contents = Contents;
  44. }