From c558f00a747b6a681327ee842e1f1c2f6bde67ae Mon Sep 17 00:00:00 2001 From: DrSmugleaf Date: Sun, 17 Sep 2023 17:22:26 -0700 Subject: [PATCH] Fix Fultons losing their beacon when split (#20179) --- Content.Server/Stack/StackSystem.cs | 3 +++ Content.Shared/Salvage/Fulton/FultonComponent.cs | 2 +- Content.Shared/Salvage/Fulton/SharedFultonSystem.cs | 9 +++++++++ Content.Shared/Stacks/StackSplitEvent.cs | 8 ++++++++ 4 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 Content.Shared/Stacks/StackSplitEvent.cs diff --git a/Content.Server/Stack/StackSystem.cs b/Content.Server/Stack/StackSystem.cs index 4fc50ce595..f49e02ab9a 100644 --- a/Content.Server/Stack/StackSystem.cs +++ b/Content.Server/Stack/StackSystem.cs @@ -70,6 +70,9 @@ namespace Content.Server.Stack stackComp.Unlimited = false; } + var ev = new StackSplitEvent(entity); + RaiseLocalEvent(uid, ref ev); + return entity; } diff --git a/Content.Shared/Salvage/Fulton/FultonComponent.cs b/Content.Shared/Salvage/Fulton/FultonComponent.cs index 5493636776..b3a0d46193 100644 --- a/Content.Shared/Salvage/Fulton/FultonComponent.cs +++ b/Content.Shared/Salvage/Fulton/FultonComponent.cs @@ -19,7 +19,7 @@ public sealed partial class FultonComponent : Component /// /// Linked fulton beacon. /// - [ViewVariables(VVAccess.ReadWrite), DataField("beacon")] + [ViewVariables(VVAccess.ReadWrite), DataField("beacon"), AutoNetworkedField] public EntityUid? Beacon; /// diff --git a/Content.Shared/Salvage/Fulton/SharedFultonSystem.cs b/Content.Shared/Salvage/Fulton/SharedFultonSystem.cs index 6814bbb3c7..cbc54c91e3 100644 --- a/Content.Shared/Salvage/Fulton/SharedFultonSystem.cs +++ b/Content.Shared/Salvage/Fulton/SharedFultonSystem.cs @@ -43,6 +43,8 @@ public abstract partial class SharedFultonSystem : EntitySystem SubscribeLocalEvent(OnFultonContainerInserted); SubscribeLocalEvent(OnFultonInteract); + + SubscribeLocalEvent(OnFultonSplit); } private void OnFultonContainerInserted(EntityUid uid, FultonedComponent component, EntGotInsertedIntoContainerMessage args) @@ -161,6 +163,13 @@ public abstract partial class SharedFultonSystem : EntitySystem }); } + private void OnFultonSplit(EntityUid uid, FultonComponent component, ref StackSplitEvent args) + { + var newFulton = EnsureComp(args.NewId); + newFulton.Beacon = component.Beacon; + Dirty(args.NewId, newFulton); + } + protected virtual void UpdateAppearance(EntityUid uid, FultonedComponent fultoned) { return; diff --git a/Content.Shared/Stacks/StackSplitEvent.cs b/Content.Shared/Stacks/StackSplitEvent.cs new file mode 100644 index 0000000000..11c803509e --- /dev/null +++ b/Content.Shared/Stacks/StackSplitEvent.cs @@ -0,0 +1,8 @@ +namespace Content.Shared.Stacks; + +/// +/// Raised on the original stack entity when it is split to create another. +/// +/// The entity id of the new stack. +[ByRefEvent] +public readonly record struct StackSplitEvent(EntityUid NewId); -- 2.51.2