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

temp fix for GalacticScale

This commit is contained in:
2023-02-15 21:45:04 +08:00
parent 698a9e3747
commit d7015e5459
2 changed files with 48 additions and 8 deletions

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Reflection.Emit;
using BepInEx;
using BepInEx.Configuration;
@@ -73,6 +74,20 @@ public class Patch : BaseUnityPlugin
Harmony.CreateAndPatchAll(typeof(BeltFix));
}
[HarmonyTranspiler, HarmonyPatch(typeof(BuildTool_Path), "CheckBuildConditions")]
private static IEnumerable<CodeInstruction> BuildTool_Path_CheckBuildConditions_Transpiler(
IEnumerable<CodeInstruction> instructions)
{
foreach (var instr in instructions)
{
if (instr.opcode == OpCodes.Ldc_R4 && instr.OperandIs(0.28f))
{
instr.operand = 0.21f;
}
yield return instr;
}
}
[HarmonyTranspiler, HarmonyPatch(typeof(LabComponent), "SetFunction")]
private static IEnumerable<CodeInstruction> LabComponent_SetFunction_Transpiler(IEnumerable<CodeInstruction> instructions)
{
@@ -135,6 +150,21 @@ public class Patch : BaseUnityPlugin
}
}
foreach (var proto in LDB.items.dataArray)
{
var prefabDesc = proto.prefabDesc;
FixExtValue(ref prefabDesc.buildCollider.ext.x);
FixExtValue(ref prefabDesc.buildCollider.ext.y);
FixExtValue(ref prefabDesc.buildCollider.ext.z);
if (prefabDesc.buildColliders == null) continue;
for (var i = 0; i < prefabDesc.buildColliders.Length; i++)
{
FixExtValue(ref prefabDesc.buildColliders[i].ext.x);
FixExtValue(ref prefabDesc.buildColliders[i].ext.y);
FixExtValue(ref prefabDesc.buildColliders[i].ext.z);
}
}
foreach (var proto in LDB.items.dataArray)
{
var prefabDesc = proto.prefabDesc;
@@ -204,4 +234,14 @@ public class Patch : BaseUnityPlugin
}
}
}
private static void FixExtValue(ref float v)
{
if (v == 0f)
{
return;
}
var b = Math.Abs(v);
v = (v - b) * 0.75f + b;
}
}