mirror of
https://github.com/soarqin/DSP_Mods.git
synced 2026-11-19 17:05:20 +08:00
refactor(uxassist): unify auto-cruise navigation
Remove the legacy cruise implementation and expose the advanced navigator through the existing auto-cruise setting and UI. Match the game's 1.6-degree steering cap and handle antiparallel target directions with a stable turn plane.
This commit is contained in:
1 parent
fa65236d5c
commit
2c601e3546
8 files changed
+158
-466
No files matched your search
@@ -159,8 +159,8 @@ The sync is implemented as an inline PowerShell `Exec` step inside the `ZipMod`
|
||||
- **Convergent in-game UI state:** In-game overlay widgets whose visibility depends on game state (e.g. `AutoConstructUI`) must not rely solely on one-shot event-driven refreshes (`SettingChanged` handlers, patch `OnEnable`/`OnDisable`), because a thrown exception earlier in a delegate chain or a failed patch application silently drops the refresh. `AutoConstructUI.OnUpdate()` reconciles button visibility and the pending-construction count with actual game state every 30 frames (also effective while paused); the `AutoConstructPatch` postfix on `PlayerAction_Rts.GameTick` only implements the fly-to-target behavior, and `AutoConstructPatch.OnEnable` logs its visibility predicate inputs once per enable as a remote-diagnosis aid.
|
||||
- **Auto-construct planner:** `AutoConstructPatch` keeps a construction-site plan while drones work, chooses among a fixed candidate set using the native 120-target construction capacity, total drone travel cost, and player travel cost, then refines the strongest candidates to an actual ghost nearest the target-group center. Candidate scoring uses the planned flight altitude when evaluating build-range coverage. It replans before the current site is empty when the remaining local workload no longer covers the next flight. Candidate evaluation has fixed limits and uses allocation-free arrays; local construction checks scan actual hash entries instead of trusting stale module counters and include ghosts whose materials can be delivered from the mecha package.
|
||||
- **Auto-construct final pass:** When at most eight eligible construction ghosts remain, the planner bypasses site-hold hysteresis and routes directly to the nearest remaining ghost. The final-pass count is capped at nine during the existing prebuild scan, so large construction queues do not incur an additional unbounded performance cost.
|
||||
- **Auto-navigation modes:** The legacy auto-navigation and the new navigation algorithm are mutually exclusive; legacy mode wins if both configuration values load as enabled. The shared `ToggleAutoCruise` key dispatches to only the selected implementation. New-navigation teardown is unconditional for configuration, target, capability, and lifecycle failures, while the manual-input option controls only user-override behavior. Its session state and cloned status label are reset through `GameLogic.OnGameEnd` and patch teardown. When the new algorithm is selected but inactive, the cloned status label prompts the player with the currently configured `ToggleAutoCruise` key only when an effective navigation target exists and it is not the local planet; it shows the active status while navigation is running. Both navigation paths must match the original PlayerMove_Sail.GameTick steering cap of 1.6 degrees per tick and explicitly choose a turn plane for antiparallel velocity and target directions; the legacy path currently uses 2 degrees per tick, and both paths currently pass the exact rear-target case through Vector3.Slerp without such a tie-break.
|
||||
- **Auto-cruise flight input:** In the original `PlayerMove_Fly.GameTick`, `PlayerController.input0.y = 1` matches manual forward movement and `input1.y = 1` matches manual upward thrust. The legacy auto-cruise `Fly` handler must preserve these signs so the mecha leaves a planet with the same orientation and motion as manual control.
|
||||
- **Auto-navigation:** UXAssist now exposes one auto-cruise implementation through `PlayerPatch.AutoNavigation`; the former legacy cruise path and algorithm-selection branch are removed. The shared `ToggleAutoCruise` key and in-game button control the session state. The configuration entry is presented as `Enable auto-cruise`, and its navigation options are grouped beneath it as indented 13-point sub-options. Steering follows the original `PlayerMove_Sail.GameTick` interpolation cap of 1.6 degrees per tick and explicitly chooses a stable turn plane for antiparallel velocity and target directions.
|
||||
- **Auto-cruise flight input:** In the original `PlayerMove_Fly.GameTick`, `PlayerController.input0.y = 1` matches manual forward movement and `input1.y = 1` matches manual upward thrust. The auto-cruise `Fly` handler must preserve these signs so the mecha leaves a planet with the same orientation and motion as manual control.
|
||||
- **Shortcut input timing:** UXAssist dispatches mod shortcuts from a postfix of the original `VFInput.OnUpdate`, after DSP has refreshed its current modifier and UI input state. Do not move shortcut polling back to an independent plugin `Update()` or a logic-tick callback: CommonAPI `PressKeyBind.keyValue` combines Unity's current-frame `Input.GetKeyDown()` with `CombineKey` modifier caches refreshed by `VFInput.OnUpdate`. Polling before that refresh can miss a shortcut when a modifier changes in the same frame, which is easier to encounter at low frame rates. Keep the typing/menu guards and per-frame registry guards.
|
||||
- **UI clone initialization and text measurement:** UXAssist UI factories and dependent mods' direct UI clones treat runtime DSP objects as style sources only; after `Instantiate`, they explicitly reset stateful `UIButton`, `Text`, `Image`, `InputField`, `Slider`, and `UIComboBox` fields that can otherwise carry source state. Use `UXAssist.UI.Util.GetPreferredWidth` for dynamic text width because it invalidates DSP's custom text-generator cache before reading `preferredWidth`; do not replace it with a generic `TextGenerator` or canvas-wide rebuild without validating the rendered result.
|
||||
- **Transpiler patches:** Performance-critical mods (LabOpt, MechaDronesTweaks) use `[HarmonyTranspiler]` to rewrite IL instructions directly for maximum efficiency. All transpilers in UXAssist, CheatEnabler, and UniverseGenTweaks carry a standard header comment (`// Harmony transpiler:`, `// Target:`, `// Fallback:`) documenting the target method and fallback behavior. `UXAssist.Common.Patching.TranspilerGuard` provides a reusable `CodeMatcher.Finish` helper that returns original instructions when a matcher becomes invalid.
|
||||
|
||||
@@ -40,8 +40,6 @@ public static class I18NKeys
|
||||
public const string KEYShowAllStarsName = "KEYShowAllStarsName";
|
||||
public const string KEYToggleAllStarsName = "KEYToggleAllStarsName";
|
||||
public const string KEYToggleAutoCruise = "KEYToggleAutoCruise";
|
||||
public const string AutoCruiseOn = "AutoCruiseOn";
|
||||
public const string AutoCruiseOff = "AutoCruiseOff";
|
||||
public const string SorterCargoStackingPrefix = "Sorter cargo stacking prefix";
|
||||
public const string UXAssist = "UXAssist";
|
||||
public const string General = "General";
|
||||
@@ -154,10 +152,8 @@ public static class I18NKeys
|
||||
public const string ShortcutKeysForBlueprintCopyMode = "Shortcut keys for Blueprint Copy mode";
|
||||
public const string ShortcutKeysForBlueprintCopyModeTips = "Shortcut keys for Blueprint Copy mode tips";
|
||||
public const string ShortcutKeysForShowingStarsName = "Shortcut keys for showing stars' name";
|
||||
public const string AutoNavigationOnSailings = "Auto navigation on sailings";
|
||||
public const string AutoBoost = "Auto boost";
|
||||
public const string DistanceToUseWarp = "Distance to use warp";
|
||||
public const string NewNavigationAlgorithm = "New navigation algorithm";
|
||||
public const string StopAutoNavigationOnManualInput = "Stop auto-navigation on manual input";
|
||||
public const string UseWarp = "Use warp";
|
||||
public const string UseWarpMinimalEnergy = "Use warp minimal energy";
|
||||
@@ -239,8 +235,6 @@ public static class I18NKeys
|
||||
I18N.Add(KEYShowAllStarsName, "[UXA] Keep pressing to show all Stars' name", "[UXA] 按住显示所有星系名称");
|
||||
I18N.Add(KEYToggleAllStarsName, "[UXA] Toggle display of all Stars' name", "[UXA] 切换所有星系名称显示状态");
|
||||
I18N.Add(KEYToggleAutoCruise, "[UXA] Toggle auto-cruise", "[UXA] 切换自动巡航");
|
||||
I18N.Add(AutoCruiseOn, "Auto-cruise enabled", "已启用自动巡航");
|
||||
I18N.Add(AutoCruiseOff, "Auto-cruise disabled", "已禁用自动巡航");
|
||||
I18N.Add(SorterCargoStackingPrefix, "Sorter Mk.III cargo stacking : ", "极速分拣器每次可运送 ");
|
||||
I18N.Add(UXAssist, "UXAssist", "UX助手");
|
||||
I18N.Add(General, "General", "常规");
|
||||
@@ -422,10 +416,8 @@ You can set 2 shortcut keys in Settings panel:
|
||||
2. 拆除选中的建筑
|
||||
""");
|
||||
I18N.Add(ShortcutKeysForShowingStarsName, "Shortcut keys for showing stars' name", "启用显示所有星系名称的快捷键");
|
||||
I18N.Add(AutoNavigationOnSailings, "Auto navigation on sailings", "宇宙航行时自动导航");
|
||||
I18N.Add(AutoBoost, "Auto boost", "自动加速");
|
||||
I18N.Add(DistanceToUseWarp, "Distance to use warp (AU)", "使用曲速的距离(AU)");
|
||||
I18N.Add(NewNavigationAlgorithm, "New navigation algorithm", "新导航算法");
|
||||
I18N.Add(StopAutoNavigationOnManualInput, "Stop auto-navigation on manual input", "手动输入时停止自动导航");
|
||||
I18N.Add(UseWarp, "Use warp", "启用曲速");
|
||||
I18N.Add(UseWarpMinimalEnergy, "Minimum energy to use warp (MJ)", "使用曲速最低能量(MJ)");
|
||||
|
||||
@@ -27,13 +27,16 @@ internal static class AutoCruiseUI
|
||||
public static void OnUpdate()
|
||||
{
|
||||
if (Time.frameCount % 30 == 0)
|
||||
Patches.PlayerPatch.AutoNavigationG.UpdateUiTip();
|
||||
{
|
||||
Patches.PlayerPatch.AutoNavigation.UpdateUiTip();
|
||||
UpdateToggleAutoCruiseCheckButtonVisiblility();
|
||||
}
|
||||
}
|
||||
|
||||
public static void InitToggleAutoCruiseCheckButton()
|
||||
{
|
||||
var lowGroup = GameObject.Find("UI Root/Overlay Canvas/In Game/Low Group");
|
||||
ToggleAutoCruise = MyCheckButton.CreateCheckButton(0, 0, lowGroup.GetComponent<RectTransform>(), Patches.PlayerPatch.AutoCruiseEnabled).WithSize(160f, 40f);
|
||||
ToggleAutoCruise = MyCheckButton.CreateCheckButton(0, 0, lowGroup.GetComponent<RectTransform>(), Patches.PlayerPatch.AutoNavigation.IsActive).WithSize(160f, 40f);
|
||||
var rectTrans = ToggleAutoCruise.rectTrans;
|
||||
rectTrans.anchorMax = new Vector2(0.5f, 0f);
|
||||
rectTrans.anchorMin = new Vector2(0.5f, 0f);
|
||||
@@ -48,19 +51,22 @@ internal static class AutoCruiseUI
|
||||
{
|
||||
if (ToggleAutoCruise.Checked)
|
||||
{
|
||||
ToggleAutoCruise.SetLabelText("Disable auto-cruise");
|
||||
ToggleAutoCruise.SetLabelText(I18NKeys.DisableAutoCruise);
|
||||
}
|
||||
else
|
||||
{
|
||||
ToggleAutoCruise.SetLabelText("Enable auto-cruise");
|
||||
ToggleAutoCruise.SetLabelText(I18NKeys.EnableAutoCruise);
|
||||
}
|
||||
}
|
||||
ToggleAutoCruise.OnChecked += Patches.PlayerPatch.AutoNavigation.Toggle;
|
||||
}
|
||||
|
||||
public static void UpdateToggleAutoCruiseCheckButtonVisiblility()
|
||||
{
|
||||
if (ToggleAutoCruise == null) return;
|
||||
var active = Patches.PlayerPatch.AutoNavigationEnabled.Value && Patches.PlayerPatch.AutoNavigation.IndicatorAstroId > 0;
|
||||
var active = Patches.PlayerPatch.AutoCruiseEnabled.Value
|
||||
&& Patches.PlayerPatch.AutoNavigation.HasNavigationTarget();
|
||||
ToggleAutoCruise.Checked = Patches.PlayerPatch.AutoNavigation.IsActive;
|
||||
ToggleAutoCruise.gameObject.SetActive(active);
|
||||
}
|
||||
}
|
||||
@@ -129,7 +129,7 @@ internal static class FactoryBuildPatches
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.navigation.navigating || global::UXAssist.Patches.PlayerPatch.AutoNavigationG.IsActive)
|
||||
if (player.navigation.navigating || global::UXAssist.Patches.PlayerPatch.AutoNavigation.IsActive)
|
||||
{
|
||||
ClearAutoRoute(player);
|
||||
ResetNavigation();
|
||||
|
||||
+66
-317
@@ -17,15 +17,11 @@ public class PlayerPatch : PatchImpl<PlayerPatch>
|
||||
public static ConfigEntry<bool> EnhancedMechaForgeCountControlEnabled;
|
||||
public static ConfigEntry<bool> HideTipsForSandsChangesEnabled;
|
||||
public static ConfigEntry<bool> ShortcutKeysForStarsNameEnabled;
|
||||
public static ConfigEntry<bool> AutoNavigationEnabled;
|
||||
public static ConfigEntry<bool> AutoCruiseEnabled;
|
||||
public static ConfigEntry<bool> AutoBoostEnabled;
|
||||
public static ConfigEntry<double> DistanceToWarp;
|
||||
private static PressKeyBind _showAllStarsNameKey;
|
||||
private static PressKeyBind _toggleAllStarsNameKey;
|
||||
private static PressKeyBind _autoDriveKey;
|
||||
|
||||
public static ConfigEntry<bool> UseNewNavigationAlgorithm { get; set; } = null!;
|
||||
public static ConfigEntry<bool> AutoCruiseEnabled { get; set; } = null!;
|
||||
public static ConfigEntry<bool> StopOnArrivalAndInput { get; set; } = null!;
|
||||
public static ConfigEntry<bool> UseWarper { get; set; } = null!;
|
||||
public static ConfigEntry<double> UseWarperMinimalEnergy { get; set; } = null!;
|
||||
@@ -63,10 +59,7 @@ public class PlayerPatch : PatchImpl<PlayerPatch>
|
||||
EnhancedMechaForgeCountControlEnabled.SettingChanged += (_, _) => EnhancedMechaForgeCountControl.Enable(EnhancedMechaForgeCountControlEnabled.Value);
|
||||
HideTipsForSandsChangesEnabled.SettingChanged += (_, _) => HideTipsForSandsChanges.Enable(HideTipsForSandsChangesEnabled.Value);
|
||||
ShortcutKeysForStarsNameEnabled.SettingChanged += (_, _) => ShortcutKeysForStarsName.Enable(ShortcutKeysForStarsNameEnabled.Value);
|
||||
AutoNavigationEnabled.SettingChanged += (_, _) => AutoNavigation.Enable(AutoNavigationEnabled.Value);
|
||||
AutoNavigationEnabled.SettingChanged += (_, _) => Functions.UIFunctions.UpdateToggleAutoCruiseCheckButtonVisiblility();
|
||||
AutoCruiseEnabled.SettingChanged += (_, _) => Functions.UIFunctions.UpdateToggleAutoCruiseCheckButtonVisiblility();
|
||||
AutoNavigationG.Init();
|
||||
AutoNavigation.Init();
|
||||
}
|
||||
|
||||
public static void Start()
|
||||
@@ -74,8 +67,7 @@ public class PlayerPatch : PatchImpl<PlayerPatch>
|
||||
EnhancedMechaForgeCountControl.Enable(EnhancedMechaForgeCountControlEnabled.Value);
|
||||
HideTipsForSandsChanges.Enable(HideTipsForSandsChangesEnabled.Value);
|
||||
ShortcutKeysForStarsName.Enable(ShortcutKeysForStarsNameEnabled.Value);
|
||||
AutoNavigation.Enable(AutoNavigationEnabled.Value);
|
||||
AutoNavigationG.Enable(true);
|
||||
AutoNavigation.Enable(true);
|
||||
Enable(true);
|
||||
}
|
||||
|
||||
@@ -83,12 +75,7 @@ public class PlayerPatch : PatchImpl<PlayerPatch>
|
||||
{
|
||||
ShortcutKeysForStarsName.OnInputUpdate();
|
||||
if (_autoDriveKey.keyValue)
|
||||
{
|
||||
if (UseNewNavigationAlgorithm.Value)
|
||||
AutoNavigationG.Toggle();
|
||||
else
|
||||
AutoNavigation.ToggleAutoCruise();
|
||||
}
|
||||
AutoNavigation.Toggle();
|
||||
}
|
||||
|
||||
public static void Uninit()
|
||||
@@ -98,7 +85,6 @@ public class PlayerPatch : PatchImpl<PlayerPatch>
|
||||
HideTipsForSandsChanges.Enable(false);
|
||||
ShortcutKeysForStarsName.Enable(false);
|
||||
AutoNavigation.Enable(false);
|
||||
AutoNavigationG.Enable(false);
|
||||
}
|
||||
// Harmony transpiler: UIStarmapStar__OnLateUpdate_Transpiler
|
||||
// Target: UIStarmapStar._OnLateUpdate
|
||||
@@ -357,279 +343,10 @@ public class PlayerPatch : PatchImpl<PlayerPatch>
|
||||
*/
|
||||
}
|
||||
|
||||
public class AutoNavigation : PatchImpl<AutoNavigation>
|
||||
{
|
||||
private static bool _canUseWarper;
|
||||
private static int _indicatorAstroId;
|
||||
private static bool _speedUp;
|
||||
private static Vector3 _direction;
|
||||
private static EMovementState _movementState = EMovementState.Walk;
|
||||
|
||||
public static int IndicatorAstroId => _indicatorAstroId;
|
||||
|
||||
protected override void OnEnable()
|
||||
{
|
||||
_canUseWarper = false;
|
||||
_indicatorAstroId = 0;
|
||||
_speedUp = false;
|
||||
_direction = Vector3.zero;
|
||||
_movementState = EMovementState.Walk;
|
||||
}
|
||||
|
||||
public static void ToggleAutoCruise()
|
||||
{
|
||||
if(UseNewNavigationAlgorithm.Value)
|
||||
return;
|
||||
AutoCruiseEnabled.Value = !AutoCruiseEnabled.Value;
|
||||
if (!DSPGame.IsMenuDemo && GameMain.isRunning)
|
||||
{
|
||||
UIRoot.instance.uiGame.generalTips.InvokeRealtimeTipAhead((AutoCruiseEnabled.Value ? I18NKeys.AutoCruiseOn : I18NKeys.AutoCruiseOff).Translate());
|
||||
}
|
||||
}
|
||||
|
||||
private static bool UpdateMovementState(PlayerController controller)
|
||||
{
|
||||
var movementStateChanged = controller.movementStateInFrame != _movementState;
|
||||
if (movementStateChanged)
|
||||
{
|
||||
_movementState = controller.movementStateInFrame;
|
||||
}
|
||||
return movementStateChanged;
|
||||
}
|
||||
// Harmony transpiler: PlayerController_GameTick_Transpiler
|
||||
// Target: PlayerController.GameTick
|
||||
// Fallback: None — patch will fail loudly if the target method body changes.
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(PlayerController), nameof(PlayerController.GameTick))]
|
||||
private static IEnumerable<CodeInstruction> PlayerController_GameTick_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(OpCodes.Callvirt, AccessTools.Method(typeof(BuildModel), nameof(BuildModel.EarlyGameTickIgnoreActive)))
|
||||
).Advance(1).InsertAndAdvance(
|
||||
new CodeInstruction(OpCodes.Ldarg_0),
|
||||
Transpilers.EmitDelegate((PlayerController controller) =>
|
||||
{
|
||||
if (UseNewNavigationAlgorithm.Value)
|
||||
return;
|
||||
/* Update target astro if changed */
|
||||
_speedUp = false;
|
||||
var player = controller.player;
|
||||
if (player.mecha.thrusterLevel < 2) return;
|
||||
var navi = player.navigation;
|
||||
var astroChanged = navi.indicatorAstroId != _indicatorAstroId;
|
||||
if (astroChanged)
|
||||
{
|
||||
_indicatorAstroId = navi.indicatorAstroId;
|
||||
Functions.UIFunctions.UpdateToggleAutoCruiseCheckButtonVisiblility();
|
||||
}
|
||||
if (_indicatorAstroId == 0) return;
|
||||
switch (controller.movementStateInFrame)
|
||||
{
|
||||
case EMovementState.Walk:
|
||||
case EMovementState.Drift:
|
||||
if (!AutoCruiseEnabled.Value) return;
|
||||
if (GameMain.localStar?.astroId == _indicatorAstroId) return;
|
||||
UpdateMovementState(controller);
|
||||
/* Press jump key to fly */
|
||||
controller.input0.z = 1f;
|
||||
break;
|
||||
case EMovementState.Fly:
|
||||
if (!AutoCruiseEnabled.Value) return;
|
||||
if (GameMain.localStar?.astroId == _indicatorAstroId) return;
|
||||
UpdateMovementState(controller);
|
||||
/* Keep moving forward and pulling up to sail */
|
||||
controller.input0.y = 1f;
|
||||
controller.input1.y = 1f;
|
||||
break;
|
||||
case EMovementState.Sail:
|
||||
if (VFInput._pullUp.pressing || VFInput._pushDown.pressing || VFInput._moveLeft.pressing || VFInput._moveRight.pressing ||
|
||||
(!player.warping && UIRoot.instance.uiGame.disableLockCursor && (VFInput._moveForward.pressing || VFInput._moveBackward.pressing)))
|
||||
return;
|
||||
var movementStateChanged = UpdateMovementState(controller);
|
||||
var playerPos = player.uPosition;
|
||||
var isHive = _indicatorAstroId > 1000000;
|
||||
ref var astro = ref isHive ? ref GameMain.spaceSector.astros[_indicatorAstroId - 1000000] : ref GameMain.galaxy.astrosData[_indicatorAstroId];
|
||||
var astroVec = astro.uPos - playerPos;
|
||||
var distance = astroVec.magnitude;
|
||||
astroVec = astroVec.normalized;
|
||||
if (astroChanged || movementStateChanged)
|
||||
{
|
||||
controller.actionSail.sailPoser.targetURotWanted = Quaternion.LookRotation(astroVec);
|
||||
}
|
||||
if (distance < astro.type switch
|
||||
{
|
||||
EAstroType.Planet => 800.0 + astro.uRadius,
|
||||
EAstroType.Star => 4000.0 + astro.uRadius,
|
||||
EAstroType.EnemyHive => 800.0,
|
||||
_ => 2000.0 + astro.uRadius
|
||||
})
|
||||
{
|
||||
if (isHive)
|
||||
{
|
||||
player.uVelocity = Vector3.zero;
|
||||
}
|
||||
return;
|
||||
}
|
||||
var autoCruise = AutoCruiseEnabled.Value;
|
||||
if (GameMain.instance.timei % 6 == 0 || _direction == Vector3.zero)
|
||||
{
|
||||
_direction = astroVec;
|
||||
|
||||
/* Check nearest astroes, try to bypass them */
|
||||
var localStar = GameMain.localStar;
|
||||
_canUseWarper = autoCruise && player.mecha.thrusterLevel >= 3 && !player.warping && player.mecha.HasWarper();
|
||||
if (localStar != null)
|
||||
{
|
||||
var nearestRange = (playerPos - localStar.uPosition).sqrMagnitude;
|
||||
var nearestPos = localStar.uPosition;
|
||||
var nearestAstroId = localStar.astroId;
|
||||
foreach (var p in localStar.planets)
|
||||
{
|
||||
var range = (playerPos - p.uPosition).sqrMagnitude;
|
||||
if (range >= nearestRange) continue;
|
||||
nearestRange = range;
|
||||
nearestPos = p.uPosition;
|
||||
nearestAstroId = p.astroId;
|
||||
}
|
||||
|
||||
/* If targeting hives, do not bypass them */
|
||||
if (!isHive)
|
||||
{
|
||||
var hiveSys = GameMain.spaceSector.dfHives[localStar.index];
|
||||
while (hiveSys != null)
|
||||
{
|
||||
if (hiveSys.realized && hiveSys.hiveAstroId > 1000000)
|
||||
{
|
||||
ref var hiveAstro = ref GameMain.spaceSector.astros[hiveSys.hiveAstroId - 1000000];
|
||||
/* Divide by 36, so that the real range is 6 times of the calculated range,
|
||||
which means the minimal range allowed is 12000 */
|
||||
var range = (playerPos - hiveAstro.uPos).sqrMagnitude / 36.0;
|
||||
if (range < nearestRange)
|
||||
{
|
||||
nearestRange = range;
|
||||
nearestPos = hiveAstro.uPos;
|
||||
nearestAstroId = hiveSys.hiveAstroId;
|
||||
}
|
||||
}
|
||||
|
||||
hiveSys = hiveSys.nextSibling;
|
||||
}
|
||||
}
|
||||
|
||||
if (nearestAstroId != _indicatorAstroId && nearestRange < 2000.0 * 2000.0)
|
||||
{
|
||||
Vector3 leavingDirection = (playerPos - nearestPos).normalized;
|
||||
var dot = Vector3.Dot(leavingDirection, _direction);
|
||||
if (dot < 0)
|
||||
{
|
||||
var cross = Vector3.Cross(_direction, leavingDirection);
|
||||
_direction = Vector3.Cross(leavingDirection, cross).normalized;
|
||||
}
|
||||
else
|
||||
{
|
||||
_direction = leavingDirection;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Vector3 uVel = player.uVelocity;
|
||||
var speed = uVel.magnitude;
|
||||
if (player.warping)
|
||||
{
|
||||
if (autoCruise)
|
||||
{
|
||||
var actionSail = controller.actionSail;
|
||||
_speedUp = actionSail.currentWarpSpeed < actionSail.maxWarpSpeed;
|
||||
/* Speed down if too close */
|
||||
if (distance < GalaxyData.LY * 1.5)
|
||||
{
|
||||
if (distance < actionSail.currentWarpSpeed * distance switch
|
||||
{
|
||||
> GalaxyData.LY * 0.6 => 0.33,
|
||||
> GalaxyData.LY * 0.3 => 0.5,
|
||||
> GalaxyData.LY * 0.1 => 0.66,
|
||||
_ => 1.0
|
||||
})
|
||||
{
|
||||
controller.input0.y = -1f;
|
||||
_speedUp = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_speedUp = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var mecha = player.mecha;
|
||||
var energyRatio = mecha.coreEnergy / mecha.coreEnergyCap;
|
||||
if (_canUseWarper && GameMain.localPlanet == null && distance > GalaxyData.AU * DistanceToWarp.Value && energyRatio >= 0.8 && player.mecha.UseWarper())
|
||||
{
|
||||
player.warpCommand = true;
|
||||
VFAudio.Create("warp-begin", player.transform, Vector3.zero, true);
|
||||
controller.actionSail.sailPoser.targetURotWanted = Quaternion.LookRotation(astroVec);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Speed up if needed */
|
||||
_speedUp = autoCruise && AutoBoostEnabled.Value && speed + 0.2f < player.mecha.maxSailSpeed && energyRatio >= 0.1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Update direction, gracefully rotate for 2 degrees for each frame */
|
||||
var angle = Vector3.Angle(uVel, _direction);
|
||||
if (angle < 2f)
|
||||
{
|
||||
player.uVelocity = _direction * speed;
|
||||
}
|
||||
else
|
||||
{
|
||||
player.uVelocity = Vector3.Slerp(uVel, _direction * speed, 2f / angle);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
_speedUp = false;
|
||||
break;
|
||||
}
|
||||
})
|
||||
);
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
// Harmony transpiler: VFInput_sailSpeedUp_Transpiler
|
||||
// Target: VFInput._sailSpeedUp (getter)
|
||||
// Fallback: None — patch will fail loudly if the target method body changes.
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(VFInput), nameof(VFInput._sailSpeedUp), MethodType.Getter)]
|
||||
private static IEnumerable<CodeInstruction> VFInput_sailSpeedUp_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
var matcher = new CodeMatcher(instructions, generator);
|
||||
matcher.MatchForward(false,
|
||||
new CodeMatch(OpCodes.Ret)
|
||||
);
|
||||
matcher.Repeat(m => m.InsertAndAdvance(
|
||||
new CodeInstruction(OpCodes.Ldsfld, AccessTools.Field(typeof(AutoNavigation), nameof(_speedUp))),
|
||||
new CodeInstruction(OpCodes.Or)
|
||||
).Advance(1));
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
|
||||
/* Disable Lock Cursor Mode on entering sail panel
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(UISailPanel), nameof(UISailPanel._OnOpen))]
|
||||
public static void OnOpen_Prefix()
|
||||
{
|
||||
UIRoot.instance.uiGame.disableLockCursor = true;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
#region New navigation algorithm
|
||||
|
||||
public class AutoNavigationG : PatchImpl<AutoNavigationG>
|
||||
public class AutoNavigation : PatchImpl<AutoNavigation>
|
||||
{
|
||||
private const double Epsilon = 1e-18;
|
||||
private const int DarkFogAstroIdStart = 1000000;
|
||||
@@ -660,7 +377,6 @@ public class PlayerPatch : PatchImpl<PlayerPatch>
|
||||
private static int EscapeAstroId { get; set; }
|
||||
private static bool FollowModeLock { get; set; }
|
||||
|
||||
private static bool _normalizingNavigationMode;
|
||||
|
||||
public static bool IsActive => IsEnable;
|
||||
|
||||
@@ -685,11 +401,11 @@ public class PlayerPatch : PatchImpl<PlayerPatch>
|
||||
|
||||
public static void Awake(ConfigFile config)
|
||||
{
|
||||
UseNewNavigationAlgorithm = config.Bind(
|
||||
AutoCruiseEnabled = config.Bind(
|
||||
"Player",
|
||||
nameof(UseNewNavigationAlgorithm),
|
||||
"AutoCruise",
|
||||
true,
|
||||
"Use the new navigation algorithm");
|
||||
"Enable auto-cruise");
|
||||
StopOnArrivalAndInput = config.Bind("Player", nameof(StopOnArrivalAndInput), true, "Stop auto-navigation on arrival or manual input");
|
||||
UseWarper = config.Bind("Player", nameof(UseWarper), true, "Use warp during auto-navigation");
|
||||
UseWarperMinimalEnergy = config.Bind<double>(
|
||||
@@ -719,9 +435,7 @@ public class PlayerPatch : PatchImpl<PlayerPatch>
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
AutoNavigationEnabled.SettingChanged += NavigationModeChanged;
|
||||
UseNewNavigationAlgorithm.SettingChanged += NavigationModeChanged;
|
||||
NormalizeNavigationMode();
|
||||
AutoCruiseEnabled.SettingChanged += NavigationModeChanged;
|
||||
}
|
||||
|
||||
public static void StartG( )
|
||||
@@ -743,6 +457,8 @@ public class PlayerPatch : PatchImpl<PlayerPatch>
|
||||
|
||||
public static void Toggle()
|
||||
{
|
||||
if (!AutoCruiseEnabled.Value)
|
||||
return;
|
||||
if (EnableTag)
|
||||
StopAutoNavigation();
|
||||
else
|
||||
@@ -795,8 +511,10 @@ public class PlayerPatch : PatchImpl<PlayerPatch>
|
||||
|
||||
private static void NavigationModeChanged(object sender, EventArgs args)
|
||||
{
|
||||
NormalizeNavigationMode();
|
||||
if (!AutoCruiseEnabled.Value)
|
||||
StopAutoNavigation(false);
|
||||
UpdateUiTip();
|
||||
global::UXAssist.Functions.UIFunctions.UpdateToggleAutoCruiseCheckButtonVisiblility();
|
||||
}
|
||||
|
||||
public static void UpdateUiTip()
|
||||
@@ -804,7 +522,7 @@ public class PlayerPatch : PatchImpl<PlayerPatch>
|
||||
if (UiTipText == null)
|
||||
return;
|
||||
|
||||
bool showTip = GameMain.isRunning && !DSPGame.IsMenuDemo && UseNewNavigationAlgorithm.Value && !AutoNavigationEnabled.Value && (EnableTag || HasNavigationTarget());
|
||||
bool showTip = GameMain.isRunning && !DSPGame.IsMenuDemo && AutoCruiseEnabled.Value && (EnableTag || HasNavigationTarget());
|
||||
UiTipText.gameObject.SetActive(showTip);
|
||||
if (!showTip)
|
||||
return;
|
||||
@@ -814,7 +532,7 @@ public class PlayerPatch : PatchImpl<PlayerPatch>
|
||||
: string.Format(I18NKeys.AutoNavigationEnableHint.Translate(), KeyBindings.GetKeyBindingText(_autoDriveKey));
|
||||
}
|
||||
|
||||
private static bool HasNavigationTarget()
|
||||
public static bool HasNavigationTarget()
|
||||
{
|
||||
Player player = GameMain.mainPlayer;
|
||||
if (player == null)
|
||||
@@ -828,16 +546,6 @@ public class PlayerPatch : PatchImpl<PlayerPatch>
|
||||
return GameMain.localPlanet == null || indicatorAstroId != GameMain.localPlanet.astroId;
|
||||
}
|
||||
|
||||
private static void NormalizeNavigationMode()
|
||||
{
|
||||
if (_normalizingNavigationMode || !AutoNavigationEnabled.Value || !UseNewNavigationAlgorithm.Value)
|
||||
return;
|
||||
_normalizingNavigationMode = true;
|
||||
UseNewNavigationAlgorithm.Value = false;
|
||||
_normalizingNavigationMode = false;
|
||||
StopAutoNavigation(false);
|
||||
}
|
||||
|
||||
private static void Pause( ) => PauseTag = true;
|
||||
|
||||
private static void Resume( ) => PauseTag = false;
|
||||
@@ -851,12 +559,7 @@ public class PlayerPatch : PatchImpl<PlayerPatch>
|
||||
{
|
||||
int previousTargetId = TargetId;
|
||||
ESpaceGuideType previousTargetType = TargetType;
|
||||
if (! UseNewNavigationAlgorithm.Value)
|
||||
{
|
||||
StopAutoNavigation( );
|
||||
return true;
|
||||
}
|
||||
if (AutoNavigationEnabled.Value)
|
||||
if (! AutoCruiseEnabled.Value)
|
||||
{
|
||||
StopAutoNavigation( );
|
||||
return true;
|
||||
@@ -1318,9 +1021,10 @@ public class PlayerPatch : PatchImpl<PlayerPatch>
|
||||
|
||||
// Smooth velocity changes.
|
||||
VectorLF3 targetVelocity = targetDir * stepSpeed;
|
||||
float angle = Vector3.Angle(targetVelocity, currentVel);
|
||||
var t = (float)(1.6 / Mathf.Max(10, angle));
|
||||
VectorLF3 dVelocity = (VectorLF3)Vector3.Slerp(currentVel, targetVelocity, t) - currentVel;
|
||||
float angle = Vector3.Angle(targetVelocity, currentVel);
|
||||
var t = 1.6f / Mathf.Max(10f, angle);
|
||||
VectorLF3 smoothedVelocity = SmoothVelocity(currentVel, targetVelocity, t, sail.sailPoser.targetURot * Vector3.up);
|
||||
VectorLF3 dVelocity = smoothedVelocity - currentVel;
|
||||
sail.UseSailEnergy(ref dVelocity, 0.36);
|
||||
VectorLF3 newVelocity = currentVel + dVelocity;
|
||||
|
||||
@@ -1329,6 +1033,51 @@ public class PlayerPatch : PatchImpl<PlayerPatch>
|
||||
UpdateRotation(controller: controller);
|
||||
}
|
||||
|
||||
private static VectorLF3 SmoothVelocity(
|
||||
VectorLF3 currentVelocity,
|
||||
VectorLF3 targetVelocity,
|
||||
float interpolation,
|
||||
VectorLF3 turnReference)
|
||||
{
|
||||
double currentMagnitude = currentVelocity.magnitude;
|
||||
double targetMagnitude = targetVelocity.magnitude;
|
||||
if (currentMagnitude < Epsilon && targetMagnitude < Epsilon)
|
||||
return VectorLF3.zero;
|
||||
|
||||
Vector3 currentDirection = currentMagnitude >= Epsilon
|
||||
? (Vector3)(currentVelocity / currentMagnitude)
|
||||
: (targetMagnitude >= Epsilon ? (Vector3)(targetVelocity / targetMagnitude) : Vector3.forward);
|
||||
Vector3 targetDirection = targetMagnitude >= Epsilon
|
||||
? (Vector3)(targetVelocity / targetMagnitude)
|
||||
: currentDirection;
|
||||
Vector3 direction;
|
||||
if (Vector3.Dot(currentDirection, targetDirection) < -0.9999f)
|
||||
{
|
||||
float angle = Vector3.Angle(currentDirection, targetDirection);
|
||||
Vector3 axis = GetStableTurnAxis(currentDirection, (Vector3)turnReference);
|
||||
direction = Quaternion.AngleAxis(angle * interpolation, axis) * currentDirection;
|
||||
}
|
||||
else
|
||||
{
|
||||
direction = Vector3.Slerp(currentDirection, targetDirection, interpolation);
|
||||
}
|
||||
|
||||
double magnitude = currentMagnitude + (targetMagnitude - currentMagnitude) * interpolation;
|
||||
return (VectorLF3)(direction.normalized * (float)magnitude);
|
||||
}
|
||||
|
||||
private static Vector3 GetStableTurnAxis(Vector3 direction, Vector3 reference)
|
||||
{
|
||||
Vector3 projectedReference = reference - direction * Vector3.Dot(reference, direction);
|
||||
if (projectedReference.sqrMagnitude < 1e-10f)
|
||||
{
|
||||
projectedReference = Vector3.Cross(direction, Vector3.right);
|
||||
if (projectedReference.sqrMagnitude < 1e-10f)
|
||||
projectedReference = Vector3.Cross(direction, Vector3.up);
|
||||
}
|
||||
return Vector3.Cross(direction, projectedReference).normalized;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates player orientation.
|
||||
/// </summary>
|
||||
|
||||
+77
-105
@@ -698,117 +698,89 @@ public static class UIConfigWindow
|
||||
|
||||
{
|
||||
y += 36f;
|
||||
var autoNavCheckBox = wnd.AddCheckBox(x, y, tab4, PlayerPatch.AutoNavigationEnabled, I18NKeys.AutoNavigationOnSailings);
|
||||
var autoCruiseCheckBox = wnd.AddCheckBox(x, y, tab4, PlayerPatch.AutoCruiseEnabled, I18NKeys.EnableAutoCruise);
|
||||
y += 27f;
|
||||
var autoCruiseCheckBox = wnd.AddCheckBox(x + 20f, y, tab4, PlayerPatch.AutoCruiseEnabled, I18NKeys.EnableAutoCruise, 13);
|
||||
var autoStopCheckBox = wnd.AddCheckBox(x + 20f, y, tab4, PlayerPatch.StopOnArrivalAndInput, I18NKeys.StopAutoNavigationOnManualInput, 13);
|
||||
y += 27f;
|
||||
var autoBoostCheckBox = wnd.AddCheckBox(x + 20f, y, tab4, PlayerPatch.AutoBoostEnabled, I18NKeys.AutoBoost, 13);
|
||||
var useWarpCheckBox = wnd.AddCheckBox(x + 20f, y, tab4, PlayerPatch.UseWarper, I18NKeys.UseWarp, 13);
|
||||
y += 27f;
|
||||
txt = wnd.AddText2(x + 20f, y, tab4, I18NKeys.DistanceToUseWarp, 15, "text-distance-to-warp");
|
||||
var navDistanceSlider = wnd.AddSlider(x + 20f + UI.Util.GetPreferredWidth(txt) + 5f, y + 6f, tab4, PlayerPatch.DistanceToWarp, new DistanceMapper(), "0.0", 100f);
|
||||
txt = wnd.AddText2(x + 20f, y, tab4, I18NKeys.UseWarpMinimalEnergy, 13, "use-warp-minimal-energy");
|
||||
var warpEnergySlider = wnd.AddSideSlider(
|
||||
x + 20f + UI.Util.GetPreferredWidth(txt) + 5f,
|
||||
y + 6f,
|
||||
tab4,
|
||||
PlayerPatch.UseWarperMinimalEnergy,
|
||||
new EnergyMapper( ),
|
||||
"0",
|
||||
200f,
|
||||
- 100f).WithFontSize(13);
|
||||
y += 27f;
|
||||
txt = wnd.AddText2(x + 20f, y, tab4, I18NKeys.DistanceToUseWarp, 13, "text-new-navigation-distance-to-warp");
|
||||
var newNavDistanceSlider = wnd.AddSlider(
|
||||
x + 20f + UI.Util.GetPreferredWidth(txt) + 5f,
|
||||
y + 6f,
|
||||
tab4,
|
||||
PlayerPatch.UseWarperDistance,
|
||||
new DistanceMapper( ),
|
||||
"0.0",
|
||||
200f);
|
||||
y += 27f;
|
||||
var speedUpCheckBox = wnd.AddCheckBox(x + 20f, y, tab4, PlayerPatch.UseSpeedUp, I18NKeys.AutoBoost, 13);
|
||||
y += 27f;
|
||||
txt = wnd.AddText2(x + 20f, y, tab4, I18NKeys.AutoBoostMinimalEnergy, 13, "auto-boost-minimal-energy");
|
||||
var speedUpEnergySlider = wnd.AddSideSlider(
|
||||
x + 20f + UI.Util.GetPreferredWidth(txt) + 5f,
|
||||
y + 6f,
|
||||
tab4,
|
||||
PlayerPatch.UseSpeedUpMinimalEnergy,
|
||||
new EnergyMapper( ),
|
||||
"0",
|
||||
200f,
|
||||
- 100f).WithFontSize(13);
|
||||
y += 27f;
|
||||
txt = wnd.AddText2(x + 20f, y, tab4, I18NKeys.DarkFogHiveFollowDistance, 13, "dark-fog-hive-follow-distance");
|
||||
var dfHiveSlider = wnd.AddSideSlider(
|
||||
x + 20f + UI.Util.GetPreferredWidth(txt) + 5f,
|
||||
y + 6f,
|
||||
tab4,
|
||||
PlayerPatch.DFHiveFollowDistance,
|
||||
new DistanceMapperHive( ),
|
||||
"0.0",
|
||||
200f,
|
||||
- 100f).WithFontSize(13);
|
||||
y += 27f;
|
||||
txt = wnd.AddText2(x + 20f, y, tab4, I18NKeys.DarkFogCarrierFollowDistance, 13, "dark-fog-carrier-follow-distance");
|
||||
var dfCarrierSlider = wnd.AddSideSlider(
|
||||
x + 20f + UI.Util.GetPreferredWidth(txt) + 5f,
|
||||
y + 6f,
|
||||
tab4,
|
||||
PlayerPatch.DFCarrierFollowDistance,
|
||||
new DistanceMapperCarrier( ),
|
||||
"0.0",
|
||||
200f,
|
||||
- 100f).WithFontSize(13);
|
||||
|
||||
y += 36f;
|
||||
MyCheckBox newAlgorithmCheckBox = wnd.AddCheckBox(
|
||||
x,
|
||||
y,
|
||||
tab4,
|
||||
PlayerPatch.UseNewNavigationAlgorithm,
|
||||
I18NKeys.NewNavigationAlgorithm);
|
||||
y += 27f;
|
||||
MyCheckBox autoStopCheckBox = wnd.AddCheckBox(
|
||||
x,
|
||||
y,
|
||||
tab4,
|
||||
PlayerPatch.StopOnArrivalAndInput,
|
||||
I18NKeys.StopAutoNavigationOnManualInput);
|
||||
y += 27f;
|
||||
MyCheckBox useWarpCheckBox = wnd.AddCheckBox(x, y, tab4, PlayerPatch.UseWarper, I18NKeys.UseWarp);
|
||||
y += 27f;
|
||||
txt = wnd.AddText2(x + 20f, y, tab4, I18NKeys.UseWarpMinimalEnergy, 15, "use-warp-minimal-energy");
|
||||
var warpEnergySlider = wnd.AddSideSlider(
|
||||
x + 20f + UI.Util.GetPreferredWidth(txt) + 5f,
|
||||
y + 6f,
|
||||
tab4,
|
||||
PlayerPatch.UseWarperMinimalEnergy,
|
||||
new EnergyMapper( ),
|
||||
"0",
|
||||
200f,
|
||||
- 100f).WithFontSize(13);
|
||||
y += 27f;
|
||||
txt = wnd.AddText2(x + 20f, y, tab4, I18NKeys.DistanceToUseWarp, 15, "text-new-navigation-distance-to-warp");
|
||||
var newNavDistanceSlider = wnd.AddSlider(
|
||||
x + 20f + UI.Util.GetPreferredWidth(txt) + 5f,
|
||||
y + 6f,
|
||||
tab4,
|
||||
PlayerPatch.UseWarperDistance,
|
||||
new DistanceMapper( ),
|
||||
"0.0",
|
||||
200f);
|
||||
y += 27f;
|
||||
MyCheckBox speedUpCheckBox = wnd.AddCheckBox(x, y, tab4, PlayerPatch.UseSpeedUp, I18NKeys.AutoBoost);
|
||||
y += 27f;
|
||||
txt = wnd.AddText2(x + 20f, y, tab4, I18NKeys.AutoBoostMinimalEnergy, 15, "auto-boost-minimal-energy");
|
||||
var speedUpEnergySlider = wnd.AddSideSlider(
|
||||
x + 20f + UI.Util.GetPreferredWidth(txt) + 5f,
|
||||
y + 6f,
|
||||
tab4,
|
||||
PlayerPatch.UseSpeedUpMinimalEnergy,
|
||||
new EnergyMapper( ),
|
||||
"0",
|
||||
200f,
|
||||
- 100f).WithFontSize(13);
|
||||
y += 27f;
|
||||
txt = wnd.AddText2(x, y, tab4, I18NKeys.DarkFogHiveFollowDistance, 15, "dark-fog-hive-follow-distance");
|
||||
var dfHiveSlider = wnd.AddSideSlider(
|
||||
x + UI.Util.GetPreferredWidth(txt) + 5f,
|
||||
y + 6f,
|
||||
tab4,
|
||||
PlayerPatch.DFHiveFollowDistance,
|
||||
new DistanceMapperHive( ),
|
||||
"0.0",
|
||||
200f,
|
||||
- 100f).WithFontSize(13);
|
||||
y += 27f;
|
||||
txt = wnd.AddText2(x, y, tab4, I18NKeys.DarkFogCarrierFollowDistance, 15, "dark-fog-carrier-follow-distance");
|
||||
var dfCarrierSlider = wnd.AddSideSlider(
|
||||
x + UI.Util.GetPreferredWidth(txt) + 5f,
|
||||
y + 6f,
|
||||
tab4,
|
||||
PlayerPatch.DFCarrierFollowDistance,
|
||||
new DistanceMapperCarrier( ),
|
||||
"0.0",
|
||||
200f,
|
||||
- 100f).WithFontSize(13);
|
||||
PlayerPatch.AutoCruiseEnabled.SettingChanged += NavSettingChanged;
|
||||
PlayerPatch.UseWarper.SettingChanged += NavSettingChanged;
|
||||
PlayerPatch.UseSpeedUp.SettingChanged += NavSettingChanged;
|
||||
wnd.OnFree += ( ) => { PlayerPatch.AutoCruiseEnabled.SettingChanged -= NavSettingChanged; };
|
||||
wnd.OnFree += ( ) => { PlayerPatch.UseWarper.SettingChanged -= NavSettingChanged; };
|
||||
wnd.OnFree += ( ) => { PlayerPatch.UseSpeedUp.SettingChanged -= NavSettingChanged; };
|
||||
NavSettingChanged(null, null);
|
||||
|
||||
PlayerPatch.AutoNavigationEnabled.SettingChanged += NavSettingChanged;
|
||||
PlayerPatch.UseNewNavigationAlgorithm.SettingChanged += NavSettingChanged;
|
||||
PlayerPatch.UseWarper.SettingChanged += NavSettingChanged;
|
||||
PlayerPatch.UseSpeedUp.SettingChanged += NavSettingChanged;
|
||||
wnd.OnFree += ( ) => { PlayerPatch.AutoNavigationEnabled.SettingChanged -= NavSettingChanged; };
|
||||
wnd.OnFree += ( ) => { PlayerPatch.UseNewNavigationAlgorithm.SettingChanged -= NavSettingChanged; };
|
||||
wnd.OnFree += ( ) => { PlayerPatch.UseWarper.SettingChanged -= NavSettingChanged; };
|
||||
wnd.OnFree += ( ) => { PlayerPatch.UseSpeedUp.SettingChanged -= NavSettingChanged; };
|
||||
NavSettingChanged(null, null);
|
||||
|
||||
void NavSettingChanged(object o, EventArgs e)
|
||||
{
|
||||
autoNavCheckBox.SetEnable(! PlayerPatch.UseNewNavigationAlgorithm.Value);
|
||||
autoCruiseCheckBox.SetEnable(PlayerPatch.AutoNavigationEnabled.Value);
|
||||
autoBoostCheckBox.SetEnable(PlayerPatch.AutoNavigationEnabled.Value);
|
||||
navDistanceSlider.SetEnable(PlayerPatch.AutoNavigationEnabled.Value);
|
||||
|
||||
newAlgorithmCheckBox.SetEnable(! PlayerPatch.AutoNavigationEnabled.Value);
|
||||
autoStopCheckBox.SetEnable(PlayerPatch.UseNewNavigationAlgorithm.Value);
|
||||
useWarpCheckBox.SetEnable(PlayerPatch.UseNewNavigationAlgorithm.Value);
|
||||
warpEnergySlider.SetEnable(PlayerPatch.UseNewNavigationAlgorithm.Value && PlayerPatch.UseWarper.Value);
|
||||
newNavDistanceSlider.SetEnable(PlayerPatch.UseNewNavigationAlgorithm.Value && PlayerPatch.UseWarper.Value);
|
||||
speedUpCheckBox.SetEnable(PlayerPatch.UseNewNavigationAlgorithm.Value);
|
||||
speedUpEnergySlider.SetEnable(PlayerPatch.UseNewNavigationAlgorithm.Value && PlayerPatch.UseSpeedUp.Value);
|
||||
dfHiveSlider.SetEnable(PlayerPatch.UseNewNavigationAlgorithm.Value);
|
||||
dfCarrierSlider.SetEnable(PlayerPatch.UseNewNavigationAlgorithm.Value);
|
||||
}
|
||||
void NavSettingChanged(object o, EventArgs e)
|
||||
{
|
||||
autoCruiseCheckBox.SetEnable(true);
|
||||
autoStopCheckBox.SetEnable(PlayerPatch.AutoCruiseEnabled.Value);
|
||||
useWarpCheckBox.SetEnable(PlayerPatch.AutoCruiseEnabled.Value);
|
||||
warpEnergySlider.SetEnable(PlayerPatch.AutoCruiseEnabled.Value && PlayerPatch.UseWarper.Value);
|
||||
newNavDistanceSlider.SetEnable(PlayerPatch.AutoCruiseEnabled.Value && PlayerPatch.UseWarper.Value);
|
||||
speedUpCheckBox.SetEnable(PlayerPatch.AutoCruiseEnabled.Value);
|
||||
speedUpEnergySlider.SetEnable(PlayerPatch.AutoCruiseEnabled.Value && PlayerPatch.UseSpeedUp.Value);
|
||||
dfHiveSlider.SetEnable(PlayerPatch.AutoCruiseEnabled.Value);
|
||||
dfCarrierSlider.SetEnable(PlayerPatch.AutoCruiseEnabled.Value);
|
||||
}
|
||||
}
|
||||
|
||||
var tab5 = wnd.AddTab(trans, I18NKeys.DysonSphere);
|
||||
x = 0f;
|
||||
y = 10f;
|
||||
|
||||
@@ -216,13 +216,6 @@ public class UXAssist : BaseUnityPlugin, IModCanSave
|
||||
"Hide tips for getting soil piles");
|
||||
PlayerPatch.ShortcutKeysForStarsNameEnabled = Config.Bind("Player", "ShortcutKeysForStarsName", false,
|
||||
"Shortcut keys for showing stars' name");
|
||||
PlayerPatch.AutoNavigationEnabled = Config.Bind("Player", "AutoNavigation", false,
|
||||
"Auto navigation");
|
||||
PlayerPatch.AutoCruiseEnabled = Config.Bind("Player", "AutoCruise", false,
|
||||
"Auto-cruise enabled");
|
||||
PlayerPatch.AutoBoostEnabled = Config.Bind("Player", "AutoBoost", false,
|
||||
"Auto boost speed with auto-cruise enabled");
|
||||
PlayerPatch.DistanceToWarp = Config.Bind("Player", "DistanceToWarp", 5.0, "Distance to warp (in AU)");
|
||||
TechPatch.SorterCargoStackingEnabled = Config.Bind("Tech", "SorterCargoStacking", false,
|
||||
"Restore upgrades of `Sorter Cargo Stacking` on panel");
|
||||
TechPatch.DisableBattleRelatedTechsInPeaceModeEnabled = Config.Bind("Tech", "DisableBattleRelatedTechsInPeaceMode", false,
|
||||
@@ -236,7 +229,7 @@ public class UXAssist : BaseUnityPlugin, IModCanSave
|
||||
DysonSpherePatch.AutoConstructMultiplier = Config.Bind("DysonSphere", "AutoConstructMultiplier", 1, "Dyson Sphere auto-construct speed multiplier");
|
||||
UIPatch.PlanetVeinUtilizationEnabled = Config.Bind("UI", "PlanetVeinUtilization", false,
|
||||
"Planet vein utilization");
|
||||
PlayerPatch.AutoNavigationG.Awake(Config);
|
||||
PlayerPatch.AutoNavigation.Awake(Config);
|
||||
|
||||
I18N.Init();
|
||||
I18NKeys.Register();
|
||||
|
||||
@@ -409,21 +409,12 @@ Total classified fields: **298**
|
||||
| `UXAssist/Patches/PlayerPatch.cs` | 13 | `public static ConfigEntry<bool> EnhancedMechaForgeCountControlEnabled;` | LifecycleSafe |
|
||||
| `UXAssist/Patches/PlayerPatch.cs` | 14 | `public static ConfigEntry<bool> HideTipsForSandsChangesEnabled;` | LifecycleSafe |
|
||||
| `UXAssist/Patches/PlayerPatch.cs` | 15 | `public static ConfigEntry<bool> ShortcutKeysForStarsNameEnabled;` | LifecycleSafe |
|
||||
| `UXAssist/Patches/PlayerPatch.cs` | 16 | `public static ConfigEntry<bool> AutoNavigationEnabled;` | LifecycleSafe |
|
||||
| `UXAssist/Patches/PlayerPatch.cs` | 17 | `public static ConfigEntry<bool> AutoCruiseEnabled;` | LifecycleSafe |
|
||||
| `UXAssist/Patches/PlayerPatch.cs` | 18 | `public static ConfigEntry<bool> AutoBoostEnabled;` | LifecycleSafe |
|
||||
| `UXAssist/Patches/PlayerPatch.cs` | 19 | `public static ConfigEntry<double> DistanceToWarp;` | LifecycleSafe |
|
||||
| `UXAssist/Patches/PlayerPatch.cs` | 20 | `private static PressKeyBind _showAllStarsNameKey;` | LifecycleSafe |
|
||||
| `UXAssist/Patches/PlayerPatch.cs` | 21 | `private static PressKeyBind _toggleAllStarsNameKey;` | LifecycleSafe |
|
||||
| `UXAssist/Patches/PlayerPatch.cs` | 22 | `private static PressKeyBind _autoDriveKey;` | LifecycleSafe |
|
||||
| `UXAssist/Patches/PlayerPatch.cs` | 194 | `public static int ShowAllStarsNameStatus;` | NeedsReset |
|
||||
| `UXAssist/Patches/PlayerPatch.cs` | 195 | `public static bool ForceShowAllStarsName;` | NeedsReset |
|
||||
| `UXAssist/Patches/PlayerPatch.cs` | 196 | `public static bool ForceShowAllStarsNameExternal;` | NeedsReset |
|
||||
| `UXAssist/Patches/PlayerPatch.cs` | 328 | `private static bool _canUseWarper;` | NeedsReset |
|
||||
| `UXAssist/Patches/PlayerPatch.cs` | 329 | `private static int _indicatorAstroId;` | NeedsReset |
|
||||
| `UXAssist/Patches/PlayerPatch.cs` | 330 | `private static bool _speedUp;` | NeedsReset |
|
||||
| `UXAssist/Patches/PlayerPatch.cs` | 331 | `private static Vector3 _direction;` | NeedsReset |
|
||||
| `UXAssist/Patches/PlayerPatch.cs` | 332 | `private static EMovementState _movementState = EMovementState.Walk;` | NeedsReset |
|
||||
|
||||
### Patches/TechPatch.cs
|
||||
|
||||
@@ -745,11 +736,6 @@ UXAssist/Patches/PlayerPatch.cs:182: private static IEnumerable<CodeInstr
|
||||
UXAssist/Patches/PlayerPatch.cs:221: private static void UIStarmap__OnOpen_Prefix()
|
||||
UXAssist/Patches/PlayerPatch.cs:228: private static IEnumerable<CodeInstruction> UIStarmapPlanet__OnLateUpdate_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
UXAssist/Patches/PlayerPatch.cs:276: private static IEnumerable<CodeInstruction> UIStarmapDFHive__OnLateUpdate_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
UXAssist/Patches/PlayerPatch.cs:328: private static bool _canUseWarper;
|
||||
UXAssist/Patches/PlayerPatch.cs:329: private static int _indicatorAstroId;
|
||||
UXAssist/Patches/PlayerPatch.cs:330: private static bool _speedUp;
|
||||
UXAssist/Patches/PlayerPatch.cs:331: private static Vector3 _direction;
|
||||
UXAssist/Patches/PlayerPatch.cs:332: private static EMovementState _movementState = EMovementState.Walk;
|
||||
UXAssist/Patches/PlayerPatch.cs:354: private static bool UpdateMovementState(PlayerController controller)
|
||||
UXAssist/Patches/PlayerPatch.cs:366: private static IEnumerable<CodeInstruction> PlayerController_GameTick_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
UXAssist/Patches/PlayerPatch.cs:565: private static IEnumerable<CodeInstruction> VFInput_sailSpeedUp_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
@@ -1142,10 +1128,6 @@ UXAssist/Patches/PlanetPatch.cs:23: public static void Uninit()
|
||||
UXAssist/Patches/PlayerPatch.cs:13: public static ConfigEntry<bool> EnhancedMechaForgeCountControlEnabled;
|
||||
UXAssist/Patches/PlayerPatch.cs:14: public static ConfigEntry<bool> HideTipsForSandsChangesEnabled;
|
||||
UXAssist/Patches/PlayerPatch.cs:15: public static ConfigEntry<bool> ShortcutKeysForStarsNameEnabled;
|
||||
UXAssist/Patches/PlayerPatch.cs:16: public static ConfigEntry<bool> AutoNavigationEnabled;
|
||||
UXAssist/Patches/PlayerPatch.cs:17: public static ConfigEntry<bool> AutoCruiseEnabled;
|
||||
UXAssist/Patches/PlayerPatch.cs:18: public static ConfigEntry<bool> AutoBoostEnabled;
|
||||
UXAssist/Patches/PlayerPatch.cs:19: public static ConfigEntry<double> DistanceToWarp;
|
||||
UXAssist/Patches/PlayerPatch.cs:24: public static void Init()
|
||||
UXAssist/Patches/PlayerPatch.cs:57: public static void Start()
|
||||
UXAssist/Patches/PlayerPatch.cs:66: public static void OnInputUpdate()
|
||||
@@ -1155,8 +1137,6 @@ UXAssist/Patches/PlayerPatch.cs:195: public static bool ForceShowAllStars
|
||||
UXAssist/Patches/PlayerPatch.cs:196: public static bool ForceShowAllStarsNameExternal;
|
||||
UXAssist/Patches/PlayerPatch.cs:198: public static void ToggleAllStarsName()
|
||||
UXAssist/Patches/PlayerPatch.cs:203: public static void OnInputUpdate()
|
||||
UXAssist/Patches/PlayerPatch.cs:334: public static int IndicatorAstroId => _indicatorAstroId;
|
||||
UXAssist/Patches/PlayerPatch.cs:345: public static void ToggleAutoCruise()
|
||||
UXAssist/Patches/PlayerPatch.cs:581: public static void OnOpen_Prefix()
|
||||
UXAssist/Patches/TechPatch.cs:14:public static class TechPatch
|
||||
UXAssist/Patches/TechPatch.cs:16: public static ConfigEntry<bool> SorterCargoStackingEnabled;
|
||||
|
||||
Reference in new issue
Block a user