static void PostTranspiler(UnitMovementAgent instance, float?minSpeed) { if (minSpeed.HasValue) { instance.SetMinSpeed(minSpeed.Value); } }
static void Postfix(UnitMovementAgent __instance, ref float?__state) { if (__state.HasValue) { __instance.SetMinSpeed(__state.Value); } }
static bool Prefix(UnitMovementAgent __instance, ref float deltaTime, ref float?__state) { if (IsInCombat()) { // passing acting ending delaying // not in combat o x x x // in combat - not current x x x x // in combat - current x o x x bool canMove = default; bool isInForceMode = __instance.GetIsInForceMode(); UnitEntityView view = __instance.Unit; if (IsPassing()) { canMove = !(view?.EntityData?.IsInCombat ?? false); } else { canMove = (view?.EntityData).IsCurrentUnit() && IsActing() && !(view.AnimationManager?.IsPreventingMovement ?? false) && !view.IsCommandsPreventMovement && __instance.IsReallyMoving; if (canMove) { CurrentTurn().TickMovement(ref deltaTime, isInForceMode); if (deltaTime <= 0f) { canMove = false; } else if (!isInForceMode) { // disable acceleration effect __state = __instance.GetMinSpeed(); __instance.SetMinSpeed(1f); __instance.SetWarmupTime(0f); __instance.SetSlowDownTime(0f); } } } if (!canMove) { if (!isInForceMode) { __instance.Stop(); } return(false); } } return(true); }
static float?PreTranspiler(UnitMovementAgent instance) { if (IsInCombat()) { // disable acceleration effect float minSpeed = instance.GetMinSpeed(); instance.SetMinSpeed(1f); instance.SetWarmupTime(0f); instance.SetSlowDownTime(0f); return(minSpeed); } return(null); }