Пример #1
0
            public static bool Prefix(UnitEntityData unit, ClickGroundHandler.CommandSettings settings)
            {
                var moveAsOne  = Main.settings.toggleMoveSpeedAsOne;
                var speedLimit = moveAsOne ? UnitEntityDataUtils.GetMaxSpeed(Game.Instance.UI.SelectionManager.SelectedUnits) : unit.ModifiedSpeedMps;

                speedLimit *= Main.settings.partyMovementSpeedMultiplier;

                UnitMoveTo unitMoveTo = new UnitMoveTo(settings.Destination, 0.3f)
                {
                    MovementDelay   = settings.Delay,
                    Orientation     = new float?(settings.Orientation),
                    CreatedByPlayer = true
                };

                if (BuildModeUtility.IsDevelopment)
                {
                    if (CheatsAnimation.SpeedForce > 0f)
                    {
                        unitMoveTo.OverrideSpeed = new float?(CheatsAnimation.SpeedForce);
                    }
                    unitMoveTo.MovementType = (UnitAnimationActionLocoMotion.WalkSpeedType)CheatsAnimation.MoveType.Get();
                }
                if (Main.settings.partyMovementSpeedMultiplier > 1)
                {
                    unitMoveTo.OverrideSpeed = speedLimit;
                }
                unitMoveTo.SpeedLimit = speedLimit;
                unitMoveTo.ApplySpeedLimitInCombat = settings.ApplySpeedLimitInCombat;
                unit.Commands.Run(unitMoveTo);
                if (unit.Commands.Queue.FirstOrDefault((UnitCommand c) => c is UnitMoveTo) == unitMoveTo || Game.Instance.IsPaused)
                {
                    ClickGroundHandler.ShowDestination(unit, unitMoveTo.Target, false);
                }
                return(false);
            }
Пример #2
0
            public static bool Prefix(UnitEntityData unit, ClickGroundHandler.CommandSettings settings)
            {
                var moveAsOne = Main.settings.toggleMoveSpeedAsOne;

                //Main.Log($"ClickGroundHandler_RunCommand_Patch - isInCombat: {unit.IsInCombat} turnBased:{Game.Instance.Player.IsTurnBasedModeOn()} moveAsOne:{moveAsOne}");
                if (unit.IsInCombat && Game.Instance.Player.IsTurnBasedModeOn())
                {
                    return(true);
                }

                // As of WoTR 1.03c RunCommand is once again the main place to adjust movement speed.  The following was needed when we used UnitEntityData_CalculateSpeedModifier_Patch above to adjust speed in non move as one cases.
                if (!moveAsOne)
                {
                    return(true);
                }
                var partTacticalCombat = unit.Get <UnitPartTacticalCombat>();

                if (partTacticalCombat != null && partTacticalCombat.Faction != ArmyFaction.Crusaders)
                {
                    return(true);
                }

                var speedLimit = moveAsOne ? UnitEntityDataUtils.GetMaxSpeed(Game.Instance.UI.SelectionManager.SelectedUnits) : unit.ModifiedSpeedMps;

                Mod.Trace($"RunCommand - moveAsOne: {moveAsOne} speedLimit: {speedLimit} selectedUnits: {string.Join(" ", Game.Instance.UI.SelectionManager.SelectedUnits.Select(u => $"{u.CharacterName} {u.ModifiedSpeedMps}"))}");
                speedLimit *= Main.settings.partyMovementSpeedMultiplier;

                unitMoveTo = new UnitMoveTo(settings.Destination, 0.3f)
                {
                    MovementDelay   = settings.Delay,
                    Orientation     = new float?(settings.Orientation),
                    CreatedByPlayer = true
                };
                if (BuildModeUtility.IsDevelopment)
                {
                    if (CheatsAnimation.SpeedForce > 0f)
                    {
                        unitMoveTo.OverrideSpeed = new float?(CheatsAnimation.SpeedForce);
                    }
                    unitMoveTo.MovementType = (UnitAnimationActionLocoMotion.WalkSpeedType)CheatsAnimation.MoveType.Get();
                }
                unitMoveTo.SpeedLimit = speedLimit;
                unitMoveTo.ApplySpeedLimitInCombat = settings.ApplySpeedLimitInCombat;
                unitMoveTo.OverrideSpeed           = speedLimit * 1.5f;
                unit.Commands.Run(unitMoveTo);
                if (unit.Commands.Queue.FirstOrDefault((UnitCommand c) => c is UnitMoveTo) == unitMoveTo || Game.Instance.IsPaused)
                {
                    ClickGroundHandler.ShowDestination(unit, unitMoveTo.Target, false);
                }
                return(false);
            }