mirror of
https://github.com/soarqin/DSP_Mods.git
synced 2025-12-09 12:53:34 +08:00
Work in progress
This commit is contained in:
@@ -190,7 +190,7 @@ public class CheatEnabler : BaseUnityPlugin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void UnlockTechRecursive(GameHistoryData history, int currentTech, int maxLevel = 10001)
|
private static void UnlockTechRecursive(GameHistoryData history, int currentTech, int maxLevel = 10000)
|
||||||
{
|
{
|
||||||
var techStates = history.techStates;
|
var techStates = history.techStates;
|
||||||
if (techStates == null || !techStates.ContainsKey(currentTech))
|
if (techStates == null || !techStates.ContainsKey(currentTech))
|
||||||
@@ -203,7 +203,7 @@ public class CheatEnabler : BaseUnityPlugin
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var value = techStates[currentTech];
|
var value = techStates[currentTech];
|
||||||
var maxLvl = Math.Min(maxLevel, value.maxLevel) + 1;
|
var maxLvl = Math.Min(maxLevel, value.maxLevel);
|
||||||
if (value.unlocked && value.curLevel >= maxLvl && value.hashUploaded >= value.hashNeeded)
|
if (value.unlocked && value.curLevel >= maxLvl && value.hashUploaded >= value.hashNeeded)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@@ -225,7 +225,7 @@ public class CheatEnabler : BaseUnityPlugin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while (value.curLevel < maxLvl)
|
while (value.curLevel <= maxLvl)
|
||||||
{
|
{
|
||||||
for (var j = 0; j < techProto.UnlockFunctions.Length; j++)
|
for (var j = 0; j < techProto.UnlockFunctions.Length; j++)
|
||||||
{
|
{
|
||||||
@@ -233,10 +233,10 @@ public class CheatEnabler : BaseUnityPlugin
|
|||||||
}
|
}
|
||||||
value.curLevel++;
|
value.curLevel++;
|
||||||
}
|
}
|
||||||
value.curLevel = maxLvl - 1;
|
value.unlocked = maxLvl >= value.maxLevel;
|
||||||
value.unlocked = maxLvl > value.maxLevel;
|
value.curLevel = value.unlocked ? maxLvl : maxLvl + 1;
|
||||||
value.hashNeeded = techProto.GetHashNeeded(value.curLevel);
|
value.hashNeeded = techProto.GetHashNeeded(value.curLevel);
|
||||||
value.hashUploaded = maxLvl >= value.maxLevel ? value.hashNeeded : 0;
|
value.hashUploaded = value.unlocked ? value.hashNeeded : 0;
|
||||||
techStates[currentTech] = value;
|
techStates[currentTech] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
using BepInEx;
|
using System.Collections.Generic;
|
||||||
|
using System.Reflection.Emit;
|
||||||
|
using BepInEx;
|
||||||
using BepInEx.Configuration;
|
using BepInEx.Configuration;
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
@@ -57,6 +59,48 @@ public class Patch : BaseUnityPlugin
|
|||||||
Harmony.CreateAndPatchAll(typeof(BeltFix));
|
Harmony.CreateAndPatchAll(typeof(BeltFix));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HarmonyTranspiler, HarmonyPatch(typeof(LabComponent), "SetFunction")]
|
||||||
|
private static IEnumerable<CodeInstruction> LabComponent_SetFunction_Transpiler(IEnumerable<CodeInstruction> instructions)
|
||||||
|
{
|
||||||
|
var lastIsLdc10000 = false;
|
||||||
|
foreach (var instr in instructions)
|
||||||
|
{
|
||||||
|
if (instr.opcode == OpCodes.Ldc_I4 && instr.OperandIs(10000))
|
||||||
|
{
|
||||||
|
lastIsLdc10000 = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (lastIsLdc10000)
|
||||||
|
{
|
||||||
|
lastIsLdc10000 = false;
|
||||||
|
if (instr.opcode == OpCodes.Stfld)
|
||||||
|
{
|
||||||
|
yield return new CodeInstruction(OpCodes.Ldc_I4, assembleSpeedMultiplier);
|
||||||
|
yield return new CodeInstruction(OpCodes.Mul);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
yield return instr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HarmonyTranspiler, HarmonyPatch(typeof(MechaForge), "GameTick")]
|
||||||
|
private static IEnumerable<CodeInstruction> MechaForge_GameTick_Transpiler(IEnumerable<CodeInstruction> instructions)
|
||||||
|
{
|
||||||
|
foreach (var instr in instructions)
|
||||||
|
{
|
||||||
|
if (instr.opcode == OpCodes.Ldc_R4 && instr.OperandIs(10000f))
|
||||||
|
{
|
||||||
|
yield return new CodeInstruction(OpCodes.Ldc_R4, 10000f * assembleSpeedMultiplier);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
yield return instr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[HarmonyPostfix, HarmonyPriority(Priority.Last), HarmonyPatch(typeof(VFPreload), "InvokeOnLoadWorkEnded")]
|
[HarmonyPostfix, HarmonyPriority(Priority.Last), HarmonyPatch(typeof(VFPreload), "InvokeOnLoadWorkEnded")]
|
||||||
private static void VFPreload_InvokeOnLoadWorkEnded_Postfix()
|
private static void VFPreload_InvokeOnLoadWorkEnded_Postfix()
|
||||||
{
|
{
|
||||||
@@ -70,10 +114,14 @@ public class Patch : BaseUnityPlugin
|
|||||||
var prefabDesc = proto.prefabDesc;
|
var prefabDesc = proto.prefabDesc;
|
||||||
if (prefabDesc.isInserter)
|
if (prefabDesc.isInserter)
|
||||||
{
|
{
|
||||||
prefabDesc.inserterSTT *= sorterSpeedMultiplier;
|
prefabDesc.inserterSTT /= sorterSpeedMultiplier;
|
||||||
prefabDesc.idleEnergyPerTick *= sorterPowerConsumptionMultiplier;
|
prefabDesc.idleEnergyPerTick *= sorterPowerConsumptionMultiplier;
|
||||||
prefabDesc.workEnergyPerTick *= sorterPowerConsumptionMultiplier;
|
prefabDesc.workEnergyPerTick *= sorterPowerConsumptionMultiplier;
|
||||||
}
|
}
|
||||||
|
if (prefabDesc.isLab)
|
||||||
|
{
|
||||||
|
prefabDesc.labAssembleSpeed *= assembleSpeedMultiplier;
|
||||||
|
}
|
||||||
if (prefabDesc.isAssembler)
|
if (prefabDesc.isAssembler)
|
||||||
{
|
{
|
||||||
prefabDesc.assemblerSpeed *= assembleSpeedMultiplier;
|
prefabDesc.assemblerSpeed *= assembleSpeedMultiplier;
|
||||||
@@ -108,10 +156,12 @@ public class Patch : BaseUnityPlugin
|
|||||||
}
|
}
|
||||||
if (prefabDesc.isPowerNode)
|
if (prefabDesc.isPowerNode)
|
||||||
{
|
{
|
||||||
|
var ival = Mathf.Floor(prefabDesc.powerConnectDistance);
|
||||||
prefabDesc.powerConnectDistance =
|
prefabDesc.powerConnectDistance =
|
||||||
Mathf.Floor(prefabDesc.powerConnectDistance) * prefabDesc.powerConnectDistance + 0.5f;
|
ival * powerSupplyAreaMultiplier + (prefabDesc.powerConnectDistance - ival);
|
||||||
|
ival = Mathf.Floor(prefabDesc.powerCoverRadius);
|
||||||
prefabDesc.powerCoverRadius =
|
prefabDesc.powerCoverRadius =
|
||||||
Mathf.Floor(prefabDesc.powerCoverRadius) * prefabDesc.powerConnectDistance + 0.5f;
|
ival * powerSupplyAreaMultiplier + (prefabDesc.powerCoverRadius - ival);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user