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

MechaDronesTweaks: release v1.1.0

This commit is contained in:
2023-07-04 16:18:00 +08:00
parent c9b39e5886
commit 01ffd11ab2
4 changed files with 302 additions and 193 deletions

View File

@@ -58,6 +58,17 @@ public class MechaDronesTweaksPlugin : BaseUnityPlugin
MechaDronesTweaks.EnergyMultiplier, MechaDronesTweaks.EnergyMultiplier,
new ConfigDescription("Energy consumption multiplier for mecha drones", new ConfigDescription("Energy consumption multiplier for mecha drones",
new AcceptableValueRange<float>(0f, 1f))).Value; new AcceptableValueRange<float>(0f, 1f))).Value;
MechaDronesTweaks.removeBuildRangeLimit = Config.Bind("MechaBuild", "RemoveBuildRangeLimit",
MechaDronesTweaks.removeBuildRangeLimit,
"Remove limit for build range and maximum count of drag building belts/buildings\nNote: this does not affect range limit for mecha drones' action")
.Value;
MechaDronesTweaks.largerAreaForUpgradeAndDismantle = Config.Bind("MechaBuild",
"LargerAreaForUpgradeAndDismantle", MechaDronesTweaks.largerAreaForUpgradeAndDismantle,
"Increase maximum area size for upgrade and dismantle to 31x31 (from 11x11)").Value;
MechaDronesTweaks.largerAreaForTerraform = Config.Bind("MechaBuild", "LargerAreaForTerraform",
MechaDronesTweaks.largerAreaForTerraform,
"Increase maximum area size for terraform to 30x30 (from 10x10)\nNote: this may impact game performance while using large area")
.Value;
_harmony.PatchAll(typeof(MechaDronesTweaks)); _harmony.PatchAll(typeof(MechaDronesTweaks));
} }
@@ -71,6 +82,9 @@ public static class MechaDronesTweaks
public static float FixedSpeed = 300f; public static float FixedSpeed = 300f;
public static float SpeedMultiplier = 4f; public static float SpeedMultiplier = 4f;
public static float EnergyMultiplier = 0.1f; public static float EnergyMultiplier = 0.1f;
public static bool removeBuildRangeLimit = true;
public static bool largerAreaForUpgradeAndDismantle = true;
public static bool largerAreaForTerraform = true;
[HarmonyTranspiler, HarmonyPatch(typeof(UITechTree), "RefreshDataValueText")] [HarmonyTranspiler, HarmonyPatch(typeof(UITechTree), "RefreshDataValueText")]
private static IEnumerable<CodeInstruction> UITechTreeRefreshDataValueText_Transpiler( private static IEnumerable<CodeInstruction> UITechTreeRefreshDataValueText_Transpiler(
@@ -156,6 +170,15 @@ public static class MechaDronesTweaks
[HarmonyTranspiler, HarmonyPatch(typeof(MechaDrone), "Update")] [HarmonyTranspiler, HarmonyPatch(typeof(MechaDrone), "Update")]
private static IEnumerable<CodeInstruction> MechaDroneUpdate_Transpiler(IEnumerable<CodeInstruction> instructions) private static IEnumerable<CodeInstruction> MechaDroneUpdate_Transpiler(IEnumerable<CodeInstruction> instructions)
{
if (!UseFixedSpeed && Math.Abs(SpeedMultiplier - 1.0f) < 0.01f)
{
foreach (var instr in instructions)
{
yield return instr;
}
}
else
{ {
var ilist = instructions.ToList(); var ilist = instructions.ToList();
for (var i = 0; i < ilist.Count; i++) for (var i = 0; i < ilist.Count; i++)
@@ -245,12 +268,22 @@ public static class MechaDronesTweaks
yield return instr; yield return instr;
} }
} }
}
[HarmonyTranspiler] [HarmonyTranspiler]
[HarmonyPatch(typeof(BuildTool_Dismantle), nameof(BuildTool_Dismantle.DeterminePreviews))] [HarmonyPatch(typeof(BuildTool_Dismantle), nameof(BuildTool_Dismantle.DeterminePreviews))]
[HarmonyPatch(typeof(BuildTool_Upgrade), nameof(BuildTool_Upgrade.DeterminePreviews))] [HarmonyPatch(typeof(BuildTool_Upgrade), nameof(BuildTool_Upgrade.DeterminePreviews))]
private static IEnumerable<CodeInstruction> BuildTools_CursorSizePatch_Transpiler( private static IEnumerable<CodeInstruction> BuildTools_CursorSizePatch_Transpiler(
IEnumerable<CodeInstruction> instructions) IEnumerable<CodeInstruction> instructions)
{
if (!largerAreaForUpgradeAndDismantle)
{
foreach (var instr in instructions)
{
yield return instr;
}
}
else
{ {
foreach (var instr in instructions) foreach (var instr in instructions)
{ {
@@ -264,10 +297,20 @@ public static class MechaDronesTweaks
} }
} }
} }
}
[HarmonyTranspiler, HarmonyPatch(typeof(BuildTool_Reform), nameof(BuildTool_Reform.ReformAction))] [HarmonyTranspiler, HarmonyPatch(typeof(BuildTool_Reform), nameof(BuildTool_Reform.ReformAction))]
private static IEnumerable<CodeInstruction> BuildTool_Reform_ReformAction_Transpiler( private static IEnumerable<CodeInstruction> BuildTool_Reform_ReformAction_Transpiler(
IEnumerable<CodeInstruction> instructions) IEnumerable<CodeInstruction> instructions)
{
if (!largerAreaForTerraform)
{
foreach (var instr in instructions)
{
yield return instr;
}
}
else
{ {
var ilist = instructions.ToList(); var ilist = instructions.ToList();
for (var i = 0; i < ilist.Count; i++) for (var i = 0; i < ilist.Count; i++)
@@ -289,11 +332,20 @@ public static class MechaDronesTweaks
} }
} }
} }
}
[HarmonyTranspiler, HarmonyPatch(typeof(ConnGizmoGraph), MethodType.Constructor)] [HarmonyTranspiler, HarmonyPatch(typeof(ConnGizmoGraph), MethodType.Constructor)]
private static IEnumerable<CodeInstruction> ConnGizmoGraph_Constructor_Transpiler( private static IEnumerable<CodeInstruction> ConnGizmoGraph_Constructor_Transpiler(
IEnumerable<CodeInstruction> instructions) IEnumerable<CodeInstruction> instructions)
{
if (!removeBuildRangeLimit)
{
foreach (var instr in instructions)
{
yield return instr;
}
}
else
{ {
foreach (var instr in instructions) foreach (var instr in instructions)
{ {
@@ -307,10 +359,20 @@ public static class MechaDronesTweaks
} }
} }
} }
}
[HarmonyTranspiler, HarmonyPatch(typeof(ConnGizmoGraph), nameof(ConnGizmoGraph.SetPointCount))] [HarmonyTranspiler, HarmonyPatch(typeof(ConnGizmoGraph), nameof(ConnGizmoGraph.SetPointCount))]
private static IEnumerable<CodeInstruction> ConnGizmoGraph_SetPointCount_Transpiler( private static IEnumerable<CodeInstruction> ConnGizmoGraph_SetPointCount_Transpiler(
IEnumerable<CodeInstruction> instructions) IEnumerable<CodeInstruction> instructions)
{
if (!removeBuildRangeLimit)
{
foreach (var instr in instructions)
{
yield return instr;
}
}
else
{ {
foreach (var instr in instructions) foreach (var instr in instructions)
{ {
@@ -324,10 +386,20 @@ public static class MechaDronesTweaks
} }
} }
} }
}
[HarmonyTranspiler, HarmonyPatch(typeof(BuildTool_Path), nameof(BuildTool_Path._OnInit))] [HarmonyTranspiler, HarmonyPatch(typeof(BuildTool_Path), nameof(BuildTool_Path._OnInit))]
private static IEnumerable<CodeInstruction> BuildTool_Path__OnInit_Transpiler( private static IEnumerable<CodeInstruction> BuildTool_Path__OnInit_Transpiler(
IEnumerable<CodeInstruction> instructions) IEnumerable<CodeInstruction> instructions)
{
if (!removeBuildRangeLimit)
{
foreach (var instr in instructions)
{
yield return instr;
}
}
else
{ {
foreach (var instr in instructions) foreach (var instr in instructions)
{ {
@@ -339,10 +411,20 @@ public static class MechaDronesTweaks
yield return instr; yield return instr;
} }
} }
}
[HarmonyTranspiler, HarmonyPatch(typeof(BuildTool_Click), nameof(BuildTool_Click._OnInit))] [HarmonyTranspiler, HarmonyPatch(typeof(BuildTool_Click), nameof(BuildTool_Click._OnInit))]
private static IEnumerable<CodeInstruction> BuildTool_Click__OnInit_Transpiler( private static IEnumerable<CodeInstruction> BuildTool_Click__OnInit_Transpiler(
IEnumerable<CodeInstruction> instructions) IEnumerable<CodeInstruction> instructions)
{
if (!removeBuildRangeLimit)
{
foreach (var instr in instructions)
{
yield return instr;
}
}
else
{ {
foreach (var instr in instructions) foreach (var instr in instructions)
{ {
@@ -356,6 +438,7 @@ public static class MechaDronesTweaks
} }
} }
} }
}
[HarmonyTranspiler] [HarmonyTranspiler]
[HarmonyPatch(typeof(BuildTool_Addon), nameof(BuildTool_Addon.CheckBuildConditions))] [HarmonyPatch(typeof(BuildTool_Addon), nameof(BuildTool_Addon.CheckBuildConditions))]
@@ -367,8 +450,17 @@ public static class MechaDronesTweaks
[HarmonyPatch(typeof(BuildTool_Reform), nameof(BuildTool_Reform.ReformAction))] [HarmonyPatch(typeof(BuildTool_Reform), nameof(BuildTool_Reform.ReformAction))]
[HarmonyPatch(typeof(BuildTool_Upgrade), nameof(BuildTool_Upgrade.DetermineMoreChainTargets))] [HarmonyPatch(typeof(BuildTool_Upgrade), nameof(BuildTool_Upgrade.DetermineMoreChainTargets))]
[HarmonyPatch(typeof(BuildTool_Upgrade), nameof(BuildTool_Upgrade.DeterminePreviews))] [HarmonyPatch(typeof(BuildTool_Upgrade), nameof(BuildTool_Upgrade.DeterminePreviews))]
private static IEnumerable<CodeInstruction> BuildAreaElimination_Transpiler( private static IEnumerable<CodeInstruction> BuildAreaLimitRemoval_Transpiler(
IEnumerable<CodeInstruction> instructions) IEnumerable<CodeInstruction> instructions)
{
if (!removeBuildRangeLimit)
{
foreach (var instr in instructions)
{
yield return instr;
}
}
else
{ {
/* Patch (player.mecha.buildArea * player.mecha.buildArea) to 100000000 */ /* Patch (player.mecha.buildArea * player.mecha.buildArea) to 100000000 */
var ilist = instructions.ToList(); var ilist = instructions.ToList();
@@ -394,7 +486,8 @@ public static class MechaDronesTweaks
} }
instr = ilist[i + 3]; instr = ilist[i + 3];
if (instr.opcode != OpCodes.Ldfld || !instr.OperandIs(AccessTools.Field(typeof(Mecha), "buildArea"))) if (instr.opcode != OpCodes.Ldfld ||
!instr.OperandIs(AccessTools.Field(typeof(Mecha), "buildArea")))
{ {
break; break;
} }
@@ -414,7 +507,8 @@ public static class MechaDronesTweaks
} }
instr = ilist[i + 7]; instr = ilist[i + 7];
if (instr.opcode != OpCodes.Ldfld || !instr.OperandIs(AccessTools.Field(typeof(Mecha), "buildArea"))) if (instr.opcode != OpCodes.Ldfld ||
!instr.OperandIs(AccessTools.Field(typeof(Mecha), "buildArea")))
{ {
break; break;
} }
@@ -446,3 +540,4 @@ public static class MechaDronesTweaks
} }
} }
} }
}

View File

@@ -5,7 +5,7 @@
<AssemblyName>MechaDronesTweaks</AssemblyName> <AssemblyName>MechaDronesTweaks</AssemblyName>
<BepInExPluginGuid>org.soardev.mechadronestweaks</BepInExPluginGuid> <BepInExPluginGuid>org.soardev.mechadronestweaks</BepInExPluginGuid>
<Description>DSP MOD - MechaDronesTweaks</Description> <Description>DSP MOD - MechaDronesTweaks</Description>
<Version>1.0.0</Version> <Version>1.1.0</Version>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>latest</LangVersion> <LangVersion>latest</LangVersion>
</PropertyGroup> </PropertyGroup>

View File

@@ -9,6 +9,7 @@
* All values are patched in memory but written to game-saves so that you can play with normal mecha drone parameters while disabling this MOD. * All values are patched in memory but written to game-saves so that you can play with normal mecha drone parameters while disabling this MOD.
* You can take benefit from this MOD on any game-saves after enabling this MOD. * You can take benefit from this MOD on any game-saves after enabling this MOD.
* Config entries: * Config entries:
* `[MechaDrones]`
* `UseFixedSpeed` [Default Value: false]: * `UseFixedSpeed` [Default Value: false]:
* If enabled: Use `FixedSpeed` for mecha drones, which makes related Upgrades not used any more. * If enabled: Use `FixedSpeed` for mecha drones, which makes related Upgrades not used any more.
* If disabled: Use `SpeedMultiplier` for mecha drones. * If disabled: Use `SpeedMultiplier` for mecha drones.
@@ -17,6 +18,12 @@
* `FixedSpeed` [Default Value: 300]: Fixed flying speed for mecha drones. * `FixedSpeed` [Default Value: 300]: Fixed flying speed for mecha drones.
* `SpeedMultiplier` [Default Value: 4]: Speed multiplier for mecha drones. * `SpeedMultiplier` [Default Value: 4]: Speed multiplier for mecha drones.
* `EnergyMultiplier` [Default Value: 0.1]: Energy consumption multiplier for mecha drones. * `EnergyMultiplier` [Default Value: 0.1]: Energy consumption multiplier for mecha drones.
* `[MechaBuild]`
* `RemoveBuildRangeLimit` [Default Value: true]: Remove limit for build range and maximum count of drag building belts/buildings.
* Note: this does not affect range limit for mecha drones' action
* `LargerAreaForUpgradeAndDismantle` [Default Value: true]: Increase maximum area size for upgrade and dismantle to 31x31 (from 11x11).
* `LargerAreaForTerraform` [Default Value: true]: Increase maximum area size for terraform to 30x30 (from 10x10).
* Note: this may impact game performance while using large area.
* Note: This MOD will disable `FastDrones` if the MOD is installed, to avoid conflict in functions. * Note: This MOD will disable `FastDrones` if the MOD is installed, to avoid conflict in functions.
## 使用说明 ## 使用说明
@@ -25,6 +32,7 @@
* 所有修改参数都在内存中Patch不会写入存档禁用此MOD后可恢复正常建设机参数。 * 所有修改参数都在内存中Patch不会写入存档禁用此MOD后可恢复正常建设机参数。
* 启用本MOD后可以在已经游玩的游戏存档上享受参数的改动。 * 启用本MOD后可以在已经游玩的游戏存档上享受参数的改动。
* 设置选项: * 设置选项:
* `[MechaDrones]`
* `UseFixedSpeed` [默认值: false]: * `UseFixedSpeed` [默认值: false]:
* 启用: 使用 `FixedSpeed`,固定速度,这将覆盖对应机甲建设机速度的升级数值。 * 启用: 使用 `FixedSpeed`,固定速度,这将覆盖对应机甲建设机速度的升级数值。
* 禁用: 使用 `SpeedMultiplier` * 禁用: 使用 `SpeedMultiplier`
@@ -33,4 +41,10 @@
* `FixedSpeed` [默认值: 300]: 固定速度。 * `FixedSpeed` [默认值: 300]: 固定速度。
* `SpeedMultiplier` [默认值: 4]: 速度倍数。 * `SpeedMultiplier` [默认值: 4]: 速度倍数。
* `EnergyMultiplier` [默认值: 0.1]: 能量消耗倍数。 * `EnergyMultiplier` [默认值: 0.1]: 能量消耗倍数。
* `[MechaBuild]`
* `RemoveBuildRangeLimit` [默认值: true]: 解除摆放建筑距离和拖放建筑/传送带数量的限制。
* 注意: 并不会解除建设机行动的距离限制。
* `LargerAreaForUpgradeAndDismantle` [默认值: true]: 提升区域升级和拆除建筑的最大区域至31x31 (之前是11x11)。
* `LargerAreaForTerraform` [默认值: true]: 提升区域铺设地地基的最大区域至30x30 (之前是10x10)。
* 注意: 使用较大的区域可能对游戏实时性能有影响。
* 说明: 如果安装了`FastDrones`本MOD会将其禁用避免功能冲突。 * 说明: 如果安装了`FastDrones`本MOD会将其禁用避免功能冲突。

View File

@@ -1,8 +1,8 @@
{ {
"name": "MechaDronesTweaks", "name": "MechaDronesTweaks",
"version_number": "1.0.0", "version_number": "1.1.0",
"website_url": "https://github.com/soarqin/DSP_Mods/tree/master/MechaDronesTweaks", "website_url": "https://github.com/soarqin/DSP_Mods/tree/master/MechaDronesTweaks",
"description": "Some tweaks for mecha drones(Successor to FastDrones MOD) / 机甲建设机调整(FastDrones MOD的后继者)", "description": "Some tweaks for mecha drones and build functions(Successor to FastDrones MOD) / 机甲建设机和建设功能调整(FastDrones MOD的后继者)",
"dependencies": [ "dependencies": [
"xiaoye97-BepInEx-5.4.17" "xiaoye97-BepInEx-5.4.17"
] ]