Decompiled source of RandomisedFamiliarShaders v1.0.6

RandomisedFamiliarShaders.dll

Decompiled 5 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using Gunfiguration;
using Microsoft.CodeAnalysis;
using MonoMod.RuntimeDetour;
using RandomisedFamiliarShaders;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Mod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Mod")]
[assembly: AssemblyCopyright("Copyright ©  2020")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("d6d7a494-722e-4763-959b-c2d6b6a42b01")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[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 Gunfiguration
{
	public static class RandFamConfig
	{
		internal static Gunfig _Gunfig;

		internal const string Enabled = "Enable Random Familiar Shaders";

		internal const string EffectOrbitals = "Enable Random Shaders For Orbitals";

		internal const string EffectOrbitalFollowers = "Enable Random Shaders For Orbital Followers";

		internal const string NewShadersEachFloor = "New Shaders Each Floor";

		internal const string NewColoursEachFloor = "New Colours Each Floor";

		internal const string AllFamiliarsSame = "All Familiars Use Same Shader";

		internal const string AllFamiliarsSameColour = "All Familiars Use Same Colour";

		internal const string SameFamiliarSameShader = "Familiars Of A Similar Type Share A Shader";

		internal const string OnlyDog = "Random Shaders Only On Hunter's Dog";

		internal static void Init(Plugin parent)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			_Gunfig = Gunfig.Get(GunfigHelpers.WithColor("Random Familiar Shaders", Color.white));
			parent.SetEnabled(_Gunfig.Enabled("Enable Random Familiar Shaders"));
			parent.SetEffectOrbitals(_Gunfig.Enabled("Enable Random Shaders For Orbitals"));
			parent.SetEffectOrbitalFollowers(_Gunfig.Enabled("Enable Random Shaders For Orbital Followers"));
			parent.SetNewShadersEachFloor(_Gunfig.Enabled("New Shaders Each Floor"));
			parent.SetNewColoursEachFloor(_Gunfig.Enabled("New Colours Each Floor"));
			parent.SetAllFamiliarsSame(_Gunfig.Enabled("All Familiars Use Same Shader"));
			parent.SetAllFamiliarsSameColour(_Gunfig.Enabled("All Familiars Use Same Colour"));
			parent.SetSameFamiliarSameShader(_Gunfig.Enabled("Familiars Of A Similar Type Share A Shader"));
			parent.SetOnlyDog(_Gunfig.Enabled("Random Shaders Only On Hunter's Dog"));
			_Gunfig.AddToggle("Enable Random Familiar Shaders", true, (string)null, (Action<string, string>)delegate(string optionKey, string optionValue)
			{
				parent.SetEnabled((optionValue == "1") ? true : false);
			}, (Update)1);
			_Gunfig.AddLabel("Orbitals Are Most Things Like Guon Stones");
			_Gunfig.AddToggle("Enable Random Shaders For Orbitals", true, (string)null, (Action<string, string>)delegate(string optionKey, string optionValue)
			{
				parent.SetEffectOrbitals((optionValue == "1") ? true : false);
			}, (Update)1);
			_Gunfig.AddLabel("Orbital Followers Are Things Like Space Friend");
			_Gunfig.AddToggle("Enable Random Shaders For Orbital Followers", true, (string)null, (Action<string, string>)delegate(string optionKey, string optionValue)
			{
				parent.SetEffectOrbitalFollowers((optionValue == "1") ? true : false);
			}, (Update)1);
			_Gunfig.AddToggle("New Shaders Each Floor", false, (string)null, (Action<string, string>)delegate(string optionKey, string optionValue)
			{
				parent.SetNewShadersEachFloor((optionValue == "1") ? true : false);
			}, (Update)1);
			_Gunfig.AddToggle("New Colours Each Floor", false, (string)null, (Action<string, string>)delegate(string optionKey, string optionValue)
			{
				parent.SetNewColoursEachFloor((optionValue == "1") ? true : false);
			}, (Update)1);
			_Gunfig.AddToggle("All Familiars Use Same Shader", false, (string)null, (Action<string, string>)delegate(string optionKey, string optionValue)
			{
				parent.SetAllFamiliarsSame((optionValue == "1") ? true : false);
			}, (Update)1);
			_Gunfig.AddToggle("All Familiars Use Same Colour", false, (string)null, (Action<string, string>)delegate(string optionKey, string optionValue)
			{
				parent.SetAllFamiliarsSameColour((optionValue == "1") ? true : false);
			}, (Update)1);
			_Gunfig.AddToggle("Familiars Of A Similar Type Share A Shader", false, (string)null, (Action<string, string>)delegate(string optionKey, string optionValue)
			{
				parent.SetSameFamiliarSameShader((optionValue == "1") ? true : false);
			}, (Update)1);
			_Gunfig.AddToggle("Random Shaders Only On Hunter's Dog", false, (string)null, (Action<string, string>)delegate(string optionKey, string optionValue)
			{
				parent.SetOnlyDog((optionValue == "1") ? true : false);
			}, (Update)1);
			_Gunfig.AddLabel("The Following Are The Possible Shaders");
			foreach (KeyValuePair<string, string> item in Plugin.ShaderDict)
			{
				AddOrRemoveShaders(item.Key, _Gunfig.Enabled(item.Key));
				_Gunfig.AddToggle(item.Key, true, (string)null, (Action<string, string>)delegate(string optionKey, string optionValue)
				{
					AddOrRemoveShaders(optionKey, (optionValue == "1") ? true : false);
				}, (Update)1);
			}
			_Gunfig.AddLabel("The Following Are Colours Used By Some Shaders");
			_Gunfig.AddLabel("Colours Will Be Random From Those Enabled");
			foreach (KeyValuePair<string, Color> colour in Plugin.Colours)
			{
				AddOrRemoveColours(colour.Key, _Gunfig.Enabled(colour.Key));
				_Gunfig.AddToggle(colour.Key, true, (string)null, (Action<string, string>)delegate(string optionKey, string optionValue)
				{
					AddOrRemoveColours(optionKey, (optionValue == "1") ? true : false);
				}, (Update)1);
			}
		}

		public static void AddOrRemoveShaders(string optionKey, bool optionValue)
		{
			if (optionValue)
			{
				Plugin.ActiveShaders.Add(optionKey);
			}
			else
			{
				Plugin.ActiveShaders.Remove(optionKey);
			}
		}

		public static void AddOrRemoveColours(string optionKey, bool optionValue)
		{
			if (optionValue)
			{
				Plugin.ActiveColours.Add(optionKey);
			}
			else
			{
				Plugin.ActiveColours.Remove(optionKey);
			}
		}
	}
}
namespace RandomisedFamiliarShaders
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("SimplyFenton.etg.randomisedfamiliarshaders", "Randomised Familiar Shaders", "1.0.6")]
	public class Plugin : BaseUnityPlugin
	{
		public const string GUID = "SimplyFenton.etg.randomisedfamiliarshaders";

		public const string NAME = "Randomised Familiar Shaders";

		public const string VERSION = "1.0.6";

		public const string TEXT_COLOR = "#00FFFF";

		public static bool OnlyDog;

		public static bool pluginEnabled;

		public static List<string> ActiveShaders = new List<string>();

		public static Dictionary<string, string> ShaderDict = new Dictionary<string, string>
		{
			{ "Platinum", "Brave/ItemSpecific/LootGlintAdditivePass" },
			{ "Radiant", "Brave/Internal/SinglePassOutline" },
			{ "Paradox", "Brave/PlayerShaderEevee" },
			{ "Goop", "Brave/GoopShader" },
			{ "Metal", "Brave/ItemSpecific/MetalSkinShader" },
			{ "Rainbow", "Brave/Internal/RainbowChestShader" },
			{ "Tangled", "Brave/LitCutoutUber" },
			{ "Lightbulb", "Brave/LitTk2dCustomFalloffTintableTiltedCutoutEmissive" },
			{ "Coloured Lines", "Brave/Internal/DownwellAfterImage" },
			{ "Hologram Green", "Brave/Internal/HologramShader" },
			{ "Hologram Blue", "Brave/Internal/HologramShader" },
			{ "Jammed", "Brave/LitCutoutUberPhantom" },
			{ "Glitch", "Brave/Internal/Glitch" },
			{ "Static", "Brave/Internal/GlitterPassAdditive" },
			{ "Colour Glow", "Brave/Internal/HighPriestAfterImage" }
		};

		public static List<string> ActiveColours = new List<string>();

		public static Dictionary<string, Color> Colours = new Dictionary<string, Color>
		{
			{
				"Black",
				Color.black
			},
			{
				"Blue",
				Color.blue
			},
			{
				"Clear",
				Color.clear
			},
			{
				"Cyan",
				Color.cyan
			},
			{
				"Grey",
				Color.grey
			},
			{
				"Green",
				Color.green
			},
			{
				"Magenta",
				Color.magenta
			},
			{
				"Red",
				Color.red
			},
			{
				"White",
				Color.white
			},
			{
				"Yellow",
				Color.yellow
			}
		};

		public static string currentShader;

		public static AIActor Dog;

		public static Dictionary<int, string> ShaderMap = new Dictionary<int, string>();

		public static Dictionary<int, string> OrbitalsShaderMap = new Dictionary<int, string>();

		public static Dictionary<int, Color> ColourMap = new Dictionary<int, Color>();

		public static Dictionary<int, Color> OrbitalsColourMap = new Dictionary<int, Color>();

		public static bool NewShadersEachFloor;

		public static bool NewColoursEachFloor;

		public static bool AllFamiliarsSame;

		public static bool AllFamiliarsSameColour;

		public static bool SameFamiliarSameShader;

		public static bool EffectOrbitals;

		public static bool EffectOrbitalFollowers;

		public static Color RunColour;

		public static string ActiveColour;

		public static List<string> tempDisabledShaders = new List<string> { "Radiant", "Goop" };

		public static List<string> tempDisabledColours = new List<string> { "Black", "Clear" };

		public static Random random;

		public void Start()
		{
			random = new Random();
			ShaderDict = ShaderDict.OrderBy((KeyValuePair<string, string> x) => x.Key).ToDictionary((KeyValuePair<string, string> pair) => pair.Key, (KeyValuePair<string, string> pair) => pair.Value);
			foreach (string tempDisabledShader in tempDisabledShaders)
			{
				ShaderDict.Remove(tempDisabledShader);
			}
			foreach (string tempDisabledColour in tempDisabledColours)
			{
				Colours.Remove(tempDisabledColour);
			}
			ETGModMainBehaviour.WaitForGameManagerStart((Action<GameManager>)GMStart);
			Init();
		}

		public void SetEnabled(bool input)
		{
			pluginEnabled = input;
		}

		public void SetOnlyDog(bool input)
		{
			OnlyDog = input;
		}

		public void SetAllFamiliarsSame(bool input)
		{
			AllFamiliarsSame = input;
		}

		public void SetAllFamiliarsSameColour(bool input)
		{
			AllFamiliarsSameColour = input;
		}

		public void SetNewColoursEachFloor(bool input)
		{
			NewColoursEachFloor = input;
		}

		public void SetNewShadersEachFloor(bool input)
		{
			NewShadersEachFloor = input;
		}

		public void SetSameFamiliarSameShader(bool input)
		{
			SameFamiliarSameShader = input;
		}

		public void SetEffectOrbitals(bool input)
		{
			EffectOrbitals = input;
		}

		public void SetEffectOrbitalFollowers(bool input)
		{
			EffectOrbitalFollowers = input;
		}

		public void NewFloor()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			if (NewColoursEachFloor)
			{
				RunColour = RandomColour(avoid: true);
				ColourMap.Clear();
				OrbitalsColourMap.Clear();
			}
			if (NewShadersEachFloor)
			{
				currentShader = RandomShader();
				ShaderMap.Clear();
				OrbitalsShaderMap.Clear();
			}
		}

		public static Color RandomColour(bool avoid = false)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: 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_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			int index = random.Next(0, ActiveColours.Count);
			Color val = Colours[ActiveColours.ElementAt(index)];
			ActiveColour = ActiveColours.ElementAt(index);
			if (avoid)
			{
				if ((val == Color.black) | (val == Color.clear))
				{
					return RandomColour(avoid: true);
				}
				return val;
			}
			return Colours[ActiveColours.ElementAt(random.Next(0, ActiveColours.Count))];
		}

		public static string RandomShader()
		{
			return ActiveShaders.ElementAt(random.Next(0, ActiveShaders.Count));
		}

		public static void ShaderLogic(AIActor actor)
		{
			//IL_0029: 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_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			//IL_023a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0336: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_029c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0295: Unknown result type (might be due to invalid IL or missing references)
			//IL_032f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0328: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
			if (!ColourMap.Keys.Contains(actor.EnemyId))
			{
				ColourMap.Add(actor.EnemyId, RandomColour());
			}
			if (SameFamiliarSameShader && !ShaderMap.Keys.Contains(actor.EnemyId) && !AllFamiliarsSame && !NewShadersEachFloor)
			{
				ShaderMap.Add(actor.EnemyId, currentShader);
				shaderChanger(actor, ShaderMap[actor.EnemyId], AllFamiliarsSameColour ? RunColour : ((!NewColoursEachFloor) ? RunColour : ColourMap[actor.EnemyId]));
			}
			else if (SameFamiliarSameShader && !ShaderMap.Keys.Contains(actor.EnemyId) && !AllFamiliarsSame)
			{
				currentShader = RandomShader();
				ShaderMap.Add(actor.EnemyId, currentShader);
				shaderChanger(actor, ShaderMap[actor.EnemyId], AllFamiliarsSameColour ? RunColour : ((!NewColoursEachFloor) ? RunColour : ColourMap[actor.EnemyId]));
			}
			else if (SameFamiliarSameShader && !AllFamiliarsSame)
			{
				shaderChanger(actor, ShaderMap[actor.EnemyId], AllFamiliarsSameColour ? RunColour : ((!NewColoursEachFloor) ? RunColour : ColourMap[actor.EnemyId]));
			}
			else if (!ShaderMap.Keys.Contains(actor.EnemyId) && !AllFamiliarsSame && !NewShadersEachFloor)
			{
				string value = RandomShader();
				ShaderMap.Add(actor.EnemyId, value);
				shaderChanger(actor, ShaderMap[actor.EnemyId], AllFamiliarsSameColour ? RunColour : ((!NewColoursEachFloor) ? RunColour : ColourMap[actor.EnemyId]));
			}
			else if (!AllFamiliarsSame && !NewShadersEachFloor)
			{
				shaderChanger(actor, ShaderMap[actor.EnemyId], AllFamiliarsSameColour ? RunColour : ((!NewColoursEachFloor) ? RunColour : ColourMap[actor.EnemyId]));
			}
			else if (!AllFamiliarsSame)
			{
				currentShader = RandomShader();
				shaderChanger(actor, currentShader, AllFamiliarsSameColour ? RunColour : ((!NewColoursEachFloor) ? RunColour : ColourMap[actor.EnemyId]));
			}
			else
			{
				shaderChanger(actor, currentShader, AllFamiliarsSameColour ? RunColour : ((!NewColoursEachFloor) ? RunColour : ColourMap[actor.EnemyId]));
			}
		}

		public static void OrbitalsShaderLogic(tk2dSprite sprite)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_038a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_0269: Unknown result type (might be due to invalid IL or missing references)
			//IL_0262: Unknown result type (might be due to invalid IL or missing references)
			//IL_025b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_037c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0336: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0375: Unknown result type (might be due to invalid IL or missing references)
			//IL_036e: Unknown result type (might be due to invalid IL or missing references)
			//IL_032f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0328: Unknown result type (might be due to invalid IL or missing references)
			if (!OrbitalsColourMap.Keys.Contains(((tk2dBaseSprite)sprite).spriteId))
			{
				OrbitalsColourMap.Add(((tk2dBaseSprite)sprite).spriteId, RandomColour());
			}
			if (SameFamiliarSameShader && !OrbitalsShaderMap.Keys.Contains(((tk2dBaseSprite)sprite).spriteId) && !AllFamiliarsSame && !NewShadersEachFloor)
			{
				OrbitalsShaderMap.Add(((tk2dBaseSprite)sprite).spriteId, currentShader);
				MatHandler(((BraveBehaviour)sprite).renderer.material, OrbitalsShaderMap[((tk2dBaseSprite)sprite).spriteId], AllFamiliarsSameColour ? RunColour : ((!NewColoursEachFloor) ? RunColour : OrbitalsColourMap[((tk2dBaseSprite)sprite).spriteId]));
			}
			else if (SameFamiliarSameShader && !OrbitalsShaderMap.Keys.Contains(((tk2dBaseSprite)sprite).spriteId) && !AllFamiliarsSame)
			{
				currentShader = RandomShader();
				OrbitalsShaderMap.Add(((tk2dBaseSprite)sprite).spriteId, currentShader);
				MatHandler(((BraveBehaviour)sprite).renderer.material, OrbitalsShaderMap[((tk2dBaseSprite)sprite).spriteId], AllFamiliarsSameColour ? RunColour : ((!NewColoursEachFloor) ? RunColour : OrbitalsColourMap[((tk2dBaseSprite)sprite).spriteId]));
			}
			else if (SameFamiliarSameShader && !AllFamiliarsSame)
			{
				MatHandler(((BraveBehaviour)sprite).renderer.material, OrbitalsShaderMap[((tk2dBaseSprite)sprite).spriteId], AllFamiliarsSameColour ? RunColour : ((!NewColoursEachFloor) ? RunColour : OrbitalsColourMap[((tk2dBaseSprite)sprite).spriteId]));
			}
			else if (!OrbitalsShaderMap.Keys.Contains(((tk2dBaseSprite)sprite).spriteId) && !AllFamiliarsSame && !NewShadersEachFloor)
			{
				string value = RandomShader();
				OrbitalsShaderMap.Add(((tk2dBaseSprite)sprite).spriteId, value);
				MatHandler(((BraveBehaviour)sprite).renderer.material, OrbitalsShaderMap[((tk2dBaseSprite)sprite).spriteId], AllFamiliarsSameColour ? RunColour : ((!NewColoursEachFloor) ? RunColour : OrbitalsColourMap[((tk2dBaseSprite)sprite).spriteId]));
			}
			else if (!AllFamiliarsSame && !NewShadersEachFloor)
			{
				MatHandler(((BraveBehaviour)sprite).renderer.material, OrbitalsShaderMap[((tk2dBaseSprite)sprite).spriteId], AllFamiliarsSameColour ? RunColour : ((!NewColoursEachFloor) ? RunColour : OrbitalsColourMap[((tk2dBaseSprite)sprite).spriteId]));
			}
			else if (!AllFamiliarsSame)
			{
				currentShader = RandomShader();
				MatHandler(((BraveBehaviour)sprite).renderer.material, currentShader, AllFamiliarsSameColour ? RunColour : ((!NewColoursEachFloor) ? RunColour : OrbitalsColourMap[((tk2dBaseSprite)sprite).spriteId]));
			}
			else
			{
				MatHandler(((BraveBehaviour)sprite).renderer.material, currentShader, AllFamiliarsSameColour ? RunColour : ((!NewColoursEachFloor) ? RunColour : OrbitalsColourMap[((tk2dBaseSprite)sprite).spriteId]));
			}
			((tk2dBaseSprite)sprite).OverrideMaterialMode = (SpriteMaterialOverrideMode)2;
		}

		public static void preInitializeOrbitalHandler(Action<PlayerOrbital, PlayerController> orig, PlayerOrbital self, PlayerController owner)
		{
			orig(self, owner);
			if (EffectOrbitals)
			{
				OrbitalsShaderLogic(((Component)self).GetComponentInChildren<tk2dSprite>());
			}
		}

		public static void preInitializeOrbitalFollowerHandler(Action<PlayerOrbitalFollower, PlayerController> orig, PlayerOrbitalFollower self, PlayerController owner)
		{
			orig(self, owner);
			if (EffectOrbitalFollowers)
			{
				OrbitalsShaderLogic(((Component)self).GetComponentInChildren<tk2dSprite>());
			}
		}

		public static void preStartActorHandler(AIActor actor)
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			if (pluginEnabled && !actor.IsNormalEnemy)
			{
				if (NewColoursEachFloor && !AllFamiliarsSameColour)
				{
					RunColour = RandomColour(avoid: true);
				}
				if (OnlyDog && actor.EnemyGuid == "c07ef60ae32b404f99e294a6f9acba75")
				{
					ShaderLogic(actor);
				}
				else if (!OnlyDog)
				{
					ShaderLogic(actor);
				}
			}
		}

		public static void MatHandler(Material mat, string shader, Color colour)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0345: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0256: Unknown result type (might be due to invalid IL or missing references)
			//IL_045b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0461: Expected O, but got Unknown
			//IL_0480: Unknown result type (might be due to invalid IL or missing references)
			//IL_0491: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
			switch (shader)
			{
			case "Goop":
			{
				Shader shader2 = ShaderCache.Acquire(ShaderDict[shader]);
				mat.shader = shader2;
				mat.SetColor("_TintColor", colour);
				mat.SetTexture("_WorldTex", (Texture)(object)GameManager.Instance.PrimaryPlayer.portalEeveeTex);
				break;
			}
			case "Radiant":
			{
				Shader shader2 = ShaderCache.Acquire(ShaderDict[shader]);
				mat.shader = shader2;
				mat.SetTexture("_MainTex", mat.mainTexture);
				mat.SetColor("_OverrideColor", colour);
				mat.SetFloat("_MaterialSourceIsSinglePassOutline", 0f);
				mat.SetFloat("_InteriorToggle", 0f);
				break;
			}
			case "Rainbow":
			{
				Shader shader2 = ShaderCache.Acquire(ShaderDict[shader]);
				mat.shader = shader2;
				mat.SetColor("_OverrideColor", Color.clear);
				mat.SetFloat("_ValueMaximum", 1f);
				mat.SetFloat("_AllColorsToggle", 1f);
				break;
			}
			case "Static":
			{
				Shader shader2 = ShaderCache.Acquire(ShaderDict[shader]);
				mat.shader = shader2;
				break;
			}
			case "Colour Glow":
			{
				Shader shader2 = ShaderCache.Acquire(ShaderDict[shader]);
				mat.shader = shader2;
				mat.EnableKeyword("BRIGHTNESS_CLAMP_OFF");
				mat.SetFloat("_EmissivePower", 75f);
				mat.SetFloat("_EmissiveColorPower", 1.55f);
				mat.SetColor("_DashColor", colour);
				break;
			}
			case "Coloured Lines":
			{
				Shader shader2 = ShaderCache.Acquire(ShaderDict[shader]);
				mat.shader = shader2;
				mat.EnableKeyword("BRIGHTNESS_CLAMP_OFF");
				mat.SetFloat("_EmissivePower", 75f);
				mat.SetFloat("_EmissiveColorPower", 1.55f);
				mat.SetColor("_DashColor", colour);
				break;
			}
			case "Glitch":
			{
				Shader shader2 = ShaderCache.Acquire(ShaderDict[shader]);
				mat.shader = shader2;
				mat.SetFloat("_GlitchInterval", 0.1f);
				mat.SetFloat("_DispProbability", 0.4f);
				mat.SetFloat("_DispIntensity", 0.01f);
				mat.SetFloat("_ColorProbablity", 0.4f);
				mat.SetFloat("_ColorIntensity", 0.04f);
				break;
			}
			case "Paradox":
			{
				Shader shader2 = ShaderCache.Acquire(ShaderDict[shader]);
				mat.shader = shader2;
				mat.SetTexture("_MainTex", mat.mainTexture);
				GameObject val = (GameObject)ResourceCache.Acquire("Global Prefabs/VFX_ParadoxPortal");
				ParadoxPortalController component = val.GetComponent<ParadoxPortalController>();
				mat.SetTexture("_EeveeTex", (Texture)(object)component.CosmicTex);
				mat.SetColor("_OverrideColor", Color.clear);
				mat.SetColor("_FlatColor", Color.clear);
				mat.SetFloat("Perpendicular", 1f);
				mat.SetFloat("_StencilVal", 146f);
				break;
			}
			case "Tangled":
			{
				Shader shader2 = ShaderCache.Acquire(ShaderDict[shader]);
				mat.shader = shader2;
				mat.SetFloat("_RectangleAmount", 1f);
				break;
			}
			case "Hologram Blue":
			{
				Shader shader2 = ShaderCache.Acquire(ShaderDict[shader]);
				mat.shader = shader2;
				mat.DisableKeyword("BRIGHTNESS_CLAMP_ON");
				mat.EnableKeyword("BRIGHTNESS_CLAMP_OFF");
				mat.SetFloat("_EmissivePower", 75f);
				mat.SetFloat("_EmissiveColorPower", 1.55f);
				mat.SetFloat("_IsGreen", 0f);
				break;
			}
			case "Hologram Green":
			{
				Shader shader2 = ShaderCache.Acquire(ShaderDict[shader]);
				mat.shader = shader2;
				mat.DisableKeyword("BRIGHTNESS_CLAMP_ON");
				mat.EnableKeyword("BRIGHTNESS_CLAMP_OFF");
				mat.SetFloat("_EmissivePower", 75f);
				mat.SetFloat("_EmissiveColorPower", 1.55f);
				mat.SetFloat("_IsGreen", 1f);
				break;
			}
			default:
			{
				Shader shader2 = ShaderCache.Acquire(ShaderDict[shader]);
				mat.shader = shader2;
				mat.DisableKeyword("BRIGHTNESS_CLAMP_ON");
				mat.EnableKeyword("BRIGHTNESS_CLAMP_OFF");
				mat.SetFloat("_EmissivePower", 75f);
				mat.SetFloat("_EmissiveColorPower", 1.55f);
				break;
			}
			}
			Log("Applied Shader: " + shader + " With Colour: " + Colours.FirstOrDefault((KeyValuePair<string, Color> x) => x.Value == colour).Key);
		}

		public static void shaderChanger(AIActor actor, string shader, Color color)
		{
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Expected O, but got Unknown
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Expected O, but got Unknown
			//IL_00ad: 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)
			if (shader == "Paradox")
			{
				for (int i = 0; i < ((BraveBehaviour)actor).healthHaver.bodySprites.Count; i++)
				{
					MeshRenderer component = ((Component)((BraveBehaviour)actor).healthHaver.bodySprites[i]).GetComponent<MeshRenderer>();
					Material[] array = ((Renderer)component).sharedMaterials;
					Array.Resize(ref array, array.Length + 1);
					Material val = new Material(ShaderCache.Acquire(ShaderDict[shader]));
					val.SetTexture("_MainTex", array[0].GetTexture("_MainTex"));
					GameObject val2 = (GameObject)ResourceCache.Acquire("Global Prefabs/VFX_ParadoxPortal");
					ParadoxPortalController component2 = val2.GetComponent<ParadoxPortalController>();
					val.SetTexture("_EeveeTex", (Texture)(object)component2.CosmicTex);
					val.SetColor("_OverrideColor", Color.clear);
					val.SetColor("_FlatColor", Color.clear);
					val.SetFloat("Perpendicular", 1f);
					val.SetFloat("_StencilVal", 146f);
					array[^1] = val;
					((Renderer)component).sharedMaterials = array;
					Log("Applied Shader: " + shader);
				}
			}
			else
			{
				Material material = ((BraveBehaviour)((Component)actor).GetComponent<tk2dSprite>()).renderer.material;
				MatHandler(material, shader, color);
				((tk2dBaseSprite)((Component)actor).GetComponent<tk2dSprite>()).OverrideMaterialMode = (SpriteMaterialOverrideMode)2;
			}
		}

		public static void PreRunStart(Action<GameStatsManager, PlayerController> orig, GameStatsManager self, PlayerController player)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			orig(self, player);
			RunColour = RandomColour(avoid: true);
			currentShader = RandomShader();
			ShaderMap.Clear();
		}

		public void Exit()
		{
		}

		public void Init()
		{
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			RandFamConfig.Init(this);
			AIActor.OnPreStart = (Action<AIActor>)Delegate.Combine(AIActor.OnPreStart, new Action<AIActor>(preStartActorHandler));
			currentShader = RandomShader();
			new Hook((MethodBase)typeof(GameStatsManager).GetMethod("BeginNewSession", BindingFlags.Instance | BindingFlags.Public), typeof(Plugin).GetMethod("PreRunStart"));
			new Hook((MethodBase)typeof(PlayerOrbital).GetMethod("Initialize", BindingFlags.Instance | BindingFlags.Public), typeof(Plugin).GetMethod("preInitializeOrbitalHandler"));
			new Hook((MethodBase)typeof(PlayerOrbitalFollower).GetMethod("Initialize", BindingFlags.Instance | BindingFlags.Public), typeof(Plugin).GetMethod("preInitializeOrbitalFollowerHandler"));
			Type[] array = new Type[2]
			{
				typeof(string),
				typeof(Texture)
			};
		}

		public void GMStart(GameManager g)
		{
			Log("Randomised Familiar Shaders v1.0.6 started successfully.", "#00FFFF");
			g.OnNewLevelFullyLoaded += NewFloor;
		}

		public static void Log(string text, string color = "#FFFFFF")
		{
			ETGModConsole.Log((object)("<color=" + color + ">" + text + "</color>"), false);
		}
	}
}