Decompiled source of GummyMan v0.0.3

plugins/GummyMan/NovemberThirteenth.dll

Decompiled 3 months ago
using System;
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 EntityStates;
using HG.Reflection;
using RoR2;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("NovemberThirteenth")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("NovemberThirteenth")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: OptIn]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.2.0")]
[module: UnverifiableCode]
namespace NovemberThirteenth;

internal class GummyBearMusicDisc : MonoBehaviour
{
	public int rolledID;

	public uint playID;

	public bool hasPaused;

	public CharacterBody characterBody;

	public EntityStateMachine bodyStateMachine;

	public SetStateOnHurt hurtState;

	public static string[] playEvents = new string[2] { "Play_vat19_gummy", "Play_november_13th" };

	public static string[] pauseEvents = new string[2] { "Pause_vat19_gummy", "Pause_november_13th" };

	public static string[] resumeEvents = new string[2] { "Resume_vat19_gummy", "Resume_november_13th" };

	public void OnEnable()
	{
		if (playID == 0)
		{
			rolledID = Random.Range(0, playEvents.Length);
			characterBody = ((Component)this).gameObject.GetComponent<CharacterBody>();
			playID = Util.PlaySound(playEvents[rolledID], ((Component)this).gameObject);
		}
		if ((Object)(object)bodyStateMachine == (Object)null && Object.op_Implicit((Object)(object)characterBody))
		{
			bodyStateMachine = EntityStateMachine.FindByCustomName(((Component)characterBody).gameObject, "Body");
			hurtState = ((Component)characterBody).GetComponent<SetStateOnHurt>();
		}
	}

	public void Update()
	{
		bool flag = false;
		bool flag2 = false;
		if (Object.op_Implicit((Object)(object)hurtState))
		{
			flag = ((object)bodyStateMachine.state).GetType() == ((SerializableEntityStateType)(ref hurtState.hurtState)).stateType;
			flag2 = ((object)bodyStateMachine.state).GetType() == typeof(ShockState);
		}
		if ((characterBody.healthComponent.isInFrozenState || flag2 || flag) && !hasPaused)
		{
			Util.PlaySound(pauseEvents[rolledID], ((Component)this).gameObject);
			hasPaused = true;
		}
		if (!characterBody.healthComponent.isInFrozenState && !flag2 && !flag && hasPaused)
		{
			Util.PlaySound(resumeEvents[rolledID], ((Component)this).gameObject);
			hasPaused = false;
		}
	}

	public void OnDisable()
	{
		AkSoundEngine.StopPlayingID(playID);
		playID = 0u;
	}
}
[BepInPlugin("com.Anreol.NovemberThirteenth", "NovemberThirteenth", "0.0.2")]
public class NovemberUnityPlugin : BaseUnityPlugin
{
	internal const string ModVer = "0.0.2";

	internal const string ModIdentifier = "NovemberThirteenth";

	internal const string ModGuid = "com.Anreol.NovemberThirteenth";

	public static NovemberUnityPlugin instance;

	public static PluginInfo pluginInfo;

	public static string soundBankDirectory => Path.Combine(Path.GetDirectoryName(pluginInfo.Location), "soundbanks");

	public void Awake()
	{
		pluginInfo = ((BaseUnityPlugin)this).Info;
		CharacterBody.onBodyStartGlobal += Gummyfy;
	}

	private void Gummyfy(CharacterBody obj)
	{
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		if (Object.op_Implicit((Object)(object)obj) && Object.op_Implicit((Object)(object)((Component)obj).gameObject) && Object.op_Implicit((Object)(object)obj.inventory) && obj.inventory.GetItemCount(Items.GummyCloneIdentifier.itemIndex) > 0)
		{
			((Component)obj).gameObject.AddComponent<GummyBearMusicDisc>();
		}
	}

	[SystemInitializer(new Type[] { })]
	public static void Init()
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		AkSoundEngine.AddBasePath(soundBankDirectory);
		uint num = default(uint);
		AkSoundEngine.LoadBank("GummyInit.bnk", ref num);
		AkSoundEngine.LoadBank("GummyBank.bnk", ref num);
	}
}