From: Leon Friedrich <60421075+ElectroJr@users.noreply.github.com> Date: Sat, 8 Apr 2023 00:54:28 +0000 (+1200) Subject: Fix computer deconstruction (#15187) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=507b0d73204805a971f45f9ec37e2dc8b4eb8546;p=space-station-14.git Fix computer deconstruction (#15187) --- diff --git a/Content.Server/Construction/Components/ConstructionComponent.cs b/Content.Server/Construction/Components/ConstructionComponent.cs index 08ffb99fe8..193c644da8 100644 --- a/Content.Server/Construction/Components/ConstructionComponent.cs +++ b/Content.Server/Construction/Components/ConstructionComponent.cs @@ -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). diff --git a/Content.Server/Construction/ConstructionSystem.Interactions.cs b/Content.Server/Construction/ConstructionSystem.Interactions.cs index 0a9d3c543b..e2f538b27f 100644 --- a/Content.Server/Construction/ConstructionSystem.Interactions.cs +++ b/Content.Server/Construction/ConstructionSystem.Interactions.cs @@ -31,20 +31,13 @@ namespace Content.Server.Construction private void InitializeInteractions() { - SubscribeLocalEvent(OnDoAfterComplete); + SubscribeLocalEvent(EnqueueEvent); // Event handling. Add your subscriptions here! Just make sure they're all handled by EnqueueEvent. SubscribeLocalEvent(EnqueueEvent, new []{typeof(AnchorableSystem), typeof(EncryptionKeySystem)}); SubscribeLocalEvent(EnqueueEvent); } - private void OnDoAfterComplete(EntityUid uid, ConstructionComponent component, ConstructionInteractDoAfterEvent args) - { - component.DoAfter = null; - if (!args.Cancelled) - EnqueueEvent(uid, component, args); - } - /// /// Takes in an entity with 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: