DoAfter Refactor (#13225)

Co-authored-by: DrSmugleaf <drsmugleaf@gmail.com>
This commit is contained in:
keronshb
2023-02-24 19:01:25 -05:00
committed by GitHub
parent 7a9baa79c2
commit 9ebb452a3c
129 changed files with 2624 additions and 4132 deletions

View File

@@ -20,4 +20,68 @@ namespace Content.Shared.Tools.Components
[DataField("useSound")]
public SoundSpecifier? UseSound { get; set; }
}
/// <summary>
/// Attempt event called *before* any do afters to see if the tool usage should succeed or not.
/// You can change the fuel consumption by changing the Fuel property.
/// </summary>
public sealed class ToolUseAttemptEvent : CancellableEntityEventArgs
{
public float Fuel { get; set; }
public EntityUid User { get; }
public ToolUseAttemptEvent(float fuel, EntityUid user)
{
Fuel = fuel;
User = user;
}
}
/// <summary>
/// Event raised on the user of a tool to see if they can actually use it.
/// </summary>
[ByRefEvent]
public struct ToolUserAttemptUseEvent
{
public EntityUid User;
public EntityUid? Target;
public bool Cancelled = false;
public ToolUserAttemptUseEvent(EntityUid user, EntityUid? target)
{
User = user;
Target = target;
}
}
/// <summary>
/// Attempt event called *after* any do afters to see if the tool usage should succeed or not.
/// You can use this event to consume any fuel needed.
/// </summary>
public sealed class ToolUseFinishAttemptEvent : CancellableEntityEventArgs
{
public float Fuel { get; }
public EntityUid User { get; }
public ToolUseFinishAttemptEvent(float fuel, EntityUid user)
{
Fuel = fuel;
}
}
public sealed class ToolEventData
{
public readonly Object? Ev;
public readonly Object? CancelledEv;
public readonly float Fuel;
public readonly EntityUid? TargetEntity;
public ToolEventData(Object? ev, float fuel = 0f, Object? cancelledEv = null, EntityUid? targetEntity = null)
{
Ev = ev;
CancelledEv = cancelledEv;
Fuel = fuel;
TargetEntity = targetEntity;
}
}
}