Decompiled source of Chest Range Update v1.0.0

ChestRangeUpdate.dll

Decompiled 6 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Configuration;
using Microsoft.CodeAnalysis;
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 = ".NET Standard 2.0")]
[assembly: AssemblyCompany("ChestRangeUpdate")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("My first plugin")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ChestRangeUpdate")]
[assembly: AssemblyTitle("ChestRangeUpdate")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace CharmArmy
{
	[BepInPlugin("org.xatini.plugins.chestrangeupdate", "ChestRangeUpdate", "0.0.1")]
	public class Plugin : BaseUnityPlugin
	{
		public static ConfigEntry<int> ConfigRange;

		private const BindingFlags BindFlags = BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;

		private async void Awake()
		{
			ConfigRange = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Range", 10, "How far workbenches can see chests");
			((BaseUnityPlugin)this).Logger.LogInfo((object)"ChestRangeUpdate is loaded!");
			await WaitTillSimulationStart();
			Type type = typeof(GameDataCache);
			FieldInfo fieldInfo = type.GetField("_sceneCache", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
			object dictObj = fieldInfo.GetValue(null);
			if (!(dictObj is Dictionary<int, Dictionary<Type, GameData>> dictionary))
			{
				Debug.LogError((object)"Cant parse dictionary :c");
				return;
			}
			Scene scene = ((Component)GameUniverse.towerWorld).gameObject.scene;
			int handle = ((Scene)(ref scene)).handle;
			if (!dictionary.TryGetValue(handle, out var dataStorage))
			{
				Debug.LogError((object)"CANT FIND DATA STORAGE");
				return;
			}
			Type storageDataType = typeof(AdditionalStorageGameData);
			if (!dataStorage.TryGetValue(storageDataType, out var gameData))
			{
				Debug.LogError((object)"Cant find game data :c");
				return;
			}
			AdditionalStorageGameData additionalStorageGameData = (AdditionalStorageGameData)(object)((gameData is AdditionalStorageGameData) ? gameData : null);
			if (additionalStorageGameData == null)
			{
				Debug.LogError((object)"Cant parse data to this AdditionalStorageGameData");
				return;
			}
			additionalStorageGameData.connectionAreaWidth = 10;
			additionalStorageGameData.arcHeight = 3f;
		}

		private static async Task WaitTillSimulationStart()
		{
			do
			{
				await Task.Delay(1000);
			}
			while (!SimUtil.worldRunning || (Object)(object)GameUniverse.towerWorld == (Object)null || GameUniverse.towerWorld.world == null);
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "ChestRangeUpdate";

		public const string PLUGIN_NAME = "ChestRangeUpdate";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}