explosion minor rework + fix (#21718)

This commit is contained in:
deltanedas
2023-11-19 17:44:42 +00:00
committed by GitHub
parent db76d85f36
commit f25773ffec
10 changed files with 148 additions and 62 deletions

View File

@@ -1,6 +1,5 @@
using Content.Shared.Damage;
using Content.Shared.Inventory;
using Robust.Shared.Map;
using Robust.Shared.Serialization;
namespace Content.Shared.Explosion;
@@ -20,3 +19,34 @@ public record struct GetExplosionResistanceEvent(string ExplosionPrototype) : II
SlotFlags IInventoryRelayEvent.TargetSlots => ~SlotFlags.POCKET;
}
/// <summary>
/// This event is raised directed at an entity that is about to receive damage from an explosion. It can be used to
/// recursively add contained/child entities that should also receive damage. E.g., entities in a player's inventory
/// or backpack. This event will be raised recursively so a matchbox in a backpack in a player's inventory
/// will also receive this event.
/// </summary>
[ByRefEvent]
public record struct BeforeExplodeEvent(DamageSpecifier Damage, string Id, List<EntityUid> Contents)
{
/// <summary>
/// The damage that will be received by this entity. Note that the entity's explosion resistance has already been
/// used to modify this damage.
/// </summary>
public readonly DamageSpecifier Damage = Damage;
/// <summary>
/// ID of the explosion prototype.
/// </summary>
public readonly string Id = Id;
/// <summary>
/// Damage multiplier for modifying the damage that will get dealt to contained entities.
/// </summary>
public float DamageCoefficient = 1;
/// <summary>
/// Contained/child entities that should receive recursive explosion damage.
/// </summary>
public readonly List<EntityUid> Contents = Contents;
}