From 6d332243c4a6f9aee3a68530659b0e8af9ae6582 Mon Sep 17 00:00:00 2001 From: hondacrx Date: Tue, 7 Dec 2021 18:32:20 -0500 Subject: [PATCH] Core/Movement: implement MotionMasterDelayedAction validator Port From (https://github.com/TrinityCore/TrinityCore/commit/36a1d00444b35d6f8fbfaabebf835f4ad9c01108) --- Source/Game/Movement/MotionMaster.cs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/Source/Game/Movement/MotionMaster.cs b/Source/Game/Movement/MotionMaster.cs index 5e27a2014..e3fcad7ed 100644 --- a/Source/Game/Movement/MotionMaster.cs +++ b/Source/Game/Movement/MotionMaster.cs @@ -59,16 +59,29 @@ namespace Game.Movement class MotionMasterDelayedAction { + Func Validator; public Action Action; public MotionMasterDelayedActionType Type; + public MotionMasterDelayedAction(Action action, Func 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; }