示例#1
0
            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 bool Prefix(UnitMovementAgent __instance, ref float deltaTime)
            {
                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
                    {
                        if (canMove = (view?.EntityData).IsCurrentUnit() && IsActing() &&
                                      !(view.AnimationManager?.IsPreventingMovement ?? false) &&
                                      !view.IsCommandsPreventMovement && __instance.IsReallyMoving)
                        {
                            CurrentTurn().TickMovement(ref deltaTime, isInForceMode);
                            canMove = deltaTime > 0f;
                        }
                        else
                        {
                            canMove = false;
                        }
                    }

                    if (!canMove)
                    {
                        if (!isInForceMode)
                        {
                            __instance.Stop();
                        }
                        return(false);
                    }
                }
                return(true);
            }