Decompiled source of 1 in 10000 Chance for Withered Foxy Jumpscare Every Second v1.0.1

plugins/Fnaf2FoxyJumpScare.dll

Decompiled 2 weeks 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 BepInEx.Bootstrap;
using BepInEx.Configuration;
using HG.Reflection;
using Microsoft.CodeAnalysis;
using R2API;
using RiskOfOptions;
using RiskOfOptions.Options;
using RoR2;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: OptIn]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Fnaf2FoxyJumpScare")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Fnaf2FoxyJumpScare")]
[assembly: AssemblyTitle("Fnaf2FoxyJumpScare")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
[module: UnverifiableCode]
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 Fnaf2FoxyJumpScare
{
	[Serializable]
	[BepInPlugin("com.brynzananas.fnaf2foxyjumpscare", "Fnaf 2 Foxy Jumpscare", "1.0.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Main : BaseUnityPlugin
	{
		public const string ModGuid = "com.brynzananas.fnaf2foxyjumpscare";

		public const string ModName = "Fnaf 2 Foxy Jumpscare";

		public const string ModVer = "1.0.1";

		public bool riskOfOptionsEnabled;

		public static AssetBundle assetBundle;

		public static GameObject Fnaf2FoxyJumpscare;

		public static ConfigFile configFile;

		public static ConfigEntry<float> chance;

		public static float stopwatch;

		public static ConfigEntry<float> interval;

		public void Awake()
		{
			configFile = ((BaseUnityPlugin)this).Config;
			chance = configFile.Bind<float>("Main", "Chance", 0.0001f, "");
			interval = configFile.Bind<float>("Main", "Interval", 1f, "");
			riskOfOptionsEnabled = Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions");
			if (riskOfOptionsEnabled)
			{
				ModCompatabilities.RiskOfOptionsCompatability.AddConfig<float>(chance);
				ModCompatabilities.RiskOfOptionsCompatability.AddConfig<float>(interval);
			}
			assetBundle = AssetBundle.LoadFromFileAsync(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "assetbundles", "fnaf2foxyjumpscareassets")).assetBundle;
			Fnaf2FoxyJumpscare = assetBundle.LoadAsset<GameObject>("Assets/Fnaf2JumpScare/Fnaf2FoxyJumpscare.prefab");
			SoundBanks.Add(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "soundbanks", "Fnaf2FoxyJumpscareBank.bnk"));
		}

		public void Update()
		{
			stopwatch += Time.unscaledDeltaTime;
			if (stopwatch >= interval.Value)
			{
				stopwatch = 0f;
				if (Util.CheckRoll(chance.Value, 0f, (CharacterMaster)null) && Object.op_Implicit((Object)(object)Fnaf2FoxyJumpscare))
				{
					Object.Instantiate<GameObject>(Fnaf2FoxyJumpscare);
				}
			}
		}
	}
	public class Fnaf2FoxyJumpscare : MonoBehaviour
	{
		public Image image;

		public Sprite[] sprites;

		public int currentFrame;

		public float spritesInterval;

		public string soundString;

		public bool loop;

		public float stopwatch;

		public void Start()
		{
			Util.PlaySound(soundString, ((Component)RoR2Application.instance).gameObject);
			UpdateImage();
		}

		public void Update()
		{
			stopwatch += Time.unscaledDeltaTime;
			if (!(stopwatch >= spritesInterval))
			{
				return;
			}
			currentFrame++;
			if (currentFrame >= sprites.Length)
			{
				if (!loop)
				{
					Object.Destroy((Object)(object)((Component)this).gameObject);
					return;
				}
				currentFrame = 0;
			}
			UpdateImage();
			stopwatch = 0f;
		}

		public void UpdateImage()
		{
			if (!((Object)(object)image == (Object)null) && sprites != null && sprites.Length != 0)
			{
				image.sprite = sprites[currentFrame];
			}
		}
	}
	public class ModCompatabilities
	{
		public class RiskOfOptionsCompatability
		{
			public const string GUID = "com.rune580.riskofoptions";

			public static void AddConfig<T>(ConfigEntry<T> config)
			{
				//IL_0015: Unknown result type (might be due to invalid IL or missing references)
				//IL_001f: Expected O, but got Unknown
				if (config is ConfigEntry<float>)
				{
					ModSettingsManager.AddOption((BaseOption)new FloatFieldOption(config as ConfigEntry<float>));
				}
			}
		}
	}
}