diff --git a/Content.Server/Construction/Completions/RaiseEvent.cs b/Content.Server/Construction/Completions/RaiseEvent.cs new file mode 100644 index 0000000000..f4a5f962f6 --- /dev/null +++ b/Content.Server/Construction/Completions/RaiseEvent.cs @@ -0,0 +1,32 @@ +using Content.Shared.Construction; +using JetBrains.Annotations; +using Robust.Shared.GameObjects; +using Robust.Shared.Serialization.Manager.Attributes; + +namespace Content.Server.Construction.Completions +{ + [UsedImplicitly] + public class RaiseEvent : IGraphAction + { + [DataField("event", required:true)] + public EntityEventArgs? Event { get; } = null; + + [DataField("directed")] + public bool Directed { get; } = true; + + [DataField("broadcast")] + public bool Broadcast { get; } = true; + + public void PerformAction(EntityUid uid, EntityUid? userUid, IEntityManager entityManager) + { + if (Event == null || !Directed && !Broadcast) + return; + + if(Directed) + entityManager.EventBus.RaiseLocalEvent(uid, (object)Event, false); + + if(Broadcast) + entityManager.EventBus.RaiseEvent(EventSource.Local, (object)Event); + } + } +} diff --git a/Content.Server/Construction/Components/MachineFrameComponent.cs b/Content.Server/Construction/Components/MachineFrameComponent.cs index 0f85261070..34bb43b867 100644 --- a/Content.Server/Construction/Components/MachineFrameComponent.cs +++ b/Content.Server/Construction/Components/MachineFrameComponent.cs @@ -8,6 +8,7 @@ using Robust.Server.GameObjects; using Robust.Shared.Containers; using Robust.Shared.GameObjects; using Robust.Shared.IoC; +using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.ViewVariables; namespace Content.Server.Construction.Components @@ -357,4 +358,9 @@ namespace Content.Server.Construction.Components return false; } } + + [DataDefinition] + public class MachineDeconstructedEvent : EntityEventArgs + { + } } diff --git a/Resources/Prototypes/Recipes/Construction/Graphs/machine.yml b/Resources/Prototypes/Recipes/Construction/Graphs/machine.yml index d18c4ac6dd..93a7535235 100644 --- a/Resources/Prototypes/Recipes/Construction/Graphs/machine.yml +++ b/Resources/Prototypes/Recipes/Construction/Graphs/machine.yml @@ -81,6 +81,10 @@ container: machine_board edges: - to: machineFrame + completed: + - !type:RaiseEvent + event: !type:MachineDeconstructedEvent + broadcast: false conditions: - !type:EntityAnchored - !type:WirePanel