Decompiled source of UpturnedVariety v2.2.0

UpturnedVariety.dll

Decompiled 6 days ago
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.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using LobbyCompatibility.Enums;
using LobbyCompatibility.Features;
using Microsoft.CodeAnalysis;
using TMPro;
using Unity.Netcode;
using UnityEngine;
using UpturnedVariety.Defs.Items;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("UpturnedVariety")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Includes some assets from The Upturned for vanilla-friendly variety")]
[assembly: AssemblyFileVersion("2.2.0.0")]
[assembly: AssemblyInformationalVersion("2.2.0+6496fa70b5bb4a5f7ae9f893269d4ab9d81e0783")]
[assembly: AssemblyProduct("UpturnedVariety")]
[assembly: AssemblyTitle("UpturnedVariety")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.2.0.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
{
	internal static class LobbyCompatibility
	{
		internal static void Init()
		{
			PluginHelper.RegisterPlugin("butterystancakes.lethalcompany.upturnedvariety", Version.Parse("2.2.0"), (CompatibilityLevel)0, (VersionStrictness)0);
		}
	}
	[BepInPlugin("butterystancakes.lethalcompany.upturnedvariety", "Upturned Variety", "2.2.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		internal const string PLUGIN_GUID = "butterystancakes.lethalcompany.upturnedvariety";

		internal const string PLUGIN_NAME = "Upturned Variety";

		internal const string PLUGIN_VERSION = "2.2.0";

		internal static ManualLogSource Logger;

		private const string GUID_LOBBY_COMPATIBILITY = "BMX.LobbyCompatibility";

		private const string GUID_GENERAL_IMPROVEMENTS = "ShaosilGaming.GeneralImprovements";

		internal static ConfigEntry<bool> configBoombox;

		internal static ConfigEntry<bool> configRecord;

		internal static AudioClip boombox;

		internal static AudioClip collectChocolateBar;

		internal static AudioClip collectedAllChocolateBarsJingle;

		internal static AudioClip hauntedRecordPlayer1;

		internal static bool INSTALLED_GENERAL_IMPROVEMENTS;

		private void Awake()
		{
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			Logger = ((BaseUnityPlugin)this).Logger;
			if (Chainloader.PluginInfos.ContainsKey("BMX.LobbyCompatibility"))
			{
				Logger.LogInfo((object)"CROSS-COMPATIBILITY - Lobby Compatibility detected");
				LobbyCompatibility.Init();
			}
			if (Chainloader.PluginInfos.ContainsKey("ShaosilGaming.GeneralImprovements"))
			{
				INSTALLED_GENERAL_IMPROVEMENTS = true;
				Logger.LogInfo((object)"CROSS-COMPATIBILITY - GeneralImprovements detected");
			}
			configBoombox = ((BaseUnityPlugin)this).Config.Bind<bool>("Items", "Boombox", true, "Enables alternate models for the \"Boombox\" item.");
			configRecord = ((BaseUnityPlugin)this).Config.Bind<bool>("Furniture", "RecordPlayer", true, "Enables alternate tracks for the \"Record player\" furniture.");
			SkinManager.LoadAllConfigs(((BaseUnityPlugin)this).Config);
			try
			{
				AssetBundle obj = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "upturnedvariety"));
				boombox = obj.LoadAsset<AudioClip>("Boombox");
				collectChocolateBar = obj.LoadAsset<AudioClip>("CollectChocolateBar");
				collectedAllChocolateBarsJingle = obj.LoadAsset<AudioClip>("CollectedAllChocolateBarsJingle");
				hauntedRecordPlayer1 = obj.LoadAsset<AudioClip>("HauntedRecordPlayer1");
				SkinManager.LoadAllSkins(obj);
				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 v2.2.0 loaded");
		}
	}
	[HarmonyPatch]
	internal class UpturnedVarietyPatches
	{
		private static readonly Color SHINY_BOOMBOX = new Color(0.5799929f, 0.5799929f, 0.5799929f);

		private static StartMatchLever _startMatchLever;

		private static Random recordRandom;

		private static AnimatedObjectTrigger recordPlayerTrigger;

		private static AudioClip recordPlayerJazz;

		private static float recordDoppler;

		private static float recordVolume;

		private static StartMatchLever StartMatchLever
		{
			get
			{
				if ((Object)(object)_startMatchLever == (Object)null)
				{
					_startMatchLever = Object.FindAnyObjectByType<StartMatchLever>();
				}
				return _startMatchLever;
			}
		}

		[HarmonyPatch(typeof(StartOfRound), "Awake")]
		[HarmonyPostfix]
		private static void StartOfRound_Post_Awake(StartOfRound __instance)
		{
			if ((Object)(object)Plugin.boombox != (Object)null)
			{
				Item val = ((IEnumerable<Item>)__instance.allItemsList.itemsList).FirstOrDefault((Func<Item, bool>)((Item item) => ((Object)item).name == "Boombox" && item.itemId == 9));
				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.LogDebug((object)"Loaded Upturned track into Boombox");
					}
				}
			}
			SkinManager.Reset();
		}

		[HarmonyPatch(typeof(RoundManager), "SyncScrapValuesClientRpc")]
		[HarmonyPostfix]
		private static void RoundManager_Post_SyncScrapValuesClientRpc(NetworkObjectReference[] spawnedScrap)
		{
			SkinManager.ApplySkinsToItems(spawnedScrap);
		}

		[HarmonyPatch(typeof(GrabbableObject), "Start")]
		[HarmonyPostfix]
		private static void GrabbableObject_Post_Start(GrabbableObject __instance)
		{
			if (((Object)__instance.itemProperties).name == "FishTestProp" && (Object)(object)__instance.mainObjectRenderer != (Object)null)
			{
				SkinManager.fish.Add((Renderer)(object)__instance.mainObjectRenderer);
			}
		}

		[HarmonyPatch(typeof(GrabbableObject), "SetControlTipsForItem")]
		[HarmonyPostfix]
		private static void GrabbableObject_Post_SetControlTipsForItem(GrabbableObject __instance)
		{
			SubstituteItemName substituteItemName = default(SubstituteItemName);
			if (((Component)__instance).TryGetComponent<SubstituteItemName>(ref substituteItemName))
			{
				((TMP_Text)HUDManager.Instance.controlTipLines[0]).SetText(((TMP_Text)HUDManager.Instance.controlTipLines[0]).text.Replace(__instance.itemProperties.itemName, substituteItemName.subName), true);
			}
			if (!((Object)(object)((Component)__instance).GetComponent<UnusableItem>() != (Object)null))
			{
				return;
			}
			for (int i = 0; i < HUDManager.Instance.controlTipLines.Length; i++)
			{
				if (((TMP_Text)HUDManager.Instance.controlTipLines[i]).text.StartsWith("Use"))
				{
					((TMP_Text)HUDManager.Instance.controlTipLines[i]).SetText(string.Empty, true);
				}
			}
		}

		[HarmonyPatch(typeof(BoomboxItem), "Start")]
		[HarmonyPostfix]
		private static void BoomboxItem_Post_Start(BoomboxItem __instance)
		{
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			NetworkObject val = default(NetworkObject);
			if (Plugin.configBoombox.Value && !((Object)(object)((GrabbableObject)__instance).mainObjectRenderer == (Object)null) && !((Object)(object)StartMatchLever == (Object)null) && StartMatchLever.leverHasBeenPulled && ((Component)__instance).TryGetComponent<NetworkObject>(ref val) && new Random(StartOfRound.Instance.randomMapSeed * (int)val.NetworkObjectId).NextDouble() >= 0.5)
			{
				Material[] materials = ((Renderer)((GrabbableObject)__instance).mainObjectRenderer).materials;
				materials[3].SetColor("_Color", SHINY_BOOMBOX);
				materials[3].SetColor("_BaseColor", SHINY_BOOMBOX);
				materials[3].SetFloat("_Metallic", 0.6833333f);
				materials[3].SetFloat("_Smoothness", 0.275f);
				((Renderer)((GrabbableObject)__instance).mainObjectRenderer).materials = materials;
			}
		}

		[HarmonyPatch(typeof(RoundManager), "DespawnPropsAtEndOfRound")]
		[HarmonyPostfix]
		private static void RoundManager_Post_DespawnPropsAtEndOfRound()
		{
			SkinManager.chocolates.Clear();
			recordRandom = new Random(StartOfRound.Instance.randomMapSeed + 3232022);
		}

		[HarmonyPatch(typeof(HUDManager), "AddNewScrapFoundToDisplay")]
		[HarmonyPostfix]
		private static void HUDManager_Post_AddNewScrapFoundToDisplay(GrabbableObject GObject)
		{
			if (SkinManager.chocolates.Count > 0 && SkinManager.chocolates.Contains(GObject))
			{
				SkinManager.chocolates.Remove(GObject);
				HUDManager.Instance.UIAudio.PlayOneShot(Plugin.collectChocolateBar);
				if (SkinManager.chocolates.Count < 1)
				{
					HUDManager.Instance.UIAudio.PlayOneShot(Plugin.collectedAllChocolateBarsJingle);
				}
			}
		}

		[HarmonyPatch(typeof(GrabbableObject), "EquipItem")]
		[HarmonyPostfix]
		private static void GrabbableObject_Post_EquipItem(GrabbableObject __instance)
		{
			if (((NetworkBehaviour)__instance).IsOwner && SkinManager.chocolates.Contains(__instance))
			{
				Transform obj = ((Component)__instance).transform.Find("Jingle");
				AudioSource val = ((obj != null) ? ((Component)obj).GetComponent<AudioSource>() : null);
				if ((Object)(object)val != (Object)null)
				{
					val.Stop();
					val.pitch = Random.Range(1.6f, 2.3f);
					val.Play();
				}
			}
		}

		[HarmonyPatch(typeof(AnimatedObjectTrigger), "PlayAudio")]
		[HarmonyPrefix]
		private static void AnimatedObjectTrigger_Pre_PlayAudio(AnimatedObjectTrigger __instance)
		{
			if ((!Plugin.configRecord.Value && (Object)(object)recordPlayerTrigger == (Object)null) || (Object)(object)GameNetworkManager.Instance?.localPlayerController == (Object)null || (Object)(object)__instance.thisAudioSource == (Object)null || (Object)(object)__instance.playWhileTrue == (Object)null || (Object)(object)Plugin.hauntedRecordPlayer1 == (Object)null)
			{
				return;
			}
			if ((Object)(object)recordPlayerTrigger == (Object)null && (Object)(object)__instance.triggerAnimator != (Object)null && ((Object)__instance.triggerAnimator).name.StartsWith("RecordPlayerContainer"))
			{
				recordPlayerTrigger = __instance;
				if ((Object)(object)recordPlayerJazz == (Object)null)
				{
					recordPlayerJazz = __instance.playWhileTrue;
					recordDoppler = __instance.thisAudioSource.dopplerLevel;
					recordVolume = __instance.thisAudioSource.volume;
				}
			}
			if (!((Object)(object)__instance == (Object)(object)recordPlayerTrigger) || recordRandom == null)
			{
				return;
			}
			AudioClip val = ((Plugin.configRecord.Value && recordRandom.NextDouble() < 0.5) ? Plugin.hauntedRecordPlayer1 : recordPlayerJazz);
			if (!((Object)(object)__instance.thisAudioSource.clip == (Object)(object)val))
			{
				__instance.playWhileTrue = val;
				if ((Object)(object)val == (Object)(object)Plugin.hauntedRecordPlayer1)
				{
					__instance.thisAudioSource.dopplerLevel = 1.78f;
					__instance.thisAudioSource.volume = recordVolume * 0.5f;
					Plugin.Logger.LogDebug((object)"Loaded Upturned track into Record player");
				}
				else
				{
					__instance.thisAudioSource.dopplerLevel = recordDoppler;
					__instance.thisAudioSource.volume = recordVolume;
					Plugin.Logger.LogDebug((object)"Loaded default track into Record player");
				}
				__instance.audioTime = 0f;
			}
		}

		[HarmonyPatch(typeof(StartOfRound), "Start")]
		[HarmonyPostfix]
		private static void StartOfRound_Post_Start(StartOfRound __instance)
		{
			recordRandom = new Random(__instance.randomMapSeed + 3232022);
		}

		[HarmonyPatch(typeof(StartOfRound), "OnPlayerConnectedClientRpc")]
		[HarmonyPostfix]
		private static void StartOfRound_Post_OnPlayerConnectedClientRpc(StartOfRound __instance)
		{
			recordRandom = new Random(__instance.randomMapSeed + 3232022);
		}

		[HarmonyPatch(typeof(TimeOfDay), "SyncTimeClientRpc")]
		[HarmonyPostfix]
		private static void TimeOfDay_Post_SyncTimeClientRpc(TimeOfDay __instance)
		{
			recordRandom = new Random(StartOfRound.Instance.randomMapSeed + 3232022 / __instance.RoundUpToNearestTen(__instance.globalTime));
		}
	}
	internal static class SharedPalette
	{
		internal static readonly Color RUBBER_HANDLE_UPTURNED = new Color(0.01842319f, 0.01562534f, 0.01562534f);

		internal static readonly Color DARK_STEEL_UPTURNED = new Color(0.2547169f, 0.2547169f, 0.2547169f);
	}
	internal static class SkinManager
	{
		private static readonly List<IUpturnedItem> allSkinnedItems = new List<IUpturnedItem>(11)
		{
			new UpturnedGiftBox(),
			new UpturnedCandy(),
			new UpturnedCashRegister(),
			new UpturnedPerfume(),
			new UpturnedPills(),
			new UpturnedMug(),
			new UpturnedControlPad(),
			new UpturnedFish(),
			new UpturnedSteeringWheel(),
			new UpturnedPickles(),
			new UpturnedLamp()
		};

		private static HashSet<ulong> cache = new HashSet<ulong>();

		private static Random random;

		internal static List<Renderer> fish = new List<Renderer>();

		internal static List<GrabbableObject> chocolates = new List<GrabbableObject>();

		internal static void LoadAllConfigs(ConfigFile cfg)
		{
			foreach (IUpturnedItem allSkinnedItem in allSkinnedItems)
			{
				allSkinnedItem.LoadConfigs(cfg);
			}
		}

		internal static void LoadAllSkins(AssetBundle bundle)
		{
			foreach (IUpturnedItem allSkinnedItem in allSkinnedItems)
			{
				allSkinnedItem.LoadSkins(bundle);
			}
		}

		internal static void Reset()
		{
			cache.Clear();
			fish.Clear();
			chocolates.Clear();
		}

		internal static void ApplySkinsToItems(NetworkObjectReference[] netRefs)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			random = new Random(StartOfRound.Instance.randomMapSeed + 32322);
			NetworkObject val2 = default(NetworkObject);
			GrabbableObject item = default(GrabbableObject);
			for (int i = 0; i < netRefs.Length; i++)
			{
				NetworkObjectReference val = netRefs[i];
				if (!((NetworkObjectReference)(ref val)).TryGet(ref val2, (NetworkManager)null) || !cache.Add(val2.NetworkObjectId) || !((Component)val2).TryGetComponent<GrabbableObject>(ref item))
				{
					continue;
				}
				IUpturnedItem upturnedItem = allSkinnedItems.FirstOrDefault((IUpturnedItem skin) => skin.GetItemName() == ((Object)item.itemProperties).name);
				if (upturnedItem != null)
				{
					int[] randomData = upturnedItem.GetRandomData();
					int[] array = new int[randomData.Length];
					for (int j = 0; j < randomData.Length; j++)
					{
						array[j] = random.Next(randomData[j]);
					}
					if (upturnedItem.MatchToVanillaItem(item))
					{
						upturnedItem.ApplySkin(item, array);
					}
				}
			}
		}

		internal static bool IsThereABanana()
		{
			bool flag = false;
			bool result = false;
			for (int i = 0; i < fish.Count; i++)
			{
				if ((Object)(object)fish[i] == (Object)null)
				{
					flag = true;
				}
				else if (fish[i].sharedMaterials != null && fish[i].sharedMaterials.Length == 3)
				{
					result = true;
				}
			}
			if (flag)
			{
				fish.RemoveAll((Renderer x) => x == null);
			}
			return result;
		}
	}
	public class SubstituteItemName : MonoBehaviour
	{
		public string subName;
	}
	public class UnusableItem : MonoBehaviour
	{
		private GrabbableObject item;

		private void LateUpdate()
		{
			if ((Object)(object)item == (Object)null)
			{
				item = ((Component)this).GetComponent<GrabbableObject>();
				if ((Object)(object)item == (Object)null)
				{
					((Behaviour)this).enabled = false;
				}
				else
				{
					item.useCooldown = 50f;
				}
			}
			else
			{
				item.currentUseCooldown = item.useCooldown;
			}
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "UpturnedVariety";

		public const string PLUGIN_NAME = "UpturnedVariety";

		public const string PLUGIN_VERSION = "2.2.0";
	}
}
namespace UpturnedVariety.Defs.Items
{
	internal interface IUpturnedItem
	{
		internal string GetItemName();

		internal int[] GetRandomData();

		internal void LoadConfigs(ConfigFile cfg);

		internal void LoadSkins(AssetBundle bundle);

		internal bool MatchToVanillaItem(GrabbableObject item);

		internal void ApplySkin(GrabbableObject item, int[] rand);
	}
	internal class UpturnedCandy : IUpturnedItem
	{
		private static readonly Color CANDY_WRAPPER = new Color(0.4528301f, 0.03396226f, 0f);

		private static readonly Color WRAPPER_FOIL = new Color(0.3584906f, 0.3584906f, 0.3584906f);

		private static readonly Color CHOCOLATE = new Color(0.1792453f, 0.07193222f, 0.03973834f);

		private static ConfigEntry<bool> enableTextures;

		private static ConfigEntry<bool> enableMeshes;

		private static ConfigEntry<int> chocolateChance;

		private static Material lollyPop;

		private static Material lightWood;

		private static Material candyPink;

		private static Material chocolateLabel;

		private static Material barcode;

		private static Mesh cylinder;

		private static Mesh sucker;

		private static Mesh cube;

		private static AudioClip chocolateBarJingle;

		public string GetItemName()
		{
			return "Candy";
		}

		public int[] GetRandomData()
		{
			return new int[3] { 2, 2, 100 };
		}

		public void LoadConfigs(ConfigFile cfg)
		{
			enableTextures = cfg.Bind<bool>("Items", "Candy", true, "Enables alternate palettes for the \"Candy\" item.");
			enableMeshes = cfg.Bind<bool>("Items", "CandyModels", true, "Enables alternate models for the \"Candy\" item.");
			chocolateChance = cfg.Bind<int>("Items", "Chocolate", 20, "Chance (in percentage) for the \"Candy\" item to be replaced with a \"Chocolate bar\" collectible.");
		}

		public void LoadSkins(AssetBundle bundle)
		{
			lollyPop = bundle.LoadAsset<Material>("LollyPop");
			lightWood = bundle.LoadAsset<Material>("LightWood");
			candyPink = bundle.LoadAsset<Material>("CandyPink");
			chocolateLabel = bundle.LoadAsset<Material>("chocolateLabel");
			barcode = bundle.LoadAsset<Material>("barcode");
			cylinder = bundle.LoadAsset<Mesh>("Cylinder.001");
			sucker = bundle.LoadAsset<Mesh>("Sucker");
			cube = bundle.LoadAsset<Mesh>("Cube");
			chocolateBarJingle = bundle.LoadAsset<AudioClip>("ChocolateBarJingle");
			if ((Object)(object)lollyPop == (Object)null || (Object)(object)lightWood == (Object)null || (Object)(object)candyPink == (Object)null || (Object)(object)cylinder == (Object)null || (Object)(object)sucker == (Object)null || (Object)(object)chocolateLabel == (Object)null || (Object)(object)barcode == (Object)null || (Object)(object)cube == (Object)null || (Object)(object)chocolateBarJingle == (Object)null)
			{
				throw new Exception("Failed to load assets for \"Candy\" item");
			}
		}

		public bool MatchToVanillaItem(GrabbableObject item)
		{
			MeshRenderer mainObjectRenderer = item.mainObjectRenderer;
			if (((mainObjectRenderer != null) ? ((Renderer)mainObjectRenderer).sharedMaterials : null) != null && ((Renderer)item.mainObjectRenderer).sharedMaterials.Length == 2)
			{
				return ((Object)((Renderer)item.mainObjectRenderer).sharedMaterials[0]).name.StartsWith("LollyPop");
			}
			return false;
		}

		public void ApplySkin(GrabbableObject item, int[] rand)
		{
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			if (chocolateChance.Value > 0 && (chocolateChance.Value >= 100 || rand[2] < chocolateChance.Value))
			{
				((Component)item.mainObjectRenderer).GetComponent<MeshFilter>().mesh = cube;
				Material[] array = (Material[])(object)new Material[5]
				{
					Object.Instantiate<Material>(((Renderer)item.mainObjectRenderer).sharedMaterials[0]),
					Object.Instantiate<Material>(((Renderer)item.mainObjectRenderer).sharedMaterials[0]),
					Object.Instantiate<Material>(((Renderer)item.mainObjectRenderer).sharedMaterials[0]),
					chocolateLabel,
					barcode
				};
				array[0].SetColor("_Color", CANDY_WRAPPER);
				array[0].SetColor("_BaseColor", CANDY_WRAPPER);
				array[0].SetFloat("_Metallic", 0f);
				array[0].SetFloat("_Smoothness", 0.733f);
				array[1].SetColor("_Color", WRAPPER_FOIL);
				array[1].SetColor("_BaseColor", WRAPPER_FOIL);
				array[1].SetFloat("_Metallic", 0.692f);
				array[1].SetFloat("_Smoothness", 0.521f);
				array[2].SetColor("_Color", CHOCOLATE);
				array[2].SetColor("_BaseColor", CHOCOLATE);
				array[2].SetFloat("_Metallic", 0.439f);
				array[2].SetFloat("_Smoothness", 0.35f);
				((Renderer)item.mainObjectRenderer).materials = array;
				ScanNodeProperties componentInChildren = ((Component)item).GetComponentInChildren<ScanNodeProperties>();
				if ((Object)(object)componentInChildren != (Object)null)
				{
					componentInChildren.headerText = "Chocolate bar";
				}
				((Component)item).gameObject.AddComponent<SubstituteItemName>().subName = "Chocolate bar";
				GameObject val = new GameObject("Jingle");
				val.AddComponent<AudioSource>().clip = chocolateBarJingle;
				val.transform.SetParent(((Component)item).transform);
				val.transform.SetLocalPositionAndRotation(Vector3.zero, Quaternion.identity);
				val.transform.localScale = Vector3.one;
				if (!SkinManager.chocolates.Contains(item))
				{
					SkinManager.chocolates.Add(item);
				}
				Plugin.Logger.LogDebug((object)$"Candy #{((Component)item).GetComponent<NetworkObject>().NetworkObjectId} becomes chocolate bar");
				return;
			}
			if (enableTextures.Value && rand[0] == 1)
			{
				((Renderer)item.mainObjectRenderer).materials = (Material[])(object)new Material[2] { lollyPop, lightWood };
				Plugin.Logger.LogDebug((object)$"Candy #{((Component)item).GetComponent<NetworkObject>().NetworkObjectId} using alternate texture");
				if (rand[1] == 0)
				{
					((Component)item.mainObjectRenderer).GetComponent<MeshFilter>().mesh = cylinder;
				}
			}
			if (enableMeshes.Value && rand[1] == 1)
			{
				((Component)item.mainObjectRenderer).GetComponent<MeshFilter>().mesh = sucker;
				Plugin.Logger.LogDebug((object)$"Candy #{((Component)item).GetComponent<NetworkObject>().NetworkObjectId} using alternate model");
				if (rand[0] == 0)
				{
					((Renderer)item.mainObjectRenderer).materials = (Material[])(object)new Material[2]
					{
						candyPink,
						((Renderer)item.mainObjectRenderer).sharedMaterials[1]
					};
				}
			}
		}
	}
	internal class UpturnedCashRegister : IUpturnedItem
	{
		private static readonly Color BLUE_COUNTER = new Color(0.08535064f, 0.08980062f, 0.1320755f);

		private static readonly Color BRASS = new Color(0.3867925f, 0.2725252f, 0.2244126f);

		private static ConfigEntry<bool> enableModels;

		private static Mesh cashRegister;

		private static Material steelDoorKnob;

		public string GetItemName()
		{
			return "CashRegister";
		}

		public int[] GetRandomData()
		{
			return new int[1] { 2 };
		}

		public void LoadConfigs(ConfigFile cfg)
		{
			enableModels = cfg.Bind<bool>("Items", "CashRegister", true, "Enables alternate models for the \"Cash register\" item.");
		}

		public void LoadSkins(AssetBundle bundle)
		{
			cashRegister = bundle.LoadAsset<Mesh>("CashRegister");
			steelDoorKnob = bundle.LoadAsset<Material>("SteelDoorKnob");
			if ((Object)(object)cashRegister == (Object)null || (Object)(object)steelDoorKnob == (Object)null)
			{
				throw new Exception("Failed to load assets for \"Cash register\" item");
			}
		}

		public bool MatchToVanillaItem(GrabbableObject item)
		{
			MeshRenderer mainObjectRenderer = item.mainObjectRenderer;
			if ((Object)(object)((mainObjectRenderer != null) ? ((Renderer)mainObjectRenderer).sharedMaterial : null) != (Object)null && ((Object)((Renderer)item.mainObjectRenderer).sharedMaterial).name.StartsWith("CashRegisterMat"))
			{
				NoisemakerProp val = (NoisemakerProp)(object)((item is NoisemakerProp) ? item : null);
				if (val != null)
				{
					return (Object)(object)val.triggerAnimator != (Object)null;
				}
			}
			return false;
		}

		public void ApplySkin(GrabbableObject item, int[] rand)
		{
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			if (!enableModels.Value || rand[0] != 1)
			{
				return;
			}
			((Component)item.mainObjectRenderer).GetComponent<MeshFilter>().mesh = cashRegister;
			Material val = Object.Instantiate<Material>(((Renderer)item.mainObjectRenderer).sharedMaterial);
			val.SetTexture("_MainTex", (Texture)null);
			val.SetTexture("_BaseColorMap", (Texture)null);
			val.SetTexture("_NormalMap", (Texture)null);
			Material[] array = (Material[])(object)new Material[5]
			{
				val,
				Object.Instantiate<Material>(val),
				steelDoorKnob,
				Object.Instantiate<Material>(val),
				Object.Instantiate<Material>(val)
			};
			array[0].SetColor("_Color", BLUE_COUNTER);
			array[0].SetColor("_BaseColor", BLUE_COUNTER);
			array[0].SetFloat("_Metallic", 0f);
			array[0].SetFloat("_Smoothness", 0.5f);
			array[1].SetColor("_Color", SharedPalette.DARK_STEEL_UPTURNED);
			array[1].SetColor("_BaseColor", SharedPalette.DARK_STEEL_UPTURNED);
			array[1].SetFloat("_Metallic", 0.724f);
			array[1].SetFloat("_Smoothness", 0.5f);
			array[3].SetColor("_Color", SharedPalette.RUBBER_HANDLE_UPTURNED);
			array[3].SetColor("_BaseColor", SharedPalette.RUBBER_HANDLE_UPTURNED);
			array[3].SetFloat("_Metallic", 0f);
			array[3].SetFloat("_Smoothness", 0.5f);
			array[4].SetColor("_Color", BRASS);
			array[4].SetColor("_BaseColor", BRASS);
			array[4].SetFloat("_Metallic", 0.78f);
			array[4].SetFloat("_Smoothness", 0.64f);
			((Renderer)item.mainObjectRenderer).materials = array;
			NoisemakerProp val2 = (NoisemakerProp)(object)((item is NoisemakerProp) ? item : null);
			if (val2 != null)
			{
				Renderer[] componentsInChildren = ((Component)val2.triggerAnimator).GetComponentsInChildren<Renderer>();
				foreach (Renderer obj in componentsInChildren)
				{
					obj.forceRenderingOff = true;
					obj.enabled = false;
				}
				((Component)val2).gameObject.AddComponent<UnusableItem>();
			}
			Plugin.Logger.LogDebug((object)$"Register #{((Component)item).GetComponent<NetworkObject>().NetworkObjectId} using alternate model");
		}
	}
	internal class UpturnedControlPad : IUpturnedItem
	{
		private static ConfigEntry<bool> enableTextures;

		private static Texture arcadeControlPanel2;

		public string GetItemName()
		{
			return "ControlPad";
		}

		public int[] GetRandomData()
		{
			return new int[1] { 2 };
		}

		public void LoadConfigs(ConfigFile cfg)
		{
			enableTextures = cfg.Bind<bool>("Items", "ControlPad", true, "Enables alternate palettes for the \"Control pad\" item.");
		}

		public void LoadSkins(AssetBundle bundle)
		{
			arcadeControlPanel2 = bundle.LoadAsset<Texture>("ArcadeControlPanel2");
			if ((Object)(object)arcadeControlPanel2 == (Object)null)
			{
				throw new Exception("Failed to load assets for \"Control pad\" item");
			}
		}

		public bool MatchToVanillaItem(GrabbableObject item)
		{
			Renderer val = default(Renderer);
			if (((Component)item).TryGetComponent<Renderer>(ref val) && (Object)(object)val.sharedMaterial != (Object)null)
			{
				return ((Object)val.sharedMaterial).name.StartsWith("ArcadeControlPanel");
			}
			return false;
		}

		public void ApplySkin(GrabbableObject item, int[] rand)
		{
			if (enableTextures.Value && rand[0] == 1)
			{
				((Component)item).GetComponent<Renderer>().material.mainTexture = arcadeControlPanel2;
				Plugin.Logger.LogDebug((object)$"Controller #{((Component)item).GetComponent<NetworkObject>().NetworkObjectId} using alternate texture");
			}
		}
	}
	internal class UpturnedFish : IUpturnedItem
	{
		private static readonly Color YELLOW_FISH = new Color(0.773024f, 0.8392157f, 0.3692549f);

		private static readonly Color SILVER_FISH = new Color(0.5019608f, 0.1780566f, 0.1556078f);

		private static readonly Color YELLOW_RUBBER = new Color(0.44f, 0.4296874f, 0.2028124f);

		private static readonly Color MATERIAL_001 = new Color(0.3799999f, 0.243271f, 0.1527103f);

		private static ConfigEntry<bool> enableMeshes;

		private static Mesh fish2;

		private static Mesh sardine;

		private static Mesh sardine001;

		public string GetItemName()
		{
			return "FishTestProp";
		}

		public int[] GetRandomData()
		{
			return new int[2] { 4, 3 };
		}

		public void LoadConfigs(ConfigFile cfg)
		{
			enableMeshes = cfg.Bind<bool>("Items", "Fish", true, "Enables alternate models for the \"Plastic fish\" item.");
		}

		public void LoadSkins(AssetBundle bundle)
		{
			fish2 = bundle.LoadAsset<Mesh>("Fish2");
			sardine = bundle.LoadAsset<Mesh>("Sardine");
			sardine001 = bundle.LoadAsset<Mesh>("Sardine.001");
			if ((Object)(object)fish2 == (Object)null || (Object)(object)sardine == (Object)null || (Object)(object)sardine001 == (Object)null)
			{
				throw new Exception("Failed to load assets for \"Plastic fish\" item");
			}
		}

		public bool MatchToVanillaItem(GrabbableObject item)
		{
			MeshRenderer mainObjectRenderer = item.mainObjectRenderer;
			if (((mainObjectRenderer != null) ? ((Renderer)mainObjectRenderer).sharedMaterials : null) != null && ((Renderer)item.mainObjectRenderer).sharedMaterials.Length == 2)
			{
				return ((Object)((Renderer)item.mainObjectRenderer).sharedMaterials[0]).name.StartsWith("Eye");
			}
			return false;
		}

		public void ApplySkin(GrabbableObject item, int[] rand)
		{
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			if (!enableMeshes.Value)
			{
				return;
			}
			int num = rand[0];
			if (num == 3 && SkinManager.IsThereABanana())
			{
				num = rand[1];
			}
			if (num > 0)
			{
				MeshFilter component = ((Component)item.mainObjectRenderer).GetComponent<MeshFilter>();
				switch (num)
				{
				case 1:
				{
					component.mesh = fish2;
					Material val4 = ((Renderer)item.mainObjectRenderer).materials[1];
					val4.SetColor("_Color", YELLOW_FISH);
					val4.SetColor("_BaseColor", YELLOW_FISH);
					((Renderer)item.mainObjectRenderer).materials = (Material[])(object)new Material[2]
					{
						val4,
						((Renderer)item.mainObjectRenderer).sharedMaterials[0]
					};
					break;
				}
				case 2:
				{
					component.mesh = sardine;
					Material val3 = ((Renderer)item.mainObjectRenderer).materials[1];
					val3.SetColor("_Color", SILVER_FISH);
					val3.SetColor("_BaseColor", SILVER_FISH);
					((Renderer)item.mainObjectRenderer).materials = (Material[])(object)new Material[2]
					{
						((Renderer)item.mainObjectRenderer).sharedMaterials[0],
						val3
					};
					break;
				}
				case 3:
				{
					component.mesh = sardine001;
					Material val = ((Renderer)item.mainObjectRenderer).materials[1];
					Material val2 = Object.Instantiate<Material>(val);
					val.SetColor("_Color", YELLOW_RUBBER);
					val.SetColor("_BaseColor", YELLOW_RUBBER);
					val2.SetColor("_Color", MATERIAL_001);
					val2.SetColor("_BaseColor", MATERIAL_001);
					((Renderer)item.mainObjectRenderer).materials = (Material[])(object)new Material[3]
					{
						((Renderer)item.mainObjectRenderer).sharedMaterials[0],
						val,
						val2
					};
					break;
				}
				}
				Plugin.Logger.LogDebug((object)$"Fish #{((Component)item).GetComponent<NetworkObject>().NetworkObjectId} using alternate model");
			}
		}
	}
	internal class UpturnedGiftBox : IUpturnedItem
	{
		private static ConfigEntry<bool> enableTextures;

		private static Texture giftBoxTex2;

		public string GetItemName()
		{
			return "GiftBox";
		}

		public int[] GetRandomData()
		{
			return new int[1] { 2 };
		}

		public void LoadConfigs(ConfigFile cfg)
		{
			enableTextures = cfg.Bind<bool>("Items", "Gift", true, "Enables alternate palettes for the \"Gift box\" item.");
		}

		public void LoadSkins(AssetBundle bundle)
		{
			giftBoxTex2 = bundle.LoadAsset<Texture>("GiftBoxTex2");
			if ((Object)(object)giftBoxTex2 == (Object)null)
			{
				throw new Exception("Failed to load assets for \"Gift box\" item");
			}
		}

		public bool MatchToVanillaItem(GrabbableObject item)
		{
			if (item is GiftBoxItem)
			{
				return item.itemProperties.itemId == 152767;
			}
			return false;
		}

		public void ApplySkin(GrabbableObject item, int[] rand)
		{
			if (enableTextures.Value && rand[0] == 1)
			{
				((Component)item).GetComponent<Renderer>().material.mainTexture = giftBoxTex2;
				Plugin.Logger.LogDebug((object)$"Gift #{((Component)item).GetComponent<NetworkObject>().NetworkObjectId} using alternate texture");
			}
		}
	}
	internal class UpturnedLamp : IUpturnedItem
	{
		private static readonly Color LAMP_STAND_UPTURNED = new Color(0.2395526f, 0.2213185f, 0.1565525f);

		private static readonly Color LAMPSHADE_LETHAL = new Color(0.513327f, 0.4134762f, 0.3871232f);

		private static readonly Color LAMP_STAND_LETHAL = new Color(0.5266604f, 0.5077859f, 0.4321852f);

		private static readonly Color DARK_STEEL_LETHAL = new Color(0.1733264f, 0.1733264f, 0.1733264f);

		private static ConfigEntry<bool> enableMeshes;

		private static Material lampshade;

		private static Mesh cylinder;

		public string GetItemName()
		{
			return "FancyLamp";
		}

		public int[] GetRandomData()
		{
			return new int[2] { 2, 2 };
		}

		public void LoadConfigs(ConfigFile cfg)
		{
			enableMeshes = cfg.Bind<bool>("Items", "Lamp", true, "Enables alternate models for the \"Fancy lamp\" item.");
		}

		public void LoadSkins(AssetBundle bundle)
		{
			lampshade = bundle.LoadAsset<Material>("Lampshade");
			cylinder = bundle.LoadAsset<Mesh>("Cylinder.000");
			if ((Object)(object)lampshade == (Object)null || (Object)(object)cylinder == (Object)null)
			{
				throw new Exception("Failed to load assets for \"Fancy lamp\" item");
			}
		}

		public bool MatchToVanillaItem(GrabbableObject item)
		{
			if (Plugin.INSTALLED_GENERAL_IMPROVEMENTS && (Object)(object)item.mainObjectRenderer == (Object)null)
			{
				item.mainObjectRenderer = ((Component)item).GetComponent<MeshRenderer>();
			}
			MeshRenderer mainObjectRenderer = item.mainObjectRenderer;
			if ((Object)(object)((mainObjectRenderer != null) ? ((Renderer)mainObjectRenderer).sharedMaterial : null) != (Object)null)
			{
				return ((Object)((Renderer)item.mainObjectRenderer).sharedMaterial).name.StartsWith("FancyLampTex");
			}
			return false;
		}

		public void ApplySkin(GrabbableObject item, int[] rand)
		{
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0229: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0271: Unknown result type (might be due to invalid IL or missing references)
			//IL_0283: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			if (enableMeshes.Value && rand[1] == 1)
			{
				((Component)item.mainObjectRenderer).GetComponent<MeshFilter>().mesh = cylinder;
				Plugin.Logger.LogDebug((object)$"Lamp #{((Component)item).GetComponent<NetworkObject>().NetworkObjectId} using alternate model");
				Material val = Object.Instantiate<Material>(((Renderer)item.mainObjectRenderer).sharedMaterial);
				val.SetTexture("_MainTex", (Texture)null);
				val.SetTexture("_BaseColorMap", (Texture)null);
				Material[] array = (Material[])(object)new Material[4]
				{
					default(Material),
					val,
					Object.Instantiate<Material>(val),
					Object.Instantiate<Material>(val)
				};
				Light componentInChildren = ((Component)item.mainObjectRenderer).GetComponentInChildren<Light>();
				((Component)componentInChildren).transform.localPosition = new Vector3(((Component)componentInChildren).transform.localPosition.x, ((Component)componentInChildren).transform.localPosition.y, 1.626763f);
				if (rand[0] == 0)
				{
					array[0] = lampshade;
					array[1].SetColor("_Color", LAMP_STAND_UPTURNED);
					array[1].SetColor("_BaseColor", LAMP_STAND_UPTURNED);
					array[1].SetFloat("_Metallic", 0.7f);
					array[1].SetFloat("_Smoothness", 0.5f);
					array[2].SetColor("_Color", SharedPalette.RUBBER_HANDLE_UPTURNED);
					array[2].SetColor("_BaseColor", SharedPalette.RUBBER_HANDLE_UPTURNED);
					array[2].SetFloat("_Metallic", 0f);
					array[2].SetFloat("_Smoothness", 0.5f);
					array[3].SetColor("_Color", SharedPalette.DARK_STEEL_UPTURNED);
					array[3].SetColor("_BaseColor", SharedPalette.DARK_STEEL_UPTURNED);
					array[3].SetFloat("_Metallic", 0.724f);
					array[3].SetFloat("_Smoothness", 0.5f);
					componentInChildren.colorTemperature = 4846f;
				}
				else
				{
					array[0] = Object.Instantiate<Material>(val);
					array[0].SetColor("_Color", LAMPSHADE_LETHAL);
					array[0].SetColor("_BaseColor", LAMPSHADE_LETHAL);
					array[0].SetFloat("_Metallic", 0f);
					array[0].SetFloat("_Smoothness", 0.5f);
					array[1].SetColor("_Color", LAMP_STAND_LETHAL);
					array[1].SetColor("_BaseColor", LAMP_STAND_LETHAL);
					array[1].SetFloat("_Metallic", 0.4583333f);
					array[1].SetFloat("_Smoothness", 0.5f);
					array[2].SetColor("_Color", Color.black);
					array[2].SetColor("_BaseColor", Color.black);
					array[2].SetFloat("_Metallic", 0f);
					array[2].SetFloat("_Smoothness", 0.0916667f);
					array[3].SetColor("_Color", DARK_STEEL_LETHAL);
					array[3].SetColor("_BaseColor", DARK_STEEL_LETHAL);
					array[3].SetFloat("_Metallic", 0.3416667f);
					array[3].SetFloat("_Smoothness", 0.55f);
					componentInChildren.colorTemperature = 4412f;
				}
				((Renderer)item.mainObjectRenderer).sharedMaterials = array;
			}
		}
	}
	internal class UpturnedMug : IUpturnedItem
	{
		private static ConfigEntry<bool> enableTextures;

		private static Material coffeeMug6;

		public string GetItemName()
		{
			return "Mug";
		}

		public int[] GetRandomData()
		{
			return new int[1] { 6 };
		}

		public void LoadConfigs(ConfigFile cfg)
		{
			enableTextures = cfg.Bind<bool>("Items", "Mug", true, "Enables alternate palettes for the \"Mug\" item.");
		}

		public void LoadSkins(AssetBundle bundle)
		{
			coffeeMug6 = bundle.LoadAsset<Material>("CoffeeMug6");
			if ((Object)(object)coffeeMug6 == (Object)null)
			{
				throw new Exception("Failed to load assets for \"Mug\" item");
			}
		}

		public bool MatchToVanillaItem(GrabbableObject item)
		{
			MeshRenderer mainObjectRenderer = item.mainObjectRenderer;
			if ((Object)(object)((mainObjectRenderer != null) ? ((Renderer)mainObjectRenderer).sharedMaterial : null) != (Object)null)
			{
				return ((Object)((Renderer)item.mainObjectRenderer).sharedMaterial).name.StartsWith("CoffeeMug");
			}
			return false;
		}

		public void ApplySkin(GrabbableObject item, int[] rand)
		{
			if (enableTextures.Value && rand[0] == 5)
			{
				((Renderer)item.mainObjectRenderer).material = coffeeMug6;
				Plugin.Logger.LogDebug((object)$"Mug #{((Component)item).GetComponent<NetworkObject>().NetworkObjectId} using alternate texture");
			}
		}
	}
	internal class UpturnedPerfume : IUpturnedItem
	{
		private static readonly Color RED = new Color(0.9f, 0.3922666f, 0.324f, 0.6313726f);

		private static readonly Color RED_TRANS = new Color(1f, 0.4f, 0.4f);

		private static readonly Color BLUE = new Color(0.4509091f, 0.416f, 0.8f, 0.6313726f);

		private static readonly Color BLUE_TRANS = new Color(0.59f, 0.6241666f, 1f);

		private static readonly Color BLACK = new Color(0.01f, 0.01f, 0.01f, 0.6313726f);

		private static readonly Color BLACK_TRANS = new Color(0.48f, 0.48f, 0.48f);

		private static ConfigEntry<bool> enableTextures;

		private static ConfigEntry<bool> enableMeshes;

		private static Mesh[] meshes;

		public string GetItemName()
		{
			return "PerfumeBottle";
		}

		public int[] GetRandomData()
		{
			return new int[2] { 4, 6 };
		}

		public void LoadConfigs(ConfigFile cfg)
		{
			enableTextures = cfg.Bind<bool>("Items", "Perfume", true, "Enables alternate palettes for the \"Perfume bottle\" item.");
			enableMeshes = cfg.Bind<bool>("Items", "PerfumeModels", true, "Enables alternate models for the \"Perfume bottle\" item.");
		}

		public void LoadSkins(AssetBundle bundle)
		{
			meshes = (Mesh[])(object)new Mesh[5]
			{
				bundle.LoadAsset<Mesh>("PerfumeBottle_001"),
				bundle.LoadAsset<Mesh>("PerfumeBottle_002"),
				bundle.LoadAsset<Mesh>("PerfumeBottle_003"),
				bundle.LoadAsset<Mesh>("PerfumeBottle_004"),
				bundle.LoadAsset<Mesh>("PerfumeBottle_005")
			};
			if (meshes.Any((Mesh mesh) => mesh == null))
			{
				throw new Exception("Failed to load assets for \"Perfume bottle\" item");
			}
		}

		public bool MatchToVanillaItem(GrabbableObject item)
		{
			MeshRenderer mainObjectRenderer = item.mainObjectRenderer;
			if (((mainObjectRenderer != null) ? ((Renderer)mainObjectRenderer).sharedMaterials : null) != null && ((Renderer)item.mainObjectRenderer).sharedMaterials.Length == 2)
			{
				return ((Object)((Renderer)item.mainObjectRenderer).sharedMaterials[0]).name.StartsWith("Material.004");
			}
			return false;
		}

		public void ApplySkin(GrabbableObject item, int[] rand)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			if (enableTextures.Value && rand[0] > 0)
			{
				Color val = default(Color);
				Color val2 = default(Color);
				switch (rand[0])
				{
				case 1:
					val = RED;
					val2 = RED_TRANS;
					break;
				case 2:
					val = BLUE;
					val2 = BLUE_TRANS;
					break;
				case 3:
					val = BLACK;
					val2 = BLACK_TRANS;
					break;
				}
				Material val3 = ((Renderer)item.mainObjectRenderer).materials[0];
				val3.SetColor("_Color", val);
				val3.SetColor("_BaseColor", val);
				val3.SetColor("_TransmittanceColor", val2);
				((Renderer)item.mainObjectRenderer).materials = (Material[])(object)new Material[2]
				{
					val3,
					((Renderer)item.mainObjectRenderer).sharedMaterials[1]
				};
				Plugin.Logger.LogDebug((object)$"Perfume #{((Component)item).GetComponent<NetworkObject>().NetworkObjectId} using alternate color");
			}
			if (enableMeshes.Value && rand[1] > 0 && rand[1] <= meshes.Length)
			{
				((Component)item.mainObjectRenderer).GetComponent<MeshFilter>().mesh = meshes[rand[1] - 1];
				Plugin.Logger.LogDebug((object)$"Perfume #{((Component)item).GetComponent<NetworkObject>().NetworkObjectId} using alternate model");
			}
		}
	}
	internal class UpturnedPickles : IUpturnedItem
	{
		private static ConfigEntry<bool> enableMeshes;

		private static Material glassCase;

		private static Material displayCasePlastic;

		private static Mesh glassJar;

		private static GameObject candyGlob;

		public string GetItemName()
		{
			return "PickleJar";
		}

		public int[] GetRandomData()
		{
			return new int[1] { 2 };
		}

		public void LoadConfigs(ConfigFile cfg)
		{
			enableMeshes = cfg.Bind<bool>("Items", "Pickles", true, "Enables \"Candy jar\" replacement for the \"Jar of pickles\" item.");
		}

		public void LoadSkins(AssetBundle bundle)
		{
			glassJar = bundle.LoadAsset<Mesh>("GlassJar");
			glassCase = bundle.LoadAsset<Material>("GlassCase");
			displayCasePlastic = bundle.LoadAsset<Material>("DisplayCasePlastic");
			candyGlob = bundle.LoadAsset<GameObject>("CandyGlob");
			if ((Object)(object)glassJar == (Object)null || (Object)(object)glassCase == (Object)null || (Object)(object)displayCasePlastic == (Object)null || (Object)(object)candyGlob == (Object)null)
			{
				throw new Exception("Failed to load assets for \"Jar of pickles\" item");
			}
		}

		public bool MatchToVanillaItem(GrabbableObject item)
		{
			Renderer val = default(Renderer);
			if (((Component)item).TryGetComponent<Renderer>(ref val) && val.sharedMaterials != null && val.sharedMaterials.Length == 2 && ((Object)val.sharedMaterials[0]).name.StartsWith("JarGlass"))
			{
				return (Object)(object)((Component)item).transform.Find("Pickles.001") != (Object)null;
			}
			return false;
		}

		public void ApplySkin(GrabbableObject item, int[] rand)
		{
			if (enableMeshes.Value && rand[0] == 1)
			{
				((Component)((Component)item).transform.Find("Pickles.001")).gameObject.SetActive(false);
				((Component)item).GetComponent<MeshFilter>().mesh = glassJar;
				((Component)item).GetComponent<Renderer>().materials = (Material[])(object)new Material[2] { glassCase, displayCasePlastic };
				Object.Instantiate<GameObject>(candyGlob, ((Component)item).transform);
				ScanNodeProperties componentInChildren = ((Component)item).GetComponentInChildren<ScanNodeProperties>();
				if ((Object)(object)componentInChildren != (Object)null)
				{
					componentInChildren.headerText = "Candy filled jar";
				}
				((Component)item).gameObject.AddComponent<SubstituteItemName>().subName = "Candy jar";
				Plugin.Logger.LogDebug((object)$"Pickles #{((Component)item).GetComponent<NetworkObject>().NetworkObjectId} is alternate");
			}
		}
	}
	internal class UpturnedPills : IUpturnedItem
	{
		private static ConfigEntry<bool> enableTextures;

		private static Texture pillBottleTextureB2;

		public string GetItemName()
		{
			return "PillBottle";
		}

		public int[] GetRandomData()
		{
			return new int[1] { 2 };
		}

		public void LoadConfigs(ConfigFile cfg)
		{
			enableTextures = cfg.Bind<bool>("Items", "Pills", true, "Enables alternate palettes for the \"Pill bottle\" item.");
		}

		public void LoadSkins(AssetBundle bundle)
		{
			pillBottleTextureB2 = bundle.LoadAsset<Texture>("PillBottleTextureB2");
			if ((Object)(object)pillBottleTextureB2 == (Object)null)
			{
				throw new Exception("Failed to load assets for \"Pill bottle\" item");
			}
		}

		public bool MatchToVanillaItem(GrabbableObject item)
		{
			MeshRenderer mainObjectRenderer = item.mainObjectRenderer;
			if ((Object)(object)((mainObjectRenderer != null) ? ((Renderer)mainObjectRenderer).sharedMaterial : null) != (Object)null)
			{
				return ((Object)((Renderer)item.mainObjectRenderer).sharedMaterial).name.StartsWith("Material.002");
			}
			return false;
		}

		public void ApplySkin(GrabbableObject item, int[] rand)
		{
			if (enableTextures.Value && rand[0] == 1)
			{
				((Renderer)item.mainObjectRenderer).material.mainTexture = pillBottleTextureB2;
				Plugin.Logger.LogDebug((object)$"Pills #{((Component)item).GetComponent<NetworkObject>().NetworkObjectId} using alternate texture");
			}
		}
	}
	internal class UpturnedSteeringWheel : IUpturnedItem
	{
		private static ConfigEntry<bool> enableTextures;

		private static Material darkPlastic;

		public string GetItemName()
		{
			return "SteeringWheel";
		}

		public int[] GetRandomData()
		{
			return new int[1] { 2 };
		}

		public void LoadConfigs(ConfigFile cfg)
		{
			enableTextures = cfg.Bind<bool>("Items", "SteeringWheel", true, "Enables alternate palettes for the \"Steering wheel\" item.");
		}

		public void LoadSkins(AssetBundle bundle)
		{
			darkPlastic = bundle.LoadAsset<Material>("DarkPlastic");
			if ((Object)(object)darkPlastic == (Object)null)
			{
				throw new Exception("Failed to load assets for \"Steering wheel\" item");
			}
		}

		public bool MatchToVanillaItem(GrabbableObject item)
		{
			if ((Object)(object)item.mainObjectRenderer != (Object)null && (Object)(object)((Renderer)item.mainObjectRenderer).sharedMaterial != (Object)null)
			{
				return ((Object)((Renderer)item.mainObjectRenderer).sharedMaterial).name.StartsWith("DirtySmoothSteel");
			}
			return false;
		}

		public void ApplySkin(GrabbableObject item, int[] rand)
		{
			if (enableTextures.Value && rand[0] == 1)
			{
				((Renderer)item.mainObjectRenderer).material = darkPlastic;
				Plugin.Logger.LogDebug((object)$"Wheel #{((Component)item).GetComponent<NetworkObject>().NetworkObjectId} using alternate texture");
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}