Decompiled source of CustomBodylogColor v1.1.0

Mods/StandaloneBodyLogColor.dll

Decompiled a month ago
using System;
using System.Collections;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BoneLib;
using BoneLib.BoneMenu;
using Il2CppSLZ.Bonelab;
using Il2CppSLZ.Marrow;
using MelonLoader;
using Microsoft.CodeAnalysis;
using StandaloneBodyLogColor;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(BodyLogColorMod), "BodyLog & Radial Color", "1.0.0", "DOOBER", null)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("StandaloneBodyLogColor")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("StandaloneBodyLogColor")]
[assembly: AssemblyTitle("StandaloneBodyLogColor")]
[assembly: AssemblyVersion("1.0.0.0")]
[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 StandaloneBodyLogColor
{
	public class BodyLogColorMod : MelonMod
	{
		private static Page _mainPage;

		public override void OnInitializeMelon()
		{
			((MelonBase)this).LoggerInstance.Msg("BodyLog & Radial Menu Color mod loaded");
		}

		public override void OnLateInitializeMelon()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			_mainPage = Page.Root.CreatePage("BodyLog Color", Color.magenta, 0, true);
			BuildMenu();
		}

		public override void OnUpdate()
		{
			BodyLogColorController.Update();
		}

		private void BuildMenu()
		{
			//IL_000b: 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_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: 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_023a: Unknown result type (might be due to invalid IL or missing references)
			//IL_027e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_031d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0361: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0400: Unknown result type (might be due to invalid IL or missing references)
			//IL_0444: Unknown result type (might be due to invalid IL or missing references)
			//IL_0488: Unknown result type (might be due to invalid IL or missing references)
			//IL_04cc: Unknown result type (might be due to invalid IL or missing references)
			_mainPage.CreateBool("Enabled", Color.white, BodyLogColorController.Enabled, (Action<bool>)delegate(bool value)
			{
				BodyLogColorController.Enabled = value;
			});
			_mainPage.CreateFunction("Apply Colors Now", Color.green, (Action)delegate
			{
				BodyLogColorController.ApplyAll();
			});
			Page val = _mainPage.CreatePage("Body Log Tint", Color.cyan, 0, true);
			val.CreateFloat("R", Color.red, BodyLogColorController.BodyLogR, 5f, 0f, 255f, (Action<float>)delegate(float value)
			{
				BodyLogColorController.BodyLogR = value;
			});
			val.CreateFloat("G", Color.green, BodyLogColorController.BodyLogG, 5f, 0f, 255f, (Action<float>)delegate(float value)
			{
				BodyLogColorController.BodyLogG = value;
			});
			val.CreateFloat("B", Color.blue, BodyLogColorController.BodyLogB, 5f, 0f, 255f, (Action<float>)delegate(float value)
			{
				BodyLogColorController.BodyLogB = value;
			});
			val.CreateFloat("A", Color.white, BodyLogColorController.BodyLogA, 5f, 0f, 255f, (Action<float>)delegate(float value)
			{
				BodyLogColorController.BodyLogA = value;
			});
			Page val2 = _mainPage.CreatePage("Ball Color", Color.yellow, 0, true);
			val2.CreateFloat("R", Color.red, BodyLogColorController.BallR, 5f, 0f, 255f, (Action<float>)delegate(float value)
			{
				BodyLogColorController.BallR = value;
			});
			val2.CreateFloat("G", Color.green, BodyLogColorController.BallG, 5f, 0f, 255f, (Action<float>)delegate(float value)
			{
				BodyLogColorController.BallG = value;
			});
			val2.CreateFloat("B", Color.blue, BodyLogColorController.BallB, 5f, 0f, 255f, (Action<float>)delegate(float value)
			{
				BodyLogColorController.BallB = value;
			});
			val2.CreateFloat("A", Color.white, BodyLogColorController.BallA, 5f, 0f, 255f, (Action<float>)delegate(float value)
			{
				BodyLogColorController.BallA = value;
			});
			Page val3 = _mainPage.CreatePage("Line Color", Color.green, 0, true);
			val3.CreateFloat("R", Color.red, BodyLogColorController.LineR, 5f, 0f, 255f, (Action<float>)delegate(float value)
			{
				BodyLogColorController.LineR = value;
			});
			val3.CreateFloat("G", Color.green, BodyLogColorController.LineG, 5f, 0f, 255f, (Action<float>)delegate(float value)
			{
				BodyLogColorController.LineG = value;
			});
			val3.CreateFloat("B", Color.blue, BodyLogColorController.LineB, 5f, 0f, 255f, (Action<float>)delegate(float value)
			{
				BodyLogColorController.LineB = value;
			});
			val3.CreateFloat("A", Color.white, BodyLogColorController.LineA, 5f, 0f, 255f, (Action<float>)delegate(float value)
			{
				BodyLogColorController.LineA = value;
			});
			Page val4 = _mainPage.CreatePage("Radial Menu Color", Color.red, 0, true);
			val4.CreateFloat("R", Color.red, BodyLogColorController.RadialR, 5f, 0f, 255f, (Action<float>)delegate(float value)
			{
				BodyLogColorController.RadialR = value;
			});
			val4.CreateFloat("G", Color.green, BodyLogColorController.RadialG, 5f, 0f, 255f, (Action<float>)delegate(float value)
			{
				BodyLogColorController.RadialG = value;
			});
			val4.CreateFloat("B", Color.blue, BodyLogColorController.RadialB, 5f, 0f, 255f, (Action<float>)delegate(float value)
			{
				BodyLogColorController.RadialB = value;
			});
			val4.CreateFloat("A", Color.white, BodyLogColorController.RadialA, 5f, 0f, 255f, (Action<float>)delegate(float value)
			{
				BodyLogColorController.RadialA = value;
			});
		}
	}
	public static class BodyLogColorController
	{
		private static bool _enabled = false;

		private static float _bodyLogR = 255f;

		private static float _bodyLogG = 255f;

		private static float _bodyLogB = 255f;

		private static float _bodyLogA = 255f;

		private static float _ballR = 255f;

		private static float _ballG = 255f;

		private static float _ballB = 255f;

		private static float _ballA = 255f;

		private static float _lineR = 255f;

		private static float _lineG = 255f;

		private static float _lineB = 255f;

		private static float _lineA = 255f;

		private static float _radialR = 255f;

		private static float _radialG = 255f;

		private static float _radialB = 255f;

		private static float _radialA = 255f;

		public static bool Enabled
		{
			get
			{
				return _enabled;
			}
			set
			{
				_enabled = value;
			}
		}

		public static float BodyLogR
		{
			get
			{
				return _bodyLogR;
			}
			set
			{
				_bodyLogR = value;
			}
		}

		public static float BodyLogG
		{
			get
			{
				return _bodyLogG;
			}
			set
			{
				_bodyLogG = value;
			}
		}

		public static float BodyLogB
		{
			get
			{
				return _bodyLogB;
			}
			set
			{
				_bodyLogB = value;
			}
		}

		public static float BodyLogA
		{
			get
			{
				return _bodyLogA;
			}
			set
			{
				_bodyLogA = value;
			}
		}

		public static float BallR
		{
			get
			{
				return _ballR;
			}
			set
			{
				_ballR = value;
			}
		}

		public static float BallG
		{
			get
			{
				return _ballG;
			}
			set
			{
				_ballG = value;
			}
		}

		public static float BallB
		{
			get
			{
				return _ballB;
			}
			set
			{
				_ballB = value;
			}
		}

		public static float BallA
		{
			get
			{
				return _ballA;
			}
			set
			{
				_ballA = value;
			}
		}

		public static float LineR
		{
			get
			{
				return _lineR;
			}
			set
			{
				_lineR = value;
			}
		}

		public static float LineG
		{
			get
			{
				return _lineG;
			}
			set
			{
				_lineG = value;
			}
		}

		public static float LineB
		{
			get
			{
				return _lineB;
			}
			set
			{
				_lineB = value;
			}
		}

		public static float LineA
		{
			get
			{
				return _lineA;
			}
			set
			{
				_lineA = value;
			}
		}

		public static float RadialR
		{
			get
			{
				return _radialR;
			}
			set
			{
				_radialR = value;
			}
		}

		public static float RadialG
		{
			get
			{
				return _radialG;
			}
			set
			{
				_radialG = value;
			}
		}

		public static float RadialB
		{
			get
			{
				return _radialB;
			}
			set
			{
				_radialB = value;
			}
		}

		public static float RadialA
		{
			get
			{
				return _radialA;
			}
			set
			{
				_radialA = value;
			}
		}

		private static Color BodyLogColor => ToUnityColor(_bodyLogR, _bodyLogG, _bodyLogB, _bodyLogA);

		private static Color BallColor => ToUnityColor(_ballR, _ballG, _ballB, _ballA);

		private static Color LineColor => ToUnityColor(_lineR, _lineG, _lineB, _lineA);

		private static Color RadialColor => ToUnityColor(_radialR, _radialG, _radialB, _radialA);

		private static Color ToUnityColor(float r, float g, float b, float a)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			return new Color(r / 255f, g / 255f, b / 255f, a / 255f);
		}

		public static void ApplyBodyLogColors()
		{
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: 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)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				PhysicsRig physicsRig = Player.PhysicsRig;
				if ((Object)(object)physicsRig == (Object)null)
				{
					return;
				}
				Transform val = null;
				Transform elbowRt = ((Rig)physicsRig).m_elbowRt;
				if ((Object)(object)elbowRt != (Object)null)
				{
					val = elbowRt.Find("BodyLogSlot/BodyLog");
				}
				if ((Object)(object)val == (Object)null)
				{
					Transform elbowLf = ((Rig)physicsRig).m_elbowLf;
					if ((Object)(object)elbowLf != (Object)null)
					{
						val = elbowLf.Find("BodyLogSlot/BodyLog");
					}
				}
				if ((Object)(object)val == (Object)null)
				{
					return;
				}
				PullCordDevice component = ((Component)val).GetComponent<PullCordDevice>();
				if ((Object)(object)component == (Object)null)
				{
					return;
				}
				component.hologramTint = BodyLogColor;
				LineRenderer lineRenderer = component.lineRenderer;
				if ((Object)(object)lineRenderer != (Object)null)
				{
					lineRenderer.startColor = LineColor;
					lineRenderer.endColor = LineColor;
				}
				Transform val2 = val.Find("spheregrip/Sphere/Art/GrabGizmo");
				if ((Object)(object)val2 != (Object)null)
				{
					MeshRenderer component2 = ((Component)val2).GetComponent<MeshRenderer>();
					if ((Object)(object)component2 != (Object)null)
					{
						((Renderer)component2).material.color = BallColor;
					}
				}
			}
			catch (Exception ex)
			{
				MelonLogger.Warning("[BodyLogColor] Apply body log error: " + ex.Message);
			}
		}

		public static void ApplyRadialMenuColors()
		{
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_024a: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				UIRig uIRig = Player.UIRig;
				if ((Object)(object)uIRig == (Object)null)
				{
					return;
				}
				object obj = ((object)uIRig).GetType().GetProperty("popUpMenu", BindingFlags.Instance | BindingFlags.Public)?.GetValue(uIRig);
				if (obj == null)
				{
					return;
				}
				object obj2 = obj.GetType().GetProperty("radialPageView", BindingFlags.Instance | BindingFlags.Public)?.GetValue(obj);
				if (obj2 == null)
				{
					return;
				}
				object obj3 = obj2.GetType().GetProperty("buttons", BindingFlags.Instance | BindingFlags.Public)?.GetValue(obj2);
				if (obj3 == null || !(obj3 is IEnumerable enumerable))
				{
					return;
				}
				Color radialColor = RadialColor;
				foreach (object item in enumerable)
				{
					if (item == null)
					{
						continue;
					}
					Type type = item.GetType();
					type.GetProperty("color2", BindingFlags.Instance | BindingFlags.Public)?.SetValue(item, radialColor);
					object obj4 = type.GetProperty("textMesh", BindingFlags.Instance | BindingFlags.Public)?.GetValue(item);
					obj4?.GetType().GetProperty("color", BindingFlags.Instance | BindingFlags.Public)?.SetValue(obj4, radialColor);
					object obj5 = type.GetProperty("icon", BindingFlags.Instance | BindingFlags.Public)?.GetValue(item);
					if (obj5 != null)
					{
						MethodInfo method = obj5.GetType().GetMethod("GetComponent", new Type[1] { typeof(string) });
						if (method != null)
						{
							object obj6 = method.Invoke(obj5, new object[1] { "CanvasRenderer" });
							obj6?.GetType().GetMethod("SetColor", new Type[1] { typeof(Color) })?.Invoke(obj6, new object[1] { radialColor });
						}
					}
				}
			}
			catch (Exception ex)
			{
				MelonLogger.Warning("[BodyLogColor] Apply radial menu error: " + ex.Message);
			}
		}

		public static void ApplyAll()
		{
			ApplyBodyLogColors();
			ApplyRadialMenuColors();
		}

		public static void Update()
		{
			if (!_enabled)
			{
				return;
			}
			try
			{
				UIRig uIRig = Player.UIRig;
				if ((Object)(object)uIRig == (Object)null)
				{
					return;
				}
				object obj = ((object)uIRig).GetType().GetProperty("popUpMenu", BindingFlags.Instance | BindingFlags.Public)?.GetValue(uIRig);
				if (obj != null)
				{
					PropertyInfo property = obj.GetType().GetProperty("gameObject", BindingFlags.Instance | BindingFlags.Public);
					if (property == null)
					{
						property = typeof(Component).GetProperty("gameObject");
					}
					object? obj2 = property?.GetValue(obj);
					GameObject val = (GameObject)((obj2 is GameObject) ? obj2 : null);
					if ((Object)(object)val != (Object)null && val.activeInHierarchy)
					{
						ApplyRadialMenuColors();
					}
				}
			}
			catch
			{
			}
		}
	}
}