mirror of
https://github.com/soarqin/DSP_Mods.git
synced 2026-08-06 05:50:18 +08:00
refactor(CheatEnabler/UniverseGen): consume more centralized constants
This commit is contained in:
@@ -5,6 +5,7 @@ using BepInEx.Configuration;
|
||||
using HarmonyLib;
|
||||
using UnityEngine.UI;
|
||||
using UXAssist.Common;
|
||||
using UXAssist.Common.GameConstants;
|
||||
using UXAssist.Common.ModFeatures;
|
||||
|
||||
namespace UniverseGenTweaks;
|
||||
@@ -87,7 +88,7 @@ public static class EpicDifficulty
|
||||
[HarmonyPatch(typeof(UIGalaxySelect), nameof(UIGalaxySelect._OnInit))]
|
||||
private static void PatchGalaxyUI_OnInit(UIGalaxySelect __instance)
|
||||
{
|
||||
__instance.resourceMultiplierSlider.maxValue = 11f;
|
||||
__instance.resourceMultiplierSlider.maxValue = UniverseGenConstants.ResourceMultiplierSliderMax;
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
@@ -165,10 +166,10 @@ public static class EpicDifficulty
|
||||
matcher.Start().InsertAndAdvance(
|
||||
new CodeInstruction(OpCodes.Ldarg_0),
|
||||
new CodeInstruction(OpCodes.Ldfld, AccessTools.Field(typeof(GameDesc), nameof(GameDesc.resourceMultiplier))),
|
||||
new CodeInstruction(OpCodes.Ldc_R4, 0.05f),
|
||||
new CodeInstruction(OpCodes.Ldc_R4, UniverseGenConstants.OilMultiplierThreshold),
|
||||
new CodeInstruction(OpCodes.Ble_S, label1)
|
||||
).End().Advance(1).Insert(
|
||||
new CodeInstruction(OpCodes.Ldc_R4, 0.5f * OilMultiplier.Value).WithLabels(label1),
|
||||
new CodeInstruction(OpCodes.Ldc_R4, UniverseGenConstants.OilMultiplierBase * OilMultiplier.Value).WithLabels(label1),
|
||||
new CodeInstruction(OpCodes.Ret)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -80,15 +80,15 @@ public static class GalaxySelectUIPatch
|
||||
_maxStepTitle.name = "max-step";
|
||||
_flattenTitle.name = "flatten";
|
||||
|
||||
TransformDeltaY(_minDistTitle.transform, -36f);
|
||||
TransformDeltaY(_minStepTitle.transform, -36f * 2);
|
||||
TransformDeltaY(_maxStepTitle.transform, -36f * 3);
|
||||
TransformDeltaY(_flattenTitle.transform, -36f * 4);
|
||||
TransformDeltaY(__instance.darkFogToggle.transform.parent, -36f * 4);
|
||||
TransformDeltaY(__instance.resourceMultiplierSlider.transform.parent, -36f * 4);
|
||||
TransformDeltaY(__instance.sandboxToggle.transform.parent, -36f * 4);
|
||||
TransformDeltaY(__instance.propertyMultiplierText.transform, -36f * 4);
|
||||
TransformDeltaY(__instance.addrText.transform.parent, -36f * 4);
|
||||
TransformDeltaY(_minDistTitle.transform, UniverseGenConstants.SliderRowSpacing);
|
||||
TransformDeltaY(_minStepTitle.transform, UniverseGenConstants.SliderRowSpacing * 2);
|
||||
TransformDeltaY(_maxStepTitle.transform, UniverseGenConstants.SliderRowSpacing * 3);
|
||||
TransformDeltaY(_flattenTitle.transform, UniverseGenConstants.SliderRowSpacing * 4);
|
||||
TransformDeltaY(__instance.darkFogToggle.transform.parent, UniverseGenConstants.SliderRowSpacing * 4);
|
||||
TransformDeltaY(__instance.resourceMultiplierSlider.transform.parent, UniverseGenConstants.SliderRowSpacing * 4);
|
||||
TransformDeltaY(__instance.sandboxToggle.transform.parent, UniverseGenConstants.SliderRowSpacing * 4);
|
||||
TransformDeltaY(__instance.propertyMultiplierText.transform, UniverseGenConstants.SliderRowSpacing * 4);
|
||||
TransformDeltaY(__instance.addrText.transform.parent, UniverseGenConstants.SliderRowSpacing * 4);
|
||||
|
||||
RemoveAllListeners();
|
||||
UpdateSliderControls();
|
||||
@@ -138,21 +138,21 @@ public static class GalaxySelectUIPatch
|
||||
|
||||
private static void UpdateSliderControls()
|
||||
{
|
||||
_minDistSlider.minValue = 10f;
|
||||
_minDistSlider.maxValue = 50f;
|
||||
_minDistSlider.value = (float)(GalaxyGenSettingsPatch.MinDist * 10.0);
|
||||
_minDistSlider.minValue = UniverseGenConstants.MinDistSliderMin;
|
||||
_minDistSlider.maxValue = UniverseGenConstants.MinDistSliderMax;
|
||||
_minDistSlider.value = (float)(GalaxyGenSettingsPatch.MinDist * UniverseGenConstants.StepSliderScale);
|
||||
|
||||
_minStepSlider.minValue = (float)(GalaxyGenSettingsPatch.MinDist * 10.0);
|
||||
_minStepSlider.maxValue = (float)(GalaxyGenSettingsPatch.MaxStep * 10.0);
|
||||
_minStepSlider.value = (float)(GalaxyGenSettingsPatch.MinStep * 10.0);
|
||||
_minStepSlider.minValue = (float)(GalaxyGenSettingsPatch.MinDist * UniverseGenConstants.StepSliderScale);
|
||||
_minStepSlider.maxValue = (float)(GalaxyGenSettingsPatch.MaxStep * UniverseGenConstants.StepSliderScale);
|
||||
_minStepSlider.value = (float)(GalaxyGenSettingsPatch.MinStep * UniverseGenConstants.StepSliderScale);
|
||||
|
||||
_maxStepSlider.minValue = (float)(GalaxyGenSettingsPatch.MinStep * 10.0);
|
||||
_maxStepSlider.maxValue = 100f;
|
||||
_maxStepSlider.value = (float)(GalaxyGenSettingsPatch.MaxStep * 10.0);
|
||||
_maxStepSlider.minValue = (float)(GalaxyGenSettingsPatch.MinStep * UniverseGenConstants.StepSliderScale);
|
||||
_maxStepSlider.maxValue = UniverseGenConstants.MaxStepSliderMax;
|
||||
_maxStepSlider.value = (float)(GalaxyGenSettingsPatch.MaxStep * UniverseGenConstants.StepSliderScale);
|
||||
|
||||
_flattenSlider.minValue = 1f;
|
||||
_flattenSlider.maxValue = 50f;
|
||||
_flattenSlider.value = (float)(GalaxyGenSettingsPatch.Flatten * 50.0);
|
||||
_flattenSlider.minValue = UniverseGenConstants.FlattenSliderMin;
|
||||
_flattenSlider.maxValue = UniverseGenConstants.FlattenSliderMax;
|
||||
_flattenSlider.value = (float)(GalaxyGenSettingsPatch.Flatten * UniverseGenConstants.FlattenSliderScale);
|
||||
|
||||
_minDistText.text = GalaxyGenSettingsPatch.MinDist.ToString();
|
||||
_minStepText.text = GalaxyGenSettingsPatch.MinStep.ToString();
|
||||
@@ -174,7 +174,7 @@ public static class GalaxySelectUIPatch
|
||||
{
|
||||
_minDistSlider.onValueChanged.AddListener(val =>
|
||||
{
|
||||
var newVal = Mathf.Round(val) / 10.0;
|
||||
var newVal = Mathf.Round(val) / UniverseGenConstants.StepSliderScale;
|
||||
if (newVal.Equals(GalaxyGenSettingsPatch.MinDist)) return;
|
||||
GalaxyGenSettingsPatch.MinDist = newVal;
|
||||
_minDistText.text = GalaxyGenSettingsPatch.MinDist.ToString();
|
||||
@@ -195,7 +195,7 @@ public static class GalaxySelectUIPatch
|
||||
});
|
||||
_minStepSlider.onValueChanged.AddListener(val =>
|
||||
{
|
||||
var newVal = Mathf.Round(val) / 10.0;
|
||||
var newVal = Mathf.Round(val) / UniverseGenConstants.StepSliderScale;
|
||||
if (newVal.Equals(GalaxyGenSettingsPatch.MinStep)) return;
|
||||
GalaxyGenSettingsPatch.MinStep = newVal;
|
||||
_maxStepSlider.minValue = (float)(newVal * 10.0);
|
||||
@@ -204,7 +204,7 @@ public static class GalaxySelectUIPatch
|
||||
});
|
||||
_maxStepSlider.onValueChanged.AddListener(val =>
|
||||
{
|
||||
var newVal = Mathf.Round(val) / 10.0;
|
||||
var newVal = Mathf.Round(val) / UniverseGenConstants.StepSliderScale;
|
||||
if (newVal.Equals(GalaxyGenSettingsPatch.MaxStep)) return;
|
||||
GalaxyGenSettingsPatch.MaxStep = newVal;
|
||||
_minStepSlider.maxValue = (float)(newVal * 10.0);
|
||||
@@ -213,7 +213,7 @@ public static class GalaxySelectUIPatch
|
||||
});
|
||||
_flattenSlider.onValueChanged.AddListener(val =>
|
||||
{
|
||||
var newVal = Mathf.Round(val) / 50.0;
|
||||
var newVal = Mathf.Round(val) / UniverseGenConstants.FlattenSliderScale;
|
||||
if (newVal.Equals(GalaxyGenSettingsPatch.Flatten)) return;
|
||||
GalaxyGenSettingsPatch.Flatten = newVal;
|
||||
_flattenText.text = GalaxyGenSettingsPatch.Flatten.ToString();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using UnityEngine;
|
||||
using UXAssist.UI;
|
||||
using UXAssist.Common;
|
||||
using UXAssist.Common.GameConstants;
|
||||
|
||||
namespace UniverseGenTweaks;
|
||||
|
||||
@@ -51,10 +52,10 @@ public static class UIConfigWindow
|
||||
MyWindow.AddText(x, y, tab1, "Maximum star count", 16);
|
||||
x += 20f;
|
||||
y += 26f;
|
||||
var sl0 = MySlider.CreateSlider(x, y, tab1, MoreSettings.MaxStarCount.Value, 64f, 1024f, "G", 240f);
|
||||
var sl0 = MySlider.CreateSlider(x, y, tab1, MoreSettings.MaxStarCount.Value, UniverseGenConstants.StarCountSliderMin, UniverseGenConstants.StarCountSliderMax, "G", 240f);
|
||||
sl0.OnValueChanged += () =>
|
||||
{
|
||||
sl0.Value = MoreSettings.MaxStarCount.Value = (Mathf.RoundToInt(sl0.Value) + 7) & ~7;
|
||||
sl0.Value = MoreSettings.MaxStarCount.Value = (Mathf.RoundToInt(sl0.Value) + UniverseGenConstants.StarCountAlignmentMask) & ~UniverseGenConstants.StarCountAlignmentMask;
|
||||
};
|
||||
x -= 30f;
|
||||
y += 36f;
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Reflection;
|
||||
using BepInEx;
|
||||
using BepInEx.Configuration;
|
||||
using crecheng.DSPModSave;
|
||||
using UXAssist.Common.GameConstants;
|
||||
using UXAssist.Common.ModFeatures;
|
||||
|
||||
namespace UniverseGenTweaks;
|
||||
@@ -19,9 +20,9 @@ public class UniverseGenTweaks : BaseUnityPlugin, IModCanSave
|
||||
private void Awake()
|
||||
{
|
||||
MoreSettings.Enabled = Config.Bind("MoreSettings", "Enabled", true, "Enable more settings on Universe Generation");
|
||||
MoreSettings.MaxStarCount = Config.Bind("MoreSettings", "MaxStarCount", 128,
|
||||
new ConfigDescription("(32 ~ 1024)\nMaximum star count for Universe Generation, enable MoreSettings.Enabled to take effect",
|
||||
new AcceptableValueRange<int>(32, 1024), new { }));
|
||||
MoreSettings.MaxStarCount = Config.Bind("MoreSettings", "MaxStarCount", UniverseGenConstants.DefaultMaxStarCount,
|
||||
new ConfigDescription($"({UniverseGenConstants.MinStarCount} ~ {UniverseGenConstants.MaxStarCount})\nMaximum star count for Universe Generation, enable MoreSettings.Enabled to take effect",
|
||||
new AcceptableValueRange<int>(UniverseGenConstants.MinStarCount, UniverseGenConstants.MaxStarCount), new { }));
|
||||
|
||||
EpicDifficulty.Enabled = Config.Bind("EpicDifficulty", "Enabled", true, "Enable Epic difficulty");
|
||||
EpicDifficulty.ResourceMultiplier = Config.Bind("EpicDifficulty", "ResourceMultiplier", 0.01f,
|
||||
|
||||
Reference in New Issue
Block a user