diff --git a/CheatEnabler/CheatEnabler.cs b/CheatEnabler/CheatEnabler.cs index c691d9d..367fae2 100644 --- a/CheatEnabler/CheatEnabler.cs +++ b/CheatEnabler/CheatEnabler.cs @@ -47,7 +47,7 @@ public class CheatEnabler : BaseUnityPlugin PlanetPatch.WaterPumpAnywhereEnabled = Config.Bind("Planet", "WaterPumpAnywhere", false, "Can pump water anywhere (while water type is not None)"); PlanetPatch.TerraformAnywayEnabled = Config.Bind("Planet", "TerraformAnyway", false, - "Can do terraform without enough sands"); + "Can do terraform without enough soil piless"); DysonSpherePatch.SkipBulletEnabled = Config.Bind("DysonSphere", "SkipBullet", false, "Skip bullet"); DysonSpherePatch.SkipAbsorbEnabled = Config.Bind("DysonSphere", "SkipAbsorb", false, diff --git a/CheatEnabler/README.md b/CheatEnabler/README.md index 31accc1..21925f5 100644 --- a/CheatEnabler/README.md +++ b/CheatEnabler/README.md @@ -9,7 +9,7 @@ * 2.3.10 + Fix following functions not working in new game updates: - `Pump Anywhere` - - `Terraform without enough sands` + - `Terraform without enough soil piles` * 2.3.9 + Support game version 0.10.28.21219 * 2.3.8 @@ -108,7 +108,7 @@ + Infinite Natural Resources + Fast Mining + Pump Anywhere - + Terraform without enought sands + + Terraform without enought soil piles + Dyson Sphere: + Skip bullet period + Skip absorption period diff --git a/CheatEnabler/UIConfigWindow.cs b/CheatEnabler/UIConfigWindow.cs index cebdc6c..a634dce 100644 --- a/CheatEnabler/UIConfigWindow.cs +++ b/CheatEnabler/UIConfigWindow.cs @@ -52,7 +52,7 @@ public static class UIConfigWindow I18N.Add("Eject anyway", "Eject anyway", "全球弹射"); I18N.Add("Overclock Ejectors", "Overclock Ejectors (10x)", "高速弹射器(10倍射速)"); I18N.Add("Overclock Silos", "Overclock Silos (10x)", "高速发射井(10倍射速)"); - I18N.Add("Terraform without enough sands", "Terraform without enough sands", "沙土不够时依然可以整改地形"); + I18N.Add("Terraform without enough soil piless", "Terraform without enough soil piles", "沙土不够时依然可以整改地形"); I18N.Apply(); MyConfigWindow.OnUICreated += CreateUI; MyConfigWindow.OnUpdateUI += UpdateUI; @@ -133,7 +133,7 @@ public static class UIConfigWindow y += 36f; MyCheckBox.CreateCheckBox(x, y, tab3, PlanetPatch.WaterPumpAnywhereEnabled, "Pump Anywhere"); y += 36f; - MyCheckBox.CreateCheckBox(x, y, tab3, PlanetPatch.TerraformAnywayEnabled, "Terraform without enough sands"); + MyCheckBox.CreateCheckBox(x, y, tab3, PlanetPatch.TerraformAnywayEnabled, "Terraform without enough soil piles"); x = 400f; y = 10f; wnd.AddButton(x, y, 200f, tab3, "矿物掩埋标题", 16, "button-bury-all", () => { PlanetFunctions.BuryAllVeins(true); }); diff --git a/Dustbin/Dustbin.cs b/Dustbin/Dustbin.cs index fbb07a5..8158cff 100644 --- a/Dustbin/Dustbin.cs +++ b/Dustbin/Dustbin.cs @@ -31,7 +31,7 @@ public class Dustbin : BaseUnityPlugin, IModCanSave, IMultiplayerMod var storageDustbin = Config.Bind("General", "StorageDustbin", true, "Can turn storages into dustbins").Value; var tankDustbin = Config.Bind("General", "TankDustbin", true, "Can turn tanks into dustbins").Value; var belgSignalDustbin = Config.Bind("General", "BeltSignalDustbin", true, "Add belt signal as dustbin").Value; - var sandsFactorsStr = Config.Bind("General", "SandsFactors", "", "Sands get from different items\nFormat: id1:value1|id2:value2|...").Value; + var sandsFactorsStr = Config.Bind("General", "SandsFactors", "", "Soil piles get from different items\nFormat: id1:value1|id2:value2|...").Value; foreach (var s in sandsFactorsStr.Split('|')) { var sp = s.Split(':'); diff --git a/Dustbin/README.md b/Dustbin/README.md index a78eb32..61270ad 100644 --- a/Dustbin/README.md +++ b/Dustbin/README.md @@ -17,7 +17,7 @@ + Add a belt signal(you can find it in first tab of signal selection panel) as dustbin, which is the simplest way to destroy items. + Reworked dustbin support for Tanks, to improve performance and resolve known bugs. - Be note that the whole tank logic is optimized which may get a slight better performance even if you don't use them as dustbin. - + Config entry for sands gain from destroyed items are changed to a more flexible format. + + Config entry for soil piless gain from destroyed items are changed to a more flexible format. + [Nebula Mupltiplayer Mod](https://dsp.thunderstore.io/package/nebula/NebulaMultiplayerMod/) and bug fixes from [ModFixerOne](https://dsp.thunderstore.io/package/starfi5h/ModFixerOne/) by [starfi5h](https://github.com/starfi5h/). * 1.2.1 @@ -37,7 +37,7 @@ * A checkbox is added to Storages and Tanks UI, which turns them into dustbins. * Items sent into dustbins are removed immediately. -* Can get sands from destroyed items, configurable through a json encoded config entry. +* Can get soil piless from destroyed items, configurable through a json encoded config entry. + You can get item ID list [here](https://dsp-wiki.com/Modding:Items_IDs). ## 更新日志 diff --git a/UXAssist/FactoryPatch.cs b/UXAssist/FactoryPatch.cs index ddb7796..05ea670 100644 --- a/UXAssist/FactoryPatch.cs +++ b/UXAssist/FactoryPatch.cs @@ -575,10 +575,9 @@ public static class FactoryPatch z = (pos.magnitude - planet.realRadius - 0.2f) / 1.3333333f; } - private static string FixedPoint(float f) + private static string FormatOffsetFloat(float f) { - var s = Mathf.RoundToInt(f * 10000); - return $"{s / 10000}.{Math.Abs(s % 10000)}".TrimEnd('0').TrimEnd('.'); + return f.ToString("0.0000").TrimEnd('0').TrimEnd('.'); } private static PlanetData _lastPlanet; @@ -598,7 +597,7 @@ public static class FactoryPatch CalculateGridOffset(__instance.planet, preview.lpos, out var x, out var y, out var z); _lastPlanet = planet; _lastPos = preview.lpos; - _lastOffsetText = $"{FixedPoint(x)},{FixedPoint(y)},{FixedPoint(z)}"; + _lastOffsetText = $"{FormatOffsetFloat(x)},{FormatOffsetFloat(y)},{FormatOffsetFloat(z)}"; } __instance.actionBuild.model.cursorText = $"({_lastOffsetText})\n" + __instance.actionBuild.model.cursorText; } @@ -625,7 +624,7 @@ public static class FactoryPatch CalculateGridOffset(planet, entity.pos, out var x, out var y, out var z); _lastPlanet = planet; _lastPos = entity.pos; - _lastOffsetText = $"{FixedPoint(x)},{FixedPoint(y)},{FixedPoint(z)}"; + _lastOffsetText = $"{FormatOffsetFloat(x)},{FormatOffsetFloat(y)},{FormatOffsetFloat(z)}"; } entityBriefInfo.entityNameText.text += $" ({_lastOffsetText})"; } diff --git a/UXAssist/PlayerPatch.cs b/UXAssist/PlayerPatch.cs index 2520c21..7e394f4 100644 --- a/UXAssist/PlayerPatch.cs +++ b/UXAssist/PlayerPatch.cs @@ -1,23 +1,33 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Reflection.Emit; using BepInEx.Configuration; using HarmonyLib; +using UnityEngine; namespace UXAssist; public static class PlayerPatch { public static ConfigEntry EnhancedMechaForgeCountControlEnabled; + public static ConfigEntry HideTipsForSandsChangesEnabled; + public static ConfigEntry AutoNavigationEnabled; public static void Init() { EnhancedMechaForgeCountControlEnabled.SettingChanged += (_, _) => EnhancedMechaForgeCountControl.Enable(EnhancedMechaForgeCountControlEnabled.Value); + HideTipsForSandsChangesEnabled.SettingChanged += (_, _) => HideTipsForSandsChanges.Enable(HideTipsForSandsChangesEnabled.Value); + AutoNavigationEnabled.SettingChanged += (_, _) => AutoNavigation.Enable(AutoNavigationEnabled.Value); EnhancedMechaForgeCountControl.Enable(EnhancedMechaForgeCountControlEnabled.Value); + HideTipsForSandsChanges.Enable(HideTipsForSandsChangesEnabled.Value); + AutoNavigation.Enable(AutoNavigationEnabled.Value); } public static void Uninit() { EnhancedMechaForgeCountControl.Enable(false); + HideTipsForSandsChanges.Enable(false); + AutoNavigation.Enable(false); } private static class EnhancedMechaForgeCountControl @@ -85,4 +95,152 @@ public static class PlayerPatch return matcher.InstructionEnumeration(); } } -} \ No newline at end of file + + private static class HideTipsForSandsChanges + { + private static Harmony _patch; + + public static void Enable(bool on) + { + if (on) + { + _patch ??= Harmony.CreateAndPatchAll(typeof(HideTipsForSandsChanges)); + } + else + { + _patch?.UnpatchSelf(); + _patch = null; + } + } + + [HarmonyTranspiler] + [HarmonyPatch(typeof(Player), nameof(Player.SetSandCount))] + private static IEnumerable Player_SetSandCount_Transpiler(IEnumerable instructions, ILGenerator generator) + { + var matcher = new CodeMatcher(instructions, generator); + matcher.MatchForward(false, + new CodeMatch(OpCodes.Call, AccessTools.PropertySetter(typeof(Player), nameof(Player.sandCount))) + ).Advance(1).Insert(new CodeInstruction(OpCodes.Ret)); + return matcher.InstructionEnumeration(); + } + } + + private static class AutoNavigation + { + private static Harmony _patch; + + private static int _indicatorAstroId; + private static bool _speedUp; + /* + private static bool _aimingEnabled; + */ + + public static void Enable(bool on) + { + if (on) + { + _patch ??= Harmony.CreateAndPatchAll(typeof(AutoNavigation)); + } + else + { + _patch?.UnpatchSelf(); + _patch = null; + } + } + + [HarmonyTranspiler] + [HarmonyPatch(typeof(PlayerController), nameof(PlayerController.GameTick))] + private static IEnumerable PlayerController_GameTick_Transpiler(IEnumerable instructions, ILGenerator generator) + { + var matcher = new CodeMatcher(instructions, generator); + matcher.MatchForward(false, + new CodeMatch(OpCodes.Callvirt, AccessTools.Method(typeof(BuildModel), nameof(BuildModel.LateGameTickIgnoreActive))) + ); + var labels = matcher.Labels; + matcher.Labels = null; + matcher.InsertAndAdvance( + new CodeInstruction(OpCodes.Ldarg_0).WithLabels(labels), + Transpilers.EmitDelegate((PlayerController controller) => + { + _speedUp = false; + if (controller.movementStateInFrame != EMovementState.Sail) return; + var navi = controller.player.navigation; + if (navi.indicatorAstroId != _indicatorAstroId) + { + _indicatorAstroId = navi.indicatorAstroId; + if (_indicatorAstroId == 0) return; + } + else if (_indicatorAstroId == 0) return; + var player = controller.player; + var playerPos = player.uPosition; + ref var astro = ref GameMain.galaxy.astrosData[_indicatorAstroId]; + var vec = astro.uPos - playerPos; + if (vec.magnitude - astro.uRadius < 800.0) return; + var direction = vec.normalized; + var localStar = GameMain.localStar; + if (localStar != null) + { + var nearestRange = (playerPos - localStar.uPosition).sqrMagnitude; + var nearestPos = localStar.uPosition; + var nearestAstroId = localStar.id; + foreach (var p in localStar.planets) + { + var range = (playerPos - p.uPosition).sqrMagnitude; + if (range >= nearestRange) continue; + nearestRange = range; + nearestPos = p.uPosition; + nearestAstroId = p.id; + } + + if (nearestAstroId != _indicatorAstroId && nearestRange < 2000.0 * 2000.0) + { + var vec2 = (playerPos - nearestPos).normalized; + var dot = Vector3.Dot(vec2, direction); + if (dot >= 0) + { + direction = vec2; + } + else + { + var cross = Vector3.Cross(direction, vec2); + direction = -Vector3.Cross(cross, vec2).normalized; + } + } + } + var uVel = player.uVelocity; + var speed = uVel.magnitude; + _speedUp = !player.warping && speed < 2000.0 - 0.1; + player.uVelocity = direction * speed; + }) + ); + return matcher.InstructionEnumeration(); + } + + [HarmonyTranspiler] + [HarmonyPatch(typeof(VFInput), nameof(VFInput._sailSpeedUp), MethodType.Getter)] + private static IEnumerable VFInput_sailSpeedUp_Transpiler(IEnumerable 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(); + } + + /* + [HarmonyPrefix] + [HarmonyPatch(typeof(UISailPanel), nameof(UISailPanel._OnOpen))] + public static void OnOpen_Prefix() + { + if (_aimingEnabled) + { + UIRoot.instance.uiGame.disableLockCursor = true; + } + } + */ + } +} diff --git a/UXAssist/README.md b/UXAssist/README.md index f22baa5..2e42606 100644 --- a/UXAssist/README.md +++ b/UXAssist/README.md @@ -4,6 +4,9 @@ #### 一些提升用户体验的功能和补丁 ## Changlog +* 1.0.16 + + Add CommonAPI to package manifest dependencies(missing in last version) + + New function: `Hide tips for soil piles changes` * 1.0.15 + Move shortcut key settings to system options window, which depends on [CommonAPI](https://dsp.thunderstore.io/package/CommonAPI/CommonAPI) + Enable `Hide UI` function(`F11` by default) while on Star Map view @@ -85,6 +88,7 @@ - Larger area for terraform(30x30 at max) - Enable player actions in globe view - Treat stack items as single in monitor components + - Hide tips for soil piles changes - Enhanced control for logistic storage limits - Logistic storage limits are not scaled on upgrading `Logistics Carrier Capacity`, if they are not set to maximum capacity. - You can use arrow keys to adjust logistic storage limits gracefully. @@ -110,6 +114,9 @@ * [OffGridConstruction](https://github.com/Velociraptor115-DSPModding/OffGridConstruction): Off-grid building & stepped rotation implementations ## 更新日志 +* 1.0.16 + + 添加了对CommonAPI的包依赖(上个版本忘记加了) + + 新功能:`隐藏沙土数量变动的提示` * 1.0.15 + 将快捷键设置移动到系统选项窗口,依赖于[CommonAPI](https://dsp.thunderstore.io/package/CommonAPI/CommonAPI) + 在星图视图中启用`隐藏UI`功能(默认按键为`F11`) @@ -193,6 +200,7 @@ - 范围铺设地基的最大区域扩大(最大30x30) - 在行星视图中允许玩家操作 - 在流速计中将堆叠物品视为单个物品 + - 隐藏沙土数量变动的提示 - 物流塔存储数量限制控制改进 - 当升级`运输机舱扩容`时,不会对各种物流塔的存储限制按比例提升,除非设置为最大允许容量。 - 你可以使用方向键微调物流塔存储限制 diff --git a/UXAssist/UI/MyConfigWindow.cs b/UXAssist/UI/MyConfigWindow.cs index f19e1ad..b388ec5 100644 --- a/UXAssist/UI/MyConfigWindow.cs +++ b/UXAssist/UI/MyConfigWindow.cs @@ -18,7 +18,7 @@ public class MyConfigWindow : MyWindowWithTabs public override void _OnCreate() { _windowTrans = GetComponent(); - _windowTrans.sizeDelta = new Vector2(810f, 476f); + _windowTrans.sizeDelta = new Vector2(810f, 512f); OnUICreated?.Invoke(this, _windowTrans); SetCurrentTab(0); diff --git a/UXAssist/UIConfigWindow.cs b/UXAssist/UIConfigWindow.cs index a6c2595..8265d48 100644 --- a/UXAssist/UIConfigWindow.cs +++ b/UXAssist/UIConfigWindow.cs @@ -31,6 +31,7 @@ public static class UIConfigWindow I18N.Add("Larger area for terraform", "Larger area for terraform", "范围铺设地基的最大区域扩大"); I18N.Add("Off-grid building and stepped rotation", "Off-grid building and stepped rotation (Hold Shift)", "脱离网格建造以及小角度旋转(按住Shift)"); I18N.Add("Enable player actions in globe view", "Enable player actions in globe view", "在行星视图中允许玩家操作"); + I18N.Add("Hide tips for soil piles changes", "Hide tips for soil piles changes", "隐藏沙土数量变动的提示"); I18N.Add("Enhance control for logistic storage limits", "Enhance control for logistic storage limits", "物流塔存储限制控制改进"); I18N.Add("Enhance control for logistic storage limits tips", "Logistic storage limits are not scaled on upgrading 'Logistics Carrier Capacity', if they are not set to maximum capacity.\nUse arrow keys to adjust logistic storage limits:\n \u2190/\u2192: -/+10 \u2193\u2191: -/+100", "当升级'运输机舱扩容'时,不会对各种物流塔的存储限制按比例提升,除非设置为最大允许容量。\n你可以使用方向键微调物流塔存储限制:\n \u2190\u2192: -/+10 \u2193\u2191: -/+100"); I18N.Add("Enhanced count control for hand-make", "Enhanced count control for hand-make", "手动制造物品的数量控制改进"); @@ -96,6 +97,8 @@ public static class UIConfigWindow y += 36f; MyCheckBox.CreateCheckBox(x, y, tab2, PlanetPatch.PlayerActionsInGlobeViewEnabled, "Enable player actions in globe view"); y += 36f; + MyCheckBox.CreateCheckBox(x, y, tab2, PlayerPatch.HideTipsForSandsChangesEnabled, "Hide tips for soil piles changes"); + y += 36f; MyCheckBox.CreateCheckBox(x, y, tab2, FactoryPatch.LogisticsCapacityTweaksEnabled, "Enhance control for logistic storage limits"); x = 270f; y += 6f; diff --git a/UXAssist/UXAssist.cs b/UXAssist/UXAssist.cs index d7e9391..5503ebd 100644 --- a/UXAssist/UXAssist.cs +++ b/UXAssist/UXAssist.cs @@ -68,8 +68,12 @@ public class UXAssist : BaseUnityPlugin FactoryPatch.TreatStackingAsSingleEnabled = Config.Bind("Factory", "TreatStackingAsSingle", false, "Treat stack items as single in monitor components"); PlanetFunctions.OrbitalCollectorMaxBuildCount = Config.Bind("Factory", "OCMaxBuildCount", 0, "Maximum Orbital Collectors to build once, set to 0 to build as many as possible"); + PlayerPatch.HideTipsForSandsChangesEnabled = Config.Bind("Player", "HideTipsForGettingSands", false, + "Hide tips for getting soil piles"); PlayerPatch.EnhancedMechaForgeCountControlEnabled = Config.Bind("Player", "EnhancedMechaForgeCountControl", false, "Enhanced count control for hand-make, increases maximum of count to 1000, and you can hold Ctrl/Shift/Alt to change the count rapidly"); + PlayerPatch.AutoNavigationEnabled = Config.Bind("Player", "AutoNavigation", false, + "Auto navigation"); DysonSpherePatch.StopEjectOnNodeCompleteEnabled = Config.Bind("DysonSphere", "StopEjectOnNodeComplete", false, "Stop ejectors when available nodes are all filled up"); DysonSpherePatch.OnlyConstructNodesEnabled = Config.Bind("DysonSphere", "OnlyConstructNodes", false, diff --git a/UXAssist/UXAssist.csproj b/UXAssist/UXAssist.csproj index efcdb41..a728af7 100644 --- a/UXAssist/UXAssist.csproj +++ b/UXAssist/UXAssist.csproj @@ -4,7 +4,7 @@ net472 org.soardev.uxassist DSP MOD - UXAssist - 1.0.15 + 1.0.16 true latest UXAssist diff --git a/UXAssist/package/manifest.json b/UXAssist/package/manifest.json index 98d9798..bdc9806 100644 --- a/UXAssist/package/manifest.json +++ b/UXAssist/package/manifest.json @@ -1,6 +1,6 @@ { "name": "UXAssist", - "version_number": "1.0.15", + "version_number": "1.0.16", "website_url": "https://github.com/soarqin/DSP_Mods/tree/master/UXAssist", "description": "Some functions and patches for better user experience / 一些提升用户体验的功能和补丁", "dependencies": [