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:
@@ -1,7 +1,5 @@
|
||||
using System.Linq;
|
||||
using Content.Server.Chemistry.Components.SolutionManager;
|
||||
using Content.Server.Chemistry.EntitySystems;
|
||||
using Content.Server.DoAfter;
|
||||
using Content.Server.Fluids.Components;
|
||||
using Content.Server.Popups;
|
||||
using Content.Shared.Chemistry.Components;
|
||||
@@ -20,7 +18,7 @@ namespace Content.Server.Fluids.EntitySystems;
|
||||
[UsedImplicitly]
|
||||
public sealed class MoppingSystem : SharedMoppingSystem
|
||||
{
|
||||
[Dependency] private readonly DoAfterSystem _doAfterSystem = default!;
|
||||
[Dependency] private readonly SharedDoAfterSystem _doAfterSystem = default!;
|
||||
[Dependency] private readonly SpillableSystem _spillableSystem = default!;
|
||||
[Dependency] private readonly TagSystem _tagSystem = default!;
|
||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||
@@ -35,8 +33,8 @@ public sealed class MoppingSystem : SharedMoppingSystem
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<AbsorbentComponent, ComponentInit>(OnAbsorbentInit);
|
||||
SubscribeLocalEvent<AbsorbentComponent, AfterInteractEvent>(OnAfterInteract);
|
||||
SubscribeLocalEvent<AbsorbentComponent, AbsorbantDoAfterEvent>(OnDoAfter);
|
||||
SubscribeLocalEvent<AbsorbentComponent, SolutionChangedEvent>(OnAbsorbentSolutionChange);
|
||||
SubscribeLocalEvent<AbsorbentComponent, DoAfterEvent<AbsorbantData>>(OnDoAfter);
|
||||
}
|
||||
|
||||
private void OnAbsorbentInit(EntityUid uid, AbsorbentComponent component, ComponentInit args)
|
||||
@@ -256,48 +254,34 @@ public sealed class MoppingSystem : SharedMoppingSystem
|
||||
if (!component.InteractingEntities.Add(target))
|
||||
return;
|
||||
|
||||
var aborbantData = new AbsorbantData(targetSolution, msg, sfx, transferAmount);
|
||||
var ev = new AbsorbantDoAfterEvent(targetSolution, msg, sfx, transferAmount);
|
||||
|
||||
var doAfterArgs = new DoAfterEventArgs(user, delay, target: target, used:used)
|
||||
var doAfterArgs = new DoAfterArgs(user, delay, ev, used, target: target, used: used)
|
||||
{
|
||||
BreakOnUserMove = true,
|
||||
BreakOnStun = true,
|
||||
BreakOnDamage = true,
|
||||
MovementThreshold = 0.2f
|
||||
};
|
||||
|
||||
_doAfterSystem.DoAfter(doAfterArgs, aborbantData);
|
||||
_doAfterSystem.TryStartDoAfter(doAfterArgs);
|
||||
}
|
||||
|
||||
private void OnDoAfter(EntityUid uid, AbsorbentComponent component, DoAfterEvent<AbsorbantData> args)
|
||||
private void OnDoAfter(EntityUid uid, AbsorbentComponent component, AbsorbantDoAfterEvent args)
|
||||
{
|
||||
if (args.Args.Target == null)
|
||||
if (args.Target == null)
|
||||
return;
|
||||
|
||||
if (args.Cancelled)
|
||||
{
|
||||
//Remove the interacting entities or else it breaks the mop
|
||||
component.InteractingEntities.Remove(args.Args.Target.Value);
|
||||
return;
|
||||
}
|
||||
component.InteractingEntities.Remove(args.Target.Value);
|
||||
|
||||
if (args.Handled)
|
||||
if (args.Cancelled || args.Handled)
|
||||
return;
|
||||
|
||||
_audio.PlayPvs(args.AdditionalData.Sound, uid);
|
||||
_popups.PopupEntity(Loc.GetString(args.AdditionalData.Message, ("target", args.Args.Target.Value), ("used", uid)), uid);
|
||||
_solutionSystem.TryTransferSolution(args.Args.Target.Value, uid, args.AdditionalData.TargetSolution,
|
||||
AbsorbentComponent.SolutionName, args.AdditionalData.TransferAmount);
|
||||
component.InteractingEntities.Remove(args.Args.Target.Value);
|
||||
_audio.PlayPvs(args.Sound, uid);
|
||||
_popups.PopupEntity(Loc.GetString(args.Message, ("target", args.Target.Value), ("used", uid)), uid);
|
||||
_solutionSystem.TryTransferSolution(args.Target.Value, uid, args.TargetSolution,
|
||||
AbsorbentComponent.SolutionName, args.TransferAmount);
|
||||
component.InteractingEntities.Remove(args.Target.Value);
|
||||
|
||||
args.Handled = true;
|
||||
}
|
||||
|
||||
private record struct AbsorbantData(string TargetSolution, string Message, SoundSpecifier Sound, FixedPoint2 TransferAmount)
|
||||
{
|
||||
public readonly string TargetSolution = TargetSolution;
|
||||
public readonly string Message = Message;
|
||||
public readonly SoundSpecifier Sound = Sound;
|
||||
public readonly FixedPoint2 TransferAmount = TransferAmount;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using Content.Server.Administration.Logs;
|
||||
using Content.Server.Chemistry.EntitySystems;
|
||||
using Content.Server.DoAfter;
|
||||
using Content.Server.Fluids.Components;
|
||||
using Content.Server.Nutrition.Components;
|
||||
using Content.Shared.Chemistry.Components;
|
||||
@@ -17,6 +16,7 @@ using Robust.Shared.Prototypes;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using Content.Shared.DoAfter;
|
||||
using Content.Shared.Spillable;
|
||||
|
||||
namespace Content.Server.Fluids.EntitySystems;
|
||||
|
||||
@@ -29,7 +29,7 @@ public sealed class SpillableSystem : EntitySystem
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
[Dependency] private readonly EntityLookupSystem _entityLookup = default!;
|
||||
[Dependency] private readonly IAdminLogManager _adminLogger= default!;
|
||||
[Dependency] private readonly DoAfterSystem _doAfterSystem = default!;
|
||||
[Dependency] private readonly SharedDoAfterSystem _doAfterSystem = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -38,7 +38,7 @@ public sealed class SpillableSystem : EntitySystem
|
||||
SubscribeLocalEvent<SpillableComponent, GetVerbsEvent<Verb>>(AddSpillVerb);
|
||||
SubscribeLocalEvent<SpillableComponent, GotEquippedEvent>(OnGotEquipped);
|
||||
SubscribeLocalEvent<SpillableComponent, SolutionSpikeOverflowEvent>(OnSpikeOverflow);
|
||||
SubscribeLocalEvent<SpillableComponent, DoAfterEvent>(OnDoAfter);
|
||||
SubscribeLocalEvent<SpillableComponent, SpillDoAfterEvent>(OnDoAfter);
|
||||
}
|
||||
|
||||
private void OnSpikeOverflow(EntityUid uid, SpillableComponent component, SolutionSpikeOverflowEvent args)
|
||||
@@ -128,29 +128,17 @@ public sealed class SpillableSystem : EntitySystem
|
||||
Verb verb = new();
|
||||
verb.Text = Loc.GetString("spill-target-verb-get-data-text");
|
||||
// TODO VERB ICONS spill icon? pouring out a glass/beaker?
|
||||
if (component.SpillDelay == null)
|
||||
|
||||
verb.Act = () =>
|
||||
{
|
||||
verb.Act = () =>
|
||||
_doAfterSystem.TryStartDoAfter(new DoAfterArgs(args.User, component.SpillDelay ?? 0, new SpillDoAfterEvent(), uid, target: uid)
|
||||
{
|
||||
var puddleSolution = _solutionContainerSystem.SplitSolution(args.Target,
|
||||
solution, solution.Volume);
|
||||
SpillAt(puddleSolution, Transform(args.Target).Coordinates, "PuddleSmear");
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
verb.Act = () =>
|
||||
{
|
||||
_doAfterSystem.DoAfter(new DoAfterEventArgs(args.User, component.SpillDelay.Value, target:uid)
|
||||
{
|
||||
BreakOnTargetMove = true,
|
||||
BreakOnUserMove = true,
|
||||
BreakOnDamage = true,
|
||||
BreakOnStun = true,
|
||||
NeedHand = true
|
||||
});
|
||||
};
|
||||
}
|
||||
BreakOnTargetMove = true,
|
||||
BreakOnUserMove = true,
|
||||
BreakOnDamage = true,
|
||||
NeedHand = true,
|
||||
});
|
||||
};
|
||||
verb.Impact = LogImpact.Medium; // dangerous reagent reaction are logged separately.
|
||||
verb.DoContactInteraction = true;
|
||||
args.Verbs.Add(verb);
|
||||
|
||||
Reference in New Issue
Block a user