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

UXAssist 1.2.4

This commit is contained in:
2024-09-24 00:33:41 +08:00
parent daaf7b4901
commit 237830fc91
13 changed files with 149 additions and 73 deletions

View File

@@ -17,6 +17,8 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
public static ConfigEntry<bool> UnlimitInteractiveEnabled;
public static ConfigEntry<bool> RemoveSomeConditionEnabled;
public static ConfigEntry<bool> NightLightEnabled;
public static ConfigEntry<float> NightLightAngleX;
public static ConfigEntry<float> NightLightAngleY;
public static ConfigEntry<bool> RemoveBuildRangeLimitEnabled;
public static ConfigEntry<bool> LargerAreaForUpgradeAndDismantleEnabled;
public static ConfigEntry<bool> LargerAreaForTerraformEnabled;
@@ -55,6 +57,8 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
UnlimitInteractiveEnabled.SettingChanged += (_, _) => UnlimitInteractive.Enable(UnlimitInteractiveEnabled.Value);
RemoveSomeConditionEnabled.SettingChanged += (_, _) => RemoveSomeConditionBuild.Enable(RemoveSomeConditionEnabled.Value);
NightLightEnabled.SettingChanged += (_, _) => NightLight.Enable(NightLightEnabled.Value);
NightLightAngleX.SettingChanged += (_, _) => NightLight.UpdateSunlightAngle();
NightLightAngleY.SettingChanged += (_, _) => NightLight.UpdateSunlightAngle();
RemoveBuildRangeLimitEnabled.SettingChanged += (_, _) => RemoveBuildRangeLimit.Enable(RemoveBuildRangeLimitEnabled.Value);
LargerAreaForUpgradeAndDismantleEnabled.SettingChanged += (_, _) => LargerAreaForUpgradeAndDismantle.Enable(LargerAreaForUpgradeAndDismantleEnabled.Value);
LargerAreaForTerraformEnabled.SettingChanged += (_, _) => LargerAreaForTerraform.Enable(LargerAreaForTerraformEnabled.Value);
@@ -175,8 +179,6 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
public class NightLight : PatchImpl<NightLight>
{
private const float NightLightAngleX = -8;
private const float NightLightAngleY = -2;
private static bool _nightlightInitialized;
private static bool _mechaOnEarth;
private static AnimationState _sail;
@@ -188,6 +190,13 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
_sunlight.transform.localEulerAngles = new Vector3(0f, 180f);
}
public static void UpdateSunlightAngle()
{
if (!_sunlight) return;
_sunlight.transform.rotation = Quaternion.LookRotation(-GameMain.mainPlayer.transform.up + GameMain.mainPlayer.transform.forward * NightLightAngleX.Value / 10f +
GameMain.mainPlayer.transform.right * NightLightAngleY.Value / 10f);
}
[HarmonyPostfix]
[HarmonyPatch(typeof(GameMain), nameof(GameMain.LateUpdate))]
public static void GameMain_LateUpdate_Postfix(GameMain __instance)
@@ -217,12 +226,13 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
if (!_sail || !_sail.enabled) return;
_mechaOnEarth = false;
if (!_sunlight || !_sunlight.transform) return;
if (!_sunlight) return;
_sunlight.transform.localEulerAngles = new Vector3(0f, 180f);
_sunlight = null;
return;
}
if (_sail && _sail.enabled) return;
if (!_sunlight)
{
var simu = GameMain.universeSimulator;
@@ -231,9 +241,7 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
}
_mechaOnEarth = true;
if (_sunlight)
_sunlight.transform.rotation = Quaternion.LookRotation(-GameMain.mainPlayer.transform.up + GameMain.mainPlayer.transform.forward * NightLightAngleX / 10f +
GameMain.mainPlayer.transform.right * NightLightAngleY / 10f);
UpdateSunlightAngle();
}
[HarmonyTranspiler]

View File

@@ -76,13 +76,13 @@ public class GamePatch: PatchImpl<GamePatch>
LoadLastWindowRectEnabled.SettingChanged += (_, _) => LoadLastWindowRect.Enable(LoadLastWindowRectEnabled.Value);
MouseCursorScaleUpMultiplier.SettingChanged += (_, _) =>
{
MouseCursorScaleUp.reload = true;
MouseCursorScaleUp.NeedReloadCursors = true;
MouseCursorScaleUp.Enable(MouseCursorScaleUpMultiplier.Value > 1);
};
// AutoSaveOptEnabled.SettingChanged += (_, _) => AutoSaveOpt.Enable(AutoSaveOptEnabled.Value);
ConvertSavesFromPeaceEnabled.SettingChanged += (_, _) => ConvertSavesFromPeace.Enable(ConvertSavesFromPeaceEnabled.Value);
ProfileBasedSaveFolderEnabled.SettingChanged += (_, _) => Functions.WindowFunctions.RefreshSavePath();
DefaultProfileName.SettingChanged += (_, _) => Functions.WindowFunctions.RefreshSavePath();
ProfileBasedSaveFolderEnabled.SettingChanged += (_, _) => RefreshSavePath();
DefaultProfileName.SettingChanged += (_, _) => RefreshSavePath();
GameUpsFactor.SettingChanged += (_, _) =>
{
if (!EnableGameUpsFactor || GameUpsFactor.Value == 0.0) return;
@@ -99,7 +99,7 @@ public class GamePatch: PatchImpl<GamePatch>
{
EnableWindowResize.Enable(EnableWindowResizeEnabled.Value);
LoadLastWindowRect.Enable(LoadLastWindowRectEnabled.Value);
MouseCursorScaleUp.reload = false;
MouseCursorScaleUp.NeedReloadCursors = false;
MouseCursorScaleUp.Enable(MouseCursorScaleUpMultiplier.Value > 1);
// AutoSaveOpt.Enable(AutoSaveOptEnabled.Value);
ConvertSavesFromPeace.Enable(ConvertSavesFromPeaceEnabled.Value);
@@ -111,7 +111,7 @@ public class GamePatch: PatchImpl<GamePatch>
Enable(false);
LoadLastWindowRect.Enable(false);
EnableWindowResize.Enable(false);
MouseCursorScaleUp.reload = false;
MouseCursorScaleUp.NeedReloadCursors = false;
MouseCursorScaleUp.Enable(false);
// AutoSaveOpt.Enable(false);
ConvertSavesFromPeace.Enable(false);
@@ -132,6 +132,33 @@ public class GamePatch: PatchImpl<GamePatch>
}
}
private static void RefreshSavePath()
{
var profileName = Functions.WindowFunctions.ProfileName;
if (profileName == null) return;
if (UIRoot.instance.loadGameWindow.gameObject.activeSelf)
{
UIRoot.instance.loadGameWindow._Close();
}
if (UIRoot.instance.saveGameWindow.gameObject.activeSelf)
{
UIRoot.instance.saveGameWindow._Close();
}
string gameSavePath;
if (ProfileBasedSaveFolderEnabled.Value && string.Compare(DefaultProfileName.Value, profileName, StringComparison.OrdinalIgnoreCase) != 0)
gameSavePath = $"{GameConfig.overrideDocumentFolder}{GameConfig.gameName}/Save/{profileName}/";
else
gameSavePath = $"{GameConfig.overrideDocumentFolder}{GameConfig.gameName}/Save/";
if (string.Compare(GameConfig.gameSavePath, gameSavePath, StringComparison.OrdinalIgnoreCase) == 0) return;
GameConfig.gameSavePath = gameSavePath;
if (!Directory.Exists(GameConfig.gameSavePath))
{
Directory.CreateDirectory(GameConfig.gameSavePath);
}
}
[HarmonyPrefix, HarmonyPatch(typeof(GameMain), nameof(GameMain.HandleApplicationQuit))]
private static void GameMain_HandleApplicationQuit_Prefix()
{
@@ -487,7 +514,7 @@ public class GamePatch: PatchImpl<GamePatch>
);
matcher.Advance(2).Opcode = OpCodes.Brfalse;
matcher.Insert(
new CodeInstruction(OpCodes.Ldsfld, AccessTools.Field(typeof(ConvertSavesFromPeace), nameof(ConvertSavesFromPeace._needConvert)))
new CodeInstruction(OpCodes.Ldsfld, AccessTools.Field(typeof(ConvertSavesFromPeace), nameof(_needConvert)))
);
return matcher.InstructionEnumeration();
}
@@ -500,13 +527,14 @@ public class GamePatch: PatchImpl<GamePatch>
}
}
[PatchSetCallbackFlag(PatchCallbackFlag.CallOnDisableAfterUnpatch)]
private class MouseCursorScaleUp: PatchImpl<MouseCursorScaleUp>
{
public static bool reload;
public static bool NeedReloadCursors;
protected override void OnEnable()
{
if (!reload) return;
if (!NeedReloadCursors) return;
if (!UICursor.loaded) return;
UICursor.loaded = false;
UICursor.LoadCursors();
@@ -514,7 +542,7 @@ public class GamePatch: PatchImpl<GamePatch>
protected override void OnDisable()
{
if (!reload) return;
if (!NeedReloadCursors) return;
if (!UICursor.loaded) return;
UICursor.loaded = false;
UICursor.LoadCursors();