More DoAfter Changes (#14609)

* DoAfters

* Compact Clone()

* Fix mice and cuffables

* Try generalize attempt events

* moves climbabledoafter event to shared, fixes issue with climbable target

* Fix merge (cuffing)

* Make all events netserializable

* handful of doafter events moved

* moves the rest of the events to their respective shared folders

* Changes all mentions of server doafter to shared

* stop stripping cancellation

* fix merge errors

* draw paused doafters

* handle unpausing

* missing netserializable ref

* removes break on stun reference

* removes cuffing state reference

* Fix tools

* Fix door prying.

* Fix construction

* Fix dumping

* Fix wielding assert

* fix rev

* Fix test

* more test fixes

---------

Co-authored-by: keronshb <keronshb@live.com>
This commit is contained in:
Leon Friedrich
2023-04-03 13:13:48 +12:00
committed by GitHub
parent 9e66fac805
commit 19277a2276
170 changed files with 3042 additions and 2954 deletions

View File

@@ -1,10 +1,12 @@
using Content.Server.Administration.Logs;
using Content.Server.Tools.Components;
using Content.Shared.Database;
using Content.Shared.DoAfter;
using Content.Shared.Examine;
using Content.Shared.Interaction;
using Content.Shared.Tools;
using Content.Shared.Tools.Components;
using Content.Shared.Tools.Systems;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Systems;
@@ -22,7 +24,6 @@ public sealed class WeldableSystem : EntitySystem
base.Initialize();
SubscribeLocalEvent<WeldableComponent, InteractUsingEvent>(OnInteractUsing);
SubscribeLocalEvent<WeldableComponent, WeldFinishedEvent>(OnWeldFinished);
SubscribeLocalEvent<WeldableComponent, WeldCancelledEvent>(OnWeldCanceled);
SubscribeLocalEvent<LayerChangeOnWeldComponent, WeldableChangedEvent>(OnWeldChanged);
SubscribeLocalEvent<WeldableComponent, ExaminedEvent>(OnExamine);
}
@@ -47,9 +48,7 @@ public sealed class WeldableSystem : EntitySystem
return false;
// Basic checks
if (!component.Weldable || component.BeingWelded)
return false;
if (!_toolSystem.HasQuality(tool, component.WeldingQuality))
if (!component.Weldable)
return false;
// Other component systems
@@ -69,8 +68,8 @@ public sealed class WeldableSystem : EntitySystem
if (!CanWeld(uid, tool, user, component))
return false;
var toolEvData = new ToolEventData(new WeldFinishedEvent(user, tool), cancelledEv: new WeldCancelledEvent(),targetEntity: uid);
component.BeingWelded = _toolSystem.UseTool(tool, user, uid, component.WeldingTime.Seconds, new[] { component.WeldingQuality }, toolEvData, fuel: component.FuelConsumption);
if (!_toolSystem.UseTool(tool, user, uid, component.WeldingTime.Seconds, component.WeldingQuality, new WeldFinishedEvent(), fuel: component.FuelConsumption))
return false;
// Log attempt
_adminLogger.Add(LogType.Action, LogImpact.Low, $"{ToPrettyString(user):user} is {(component.IsWelded ? "un" : "")}welding {ToPrettyString(uid):target} at {Transform(uid).Coordinates:targetlocation}");
@@ -80,10 +79,11 @@ public sealed class WeldableSystem : EntitySystem
private void OnWeldFinished(EntityUid uid, WeldableComponent component, WeldFinishedEvent args)
{
component.BeingWelded = false;
if (args.Cancelled || args.Used == null)
return;
// Check if target is still valid
if (!CanWeld(uid, args.Tool, args.User, component))
if (!CanWeld(uid, args.Used.Value, args.User, component))
return;
component.IsWelded = !component.IsWelded;
@@ -95,11 +95,6 @@ public sealed class WeldableSystem : EntitySystem
_adminLogger.Add(LogType.Action, LogImpact.Low, $"{ToPrettyString(args.User):user} {(!component.IsWelded ? "un" : "")}welded {ToPrettyString(uid):target}");
}
private void OnWeldCanceled(EntityUid uid, WeldableComponent component, WeldCancelledEvent args)
{
component.BeingWelded = false;
}
private void OnWeldChanged(EntityUid uid, LayerChangeOnWeldComponent component, WeldableChangedEvent args)
{
if (!TryComp<FixturesComponent>(uid, out var fixtures))
@@ -148,30 +143,6 @@ public sealed class WeldableSystem : EntitySystem
return;
component.WeldingTime = time;
}
/// <summary>
/// Raised after welding do_after has finished. It doesn't guarantee success,
/// use <see cref="WeldableChangedEvent"/> to get updated status.
/// </summary>
private sealed class WeldFinishedEvent : EntityEventArgs
{
public readonly EntityUid User;
public readonly EntityUid Tool;
public WeldFinishedEvent(EntityUid user, EntityUid tool)
{
User = user;
Tool = tool;
}
}
/// <summary>
/// Raised when entity welding has failed.
/// </summary>
private sealed class WeldCancelledEvent : EntityEventArgs
{
}
}
/// <summary>