Adds repeating DoAfters to Food and Drink (#15233)
This commit is contained in:
@@ -127,6 +127,7 @@ public sealed class DoAfterArgs
|
||||
[DataField("blockDuplicate")]
|
||||
public bool BlockDuplicate = true;
|
||||
|
||||
//TODO: User pref to not cancel on second use on specific doafters
|
||||
/// <summary>
|
||||
/// If true, this will cancel any duplicate DoAfters when attempting to add a new DoAfter. See also
|
||||
/// <see cref="DuplicateConditions"/>.
|
||||
@@ -206,6 +207,7 @@ public sealed class DoAfterArgs
|
||||
|
||||
#endregion
|
||||
|
||||
//The almighty pyramid returns.......
|
||||
public DoAfterArgs(DoAfterArgs other)
|
||||
{
|
||||
User = other.User;
|
||||
|
||||
@@ -15,6 +15,12 @@ public abstract class DoAfterEvent : HandledEntityEventArgs
|
||||
[NonSerialized]
|
||||
public DoAfter DoAfter = default!;
|
||||
|
||||
//TODO: User pref to toggle repeat on specific doafters
|
||||
/// <summary>
|
||||
/// If set to true while handling this event, then the DoAfter will automatically be repeated.
|
||||
/// </summary>
|
||||
public bool Repeat = false;
|
||||
|
||||
/// <summary>
|
||||
/// Duplicate the current event. This is used by state handling, and should copy by value unless the reference
|
||||
/// types are immutable.
|
||||
|
||||
@@ -117,7 +117,14 @@ public abstract partial class SharedDoAfterSystem : EntitySystem
|
||||
}
|
||||
|
||||
doAfter.Completed = true;
|
||||
|
||||
RaiseDoAfterEvents(doAfter, component);
|
||||
|
||||
if (doAfter.Args.Event.Repeat)
|
||||
{
|
||||
doAfter.StartTime = GameTiming.CurTime;
|
||||
doAfter.Completed = false;
|
||||
}
|
||||
}
|
||||
|
||||
private bool ShouldCancel(DoAfter doAfter,
|
||||
|
||||
@@ -83,6 +83,8 @@ public abstract partial class SharedDoAfterSystem : EntitySystem
|
||||
private void RaiseDoAfterEvents(DoAfter doAfter, DoAfterComponent component)
|
||||
{
|
||||
var ev = doAfter.Args.Event;
|
||||
ev.Handled = false;
|
||||
ev.Repeat = false;
|
||||
ev.DoAfter = doAfter;
|
||||
|
||||
if (Exists(doAfter.Args.EventTarget))
|
||||
|
||||
Reference in New Issue
Block a user