mirror of
https://github.com/soarqin/DSP_Mods.git
synced 2026-02-04 18:22:18 +08:00
WIP
This commit is contained in:
@@ -32,7 +32,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;
|
private static Harmony _patch, _permanentPatch;
|
||||||
|
|
||||||
private static double _gameMinDist = 2;
|
private static double _gameMinDist = 2;
|
||||||
private static double _gameMinStep = 2;
|
private static double _gameMinStep = 2;
|
||||||
@@ -46,6 +46,9 @@ public class MoreSettings
|
|||||||
I18N.Add("步进最大距离", "Step Distance Max", "步进最大距离");
|
I18N.Add("步进最大距离", "Step Distance Max", "步进最大距离");
|
||||||
I18N.Add("扁平度", "Flatness", "扁平度");
|
I18N.Add("扁平度", "Flatness", "扁平度");
|
||||||
I18N.Apply();
|
I18N.Apply();
|
||||||
|
|
||||||
|
_permanentPatch ??= Harmony.CreateAndPatchAll(typeof(PermanentPatch));
|
||||||
|
|
||||||
Enabled.SettingChanged += (_, _) => Enable(Enabled.Value);
|
Enabled.SettingChanged += (_, _) => Enable(Enabled.Value);
|
||||||
Enable(Enabled.Value);
|
Enable(Enabled.Value);
|
||||||
}
|
}
|
||||||
@@ -53,17 +56,20 @@ public class MoreSettings
|
|||||||
public static void Uninit()
|
public static void Uninit()
|
||||||
{
|
{
|
||||||
Enable(false);
|
Enable(false);
|
||||||
|
|
||||||
|
_permanentPatch?.UnpatchSelf();
|
||||||
|
_permanentPatch = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void Enable(bool on)
|
private static void Enable(bool on)
|
||||||
{
|
{
|
||||||
if (on)
|
if (on)
|
||||||
{
|
{
|
||||||
_harmony ??= Harmony.CreateAndPatchAll(typeof(MoreSettings));
|
_patch ??= Harmony.CreateAndPatchAll(typeof(MoreSettings));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_harmony?.UnpatchSelf();
|
_patch?.UnpatchSelf();
|
||||||
_harmony = null;
|
_patch = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void CreateSliderWithText(Slider orig, out Text title, out Slider slider, out Text text, out Localizer loc)
|
private static void CreateSliderWithText(Slider orig, out Text title, out Slider slider, out Text text, out Localizer loc)
|
||||||
@@ -218,22 +224,41 @@ public class MoreSettings
|
|||||||
return matcher.InstructionEnumeration();
|
return matcher.InstructionEnumeration();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static class PermanentPatch
|
||||||
|
{
|
||||||
|
private static void ResetSettings()
|
||||||
|
{
|
||||||
|
_gameMinDist = 2;
|
||||||
|
_gameMinStep = 2;
|
||||||
|
_gameMaxStep = 3.2;
|
||||||
|
_gameFlatten = 0.18;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HarmonyPrefix]
|
||||||
|
[HarmonyPatch(typeof(GameData), nameof(GameData.Import))]
|
||||||
|
private static void GameData_Import_Prefix(GameData __instance)
|
||||||
|
{
|
||||||
|
ResetSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HarmonyPrefix]
|
||||||
|
[HarmonyPatch(typeof(GameData), nameof(GameData.SetForNewGame))]
|
||||||
|
private static void GameData_SetForNewGame_Prefix(GameData __instance)
|
||||||
|
{
|
||||||
|
if (Enabled.Value) return;
|
||||||
|
ResetSettings();
|
||||||
|
}
|
||||||
|
|
||||||
[HarmonyTranspiler]
|
[HarmonyTranspiler]
|
||||||
[HarmonyPatch(typeof(GalaxyData), MethodType.Constructor)]
|
[HarmonyPatch(typeof(GalaxyData), MethodType.Constructor)]
|
||||||
private static IEnumerable<CodeInstruction> GalaxyData_Constructor_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
private static IEnumerable<CodeInstruction> GalaxyData_Constructor_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||||
{
|
{
|
||||||
// 25700 -> (MaxStarCount.Value + 1) * 100
|
// 25700 -> 102500
|
||||||
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(25700))
|
new CodeMatch(ci => ci.opcode == OpCodes.Ldc_I4 && ci.OperandIs(25700))
|
||||||
);
|
);
|
||||||
matcher.Repeat(m => m.SetAndAdvance(OpCodes.Ldsfld, AccessTools.Field(typeof(MoreSettings), nameof(MoreSettings.MaxStarCount))).Insert(
|
matcher.Repeat(m => m.SetAndAdvance(OpCodes.Ldc_I4, 102500));
|
||||||
new CodeInstruction(OpCodes.Call, AccessTools.PropertyGetter(typeof(ConfigEntry<int>), nameof(ConfigEntry<int>.Value))),
|
|
||||||
new CodeInstruction(OpCodes.Ldc_I4_1),
|
|
||||||
new CodeInstruction(OpCodes.Add),
|
|
||||||
new CodeInstruction(OpCodes.Ldc_I4_S, 100),
|
|
||||||
new CodeInstruction(OpCodes.Mul)
|
|
||||||
));
|
|
||||||
return matcher.InstructionEnumeration();
|
return matcher.InstructionEnumeration();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -242,18 +267,12 @@ public class MoreSettings
|
|||||||
[HarmonyPatch(typeof(SpaceColliderLogic), nameof(SpaceColliderLogic.UpdateCollidersPose))]
|
[HarmonyPatch(typeof(SpaceColliderLogic), nameof(SpaceColliderLogic.UpdateCollidersPose))]
|
||||||
private static IEnumerable<CodeInstruction> SectorModel_CreateGalaxyAstroBuffer_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
private static IEnumerable<CodeInstruction> SectorModel_CreateGalaxyAstroBuffer_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||||
{
|
{
|
||||||
// 25600 -> (MaxStarCount.Value + 1) * 100
|
// 25600 -> 102500
|
||||||
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))
|
||||||
);
|
);
|
||||||
matcher.Repeat(m => m.SetAndAdvance(OpCodes.Ldsfld, AccessTools.Field(typeof(MoreSettings), nameof(MoreSettings.MaxStarCount))).Insert(
|
matcher.Repeat(m => m.SetAndAdvance(OpCodes.Ldc_I4, 102500));
|
||||||
new CodeInstruction(OpCodes.Call, AccessTools.PropertyGetter(typeof(ConfigEntry<int>), nameof(ConfigEntry<int>.Value))),
|
|
||||||
new CodeInstruction(OpCodes.Ldc_I4_1),
|
|
||||||
new CodeInstruction(OpCodes.Add),
|
|
||||||
new CodeInstruction(OpCodes.Ldc_I4_S, 100),
|
|
||||||
new CodeInstruction(OpCodes.Mul)
|
|
||||||
));
|
|
||||||
return matcher.InstructionEnumeration();
|
return matcher.InstructionEnumeration();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -287,6 +306,7 @@ public class MoreSettings
|
|||||||
matcher.Repeat(m => m.Advance(1).SetInstructionAndAdvance(new CodeInstruction(OpCodes.Ldarg_3)));
|
matcher.Repeat(m => m.Advance(1).SetInstructionAndAdvance(new CodeInstruction(OpCodes.Ldarg_3)));
|
||||||
return matcher.InstructionEnumeration();
|
return matcher.InstructionEnumeration();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[HarmonyPrefix]
|
[HarmonyPrefix]
|
||||||
[HarmonyPatch(typeof(UIGalaxySelect), nameof(UIGalaxySelect.EnterGame))]
|
[HarmonyPatch(typeof(UIGalaxySelect), nameof(UIGalaxySelect.EnterGame))]
|
||||||
@@ -665,6 +685,110 @@ public class MoreSettings
|
|||||||
__instance.propertyMultiplierText.text = "元数据生成倍率".Translate() + " " + gameDesc.propertyMultiplier.ToString("0%");
|
__instance.propertyMultiplierText.text = "元数据生成倍率".Translate() + " " + gameDesc.propertyMultiplier.ToString("0%");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HarmonyPrefix]
|
||||||
|
[HarmonyPatch(typeof(CombatSettings),nameof(CombatSettings.difficulty), MethodType.Getter)]
|
||||||
|
private static bool CombatSettings_difficulty_Getter_Prefix(CombatSettings __instance, ref float __result)
|
||||||
|
{
|
||||||
|
var aggressivenessScore = __instance.aggressiveness switch
|
||||||
|
{
|
||||||
|
< -0.1f => -0.2f,
|
||||||
|
< 0.25f => 0f,
|
||||||
|
< 0.75f => 0.5f,
|
||||||
|
< 1.5f => 0.75f,
|
||||||
|
< 2.5f => 0.875f,
|
||||||
|
_ => 1.125f
|
||||||
|
};
|
||||||
|
var initialLevelScore = __instance.initialLevel * 0.8f;
|
||||||
|
var initialGrowthScore = __instance.initialGrowth switch
|
||||||
|
{
|
||||||
|
< 0.15f => 0f,
|
||||||
|
< 0.3f => 0.25f,
|
||||||
|
< 0.65f => 0.5f,
|
||||||
|
< 0.8f => 0.75f,
|
||||||
|
< 1.15f => 1f,
|
||||||
|
< 1.65f => 1.25f,
|
||||||
|
< 2.15f => 1.5f,
|
||||||
|
< 2.65f => 1.75f,
|
||||||
|
< 3.15f => 2f,
|
||||||
|
< 3.65f => 2.25f,
|
||||||
|
_ => 2.5f
|
||||||
|
};
|
||||||
|
var initialColonizeScore = __instance.initialColonize switch
|
||||||
|
{
|
||||||
|
< 0.15f => 0f,
|
||||||
|
< 0.3f => 0.25f,
|
||||||
|
< 0.65f => 0.5f,
|
||||||
|
< 0.8f => 0.75f,
|
||||||
|
< 1.15f => 1f,
|
||||||
|
< 1.65f => 1.25f,
|
||||||
|
< 2.15f => 1.5f,
|
||||||
|
< 2.65f => 1.75f,
|
||||||
|
< 3.15f => 2f,
|
||||||
|
< 3.65f => 2.25f,
|
||||||
|
_ => 2.5f
|
||||||
|
};
|
||||||
|
var maxDensityScore = __instance.maxDensity - 1f;
|
||||||
|
var growthSpeedFactorScore = __instance.growthSpeedFactor switch
|
||||||
|
{
|
||||||
|
< 0.35f => 0.3f,
|
||||||
|
< 0.75f => 0.7f,
|
||||||
|
< 1.5f => 1f,
|
||||||
|
< 2.5f => 1.2f,
|
||||||
|
< 3.5f => 1.5f,
|
||||||
|
< 4.5f => 1.6f,
|
||||||
|
< 5.5f => 1.8f,
|
||||||
|
_ => 2f
|
||||||
|
};
|
||||||
|
var powerThreatFactorScore = __instance.powerThreatFactor switch
|
||||||
|
{
|
||||||
|
< 0.05f => 0.125f,
|
||||||
|
< 0.15f => 0.3f,
|
||||||
|
< 0.25f => 0.6f,
|
||||||
|
< 0.55f => 0.8f,
|
||||||
|
< 1.15f => 1f,
|
||||||
|
< 2.15f => 1.2f,
|
||||||
|
< 5.15f => 1.5f,
|
||||||
|
< 8.15f => 1.8f,
|
||||||
|
< 10.15f => 2f,
|
||||||
|
< 15.15f => 2.5f,
|
||||||
|
_ => 3f
|
||||||
|
};
|
||||||
|
var battleThreatFactorScore = __instance.battleThreatFactor switch
|
||||||
|
{
|
||||||
|
< 0.05f => 0.125f,
|
||||||
|
< 0.15f => 0.3f,
|
||||||
|
< 0.25f => 0.6f,
|
||||||
|
< 0.55f => 0.8f,
|
||||||
|
< 1.15f => 1f,
|
||||||
|
< 2.15f => 1.2f,
|
||||||
|
< 5.15f => 1.5f,
|
||||||
|
< 8.15f => 1.8f,
|
||||||
|
< 10.15f => 2f,
|
||||||
|
< 15.15f => 2.5f,
|
||||||
|
_ => 3f
|
||||||
|
};
|
||||||
|
var battleExpFactorScore = __instance.battleExpFactor switch
|
||||||
|
{
|
||||||
|
< 0.05f => 0f,
|
||||||
|
< 0.15f => 1f,
|
||||||
|
< 0.25f => 3f,
|
||||||
|
< 0.55f => 6f,
|
||||||
|
< 1.15f => 10f,
|
||||||
|
< 2.15f => 12f,
|
||||||
|
< 5.15f => 14f,
|
||||||
|
< 8.15f => 16f,
|
||||||
|
< 10.15f => 18f,
|
||||||
|
< 15.15f => 19f,
|
||||||
|
_ => 20f
|
||||||
|
};
|
||||||
|
var score1 = aggressivenessScore < 0f ? 0f : 0.25f + aggressivenessScore * (powerThreatFactorScore * 0.5f + battleThreatFactorScore * 0.5f);
|
||||||
|
var score2 = 0.375f + 0.625f * ((initialLevelScore + battleExpFactorScore) / 10f);
|
||||||
|
var score3 = 0.375f + 0.625f * ((initialColonizeScore * 0.6f + initialGrowthScore * 0.4f * (initialColonizeScore * 0.75f + 0.25f)) * 0.6f + growthSpeedFactorScore * 0.4f * (initialColonizeScore * 0.8f + 0.2f) + maxDensityScore * 0.29f * (initialColonizeScore * 0.5f + 0.5f));
|
||||||
|
__result = (int)(score1 * score2 * score3 * 10000f + 0.5f) / 10000f;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region ModSave
|
#region ModSave
|
||||||
|
|||||||
@@ -4,6 +4,9 @@
|
|||||||
#### 宇宙生成参数调节
|
#### 宇宙生成参数调节
|
||||||
|
|
||||||
## Changelog
|
## Changelog
|
||||||
|
* 1.2.6
|
||||||
|
+ Fix possible crash or wrong stars data when loading save file with changed generation settings but with `Enable more settings on UniverseGen` disabled on config window.
|
||||||
|
+ Larger maximum value in combat settings (except `Aggressiveness` and `Max Density`).
|
||||||
* 1.2.5
|
* 1.2.5
|
||||||
+ Thanks to [kremnev8](https://github.com/kremnev8)'s work on new version of [DSPModSave](https://dsp.thunderstore.io/package/CommonAPI/DSPModSave/), universe generation options are stored in save file now.
|
+ Thanks to [kremnev8](https://github.com/kremnev8)'s work on new version of [DSPModSave](https://dsp.thunderstore.io/package/CommonAPI/DSPModSave/), universe generation options are stored in save file now.
|
||||||
+ Fix text display issue on new game screen
|
+ Fix text display issue on new game screen
|
||||||
@@ -32,6 +35,7 @@
|
|||||||
* More options on universe generation
|
* More options on universe generation
|
||||||
+ Can set maximum star count(128 by default, up to 1024) in config file.
|
+ Can set maximum star count(128 by default, up to 1024) in config file.
|
||||||
- Note: there is performance issue on galaxy view with large amount of stars.
|
- Note: there is performance issue on galaxy view with large amount of stars.
|
||||||
|
+ Larger maximum value in combat settings (except `Aggressiveness` and `Max Density`).
|
||||||
* Epic difficulty
|
* 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
|
||||||
@@ -41,6 +45,9 @@
|
|||||||
* High luminosity for birth star
|
* High luminosity for birth star
|
||||||
|
|
||||||
## 更新日志
|
## 更新日志
|
||||||
|
* 1.2.6
|
||||||
|
+ 修复了在存档中更改了生成参数但是在配置面板中禁用了`启用更多宇宙生成设置`时可能崩溃或者星系数据错误的问题
|
||||||
|
+ 在星系生成时的战斗设置面板上提升了各选项的最大值(`黑雾攻击性`和`最大黑雾密度`除外`)
|
||||||
* 1.2.5
|
* 1.2.5
|
||||||
+ 感谢[kremnev8](https://github.com/kremnev8)对[DSPModSave](https://dsp.thunderstore.io/package/CommonAPI/DSPModSave/)的更新,现在宇宙生成选项会被保存到存档中
|
+ 感谢[kremnev8](https://github.com/kremnev8)对[DSPModSave](https://dsp.thunderstore.io/package/CommonAPI/DSPModSave/)的更新,现在宇宙生成选项会被保存到存档中
|
||||||
+ 修复新建游戏界面文本显示问题
|
+ 修复新建游戏界面文本显示问题
|
||||||
@@ -69,6 +76,7 @@
|
|||||||
* 生成宇宙时提供更多选项
|
* 生成宇宙时提供更多选项
|
||||||
+可以在配置文件中设置最大恒星数(默认128, 最多1024)
|
+可以在配置文件中设置最大恒星数(默认128, 最多1024)
|
||||||
- 注意: 大量恒星会导致宇宙视图出现性能问题
|
- 注意: 大量恒星会导致宇宙视图出现性能问题
|
||||||
|
+ 在星系生成时的战斗设置面板上提升了各选项的最大值(`黑雾攻击性`和`最大黑雾密度`除外`)
|
||||||
* 史诗难度
|
* 史诗难度
|
||||||
* 资源0.01倍,油井储量0.25倍(极难是0.5倍)
|
* 资源0.01倍,油井储量0.25倍(极难是0.5倍)
|
||||||
* 采油速度和极难相同
|
* 采油速度和极难相同
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<AssemblyName>UniverseGenTweaks</AssemblyName>
|
<AssemblyName>UniverseGenTweaks</AssemblyName>
|
||||||
<BepInExPluginGuid>org.soardev.universegentweaks</BepInExPluginGuid>
|
<BepInExPluginGuid>org.soardev.universegentweaks</BepInExPluginGuid>
|
||||||
<Description>DSP MOD - UniverseGenTweaks</Description>
|
<Description>DSP MOD - UniverseGenTweaks</Description>
|
||||||
<Version>1.2.5</Version>
|
<Version>1.2.6</Version>
|
||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
<LangVersion>latest</LangVersion>
|
<LangVersion>latest</LangVersion>
|
||||||
<RestoreAdditionalProjectSources>https://nuget.bepinex.dev/v3/index.json</RestoreAdditionalProjectSources>
|
<RestoreAdditionalProjectSources>https://nuget.bepinex.dev/v3/index.json</RestoreAdditionalProjectSources>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "UniverseGenTweaks",
|
"name": "UniverseGenTweaks",
|
||||||
"version_number": "1.2.5",
|
"version_number": "1.2.6",
|
||||||
"website_url": "https://github.com/soarqin/DSP_Mods/tree/master/UniverseGenTweaks",
|
"website_url": "https://github.com/soarqin/DSP_Mods/tree/master/UniverseGenTweaks",
|
||||||
"description": "Universe Generation Tweaks / 宇宙生成参数调节",
|
"description": "Universe Generation Tweaks / 宇宙生成参数调节",
|
||||||
"dependencies": [
|
"dependencies": [
|
||||||
|
|||||||
Reference in New Issue
Block a user