using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
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 UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("UpturnedVariety")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Includes some assets from The Upturned for vanilla-friendly variety")]
[assembly: AssemblyFileVersion("1.0.2.0")]
[assembly: AssemblyInformationalVersion("1.0.2+9f01d53b646c0873dc98a2ab33b92f41f1a9782a")]
[assembly: AssemblyProduct("UpturnedVariety")]
[assembly: AssemblyTitle("UpturnedVariety")]
[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 UpturnedVariety
{
[BepInPlugin("butterystancakes.lethalcompany.upturnedvariety", "Upturned Variety", "1.0.2")]
public class Plugin : BaseUnityPlugin
{
private const string PLUGIN_GUID = "butterystancakes.lethalcompany.upturnedvariety";
private const string PLUGIN_NAME = "Upturned Variety";
private const string PLUGIN_VERSION = "1.0.2";
internal static ManualLogSource Logger;
internal static AudioClip boombox;
internal static Texture giftBoxTex2;
private void Awake()
{
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
Logger = ((BaseUnityPlugin)this).Logger;
try
{
AssetBundle obj = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "upturnedvariety"));
boombox = obj.LoadAsset<AudioClip>("Boombox");
giftBoxTex2 = obj.LoadAsset<Texture>("GiftBoxTex2");
obj.Unload(false);
}
catch
{
Logger.LogError((object)"Encountered some error loading asset bundle. Did you install the plugin correctly?");
return;
}
new Harmony("butterystancakes.lethalcompany.upturnedvariety").PatchAll();
Logger.LogInfo((object)"Upturned Variety v1.0.2 loaded");
}
}
[HarmonyPatch]
internal class UpturnedVarietyPatches
{
private static StartMatchLever startMatchLever;
[HarmonyPatch(typeof(StartOfRound), "Awake")]
[HarmonyPostfix]
private static void StartOfRoundPostAwake(StartOfRound __instance)
{
if (!((Object)(object)Plugin.boombox != (Object)null))
{
return;
}
Item val = ((IEnumerable<Item>)__instance.allItemsList.itemsList).FirstOrDefault((Func<Item, bool>)((Item item) => ((Object)item).name == "Boombox"));
if ((Object)(object)val != (Object)null)
{
BoomboxItem component = val.spawnPrefab.GetComponent<BoomboxItem>();
if (Array.IndexOf(component.musicAudios, Plugin.boombox) < 0)
{
component.musicAudios = new List<AudioClip>(component.musicAudios) { Plugin.boombox }.ToArray();
Plugin.Logger.LogInfo((object)"Loaded Upturned track into Boombox");
}
}
}
[HarmonyPatch(typeof(GiftBoxItem), "Start")]
[HarmonyPostfix]
private static void GiftBoxItemPostStart(GiftBoxItem __instance)
{
if ((Object)(object)startMatchLever == (Object)null)
{
startMatchLever = Object.FindObjectOfType<StartMatchLever>();
}
if ((Object)(object)startMatchLever != (Object)null && (Object)(object)Plugin.giftBoxTex2 != (Object)null && startMatchLever.leverHasBeenPulled && new Random((int)((GrabbableObject)__instance).targetFloorPosition.x + (int)((GrabbableObject)__instance).targetFloorPosition.y).NextDouble() > 0.5)
{
((Component)__instance).GetComponent<Renderer>().material.mainTexture = Plugin.giftBoxTex2;
Plugin.Logger.LogInfo((object)$"Gift #{((Object)__instance).GetInstanceID()} using alternate texture");
}
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "UpturnedVariety";
public const string PLUGIN_NAME = "UpturnedVariety";
public const string PLUGIN_VERSION = "1.0.2";
}
}