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

work in progress

This commit is contained in:
2023-10-14 22:35:47 +08:00
parent 31b992c7a2
commit 7fae7cc66e
14 changed files with 308 additions and 293 deletions

View File

@@ -60,26 +60,6 @@ public class CheatEnabler : BaseUnityPlugin
"Overclock ejector"); "Overclock ejector");
DysonSpherePatch.OverclockSiloEnabled = Config.Bind("DysonSphere", "OverclockSilo", false, DysonSpherePatch.OverclockSiloEnabled = Config.Bind("DysonSphere", "OverclockSilo", false,
"Overclock silo"); "Overclock silo");
BirthPlanetPatch.SitiVeinsOnBirthPlanet = Config.Bind("Birth", "SiTiVeinsOnBirthPlanet", false,
"Silicon/Titanium on birth planet");
BirthPlanetPatch.FireIceOnBirthPlanet = Config.Bind("Birth", "FireIceOnBirthPlanet", false,
"Fire ice on birth planet");
BirthPlanetPatch.KimberliteOnBirthPlanet = Config.Bind("Birth", "KimberliteOnBirthPlanet", false,
"Kimberlite on birth planet");
BirthPlanetPatch.FractalOnBirthPlanet = Config.Bind("Birth", "FractalOnBirthPlanet", false,
"Fractal silicon on birth planet");
BirthPlanetPatch.OrganicOnBirthPlanet = Config.Bind("Birth", "OrganicOnBirthPlanet", false,
"Organic crystal on birth planet");
BirthPlanetPatch.OpticalOnBirthPlanet = Config.Bind("Birth", "OpticalOnBirthPlanet", false,
"Optical grating crystal on birth planet");
BirthPlanetPatch.SpiniformOnBirthPlanet = Config.Bind("Birth", "SpiniformOnBirthPlanet", false,
"Spiniform stalagmite crystal on birth planet");
BirthPlanetPatch.UnipolarOnBirthPlanet = Config.Bind("Birth", "UnipolarOnBirthPlanet", false,
"Unipolar magnet on birth planet");
BirthPlanetPatch.FlatBirthPlanet = Config.Bind("Birth", "FlatBirthPlanet", false,
"Birth planet is solid flat (no water at all)");
BirthPlanetPatch.HighLuminosityBirthStar = Config.Bind("Birth", "HighLuminosityBirthStar", false,
"Birth star has high luminosity");
UIConfigWindow.Init(); UIConfigWindow.Init();
@@ -90,12 +70,10 @@ public class CheatEnabler : BaseUnityPlugin
ResourcePatch.Init(); ResourcePatch.Init();
PlanetPatch.Init(); PlanetPatch.Init();
DysonSpherePatch.Init(); DysonSpherePatch.Init();
BirthPlanetPatch.Init();
} }
private void OnDestroy() private void OnDestroy()
{ {
BirthPlanetPatch.Uninit();
DysonSpherePatch.Uninit(); DysonSpherePatch.Uninit();
PlanetPatch.Uninit(); PlanetPatch.Uninit();
ResourcePatch.Uninit(); ResourcePatch.Uninit();

View File

@@ -6,6 +6,7 @@
## Changlog ## Changlog
* 2.3.2 * 2.3.2
+ Birth star options moved to [UniverseGenTweaks](https://dsp.thunderstore.io/package/soarqin/UniverseGenTweaks/) + Birth star options moved to [UniverseGenTweaks](https://dsp.thunderstore.io/package/soarqin/UniverseGenTweaks/)
+ `Fast Mining` ensures full output of oil extractors now.
+ Crash fix for some options + Crash fix for some options
* 2.3.1 * 2.3.1
+ Add UXAssist to dependencies in manifest. + Add UXAssist to dependencies in manifest.
@@ -84,10 +85,6 @@
+ Skip absorption period + Skip absorption period
+ Quick absorb + Quick absorb
+ Eject anyway + Eject anyway
+ Birth star:
+ Rare resources on birth planet
+ Solid flat on birth planet
+ High luminosity for birth star
## Notes ## Notes
* Please upgrade `BepInEx` 5.4.21 or later if using with [BlueprintTweaks](https://dsp.thunderstore.io/package/kremnev8/BlueprintTweaks/) to avoid possible conflicts. * Please upgrade `BepInEx` 5.4.21 or later if using with [BlueprintTweaks](https://dsp.thunderstore.io/package/kremnev8/BlueprintTweaks/) to avoid possible conflicts.
@@ -102,6 +99,7 @@
## 更新日志 ## 更新日志
* 2.3.2 * 2.3.2
+ 母星系的选项移动到了[UniverseGenTweaks](https://dsp.thunderstore.io/package/soarqin/UniverseGenTweaks/) + 母星系的选项移动到了[UniverseGenTweaks](https://dsp.thunderstore.io/package/soarqin/UniverseGenTweaks/)
+ `高速采集`现在可以保证油井的最大产出
+ 修复了一些选项可能导致崩溃的问题 + 修复了一些选项可能导致崩溃的问题
* 2.3.1 * 2.3.1
+ 在manifest中添加UXAssist到依赖 + 在manifest中添加UXAssist到依赖
@@ -180,10 +178,6 @@
+ 跳过吸收阶段 + 跳过吸收阶段
+ 快速吸收 + 快速吸收
+ 全球弹射 + 全球弹射
+ 母星系:
+ 母星有稀有资源
+ 母星是纯平的
+ 母星系恒星高亮
## 注意事项 ## 注意事项
* 如果和[BlueprintTweaks](https://dsp.thunderstore.io/package/kremnev8/BlueprintTweaks/)一起使用,请升级`BepInEx`到5.4.21或更高版本,以避免可能的冲突。 * 如果和[BlueprintTweaks](https://dsp.thunderstore.io/package/kremnev8/BlueprintTweaks/)一起使用,请升级`BepInEx`到5.4.21或更高版本,以避免可能的冲突。

View File

@@ -107,7 +107,7 @@ public static class ResourcePatch
).Repeat(codeMatcher => ).Repeat(codeMatcher =>
codeMatcher.RemoveInstruction().InsertAndAdvance( codeMatcher.RemoveInstruction().InsertAndAdvance(
new CodeInstruction(OpCodes.Pop), new CodeInstruction(OpCodes.Pop),
new CodeInstruction(OpCodes.Ldc_R4, 720f) new CodeInstruction(OpCodes.Ldc_R4, 2400f)
) )
); );
return matcher.InstructionEnumeration(); return matcher.InstructionEnumeration();

View File

@@ -183,30 +183,6 @@ public static class UIConfigWindow
MyCheckBox.CreateCheckBox(x, y, tab4, DysonSpherePatch.OverclockEjectorEnabled, "Overclock Ejectors"); MyCheckBox.CreateCheckBox(x, y, tab4, DysonSpherePatch.OverclockEjectorEnabled, "Overclock Ejectors");
y += 36f; y += 36f;
MyCheckBox.CreateCheckBox(x, y, tab4, DysonSpherePatch.OverclockSiloEnabled, "Overclock Silos"); MyCheckBox.CreateCheckBox(x, y, tab4, DysonSpherePatch.OverclockSiloEnabled, "Overclock Silos");
var tab5 = wnd.AddTab(_windowTrans, "Birth");
x = 0f;
y = 10f;
MyCheckBox.CreateCheckBox(x, y, tab5, BirthPlanetPatch.SitiVeinsOnBirthPlanet, "Silicon/Titanium on birth planet");
y += 36f;
MyCheckBox.CreateCheckBox(x, y, tab5, BirthPlanetPatch.FireIceOnBirthPlanet, "Fire ice on birth planet");
y += 36f;
MyCheckBox.CreateCheckBox(x, y, tab5, BirthPlanetPatch.KimberliteOnBirthPlanet, "Kimberlite on birth planet");
y += 36f;
MyCheckBox.CreateCheckBox(x, y, tab5, BirthPlanetPatch.FractalOnBirthPlanet, "Fractal silicon on birth planet");
y += 36f;
MyCheckBox.CreateCheckBox(x, y, tab5, BirthPlanetPatch.OrganicOnBirthPlanet, "Organic crystal on birth planet");
y += 36f;
MyCheckBox.CreateCheckBox(x, y, tab5, BirthPlanetPatch.OpticalOnBirthPlanet, "Optical grating crystal on birth planet");
y += 36f;
MyCheckBox.CreateCheckBox(x, y, tab5, BirthPlanetPatch.SpiniformOnBirthPlanet, "Spiniform stalagmite crystal on birth planet");
y += 36f;
MyCheckBox.CreateCheckBox(x, y, tab5, BirthPlanetPatch.UnipolarOnBirthPlanet, "Unipolar magnet on birth planet");
x = 300f;
y = 10f;
MyCheckBox.CreateCheckBox(x, y, tab5, BirthPlanetPatch.FlatBirthPlanet, "Birth planet is solid flat (no water at all)");
y += 36f;
MyCheckBox.CreateCheckBox(x, y, tab5, BirthPlanetPatch.HighLuminosityBirthStar, "Birth star has high luminosity");
return; return;
void OnBeltSignalChanged() void OnBeltSignalChanged()

View File

@@ -47,6 +47,7 @@
## 更新日志 ## 更新日志
* 1.0.1 * 1.0.1
+ 修复了返回标题界面后设置按钮文本和提示信息不正确的问题 + 修复了返回标题界面后设置按钮文本和提示信息不正确的问题
+ 添加了一个补丁,修复了`矿物利用`升级到8000级以上时弹出警告的bug
* 1.0.0 * 1.0.0
+ 初始版本 + 初始版本
+ 从[MechaDronesTweaks](https://dsp.thunderstore.io/package/soarqin/MechaDronesTweaks/)和[CheatEnabler](https://dsp.thunderstore.io/package/soarqin/CheatEnabler/)移动了部分功能过来 + 从[MechaDronesTweaks](https://dsp.thunderstore.io/package/soarqin/MechaDronesTweaks/)和[CheatEnabler](https://dsp.thunderstore.io/package/soarqin/CheatEnabler/)移动了部分功能过来

View File

@@ -1,4 +1,5 @@
using System; using System;
using BepInEx.Configuration;
using UnityEngine; using UnityEngine;
using UnityEngine.UI; using UnityEngine.UI;
@@ -24,7 +25,7 @@ public class MySlider : MonoBehaviour
} }
} }
public static RectTransform CreateSlider(float x, float y, RectTransform parent, float value, float minValue, float maxValue, string format = "{0}", float width = 0f) public static MySlider CreateSlider(float x, float y, RectTransform parent, float value, float minValue, float maxValue, string format = "G", float width = 0f)
{ {
var optionWindow = UIRoot.instance.optionWindow; var optionWindow = UIRoot.instance.optionWindow;
var src = optionWindow.audioVolumeComp; var src = optionWindow.audioVolumeComp;
@@ -71,14 +72,14 @@ public class MySlider : MonoBehaviour
sl.OnValueSet(); sl.OnValueSet();
sl.UpdateLabel(); sl.UpdateLabel();
return sl.rectTrans; return sl;
} }
public void OnValueSet() public void OnValueSet()
{ {
lock (this) lock (this)
{ {
var sliderVal = _value; var sliderVal = _value;
if (_value.Equals(slider.value)) return; if (sliderVal.Equals(slider.value)) return;
if (sliderVal > slider.maxValue) if (sliderVal > slider.maxValue)
{ {
_value = sliderVal = slider.maxValue; _value = sliderVal = slider.maxValue;

View File

@@ -2,7 +2,7 @@
using BepInEx.Configuration; using BepInEx.Configuration;
using HarmonyLib; using HarmonyLib;
namespace CheatEnabler; namespace UniverseGenTweaks;
public static class BirthPlanetPatch public static class BirthPlanetPatch
{ {
public static ConfigEntry<bool> SitiVeinsOnBirthPlanet; public static ConfigEntry<bool> SitiVeinsOnBirthPlanet;

View File

@@ -1,19 +1,84 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Reflection.Emit; using System.Reflection.Emit;
using BepInEx.Configuration;
using HarmonyLib; using HarmonyLib;
using UnityEngine.UI; using UnityEngine.UI;
using UXAssist.Common;
namespace UniverseGenTweaks; namespace UniverseGenTweaks;
public class EpicDifficulty public static class EpicDifficulty
{ {
public static ConfigEntry<bool> Enabled;
public static ConfigEntry<float> ResourceMultiplier;
public static ConfigEntry<float> OilMultiplier;
private static Harmony _harmony;
private static readonly float[] ResourceMultipliers = new[] { 0.0001f, 0.0005f, 0.001f, 0.005f, 0.01f, 0.02f, 0.03f, 0.04f, 0.05f };
private static readonly float[] OilMultipliers = new[] { 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f, 1f };
public static void Init() public static void Init()
{ {
I18N.Add("究极少", "Micro", "究极少"); I18N.Add("究极少", "Micro", "究极少");
I18N.Add("史诗难度", "Epic Difficulty !!", "史诗难度 !!"); I18N.Add("史诗难度", "Epic Difficulty !!", "史诗难度 !!");
I18N.Apply(); I18N.Apply();
Harmony.CreateAndPatchAll(typeof(EpicDifficulty)); Enabled.SettingChanged += (_, _) => Enable(Enabled.Value);
Enable(Enabled.Value);
}
public static void Uninit()
{
Enable(false);
}
private static void Enable(bool on)
{
if (on)
{
_harmony ??= Harmony.CreateAndPatchAll(typeof(EpicDifficulty));
return;
}
_harmony?.UnpatchSelf();
_harmony = null;
}
public static float IndexToResourceMultiplier(int index)
{
return ResourceMultipliers[index < 0 ? 0 : index >= ResourceMultipliers.Length ? ResourceMultipliers.Length - 1 : index];
}
public static int ResourceMultiplierToIndex(float mult)
{
for (var i = ResourceMultipliers.Length - 1; i > 0; i--)
{
if (ResourceMultipliers[i] <= mult) return i;
}
return 0;
}
public static int ResourceMultipliersCount()
{
return ResourceMultipliers.Length;
}
public static float IndexToOilMultiplier(int index)
{
return OilMultipliers[index < 0 ? 0 : index >= OilMultipliers.Length ? OilMultipliers.Length - 1 : index];
}
public static int OilMultiplierToIndex(float mult)
{
for (var i = OilMultipliers.Length - 1; i > 0; i--)
{
if (OilMultipliers[i] <= mult) return i;
}
return 0;
}
public static int OilMultipliersCount()
{
return OilMultipliers.Length;
} }
[HarmonyPostfix] [HarmonyPostfix]
@@ -27,51 +92,21 @@ public class EpicDifficulty
[HarmonyPatch(typeof(UIGalaxySelect), nameof(UIGalaxySelect.OnResourceMultiplierValueChange))] [HarmonyPatch(typeof(UIGalaxySelect), nameof(UIGalaxySelect.OnResourceMultiplierValueChange))]
private static bool UIGalaxySelect_OnResourceMultiplierValueChange_Prefix(UIGalaxySelect __instance, float val) private static bool UIGalaxySelect_OnResourceMultiplierValueChange_Prefix(UIGalaxySelect __instance, float val)
{ {
float value = __instance.resourceMultiplierSlider.value; var value = __instance.resourceMultiplierSlider.value;
if (value < 0.5f) __instance.gameDesc.resourceMultiplier = value switch
{ {
__instance.gameDesc.resourceMultiplier = 0.01f; < 0.5f => ResourceMultiplier.Value,
} < 1.5f => 0.1f,
else if (value < 1.5f) < 2.5f => 0.5f,
{ < 3.5f => 0.8f,
__instance.gameDesc.resourceMultiplier = 0.1f; < 4.5f => 1f,
} < 5.5f => 1.5f,
else if (value < 2.5f) < 6.5f => 2f,
{ < 7.5f => 3f,
__instance.gameDesc.resourceMultiplier = 0.5f; < 8.5f => 5f,
} < 9.5f => 8f,
else if (value < 3.5f) _ => 100f
{ };
__instance.gameDesc.resourceMultiplier = 0.8f;
}
else if (value < 4.5f)
{
__instance.gameDesc.resourceMultiplier = 1f;
}
else if (value < 5.5f)
{
__instance.gameDesc.resourceMultiplier = 1.5f;
}
else if (value < 6.5f)
{
__instance.gameDesc.resourceMultiplier = 2f;
}
else if (value < 7.5f)
{
__instance.gameDesc.resourceMultiplier = 3f;
}
else if (value < 8.5f)
{
__instance.gameDesc.resourceMultiplier = 5f;
}
else if (value < 9.5f)
{
__instance.gameDesc.resourceMultiplier = 8f;
}
else
{
__instance.gameDesc.resourceMultiplier = 100f;
}
__instance.UpdateParametersUIDisplay(); __instance.UpdateParametersUIDisplay();
return false; return false;
} }
@@ -80,84 +115,37 @@ public class EpicDifficulty
[HarmonyPatch(typeof(UIGalaxySelect), nameof(UIGalaxySelect.UpdateParametersUIDisplay))] [HarmonyPatch(typeof(UIGalaxySelect), nameof(UIGalaxySelect.UpdateParametersUIDisplay))]
private static bool UIGalaxySelect_UpdateParametersUIDisplay_Prefix(UIGalaxySelect __instance) private static bool UIGalaxySelect_UpdateParametersUIDisplay_Prefix(UIGalaxySelect __instance)
{ {
float resourceMultiplier = __instance.gameDesc.resourceMultiplier; var resourceMultiplier = __instance.gameDesc.resourceMultiplier;
string text = ""; var text = "";
if (resourceMultiplier < 0.04f) __instance.resourceMultiplierSlider.value = resourceMultiplier switch
{ {
__instance.resourceMultiplierSlider.value = 0f; < 0.09f => 0f,
} < 0.11f => 1f,
else if (resourceMultiplier < 0.11f) < 0.51f => 2f,
< 0.81f => 3f,
< 1.01f => 4f,
< 1.51f => 5f,
< 2.01f => 6f,
< 3.01f => 7f,
< 5.01f => 8f,
< 8.01f => 9f,
_ => 10f
};
text = resourceMultiplier switch
{ {
__instance.resourceMultiplierSlider.value = 1f; < 100f and > 0.1f => resourceMultiplier + "x",
} >= 100f => "无限".Translate(),
else if (resourceMultiplier < 0.51f) < 0.09f => "究极少".Translate(),
{ < 0.11f => "极少".Translate(),
__instance.resourceMultiplierSlider.value = 2f; _ => text
} };
else if (resourceMultiplier < 0.81f)
{
__instance.resourceMultiplierSlider.value = 3f;
}
else if (resourceMultiplier < 1.01f)
{
__instance.resourceMultiplierSlider.value = 4f;
}
else if (resourceMultiplier < 1.51f)
{
__instance.resourceMultiplierSlider.value = 5f;
}
else if (resourceMultiplier < 2.01f)
{
__instance.resourceMultiplierSlider.value = 6f;
}
else if (resourceMultiplier < 3.01f)
{
__instance.resourceMultiplierSlider.value = 7f;
}
else if (resourceMultiplier < 5.01f)
{
__instance.resourceMultiplierSlider.value = 8f;
}
else if (resourceMultiplier < 8.01f)
{
__instance.resourceMultiplierSlider.value = 9f;
}
else
{
__instance.resourceMultiplierSlider.value = 10f;
}
if (resourceMultiplier < 100f && resourceMultiplier > 0.1f)
{
text = resourceMultiplier.ToString() + "x";
}
else if (resourceMultiplier >= 100f)
{
text = "无限".Translate();
}
else if (resourceMultiplier < 0.04f)
{
text = "究极少".Translate();
}
else if (resourceMultiplier < 0.11f)
{
text = "极少".Translate();
}
__instance.resourceMultiplierText.text = text; __instance.resourceMultiplierText.text = text;
__instance.propertyMultiplierText.text = "元数据生成倍率".Translate() + " " + __instance.gameDesc.propertyMultiplier.ToString("P0"); __instance.propertyMultiplierText.text = "元数据生成倍率".Translate() + " " + __instance.gameDesc.propertyMultiplier.ToString("P0");
__instance.addrText.text = __instance.gameDesc.clusterString; __instance.addrText.text = __instance.gameDesc.clusterString;
var showDifficultTip = resourceMultiplier < 0.11f && !__instance.gameDesc.isSandboxMode; var showDifficultTip = resourceMultiplier < 0.11f && !__instance.gameDesc.isSandboxMode;
__instance.difficultTipGroup.SetActive(showDifficultTip); __instance.difficultTipGroup.SetActive(showDifficultTip);
if (showDifficultTip) if (!showDifficultTip) return false;
{ __instance.difficultTipGroup.transform.Find("difficult-tip-text").GetComponent<Text>().text = (resourceMultiplier < 0.09f ? "史诗难度" : "非常困难").Translate();
if (resourceMultiplier < 0.04f)
{
__instance.difficultTipGroup.transform.Find("difficult-tip-text").GetComponent<Text>().text = "史诗难度".Translate();
}
else
{
__instance.difficultTipGroup.transform.Find("difficult-tip-text").GetComponent<Text>().text = "非常困难".Translate();
}
}
return false; return false;
} }
@@ -167,7 +155,7 @@ public class EpicDifficulty
private static IEnumerable<CodeInstruction> GameDesc_get_oilAmountMultiplier_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator) private static IEnumerable<CodeInstruction> GameDesc_get_oilAmountMultiplier_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
{ {
var matcher = new CodeMatcher(instructions, generator); var matcher = new CodeMatcher(instructions, generator);
if (Math.Abs(UniverseGenTweaks.OilMultiplier - 1f) > 0.00001f) if (Math.Abs(OilMultiplier.Value - 1f) > 0.00001f)
{ {
var label1 = generator.DefineLabel(); var label1 = generator.DefineLabel();
matcher.Start().InsertAndAdvance( matcher.Start().InsertAndAdvance(
@@ -176,7 +164,7 @@ public class EpicDifficulty
new CodeInstruction(OpCodes.Ldc_R4, 0.05f), new CodeInstruction(OpCodes.Ldc_R4, 0.05f),
new CodeInstruction(OpCodes.Ble_S, label1) new CodeInstruction(OpCodes.Ble_S, label1)
).End().Advance(1).Insert( ).End().Advance(1).Insert(
new CodeInstruction(OpCodes.Ldc_R4, 0.5f * UniverseGenTweaks.OilMultiplier).WithLabels(label1), new CodeInstruction(OpCodes.Ldc_R4, 0.5f * OilMultiplier.Value).WithLabels(label1),
new CodeInstruction(OpCodes.Ret) new CodeInstruction(OpCodes.Ret)
); );
} }

View File

@@ -1,83 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using HarmonyLib;
namespace UniverseGenTweaks;
public class I18N
{
private static bool _initialized;
public static Action OnInitialized;
public static void Init()
{
Harmony.CreateAndPatchAll(typeof(I18N));
}
private static int _nextID = 1;
private static readonly List<StringProto> StringsToAdd = new();
public static void Add(string key, string enus, string zhcn = null, string frfr = null)
{
var strings = LDB._strings;
var strProto = new StringProto
{
Name = key,
SID = "",
ENUS = enus,
ZHCN = string.IsNullOrEmpty(zhcn) ? enus : zhcn,
FRFR = string.IsNullOrEmpty(frfr) ? enus : frfr
};
StringsToAdd.Add(strProto);
}
public static void Apply()
{
if (!_initialized) return;
var strings = LDB._strings;
var index = strings.dataArray.Length;
strings.dataArray = strings.dataArray.Concat(StringsToAdd).ToArray();
StringsToAdd.Clear();
var newIndex = strings.dataArray.Length;
for (; index < newIndex; index++)
{
var strProto = strings.dataArray[index];
strProto.ID = GetNextID();
strings.dataIndices[strProto.ID] = index;
strings.nameIndices[strings.dataArray[index].Name] = index;
}
}
[HarmonyPostfix, HarmonyPriority(Priority.Last), HarmonyPatch(typeof(VFPreload), "InvokeOnLoadWorkEnded")]
private static void VFPreload_InvokeOnLoadWorkEnded_Postfix()
{
if (_initialized) return;
_initialized = true;
if (StringsToAdd.Count == 0)
{
OnInitialized?.Invoke();
return;
}
Apply();
OnInitialized?.Invoke();
}
private static int GetNextID()
{
var strings = LDB._strings;
while (_nextID <= 12000)
{
if (!strings.dataIndices.ContainsKey(_nextID))
{
break;
}
_nextID++;
}
var result = _nextID;
_nextID++;
return result;
}
}

View File

@@ -4,11 +4,13 @@ using BepInEx.Configuration;
using HarmonyLib; using HarmonyLib;
using UnityEngine; using UnityEngine;
using UnityEngine.UI; using UnityEngine.UI;
using UXAssist.Common;
namespace UniverseGenTweaks; namespace UniverseGenTweaks;
public class MoreSettings public class MoreSettings
{ {
public static ConfigEntry<bool> Enabled;
public static ConfigEntry<int> MaxStarCount; public static ConfigEntry<int> MaxStarCount;
private static double _minDist = 2; private static double _minDist = 2;
private static double _minStep = 2; private static double _minStep = 2;
@@ -27,6 +29,7 @@ public class MoreSettings
private static Text _minStepText; private static Text _minStepText;
private static Text _maxStepText; private static Text _maxStepText;
private static Text _flattenText; private static Text _flattenText;
private static Harmony _harmony;
public static void Init() public static void Init()
{ {
@@ -35,7 +38,24 @@ public class MoreSettings
I18N.Add("步进最大距离", "Step Distance Max", "步进最大距离"); I18N.Add("步进最大距离", "Step Distance Max", "步进最大距离");
I18N.Add("扁平度", "Flatness", "扁平度"); I18N.Add("扁平度", "Flatness", "扁平度");
I18N.Apply(); I18N.Apply();
Harmony.CreateAndPatchAll(typeof(MoreSettings)); Enabled.SettingChanged += (_, _) => Enable(Enabled.Value);
Enable(Enabled.Value);
}
public static void Uninit()
{
Enable(false);
}
private static void Enable(bool on)
{
if (on)
{
_harmony ??= Harmony.CreateAndPatchAll(typeof(MoreSettings));
return;
}
_harmony?.UnpatchSelf();
_harmony = null;
} }
private static void CreateSliderWithText(Slider orig, out Text title, out Slider slider, out Text text) private static void CreateSliderWithText(Slider orig, out Text title, out Slider slider, out Text text)
@@ -48,9 +68,9 @@ public class MoreSettings
private static void TransformDeltaY(Transform trans, float delta) private static void TransformDeltaY(Transform trans, float delta)
{ {
var pos = trans.position; var pos = ((RectTransform)trans).anchoredPosition3D;
pos.y += delta; pos.y += delta;
trans.position = pos; ((RectTransform)trans).anchoredPosition3D = pos;
} }
[HarmonyPostfix] [HarmonyPostfix]
@@ -84,14 +104,14 @@ public class MoreSettings
_flattenSlider.maxValue = 50f; _flattenSlider.maxValue = 50f;
_flattenSlider.value = (float)(_flatten * 50.0); _flattenSlider.value = (float)(_flatten * 50.0);
TransformDeltaY(_minDistTitle.transform, -0.3573f); TransformDeltaY(_minDistTitle.transform, -36f);
TransformDeltaY(_minStepTitle.transform, -0.3573f * 2); TransformDeltaY(_minStepTitle.transform, -36f * 2);
TransformDeltaY(_maxStepTitle.transform, -0.3573f * 3); TransformDeltaY(_maxStepTitle.transform, -36f * 3);
TransformDeltaY(_flattenTitle.transform, -0.3573f * 4); TransformDeltaY(_flattenTitle.transform, -36f * 4);
TransformDeltaY(__instance.resourceMultiplierSlider.transform.parent, -0.3573f * 4); TransformDeltaY(__instance.resourceMultiplierSlider.transform.parent, -36f * 4);
TransformDeltaY(__instance.sandboxToggle.transform.parent, -0.3573f * 4); TransformDeltaY(__instance.sandboxToggle.transform.parent, -36f * 4);
TransformDeltaY(__instance.propertyMultiplierText.transform, -0.3573f * 4); TransformDeltaY(__instance.propertyMultiplierText.transform, -36f * 4);
TransformDeltaY(__instance.addrText.transform.parent, -0.3573f * 4); TransformDeltaY(__instance.addrText.transform.parent, -36f * 4);
} }
[HarmonyPrefix] [HarmonyPrefix]
@@ -182,7 +202,7 @@ public class MoreSettings
var matcher = new CodeMatcher(instructions, generator); var matcher = new CodeMatcher(instructions, generator);
matcher.MatchForward(false, matcher.MatchForward(false,
new CodeMatch(ci => ci.opcode == OpCodes.Ldc_I4_S && ci.OperandIs(80)) new CodeMatch(ci => ci.opcode == OpCodes.Ldc_I4_S && ci.OperandIs(80))
).Set(OpCodes.Ldsfld, AccessTools.Field(typeof(MoreSettings), nameof(MoreSettings.MaxStarCount))).Insert( ).SetAndAdvance(OpCodes.Ldsfld, AccessTools.Field(typeof(MoreSettings), nameof(MoreSettings.MaxStarCount))).Insert(
new CodeInstruction(OpCodes.Call, AccessTools.PropertyGetter(typeof(ConfigEntry<int>), nameof(ConfigEntry<int>.Value))) new CodeInstruction(OpCodes.Call, AccessTools.PropertyGetter(typeof(ConfigEntry<int>), nameof(ConfigEntry<int>.Value)))
); );
return matcher.InstructionEnumeration(); return matcher.InstructionEnumeration();
@@ -196,7 +216,7 @@ public class MoreSettings
var matcher = new CodeMatcher(instructions, generator); var matcher = new CodeMatcher(instructions, generator);
matcher.MatchForward(false, matcher.MatchForward(false,
new CodeMatch(ci => ci.opcode == OpCodes.Ldc_I4 && ci.OperandIs(25600)) new CodeMatch(ci => ci.opcode == OpCodes.Ldc_I4 && ci.OperandIs(25600))
).Set(OpCodes.Ldfld, AccessTools.Field(typeof(MoreSettings), nameof(MoreSettings.MaxStarCount))).Insert( ).SetAndAdvance(OpCodes.Ldsfld, AccessTools.Field(typeof(MoreSettings), nameof(MoreSettings.MaxStarCount))).Insert(
new CodeInstruction(OpCodes.Call, AccessTools.PropertyGetter(typeof(ConfigEntry<int>), nameof(ConfigEntry<int>.Value))), new CodeInstruction(OpCodes.Call, AccessTools.PropertyGetter(typeof(ConfigEntry<int>), nameof(ConfigEntry<int>.Value))),
new CodeInstruction(OpCodes.Ldc_I4_1), new CodeInstruction(OpCodes.Ldc_I4_1),
new CodeInstruction(OpCodes.Add), new CodeInstruction(OpCodes.Add),

View File

@@ -4,6 +4,10 @@
#### 宇宙生成参数调节 #### 宇宙生成参数调节
## Changelog ## Changelog
* 1.2.0
+ Depends on [UXAssist](https://dsp.thunderstore.io/package/soarqin/UXAssist/) now.
+ Add `Birth star` options
+ Config tab added to UXAssist config panel.
* 1.1.0 * 1.1.0
+ Add epic difficulty + Add epic difficulty
+ `More options` and `Epic difficulty` can be enabled individually now. + `More options` and `Epic difficulty` can be enabled individually now.
@@ -18,8 +22,16 @@
2. Epic difficulty 2. Epic difficulty
* 0.01x resources and 0.25x oils (very hard difficulty has 0.5x oils). * 0.01x resources and 0.25x oils (very hard difficulty has 0.5x oils).
* Same oil mining speed as very hard difficuly * Same oil mining speed as very hard difficuly
3. Birth star
* Rare resources on birth planet
* Solid flat on birth planet
* High luminosity for birth star
## 更新日志 ## 更新日志
* 1.2.0
+ 现在依赖于[UXAssist](https://dsp.thunderstore.io/package/soarqin/UXAssist/)
+ 增加`母星系`选项
+ 在UXAssist的配置面板中增加了一个选项卡
* 1.1.0 * 1.1.0
+ 增加史诗难度 + 增加史诗难度
+ `更多选项``史诗难度`现在可以单独启用 + `更多选项``史诗难度`现在可以单独启用
@@ -34,3 +46,7 @@
2. 史诗难度 2. 史诗难度
* 资源0.01倍油井储量0.25倍(极难是0.5倍) * 资源0.01倍油井储量0.25倍(极难是0.5倍)
* 采油速度和极难相同 * 采油速度和极难相同
3. 母星系
* 母星有稀有资源
* 母星是纯平的
* 母星系恒星高亮

View File

@@ -0,0 +1,98 @@
using UnityEngine;
using UXAssist.UI;
using UXAssist.Common;
namespace UniverseGenTweaks;
public static class UIConfigWindow
{
private static RectTransform _windowTrans;
public static void Init()
{
I18N.Add("GalaxyGen", "+UniverseGen+", "+宇宙生成+");
I18N.Add("Enable more settings on UniverseGen", "Enable more settings on UniverseGen", "启用更多宇宙生成设置");
I18N.Add("* Requires game restart to take effect", "* Requires game restart to take effect", "* 需要重启游戏才能生效");
I18N.Add("Enable Epic difficulty", "Enable Epic difficulty", "启用史诗难度");
I18N.Add("Resource multiplier", "Resource multiplier", "资源倍率");
I18N.Add("Oil multiplier (relative to Very Hard)", "Oil multiplier (relative to Very Hard)", "石油倍率(相对于非常困难)");
I18N.Add("Silicon/Titanium on birth planet", "Silicon/Titanium on birth planet", "母星有硅和钛");
I18N.Add("Fire ice on birth planet", "Fire ice on birth planet", "母星有可燃冰");
I18N.Add("Kimberlite on birth planet", "Kimberlite on birth planet", "母星有金伯利矿");
I18N.Add("Fractal silicon on birth planet", "Fractal silicon on birth planet", "母星有分形硅");
I18N.Add("Organic crystal on birth planet", "Organic crystal on birth planet", "母星有有机晶体");
I18N.Add("Optical grating crystal on birth planet", "Optical grating crystal on birth planet", "母星有光栅石");
I18N.Add("Spiniform stalagmite crystal on birth planet", "Spiniform stalagmite crystal on birth planet", "母星有刺笋结晶");
I18N.Add("Unipolar magnet on birth planet", "Unipolar magnet on birth planet", "母星有单极磁石");
I18N.Add("Birth planet is solid flat (no water at all)", "Birth planet is solid flat (no water at all)", "母星是纯平的(没有水)");
I18N.Add("Birth star has high luminosity", "Birth star has high luminosity", "母星系恒星高亮");
I18N.Apply();
MyConfigWindow.OnUICreated += CreateUI;
}
private static void CreateUI(MyConfigWindow wnd, RectTransform trans)
{
_windowTrans = trans;
// General tab
var x = 0f;
var y = 10f;
var tab = wnd.AddTab(_windowTrans, "GalaxyGen");
MyCheckBox.CreateCheckBox(x, y, tab, MoreSettings.Enabled, "Enable more settings on UniverseGen");
x += 20f;
y += 26f;
MyWindow.AddText(x, y, tab, "* Requires game restart to take effect", 13);
x -= 20f;
y += 36f;
MyCheckBox.CreateCheckBox(x, y, tab, EpicDifficulty.Enabled, "Enable Epic difficulty");
y += 36f;
x += 10f;
MyWindow.AddText(x, y, tab, "Resource multiplier", 16);
x += 20f;
y += 26f;
var index = EpicDifficulty.ResourceMultiplierToIndex(EpicDifficulty.ResourceMultiplier.Value);
var sl = MySlider.CreateSlider(x, y, tab, index, 0f, (float)EpicDifficulty.ResourceMultipliersCount() - 1, "G", 240f);
sl.SetLabelText(EpicDifficulty.IndexToResourceMultiplier(Mathf.RoundToInt(sl.Value)).ToString(sl.labelFormat));
sl.OnValueChanged += () =>
{
var val = EpicDifficulty.IndexToResourceMultiplier(Mathf.RoundToInt(sl.Value));
EpicDifficulty.ResourceMultiplier.Value = val;
sl.SetLabelText(val.ToString(sl.labelFormat));
};
x -= 30f;
y += 31f;
x += 10f;
MyWindow.AddText(x, y, tab, "Oil multiplier (relative to Very Hard)", 16);
x += 20f;
y += 26f;
index = EpicDifficulty.OilMultiplierToIndex(EpicDifficulty.OilMultiplier.Value);
var sl2 = MySlider.CreateSlider(x, y, tab, index, 0f, (float)EpicDifficulty.OilMultipliersCount() - 1, "G", 240f);
sl2.SetLabelText(EpicDifficulty.IndexToOilMultiplier(Mathf.RoundToInt(sl2.Value)).ToString(sl2.labelFormat));
sl2.OnValueChanged += () =>
{
var val = EpicDifficulty.IndexToOilMultiplier(Mathf.RoundToInt(sl2.Value));
EpicDifficulty.OilMultiplier.Value = val;
sl2.SetLabelText(val.ToString(sl2.labelFormat));
};
x = 300f;
y = 10f;
MyCheckBox.CreateCheckBox(x, y, tab, BirthPlanetPatch.SitiVeinsOnBirthPlanet, "Silicon/Titanium on birth planet");
y += 36f;
MyCheckBox.CreateCheckBox(x, y, tab, BirthPlanetPatch.FireIceOnBirthPlanet, "Fire ice on birth planet");
y += 36f;
MyCheckBox.CreateCheckBox(x, y, tab, BirthPlanetPatch.KimberliteOnBirthPlanet, "Kimberlite on birth planet");
y += 36f;
MyCheckBox.CreateCheckBox(x, y, tab, BirthPlanetPatch.FractalOnBirthPlanet, "Fractal silicon on birth planet");
y += 36f;
MyCheckBox.CreateCheckBox(x, y, tab, BirthPlanetPatch.OrganicOnBirthPlanet, "Organic crystal on birth planet");
y += 36f;
MyCheckBox.CreateCheckBox(x, y, tab, BirthPlanetPatch.OpticalOnBirthPlanet, "Optical grating crystal on birth planet");
y += 36f;
MyCheckBox.CreateCheckBox(x, y, tab, BirthPlanetPatch.SpiniformOnBirthPlanet, "Spiniform stalagmite crystal on birth planet");
y += 36f;
MyCheckBox.CreateCheckBox(x, y, tab, BirthPlanetPatch.UnipolarOnBirthPlanet, "Unipolar magnet on birth planet");
y += 36f;
MyCheckBox.CreateCheckBox(x, y, tab, BirthPlanetPatch.FlatBirthPlanet, "Birth planet is solid flat (no water at all)");
y += 36f;
MyCheckBox.CreateCheckBox(x, y, tab, BirthPlanetPatch.HighLuminosityBirthStar, "Birth star has high luminosity");
}
}

View File

@@ -9,31 +9,53 @@ public class UniverseGenTweaks : BaseUnityPlugin
public new static readonly BepInEx.Logging.ManualLogSource Logger = public new static readonly BepInEx.Logging.ManualLogSource Logger =
BepInEx.Logging.Logger.CreateLogSource(PluginInfo.PLUGIN_NAME); BepInEx.Logging.Logger.CreateLogSource(PluginInfo.PLUGIN_NAME);
private bool _moreSettings = true;
private bool _epicDifficulty = true;
public static float OilMultiplier = 0.5f;
private void Awake() private void Awake()
{ {
_moreSettings = Config.Bind("MoreSettings", "Enabled", _moreSettings, "Enable more settings on Universe Generation").Value; MoreSettings.Enabled = Config.Bind("MoreSettings", "Enabled", true, "Enable more settings on Universe Generation");
MoreSettings.MaxStarCount = Config.Bind("MoreSettings", "MaxStarCount", 128, MoreSettings.MaxStarCount = Config.Bind("MoreSettings", "MaxStarCount", 128,
new ConfigDescription("(32 ~ 1024)\nMaximum star count for Universe Generation, enable MoreSettings.Enabled to take effect", new ConfigDescription("(32 ~ 1024)\nMaximum star count for Universe Generation, enable MoreSettings.Enabled to take effect",
new AcceptableValueRange<int>(32, 1024), new {})); new AcceptableValueRange<int>(32, 1024), new {}));
_epicDifficulty = Config.Bind("EpicDifficulty", "Enabled", _epicDifficulty, "Enable Epic difficulty").Value;
OilMultiplier = Config.Bind("EpicDifficulty", "OilMultiplier", OilMultiplier,
new ConfigDescription("Multiplier relative to the Very-Hard difficulty multiplier",
new AcceptableValueRange<float>(0.1f, 1f), new {}))
.Value;
I18N.Init(); EpicDifficulty.Enabled = Config.Bind("EpicDifficulty", "Enabled", true, "Enable Epic difficulty");
if (_moreSettings) EpicDifficulty.ResourceMultiplier = Config.Bind("EpicDifficulty", "ResourceMultiplier", 0.01f,
{ new ConfigDescription("Resource multiplier for Epic difficulty",
MoreSettings.Init(); new AcceptableValueRange<float>(0.0001f, 0.05f), new {}));
} EpicDifficulty.OilMultiplier = Config.Bind("EpicDifficulty", "OilMultiplier", 0.5f,
new ConfigDescription("Oil multiplier for Epic difficulty relative to the Very-Hard difficulty",
new AcceptableValueRange<float>(0.1f, 1f), new {}));
if (_epicDifficulty) BirthPlanetPatch.SitiVeinsOnBirthPlanet = Config.Bind("Birth", "SiTiVeinsOnBirthPlanet", false,
{ "Silicon/Titanium on birth planet");
EpicDifficulty.Init(); BirthPlanetPatch.FireIceOnBirthPlanet = Config.Bind("Birth", "FireIceOnBirthPlanet", false,
} "Fire ice on birth planet");
BirthPlanetPatch.KimberliteOnBirthPlanet = Config.Bind("Birth", "KimberliteOnBirthPlanet", false,
"Kimberlite on birth planet");
BirthPlanetPatch.FractalOnBirthPlanet = Config.Bind("Birth", "FractalOnBirthPlanet", false,
"Fractal silicon on birth planet");
BirthPlanetPatch.OrganicOnBirthPlanet = Config.Bind("Birth", "OrganicOnBirthPlanet", false,
"Organic crystal on birth planet");
BirthPlanetPatch.OpticalOnBirthPlanet = Config.Bind("Birth", "OpticalOnBirthPlanet", false,
"Optical grating crystal on birth planet");
BirthPlanetPatch.SpiniformOnBirthPlanet = Config.Bind("Birth", "SpiniformOnBirthPlanet", false,
"Spiniform stalagmite crystal on birth planet");
BirthPlanetPatch.UnipolarOnBirthPlanet = Config.Bind("Birth", "UnipolarOnBirthPlanet", false,
"Unipolar magnet on birth planet");
BirthPlanetPatch.FlatBirthPlanet = Config.Bind("Birth", "FlatBirthPlanet", false,
"Birth planet is solid flat (no water at all)");
BirthPlanetPatch.HighLuminosityBirthStar = Config.Bind("Birth", "HighLuminosityBirthStar", false,
"Birth star has high luminosity");
UIConfigWindow.Init();
MoreSettings.Init();
EpicDifficulty.Init();
BirthPlanetPatch.Init();
}
private void OnDestroy()
{
BirthPlanetPatch.Uninit();
EpicDifficulty.Uninit();
MoreSettings.Uninit();
} }
} }

View File

@@ -22,6 +22,10 @@
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" PrivateAssets="all" /> <PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" PrivateAssets="all" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<ProjectReference Include="..\UXAssist\UXAssist.csproj" />
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent"> <Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="del /F /Q package\$(ProjectName)-$(Version).zip&#xA;zip -9 -j package/$(ProjectName)-$(Version).zip $(TargetPath) package/icon.png package/manifest.json README.md" /> <Exec Command="del /F /Q package\$(ProjectName)-$(Version).zip&#xA;zip -9 -j package/$(ProjectName)-$(Version).zip $(TargetPath) package/icon.png package/manifest.json README.md" />
</Target> </Target>