Decompiled source of 43Coralation v1.2.0

Flush/FlushCoralation.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Events;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("SaveBeforeLand")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("MelanieMelicious")]
[assembly: AssemblyProduct("Save Before Landing")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[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;
		}
	}
}
internal class HarmonyPatches
{
	private static bool loaded;

	[HarmonyPostfix]
	[HarmonyPatch(typeof(StartOfRound), "Awake")]
	private static void EditToilet(StartOfRound __instance)
	{
		//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0110: Unknown result type (might be due to invalid IL or missing references)
		if (loaded)
		{
			return;
		}
		UnlockableItem val = __instance.unlockablesList.unlockables[9];
		if (val.unlockableName != "Toilet")
		{
			foreach (UnlockableItem unlockable in __instance.unlockablesList.unlockables)
			{
				if (unlockable.unlockableName == "Toilet")
				{
					val = unlockable;
				}
			}
		}
		((Component)val.prefabObject.transform.Find("ToiletMesh")).GetComponent<MeshFilter>().sharedMesh = Plugin.bundle.LoadAsset<Mesh>("Assets/FlushCoralation/ToiletOpen.mesh");
		Transform transform = Object.Instantiate<GameObject>(Plugin.bundle.LoadAsset<GameObject>("Assets/FlushCoralation/Whirlpool.prefab")).transform;
		transform.parent = val.prefabObject.transform;
		transform.localPosition = new Vector3(0f, 1.5f, 0.4f);
		transform.localEulerAngles = new Vector3(-90f, 0f, 0f);
		((Component)val.prefabObject.transform.Find("Cube")).gameObject.AddComponent<Toilet>();
		loaded = true;
	}
}
[BepInPlugin("MelanieMelicious.FlushCoralation", "Melanie Melicious - FlushCoralation", "1.0.0")]
internal class Plugin : BaseUnityPlugin
{
	private const string GUID = "MelanieMelicious.FlushCoralation";

	private const string NAME = "Melanie Melicious - FlushCoralation";

	private const string VERSION = "1.0.0";

	private readonly Harmony harmony = new Harmony("MelanieMelicious.FlushCoralation");

	public static AssetBundle bundle;

	private void Awake()
	{
		string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "flushcoralation");
		bundle = AssetBundle.LoadFromFile(text);
		harmony.PatchAll(typeof(HarmonyPatches));
	}
}
public class Toilet : MonoBehaviour
{
	internal ParticleSystem particle;

	private const string coralation = "43 Coralation";

	private Coroutine draining;

	internal void Flush(PlayerControllerB player)
	{
		if (StartOfRound.Instance.currentLevel.PlanetName == "43 Coralation" && draining == null && (StartOfRound.Instance.shipHasLanded || StartOfRound.Instance.shipLandingAudio.isPlaying) && Object.op_Implicit((Object)(object)GameObject.Find("/yknowwhatthatmeans")))
		{
			draining = ((MonoBehaviour)this).StartCoroutine(Drain());
		}
	}

	private IEnumerator Drain()
	{
		Transform[] water = (Transform[])(object)new Transform[6]
		{
			GameObject.Find("/yknowwhatthatmeans").transform,
			GameObject.Find("/caustics").transform,
			GameObject.Find("/watereffects").transform,
			GameObject.Find("/LocalVolume").transform,
			GameObject.Find("/WaterBlock").transform,
			GameObject.Find("/WATERSPLASH").transform
		};
		particle.Play();
		for (int i = 0; i < 800; i++)
		{
			Transform obj = water[0];
			obj.position += Vector3.down * 0.1f;
			Transform obj2 = water[1];
			obj2.position += Vector3.down * 0.1f;
			Transform obj3 = water[2];
			obj3.position += Vector3.down * 0.1f;
			Transform obj4 = water[3];
			obj4.position += Vector3.down * 0.1f;
			Transform obj5 = water[4];
			obj5.position += Vector3.down * 0.1f;
			Transform obj6 = water[5];
			obj6.position += Vector3.down * 0.1f;
			if (i == 270)
			{
				particle.Stop();
			}
			yield return (object)new WaitForSeconds(0.05f);
		}
		((Component)water[0]).gameObject.SetActive(false);
		((Component)water[1]).gameObject.SetActive(false);
		((Component)water[2]).gameObject.SetActive(false);
		((Component)water[3]).gameObject.SetActive(false);
		((Component)water[4]).gameObject.SetActive(false);
		((Component)water[5]).gameObject.SetActive(false);
		draining = null;
	}

	private void Start()
	{
		particle = ((Component)((Component)this).transform.parent.Find("Whirlpool(Clone)")).GetComponent<ParticleSystem>();
		((UnityEvent<PlayerControllerB>)(object)((Component)this).GetComponent<InteractTrigger>().onInteract).AddListener((UnityAction<PlayerControllerB>)Flush);
	}
}