explosion minor rework + fix (#21718)
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
using System.Linq;
|
||||
using Content.Shared.Administration.Logs;
|
||||
using Content.Shared.Damage.Prototypes;
|
||||
using Content.Shared.FixedPoint;
|
||||
using Content.Shared.Inventory;
|
||||
using Content.Shared.Mind.Components;
|
||||
using Content.Shared.Mobs.Components;
|
||||
using Content.Shared.Mobs.Systems;
|
||||
using Content.Shared.Radiation.Events;
|
||||
@@ -16,12 +18,14 @@ namespace Content.Shared.Damage
|
||||
public sealed class DamageableSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
[Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
|
||||
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
|
||||
[Dependency] private readonly INetManager _netMan = default!;
|
||||
[Dependency] private readonly MobThresholdSystem _mobThreshold = default!;
|
||||
|
||||
private EntityQuery<AppearanceComponent> _appearanceQuery;
|
||||
private EntityQuery<DamageableComponent> _damageableQuery;
|
||||
private EntityQuery<MindContainerComponent> _mindContainerQuery;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -33,6 +37,7 @@ namespace Content.Shared.Damage
|
||||
|
||||
_appearanceQuery = GetEntityQuery<AppearanceComponent>();
|
||||
_damageableQuery = GetEntityQuery<DamageableComponent>();
|
||||
_mindContainerQuery = GetEntityQuery<MindContainerComponent>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -124,6 +124,12 @@ public abstract partial class SharedEntityStorageComponent : Component
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
public Container Contents = default!;
|
||||
|
||||
/// <summary>
|
||||
/// Multiplier for explosion damage that gets applied to contained entities.
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public float ExplosionDamageCoefficient = 1;
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
|
||||
Reference in New Issue
Block a user