Refactor doAfterEventArgs

This commit is contained in:
Víctor Aguilera Puerto
2020-08-09 01:44:17 +02:00
parent 622b9243de
commit a57883e363

View File

@@ -2,6 +2,7 @@
using System;
using System.Threading;
using Robust.Shared.Interfaces.GameObjects;
// ReSharper disable UnassignedReadonlyField
namespace Content.Server.GameObjects.EntitySystems
{
@@ -32,48 +33,36 @@ namespace Content.Server.GameObjects.EntitySystems
/// Whether we need to keep our active hand as is (i.e. can't change hand or change item).
/// This also covers requiring the hand to be free (if applicable).
/// </summary>
public bool NeedHand { get; }
public readonly bool NeedHand;
/// <summary>
/// If do_after stops when the user moves
/// </summary>
public bool BreakOnUserMove { get; }
public readonly bool BreakOnUserMove;
/// <summary>
/// If do_after stops when the target moves (if there is a target)
/// </summary>
public bool BreakOnTargetMove { get; }
public bool BreakOnDamage { get; }
public bool BreakOnStun { get; }
public readonly bool BreakOnTargetMove;
public readonly bool BreakOnDamage;
public readonly bool BreakOnStun;
/// <summary>
/// Additional conditions that need to be met. Return false to cancel.
/// </summary>
public Func<bool>? ExtraCheck { get; }
public readonly Func<bool>? ExtraCheck;
public DoAfterEventArgs(
IEntity user,
float delay,
CancellationToken cancelToken,
IEntity? target = null,
bool needHand = true,
bool breakOnUserMove = true,
bool breakOnTargetMove = true,
bool breakOnDamage = true,
bool breakOnStun = true,
Func<bool>? extraCheck = null
)
CancellationToken cancelToken = default,
IEntity? target = null)
{
User = user;
Delay = delay;
CancelToken = cancelToken;
Target = target;
NeedHand = needHand;
BreakOnUserMove = breakOnUserMove;
BreakOnTargetMove = breakOnTargetMove;
BreakOnDamage = breakOnDamage;
BreakOnStun = breakOnStun;
ExtraCheck = extraCheck;
if (Target == null)
{