]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix Fultons losing their beacon when split (#20179)
authorDrSmugleaf <DrSmugleaf@users.noreply.github.com>
Mon, 18 Sep 2023 00:22:26 +0000 (17:22 -0700)
committerGitHub <noreply@github.com>
Mon, 18 Sep 2023 00:22:26 +0000 (20:22 -0400)
Content.Server/Stack/StackSystem.cs
Content.Shared/Salvage/Fulton/FultonComponent.cs
Content.Shared/Salvage/Fulton/SharedFultonSystem.cs
Content.Shared/Stacks/StackSplitEvent.cs [new file with mode: 0644]

index 4fc50ce595d4d078f7f4276fc8dfee11a17e1467..f49e02ab9aa765562b173fd3a0628b072bb35dec 100644 (file)
@@ -70,6 +70,9 @@ namespace Content.Server.Stack
                 stackComp.Unlimited = false;
             }
 
+            var ev = new StackSplitEvent(entity);
+            RaiseLocalEvent(uid, ref ev);
+
             return entity;
         }
 
index 54936367768e3d9bc2a15b5cf6e0e2d8e7ed79e9..b3a0d4619308523aaf16a7ccba38c7ed5d4d1dc8 100644 (file)
@@ -19,7 +19,7 @@ public sealed partial class FultonComponent : Component
     /// <summary>
     /// Linked fulton beacon.
     /// </summary>
-    [ViewVariables(VVAccess.ReadWrite), DataField("beacon")]
+    [ViewVariables(VVAccess.ReadWrite), DataField("beacon"), AutoNetworkedField]
     public EntityUid? Beacon;
 
     /// <summary>
index 6814bbb3c76cf8f863238e3154fcccbe2039fc1f..cbc54c91e37a7fc431b5060e5668a1aa3ab2f8a3 100644 (file)
@@ -43,6 +43,8 @@ public abstract partial class SharedFultonSystem : EntitySystem
         SubscribeLocalEvent<FultonedComponent, EntGotInsertedIntoContainerMessage>(OnFultonContainerInserted);
 
         SubscribeLocalEvent<FultonComponent, AfterInteractEvent>(OnFultonInteract);
+
+        SubscribeLocalEvent<FultonComponent, StackSplitEvent>(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<FultonComponent>(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 (file)
index 0000000..11c8035
--- /dev/null
@@ -0,0 +1,8 @@
+namespace Content.Shared.Stacks;
+
+/// <summary>
+///     Raised on the original stack entity when it is split to create another.
+/// </summary>
+/// <param name="NewId">The entity id of the new stack.</param>
+[ByRefEvent]
+public readonly record struct StackSplitEvent(EntityUid NewId);