@@ -1,10 +1,38 @@
|
||||
using System.Linq;
|
||||
using Content.Shared.Acts;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||
|
||||
namespace Content.Shared.Inventory;
|
||||
|
||||
public abstract class InventoryComponent : Component
|
||||
public abstract class InventoryComponent : Component, IExAct
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entityManager = default!;
|
||||
|
||||
[DataField("templateId", required: true,
|
||||
customTypeSerializer: typeof(PrototypeIdSerializer<InventoryTemplatePrototype>))]
|
||||
public string TemplateId { get; } = "human";
|
||||
|
||||
void IExAct.OnExplosion(ExplosionEventArgs eventArgs)
|
||||
{
|
||||
if (eventArgs.Severity < ExplosionSeverity.Heavy)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (EntitySystem.Get<InventorySystem>()
|
||||
.TryGetContainerSlotEnumerator(Owner, out var enumerator, this))
|
||||
{
|
||||
while (enumerator.MoveNext(out var container))
|
||||
{
|
||||
if (!container.ContainedEntity.HasValue) continue;
|
||||
foreach (var exAct in _entityManager.GetComponents<IExAct>(container.ContainedEntity.Value).ToArray())
|
||||
{
|
||||
exAct.OnExplosion(eventArgs);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.Electrocution;
|
||||
using Content.Shared.Explosion;
|
||||
using Content.Shared.Movement.EntitySystems;
|
||||
using Content.Shared.Slippery;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Shared.Inventory;
|
||||
|
||||
@@ -14,7 +14,6 @@ public partial class InventorySystem
|
||||
SubscribeLocalEvent<InventoryComponent, ElectrocutionAttemptEvent>(RelayInventoryEvent);
|
||||
SubscribeLocalEvent<InventoryComponent, SlipAttemptEvent>(RelayInventoryEvent);
|
||||
SubscribeLocalEvent<InventoryComponent, RefreshMovementSpeedModifiersEvent>(RelayInventoryEvent);
|
||||
SubscribeLocalEvent<InventoryComponent, GetExplosionResistanceEvent>(RelayInventoryEvent);
|
||||
}
|
||||
|
||||
protected void RelayInventoryEvent<T>(EntityUid uid, InventoryComponent component, T args) where T : EntityEventArgs, IInventoryRelayEvent
|
||||
|
||||
Reference in New Issue
Block a user