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,6 @@
|
||||
using System.Threading;
|
||||
using Content.Server.DoAfter;
|
||||
using Content.Shared.Alert;
|
||||
using Content.Shared.DoAfter;
|
||||
using Content.Shared.Ensnaring;
|
||||
using Content.Shared.Ensnaring.Components;
|
||||
using Content.Shared.IdentityManagement;
|
||||
using Content.Shared.StepTrigger.Systems;
|
||||
@@ -11,7 +10,7 @@ namespace Content.Server.Ensnaring;
|
||||
|
||||
public sealed partial class EnsnareableSystem
|
||||
{
|
||||
[Dependency] private readonly DoAfterSystem _doAfter = default!;
|
||||
[Dependency] private readonly SharedDoAfterSystem _doAfter = default!;
|
||||
[Dependency] private readonly AlertsSystem _alerts = default!;
|
||||
|
||||
public void InitializeEnsnaring()
|
||||
@@ -74,40 +73,35 @@ public sealed partial class EnsnareableSystem
|
||||
/// <summary>
|
||||
/// Used where you want to try to free an entity with the <see cref="EnsnareableComponent"/>
|
||||
/// </summary>
|
||||
/// <param name="target">The entity that will be free</param>
|
||||
/// <param name="target">The entity that will be freed</param>
|
||||
/// <param name="user">The entity that is freeing the target</param>
|
||||
/// <param name="ensnare">The entity used to ensnare</param>
|
||||
/// <param name="component">The ensnaring component</param>
|
||||
public void TryFree(EntityUid target, EntityUid ensnare, EnsnaringComponent component, EntityUid? user = null)
|
||||
public void TryFree(EntityUid target, EntityUid user, EntityUid ensnare, EnsnaringComponent component)
|
||||
{
|
||||
//Don't do anything if they don't have the ensnareable component.
|
||||
if (!HasComp<EnsnareableComponent>(target))
|
||||
return;
|
||||
|
||||
var isOwner = !(user != null && target != user);
|
||||
var freeTime = isOwner ? component.BreakoutTime : component.FreeTime;
|
||||
bool breakOnMove;
|
||||
var freeTime = user == target ? component.BreakoutTime : component.FreeTime;
|
||||
var breakOnMove = user != target || !component.CanMoveBreakout;
|
||||
|
||||
if (isOwner)
|
||||
breakOnMove = !component.CanMoveBreakout;
|
||||
else
|
||||
breakOnMove = true;
|
||||
|
||||
var doAfterEventArgs = new DoAfterEventArgs(target, freeTime, target: target, used:ensnare)
|
||||
var doAfterEventArgs = new DoAfterArgs(user, freeTime, new EnsnareableDoAfterEvent(), target, target: target, used: ensnare)
|
||||
{
|
||||
BreakOnUserMove = breakOnMove,
|
||||
BreakOnTargetMove = breakOnMove,
|
||||
BreakOnDamage = false,
|
||||
BreakOnStun = true,
|
||||
NeedHand = true
|
||||
NeedHand = true,
|
||||
BlockDuplicate = true,
|
||||
};
|
||||
|
||||
_doAfter.DoAfter(doAfterEventArgs);
|
||||
if (!_doAfter.TryStartDoAfter(doAfterEventArgs))
|
||||
return;
|
||||
|
||||
if (isOwner)
|
||||
if (user == target)
|
||||
_popup.PopupEntity(Loc.GetString("ensnare-component-try-free", ("ensnare", ensnare)), target, target);
|
||||
|
||||
if (!isOwner && user != null)
|
||||
_popup.PopupEntity(Loc.GetString("ensnare-component-try-free-other", ("ensnare", ensnare), ("user", Identity.Entity(target, EntityManager))), user.Value, user.Value);
|
||||
else
|
||||
_popup.PopupEntity(Loc.GetString("ensnare-component-try-free-other", ("ensnare", ensnare), ("user", Identity.Entity(target, EntityManager))), user, user);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user