using System.Collections;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using UnityEngine;
using UnityEngine.SceneManagement;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("WWAG_LargerChestRange")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Increases the range in which workbenches can see chests")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1")]
[assembly: AssemblyProduct("WWAG_LargerChestRange")]
[assembly: AssemblyTitle("WWAG_LargerChestRange")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.1.0")]
[module: UnverifiableCode]
namespace WWAG_LargerChestRange;
[BepInPlugin("com.NikoTheFox.LargerChestRange", "Larger Chest Range", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
public static ConfigEntry<int> configRange;
private void Awake()
{
configRange = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Range", 6, "How far workbenches can see chests");
((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin WWAG_LargerChestRange is loaded!");
}
private void OnEnable()
{
Debug.Log((object)"Plugin enabled");
SceneManager.sceneLoaded += OnSceneLoaded;
}
private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Expected O, but got Unknown
ManualLogSource logger = ((BaseUnityPlugin)this).Logger;
Scene activeScene = SceneManager.GetActiveScene();
logger.LogInfo((object)("Currently in scene: " + ((Scene)(ref activeScene)).name));
if (((Scene)(ref scene)).name == "scene-tower")
{
GameObject val = new GameObject("ModUpdater");
val.AddComponent<YourModScript>();
Object.DontDestroyOnLoad((Object)(object)val);
}
}
}
public class YourModScript : MonoBehaviour
{
private void OnEnable()
{
Debug.Log((object)"[LargerChestRange] Script Enabled");
((MonoBehaviour)this).StartCoroutine(DelayedComponentCheck());
}
private IEnumerator DelayedComponentCheck()
{
yield return (object)new WaitForSeconds(5f);
Debug.Log((object)"[LargerChestRange] Looking for object");
AdditionalStorageGameData asgd3 = FindComponentInDontSaveObjects();
if ((Object)(object)asgd3 == (Object)null)
{
Debug.LogError((object)"[LargerChestRange] I didnt find the object to change stuff, will try again in 3 seconds");
yield return (object)new WaitForSeconds(3f);
asgd3 = FindComponentInDontSaveObjects();
if ((Object)(object)asgd3 == (Object)null)
{
Debug.LogError((object)"[LargerChestRange] I didnt find the object to change stuff, will try again in 3 seconds");
yield return (object)new WaitForSeconds(3f);
asgd3 = FindComponentInDontSaveObjects();
if ((Object)(object)asgd3 == (Object)null)
{
Debug.LogError((object)"[LargerChestRange] I didnt find the object to change stuff, so the mod wont work. Sorry!");
}
}
}
else
{
asgd3.connectionAreaWidth = Plugin.configRange.Value;
asgd3.arcHeight = 3f;
}
}
private AdditionalStorageGameData FindComponentInDontSaveObjects()
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Invalid comparison between Unknown and I4
GameObject[] array = Resources.FindObjectsOfTypeAll<GameObject>();
foreach (GameObject val in array)
{
if ((int)((Object)val).hideFlags == 0)
{
AdditionalStorageGameData component = val.GetComponent<AdditionalStorageGameData>();
if ((Object)(object)component != (Object)null)
{
return component;
}
}
}
Debug.LogError((object)"[LargerChestRange] Found nothing, this is bad");
return null;
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "WWAG_LargerChestRange";
public const string PLUGIN_NAME = "WWAG_LargerChestRange";
public const string PLUGIN_VERSION = "1.0.1";
}