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,13 +1,13 @@
|
||||
using Content.Server.Animals.Components;
|
||||
using Content.Server.Chemistry.Components.SolutionManager;
|
||||
using Content.Server.Chemistry.EntitySystems;
|
||||
using Content.Server.DoAfter;
|
||||
using Content.Server.Nutrition.Components;
|
||||
using Content.Server.Popups;
|
||||
using Content.Shared.DoAfter;
|
||||
using Content.Shared.IdentityManagement;
|
||||
using Content.Shared.Nutrition.Components;
|
||||
using Content.Shared.Popups;
|
||||
using Content.Shared.Udder;
|
||||
using Content.Shared.Verbs;
|
||||
|
||||
namespace Content.Server.Animals.Systems
|
||||
@@ -18,7 +18,7 @@ namespace Content.Server.Animals.Systems
|
||||
internal sealed class UdderSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly SolutionContainerSystem _solutionContainerSystem = default!;
|
||||
[Dependency] private readonly DoAfterSystem _doAfterSystem = default!;
|
||||
[Dependency] private readonly SharedDoAfterSystem _doAfterSystem = default!;
|
||||
[Dependency] private readonly PopupSystem _popupSystem = default!;
|
||||
|
||||
public override void Initialize()
|
||||
@@ -26,7 +26,7 @@ namespace Content.Server.Animals.Systems
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<UdderComponent, GetVerbsEvent<AlternativeVerb>>(AddMilkVerb);
|
||||
SubscribeLocalEvent<UdderComponent, DoAfterEvent>(OnDoAfter);
|
||||
SubscribeLocalEvent<UdderComponent, MilkingDoAfterEvent>(OnDoAfter);
|
||||
}
|
||||
public override void Update(float frameTime)
|
||||
{
|
||||
@@ -64,38 +64,21 @@ namespace Content.Server.Animals.Systems
|
||||
if (!Resolve(uid, ref udder))
|
||||
return;
|
||||
|
||||
if (udder.BeingMilked)
|
||||
{
|
||||
_popupSystem.PopupEntity(Loc.GetString("udder-system-already-milking"), uid, userUid);
|
||||
return;
|
||||
}
|
||||
|
||||
udder.BeingMilked = true;
|
||||
|
||||
var doargs = new DoAfterEventArgs(userUid, 5, target:uid, used:containerUid)
|
||||
var doargs = new DoAfterArgs(userUid, 5, new MilkingDoAfterEvent(), uid, uid, used: containerUid)
|
||||
{
|
||||
BreakOnUserMove = true,
|
||||
BreakOnDamage = true,
|
||||
BreakOnStun = true,
|
||||
BreakOnTargetMove = true,
|
||||
MovementThreshold = 1.0f
|
||||
MovementThreshold = 1.0f,
|
||||
};
|
||||
|
||||
_doAfterSystem.DoAfter(doargs);
|
||||
_doAfterSystem.TryStartDoAfter(doargs);
|
||||
}
|
||||
|
||||
private void OnDoAfter(EntityUid uid, UdderComponent component, DoAfterEvent args)
|
||||
private void OnDoAfter(EntityUid uid, UdderComponent component, MilkingDoAfterEvent args)
|
||||
{
|
||||
if (args.Cancelled)
|
||||
{
|
||||
component.BeingMilked = false;
|
||||
if (args.Cancelled || args.Handled || args.Args.Used == null)
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.Handled || args.Args.Used == null)
|
||||
return;
|
||||
|
||||
component.BeingMilked = false;
|
||||
|
||||
if (!_solutionContainerSystem.TryGetSolution(uid, component.TargetSolutionName, out var solution))
|
||||
return;
|
||||
@@ -103,6 +86,7 @@ namespace Content.Server.Animals.Systems
|
||||
if (!_solutionContainerSystem.TryGetRefillableSolution(args.Args.Used.Value, out var targetSolution))
|
||||
return;
|
||||
|
||||
args.Handled = true;
|
||||
var quantity = solution.Volume;
|
||||
if(quantity == 0)
|
||||
{
|
||||
@@ -118,8 +102,6 @@ namespace Content.Server.Animals.Systems
|
||||
|
||||
_popupSystem.PopupEntity(Loc.GetString("udder-system-success", ("amount", quantity), ("target", Identity.Entity(args.Args.Used.Value, EntityManager))), uid,
|
||||
args.Args.User, PopupType.Medium);
|
||||
|
||||
args.Handled = true;
|
||||
}
|
||||
|
||||
private void AddMilkVerb(EntityUid uid, UdderComponent component, GetVerbsEvent<AlternativeVerb> args)
|
||||
|
||||
Reference in New Issue
Block a user