Decompiled source of CustomShiftstoneModels v1.1.2

Mods/ShifstoneModels.dll

Decompiled a day ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using HarmonyLib;
using Il2CppRUMBLE.Combat.ShiftStones;
using MelonLoader;
using RumbleModdingAPI;
using ShifstoneModels;
using UnityEngine;
using UnityEngine.VFX;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(Class1), "Custom Shiftstone Models", "1.1.2", "SpooderCode", null)]
[assembly: MelonGame("", "")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("ShifstoneModels")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ShifstoneModels")]
[assembly: AssemblyTitle("ShifstoneModels")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace ShifstoneModels;

public class Class1 : MelonMod
{
	[HarmonyPatch(typeof(ShiftStone), "OnFetchFromPool")]
	public class ReplaceStone
	{
		[HarmonyPostfix]
		public static void Postfix(ShiftStone __instance)
		{
			switch (__instance.StoneName)
			{
			case "Charge Stone":
				replace(__instance, chargemodel);
				break;
			case "Guard Stone":
				replace(__instance, guardmodel);
				break;
			case "Volatile Stone":
				replace(__instance, volatilemodel);
				break;
			case "Stubborn Stone":
				replace(__instance, stubbornmodel);
				break;
			case "Flow Stone":
				replace(__instance, flowmodel);
				break;
			case "Surge Stone":
				replace(__instance, surgemodel);
				break;
			case "Adamant Stone":
				replace(__instance, adamantmodel);
				break;
			case "Vigor Stone":
				replace(__instance, vigormodel);
				break;
			}
		}
	}

	[HarmonyPatch(typeof(VisualEffect), "Play", new Type[] { })]
	public class ShiftstoneActivateEffect
	{
		[HarmonyPostfix]
		public static void Postfix(VisualEffect __instance)
		{
			if (!(((Object)__instance).name == "Shiftstone Trigger VFX") || ((Component)__instance).transform.parent.childCount <= 2)
			{
				return;
			}
			foreach (Animation componentsInChild in ((Component)((Component)__instance).transform.parent).GetComponentsInChildren<Animation>())
			{
				if (((Object)((Component)componentsInChild).gameObject).name.Contains("$"))
				{
					componentsInChild.Play();
				}
			}
			foreach (ParticleSystem componentsInChild2 in ((Component)((Component)__instance).transform.parent).GetComponentsInChildren<ParticleSystem>())
			{
				if (((Object)((Component)componentsInChild2).gameObject).name.Contains("$"))
				{
					componentsInChild2.Play(false);
				}
			}
			foreach (AudioSource componentsInChild3 in ((Component)((Component)__instance).transform.parent).GetComponentsInChildren<AudioSource>())
			{
				if (((Object)((Component)componentsInChild3).gameObject).name.Contains("$"))
				{
					componentsInChild3.Play();
				}
			}
		}
	}

	private static GameObject chargemodel;

	private static GameObject adamantmodel;

	private static GameObject stubbornmodel;

	private static GameObject flowmodel;

	private static GameObject guardmodel;

	private static GameObject surgemodel;

	private static GameObject volatilemodel;

	private static GameObject vigormodel;

	public GameObject LoadShifstone(string file)
	{
		try
		{
			GameObject val;
			try
			{
				val = Object.Instantiate<GameObject>(Calls.LoadAssetFromFile<GameObject>("UserData/ShiftstoneModels/" + file, file));
			}
			catch
			{
				val = Object.Instantiate<GameObject>(Calls.LoadAssetFromFile<GameObject>("UserData/ShiftstoneModels/" + file, "Stone"));
			}
			val.SetActive(false);
			return val;
		}
		catch
		{
			return null;
		}
	}

	public static void replace(ShiftStone stone, GameObject shiftstone)
	{
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		if (((Component)stone).transform.childCount >= 3 || !((Object)(object)shiftstone != (Object)null) || !((Object)(object)stone != (Object)null))
		{
			return;
		}
		((Renderer)((Component)stone).GetComponentInChildren<MeshRenderer>()).enabled = false;
		((Component)stone).transform.localRotation = Quaternion.identity;
		GameObject val = Object.Instantiate<GameObject>(shiftstone, ((Component)stone).transform);
		val.SetActive(true);
		foreach (MeshRenderer componentsInChild in ((Component)stone).GetComponentsInChildren<MeshRenderer>())
		{
			if (((Object)((Component)componentsInChild).gameObject).name.Contains("%"))
			{
				((Renderer)componentsInChild).material = ((Renderer)((Component)((Component)stone).transform.GetChild(0)).GetComponent<MeshRenderer>()).material;
			}
		}
	}

	public override void OnSceneWasLoaded(int buildIndex, string sceneName)
	{
		if (sceneName == "Loader")
		{
			chargemodel = LoadShifstone("CHARGE");
			if (Object.op_Implicit((Object)(object)chargemodel))
			{
				Object.DontDestroyOnLoad((Object)(object)chargemodel);
			}
			guardmodel = LoadShifstone("GUARD");
			if (Object.op_Implicit((Object)(object)guardmodel))
			{
				Object.DontDestroyOnLoad((Object)(object)guardmodel);
			}
			flowmodel = LoadShifstone("FLOW");
			if (Object.op_Implicit((Object)(object)flowmodel))
			{
				Object.DontDestroyOnLoad((Object)(object)flowmodel);
			}
			surgemodel = LoadShifstone("SURGE");
			if (Object.op_Implicit((Object)(object)surgemodel))
			{
				Object.DontDestroyOnLoad((Object)(object)surgemodel);
			}
			adamantmodel = LoadShifstone("ADAMANT");
			if (Object.op_Implicit((Object)(object)adamantmodel))
			{
				Object.DontDestroyOnLoad((Object)(object)adamantmodel);
			}
			stubbornmodel = LoadShifstone("STUBBORN");
			if (Object.op_Implicit((Object)(object)stubbornmodel))
			{
				Object.DontDestroyOnLoad((Object)(object)stubbornmodel);
			}
			volatilemodel = LoadShifstone("VOLATILE");
			if (Object.op_Implicit((Object)(object)volatilemodel))
			{
				Object.DontDestroyOnLoad((Object)(object)volatilemodel);
			}
			vigormodel = LoadShifstone("VIGOR");
			if (Object.op_Implicit((Object)(object)vigormodel))
			{
				Object.DontDestroyOnLoad((Object)(object)vigormodel);
			}
		}
	}
}