mirror of
https://github.com/soarqin/DSP_Mods.git
synced 2026-02-04 17:02:17 +08:00
WIP
This commit is contained in:
@@ -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 = $"<color=#ffbfbfff>{FixedPoint(x)}</color>,<color=#bfffbfff>{FixedPoint(y)}</color>,<color=#bfbfffff>{FixedPoint(z)}</color>";
|
||||
_lastOffsetText = $"<color=#ffbfbfff>{FormatOffsetFloat(x)}</color>,<color=#bfffbfff>{FormatOffsetFloat(y)}</color>,<color=#bfbfffff>{FormatOffsetFloat(z)}</color>";
|
||||
}
|
||||
__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 = $"<color=#ffbfbfff>{FixedPoint(x)}</color>,<color=#bfffbfff>{FixedPoint(y)}</color>,<color=#bfbfffff>{FixedPoint(z)}</color>";
|
||||
_lastOffsetText = $"<color=#ffbfbfff>{FormatOffsetFloat(x)}</color>,<color=#bfffbfff>{FormatOffsetFloat(y)}</color>,<color=#bfbfffff>{FormatOffsetFloat(z)}</color>";
|
||||
}
|
||||
entityBriefInfo.entityNameText.text += $" ({_lastOffsetText})";
|
||||
}
|
||||
|
||||
@@ -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<bool> EnhancedMechaForgeCountControlEnabled;
|
||||
public static ConfigEntry<bool> HideTipsForSandsChangesEnabled;
|
||||
public static ConfigEntry<bool> 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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<CodeInstruction> Player_SetSandCount_Transpiler(IEnumerable<CodeInstruction> 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<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.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<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();
|
||||
}
|
||||
|
||||
/*
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(UISailPanel), nameof(UISailPanel._OnOpen))]
|
||||
public static void OnOpen_Prefix()
|
||||
{
|
||||
if (_aimingEnabled)
|
||||
{
|
||||
UIRoot.instance.uiGame.disableLockCursor = true;
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
- 在行星视图中允许玩家操作
|
||||
- 在流速计中将堆叠物品视为单个物品
|
||||
- 隐藏沙土数量变动的提示
|
||||
- 物流塔存储数量限制控制改进
|
||||
- 当升级`运输机舱扩容`时,不会对各种物流塔的存储限制按比例提升,除非设置为最大允许容量。
|
||||
- 你可以使用方向键微调物流塔存储限制
|
||||
|
||||
@@ -18,7 +18,7 @@ public class MyConfigWindow : MyWindowWithTabs
|
||||
public override void _OnCreate()
|
||||
{
|
||||
_windowTrans = GetComponent<RectTransform>();
|
||||
_windowTrans.sizeDelta = new Vector2(810f, 476f);
|
||||
_windowTrans.sizeDelta = new Vector2(810f, 512f);
|
||||
|
||||
OnUICreated?.Invoke(this, _windowTrans);
|
||||
SetCurrentTab(0);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<TargetFramework>net472</TargetFramework>
|
||||
<BepInExPluginGuid>org.soardev.uxassist</BepInExPluginGuid>
|
||||
<Description>DSP MOD - UXAssist</Description>
|
||||
<Version>1.0.15</Version>
|
||||
<Version>1.0.16</Version>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<PackageId>UXAssist</PackageId>
|
||||
|
||||
@@ -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": [
|
||||
|
||||
Reference in New Issue
Block a user