Core/Movement: implement MotionMasterDelayedAction validator

Port From (https://github.com/TrinityCore/TrinityCore/commit/36a1d00444b35d6f8fbfaabebf835f4ad9c01108)
This commit is contained in:
hondacrx
2021-12-07 18:32:20 -05:00
parent 2fdc3665a4
commit 6d332243c4
+15 -2
View File
@@ -59,16 +59,29 @@ namespace Game.Movement
class MotionMasterDelayedAction
{
Func<bool> Validator;
public Action Action;
public MotionMasterDelayedActionType Type;
public MotionMasterDelayedAction(Action action, Func<bool> validator, MotionMasterDelayedActionType type)
{
Action = action;
Validator = validator;
Type = type;
}
public MotionMasterDelayedAction(Action action, MotionMasterDelayedActionType type)
{
Action = action;
Validator = () => true;
Type = type;
}
public void Resolve() { Action(); }
public void Resolve()
{
if (Validator())
Action();
}
}
public class MotionMaster
@@ -112,7 +125,7 @@ namespace Game.Movement
return _defaultGenerator == null && _generators.Empty();
}
int Size()
public int Size()
{
return _defaultGenerator != null ? 1 : 0 + _generators.Count;
}