Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of WingDye v1.1.0
BepInEx/plugins/WingDye/WingDye.dll
Decompiled a day agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using ExitGames.Client.Photon; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using Photon.Realtime; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyVersion("0.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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 WingDye { [BepInPlugin("xingKong.WingDye", "翅膀染色", "1.1.0")] [BepInProcess("REPO.exe")] public class Plugin : BaseUnityPlugin { public const string PluginGuid = "xingKong.WingDye"; public const string PluginName = "翅膀染色"; public const string PluginVersion = "1.1.0"; internal static ManualLogSource Log; internal static PluginConfig Cfg; internal static readonly BindingFlags AnyMember = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; private Harmony _harmony; private Coroutine _loop; private void Awake() { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; Cfg = new PluginConfig(((BaseUnityPlugin)this).Config); _harmony = new Harmony("xingKong.WingDye"); _harmony.PatchAll(typeof(Patches)); _loop = ((MonoBehaviour)this).StartCoroutine(CoApplyLoop()); Log.LogInfo((object)("翅膀染色 v1.1.0 已加载:本体 " + Cfg.BaseColor.Value + ",边缘 " + Cfg.FresnelColor.Value + "。")); } private void OnDestroy() { try { if (_loop != null) { ((MonoBehaviour)this).StopCoroutine(_loop); } Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } catch { } } internal static IEnumerator CoApplyLoop() { while (true) { try { if (Cfg != null && Cfg.Enabled.Value) { ApplyToLocal(); WingSync.SyncLocalProperties(); WingSync.ApplyRemote(); } } catch (Exception ex) { Exception e = ex; Log.LogDebug((object)("[翅膀] 应用失败:" + e.Message)); } float interval = ((Cfg != null) ? Mathf.Clamp(Cfg.Interval.Value, 0.1f, 3f) : 0.5f); yield return (object)new WaitForSeconds(interval); } } internal static void ApplyToLocal() { PlayerAvatar instance = PlayerAvatar.instance; if ((Object)(object)instance == (Object)null) { return; } ItemUpgradePlayerTumbleWingsLogic val = (((Object)(object)instance.upgradeTumbleWingsLogic != (Object)null) ? instance.upgradeTumbleWingsLogic : ((Component)instance).GetComponentInChildren<ItemUpgradePlayerTumbleWingsLogic>(true)); if (!((Object)(object)val == (Object)null)) { Reflection.Set(instance, "upgradeTumbleWingsVisualsActive", true); Reflection.Set(instance, "upgradeTumbleWingsVisualsPink", false); Reflection.Set(instance, "upgradeTumbleWingsVisualsTimer", 1f); if (Cfg.ForceWings.Value) { float num = (float)(Reflection.Get(instance, "upgradeTumbleWings") ?? ((object)0f)); Reflection.Set(instance, "upgradeTumbleWings", Mathf.Max(num, 1f)); } Reflection.Set(val, "tumbleWingTimer", 1.15f); try { val.WingsSetOriginalColors(); } catch (Exception ex) { Log.LogDebug((object)("[翅膀] 颜色应用失败:" + ex.Message)); } ApplyColors(val); ApplySound(val); } } internal static void ApplyColors(ItemUpgradePlayerTumbleWingsLogic logic) { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: 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_00ae: 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) if (!((Object)(object)logic == (Object)null) && Cfg != null && Cfg.Enabled.Value) { ApplyColors(logic, ParseColor(Cfg.BaseColor.Value, new Color(0.35f, 0.65f, 1f, 1f)), ParseColor(Cfg.FresnelColor.Value, new Color(0.55f, 0.85f, 1f, 1f)), ParseColor(Cfg.LightColor.Value, ParseColor(Cfg.BaseColor.Value, Color.white))); } } internal static void ApplyColors(ItemUpgradePlayerTumbleWingsLogic logic, Color baseColor, Color fresnel, Color lightColor) { //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)logic == (Object)null) { return; } string[] array = new string[2] { "wing1MeshRenderer", "wing2MeshRenderer" }; foreach (string field in array) { object obj = Reflection.Get(logic, field); MeshRenderer val = (MeshRenderer)((obj is MeshRenderer) ? obj : null); if (!((Object)(object)val == (Object)null) && !((Object)(object)((Renderer)val).material == (Object)null)) { ((Renderer)val).material.SetColor("_BaseColor", baseColor); ((Renderer)val).material.SetColor("_FresnelColor", fresnel); } } object obj2 = Reflection.Get(logic, "lightWings"); Light val2 = (Light)((obj2 is Light) ? obj2 : null); if ((Object)(object)val2 != (Object)null) { val2.color = lightColor; } } internal static void ApplySound(ItemUpgradePlayerTumbleWingsLogic logic) { if ((Object)(object)logic == (Object)null || Cfg == null) { return; } bool value = Cfg.MuteSound.Value; object obj = Reflection.Get(logic, "localAudioSource"); AudioSource val = (AudioSource)((obj is AudioSource) ? obj : null); if ((Object)(object)val != (Object)null) { val.mute = value; if (value && val.isPlaying) { val.Stop(); } } Sound soundWingsLoop = logic.soundWingsLoop; if (soundWingsLoop != null && (Object)(object)soundWingsLoop.Source != (Object)null) { soundWingsLoop.Source.mute = value; if (value && soundWingsLoop.Source.isPlaying) { soundWingsLoop.Source.Stop(); } } } internal static Color ParseColor(string hex, Color fallback) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0047: 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_0048: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrWhiteSpace(hex)) { return fallback; } string text = hex.Trim(); if (!text.StartsWith("#", StringComparison.Ordinal)) { text = "#" + text; } Color val = default(Color); return ColorUtility.TryParseHtmlString(text, ref val) ? val : fallback; } } internal static class Reflection { internal static object Get(object target, string field) { if (target == null) { return null; } Type type = target.GetType(); FieldInfo field2 = type.GetField(field, Plugin.AnyMember); if (field2 != null) { return field2.GetValue(target); } PropertyInfo property = type.GetProperty(field, Plugin.AnyMember); return (property != null && property.CanRead) ? property.GetValue(target, null) : null; } internal static void Set(object target, string field, object value) { if (target == null) { return; } Type type = target.GetType(); FieldInfo field2 = type.GetField(field, Plugin.AnyMember); if (field2 != null) { field2.SetValue(target, value); return; } PropertyInfo property = type.GetProperty(field, Plugin.AnyMember); if (property != null && property.CanWrite) { property.SetValue(target, value, null); } } } [HarmonyPatch(typeof(ItemUpgradePlayerTumbleWingsLogic), "Start")] internal static class WingsStartPatch { [HarmonyPostfix] private static void Postfix(ItemUpgradePlayerTumbleWingsLogic __instance) { try { Plugin.ApplyColors(__instance); } catch { } } } [HarmonyPatch(typeof(ItemUpgradePlayerTumbleWingsLogic), "WingsSetPinkColors")] internal static class PinkColorsPatch { [HarmonyPostfix] private static void Postfix(ItemUpgradePlayerTumbleWingsLogic __instance) { Plugin.ApplyColors(__instance); } } [HarmonyPatch(typeof(ItemUpgradePlayerTumbleWingsLogic), "WingsSetOriginalColors")] internal static class OriginalColorsPatch { [HarmonyPostfix] private static void Postfix(ItemUpgradePlayerTumbleWingsLogic __instance) { Plugin.ApplyColors(__instance); } } [HarmonyPatch(typeof(PlayerAvatar), "UpgradeTumbleWingsVisualsActiveRPC")] internal static class WingsRpcPatch { [HarmonyPostfix] private static void Postfix(PlayerAvatar __instance) { if ((Object)(object)__instance != (Object)null && (Object)(object)__instance == (Object)(object)PlayerAvatar.instance) { Plugin.ApplyToLocal(); } } } internal static class WingSync { private const string KeyBase = "WingDye_Base"; private const string KeyFresnel = "WingDye_Fresnel"; private const string KeyLight = "WingDye_Light"; private static string _lastBase; private static string _lastFresnel; private static string _lastLight; internal static void SyncLocalProperties() { //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Expected O, but got Unknown //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Expected O, but got Unknown //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Expected O, but got Unknown //IL_00f0: Expected O, but got Unknown if (!Plugin.Cfg.SyncToOthers.Value || !SemiFunc.IsMultiplayer() || !PhotonNetwork.InRoom) { return; } Player localPlayer = PhotonNetwork.LocalPlayer; if (localPlayer == null) { return; } string text = Plugin.Cfg.BaseColor.Value ?? string.Empty; string text2 = Plugin.Cfg.FresnelColor.Value ?? string.Empty; string text3 = Plugin.Cfg.LightColor.Value ?? string.Empty; if (text == _lastBase && text2 == _lastFresnel && text3 == _lastLight) { return; } Hashtable val = new Hashtable(); ((Dictionary<object, object>)val).Add((object)"WingDye_Base", (object)text); ((Dictionary<object, object>)val).Add((object)"WingDye_Fresnel", (object)text2); ((Dictionary<object, object>)val).Add((object)"WingDye_Light", (object)text3); Hashtable val2 = val; try { localPlayer.SetCustomProperties(val2, (Hashtable)null, (WebFlags)null); _lastBase = text; _lastFresnel = text2; _lastLight = text3; } catch (Exception ex) { Plugin.Log.LogDebug((object)("[翅膀] 同步颜色失败:" + ex.Message)); } } internal static void ApplyRemote() { //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0184: 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_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: 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_01b7: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.Cfg.SyncToOthers.Value || !SemiFunc.IsMultiplayer() || !PhotonNetwork.InRoom) { return; } GameDirector instance = GameDirector.instance; if ((Object)(object)instance == (Object)null || instance.PlayerList == null) { return; } foreach (PlayerAvatar player in instance.PlayerList) { if ((Object)(object)player == (Object)null || (Object)(object)player == (Object)(object)PlayerAvatar.instance) { continue; } ItemUpgradePlayerTumbleWingsLogic upgradeTumbleWingsLogic = player.upgradeTumbleWingsLogic; if (!((Object)(object)upgradeTumbleWingsLogic == (Object)null)) { object obj = Reflection.Get(player, "photonView"); PhotonView val = (PhotonView)((obj is PhotonView) ? obj : null); Player val2 = (((Object)(object)val != (Object)null) ? val.Owner : null); Hashtable val3 = ((val2 != null) ? val2.CustomProperties : null); if (val3 != null && ((Dictionary<object, object>)(object)val3).ContainsKey((object)"WingDye_Base")) { string hex = val3[(object)"WingDye_Base"] as string; string hex2 = (((Dictionary<object, object>)(object)val3).ContainsKey((object)"WingDye_Fresnel") ? (val3[(object)"WingDye_Fresnel"] as string) : null); string hex3 = (((Dictionary<object, object>)(object)val3).ContainsKey((object)"WingDye_Light") ? (val3[(object)"WingDye_Light"] as string) : null); Plugin.ApplyColors(upgradeTumbleWingsLogic, Plugin.ParseColor(hex, new Color(0.35f, 0.65f, 1f, 1f)), Plugin.ParseColor(hex2, new Color(0.55f, 0.85f, 1f, 1f)), Plugin.ParseColor(hex3, Plugin.ParseColor(hex, Color.white))); } } } } } internal sealed class PluginConfig { public readonly ConfigEntry<bool> Enabled; public readonly ConfigEntry<string> BaseColor; public readonly ConfigEntry<string> FresnelColor; public readonly ConfigEntry<string> LightColor; public readonly ConfigEntry<bool> MuteSound; public readonly ConfigEntry<bool> ForceWings; public readonly ConfigEntry<bool> SyncToOthers; public readonly ConfigEntry<float> Interval; public PluginConfig(ConfigFile cfg) { //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Expected O, but got Unknown Enabled = cfg.Bind<bool>("1. 通用", "启用", true, "总开关。"); BaseColor = cfg.Bind<string>("2. 颜色", "翅膀本体颜色", "#59A6FFFF", "翅膀主色(#RRGGBBAA)。例如浅蓝 #59A6FFFF、紫 #B45CFFFF、金 #FFD24AFF。"); FresnelColor = cfg.Bind<string>("2. 颜色", "翅膀边缘光颜色", "#8FD9FFFF", "翅膀边缘发光色(#RRGGBBAA),通常比本体更亮。"); LightColor = cfg.Bind<string>("2. 颜色", "翅膀灯光颜色", "#8FD9FFFF", "翅膀自带灯光的颜色(#RRGGBBAA),留空则跟随本体颜色。"); MuteSound = cfg.Bind<bool>("3. 其它", "静音翅膀循环音", true, "关闭翅膀的循环音效。"); ForceWings = cfg.Bind<bool>("1. 通用", "强制拥有翅膀", true, "即使没有买翅膀升级,也强制把翅膀等级设为 1 以显示/飞行。"); SyncToOthers = cfg.Bind<bool>("4. 联机", "同步颜色给队友", true, "通过 Photon 玩家属性同步颜色,装了本模组的队友会看到你的配色。"); Interval = cfg.Bind<float>("3. 其它", "重新应用间隔(秒)", 0.5f, new ConfigDescription("定期重新应用颜色,防止被游戏刷新覆盖。", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 3f), Array.Empty<object>())); } } }