Fix computer deconstruction (#15187)
This commit is contained in:
parent
3c06b87572
commit
507b0d7320
|
|
@ -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).
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Reference in New Issue