using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
using YrellisLantern.Patches;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("YrellisLantern")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("The cutest lantern at your disposal")]
[assembly: AssemblyFileVersion("1.0.2.0")]
[assembly: AssemblyInformationalVersion("1.0.2")]
[assembly: AssemblyProduct("YrellisLantern")]
[assembly: AssemblyTitle("YrellisLantern")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.2.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
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 YrellisLantern
{
[BepInPlugin("YrellisLantern", "Yrellis Lantern", "1.0.2")]
public class Plugin : BaseUnityPlugin
{
private const string pluginName = "Yrellis Lantern";
private readonly Harmony harmony = new Harmony("YrellisLantern");
private static Plugin Instance;
internal static ManualLogSource Logger;
internal static AssetBundle YrellisBundle;
internal static Mesh YrellisLanternMesh;
internal static AudioClip YrellisLanternSound;
private void Awake()
{
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
Logger = ((BaseUnityPlugin)this).Logger;
Logger.LogInfo((object)"Yrellis Lantern v1.0.2 is loaded successfully! UwU");
harmony.PatchAll(typeof(Plugin));
harmony.PatchAll(typeof(StartOfRoundPatch));
harmony.PatchAll(typeof(NetworkSpawnManagerPatch));
string location = ((BaseUnityPlugin)Instance).Info.Location;
location = location.TrimEnd("YrellisLantern.dll".ToCharArray());
YrellisBundle = AssetBundle.LoadFromFile(location + "yrellis");
if ((Object)(object)YrellisBundle != (Object)null)
{
YrellisLanternMesh = YrellisBundle.LoadAsset<Mesh>("yrellislantern.fbx");
YrellisLanternSound = YrellisBundle.LoadAsset<AudioClip>("wahwahwah.wav");
if ((Object)(object)YrellisLanternMesh != (Object)null && (Object)(object)YrellisLanternSound != (Object)null)
{
Logger.LogInfo((object)"Everything goes according to keikaku!");
}
}
}
public static void PerformPumpkinSwap()
{
GameObject val = GameObject.Find("PumpkinMesh");
if (!((Object)(object)val != (Object)null))
{
return;
}
MeshFilter component = val.GetComponent<MeshFilter>();
if (!((Object)(object)component != (Object)null) || !(((Object)component.mesh).name == "Sphere Instance"))
{
return;
}
component.mesh = YrellisLanternMesh;
GameObject gameObject = ((Component)val.transform.parent).gameObject;
GameObject gameObject2 = ((Component)gameObject.transform.Find("HitPumpkinTrigger")).gameObject;
if ((Object)(object)gameObject2 != (Object)null)
{
AudioSource component2 = gameObject2.GetComponent<AudioSource>();
if ((Object)(object)component2 != (Object)null)
{
component2.volume = 0.4f;
}
InteractTrigger component3 = gameObject2.GetComponent<InteractTrigger>();
component3.hoverTip = "Pat Yrellis : [LMB]";
AnimatedObjectTrigger component4 = gameObject2.GetComponent<AnimatedObjectTrigger>();
component4.boolFalseAudios[0] = YrellisLanternSound;
}
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "YrellisLantern";
public const string PLUGIN_NAME = "YrellisLantern";
public const string PLUGIN_VERSION = "1.0.2";
}
}
namespace YrellisLantern.Patches
{
[HarmonyPatch(typeof(NetworkSpawnManager))]
internal class NetworkSpawnManagerPatch
{
[HarmonyPatch("SpawnNetworkObjectLocallyCommon")]
[HarmonyPostfix]
private static void OverridePumpkinOnClientSpawn(NetworkSpawnManager __instance, NetworkObject networkObject)
{
if (((Object)networkObject).name == "PumpkinUnlockableContainer(Clone)")
{
Plugin.PerformPumpkinSwap();
}
}
}
[HarmonyPatch(typeof(StartOfRound))]
internal class StartOfRoundPatch
{
[HarmonyPatch("SpawnUnlockable")]
[HarmonyPostfix]
private static void OverridePumpkinOnServerSpawn(StartOfRound __instance, int unlockableIndex, UnlockablesList ___unlockablesList)
{
string unlockableName = ___unlockablesList.unlockables[unlockableIndex].unlockableName;
if (unlockableName == "JackOLantern")
{
Plugin.PerformPumpkinSwap();
}
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}