]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix computer deconstruction (#15187)
authorLeon Friedrich <60421075+ElectroJr@users.noreply.github.com>
Sat, 8 Apr 2023 00:54:28 +0000 (12:54 +1200)
committerGitHub <noreply@github.com>
Sat, 8 Apr 2023 00:54:28 +0000 (10:54 +1000)
Content.Server/Construction/Components/ConstructionComponent.cs
Content.Server/Construction/ConstructionSystem.Interactions.cs

index 08ffb99fe84325535e62bc111e181b759da2cdd2..193c644da8740b5def4c5e2db688a8795bd751c3 100644 (file)
@@ -34,9 +34,6 @@ namespace Content.Server.Construction.Components
         [DataField("deconstructionTarget")]
         public string? DeconstructionNode { get; set; } = "start";
 
-        [DataField("doAfter")]
-        public DoAfterId? DoAfter;
-
         [ViewVariables]
         // TODO Force flush interaction queue before serializing to YAML.
         // Otherwise you can end up with entities stuck in invalid states (e.g., waiting for DoAfters).
index 0a9d3c543bd8ccb33e7c839d95766bb46cd907ff..e2f538b27f43edb64cde5a6e71e810b6f8040a37 100644 (file)
@@ -31,20 +31,13 @@ namespace Content.Server.Construction
 
         private void InitializeInteractions()
         {
-            SubscribeLocalEvent<ConstructionComponent, ConstructionInteractDoAfterEvent>(OnDoAfterComplete);
+            SubscribeLocalEvent<ConstructionComponent, ConstructionInteractDoAfterEvent>(EnqueueEvent);
 
             // Event handling. Add your subscriptions here! Just make sure they're all handled by EnqueueEvent.
             SubscribeLocalEvent<ConstructionComponent, InteractUsingEvent>(EnqueueEvent, new []{typeof(AnchorableSystem), typeof(EncryptionKeySystem)});
             SubscribeLocalEvent<ConstructionComponent, OnTemperatureChangeEvent>(EnqueueEvent);
         }
 
-        private void OnDoAfterComplete(EntityUid uid, ConstructionComponent component, ConstructionInteractDoAfterEvent args)
-        {
-            component.DoAfter = null;
-            if (!args.Cancelled)
-                EnqueueEvent(uid, component, args);
-        }
-
         /// <summary>
         ///     Takes in an entity with <see cref="ConstructionComponent"/> and an object event, and handles any
         ///     possible construction interactions, depending on the construction's state.
@@ -231,8 +224,8 @@ namespace Content.Server.Construction
             // The DoAfter events can only perform special logic when we're not validating events.
             if (ev is ConstructionInteractDoAfterEvent interactDoAfter)
             {
-                // cancelled events should not reach this point.
-                DebugTools.Assert(!interactDoAfter.Cancelled);
+                if (interactDoAfter.Cancelled)
+                    return HandleResult.False;
 
                 ev = new InteractUsingEvent(
                     interactDoAfter.User,
@@ -289,7 +282,7 @@ namespace Content.Server.Construction
                             NeedHand = true
                         };
 
-                        var started  = _doAfterSystem.TryStartDoAfter(doAfterEventArgs, out construction.DoAfter);
+                        var started  = _doAfterSystem.TryStartDoAfter(doAfterEventArgs);
 
                         if (!started)
                             return HandleResult.False;
@@ -367,10 +360,10 @@ namespace Content.Server.Construction
                         TimeSpan.FromSeconds(toolInsertStep.DoAfter),
                         new [] { toolInsertStep.Tool },
                         new ConstructionInteractDoAfterEvent(interactUsing),
-                        out construction.DoAfter,
+                        out var doAfter,
                         fuel: toolInsertStep.Fuel);
 
-                    return construction.DoAfter != null ? HandleResult.DoAfter : HandleResult.False;
+                    return result && doAfter != null ? HandleResult.DoAfter : HandleResult.False;
                 }
 
                 case TemperatureConstructionGraphStep temperatureChangeStep: