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.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
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.3.2.0")]
[assembly: AssemblyInformationalVersion("1.3.2+b3aab75686f42924c81d4ab45b62edbb0f5914a0")]
[assembly: AssemblyProduct("UpturnedVariety")]
[assembly: AssemblyTitle("UpturnedVariety")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.3.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.3.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.3.2";
internal static ManualLogSource Logger;
internal static ConfigEntry<bool> configGift;
internal static ConfigEntry<bool> configCandy;
internal static ConfigEntry<bool> configPerfume;
internal static ConfigEntry<bool> configPerfumeMeshes;
internal static ConfigEntry<bool> configPills;
internal static ConfigEntry<bool> configMug;
internal static ConfigEntry<bool> configControlPad;
internal static ConfigEntry<bool> configFish;
internal static ConfigEntry<bool> configCandyMeshes;
internal static ConfigEntry<bool> configSteeringWheel;
private void Awake()
{
//IL_0317: Unknown result type (might be due to invalid IL or missing references)
Logger = ((BaseUnityPlugin)this).Logger;
configGift = ((BaseUnityPlugin)this).Config.Bind<bool>("Items", "Gift", true, "Enables alternate palettes for the \"Gift box\" item.");
configCandy = ((BaseUnityPlugin)this).Config.Bind<bool>("Items", "Candy", true, "Enables alternate palettes for the \"Candy\" item.");
configCandyMeshes = ((BaseUnityPlugin)this).Config.Bind<bool>("Items", "CandyModels", true, "Enables alternate models for the \"Candy\" item.");
configPerfume = ((BaseUnityPlugin)this).Config.Bind<bool>("Items", "Perfume", true, "Enables alternate palettes for the \"Perfume bottle\" item.");
configPerfumeMeshes = ((BaseUnityPlugin)this).Config.Bind<bool>("Items", "PerfumeModels", true, "Enables alternate models for the \"Perfume bottle\" item.");
configPills = ((BaseUnityPlugin)this).Config.Bind<bool>("Items", "Pills", true, "Enables alternate palettes for the \"Pill bottle\" item.");
configMug = ((BaseUnityPlugin)this).Config.Bind<bool>("Items", "Mug", true, "Enables alternate palettes for the \"Mug\" item.");
configControlPad = ((BaseUnityPlugin)this).Config.Bind<bool>("Items", "ControlPad", true, "Enables alternate palettes for the \"Control pad\" item.");
configFish = ((BaseUnityPlugin)this).Config.Bind<bool>("Items", "Fish", true, "Enables alternate models for the \"Plastic fish\" item.");
configSteeringWheel = ((BaseUnityPlugin)this).Config.Bind<bool>("Items", "SteeringWheel", true, "Enables alternate palettes for the \"Steering wheel\" item.");
try
{
AssetBundle val = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "upturnedvariety"));
ItemVariety.boombox = val.LoadAsset<AudioClip>("Boombox");
if (configGift.Value)
{
ItemVariety.giftBoxTex2 = val.LoadAsset<Texture>("GiftBoxTex2");
}
if (configCandy.Value)
{
ItemVariety.lollipop2 = val.LoadAsset<Material>("LollyPop");
ItemVariety.lollyStick = val.LoadAsset<Material>("LightWood");
ItemVariety.lollyMesh = val.LoadAsset<Mesh>("Cylinder.001");
if (configCandyMeshes.Value)
{
ItemVariety.sucker = val.LoadAsset<Mesh>("Sucker");
}
}
if (configPerfumeMeshes.Value)
{
ItemVariety.perfumeMeshes = (Mesh[])(object)new Mesh[5]
{
val.LoadAsset<Mesh>("PerfumeBottle_001"),
val.LoadAsset<Mesh>("PerfumeBottle_002"),
val.LoadAsset<Mesh>("PerfumeBottle_003"),
val.LoadAsset<Mesh>("PerfumeBottle_004"),
val.LoadAsset<Mesh>("PerfumeBottle_005")
};
}
if (configPills.Value)
{
ItemVariety.pillBottle2 = val.LoadAsset<Texture>("PillBottleTextureB2");
}
if (configMug.Value)
{
ItemVariety.coffeeMug6 = val.LoadAsset<Material>("CoffeeMug6");
}
if (configControlPad.Value)
{
ItemVariety.controlPad2 = val.LoadAsset<Texture>("ArcadeControlPanel2");
}
if (configFish.Value)
{
ItemVariety.fish2 = val.LoadAsset<Mesh>("Fish2");
ItemVariety.sardine = val.LoadAsset<Mesh>("Sardine");
ItemVariety.sardineBanana = val.LoadAsset<Mesh>("Sardine.001");
}
if (configSteeringWheel.Value)
{
ItemVariety.darkPlastic = val.LoadAsset<Material>("DarkPlastic");
}
val.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.3.2 loaded");
}
}
[HarmonyPatch]
internal class UpturnedVarietyPatches
{
[HarmonyPatch(typeof(StartOfRound), "Awake")]
[HarmonyPostfix]
private static void StartOfRoundPostAwake(StartOfRound __instance)
{
if ((Object)(object)ItemVariety.boombox != (Object)null)
{
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, ItemVariety.boombox) < 0)
{
component.musicAudios = new List<AudioClip>(component.musicAudios) { ItemVariety.boombox }.ToArray();
Plugin.Logger.LogDebug((object)"Loaded Upturned track into Boombox");
}
}
}
ItemVariety.cache.Clear();
}
[HarmonyPatch(typeof(RoundManager), "SyncScrapValuesClientRpc")]
[HarmonyPostfix]
private static void PostSyncScrapValuesClientRpc(RoundManager __instance, NetworkObjectReference[] spawnedScrap)
{
//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
//IL_069a: Unknown result type (might be due to invalid IL or missing references)
//IL_06ab: Unknown result type (might be due to invalid IL or missing references)
//IL_06bc: Unknown result type (might be due to invalid IL or missing references)
//IL_06cd: Unknown result type (might be due to invalid IL or missing references)
//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
//IL_02d7: Unknown result type (might be due to invalid IL or missing references)
//IL_02db: Unknown result type (might be due to invalid IL or missing references)
//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
//IL_02f0: Unknown result type (might be due to invalid IL or missing references)
//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
//IL_030d: Unknown result type (might be due to invalid IL or missing references)
//IL_031a: Unknown result type (might be due to invalid IL or missing references)
//IL_0327: Unknown result type (might be due to invalid IL or missing references)
//IL_075f: Unknown result type (might be due to invalid IL or missing references)
//IL_0770: Unknown result type (might be due to invalid IL or missing references)
//IL_07c4: Unknown result type (might be due to invalid IL or missing references)
//IL_07d5: Unknown result type (might be due to invalid IL or missing references)
ItemVariety.offsets.Clear();
NetworkObject val = default(NetworkObject);
GrabbableObject val2 = default(GrabbableObject);
Renderer val6 = default(Renderer);
MeshFilter val7 = default(MeshFilter);
for (int i = 0; i < spawnedScrap.Length; i++)
{
if (!((NetworkObjectReference)(ref spawnedScrap[i])).TryGet(ref val, (NetworkManager)null) || !ItemVariety.cache.Add(val.NetworkObjectId) || !((Component)val).TryGetComponent<GrabbableObject>(ref val2))
{
continue;
}
if (val2 is GiftBoxItem)
{
ItemVariety.GetSkinIndices(val2);
if (Plugin.configGift.Value && (Object)(object)ItemVariety.giftBoxTex2 != (Object)null && ItemVariety.tex == 1)
{
((Component)val2).GetComponent<Renderer>().material.mainTexture = ItemVariety.giftBoxTex2;
Plugin.Logger.LogDebug((object)$"Gift #{val.NetworkObjectId} using alternate texture");
}
continue;
}
if (((Object)val2.itemProperties).name == "Candy")
{
MeshRenderer mainObjectRenderer = val2.mainObjectRenderer;
if (((mainObjectRenderer != null) ? ((Renderer)mainObjectRenderer).sharedMaterials : null) != null && ((Renderer)val2.mainObjectRenderer).sharedMaterials.Length == 2 && ((Object)((Renderer)val2.mainObjectRenderer).sharedMaterials[0]).name.StartsWith("LollyPop"))
{
ItemVariety.GetSkinIndices(val2, 2, 2);
if (Plugin.configCandy.Value && (Object)(object)ItemVariety.lollipop2 != (Object)null && (Object)(object)ItemVariety.lollyStick != (Object)null && ItemVariety.tex == 1)
{
((Renderer)val2.mainObjectRenderer).materials = (Material[])(object)new Material[2]
{
ItemVariety.lollipop2,
ItemVariety.lollyStick
};
Plugin.Logger.LogDebug((object)$"Candy #{val.NetworkObjectId} using alternate texture");
if (Plugin.configCandyMeshes.Value && ItemVariety.mesh == 1)
{
((Component)val2.mainObjectRenderer).GetComponent<MeshFilter>().mesh = ItemVariety.sucker;
Plugin.Logger.LogDebug((object)$"Candy #{val.NetworkObjectId} using alternate model");
}
else if ((Object)(object)ItemVariety.lollyMesh != (Object)null)
{
((Component)val2.mainObjectRenderer).GetComponent<MeshFilter>().mesh = ItemVariety.lollyMesh;
}
}
continue;
}
}
if (((Object)val2.itemProperties).name == "PerfumeBottle")
{
MeshRenderer mainObjectRenderer2 = val2.mainObjectRenderer;
if (((mainObjectRenderer2 != null) ? ((Renderer)mainObjectRenderer2).sharedMaterials : null) != null && ((Renderer)val2.mainObjectRenderer).sharedMaterials.Length == 2 && ((Object)((Renderer)val2.mainObjectRenderer).sharedMaterials[0]).name.StartsWith("Material.004"))
{
ItemVariety.GetSkinIndices(val2, 4, 6);
if (Plugin.configPerfume.Value && ItemVariety.tex != 0)
{
Color val3 = default(Color);
Color val4 = default(Color);
switch (ItemVariety.tex)
{
case 1:
val3 = ItemVariety.perfumeRed;
val4 = ItemVariety.perfumeRedTrans;
break;
case 2:
val3 = ItemVariety.perfumeBlue;
val4 = ItemVariety.perfumeBlueTrans;
break;
case 3:
val3 = ItemVariety.perfumeBlack;
val4 = ItemVariety.perfumeBlackTrans;
break;
}
Material val5 = ((Renderer)val2.mainObjectRenderer).materials[0];
val5.SetColor("_Color", val3);
val5.SetColor("_BaseColor", val3);
val5.SetColor("_TransmittanceColor", val4);
((Renderer)val2.mainObjectRenderer).materials = (Material[])(object)new Material[2]
{
val5,
((Renderer)val2.mainObjectRenderer).sharedMaterials[1]
};
Plugin.Logger.LogDebug((object)$"Perfume #{val.NetworkObjectId} using alternate texture");
}
if (Plugin.configPerfumeMeshes.Value && ItemVariety.perfumeMeshes != null && ItemVariety.perfumeMeshes.Length >= 5 && ItemVariety.mesh != 0)
{
((Component)val2.mainObjectRenderer).GetComponent<MeshFilter>().mesh = ItemVariety.perfumeMeshes[ItemVariety.mesh - 1];
Plugin.Logger.LogDebug((object)$"Perfume #{val.NetworkObjectId} using alternate model");
}
continue;
}
}
if (((Object)val2.itemProperties).name == "PillBottle")
{
MeshRenderer mainObjectRenderer3 = val2.mainObjectRenderer;
if ((Object)(object)((mainObjectRenderer3 != null) ? ((Renderer)mainObjectRenderer3).sharedMaterial : null) != (Object)null && ((Object)((Renderer)val2.mainObjectRenderer).sharedMaterial).name.StartsWith("Material.002"))
{
ItemVariety.GetSkinIndices(val2);
if (Plugin.configPills.Value && (Object)(object)ItemVariety.pillBottle2 != (Object)null && ItemVariety.tex == 1)
{
((Renderer)val2.mainObjectRenderer).material.mainTexture = ItemVariety.pillBottle2;
Plugin.Logger.LogDebug((object)$"Pills #{val.NetworkObjectId} using alternate texture");
}
continue;
}
}
if (((Object)val2.itemProperties).name == "Mug")
{
MeshRenderer mainObjectRenderer4 = val2.mainObjectRenderer;
if ((Object)(object)((mainObjectRenderer4 != null) ? ((Renderer)mainObjectRenderer4).sharedMaterial : null) != (Object)null && ((Object)((Renderer)val2.mainObjectRenderer).sharedMaterial).name.StartsWith("CoffeeMug"))
{
ItemVariety.GetSkinIndices(val2, 6);
if (Plugin.configMug.Value && (Object)(object)ItemVariety.coffeeMug6 != (Object)null && ItemVariety.tex == 5)
{
((Renderer)val2.mainObjectRenderer).material = ItemVariety.coffeeMug6;
Plugin.Logger.LogDebug((object)$"Mug #{val.NetworkObjectId} using alternate texture");
}
continue;
}
}
if (((Object)val2.itemProperties).name == "ControlPad" && ((Component)val2).TryGetComponent<Renderer>(ref val6) && (Object)(object)val6.sharedMaterial != (Object)null && ((Object)val6.sharedMaterial).name.StartsWith("ArcadeControlPanel"))
{
ItemVariety.GetSkinIndices(val2);
if (Plugin.configControlPad.Value && (Object)(object)ItemVariety.controlPad2 != (Object)null && ItemVariety.tex == 1)
{
val6.material.mainTexture = ItemVariety.controlPad2;
Plugin.Logger.LogDebug((object)$"Controller #{val.NetworkObjectId} using alternate texture");
}
}
else if (((Object)val2.itemProperties).name == "FishTestProp" && ((Component)val2.mainObjectRenderer).TryGetComponent<MeshFilter>(ref val7))
{
ItemVariety.GetSkinIndices(val2, 9, 3);
if (!Plugin.configFish.Value)
{
continue;
}
if (ItemVariety.tex == 8)
{
if ((Object)(object)ItemVariety.sardineBanana == (Object)null)
{
continue;
}
val7.mesh = ItemVariety.sardineBanana;
Material val8 = ((Renderer)val2.mainObjectRenderer).materials[1];
Material val9 = Object.Instantiate<Material>(val8);
val8.SetColor("_Color", ItemVariety.banana);
val8.SetColor("_BaseColor", ItemVariety.banana);
val9.SetColor("_Color", ItemVariety.stem);
val9.SetColor("_BaseColor", ItemVariety.stem);
((Renderer)val2.mainObjectRenderer).materials = (Material[])(object)new Material[3]
{
((Renderer)val2.mainObjectRenderer).sharedMaterials[0],
val8,
val9
};
}
else if ((Object)(object)ItemVariety.fish2 != (Object)null && (Object)(object)ItemVariety.sardine != (Object)null)
{
int mesh = ItemVariety.mesh;
if (mesh != 1)
{
if (mesh != 2)
{
continue;
}
val7.mesh = ItemVariety.sardine;
Material val10 = ((Renderer)val2.mainObjectRenderer).materials[1];
val10.SetColor("_Color", ItemVariety.fishRed);
val10.SetColor("_BaseColor", ItemVariety.fishRed);
((Renderer)val2.mainObjectRenderer).materials = (Material[])(object)new Material[2]
{
((Renderer)val2.mainObjectRenderer).sharedMaterials[0],
val10
};
}
else
{
val7.mesh = ItemVariety.fish2;
Material val11 = ((Renderer)val2.mainObjectRenderer).materials[1];
val11.SetColor("_Color", ItemVariety.fishYellow);
val11.SetColor("_BaseColor", ItemVariety.fishYellow);
((Renderer)val2.mainObjectRenderer).materials = (Material[])(object)new Material[2]
{
val11,
((Renderer)val2.mainObjectRenderer).sharedMaterials[0]
};
}
}
Plugin.Logger.LogDebug((object)$"Fish #{val.NetworkObjectId} using alternate model");
}
else if (((Object)val2.itemProperties).name == "SteeringWheel" && (Object)(object)val2.mainObjectRenderer != (Object)null && (Object)(object)((Renderer)val2.mainObjectRenderer).sharedMaterial != (Object)null && ((Object)((Renderer)val2.mainObjectRenderer).sharedMaterial).name.StartsWith("DirtySmoothSteel"))
{
ItemVariety.GetSkinIndices(val2);
if (Plugin.configSteeringWheel.Value && (Object)(object)ItemVariety.darkPlastic != (Object)null && ItemVariety.tex == 1)
{
((Renderer)val2.mainObjectRenderer).material = ItemVariety.darkPlastic;
Plugin.Logger.LogDebug((object)$"Wheel #{val.NetworkObjectId} using alternate texture");
}
}
}
}
}
internal class ItemVariety
{
internal static AudioClip boombox;
internal static Texture giftBoxTex2;
internal static Texture pillBottle2;
internal static Texture controlPad2;
internal static Material lollipop2;
internal static Material lollyStick;
internal static Material coffeeMug6;
internal static Material darkPlastic;
internal static Color perfumeRed = new Color(0.9f, 0.3922666f, 0.324f, 0.6313726f);
internal static Color perfumeRedTrans = new Color(1f, 0.4f, 0.4f);
internal static Color perfumeBlue = new Color(0.4509091f, 0.416f, 0.8f, 0.6313726f);
internal static Color perfumeBlueTrans = new Color(0.59f, 0.6241666f, 1f);
internal static Color perfumeBlack = new Color(0.01f, 0.01f, 0.01f, 0.6313726f);
internal static Color perfumeBlackTrans = new Color(0.48f, 0.48f, 0.48f);
internal static Color fishYellow = new Color(0.773024f, 0.8392157f, 0.3692549f);
internal static Color fishRed = new Color(0.5019608f, 0.1780566f, 0.1556078f);
internal static Color banana = new Color(0.44f, 0.4296874f, 0.2028124f);
internal static Color stem = new Color(0.3799999f, 0.243271f, 0.1527103f);
internal static Mesh lollyMesh;
internal static Mesh sucker;
internal static Mesh fish2;
internal static Mesh sardine;
internal static Mesh sardineBanana;
internal static Mesh[] perfumeMeshes;
internal static HashSet<ulong> cache = new HashSet<ulong>();
internal static Dictionary<string, int> offsets = new Dictionary<string, int>();
internal static int tex = -1;
internal static int mesh = -1;
internal static void GetSkinIndices(GrabbableObject obj, int texCount = 2, int meshCount = -1)
{
if (offsets.ContainsKey(((Object)obj.itemProperties).name))
{
offsets[((Object)obj.itemProperties).name]++;
}
else
{
offsets.Add(((Object)obj.itemProperties).name, 0);
}
Random random = new Random(StartOfRound.Instance.randomMapSeed + (int)obj.targetFloorPosition.x + (int)obj.targetFloorPosition.z + offsets[((Object)obj.itemProperties).name]);
if (texCount >= 0)
{
tex = random.Next(texCount);
}
if (meshCount >= 0)
{
mesh = random.Next(meshCount);
}
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "UpturnedVariety";
public const string PLUGIN_NAME = "UpturnedVariety";
public const string PLUGIN_VERSION = "1.3.2";
}
}