Decompiled source of Theft Objective Colours v1.0.0

TheftObjectiveColours.dll

Decompiled 8 hours ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using AssetBundleLoader;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using DDSScriptExtensions;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using MoonSharp.Interpreter;
using SOD.Common.BepInEx;
using UnityEngine;
using UniverseLib;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("TheftObjectiveColours")]
[assembly: AssemblyConfiguration("IL2CPP")]
[assembly: AssemblyDescription("Adds colour variety to corporate theft objectives in SOD. No more looking at 5 envelopes with no way to know the right one!")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+0638fdeb82f875e4aff64d533217dd7fe6fdb7aa")]
[assembly: AssemblyProduct("TheftObjectiveColours")]
[assembly: AssemblyTitle("TheftObjectiveColours")]
[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;
		}
	}
}
namespace TheftObjectiveColours
{
	public class TheftObjectiveColoursHooks
	{
		[HarmonyPatch(typeof(Toolbox), "Start")]
		public class Toolbox_Start
		{
			public class DDSScriptHelper
			{
				public readonly DDSScriptHelper Instance;

				public DDSScriptHelper()
				{
					Instance = this;
				}

				public static string GetEnvelopeColour(object inputObject)
				{
					Interactable val = null;
					if (ReflectionExtensions.GetActualType(inputObject) == typeof(SideJob))
					{
						val = ReflectionExtensions.TryCast<SideJob>(inputObject).activeJobItems[(JobTag)0];
					}
					string seed = val.seed;
					int num = Toolbox.Instance.RandContained(0, TheftObjectiveColoursPlugin.CachedTextures.Length, ref seed);
					return TheftObjectiveColoursPlugin.ColourNames[num];
				}
			}

			private static DDSScriptHelper scriptHelper;

			public static void Postfix()
			{
				RebuildTextures();
				scriptHelper = new DDSScriptHelper();
				DDSScriptExtensionsPlugin.LuaScriptEnvironment.Globals[(object)"TheftObjectiveColours"] = UserData.Create((object)scriptHelper.Instance);
			}

			public static void RebuildTextures()
			{
				//IL_0050: Unknown result type (might be due to invalid IL or missing references)
				Texture2D val = Texture2DLoader.CreateTexture2DFromPNG(Assembly.GetExecutingAssembly(), "SealedEnvelope_diffuse.png");
				((Texture)val).filterMode = (FilterMode)0;
				TheftObjectiveColoursPlugin.OverlayTexture = Texture2DLoader.CreateTexture2DFromPNG(Assembly.GetExecutingAssembly(), "SealedEnvelope_diffuse_overlay.png");
				((Texture)TheftObjectiveColoursPlugin.OverlayTexture).filterMode = (FilterMode)0;
				for (int i = 0; i < TheftObjectiveColoursPlugin.Colours.Length; i++)
				{
					TheftObjectiveColoursPlugin.CachedTextures[i] = Texture2DLoader.CombineTexture2D(val, TheftObjectiveColoursPlugin.OverlayTexture, TheftObjectiveColoursPlugin.Colours[i], true);
					((Texture)TheftObjectiveColoursPlugin.CachedTextures[i]).filterMode = (FilterMode)0;
				}
			}
		}

		[HarmonyPatch(typeof(Interactable), "OnSpawn")]
		public class Interactable_OnSpawn
		{
			public static void Postfix(Interactable __instance)
			{
				if (((SoCustomComparison)__instance.preset).presetName == "SealedEnvelope")
				{
					string seed = __instance.seed;
					int num = Toolbox.Instance.RandContained(0, TheftObjectiveColoursPlugin.CachedTextures.Length, ref seed);
					if ((Object)(object)TheftObjectiveColoursPlugin.CachedTextures[num] == (Object)null)
					{
						Toolbox_Start.RebuildTextures();
					}
					((Renderer)__instance.spawnedObject.GetComponent<MeshRenderer>()).material.mainTexture = (Texture)(object)TheftObjectiveColoursPlugin.CachedTextures[num];
				}
			}
		}

		[HarmonyPatch(typeof(FirstPersonItemController), "RefreshHeldObjects")]
		public class FirstPersonItemController_RefreshHeldObjects
		{
			public static void Postfix(FirstPersonItemController __instance)
			{
				InventorySlot selectedSlot = BioScreenController.Instance.selectedSlot;
				Interactable val = ((selectedSlot != null) ? selectedSlot.GetInteractable() : null);
				if (val != null && ((SoCustomComparison)val.preset).presetName == "SealedEnvelope")
				{
					string seed = val.seed;
					int num = Toolbox.Instance.RandContained(0, TheftObjectiveColoursPlugin.CachedTextures.Length, ref seed);
					if ((Object)(object)TheftObjectiveColoursPlugin.CachedTextures[num] == (Object)null)
					{
						Toolbox_Start.RebuildTextures();
					}
					((Renderer)__instance.rightPrefabReference.GetComponent<MeshRenderer>()).material.mainTexture = (Texture)(object)TheftObjectiveColoursPlugin.CachedTextures[num];
				}
			}
		}
	}
	[BepInPlugin("TheftObjectiveColours", "TheftObjectiveColours", "1.0.0")]
	public class TheftObjectiveColoursPlugin : PluginController<TheftObjectiveColoursPlugin>
	{
		private static ConfigEntry<bool> _enabled;

		public static Texture2D OverlayTexture = null;

		public static readonly Texture2D[] CachedTextures = (Texture2D[])(object)new Texture2D[19];

		public static readonly Color[] Colours = (Color[])(object)new Color[19]
		{
			new Color(0.902f, 0.098f, 0.294f, 1f),
			new Color(0.235f, 0.706f, 0.294f, 1f),
			new Color(1f, 0.882f, 0.098f, 1f),
			new Color(0f, 0.51f, 0.784f, 1f),
			new Color(0.961f, 0.51f, 0.188f, 1f),
			new Color(0.569f, 0.118f, 0.706f, 1f),
			new Color(0.275f, 0.941f, 0.941f, 1f),
			new Color(0.941f, 0.196f, 0.902f, 1f),
			new Color(0.824f, 0.961f, 0.235f, 1f),
			new Color(0.98f, 0.745f, 0.831f, 1f),
			new Color(0f, 0.502f, 0.502f, 1f),
			new Color(0.863f, 0.745f, 1f, 1f),
			new Color(1f, 0.98f, 0.784f, 1f),
			new Color(0.502f, 0f, 0f, 1f),
			new Color(0.667f, 1f, 0.765f, 1f),
			new Color(0.502f, 0.502f, 0f, 1f),
			new Color(1f, 0.843f, 0.706f, 1f),
			new Color(0f, 0f, 0.502f, 1f),
			new Color(0.502f, 0.502f, 0.502f, 1f)
		};

		public static readonly string[] ColourNames = new string[19]
		{
			"red", "green", "yellow", "blue", "orange", "purple", "cyan", "magenta", "lime", "pink",
			"teal", "lavender", "beige", "maroon", "mint", "olive", "apricot", "navy", "grey"
		};

		public override void Load()
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Expected O, but got Unknown
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Expected O, but got Unknown
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Expected O, but got Unknown
			_enabled = base.Config.Bind<bool>("General", "Enabled", true, "Is the mod enabled at all? (Game restart required)");
			if (_enabled.Value)
			{
				ManualLogSource log = PluginController<TheftObjectiveColoursPlugin, IEmptyBindings>.Log;
				bool flag = default(bool);
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(18, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("TheftObjectiveColours");
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is loaded!");
				}
				log.LogInfo(val);
				Harmony val2 = new Harmony("TheftObjectiveColours");
				val2.PatchAll();
				ManualLogSource log2 = PluginController<TheftObjectiveColoursPlugin, IEmptyBindings>.Log;
				val = new BepInExInfoLogInterpolatedStringHandler(19, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("TheftObjectiveColours");
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is patched!");
				}
				log2.LogInfo(val);
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "TheftObjectiveColours";

		public const string PLUGIN_NAME = "TheftObjectiveColours";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}