Decompiled source of ColorfulGlowStick v2.0.1

ColorfulGlowStick_1.2.1(recommended).dll

Decompiled 3 months ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = "")]
[assembly: AssemblyVersion("1.2.1.0")]
namespace ColorfulGlowStick;

[BepInPlugin("F_O_G.ColorfulGlowStick", "F_O_G.ColorfulGlowStick", "1.2.1")]
public class EntryPoint : BasePlugin
{
	public static Random shinestick_random;

	public static ConfigFile configFile;

	private static ConfigEntry<float> _lightrange;

	private static ConfigEntry<bool> _forcelight;

	private static ConfigEntry<float> _coloralpha;

	private static ConfigEntry<bool> _logcolor;

	private static ConfigEntry<bool> _fixedcolor;

	private static ConfigEntry<string> _prefid_origin;

	private static ConfigEntry<float> _lighttime;

	private static ConfigEntry<bool> _prefid_rolling;

	public static int CGSprefidRoller;

	public static float CGSlightRange => _lightrange.Value;

	public static bool CGSforceLight => _forcelight.Value;

	public static float CGScolorAlpha => _coloralpha.Value;

	public static bool CGSlogColor => _logcolor.Value;

	public static bool CGSfixedColor => _fixedcolor.Value;

	public static string CGSprefid_origin => _prefid_origin.Value;

	public static float CGSlightTime => _lighttime.Value;

	public static bool CGSprefid_rolling => _prefid_rolling.Value;

	public override void Load()
	{
		//IL_0010: 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_014a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0158: Expected O, but got Unknown
		Logout.LogInstance = ((BasePlugin)this).Log;
		Harmony val = new Harmony("F_O_G.ColorfulGlowStick");
		_lightrange = configFile.Bind<float>("A: GlowStick Properties Setting", "LightRange", 5f, "The light range of glowsticks.( Meters )");
		_coloralpha = configFile.Bind<float>("A: GlowStick Properties Setting", "Brightness", 0.3f, "The brightness of glowsticks.( Min 0.0 - Max 1.0 )");
		_lighttime = configFile.Bind<float>("A: GlowStick Properties Setting", "LightTime", 60f, "The brightest duration of glowsticks.( Seconds )");
		_fixedcolor = configFile.Bind<bool>("A: GlowStick Properties Setting", "UseColorGenerator", true, "Use the [Color Generator Mode], generate a completely random color everytime.(Else use [Prefined Color Mode])");
		_forcelight = configFile.Bind<bool>("B: Color Generator Mode", "ForceBright", true, "Allow glow sticks appear dark color when this option disable.");
		_logcolor = configFile.Bind<bool>("A: GlowStick Properties Setting", "LogColorValue", false, "Use for debug. Out print the color value of the glow stick to log when throwing a new glowstick.");
		_prefid_origin = configFile.Bind<string>("C: Prefined Color Mode", "ColorPool", "255,63,0 0,255,63 63,0,255", "All possible colors the glowsticks can use. Each color use three 0-255 RGB value, and separate other color with space.");
		_prefid_rolling = configFile.Bind<bool>("C: Prefined Color Mode", "RandomPickColor", true, "If this option disable, the [Prefined Color Mode] will pick colors keeping the sort of color pool rather than randomly.");
		MethodInfo method = typeof(GlowstickInstance).GetMethod("Setup");
		MethodInfo method2 = typeof(ColorfulGlowStick).GetMethod("UpdateProperties");
		val.Patch((MethodBase)method, new HarmonyMethod(method2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		val.PatchAll();
	}

	static EntryPoint()
	{
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Expected O, but got Unknown
		shinestick_random = new Random();
		configFile = new ConfigFile(Path.Combine(Paths.ConfigPath, "F_O_G.ColorfulGlowStick.cfg"), true);
		CGSprefidRoller = 0;
	}
}
public static class ColorfulGlowStick
{
	public static void UpdateProperties(GlowstickInstance __instance)
	{
		//IL_0181: Unknown result type (might be due to invalid IL or missing references)
		//IL_0193: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_037a: Unknown result type (might be due to invalid IL or missing references)
		//IL_038c: Unknown result type (might be due to invalid IL or missing references)
		//IL_039e: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b0: Unknown result type (might be due to invalid IL or missing references)
		__instance.s_lightRange = EntryPoint.CGSlightRange;
		__instance.s_lightLifeTime = EntryPoint.CGSlightTime;
		float num = EntryPoint.CGScolorAlpha;
		float num2 = 0f;
		float num3 = 0f;
		float num4 = 0f;
		if (num > 1f)
		{
			num = 1f;
		}
		else if (num < 0f)
		{
			num = 0f;
		}
		if (EntryPoint.CGSfixedColor)
		{
			if (EntryPoint.CGSforceLight)
			{
				for (int num5 = 0; num5 <= 120; num5 = (int)num2 + (int)num3 + (int)num4)
				{
					num2 = EntryPoint.shinestick_random.Next(1, 100);
					num3 = EntryPoint.shinestick_random.Next(1, 100);
					num4 = EntryPoint.shinestick_random.Next(1, 100);
				}
			}
			else
			{
				num2 = EntryPoint.shinestick_random.Next(1, 100);
				num3 = EntryPoint.shinestick_random.Next(1, 100);
				num4 = EntryPoint.shinestick_random.Next(1, 100);
			}
			num2 /= 10f;
			num3 /= 10f;
			num4 /= 10f;
			if (EntryPoint.CGSlogColor)
			{
				Logout.Log("A new glow stick has been throwed with color ( " + (int)(num2 * 25.5f) + "/255 , " + (int)(num3 * 25.5f) + "/255 , " + (int)(num4 * 25.5f) + "/255 , " + num + "/1.0 ).");
			}
			num2 *= num;
			num3 *= num;
			num4 *= num;
			__instance.m_LightColorTarget = new Color(num2, num3, num4, 1f);
			GlowstickInstance.s_lightColorYellow = new Color(num2, num3, num4, 1f);
			GlowstickInstance.s_lightColorChristmas = new Color(num2, num3, num4, 1f);
			GlowstickInstance.s_lightColorHalloween = new Color(num2, num3, num4, 1f);
			return;
		}
		string[] array = EntryPoint.CGSprefid_origin.Split(' ', StringSplitOptions.RemoveEmptyEntries);
		string[] array2 = new string[3];
		if (EntryPoint.CGSprefid_rolling)
		{
			array2 = array[EntryPoint.shinestick_random.Next(array.Length)].Split(',');
		}
		else
		{
			array2 = array[EntryPoint.CGSprefidRoller].Split(',');
			EntryPoint.CGSprefidRoller++;
			if (EntryPoint.CGSprefidRoller >= array.Length)
			{
				EntryPoint.CGSprefidRoller = 0;
			}
		}
		num2 = (float)Convert.ToDouble(array2[0]);
		num3 = (float)Convert.ToDouble(array2[1]);
		num4 = (float)Convert.ToDouble(array2[2]);
		num2 = ((num2 > 255f) ? 10f : ((!(num2 < 0f)) ? (num2 / 25.5f) : 0f));
		num3 = ((num3 > 255f) ? 10f : ((!(num3 < 0f)) ? (num3 / 25.5f) : 0f));
		num4 = ((num4 > 255f) ? 10f : ((!(num4 < 0f)) ? (num4 / 25.5f) : 0f));
		if (EntryPoint.CGSlogColor)
		{
			Logout.Log("Glow sticks using predefined light color ( " + num2 * 25.5f + "/255 , " + num3 * 25.5f + "/255 , " + num4 * 25.5f + "/255 , " + num + "/1.0 ) in total " + array.Length + ".");
		}
		num2 *= num;
		num3 *= num;
		num4 *= num;
		__instance.m_LightColorTarget = new Color(num2, num3, num4, 1f);
		GlowstickInstance.s_lightColorYellow = new Color(num2, num3, num4, 1f);
		GlowstickInstance.s_lightColorChristmas = new Color(num2, num3, num4, 1f);
		GlowstickInstance.s_lightColorHalloween = new Color(num2, num3, num4, 1f);
	}
}
public static class Logout
{
	public static ManualLogSource LogInstance;

	public static void Log(string format, params object[] AoiYuki)
	{
		Log(string.Format(format, AoiYuki));
	}

	public static void Log(string str)
	{
		ManualLogSource logInstance = LogInstance;
		logInstance.Log((LogLevel)8, (object)str);
	}
}

ColorfulGlowStick_2.0.0(network_testing_but_failured).dll

Decompiled 3 months ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using GTFO.API;
using HarmonyLib;
using SNetwork;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = "")]
[assembly: AssemblyVersion("2.0.0.0")]
namespace ColorfulGlowStick;

[BepInPlugin("ColorfulGlowStick", "ColorfulGlowStick", "2.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class EntryPoint : BasePlugin
{
	public static Random shinestick_random;

	public static ConfigFile configFile;

	private static ConfigEntry<float> _lightrange;

	private static ConfigEntry<bool> _forcelight;

	private static ConfigEntry<float> _coloralpha;

	private static ConfigEntry<bool> _logcolor;

	private static ConfigEntry<bool> _fixedcolor;

	private static ConfigEntry<string> _prefid_origin;

	private static ConfigEntry<float> _lighttime;

	private static ConfigEntry<bool> _prefid_rolling;

	public static int CGSprefidRoller;

	private static ConfigEntry<bool> _enable_network;

	public static float CGSlightRange => _lightrange.Value;

	public static bool CGSforceLight => _forcelight.Value;

	public static float CGScolorAlpha => _coloralpha.Value;

	public static bool CGSlogColor => _logcolor.Value;

	public static bool CGSfixedColor => _fixedcolor.Value;

	public static string CGSprefid_origin => _prefid_origin.Value;

	public static float CGSlightTime => _lighttime.Value;

	public static bool CGSprefid_rolling => _prefid_rolling.Value;

	public static bool CGSenable_network => _enable_network.Value;

	public override void Load()
	{
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Expected O, but got Unknown
		//IL_016a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0178: Expected O, but got Unknown
		//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c9: Expected O, but got Unknown
		Logout.LogInstance = ((BasePlugin)this).Log;
		Harmony val = new Harmony("ColorfulGlowStick");
		_lightrange = configFile.Bind<float>("A: GlowStick Properties Setting", "LightRange", 5f, "The light range of glowsticks.( Meters )");
		_coloralpha = configFile.Bind<float>("A: GlowStick Properties Setting", "Brightness", 0.3f, "The brightness of glowsticks.( Min 0.0 - Max 1.0 )");
		_lighttime = configFile.Bind<float>("A: GlowStick Properties Setting", "LightTime", 60f, "The brightest duration of glowsticks.( Seconds )");
		_fixedcolor = configFile.Bind<bool>("A: GlowStick Properties Setting", "UseColorGenerator", true, "Use the [Color Generator Mode], generate a completely random color everytime.(Else use [Prefined Color Mode])");
		_forcelight = configFile.Bind<bool>("B: Color Generator Mode", "ForceBright", true, "Allow glow sticks appear dark color when this option disable.");
		_logcolor = configFile.Bind<bool>("A: GlowStick Properties Setting", "LogColorValue", false, "Use for debug. Out print the color value of the glow stick to log when throwing a new glowstick.");
		_prefid_origin = configFile.Bind<string>("C: Prefined Color Mode", "ColorPool", "255,63,0 0,255,63 63,0,255", "All possible colors the glowsticks can use. Each color use three 0-255 RGB value, and separate other color with space.");
		_prefid_rolling = configFile.Bind<bool>("C: Prefined Color Mode", "RandomPickColor", true, "If this option disable, the [Prefined Color Mode] will pick colors keeping the sort of color pool rather than randomly.");
		_enable_network = configFile.Bind<bool>("D: Network Sync", "EnableSync", false, "[TESTING]Enable multiplayer glowsticks color sync.");
		MethodInfo method = typeof(GlowstickInstance).GetMethod("Update");
		MethodInfo method2 = typeof(ColorfulGlowStick).GetMethod("UpdateProperties");
		val.Patch((MethodBase)method, new HarmonyMethod(method2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		MethodInfo method3 = typeof(ThrowingWeapon).GetMethod("Throw", new Type[1] { typeof(float) });
		MethodInfo method4 = typeof(ColorfulGlowStick).GetMethod("SendColorOnThrow");
		val.Patch((MethodBase)method3, new HarmonyMethod(method4), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		val.PatchAll();
		NetworkAPI.RegisterEvent<GlowStickMessage>("GlowStickMessage", (Action<ulong, GlowStickMessage>)delegate(ulong _ulong, GlowStickMessage Package)
		{
			ColorfulGlowStick.InNetworkStorage = Package;
			Logout.LogInstance.Log((LogLevel)8, (object)"Network.Package_Received");
		});
		Logout.LogInstance.Log((LogLevel)8, (object)"Load Finished.");
	}

	static EntryPoint()
	{
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Expected O, but got Unknown
		shinestick_random = new Random();
		configFile = new ConfigFile(Path.Combine(Paths.ConfigPath, "F_O_G.ColorfulGlowStick.cfg"), true);
		CGSprefidRoller = 0;
	}
}
public static class ColorfulGlowStick
{
	public static GlowStickMessage InNetworkStorage;

	public static void UpdateProperties(GlowstickInstance __instance)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0083: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		//IL_008f: Unknown result type (might be due to invalid IL or missing references)
		//IL_013f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0145: Invalid comparison between Unknown and I4
		//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_011a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0120: Unknown result type (might be due to invalid IL or missing references)
		//IL_0126: Unknown result type (might be due to invalid IL or missing references)
		//IL_012c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0148: Unknown result type (might be due to invalid IL or missing references)
		//IL_014d: 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)
		if (__instance.m_LightColorTarget.a == 1f)
		{
			if (!EntryPoint.CGSenable_network)
			{
				Logout.LogInstance.Log((LogLevel)8, (object)"Update.local");
				__instance.m_progression = 0f;
				__instance.m_state = (eFadeState)0;
				Color val = default(Color);
				__instance.s_lightRange = EntryPoint.CGSlightRange;
				__instance.s_lightLifeTime = EntryPoint.CGSlightTime;
				float[] array = new float[3];
				array = MakeColor();
				((Color)(ref val))..ctor(array[0], array[1], array[2], 1.1f);
				__instance.m_LightColorTarget = val;
				GlowstickInstance.s_lightColorYellow = val;
				GlowstickInstance.s_lightColorChristmas = val;
				GlowstickInstance.s_lightColorHalloween = val;
			}
			else if (InNetworkStorage.package_unused)
			{
				Logout.LogInstance.Log((LogLevel)8, (object)"Update.network");
				__instance.m_progression = 0f;
				__instance.m_state = (eFadeState)0;
				Color val2 = default(Color);
				__instance.s_lightRange = InNetworkStorage.range;
				__instance.s_lightLifeTime = InNetworkStorage.time;
				((Color)(ref val2))..ctor(InNetworkStorage.red, InNetworkStorage.green, InNetworkStorage.blue, 1.1f);
				__instance.m_LightColorTarget = val2;
				GlowstickInstance.s_lightColorYellow = val2;
				GlowstickInstance.s_lightColorChristmas = val2;
				GlowstickInstance.s_lightColorHalloween = val2;
				InNetworkStorage.package_unused = false;
			}
			else if ((int)__instance.m_state == 2)
			{
				Color lightColorTarget = __instance.m_LightColorTarget;
				lightColorTarget.a = 1.1f;
				__instance.m_LightColorTarget = lightColorTarget;
			}
		}
	}

	public static float[] MakeColor()
	{
		Logout.LogInstance.Log((LogLevel)8, (object)"MakeColor.doing");
		float num = EntryPoint.CGScolorAlpha;
		if (num > 1f)
		{
			num = 1f;
		}
		else if (num < 0f)
		{
			num = 0f;
		}
		float[] array = new float[3];
		if (EntryPoint.CGSfixedColor)
		{
			int num2;
			for (num2 = 0; num2 <= 120; num2++)
			{
				num2 = 0;
				for (int i = 0; i <= 2; i++)
				{
					array[i] = EntryPoint.shinestick_random.Next(1, 100);
					num2 += (int)array[i];
				}
				if (!EntryPoint.CGSforceLight)
				{
					break;
				}
			}
			for (int j = 0; j <= 2; j++)
			{
				array[j] /= 10f;
			}
			for (int k = 0; k <= 2; k++)
			{
				array[k] *= num;
			}
		}
		else
		{
			string[] array2 = EntryPoint.CGSprefid_origin.Split(' ', StringSplitOptions.RemoveEmptyEntries);
			string[] array3 = new string[3];
			if (EntryPoint.CGSprefid_rolling)
			{
				array3 = array2[EntryPoint.shinestick_random.Next(array2.Length)].Split(',');
			}
			else
			{
				array3 = array2[EntryPoint.CGSprefidRoller].Split(',');
				EntryPoint.CGSprefidRoller++;
				if (EntryPoint.CGSprefidRoller >= array2.Length)
				{
					EntryPoint.CGSprefidRoller = 0;
				}
			}
			for (int l = 0; l <= 2; l++)
			{
				array[l] = (float)Convert.ToDouble(array3[l]);
			}
			for (int m = 0; m <= 2; m++)
			{
				if (array[m] > 255f)
				{
					array[m] = 10f;
				}
				else if (array[m] < 0f)
				{
					array[m] = 0f;
				}
				else
				{
					array[m] /= 25.5f;
				}
			}
			for (int n = 0; n <= 2; n++)
			{
				array[n] *= num;
			}
		}
		return array;
	}

	public static void SendColorOnThrow(ThrowingWeapon __instance)
	{
		Logout.LogInstance.Log((LogLevel)8, (object)"SendColorOnThrow.getting");
		if (EntryPoint.CGSenable_network && ((Item)__instance).LeftHandGripAnim == "GlowStick")
		{
			GlowStickMessage glowStickMessage = default(GlowStickMessage);
			float[] array = new float[3];
			array = MakeColor();
			glowStickMessage.range = EntryPoint.CGSlightRange;
			glowStickMessage.time = EntryPoint.CGSlightTime;
			glowStickMessage.red = array[0];
			glowStickMessage.green = array[1];
			glowStickMessage.blue = array[2];
			glowStickMessage.package_unused = true;
			InNetworkStorage = glowStickMessage;
			Logout.LogInstance.Log((LogLevel)8, (object)"SendColorOnThrow.doing");
			NetworkAPI.InvokeEvent<GlowStickMessage>("GlowStickMessage", glowStickMessage, (SNet_ChannelType)3);
		}
	}
}
public static class Logout
{
	public static ManualLogSource LogInstance;

	public static void Log(float[] rgb, float alpha)
	{
		string text = "Made color( " + (int)(rgb[0] * 25.5f) + "/255 , " + (int)(rgb[1] * 25.5f) + "/255 , " + (int)(rgb[2] * 25.5f) + "/255 , " + alpha + "/1.0 ).";
		LogInstance.Log((LogLevel)8, (object)text);
	}
}
public struct GlowStickMessage
{
	public float red;

	public float green;

	public float blue;

	public float range;

	public float time;

	public bool package_unused;
}