Explosion refactor TEST MERG (#6995)

* Explosions

* fix yaml typo

and prevent silly UI inputs

* oop

Co-authored-by: ElectroJr <leonsfriedrich@gmail.com>
This commit is contained in:
Moony
2022-03-04 13:48:01 -06:00
committed by GitHub
parent 4e203f49d2
commit 4a466f4927
71 changed files with 3958 additions and 760 deletions

View File

@@ -1,38 +1,10 @@
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, IExAct
public abstract class InventoryComponent : Component
{
[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);
}
}
}
}
}