using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Il2CppSystem;
using Microsoft.CodeAnalysis;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("SightColors")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("SightColors")]
[assembly: AssemblyTitle("SightColors")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
}
namespace SightColors
{
[BepInPlugin("SightColors", "SightColors", "0.0.1")]
public class Plugin : BasePlugin
{
public class SightColors : MonoBehaviour
{
public static void Setup()
{
//IL_0196: Unknown result type (might be due to invalid IL or missing references)
//IL_01a2: 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_01c6: Unknown result type (might be due to invalid IL or missing references)
//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
//IL_01de: Unknown result type (might be due to invalid IL or missing references)
//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
//IL_0202: Unknown result type (might be due to invalid IL or missing references)
//IL_020e: Unknown result type (might be due to invalid IL or missing references)
//IL_08e5: Unknown result type (might be due to invalid IL or missing references)
Dictionary<string, Dictionary<int, Dictionary<int, int[]>>> dictionary = new Dictionary<string, Dictionary<int, Dictionary<int, int[]>>>();
dictionary["asd"] = new Dictionary<int, Dictionary<int, int[]>>
{
[0] = new Dictionary<int, int[]>
{
[0] = new int[4],
[1] = new int[4],
[2] = new int[4]
},
[1] = new Dictionary<int, int[]>
{
[0] = new int[4],
[1] = new int[4],
[2] = new int[4]
},
[2] = new Dictionary<int, int[]>
{
[0] = new int[4],
[1] = new int[4],
[2] = new int[4]
}
};
Dictionary<string, Dictionary<int, Dictionary<int, int[]>>> dictionary2 = dictionary;
foreach (string item in namesToColor)
{
dictionary2[item] = new Dictionary<int, Dictionary<int, int[]>>
{
[0] = new Dictionary<int, int[]>
{
[0] = new int[4],
[1] = new int[4],
[2] = new int[4]
},
[1] = new Dictionary<int, int[]>
{
[0] = new int[4],
[1] = new int[4],
[2] = new int[4]
},
[2] = new Dictionary<int, int[]>
{
[0] = new int[4],
[1] = new int[4],
[2] = new int[4]
}
};
SightColorsColors[item] = new Dictionary<int, Dictionary<int, Color>>
{
[0] = new Dictionary<int, Color>
{
[0] = Color.black,
[1] = Color.black,
[2] = Color.black
},
[1] = new Dictionary<int, Color>
{
[0] = Color.black,
[1] = Color.black,
[2] = Color.black
},
[2] = new Dictionary<int, Color>
{
[0] = Color.black,
[1] = Color.black,
[2] = Color.black
}
};
}
dictionary2["Bataldo Custom K330"][0][0] = new int[4] { 455, 290, 0, 555 };
dictionary2["Bataldo Custom K330"][0][1] = new int[4] { 455, 290, 0, 555 };
dictionary2["Bataldo Custom K330"][1][0] = new int[4] { 0, 0, 0, 255 };
dictionary2["Bataldo Custom K330"][1][1] = new int[4] { 0, 0, 0, 255 };
dictionary2["Bataldo Custom K330"][1][2] = new int[4] { 0, 0, 0, 255 };
dictionary2["Bataldo Custom K330"][2][0] = new int[4] { 0, 0, 0, 255 };
dictionary2["Bataldo Custom K330"][2][1] = new int[4] { 0, 0, 0, 255 };
dictionary2["Bataldo Custom K330"][2][2] = new int[4] { 0, 0, 0, 255 };
dictionary2["Van Auken LTC5"][0][0] = new int[4] { 250, 227, 0, 255 };
dictionary2["Van Auken LTC5"][0][1] = new int[4] { 250, 227, 0, 255 };
dictionary2["Van Auken LTC5"][0][2] = new int[4] { 350, 327, 0, 455 };
dictionary2["Van Auken LTC5"][1][0] = new int[4] { 0, 0, 0, 255 };
dictionary2["Van Auken LTC5"][1][1] = new int[4] { 0, 0, 0, 255 };
dictionary2["Van Auken LTC5"][1][2] = new int[4] { 0, 0, 0, 255 };
dictionary2["Van Auken LTC5"][2][0] = new int[4] { 0, 0, 0, 255 };
dictionary2["Van Auken LTC5"][2][1] = new int[4] { 0, 0, 0, 255 };
dictionary2["Van Auken LTC5"][2][2] = new int[4] { 0, 0, 0, 255 };
dictionary2["Accrat ND6"][0][0] = new int[4] { 0, 655, 605, 600 };
dictionary2["Accrat ND6"][0][1] = new int[4] { 0, 655, 605, 600 };
dictionary2["Accrat ND6"][0][2] = new int[4] { 0, 655, 605, 600 };
dictionary2["Accrat ND6"][1][0] = new int[4] { 0, 0, 0, 255 };
dictionary2["Accrat ND6"][1][1] = new int[4] { 0, 0, 0, 255 };
dictionary2["Accrat ND6"][1][2] = new int[4] { 0, 0, 0, 255 };
dictionary2["Accrat ND6"][2][0] = new int[4] { 0, 0, 0, 255 };
dictionary2["Accrat ND6"][2][1] = new int[4] { 0, 0, 0, 255 };
dictionary2["Accrat ND6"][2][2] = new int[4] { 0, 0, 0, 255 };
dictionary2["Malatack HXC"][0][0] = new int[4] { 255, 223, 0, 300 };
dictionary2["Malatack HXC"][0][2] = new int[4] { 0, 181, 255, 150 };
dictionary2["Malatack HXC"][1][0] = new int[4] { 0, 0, 0, 255 };
dictionary2["Malatack HXC"][1][1] = new int[4] { 0, 0, 0, 255 };
dictionary2["Malatack HXC"][1][2] = new int[4] { 0, 0, 0, 255 };
dictionary2["Malatack HXC"][2][0] = new int[4] { 0, 0, 0, 255 };
dictionary2["Malatack HXC"][2][1] = new int[4] { 0, 0, 0, 255 };
dictionary2["Malatack HXC"][2][2] = new int[4] { 0, 0, 0, 255 };
Debug.Log(Object.op_Implicit("SightColors - COLORS LOADED.."));
foreach (string item2 in namesToColor)
{
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 3; j++)
{
Debug.Log(Object.op_Implicit($"SightColors - {item2} {i} {j} {dictionary2[item2][i][j].Length}"));
int num = dictionary2[item2][i][j][0];
int num2 = dictionary2[item2][i][j][1];
int num3 = dictionary2[item2][i][j][2];
int num4 = dictionary2[item2][i][j][3];
float num5 = 0f;
float num6 = 0f;
float num7 = 0f;
float num8 = 0f;
if (num > 0)
{
num5 = (float)num / 255f;
}
if (num2 > 0)
{
num6 = (float)num2 / 255f;
}
if (num3 > 0)
{
num7 = (float)num3 / 255f;
}
if (num4 > 0)
{
num8 = (float)num4 / 255f;
}
SightColorsColors[item2][i][j] = new Color(num5, num6, num7, num8);
}
}
}
}
public static void ColorMe(ItemEquippable __instance)
{
//IL_02f7: Unknown result type (might be due to invalid IL or missing references)
//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
//IL_040f: Unknown result type (might be due to invalid IL or missing references)
//IL_0414: Unknown result type (might be due to invalid IL or missing references)
//IL_0326: Unknown result type (might be due to invalid IL or missing references)
//IL_045a: Unknown result type (might be due to invalid IL or missing references)
//IL_045f: Unknown result type (might be due to invalid IL or missing references)
//IL_043e: Unknown result type (might be due to invalid IL or missing references)
//IL_04a5: Unknown result type (might be due to invalid IL or missing references)
//IL_04aa: Unknown result type (might be due to invalid IL or missing references)
//IL_0489: Unknown result type (might be due to invalid IL or missing references)
//IL_04d4: Unknown result type (might be due to invalid IL or missing references)
int key = 0;
string text = ((Object)__instance).name.Replace("GearItem_", "");
Debug.Log(Object.op_Implicit("SightColors - arrived at " + ((Object)__instance).name + " - " + text));
if (!namesToColor.Contains(text))
{
return;
}
Debug.Log(Object.op_Implicit("SightColors - working on " + text));
GameObject sightPart = __instance.GearPartHolder.SightPart;
GameObject meleeNeckPart = __instance.GearPartHolder.MeleeNeckPart;
GameObject meleeHeadPart = __instance.GearPartHolder.MeleeHeadPart;
GameObject frontPart = __instance.GearPartHolder.FrontPart;
foreach (GameObject item in new List<GameObject> { sightPart, meleeNeckPart, meleeHeadPart, frontPart })
{
if ((Object)(object)item == (Object)null)
{
continue;
}
if ((Object)(object)item == (Object)(object)__instance.GearPartHolder.SightPart)
{
key = 0;
}
if ((Object)(object)item == (Object)(object)__instance.GearPartHolder.FrontPart)
{
key = 0;
}
if ((Object)(object)item == (Object)(object)__instance.GearPartHolder.MeleeNeckPart)
{
key = 1;
}
if ((Object)(object)item == (Object)(object)__instance.GearPartHolder.MeleeHeadPart)
{
key = 2;
}
foreach (Transform componentsInChild in item.GetComponentsInChildren<Transform>())
{
int num = 0;
foreach (MeshRenderer component in ((Component)componentsInChild).GetComponents<MeshRenderer>())
{
if ((Object)(object)componentsInChild == (Object)null || (Object)(object)component == (Object)null)
{
continue;
}
if (Regex.Match(((Object)componentsInChild).name.ToLower(), "_sight", RegexOptions.IgnoreCase).Success)
{
num = 1;
}
if (Regex.Match(((Object)componentsInChild).name.ToLower(), "iron", RegexOptions.IgnoreCase).Success)
{
num = 1;
}
if (Regex.Match(((Object)((Renderer)component).material).name.ToLower(), "pistol_sight", RegexOptions.IgnoreCase).Success)
{
num = 1;
}
if (Regex.Match(((Object)((Renderer)component).material).name.ToLower(), "emissive", RegexOptions.IgnoreCase).Success)
{
num = 1;
}
if (Regex.Match(((Object)componentsInChild).name.ToLower(), "glass", RegexOptions.IgnoreCase).Success)
{
num = 2;
}
if (Regex.Match(((Object)componentsInChild).name.ToLower(), "holo", RegexOptions.IgnoreCase).Success)
{
num = 2;
}
if (Regex.Match(((Object)componentsInChild).name.ToLower(), "_picture", RegexOptions.IgnoreCase).Success)
{
num = 2;
}
if (num == 1)
{
Debug.Log(Object.op_Implicit($"SightColors - we do sights on {((Object)((Component)__instance).gameObject).name} {((Object)componentsInChild).name} {((Object)component).name}"));
if (SightColorsColors[text][key][0] != Color.black)
{
((Renderer)component).material.SetColor("_EmissiveColor", SightColorsColors[text][key][0]);
}
((Renderer)component).material.SetTexture("_MainTex", (Texture)(object)Texture2D.grayTexture);
((Renderer)component).material.SetTexture("_BumpMap", (Texture)(object)Texture2D.grayTexture);
((Renderer)component).material.SetTexture("_MetallicGlossMap", (Texture)(object)Texture2D.grayTexture);
((Renderer)component).material.SetTexture("_EmissiveMap", (Texture)(object)Texture2D.grayTexture);
}
if (num == 2)
{
Debug.Log(Object.op_Implicit($"SightColors - we do sights on {((Object)((Component)__instance).gameObject).name} {((Object)componentsInChild).name} {((Object)component).name}"));
if (SightColorsColors[text][key][0] != Color.black)
{
((Renderer)component).material.SetColor("_ReticuleColorA", SightColorsColors[text][key][0]);
}
if (SightColorsColors[text][key][1] != Color.black)
{
((Renderer)component).material.SetColor("_ReticuleColorB", SightColorsColors[text][key][1]);
}
if (SightColorsColors[text][key][2] != Color.black)
{
((Renderer)component).material.SetColor("_ReticuleColorC", SightColorsColors[text][key][2]);
}
}
}
}
}
}
}
[HarmonyPatch]
private class SightColorsPatch1
{
[HarmonyPatch(typeof(ItemEquippable), "OnWield")]
[HarmonyPrefix]
private static bool Prefix(ItemEquippable __instance)
{
SightColors.ColorMe(__instance);
return true;
}
}
public static List<string> namesToColor = new List<string> { "Bataldo Custom K330", "Van Auken LTC5", "Malatack HXC", "Accrat ND6" };
public static Dictionary<string, Dictionary<int, Dictionary<int, Color>>> SightColorsColors = new Dictionary<string, Dictionary<int, Dictionary<int, Color>>>();
public override void Load()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
new Harmony("SightColors").PatchAll();
Debug.Log(Object.op_Implicit("SightColors - LOADING"));
SightColors.Setup();
}
}
}