Decompiled source of Extraction Point Manager v1.0.1

ExtractionPointManager.dll

Decompiled a day ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("ExtractionPointManager")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ExtractionPointManager")]
[assembly: AssemblyTitle("ExtractionPointManager")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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;
		}
	}
}
[BepInPlugin("dumbcatter.extractionpointmenu", "Dumbcatter Extraction Point Menu", "1.0.0")]
public class ExtractionPointManager : BaseUnityPlugin
{
	private Rect window = new Rect(20f, 20f, 300f, 500f);

	private bool visible = true;

	private bool allExtractions;

	private void Awake()
	{
		Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Dumbcatter Extraction Point Menu loaded!");
	}

	private void Update()
	{
		if (Input.GetKeyDown((KeyCode)286))
		{
			visible = !visible;
		}
	}

	private void OnGUI()
	{
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_002b: Expected O, but got Unknown
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		if (visible)
		{
			window = GUI.Window(7845120, window, new WindowFunction(DrawWindow), "Dumbcatter - Extraction Points");
		}
	}

	private void DrawWindow(int id)
	{
		GUILayout.Label("STATE", Array.Empty<GUILayoutOption>());
		if (GUILayout.Button("Active", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(35f) }))
		{
			SetState((State)2);
		}
		if (GUILayout.Button("Success", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(35f) }))
		{
			SetState((State)3);
		}
		if (GUILayout.Button("Warning", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(35f) }))
		{
			SetState((State)4);
		}
		if (GUILayout.Button("Cancel", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(35f) }))
		{
			SetState((State)5);
		}
		if (GUILayout.Button("Extracting", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(35f) }))
		{
			SetState((State)6);
		}
		if (GUILayout.Button("Complete", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(35f) }))
		{
			SetState((State)7);
		}
		if (GUILayout.Button("Surplus", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(35f) }))
		{
			SetState((State)8);
		}
		if (GUILayout.Button("TaxReturn", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(35f) }))
		{
			SetState((State)9);
		}
		GUILayout.Space(10f);
		GUILayout.Label("TARGET", Array.Empty<GUILayoutOption>());
		if (GUILayout.Button(allExtractions ? "Only One Extraction" : "Only One Extraction [SELECTED]", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(35f) }))
		{
			allExtractions = false;
		}
		if (GUILayout.Button(allExtractions ? "All Extractions [SELECTED]" : "All Extractions", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(35f) }))
		{
			allExtractions = true;
		}
		GUILayout.Space(5f);
		GUILayout.Label("F5 = Show / Hide", Array.Empty<GUILayoutOption>());
		GUI.DragWindow();
	}

	private unsafe void SetState(State state)
	{
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		ExtractionPoint[] array = Resources.FindObjectsOfTypeAll<ExtractionPoint>();
		int num = 0;
		if (allExtractions)
		{
			for (int i = 0; i < array.Length; i++)
			{
				if (!((Object)(object)array[i] == (Object)null))
				{
					ApplyState(array[i], state);
					num++;
				}
			}
		}
		else
		{
			for (int j = 0; j < array.Length; j++)
			{
				if (!((Object)(object)array[j] == (Object)null))
				{
					ApplyState(array[j], state);
					num++;
					break;
				}
			}
		}
		((BaseUnityPlugin)this).Logger.LogInfo((object)("Changed " + num + " ExtractionPoint(s) to " + ((object)(*(State*)(&state))/*cast due to .constrained prefix*/).ToString()));
	}

	private void ApplyState(ExtractionPoint ep, State state)
	{
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: Unknown result type (might be due to invalid IL or missing references)
		MethodInfo method = ((object)ep).GetType().GetMethod("StateSet", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
		if (method != null)
		{
			method.Invoke(ep, new object[1] { state });
		}
		else
		{
			((BaseUnityPlugin)this).Logger.LogWarning((object)("StateSet was not found on " + ((object)ep).GetType().FullName));
		}
		PhotonView val = ((Component)ep).GetComponent<PhotonView>();
		if ((Object)(object)val == (Object)null)
		{
			val = ((Component)ep).GetComponentInParent<PhotonView>();
		}
		if ((Object)(object)val != (Object)null)
		{
			val.RPC("StateSetRPC", (RpcTarget)0, new object[1] { state });
		}
	}
}