diff --git a/Content.Server/Buckle/Components/StrapComponent.cs b/Content.Server/Buckle/Components/StrapComponent.cs index 8f94992a65..4618770406 100644 --- a/Content.Server/Buckle/Components/StrapComponent.cs +++ b/Content.Server/Buckle/Components/StrapComponent.cs @@ -1,5 +1,4 @@ using System.Linq; -using Content.Shared.Acts; using Content.Shared.Alert; using Content.Shared.Buckle.Components; using Content.Shared.DragDrop; @@ -11,7 +10,7 @@ namespace Content.Server.Buckle.Components { [RegisterComponent] [ComponentReference(typeof(SharedStrapComponent))] - public sealed class StrapComponent : SharedStrapComponent, ISerializationHooks, IDestroyAct + public sealed class StrapComponent : SharedStrapComponent, ISerializationHooks { [Dependency] private readonly IEntityManager _entityManager = default!; @@ -183,12 +182,7 @@ namespace Content.Server.Buckle.Components RemoveAll(); } - void IDestroyAct.OnDestroy(DestructionEventArgs eventArgs) - { - RemoveAll(); - } - - private void RemoveAll() + public void RemoveAll() { var entManager = IoCManager.Resolve(); diff --git a/Content.Server/Buckle/Systems/StrapSystem.cs b/Content.Server/Buckle/Systems/StrapSystem.cs index 62e363eb63..98b52c7a2a 100644 --- a/Content.Server/Buckle/Systems/StrapSystem.cs +++ b/Content.Server/Buckle/Systems/StrapSystem.cs @@ -1,5 +1,6 @@ using Content.Server.Buckle.Components; using Content.Server.Interaction; +using Content.Shared.Destructible; using Content.Shared.Interaction; using Content.Shared.Storage; using Content.Shared.Verbs; @@ -22,6 +23,7 @@ namespace Content.Server.Buckle.Systems SubscribeLocalEvent>(AddStrapVerbs); SubscribeLocalEvent(OnInsertAttempt); SubscribeLocalEvent(OnInteractHand); + SubscribeLocalEvent(OnDestroy); } private void OnInsertAttempt(EntityUid uid, StrapComponent component, ContainerGettingInsertedAttemptEvent args) @@ -118,5 +120,10 @@ namespace Content.Server.Buckle.Systems args.Verbs.Add(verb); } } + + private void OnDestroy(EntityUid uid, StrapComponent component, DestructionEventArgs args) + { + component.RemoveAll(); + } } } diff --git a/Content.Server/Construction/Completions/DestroyEntity.cs b/Content.Server/Construction/Completions/DestroyEntity.cs index fdde0279f3..4b4bb03b8a 100644 --- a/Content.Server/Construction/Completions/DestroyEntity.cs +++ b/Content.Server/Construction/Completions/DestroyEntity.cs @@ -4,7 +4,6 @@ using Robust.Shared.GameObjects; using Robust.Shared.Serialization.Manager.Attributes; using System.Threading.Tasks; using Content.Server.Destructible; -using Content.Shared.Acts; namespace Content.Server.Construction.Completions { @@ -14,7 +13,7 @@ namespace Content.Server.Construction.Completions { public void PerformAction(EntityUid uid, EntityUid? userUid, IEntityManager entityManager) { - entityManager.EntitySysManager.GetEntitySystem().HandleDestruction(uid); + entityManager.EntitySysManager.GetEntitySystem().DestroyEntity(uid); } } } diff --git a/Content.Server/Destructible/DestructibleSystem.cs b/Content.Server/Destructible/DestructibleSystem.cs index 868a5ac5f7..6efe8ebd46 100644 --- a/Content.Server/Destructible/DestructibleSystem.cs +++ b/Content.Server/Destructible/DestructibleSystem.cs @@ -4,7 +4,6 @@ using Content.Server.Destructible.Thresholds.Behaviors; using Content.Server.Destructible.Thresholds.Triggers; using Content.Server.Explosion.EntitySystems; using Content.Server.Stack; -using Content.Shared.Acts; using Content.Shared.Damage; using Content.Shared.FixedPoint; using JetBrains.Annotations; @@ -12,16 +11,16 @@ using Robust.Server.GameObjects; using Robust.Shared.Prototypes; using Robust.Shared.Random; using System; +using Content.Shared.Destructible; namespace Content.Server.Destructible { [UsedImplicitly] - public sealed class DestructibleSystem : EntitySystem + public sealed class DestructibleSystem : SharedDestructibleSystem { [Dependency] public readonly IRobustRandom Random = default!; public new IEntityManager EntityManager => base.EntityManager; - [Dependency] public readonly ActSystem ActSystem = default!; [Dependency] public readonly AudioSystem AudioSystem = default!; [Dependency] public readonly ConstructionSystem ConstructionSystem = default!; [Dependency] public readonly ExplosionSystem ExplosionSystem = default!; diff --git a/Content.Server/Destructible/Thresholds/Behaviors/DoActsBehavior.cs b/Content.Server/Destructible/Thresholds/Behaviors/DoActsBehavior.cs index 3b545a3c1d..cca0dfbb4a 100644 --- a/Content.Server/Destructible/Thresholds/Behaviors/DoActsBehavior.cs +++ b/Content.Server/Destructible/Thresholds/Behaviors/DoActsBehavior.cs @@ -1,9 +1,4 @@ -using System; -using Content.Shared.Acts; -using Robust.Shared.GameObjects; -using Robust.Shared.Serialization.Manager.Attributes; - -namespace Content.Server.Destructible.Thresholds.Behaviors +namespace Content.Server.Destructible.Thresholds.Behaviors { [Serializable] [DataDefinition] @@ -11,7 +6,6 @@ namespace Content.Server.Destructible.Thresholds.Behaviors { /// /// What acts should be triggered upon activation. - /// See . /// [DataField("acts")] public ThresholdActs Acts { get; set; } @@ -25,12 +19,12 @@ namespace Content.Server.Destructible.Thresholds.Behaviors { if (HasAct(ThresholdActs.Breakage)) { - system.ActSystem.HandleBreakage(owner); + system.BreakEntity(owner); } if (HasAct(ThresholdActs.Destruction)) { - system.ActSystem.HandleDestruction(owner); + system.DestroyEntity(owner); } } } diff --git a/Content.Server/Disposal/Tube/Components/DisposalTubeComponent.cs b/Content.Server/Disposal/Tube/Components/DisposalTubeComponent.cs index aa788ec7f0..c3cfb55ccf 100644 --- a/Content.Server/Disposal/Tube/Components/DisposalTubeComponent.cs +++ b/Content.Server/Disposal/Tube/Components/DisposalTubeComponent.cs @@ -2,7 +2,6 @@ using System; using System.Linq; using Content.Server.Disposal.Unit.Components; using Content.Server.Disposal.Unit.EntitySystems; -using Content.Shared.Acts; using Content.Shared.Construction.Components; using Content.Shared.Disposal.Components; using Content.Shared.Popups; @@ -18,7 +17,7 @@ using Robust.Shared.ViewVariables; namespace Content.Server.Disposal.Tube.Components { - public abstract class DisposalTubeComponent : Component, IDisposalTubeComponent, IBreakAct + public abstract class DisposalTubeComponent : Component, IDisposalTubeComponent { [Dependency] private readonly IEntityManager _entMan = default!; @@ -73,7 +72,7 @@ namespace Content.Server.Disposal.Tube.Components return true; } - private void Disconnect() + public void Disconnect() { if (!_connected) { @@ -108,7 +107,7 @@ namespace Content.Server.Disposal.Tube.Components } var state = Anchored - ? DisposalTubeVisualState.Anchored + ? DisposalTubeVisualState.Anchored : DisposalTubeVisualState.Free; appearance.SetData(DisposalTubeVisuals.VisualState, state); @@ -171,10 +170,5 @@ namespace Content.Server.Disposal.Tube.Components Disconnect(); } - - void IBreakAct.OnBreak(BreakageEventArgs eventArgs) - { - Disconnect(); - } } } diff --git a/Content.Server/Disposal/Tube/DisposalTubeSystem.cs b/Content.Server/Disposal/Tube/DisposalTubeSystem.cs index ae48f8b98b..126de2783f 100644 --- a/Content.Server/Disposal/Tube/DisposalTubeSystem.cs +++ b/Content.Server/Disposal/Tube/DisposalTubeSystem.cs @@ -1,6 +1,7 @@ using Content.Server.Disposal.Tube.Components; using Content.Server.UserInterface; using Content.Server.Hands.Components; +using Content.Shared.Destructible; using Content.Shared.Movement; using Content.Shared.Verbs; using Content.Shared.Popups; @@ -23,6 +24,7 @@ namespace Content.Server.Disposal.Tube SubscribeLocalEvent(BodyTypeChanged); SubscribeLocalEvent(OnRelayMovement); + SubscribeLocalEvent(OnBreak); SubscribeLocalEvent>(AddOpenUIVerbs); SubscribeLocalEvent>(AddOpenUIVerbs); SubscribeLocalEvent(OnOpenRouterUIAttempt); @@ -73,6 +75,11 @@ namespace Content.Server.Disposal.Tube SoundSystem.Play(Filter.Pvs(uid), component.ClangSound.GetSound(), uid); } + private void OnBreak(EntityUid uid, DisposalTubeComponent component, BreakageEventArgs args) + { + component.Disconnect(); + } + private void OnOpenRouterUIAttempt(EntityUid uid, DisposalRouterComponent router, ActivatableUIOpenAttemptEvent args) { if (!TryComp(args.User, out var hands)) diff --git a/Content.Server/Disposal/Unit/EntitySystems/DisposalUnitSystem.cs b/Content.Server/Disposal/Unit/EntitySystems/DisposalUnitSystem.cs index 4adcadfd3b..c40b7adc28 100644 --- a/Content.Server/Disposal/Unit/EntitySystems/DisposalUnitSystem.cs +++ b/Content.Server/Disposal/Unit/EntitySystems/DisposalUnitSystem.cs @@ -10,9 +10,9 @@ using Content.Server.Hands.Components; using Content.Server.Power.Components; using Content.Server.UserInterface; using Content.Shared.ActionBlocker; -using Content.Shared.Acts; using Content.Shared.Atmos; using Content.Shared.Construction.Components; +using Content.Shared.Destructible; using Content.Shared.Disposal; using Content.Shared.Disposal.Components; using Content.Shared.DragDrop; diff --git a/Content.Server/Kitchen/Components/MicrowaveComponent.cs b/Content.Server/Kitchen/Components/MicrowaveComponent.cs index fdd366739e..bd1d6966e9 100644 --- a/Content.Server/Kitchen/Components/MicrowaveComponent.cs +++ b/Content.Server/Kitchen/Components/MicrowaveComponent.cs @@ -8,7 +8,6 @@ using Content.Server.Power.Components; using Content.Server.Temperature.Components; using Content.Server.Temperature.Systems; using Content.Server.UserInterface; -using Content.Shared.Acts; using Content.Shared.Body.Components; using Content.Shared.Body.Part; using Content.Shared.FixedPoint; @@ -26,7 +25,7 @@ using Robust.Shared.Player; namespace Content.Server.Kitchen.Components { [RegisterComponent] - public sealed class MicrowaveComponent : SharedMicrowaveComponent, ISuicideAct, IBreakAct + public sealed class MicrowaveComponent : SharedMicrowaveComponent, ISuicideAct { [Dependency] private readonly IEntityManager _entities = default!; @@ -178,7 +177,7 @@ namespace Content.Server.Kitchen.Components } } - private void SetAppearance(MicrowaveVisualState state) + public void SetAppearance(MicrowaveVisualState state) { var finalState = state; if (Broken) @@ -192,11 +191,6 @@ namespace Content.Server.Kitchen.Components } } - public void OnBreak(BreakageEventArgs eventArgs) - { - Broken = true; - SetAppearance(MicrowaveVisualState.Broken); - } // ReSharper disable once InconsistentNaming // ReSharper disable once IdentifierTypo private void Wzhzhzh() diff --git a/Content.Server/Kitchen/EntitySystems/MicrowaveSystem.cs b/Content.Server/Kitchen/EntitySystems/MicrowaveSystem.cs index 54eb31f412..288b3b2ff5 100644 --- a/Content.Server/Kitchen/EntitySystems/MicrowaveSystem.cs +++ b/Content.Server/Kitchen/EntitySystems/MicrowaveSystem.cs @@ -1,8 +1,10 @@ using Content.Server.Chemistry.EntitySystems; using Content.Server.Kitchen.Components; using Content.Server.Popups; +using Content.Shared.Destructible; using Content.Shared.Interaction; using Content.Shared.Item; +using Content.Shared.Kitchen.Components; using Robust.Shared.Player; using JetBrains.Annotations; @@ -18,6 +20,7 @@ namespace Content.Server.Kitchen.EntitySystems SubscribeLocalEvent(OnSolutionChange); SubscribeLocalEvent(OnInteractUsing); + SubscribeLocalEvent(OnBreak); } private void OnSolutionChange(EntityUid uid, MicrowaveComponent component, SolutionChangedEvent args) @@ -57,5 +60,11 @@ namespace Content.Server.Kitchen.EntitySystems component.Storage.Insert(args.Used); component.DirtyUi(); } + + private void OnBreak(EntityUid uid, MicrowaveComponent component, BreakageEventArgs args) + { + component.Broken = true; + component.SetAppearance(MicrowaveVisualState.Broken); + } } } diff --git a/Content.Server/Light/Components/LightBulbComponent.cs b/Content.Server/Light/Components/LightBulbComponent.cs index 82a7112076..3f09e7a717 100644 --- a/Content.Server/Light/Components/LightBulbComponent.cs +++ b/Content.Server/Light/Components/LightBulbComponent.cs @@ -1,5 +1,4 @@ using Content.Server.Light.EntitySystems; -using Content.Shared.Acts; using Content.Shared.Light; using Content.Shared.Sound; using Robust.Shared.Analyzers; @@ -13,7 +12,7 @@ namespace Content.Server.Light.Components /// Component that represents a light bulb. Can be broken, or burned, which turns them mostly useless. /// [RegisterComponent, Friend(typeof(LightBulbSystem))] - public sealed class LightBulbComponent : Component, IBreakAct + public sealed class LightBulbComponent : Component { [DataField("color")] public Color Color = Color.White; @@ -41,12 +40,5 @@ namespace Content.Server.Light.Components [DataField("breakSound")] public SoundSpecifier BreakSound = new SoundCollectionSpecifier("GlassBreak"); - - // TODO: move me to ECS - public void OnBreak(BreakageEventArgs eventArgs) - { - EntitySystem.Get() - .SetState(Owner, LightBulbState.Broken, this); - } } } diff --git a/Content.Server/Light/EntitySystems/LightBulbSystem.cs b/Content.Server/Light/EntitySystems/LightBulbSystem.cs index b4e2880b28..91b8a6c1d7 100644 --- a/Content.Server/Light/EntitySystems/LightBulbSystem.cs +++ b/Content.Server/Light/EntitySystems/LightBulbSystem.cs @@ -1,10 +1,8 @@ using Content.Server.Light.Components; -using Content.Server.Light.Events; +using Content.Shared.Destructible; using Content.Shared.Light; using Content.Shared.Throwing; using Robust.Shared.Audio; -using Robust.Shared.GameObjects; -using Robust.Shared.Maths; using Robust.Shared.Player; namespace Content.Server.Light.EntitySystems @@ -17,6 +15,7 @@ namespace Content.Server.Light.EntitySystems SubscribeLocalEvent(OnInit); SubscribeLocalEvent(HandleLand); + SubscribeLocalEvent(OnBreak); } private void OnInit(EntityUid uid, LightBulbComponent bulb, ComponentInit args) @@ -32,6 +31,11 @@ namespace Content.Server.Light.EntitySystems SetState(uid, LightBulbState.Broken, bulb); } + private void OnBreak(EntityUid uid, LightBulbComponent component, BreakageEventArgs args) + { + SetState(uid, LightBulbState.Broken, component); + } + /// /// Set a new color for a light bulb and raise event about change /// diff --git a/Content.Server/Medical/MedicalScannerSystem.cs b/Content.Server/Medical/MedicalScannerSystem.cs index a2c06f756b..873f13fd00 100644 --- a/Content.Server/Medical/MedicalScannerSystem.cs +++ b/Content.Server/Medical/MedicalScannerSystem.cs @@ -6,9 +6,9 @@ using Content.Server.Popups; using Content.Server.Power.Components; using Content.Server.Preferences.Managers; using Content.Shared.ActionBlocker; -using Content.Shared.Acts; using Content.Shared.CharacterAppearance.Components; using Content.Shared.Damage; +using Content.Shared.Destructible; using Content.Shared.DragDrop; using Content.Shared.Interaction; using Content.Shared.MobState.Components; diff --git a/Content.Server/Storage/Components/EntityStorageComponent.cs b/Content.Server/Storage/Components/EntityStorageComponent.cs index d247df22d2..484740399c 100644 --- a/Content.Server/Storage/Components/EntityStorageComponent.cs +++ b/Content.Server/Storage/Components/EntityStorageComponent.cs @@ -5,8 +5,8 @@ using System.Threading.Tasks; using Content.Server.Construction; using Content.Server.Construction.Components; using Content.Server.Ghost.Components; +using Content.Server.Storage.EntitySystems; using Content.Server.Tools; -using Content.Shared.Acts; using Content.Shared.Body.Components; using Content.Shared.Foldable; using Content.Shared.Interaction; @@ -29,7 +29,7 @@ namespace Content.Server.Storage.Components [Virtual] [ComponentReference(typeof(IActivate))] [ComponentReference(typeof(IStorageComponent))] - public class EntityStorageComponent : Component, IActivate, IStorageComponent, IInteractUsing, IDestroyAct + public class EntityStorageComponent : Component, IActivate, IStorageComponent, IInteractUsing { [Dependency] private readonly IEntityManager _entMan = default!; @@ -70,7 +70,7 @@ namespace Content.Server.Storage.Components private bool _occludesLight = true; [DataField("open")] - private bool _open; + public bool Open; [DataField("weldingQuality", customTypeSerializer:typeof(PrototypeIdSerializer))] private string _weldingQuality = "Welding"; @@ -115,13 +115,6 @@ namespace Content.Server.Storage.Components } } - [ViewVariables(VVAccess.ReadWrite)] - public bool Open - { - get => _open; - private set => _open = value; - } - [ViewVariables(VVAccess.ReadWrite)] public bool IsWeldedShut { @@ -298,7 +291,7 @@ namespace Content.Server.Storage.Components protected virtual void OpenStorage() { Open = true; - EmptyContents(); + EntitySystem.Get().EmptyContents(Owner, this); ModifyComponents(); SoundSystem.Play(Filter.Pvs(Owner), _openSound.GetSound(), Owner); } @@ -366,21 +359,6 @@ namespace Content.Server.Storage.Components return _entMan.GetComponent(Owner).WorldPosition; } - private void EmptyContents() - { - foreach (var contained in Contents.ContainedEntities.ToArray()) - { - if (Contents.Remove(contained)) - { - _entMan.GetComponent(contained).WorldPosition = ContentsDumpPosition(); - if (_entMan.TryGetComponent(contained, out var physics)) - { - physics.CanCollide = true; - } - } - } - } - public virtual bool TryOpenStorage(EntityUid user) { if (!CanOpen(user)) return false; @@ -473,12 +451,6 @@ namespace Content.Server.Storage.Components return true; } - void IDestroyAct.OnDestroy(DestructionEventArgs eventArgs) - { - Open = true; - EmptyContents(); - } - protected virtual IEnumerable DetermineCollidingEntities() { var entityLookup = EntitySystem.Get(); diff --git a/Content.Server/Storage/EntitySystems/EntityStorageSystem.cs b/Content.Server/Storage/EntitySystems/EntityStorageSystem.cs new file mode 100644 index 0000000000..e4895bf5dc --- /dev/null +++ b/Content.Server/Storage/EntitySystems/EntityStorageSystem.cs @@ -0,0 +1,40 @@ +using System.Linq; +using Content.Server.Storage.Components; +using Content.Shared.Destructible; +using Robust.Shared.Physics; + +namespace Content.Server.Storage.EntitySystems; + +public sealed class EntityStorageSystem : EntitySystem +{ + public override void Initialize() + { + base.Initialize(); + SubscribeLocalEvent(OnDestroy); + } + + private void OnDestroy(EntityUid uid, EntityStorageComponent component, DestructionEventArgs args) + { + component.Open = true; + EmptyContents(uid, component); + } + + public void EmptyContents(EntityUid uid, EntityStorageComponent? component = null) + { + if (!Resolve(uid, ref component)) + return; + + var containedArr = component.Contents.ContainedEntities.ToArray(); + foreach (var contained in containedArr) + { + if (component.Contents.Remove(contained)) + { + Transform(contained).WorldPosition = component.ContentsDumpPosition(); + if (TryComp(contained, out IPhysBody? physics)) + { + physics.CanCollide = true; + } + } + } + } +} diff --git a/Content.Server/Storage/EntitySystems/SecretStashSystem.cs b/Content.Server/Storage/EntitySystems/SecretStashSystem.cs index 012366d80e..5ffebe988e 100644 --- a/Content.Server/Storage/EntitySystems/SecretStashSystem.cs +++ b/Content.Server/Storage/EntitySystems/SecretStashSystem.cs @@ -1,6 +1,6 @@ using Content.Server.Popups; using Content.Server.Storage.Components; -using Content.Shared.Acts; +using Content.Shared.Destructible; using Content.Shared.Hands.Components; using Content.Shared.Hands.EntitySystems; using Content.Shared.Item; diff --git a/Content.Server/Storage/EntitySystems/StorageSystem.cs b/Content.Server/Storage/EntitySystems/StorageSystem.cs index 62e579a5f9..ac1da00792 100644 --- a/Content.Server/Storage/EntitySystems/StorageSystem.cs +++ b/Content.Server/Storage/EntitySystems/StorageSystem.cs @@ -17,7 +17,6 @@ using Robust.Shared.Utility; using System.Threading; using Content.Server.DoAfter; using Content.Server.Interaction; -using Content.Shared.Acts; using Content.Shared.Hands.EntitySystems; using Content.Shared.Item; using Content.Shared.Placeable; @@ -28,6 +27,7 @@ using Robust.Shared.Map; using Robust.Shared.Player; using Robust.Server.Containers; using Content.Server.Popups; +using Content.Shared.Destructible; using static Content.Shared.Storage.SharedStorageComponent; namespace Content.Server.Storage.EntitySystems diff --git a/Content.Server/VendingMachines/VendingMachineSystem.cs b/Content.Server/VendingMachines/VendingMachineSystem.cs index c6c18dccf4..15acb8ec20 100644 --- a/Content.Server/VendingMachines/VendingMachineSystem.cs +++ b/Content.Server/VendingMachines/VendingMachineSystem.cs @@ -9,7 +9,7 @@ using Content.Shared.VendingMachines; using Robust.Server.GameObjects; using Robust.Shared.Prototypes; using Robust.Shared.Random; -using Content.Shared.Acts; +using Content.Shared.Destructible; using Content.Shared.Emag.Systems; using static Content.Shared.VendingMachines.SharedVendingMachineComponent; using Content.Shared.Throwing; @@ -21,7 +21,7 @@ namespace Content.Server.VendingMachines.systems [Dependency] private readonly IRobustRandom _random = default!; [Dependency] private readonly IPrototypeManager _prototypeManager = default!; [Dependency] private readonly AccessReaderSystem _accessReader = default!; - [Dependency] private readonly PopupSystem _popupSystem = default!; + [Dependency] private readonly PopupSystem _popupSystem = default!; [Dependency] private readonly ThrowingSystem _throwingSystem = default!; public override void Initialize() diff --git a/Content.Shared/Acts/ActSystem.cs b/Content.Shared/Acts/ActSystem.cs deleted file mode 100644 index 7527db0678..0000000000 --- a/Content.Shared/Acts/ActSystem.cs +++ /dev/null @@ -1,61 +0,0 @@ -using System; -using System.Linq; -using JetBrains.Annotations; -using Robust.Shared.GameObjects; -using Robust.Shared.Map; - -namespace Content.Shared.Acts -{ - /// - /// This interface gives components behavior on getting destroyed. - /// - public interface IDestroyAct - { - /// - /// Called when object is destroyed - /// - void OnDestroy(DestructionEventArgs eventArgs); - } - - public sealed class DestructionEventArgs : EntityEventArgs { } - - public sealed class BreakageEventArgs : EntityEventArgs { } - - public interface IBreakAct - { - /// - /// Called when object is broken - /// - void OnBreak(BreakageEventArgs eventArgs); - } - - [UsedImplicitly] - public sealed class ActSystem : EntitySystem - { - public void HandleDestruction(EntityUid owner) - { - var eventArgs = new DestructionEventArgs(); - - RaiseLocalEvent(owner, eventArgs, false); - var destroyActs = EntityManager.GetComponents(owner).ToList(); - - foreach (var destroyAct in destroyActs) - { - destroyAct.OnDestroy(eventArgs); - } - - QueueDel(owner); - } - - public void HandleBreakage(EntityUid owner) - { - var eventArgs = new BreakageEventArgs(); - RaiseLocalEvent(owner, eventArgs, false); - var breakActs = EntityManager.GetComponents(owner).ToList(); - foreach (var breakAct in breakActs) - { - breakAct.OnBreak(eventArgs); - } - } - } -} diff --git a/Content.Shared/Containers/ItemSlot/ItemSlotsSystem.cs b/Content.Shared/Containers/ItemSlot/ItemSlotsSystem.cs index d0d5cfef93..b872af8b53 100644 --- a/Content.Shared/Containers/ItemSlot/ItemSlotsSystem.cs +++ b/Content.Shared/Containers/ItemSlot/ItemSlotsSystem.cs @@ -1,5 +1,4 @@ using Content.Shared.ActionBlocker; -using Content.Shared.Acts; using Content.Shared.Hands.Components; using Content.Shared.Hands.EntitySystems; using Content.Shared.Interaction; @@ -13,6 +12,7 @@ using Robust.Shared.GameStates; using Robust.Shared.Player; using Robust.Shared.Timing; using System.Diagnostics.CodeAnalysis; +using Content.Shared.Destructible; namespace Content.Shared.Containers.ItemSlots { diff --git a/Content.Shared/Destructible/SharedDestructibleSystem.cs b/Content.Shared/Destructible/SharedDestructibleSystem.cs new file mode 100644 index 0000000000..b16ededbe7 --- /dev/null +++ b/Content.Shared/Destructible/SharedDestructibleSystem.cs @@ -0,0 +1,40 @@ +namespace Content.Shared.Destructible; + +public abstract class SharedDestructibleSystem : EntitySystem +{ + /// + /// Force entity to be destroyed and deleted. + /// + public void DestroyEntity(EntityUid owner) + { + var eventArgs = new DestructionEventArgs(); + + RaiseLocalEvent(owner, eventArgs, false); + QueueDel(owner); + } + + /// + /// Force entity to broke. + /// + public void BreakEntity(EntityUid owner) + { + var eventArgs = new BreakageEventArgs(); + RaiseLocalEvent(owner, eventArgs, false); + } +} + +/// +/// Raised when entity is destroyed and about to be deleted. +/// +public sealed class DestructionEventArgs : EntityEventArgs +{ + +} + +/// +/// Raised when entity was heavy damage and about to break. +/// +public sealed class BreakageEventArgs : EntityEventArgs +{ + +}