Decompiled source of WaffleHouseCompany v0.9.5

WaffleCompany.dll

Decompiled 4 months ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
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.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("WaffleCompany")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Replaces company building with waffle house")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("WaffleCompany")]
[assembly: AssemblyTitle("WaffleCompany")]
[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 WaffleCompany
{
	[BepInPlugin("WaffleCompany", "WaffleCompany", "1.0")]
	public class Plugin : BaseUnityPlugin
	{
		public static GameObject WaffleHouse;

		public static string pluginDir;

		public static AssetBundle WaffleBundle;

		public static GameObject audioSource;

		private void Awake()
		{
			pluginDir = ((BaseUnityPlugin)this).Info.Location;
			LoadAssets();
			Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
		}

		private static void LoadAssets()
		{
			try
			{
				WaffleBundle = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(pluginDir), "wafflebundle"));
			}
			catch (Exception ex)
			{
				Debug.LogError((object)("WaffleCompany: AssetBundle failed to load -- " + ex.Message));
				return;
			}
			try
			{
				WaffleHouse = WaffleBundle.LoadAsset<GameObject>("Waffle_House.prefab");
				audioSource = WaffleBundle.LoadAsset<GameObject>("explodeSound.prefab");
				Debug.Log((object)$"WaffleCompany: GameObject is loaded as {WaffleHouse}");
				Debug.Log((object)"WaffleCompany: Successfully loaded assets.");
			}
			catch (Exception ex2)
			{
				Debug.LogError((object)("WaffleCompany: Failed to load assets -- " + ex2.Message));
			}
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "WaffleCompany";

		public const string PLUGIN_NAME = "WaffleCompany";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace WaffleCompany.Patches
{
	[HarmonyPatch(typeof(DepositItemsDesk))]
	internal class CompanyAttack
	{
		[HarmonyPatch("Attack")]
		[HarmonyPrefix]
		private static void ExplodeYoAss(DepositItemsDesk __instance)
		{
			//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_0016: Unknown result type (might be due to invalid IL or missing references)
			RoundStart.source.Play();
			Landmine.SpawnExplosion(RoundStart.detPos + Vector3.up, true, 5.7f, 6f, 50, 0f, (GameObject)null, false);
		}
	}
	[HarmonyPatch(typeof(DepositItemsDesk))]
	internal class RoundStart
	{
		public static Vector3 detPos;

		public static AudioSource source;

		[HarmonyPatch("Start")]
		[HarmonyFinalizer]
		private static void SummonWaffleHouse()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0303: Unknown result type (might be due to invalid IL or missing references)
			//IL_04da: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0365: Unknown result type (might be due to invalid IL or missing references)
			//IL_053f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0334: Unknown result type (might be due to invalid IL or missing references)
			//IL_041f: Unknown result type (might be due to invalid IL or missing references)
			//IL_044a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0470: Unknown result type (might be due to invalid IL or missing references)
			//IL_049b: Unknown result type (might be due to invalid IL or missing references)
			Debug.Log((object)"WaffleCompany: DepositItemsDesk started");
			Scene sceneByName = SceneManager.GetSceneByName("CompanyBuilding");
			if (((Scene)(ref sceneByName)).IsValid())
			{
				Debug.Log((object)"WaffleCompany: Summoning waffle house...");
				GameObject val = Object.Instantiate<GameObject>(Plugin.WaffleHouse);
				val.transform.localPosition = new Vector3(0f, 0f, 0f);
				val.transform.localScale = new Vector3(1.65f, 1.65f, 1.65f);
				val.transform.rotation = Quaternion.Euler(0f, 270f, 0f);
				val.transform.position = new Vector3(-34f, -2.5f, -30f);
				Debug.Log((object)"WaffleCompany: Creating platform extension");
				GameObject val2 = GameObject.CreatePrimitive((PrimitiveType)4);
				((Object)val2).name = "Platform";
				val2.AddComponent<MeshCollider>();
				val2.transform.position = new Vector3(-92f, -2.7f, -28f);
				val2.transform.localScale = new Vector3(14f, 1f, 120f);
				GameObject val3 = Object.Instantiate<GameObject>(Plugin.audioSource);
				source = val3.GetComponent<AudioSource>();
				Debug.Log((object)"WaffleCompany: Found valid scene. Getting root objects");
				GameObject[] rootGameObjects = ((Scene)(ref sceneByName)).GetRootGameObjects();
				foreach (GameObject val4 in rootGameObjects)
				{
					switch (((Object)val4).name)
					{
					case "Plane":
						val4.SetActive(false);
						Debug.Log((object)"WaffleCompany: Plane disabled");
						break;
					case "Cube":
						val4.transform.position = new Vector3(-30.8f, -0.605f, -29f);
						Debug.Log((object)"WaffleCompany: Cube moved");
						break;
					case "Canvas":
						val4.transform.position = new Vector3(-30.6f, -0.5931f, -29f);
						Debug.Log((object)"WaffleCompany: Canvas moved");
						break;
					case "Cube(Clone)":
						val4.transform.position = new Vector3(-30.8f, -0.605f, -31.4f);
						Debug.Log((object)"WaffleCompany: Cube(Clone) moved");
						break;
					case "Canvas(Clone)":
						val4.transform.position = new Vector3(-30.56f, -0.6069f, -31.4f);
						Debug.Log((object)"WaffleCompany: Canvas(Clone) moved");
						break;
					case "Environment":
						val.transform.SetParent(val4.transform);
						val2.transform.SetParent(val4.transform);
						Debug.Log((object)"WaffleCompany: set Environment as parent to Plane and WaffleHouse");
						findAndTurnOff("Map/CompanyPlanet/Cube.003", val4.transform);
						findAndTurnOff("Map/ShippingContainers/ShippingContainer", val4.transform);
						findAndTurnOff("Map/ShippingContainers/ShippingContainer (1)", val4.transform);
						findAndTurnOff("Map/ShippingContainers/ShippingContainer (4)", val4.transform);
						findAndTurnOff("LightsContainer/LEDHangingLight (1)", val4.transform);
						findAndMove("LightsContainer/LEDHangingLight (2)", new Vector3(-31.8f, -1.5f, -44.5f), val4.transform);
						findAndRotate("LightsContainer/LEDHangingLight (2)", new Quaternion(0.6964f, 0.1228f, 0.1228f, 0.6964f), val4.transform);
						findAndMove("LightsContainer/LEDHangingLight (3)", new Vector3(2.45f, 5.6f, -35.9f), val4.transform);
						findAndRotate("LightsContainer/LEDHangingLight (3)", new Quaternion(0.6533f, 0.2706f, 0.2706f, 0.6533f), val4.transform);
						findAndTurnOff("LightsContainer/LEDHangingLight (4)", val4.transform);
						break;
					case "BellDinger":
						val4.transform.position = new Vector3(-29.7f, -0.654f, -28.6f);
						detPos = val4.transform.position;
						val3.transform.position = detPos;
						val3.transform.SetParent(val4.transform);
						Debug.Log((object)"WaffleCompany: set detonation position to bell");
						break;
					case "DepositCounter":
						val4.transform.position = new Vector3(23.08f, 8.11f, -9.39f);
						findAndTurnOff("TinyCamera (1)", val4.transform);
						findAndTurnOff("SpeakerBox", val4.transform);
						findAndTurnOff("DoorAndHookAnim/DepositCounterDoor (1)", val4.transform);
						break;
					case "CompanyMonstersAnims":
						findAndTurnOff("TentacleAnimContainer", val4.transform);
						break;
					}
				}
			}
			else
			{
				Debug.LogWarning((object)"WaffleCompany: Could not find CompanyBuilding Scene. DepositItemsDesk might be being used on a different moon");
			}
		}

		public static void findAndTurnOff(string objName, Transform parent)
		{
			Transform val = parent.Find(objName);
			if ((Object)(object)val != (Object)null)
			{
				((Component)val).gameObject.SetActive(false);
				Debug.Log((object)("WaffleCompany: turned off " + objName));
			}
			else
			{
				Debug.LogError((object)("WaffleCompany: Could not find " + objName + ". Object is null"));
			}
		}

		public static void findAndMove(string objName, Vector3 newPos, Transform parent)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			Transform val = parent.Find(objName);
			if ((Object)(object)val != (Object)null)
			{
				val.position = newPos;
				Debug.Log((object)("WaffleCompany: moved " + objName));
			}
			else
			{
				Debug.LogError((object)("WaffleCompany: Could not find " + objName + ". Object is null"));
			}
		}

		public static void findAndRotate(string objName, Quaternion newRot, Transform parent)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			Transform val = parent.Find(objName);
			if ((Object)(object)val != (Object)null)
			{
				val.rotation = newRot;
				Debug.Log((object)("WaffleCompany: rotated " + objName));
			}
			else
			{
				Debug.LogError((object)("WaffleCompany: Could not find " + objName + ". Object is null"));
			}
		}
	}
}