From 11746a0bb410a7e5e5d13e47dc16344d7b468968 Mon Sep 17 00:00:00 2001 From: Soar Qin Date: Mon, 25 Mar 2024 03:35:37 +0800 Subject: [PATCH] UXAssist 1.0.18 --- UXAssist/PlayerPatch.cs | 54 ++++++++++++++++++++++------------ UXAssist/README.md | 6 ++++ UXAssist/UXAssist.csproj | 2 +- UXAssist/package/manifest.json | 2 +- 4 files changed, 43 insertions(+), 21 deletions(-) diff --git a/UXAssist/PlayerPatch.cs b/UXAssist/PlayerPatch.cs index 5ffbd83..9cf4489 100644 --- a/UXAssist/PlayerPatch.cs +++ b/UXAssist/PlayerPatch.cs @@ -219,14 +219,24 @@ public static class PlayerPatch (!player.warping && UIRoot.instance.uiGame.disableLockCursor && (VFInput._moveForward.pressing || VFInput._moveBackward.pressing))) return; var playerPos = player.uPosition; - ref var astro = ref GameMain.galaxy.astrosData[_indicatorAstroId]; + 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; - if (distance - astro.uRadius < astro.type switch { - EAstroType.Planet => 800.0, - EAstroType.Star => 4000.0, - _ => 2000.0 - }) return; + if (distance < astro.type switch + { + EAstroType.Planet => 800.0 + astro.uRadius, + EAstroType.Star => 4000.0 + astro.uRadius, + EAstroType.EnemyHive => 400.0, + _ => 2000.0 + astro.uRadius + }) + { + if (isHive) + { + player.uVelocity = Vector3.zero; + } + return; + } if (GameMain.instance.timei % 6 == 0) { _direction = astroVec.normalized; @@ -248,22 +258,28 @@ public static class PlayerPatch nearestAstroId = p.astroId; } - var hiveSys = GameMain.spaceSector.dfHives[localStar.index]; - while (hiveSys != null) + /* If targeting hives, do not bypass them */ + if (!isHive) { - if (hiveSys.realized) + var hiveSys = GameMain.spaceSector.dfHives[localStar.index]; + while (hiveSys != null) { - ref var hiveAstro = ref GameMain.galaxy.astrosData[hiveSys.hiveAstroId]; - /* Divide by 4, so that the real range is 2 times of the calculated range, - which means the minimal range allowed is 4000 */ - var range = (playerPos - hiveAstro.uPos).sqrMagnitude / 4.0; - if (range >= nearestRange) continue; - nearestRange = range; - nearestPos = hiveAstro.uPos; - nearestAstroId = hiveSys.hiveAstroId; - } + if (hiveSys.realized && hiveSys.hiveAstroId > 1000000) + { + ref var hiveAstro = ref GameMain.spaceSector.astros[hiveSys.hiveAstroId - 1000000]; + /* Divide by 4, so that the real range is 2 times of the calculated range, + which means the minimal range allowed is 4000 */ + var range = (playerPos - hiveAstro.uPos).sqrMagnitude / 4.0; + if (range < nearestRange) + { + nearestRange = range; + nearestPos = hiveAstro.uPos; + nearestAstroId = hiveSys.hiveAstroId; + } + } - hiveSys = hiveSys.nextSibling; + hiveSys = hiveSys.nextSibling; + } } if (nearestAstroId != _indicatorAstroId && nearestRange < 2000.0 * 2000.0) diff --git a/UXAssist/README.md b/UXAssist/README.md index 50f0570..c188bce 100644 --- a/UXAssist/README.md +++ b/UXAssist/README.md @@ -4,6 +4,9 @@ #### 一些提升用户体验的功能和补丁 ## Changlog +* 1.0.18 + + Fix crash while coursing to a dark-fog hive. + + Auto-cruise does not bypass dark-fog hives if they are targeted. * 1.0.17 + New function: `Auto navigation on sailings`, which is inspired by [CruiseAssist](https://dsp.thunderstore.io/package/tanu/CruiseAssist/) and its extension [AutoPilot](https://dsp.thunderstore.io/package/tanu/AutoPilot/) - It keeps Icarus on course to the target planet @@ -132,6 +135,9 @@ * [CruiseAssist](https://dsp.thunderstore.io/package/tanu/CruiseAssist/) and its extension [AutoPilot](https://dsp.thunderstore.io/package/tanu/AutoPilot/): `Auto navigation on sailings` and `Auto-cruise` implementations ## 更新日志 +* 1.0.18 + + 修复了以黑雾巢穴为目标时导致崩溃的问题 + + 当黑雾巢穴是目标时,自动导航不会绕过它 * 1.0.17 + 新功能:`航行时自动导航`,想法来自[CruiseAssist](https://dsp.thunderstore.io/package/tanu/CruiseAssist/)及其扩展[AutoPilot](https://dsp.thunderstore.io/package/tanu/AutoPilot/) - 它会保持伊卡洛斯飞向目标星球 diff --git a/UXAssist/UXAssist.csproj b/UXAssist/UXAssist.csproj index a0786d8..ceedfde 100644 --- a/UXAssist/UXAssist.csproj +++ b/UXAssist/UXAssist.csproj @@ -4,7 +4,7 @@ net472 org.soardev.uxassist DSP MOD - UXAssist - 1.0.17 + 1.0.18 true latest UXAssist diff --git a/UXAssist/package/manifest.json b/UXAssist/package/manifest.json index ec37514..5192e53 100644 --- a/UXAssist/package/manifest.json +++ b/UXAssist/package/manifest.json @@ -1,6 +1,6 @@ { "name": "UXAssist", - "version_number": "1.0.17", + "version_number": "1.0.18", "website_url": "https://github.com/soarqin/DSP_Mods/tree/master/UXAssist", "description": "Some functions and patches for better user experience / 一些提升用户体验的功能和补丁", "dependencies": [