Decompiled source of ULTRASPEEDRUN v1.1.0

plugins/UltraSpeedRun.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("UltraSpeedRun")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("UltraSpeedRun")]
[assembly: AssemblyTitle("UltraSpeedRun")]
[assembly: AssemblyVersion("1.0.0.0")]
[HarmonyPatch(typeof(CheatsManager), "Start")]
public class CheatsPatcher
{
	[HarmonyPrefix]
	public static void Prefix(CheatsManager __instance)
	{
		Debug.Log((object)"Yippe!");
		__instance.RegisterExternalCheat((ICheat)(object)new ShowZoneCheats());
	}
}
public class ShowZoneCheats : ICheat
{
	private bool _active = false;

	private List<MeshRenderer> objectsMadeVisible = new List<MeshRenderer>();

	private Material theMaterial;

	private Mesh theMesh;

	private Dictionary<Type, Color> _colors = new Dictionary<Type, Color>();

	private static readonly int EmissionColor = Shader.PropertyToID("_EmissionColor");

	public string LongName => "Show All Trigger Zones";

	public string Identifier => "ultraspeedrun.zones";

	public string ButtonEnabledOverride => "Hide Zones";

	public string ButtonDisabledOverride => "Show Zones";

	public string Icon => "noclip";

	public bool IsActive => _active;

	public bool DefaultState => false;

	public StatePersistenceMode PersistenceMode => (StatePersistenceMode)1;

	public void Disable()
	{
		_active = false;
		foreach (MeshRenderer item in objectsMadeVisible)
		{
			((Renderer)item).enabled = false;
		}
	}

	public void Enable()
	{
		_active = true;
		PlayerActivator val = Object.FindObjectOfType<PlayerActivator>();
		theMaterial = ((Renderer)((Component)val).GetComponent<MeshRenderer>()).material;
		theMesh = ((Component)val).GetComponent<MeshFilter>().mesh;
		this.SetObjectsVisible<ObjectActivator>();
		this.SetObjectsVisible<ActivateArena>();
		this.SetObjectsVisible<DoorController>();
	}

	public ShowZoneCheats()
	{
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_0078: Unknown result type (might be due to invalid IL or missing references)
		_colors.Add(typeof(ActivateArena), new Color(0.23f, 0.5f, 0.2f, 0.25f));
		_colors.Add(typeof(DoorController), new Color(0.2f, 0.2f, 0.5f, 0.25f));
	}

	public void SetObjectsVisible<T>() where T : MonoBehaviour
	{
		T[] array = Resources.FindObjectsOfTypeAll<T>();
		MeshRenderer renderer = default(MeshRenderer);
		MeshFilter val2 = default(MeshFilter);
		foreach (T val in array)
		{
			((Component)(object)val).gameObject.layer = 0;
			if (((Component)(object)val).TryGetComponent<MeshRenderer>(ref renderer))
			{
				MakeVisible<T>(renderer);
				continue;
			}
			MeshRenderer renderer2 = ((Component)(object)val).gameObject.AddComponent<MeshRenderer>();
			if (!((Component)(object)val).gameObject.TryGetComponent<MeshFilter>(ref val2))
			{
				val2 = ((Component)(object)val).gameObject.AddComponent<MeshFilter>();
			}
			val2.mesh = theMesh;
			MakeVisible<T>(renderer2);
		}
	}

	public void MakeVisible<T>(MeshRenderer renderer) where T : MonoBehaviour
	{
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		((Renderer)renderer).enabled = true;
		((Renderer)renderer).material = theMaterial;
		if (_colors.ContainsKey(typeof(T)))
		{
			((Renderer)renderer).material.SetColor(EmissionColor, _colors[typeof(T)]);
		}
		if (!objectsMadeVisible.Contains(renderer))
		{
			objectsMadeVisible.Add(renderer);
		}
	}

	public void Update()
	{
	}
}
[BepInPlugin("robi.uk.speedrun", "Speedrun Thingy", "1.1.0")]
public class SpeedRunMod : BaseUnityPlugin
{
	public const string pluginGuid = "robi.uk.speedrun";

	public const string pluginName = "Speedrun Thingy";

	public const string pluginVersion = "1.1.0";

	private static Harmony _harmony;

	private void Awake()
	{
		Debug.Log((object)"Loaded mod.");
	}

	private void Start()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Expected O, but got Unknown
		_harmony = new Harmony("robi.uk.speedrun");
		_harmony.PatchAll();
		Debug.Log((object)("Harmony? " + (object)_harmony == null));
	}

	private void OnDestroy()
	{
		Harmony harmony = _harmony;
		if (harmony != null)
		{
			harmony.UnpatchSelf();
		}
		Debug.Log((object)"Bye");
	}
}