using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using OldMarket.AutoLights;
using Unity.Netcode;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("OldMarket.AutoLightOn")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("OldMarket.AutoLightOn")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("aa406097-aeca-4de9-82fd-4ef29bc914d6")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
[HarmonyPatch(typeof(GameManager))]
internal static class GameManager_AutoLights_Patch
{
[HarmonyPostfix]
[HarmonyPatch("LoadWorldServer")]
private static void Post_LoadWorldServer(GameManager __instance)
{
if (!((NetworkBehaviour)__instance).IsServer || !__instance.IsWorldLoaded())
{
return;
}
try
{
BlockLight[] array = Object.FindObjectsOfType<BlockLight>();
if (array == null || array.Length == 0)
{
return;
}
BlockLight[] array2 = array;
foreach (BlockLight val in array2)
{
if (!((Object)(object)val == (Object)null))
{
NetworkVariable<bool> value = Traverse.Create((object)val).Field("isLightOn").GetValue<NetworkVariable<bool>>();
if (value != null && !value.Value)
{
val.ToggleLightServerRpc();
}
}
}
}
catch (Exception arg)
{
ManualLogSource log = AutoLightsPlugin.Log;
if (log != null)
{
log.LogError((object)$"AutoLights: failed to toggle lights after world load: {arg}");
}
}
}
}
namespace OldMarket.AutoLights;
[BepInPlugin("OldMarket.AutoLightOn", "OldMarket Auto LightOn", "1.0.2")]
public class AutoLightsPlugin : BaseUnityPlugin
{
public const string PluginGuid = "OldMarket.AutoLightOn";
public const string PluginName = "OldMarket Auto LightOn";
public const string PluginVersion = "1.0.2";
internal static ManualLogSource Log;
private void Awake()
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
Log = ((BaseUnityPlugin)this).Logger;
try
{
new Harmony("OldMarket.AutoLightOn").PatchAll();
}
catch (Exception arg)
{
Log.LogError((object)$"AutoLights: failed to apply Harmony patches: {arg}");
}
}
}