using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("SLBuildingPatch")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SLBuildingPatch")]
[assembly: AssemblyCopyright("Copyright © ModderJohn 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("c5450fe0-edcf-483f-b9ea-4b1ef9d36da7")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = "")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace SLBuildingPatch;
[BepInPlugin("ModderJohn.SLBuildingPatch", "SLBuildingPatch", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
[HarmonyPatch]
public static class SL_ConstructionPhase_GeneratePhase_Patch
{
private static MethodBase TargetMethod()
{
Type type = AccessTools.TypeByName("SideLoader.SL_ConstructionPhase") ?? AccessTools.TypeByName("SL_ConstructionPhase");
if (type == null)
{
Log.LogError((object)"[SLBuildingPatch] Could not find SL_ConstructionPhase type.");
return null;
}
MethodInfo methodInfo = AccessTools.Method(type, "GeneratePhase", Array.Empty<Type>(), (Type[])null);
if (methodInfo == null)
{
Log.LogError((object)"[SLBuildingPatch] Could not find GeneratePhase() method.");
}
return methodInfo;
}
private static void Postfix(object __instance, ref object __result)
{
try
{
if (__result != null && __instance != null)
{
Type type = __result.GetType();
Type type2 = __instance.GetType();
FieldInfo field = type2.GetField("ConstructionTime", BindingFlags.Instance | BindingFlags.Public);
FieldInfo field2 = type2.GetField("ConstructionCosts", BindingFlags.Instance | BindingFlags.Public);
int num = 0;
object obj = null;
if (field != null)
{
num = (int)field.GetValue(__instance);
}
if (field2 != null)
{
obj = field2.GetValue(__instance);
}
FieldInfo field3 = type.GetField("m_constructionTime", BindingFlags.Instance | BindingFlags.NonPublic);
FieldInfo field4 = type.GetField("m_constructionCosts", BindingFlags.Instance | BindingFlags.NonPublic);
if (field3 != null)
{
field3.SetValue(__result, num);
}
if (field4 != null && obj != null)
{
field4.SetValue(__result, obj);
}
}
}
catch (Exception ex)
{
Log.LogError((object)("[SLBuildingPatch] Exception in Postfix: " + ex));
}
}
}
internal static ManualLogSource Log;
private void Awake()
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
Log = ((BaseUnityPlugin)this).Logger;
new Harmony("ModderJohn.SLBuildingPatch").PatchAll();
}
}