1
0
mirror of https://github.com/soarqin/DSP_Mods.git synced 2025-12-09 14:53:30 +08:00

new UXAssist and CheatEnabler release

This commit is contained in:
2024-09-19 23:53:02 +08:00
parent 722c32fdd6
commit 2d2602d8b9
13 changed files with 166 additions and 66 deletions

View File

@@ -43,7 +43,7 @@ public class FactoryPatch: PatchImpl<FactoryPatch>
I18N.Add("KEYToggleDoNotRenderEntities", "Toggle Do Not Render Factory Entities", "切换不渲染工厂建筑实体");
_offgridfForPathsKey = KeyBindings.RegisterKeyBinding(new BuiltinKey
{
key = new CombineKey((int)KeyCode.LeftControl, 0, ECombineKeyAction.OnceClick, false),
key = new CombineKey(0, CombineKey.CTRL_COMB, ECombineKeyAction.OnceClick, false),
conflictGroup = KeyBindConflict.MOVEMENT | KeyBindConflict.UI | KeyBindConflict.FLYING | KeyBindConflict.SAILING | KeyBindConflict.BUILD_MODE_1 | KeyBindConflict.KEYBOARD_KEYBIND,
name = "OffgridForPaths",
canOverride = true
@@ -526,12 +526,11 @@ public class FactoryPatch: PatchImpl<FactoryPatch>
public class OffGridBuilding: PatchImpl<OffGridBuilding>
{
private const float SteppedRotationDegrees = 15f;
// private const float SteppedRotationDegrees = 15f;
private static bool _initialized;
[HarmonyPostfix, HarmonyPatch(typeof(UIRoot), "_OnOpen")]
public static void UIRoot__OnOpen_Postfix()
private static void SetupRichTextSupport()
{
if (_initialized) return;
UIGeneralTips.instance.buildCursorTextComp.supportRichText = true;
@@ -575,6 +574,7 @@ public class FactoryPatch: PatchImpl<FactoryPatch>
var planet = __instance.planet;
if (_lastPlanet != planet || _lastPos != preview.lpos)
{
SetupRichTextSupport();
CalculateGridOffset(__instance.planet, preview.lpos, out var x, out var y, out var z);
_lastPlanet = planet;
_lastPos = preview.lpos;
@@ -605,6 +605,7 @@ public class FactoryPatch: PatchImpl<FactoryPatch>
var planet = entityBriefInfo.factory.planet;
if (_lastPlanet != planet || _lastPos != entity.pos)
{
SetupRichTextSupport();
CalculateGridOffset(planet, entity.pos, out var x, out var y, out var z);
_lastPlanet = planet;
_lastPos = entity.pos;
@@ -684,6 +685,13 @@ public class FactoryPatch: PatchImpl<FactoryPatch>
return matcher.InstructionEnumeration();
}
private static bool CheckOffgridForPathsKeyPressed()
{
ref var bind = ref _offgridfForPathsKey.defaultBind;
ref var key = ref VFInput.override_keys[bind.id];
return key.IsNull() ? bind.key.GetKey() : key.GetKey();
}
[HarmonyTranspiler]
[HarmonyPatch(typeof(BuildTool_Path), nameof(BuildTool_Path.UpdateRaycast))]
@@ -709,8 +717,7 @@ public class FactoryPatch: PatchImpl<FactoryPatch>
var jmp0 = generator.DefineLabel();
var jmp1 = generator.DefineLabel();
matcher.InsertAndAdvance(
new CodeInstruction(OpCodes.Ldsfld, AccessTools.Field(typeof(FactoryPatch), nameof(_offgridfForPathsKey))),
new CodeInstruction(OpCodes.Call, AccessTools.PropertyGetter(typeof(PressKeyBind), nameof(PressKeyBind.keyValue))),
new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(OffGridBuilding), nameof(CheckOffgridForPathsKeyPressed))),
new CodeInstruction(OpCodes.Brfalse, jmp0),
new CodeInstruction(OpCodes.Ldarg_0),
new CodeInstruction(OpCodes.Ldarg_0),
@@ -1662,7 +1669,7 @@ public class FactoryPatch: PatchImpl<FactoryPatch>
GameLogic.OnDataLoaded -= VFPreload_InvokeOnLoadWorkEnded_Postfix;
}
public static void VFPreload_InvokeOnLoadWorkEnded_Postfix()
private static void VFPreload_InvokeOnLoadWorkEnded_Postfix()
{
if (_initialized) return;
_initialized = true;
@@ -1680,7 +1687,7 @@ public class FactoryPatch: PatchImpl<FactoryPatch>
RemovePlanetSignalBelts(factory.index);
}
public static void GameMain_Begin_Postfix()
private static void GameMain_Begin_Postfix()
{
_clusterSeedKey = GameMain.data.GetClusterSeedKey();
InitSignalBelts();

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.IO;
using System.Reflection.Emit;
using BepInEx.Configuration;
using CommonAPI.Systems;
using HarmonyLib;
using UnityEngine;
using UXAssist.Common;
@@ -26,6 +27,8 @@ public class GamePatch: PatchImpl<GamePatch>
public static ConfigEntry<string> DefaultProfileName;
public static ConfigEntry<double> GameUpsFactor;
private static PressKeyBind _speedDownKey;
private static PressKeyBind _speedUpKey;
private static bool _enableGameUpsFactor = true;
public static bool EnableGameUpsFactor
{
@@ -52,6 +55,26 @@ public class GamePatch: PatchImpl<GamePatch>
public static void Init()
{
_speedDownKey = KeyBindings.RegisterKeyBinding(new BuiltinKey
{
key = new CombineKey((int)KeyCode.KeypadMinus, 0, ECombineKeyAction.OnceClick, false),
conflictGroup = KeyBindConflict.MOVEMENT | KeyBindConflict.FLYING | KeyBindConflict.SAILING | KeyBindConflict.BUILD_MODE_1 | KeyBindConflict.KEYBOARD_KEYBIND,
name = "UPSSpeedDown",
canOverride = true
}
);
I18N.Add("KEYUPSSpeedDown", "Decrease logical frame rate", "降低逻辑帧率");
_speedUpKey = KeyBindings.RegisterKeyBinding(new BuiltinKey
{
key = new CombineKey((int)KeyCode.KeypadPlus, 0, ECombineKeyAction.OnceClick, false),
conflictGroup = KeyBindConflict.MOVEMENT | KeyBindConflict.UI | KeyBindConflict.FLYING | KeyBindConflict.SAILING | KeyBindConflict.BUILD_MODE_1 | KeyBindConflict.KEYBOARD_KEYBIND,
name = "UPSSpeedUp",
canOverride = true
}
);
I18N.Add("KEYUPSSpeedUp", "Increase logical frame rate", "提升逻辑帧率");
I18N.Add("Logical frame rate: {0}x", "Logical frame rate: {0}x", "逻辑帧速率: {0}x");
// Get profile name from command line arguments, and set window title accordingly
var args = Environment.GetCommandLineArgs();
for (var i = 0; i < args.Length - 1; i++)
@@ -120,6 +143,21 @@ public class GamePatch: PatchImpl<GamePatch>
ConvertSavesFromPeace.Enable(false);
}
public static void OnUpdate()
{
if (!_enableGameUpsFactor) return;
if (_speedDownKey.keyValue)
{
GameUpsFactor.Value = Maths.Clamp(Math.Round((GameUpsFactor.Value - 0.5) * 2.0) / 2.0, 0.1, 10.0);
UIRoot.instance.uiGame.generalTips.InvokeRealtimeTipAhead(string.Format("Logical frame rate: {0}x".Translate(), GameUpsFactor.Value));
}
if (_speedUpKey.keyValue)
{
GameUpsFactor.Value = Maths.Clamp(Math.Round((GameUpsFactor.Value + 0.5) * 2.0) / 2.0, 0.1, 10.0);
UIRoot.instance.uiGame.generalTips.InvokeRealtimeTipAhead(string.Format("Logical frame rate: {0}x".Translate(), GameUpsFactor.Value));
}
}
private static void RefreshSavePath()
{
if (ProfileName == null) return;

View File

@@ -837,7 +837,7 @@ public static class LogisticsPatch
stationTip.rectTransform.anchoredPosition = rectPoint;
stationTip.transform.localScale = Vector3.one * localScaleMultiple;
stationTip.UpdateStationInfo(stationComponent, factory);
stationTip.UpdateStationInfo(stationComponent);
}
}
@@ -867,7 +867,6 @@ public static class LogisticsPatch
private Text[] _carrierIdleCountText;
private GameObject _infoText;
private StationComponent _currentStation;
private EStationTipLayout _layout = EStationTipLayout.None;
private int _storageNum;
private float _pixelPerItem;
@@ -964,7 +963,6 @@ public static class LogisticsPatch
public void ResetStationTip()
{
_currentStation = null;
_layout = EStationTipLayout.None;
for (var i = StorageSlotCount - 1; i >= 0; i--)
{
@@ -1178,55 +1176,52 @@ public static class LogisticsPatch
private static readonly float[] TipWindowExtraHeights = [0f, 5f, 5f, 40f, 40f];
private static readonly float[] CarrierPositionX = [5f, 35f, 85f];
public void UpdateStationInfo(StationComponent stationComponent, PlanetFactory factory)
public void UpdateStationInfo(StationComponent stationComponent)
{
if (_currentStation != stationComponent)
var layout = stationComponent.isCollector ? EStationTipLayout.Collector :
stationComponent.isVeinCollector ? EStationTipLayout.VeinCollector :
stationComponent.isStellar ? EStationTipLayout.InterstellarLogistics : EStationTipLayout.PlanetaryLogistics;
if (_layout != layout)
{
_currentStation = stationComponent;
var layout = stationComponent.isCollector ? EStationTipLayout.Collector :
stationComponent.isVeinCollector ? EStationTipLayout.VeinCollector :
stationComponent.isStellar ? EStationTipLayout.InterstellarLogistics : EStationTipLayout.PlanetaryLogistics;
if (_layout != layout)
_layout = layout;
for (var i = StorageSlotCount - 1; i >= 0; i--)
{
_layout = layout;
for (var i = StorageSlotCount - 1; i >= 0; i--)
_iconLocals[i].gameObject.SetActive(false);
_iconRemotes[i].gameObject.SetActive(false);
_icons[i].gameObject.SetActive(false);
switch (layout)
{
_iconLocals[i].gameObject.SetActive(false);
_iconRemotes[i].gameObject.SetActive(false);
_icons[i].gameObject.SetActive(false);
switch (layout)
{
case EStationTipLayout.PlanetaryLogistics:
var rectTrans = (RectTransform)_iconLocals[i].transform;
rectTrans.sizeDelta = new Vector2(20f, 20f);
rectTrans.anchoredPosition3D = new Vector3(100f, -5f - 35f * i - 5f, 0);
break;
case EStationTipLayout.InterstellarLogistics:
rectTrans = (RectTransform)_iconLocals[i].transform;
rectTrans.sizeDelta = new Vector2(16f, 16f);
rectTrans.anchoredPosition3D = new Vector3(102f, -5f - 35f * i, 0);
break;
}
case EStationTipLayout.PlanetaryLogistics:
var rectTrans = (RectTransform)_iconLocals[i].transform;
rectTrans.sizeDelta = new Vector2(20f, 20f);
rectTrans.anchoredPosition3D = new Vector3(100f, -5f - 35f * i - 5f, 0);
break;
case EStationTipLayout.InterstellarLogistics:
rectTrans = (RectTransform)_iconLocals[i].transform;
rectTrans.sizeDelta = new Vector2(16f, 16f);
rectTrans.anchoredPosition3D = new Vector3(102f, -5f - 35f * i, 0);
break;
}
_storageNum = Math.Min(StorageNums[(int)layout], stationComponent.storage.Length);
rectTransform.sizeDelta = new Vector2(TipWindowWidths[(int)layout], TipWindowExtraHeights[(int)layout] + 35f * _storageNum);
for (var i = StorageSlotCount - 1; i >= 0; i--)
{
_countTexts[i].gameObject.SetActive(i < _storageNum);
}
for (var i = CarrierSlotCount - 1; i >= 0; i--)
{
var active = CarrierEnabled[(int)layout][i];
_carrierIcons[i].gameObject.SetActive(active);
if (!active) continue;
var rectTrans = (RectTransform)_carrierIcons[i].transform;
rectTrans.anchoredPosition3D = new Vector3(CarrierPositionX[i], -5f - 35f * _storageNum, 0);
}
_pixelPerItem = _layout == EStationTipLayout.InterstellarLogistics ? _remoteStoragePixelPerItem : _localStoragePixelPerItem;
}
_storageNum = Math.Min(StorageNums[(int)layout], stationComponent.storage.Length);
rectTransform.sizeDelta = new Vector2(TipWindowWidths[(int)layout], TipWindowExtraHeights[(int)layout] + 35f * _storageNum);
for (var i = StorageSlotCount - 1; i >= 0; i--)
{
_countTexts[i].gameObject.SetActive(i < _storageNum);
}
for (var i = CarrierSlotCount - 1; i >= 0; i--)
{
var active = CarrierEnabled[(int)layout][i];
_carrierIcons[i].gameObject.SetActive(active);
if (!active) continue;
var rectTrans = (RectTransform)_carrierIcons[i].transform;
rectTrans.anchoredPosition3D = new Vector3(CarrierPositionX[i], -5f - 35f * _storageNum, 0);
}
_pixelPerItem = _layout == EStationTipLayout.InterstellarLogistics ? _remoteStoragePixelPerItem : _localStoragePixelPerItem;
}
var storageArray = stationComponent.storage;