Fixed wires do after spam (#12792)
This commit is contained in:
@@ -62,6 +62,13 @@ public sealed class WiresComponent : Component
|
|||||||
[DataField("alwaysRandomize")]
|
[DataField("alwaysRandomize")]
|
||||||
public bool AlwaysRandomize { get; }
|
public bool AlwaysRandomize { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Marks if maintenance panel being open/closed by someone with a screwdriver.
|
||||||
|
/// Prevents do after spam.
|
||||||
|
/// </summary>
|
||||||
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
|
public bool IsScrewing;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Per wire status, keyed by an object.
|
/// Per wire status, keyed by an object.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ public sealed class WiresSystem : EntitySystem
|
|||||||
|
|
||||||
// this is a broadcast event
|
// this is a broadcast event
|
||||||
SubscribeLocalEvent<WireToolFinishedEvent>(OnToolFinished);
|
SubscribeLocalEvent<WireToolFinishedEvent>(OnToolFinished);
|
||||||
|
SubscribeLocalEvent<WireToolCanceledEvent>(OnToolCanceled);
|
||||||
SubscribeLocalEvent<WiresComponent, ComponentStartup>(OnWiresStartup);
|
SubscribeLocalEvent<WiresComponent, ComponentStartup>(OnWiresStartup);
|
||||||
SubscribeLocalEvent<WiresComponent, WiresActionMessage>(OnWiresActionMessage);
|
SubscribeLocalEvent<WiresComponent, WiresActionMessage>(OnWiresActionMessage);
|
||||||
SubscribeLocalEvent<WiresComponent, InteractUsingEvent>(OnInteractUsing);
|
SubscribeLocalEvent<WiresComponent, InteractUsingEvent>(OnInteractUsing);
|
||||||
@@ -462,9 +463,14 @@ public sealed class WiresSystem : EntitySystem
|
|||||||
args.Handled = true;
|
args.Handled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (_toolSystem.UseTool(args.Used, args.User, uid, 0f, ScrewTime, new string[]{ "Screwing" }, doAfterCompleteEvent:new WireToolFinishedEvent(uid), toolComponent:tool))
|
else if (!component.IsScrewing && _toolSystem.HasQuality(args.Used, "Screwing", tool))
|
||||||
{
|
{
|
||||||
args.Handled = true;
|
component.IsScrewing = _toolSystem.UseTool(args.Used, args.User, uid,
|
||||||
|
0f, ScrewTime, new[] { "Screwing" },
|
||||||
|
new WireToolFinishedEvent(uid),
|
||||||
|
new WireToolCanceledEvent(uid),
|
||||||
|
toolComponent: tool);
|
||||||
|
args.Handled = component.IsScrewing;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -473,6 +479,7 @@ public sealed class WiresSystem : EntitySystem
|
|||||||
if (!EntityManager.TryGetComponent(args.Target, out WiresComponent? component))
|
if (!EntityManager.TryGetComponent(args.Target, out WiresComponent? component))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
component.IsScrewing = false;
|
||||||
component.IsPanelOpen = !component.IsPanelOpen;
|
component.IsPanelOpen = !component.IsPanelOpen;
|
||||||
UpdateAppearance(args.Target);
|
UpdateAppearance(args.Target);
|
||||||
|
|
||||||
@@ -491,6 +498,14 @@ public sealed class WiresSystem : EntitySystem
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnToolCanceled(WireToolCanceledEvent ev)
|
||||||
|
{
|
||||||
|
if (!TryComp(ev.Target, out WiresComponent? component))
|
||||||
|
return;
|
||||||
|
|
||||||
|
component.IsScrewing = false;
|
||||||
|
}
|
||||||
|
|
||||||
private void OnExamine(EntityUid uid, WiresComponent component, ExaminedEvent args)
|
private void OnExamine(EntityUid uid, WiresComponent component, ExaminedEvent args)
|
||||||
{
|
{
|
||||||
args.PushMarkup(Loc.GetString(component.IsPanelOpen
|
args.PushMarkup(Loc.GetString(component.IsPanelOpen
|
||||||
@@ -911,6 +926,8 @@ public sealed class WiresSystem : EntitySystem
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public record struct WireToolCanceledEvent(EntityUid Target);
|
||||||
|
|
||||||
private sealed class OnWireDoAfterEvent : EntityEventArgs
|
private sealed class OnWireDoAfterEvent : EntityEventArgs
|
||||||
{
|
{
|
||||||
public EntityUid User { get; set; }
|
public EntityUid User { get; set; }
|
||||||
|
|||||||
Reference in New Issue
Block a user