using System;
using System.Collections;
using System.Collections.Generic;
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 RoR2.ContentManagement;
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.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Main : BaseUnityPlugin
{
[Serializable]
[CompilerGenerated]
private sealed class <>c
{
public static readonly <>c <>9 = new <>c();
public static CollectContentPackProvidersDelegate <>9__10_0;
internal void <Awake>b__10_0(AddContentPackProviderDelegate addContentPackProvider)
{
addContentPackProvider.Invoke((IContentPackProvider)(object)new ContentPacks());
}
}
public const string ModGuid = "com.brynzananas.fnaf2foxyjumpscare";
public const string ModName = "Fnaf 2 Foxy Jumpscare";
public const string ModVer = "1.0.0";
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()
{
//IL_0121: Unknown result type (might be due to invalid IL or missing references)
//IL_0126: Unknown result type (might be due to invalid IL or missing references)
//IL_012c: Expected O, but got Unknown
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"));
NetworkSoundEventDef val = ScriptableObject.CreateInstance<NetworkSoundEventDef>();
val.eventName = "Play_fnaf2foxyjumpscare";
ContentPacks.sounds.Add(val);
object obj = <>c.<>9__10_0;
if (obj == null)
{
CollectContentPackProvidersDelegate val2 = delegate(AddContentPackProviderDelegate addContentPackProvider)
{
addContentPackProvider.Invoke((IContentPackProvider)(object)new ContentPacks());
};
<>c.<>9__10_0 = val2;
obj = (object)val2;
}
ContentManager.collectContentPackProviders += (CollectContentPackProvidersDelegate)obj;
}
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 ContentPacks : IContentPackProvider
{
internal ContentPack contentPack = new ContentPack();
public static List<NetworkSoundEventDef> sounds = new List<NetworkSoundEventDef>();
public string identifier => "com.brynzananas.fnaf2foxyjumpscare.ContentProvider";
public IEnumerator FinalizeAsync(FinalizeAsyncArgs args)
{
args.ReportProgress(1f);
yield break;
}
public IEnumerator GenerateContentPackAsync(GetContentPackAsyncArgs args)
{
ContentPack.Copy(contentPack, args.output);
args.ReportProgress(1f);
yield break;
}
public IEnumerator LoadStaticContentAsync(LoadStaticContentAsyncArgs args)
{
contentPack.identifier = identifier;
contentPack.networkSoundEventDefs.Add(sounds.ToArray());
yield break;
}
}
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>));
}
}
}
}
}