using System;
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.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using VividPickles.Utils;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.1", FrameworkDisplayName = ".NET Framework 4.7.1")]
[assembly: AssemblyCompany("VividPickles")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("VividPickles")]
[assembly: AssemblyTitle("VividPickles")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.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;
}
}
}
public class Colorfull : MonoBehaviour
{
private Light light;
private List<Material> materials = new List<Material>();
private Color32 targetcolor = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue);
public int rar = 0;
private void Start()
{
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
//IL_012e: 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)
light = ((Component)this).GetComponentInChildren<Light>();
Renderer[] componentsInChildren = ((Component)this).GetComponentsInChildren<Renderer>();
foreach (Renderer val in componentsInChildren)
{
Material[] array = val.materials;
foreach (Material val2 in array)
{
if (((Object)val2.shader).name.Contains("HDRP/Lit") && ((Object)val2).name != "PickleJarTex")
{
materials.Add(val2);
}
}
}
if (rar == 1)
{
targetcolor = new Color32((byte)183, (byte)229, (byte)137, byte.MaxValue);
}
else if (rar == 2)
{
targetcolor = new Color32((byte)0, (byte)103, byte.MaxValue, byte.MaxValue);
}
light.color = Color32.op_Implicit(targetcolor);
targetcolor.a = 65;
foreach (Material material in materials)
{
material.SetColor("_BaseColor", Color32.op_Implicit(targetcolor));
}
}
}
public class RainbowColor : MonoBehaviour
{
private Light light;
private List<Material> materials = new List<Material>();
private void Start()
{
light = ((Component)this).GetComponentInChildren<Light>();
Renderer[] componentsInChildren = ((Component)this).GetComponentsInChildren<Renderer>();
foreach (Renderer val in componentsInChildren)
{
Material[] array = val.materials;
foreach (Material val2 in array)
{
if (((Object)val2.shader).name.Contains("HDRP/Lit") && ((Object)val2).name != "PickleJarTex")
{
materials.Add(val2);
}
}
}
}
private void Update()
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
float num = Mathf.Abs(Mathf.Sin(Time.time / 10f));
Color val = Color.HSVToRGB(num, 1f, 1f);
light.color = val;
val.a = 0.3f;
foreach (Material material in materials)
{
material.SetColor("_BaseColor", val);
}
}
}
namespace VividPickles
{
[BepInPlugin("VividPickles", "VividPickles", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
internal static ManualLogSource Logger;
internal static string ProjectNamespace = "VividPickles";
internal static GameObject Jar;
internal static AssetBundle bundle;
public static Harmony harmony = new Harmony("VividPickles");
private void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
Logger.LogInfo((object)"Plugin VividPickles is loaded!");
bundle = AssetBundleUtil.LoadBundleFromFile("pickuless");
((Object)bundle).hideFlags = (HideFlags)32;
Jar = bundle.LoadAsset<GameObject>("assets/pickuless/colorfulpicklejargiant.prefab");
((Object)Jar).hideFlags = (HideFlags)32;
Jar.GetComponentInChildren<Light>().range = 0.5f;
harmony.PatchAll();
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "VividPickles";
public const string PLUGIN_NAME = "VividPickles";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace VividPickles.Utils
{
internal class AssetBundleUtil
{
public static AssetBundle LoadBundleFromFile(string id)
{
if (string.IsNullOrWhiteSpace(id))
{
throw new ArgumentException("Resource ID cannot be null or whitespace.", "id");
}
Assembly executingAssembly = Assembly.GetExecutingAssembly();
string text = Plugin.ProjectNamespace + ".Resources." + id;
using Stream stream = executingAssembly.GetManifestResourceStream(text);
if (stream == null)
{
throw new ArgumentException("Resource '" + text + "' not found in assembly.");
}
string text2 = Path.Combine(Path.GetTempPath(), id + ".bundle");
try
{
using (FileStream destination = new FileStream(text2, FileMode.Create, FileAccess.Write))
{
stream.CopyTo(destination);
}
AssetBundle val = AssetBundle.LoadFromFile(text2);
if ((Object)(object)val == (Object)null)
{
throw new InvalidOperationException("Failed to load AssetBundle from resource '" + id + "'.");
}
return val;
}
finally
{
try
{
if (File.Exists(text2))
{
File.Delete(text2);
}
}
catch (Exception ex)
{
Plugin.Logger.LogWarning((object)("Failed to delete temporary file '" + text2 + "': " + ex.Message));
}
}
}
}
}
namespace VividPickles.Patch
{
[HarmonyPatch(typeof(GrabbableObject), "EnableItemMeshes")]
internal class EnableItemMesh
{
[HarmonyPostfix]
private static void Postfix(GrabbableObject __instance, bool enable)
{
GameObject gameObject = ((Component)__instance).gameObject;
if ((Object)(object)gameObject == (Object)null)
{
Plugin.Logger.LogError((object)"GrabbableObject::EnableItemMeshes -> gameObject is null!");
}
else if (((Object)gameObject).name == "PickleJar(Clone)" && Object.op_Implicit((Object)(object)gameObject.transform.Find("FakeJar")))
{
((Behaviour)((Component)gameObject.transform.Find("FakeJar")).GetComponentInChildren<Light>()).enabled = enable;
}
}
}
[HarmonyPatch(typeof(GrabbableObject), "Start")]
internal class GrabbableObjectPatch
{
[HarmonyPostfix]
private static void Postfix(GrabbableObject __instance)
{
//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
//IL_0108: Unknown result type (might be due to invalid IL or missing references)
//IL_012e: Unknown result type (might be due to invalid IL or missing references)
GameObject gameObject = ((Component)__instance).gameObject;
if ((Object)(object)gameObject == (Object)null)
{
Plugin.Logger.LogError((object)"GrabbableObject::Start -> gameObject is null!");
}
else if (((Object)gameObject).name == "PickleJar(Clone)" && !Object.op_Implicit((Object)(object)gameObject.transform.Find("FakeJar")))
{
Plugin.Logger.LogInfo((object)"Replacing Mesh...");
Object.DestroyImmediate((Object)(object)gameObject.GetComponent<MeshFilter>());
Object.DestroyImmediate((Object)(object)gameObject.GetComponent<MeshRenderer>());
GameObject gameObject2 = ((Component)gameObject.transform.Find("Pickles.001")).gameObject;
Object.DestroyImmediate((Object)(object)gameObject2.GetComponent<MeshFilter>());
Object.DestroyImmediate((Object)(object)gameObject2.GetComponent<MeshRenderer>());
GameObject val = Object.Instantiate<GameObject>(Plugin.Jar);
((Object)val).name = "FakeJar";
val.transform.parent = gameObject.transform;
val.transform.localScale = Vector3.one;
val.transform.localPosition = new Vector3(0f, 0f, -0.2f);
val.transform.localRotation = new Quaternion(0f, 0f, 0f, 0f);
int num = 60;
int num2 = 32;
float num3 = num - num2;
float num4 = (float)(gameObject.GetComponentInChildren<ScanNodeProperties>().scrapValue - num2) / num3;
Plugin.Logger.LogInfo((object)gameObject.GetComponentInChildren<ScanNodeProperties>().scrapValue);
Plugin.Logger.LogInfo((object)$"{num4} ");
if (num4 <= 1f / 3f)
{
Colorfull colorfull = val.AddComponent<Colorfull>();
colorfull.rar = 1;
}
else if (num4 <= 2f / 3f)
{
Colorfull colorfull2 = val.AddComponent<Colorfull>();
colorfull2.rar = 2;
}
else
{
val.AddComponent<RainbowColor>();
}
}
}
}
}