@@ -152,7 +152,7 @@ public sealed partial class ExplosionSystem : EntitySystem
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
var ev = new GetExplosionResistanceEvent(explosionType.ID);
|
var ev = new GetExplosionResistanceEvent(explosionType.ID);
|
||||||
RaiseLocalEvent(uid, ev, false);
|
RaiseLocalEvent(uid, ref ev);
|
||||||
|
|
||||||
damagePerIntensity += value * Math.Max(0, ev.DamageCoefficient);
|
damagePerIntensity += value * Math.Max(0, ev.DamageCoefficient);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -390,7 +390,7 @@ public sealed partial class ExplosionSystem : EntitySystem
|
|||||||
if (damage != null && damageQuery.TryGetComponent(uid, out var damageable))
|
if (damage != null && damageQuery.TryGetComponent(uid, out var damageable))
|
||||||
{
|
{
|
||||||
var ev = new GetExplosionResistanceEvent(id);
|
var ev = new GetExplosionResistanceEvent(id);
|
||||||
RaiseLocalEvent(uid, ev, false);
|
RaiseLocalEvent(uid, ref ev, false);
|
||||||
|
|
||||||
ev.DamageCoefficient = Math.Max(0, ev.DamageCoefficient);
|
ev.DamageCoefficient = Math.Max(0, ev.DamageCoefficient);
|
||||||
|
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ public sealed partial class ExplosionSystem : EntitySystem
|
|||||||
SubscribeLocalEvent<ExplosionResistanceComponent, GetExplosionResistanceEvent>(OnGetResistance);
|
SubscribeLocalEvent<ExplosionResistanceComponent, GetExplosionResistanceEvent>(OnGetResistance);
|
||||||
|
|
||||||
// as long as explosion-resistance mice are never added, this should be fine (otherwise a mouse-hat will transfer it's power to the wearer).
|
// as long as explosion-resistance mice are never added, this should be fine (otherwise a mouse-hat will transfer it's power to the wearer).
|
||||||
SubscribeLocalEvent<ExplosionResistanceComponent, InventoryRelayedEvent<GetExplosionResistanceEvent>>((e, c, ev) => OnGetResistance(e, c, ev.Args));
|
SubscribeLocalEvent<ExplosionResistanceComponent, InventoryRelayedEvent<GetExplosionResistanceEvent>>(RelayedResistance);
|
||||||
|
|
||||||
SubscribeLocalEvent<TileChangedEvent>(OnTileChanged);
|
SubscribeLocalEvent<TileChangedEvent>(OnTileChanged);
|
||||||
|
|
||||||
@@ -112,10 +112,17 @@ public sealed partial class ExplosionSystem : EntitySystem
|
|||||||
_pathfindingSystem.PauseUpdating = false;
|
_pathfindingSystem.PauseUpdating = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnGetResistance(EntityUid uid, ExplosionResistanceComponent component, GetExplosionResistanceEvent args)
|
private void RelayedResistance(EntityUid uid, ExplosionResistanceComponent component,
|
||||||
|
InventoryRelayedEvent<GetExplosionResistanceEvent> args)
|
||||||
|
{
|
||||||
|
var a = args.Args;
|
||||||
|
OnGetResistance(uid, component, ref a);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnGetResistance(EntityUid uid, ExplosionResistanceComponent component, ref GetExplosionResistanceEvent args)
|
||||||
{
|
{
|
||||||
args.DamageCoefficient *= component.DamageCoefficient;
|
args.DamageCoefficient *= component.DamageCoefficient;
|
||||||
if (component.Modifiers.TryGetValue(args.ExplotionPrototype, out var modifier))
|
if (component.Modifiers.TryGetValue(args.ExplosionPrototype, out var modifier))
|
||||||
args.DamageCoefficient *= modifier;
|
args.DamageCoefficient *= modifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,19 +8,15 @@ namespace Content.Shared.Explosion;
|
|||||||
/// Raised directed at an entity to determine its explosion resistance, probably right before it is about to be
|
/// Raised directed at an entity to determine its explosion resistance, probably right before it is about to be
|
||||||
/// damaged by one.
|
/// damaged by one.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed class GetExplosionResistanceEvent : EntityEventArgs, IInventoryRelayEvent
|
[ByRefEvent]
|
||||||
|
public record struct GetExplosionResistanceEvent(string ExplosionPrototype) : IInventoryRelayEvent
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A coefficient applied to overall explosive damage.
|
/// A coefficient applied to overall explosive damage.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float DamageCoefficient = 1;
|
public float DamageCoefficient = 1;
|
||||||
|
|
||||||
public readonly string ExplotionPrototype;
|
public readonly string ExplosionPrototype = ExplosionPrototype;
|
||||||
|
|
||||||
SlotFlags IInventoryRelayEvent.TargetSlots => ~SlotFlags.POCKET;
|
SlotFlags IInventoryRelayEvent.TargetSlots => ~SlotFlags.POCKET;
|
||||||
|
|
||||||
public GetExplosionResistanceEvent(string id)
|
|
||||||
{
|
|
||||||
ExplotionPrototype = id;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ public partial class InventorySystem
|
|||||||
SubscribeLocalEvent<InventoryComponent, ElectrocutionAttemptEvent>(RelayInventoryEvent);
|
SubscribeLocalEvent<InventoryComponent, ElectrocutionAttemptEvent>(RelayInventoryEvent);
|
||||||
SubscribeLocalEvent<InventoryComponent, SlipAttemptEvent>(RelayInventoryEvent);
|
SubscribeLocalEvent<InventoryComponent, SlipAttemptEvent>(RelayInventoryEvent);
|
||||||
SubscribeLocalEvent<InventoryComponent, RefreshMovementSpeedModifiersEvent>(RelayInventoryEvent);
|
SubscribeLocalEvent<InventoryComponent, RefreshMovementSpeedModifiersEvent>(RelayInventoryEvent);
|
||||||
SubscribeLocalEvent<InventoryComponent, GetExplosionResistanceEvent>(RelayInventoryEvent);
|
SubscribeLocalEvent<InventoryComponent, GetExplosionResistanceEvent>(RefRelayInventoryEvent);
|
||||||
SubscribeLocalEvent<InventoryComponent, BeforeStripEvent>(RelayInventoryEvent);
|
SubscribeLocalEvent<InventoryComponent, BeforeStripEvent>(RelayInventoryEvent);
|
||||||
SubscribeLocalEvent<InventoryComponent, SeeIdentityAttemptEvent>(RelayInventoryEvent);
|
SubscribeLocalEvent<InventoryComponent, SeeIdentityAttemptEvent>(RelayInventoryEvent);
|
||||||
SubscribeLocalEvent<InventoryComponent, ModifyChangedTemperatureEvent>(RelayInventoryEvent);
|
SubscribeLocalEvent<InventoryComponent, ModifyChangedTemperatureEvent>(RelayInventoryEvent);
|
||||||
@@ -42,7 +42,22 @@ public partial class InventorySystem
|
|||||||
SubscribeLocalEvent<InventoryComponent, GetVerbsEvent<EquipmentVerb>>(OnGetStrippingVerbs);
|
SubscribeLocalEvent<InventoryComponent, GetVerbsEvent<EquipmentVerb>>(OnGetStrippingVerbs);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void RelayInventoryEvent<T>(EntityUid uid, InventoryComponent component, T args) where T : EntityEventArgs, IInventoryRelayEvent
|
protected void RefRelayInventoryEvent<T>(EntityUid uid, InventoryComponent component, ref T args) where T : IInventoryRelayEvent
|
||||||
|
{
|
||||||
|
// Just so I don't have to update 20 morbillion events at once.
|
||||||
|
if (args.TargetSlots == SlotFlags.NONE)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var containerEnumerator = new ContainerSlotEnumerator(uid, component.TemplateId, _prototypeManager, this, args.TargetSlots);
|
||||||
|
var ev = new InventoryRelayedEvent<T>(args);
|
||||||
|
while (containerEnumerator.MoveNext(out var container))
|
||||||
|
{
|
||||||
|
if (!container.ContainedEntity.HasValue) continue;
|
||||||
|
RaiseLocalEvent(container.ContainedEntity.Value, ev, broadcast: false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void RelayInventoryEvent<T>(EntityUid uid, InventoryComponent component, T args) where T : IInventoryRelayEvent
|
||||||
{
|
{
|
||||||
if (args.TargetSlots == SlotFlags.NONE)
|
if (args.TargetSlots == SlotFlags.NONE)
|
||||||
return;
|
return;
|
||||||
@@ -93,7 +108,7 @@ public partial class InventorySystem
|
|||||||
/// happens to be a dead mouse. Clothing that wishes to modify movement speed must subscribe to
|
/// happens to be a dead mouse. Clothing that wishes to modify movement speed must subscribe to
|
||||||
/// InventoryRelayedEvent<RefreshMovementSpeedModifiersEvent>
|
/// InventoryRelayedEvent<RefreshMovementSpeedModifiersEvent>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public sealed class InventoryRelayedEvent<TEvent> : EntityEventArgs where TEvent : EntityEventArgs
|
public sealed class InventoryRelayedEvent<TEvent> : EntityEventArgs
|
||||||
{
|
{
|
||||||
public readonly TEvent Args;
|
public readonly TEvent Args;
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ namespace Content.Shared.SubFloor
|
|||||||
SubscribeLocalEvent<SubFloorHideComponent, GetExplosionResistanceEvent>(OnGetExplosionResistance);
|
SubscribeLocalEvent<SubFloorHideComponent, GetExplosionResistanceEvent>(OnGetExplosionResistance);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnGetExplosionResistance(EntityUid uid, SubFloorHideComponent component, GetExplosionResistanceEvent args)
|
private void OnGetExplosionResistance(EntityUid uid, SubFloorHideComponent component, ref GetExplosionResistanceEvent args)
|
||||||
{
|
{
|
||||||
if (component.BlockInteractions && component.IsUnderCover)
|
if (component.BlockInteractions && component.IsUnderCover)
|
||||||
args.DamageCoefficient = 0;
|
args.DamageCoefficient = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user