Fix computer deconstruction (#15187)
This commit is contained in:
@@ -34,9 +34,6 @@ namespace Content.Server.Construction.Components
|
|||||||
[DataField("deconstructionTarget")]
|
[DataField("deconstructionTarget")]
|
||||||
public string? DeconstructionNode { get; set; } = "start";
|
public string? DeconstructionNode { get; set; } = "start";
|
||||||
|
|
||||||
[DataField("doAfter")]
|
|
||||||
public DoAfterId? DoAfter;
|
|
||||||
|
|
||||||
[ViewVariables]
|
[ViewVariables]
|
||||||
// TODO Force flush interaction queue before serializing to YAML.
|
// 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).
|
// 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()
|
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.
|
// 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, InteractUsingEvent>(EnqueueEvent, new []{typeof(AnchorableSystem), typeof(EncryptionKeySystem)});
|
||||||
SubscribeLocalEvent<ConstructionComponent, OnTemperatureChangeEvent>(EnqueueEvent);
|
SubscribeLocalEvent<ConstructionComponent, OnTemperatureChangeEvent>(EnqueueEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnDoAfterComplete(EntityUid uid, ConstructionComponent component, ConstructionInteractDoAfterEvent args)
|
|
||||||
{
|
|
||||||
component.DoAfter = null;
|
|
||||||
if (!args.Cancelled)
|
|
||||||
EnqueueEvent(uid, component, args);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Takes in an entity with <see cref="ConstructionComponent"/> and an object event, and handles any
|
/// Takes in an entity with <see cref="ConstructionComponent"/> and an object event, and handles any
|
||||||
/// possible construction interactions, depending on the construction's state.
|
/// 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.
|
// The DoAfter events can only perform special logic when we're not validating events.
|
||||||
if (ev is ConstructionInteractDoAfterEvent interactDoAfter)
|
if (ev is ConstructionInteractDoAfterEvent interactDoAfter)
|
||||||
{
|
{
|
||||||
// cancelled events should not reach this point.
|
if (interactDoAfter.Cancelled)
|
||||||
DebugTools.Assert(!interactDoAfter.Cancelled);
|
return HandleResult.False;
|
||||||
|
|
||||||
ev = new InteractUsingEvent(
|
ev = new InteractUsingEvent(
|
||||||
interactDoAfter.User,
|
interactDoAfter.User,
|
||||||
@@ -289,7 +282,7 @@ namespace Content.Server.Construction
|
|||||||
NeedHand = true
|
NeedHand = true
|
||||||
};
|
};
|
||||||
|
|
||||||
var started = _doAfterSystem.TryStartDoAfter(doAfterEventArgs, out construction.DoAfter);
|
var started = _doAfterSystem.TryStartDoAfter(doAfterEventArgs);
|
||||||
|
|
||||||
if (!started)
|
if (!started)
|
||||||
return HandleResult.False;
|
return HandleResult.False;
|
||||||
@@ -367,10 +360,10 @@ namespace Content.Server.Construction
|
|||||||
TimeSpan.FromSeconds(toolInsertStep.DoAfter),
|
TimeSpan.FromSeconds(toolInsertStep.DoAfter),
|
||||||
new [] { toolInsertStep.Tool },
|
new [] { toolInsertStep.Tool },
|
||||||
new ConstructionInteractDoAfterEvent(interactUsing),
|
new ConstructionInteractDoAfterEvent(interactUsing),
|
||||||
out construction.DoAfter,
|
out var doAfter,
|
||||||
fuel: toolInsertStep.Fuel);
|
fuel: toolInsertStep.Fuel);
|
||||||
|
|
||||||
return construction.DoAfter != null ? HandleResult.DoAfter : HandleResult.False;
|
return result && doAfter != null ? HandleResult.DoAfter : HandleResult.False;
|
||||||
}
|
}
|
||||||
|
|
||||||
case TemperatureConstructionGraphStep temperatureChangeStep:
|
case TemperatureConstructionGraphStep temperatureChangeStep:
|
||||||
|
|||||||
Reference in New Issue
Block a user