using System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("PeakRescueClawMod")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+99151048b447326af5d8c0824b46daf47a9bdf41")] [assembly: AssemblyProduct("PeakRescueClawMod")] [assembly: AssemblyTitle("PeakRescueClawMod")] [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 PeakRescueClawMod { [BepInPlugin("nixi.peakrescueclawmod", "Rescue Claw Crosshair Mod", "1.0.0")] public class RescueClawMod : BaseUnityPlugin { internal static ConfigEntry ColorMode; internal static ConfigEntry StaticColor; internal static ConfigEntry CustomR; internal static ConfigEntry CustomG; internal static ConfigEntry CustomB; private void Awake() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown InitializeConfig(); Harmony val = new Harmony("nixi.peakrescueclawmod"); val.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"RescueClawMod v1.0.0 загружен!"); } private void InitializeConfig() { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Expected O, but got Unknown //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Expected O, but got Unknown //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Expected O, but got Unknown //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Expected O, but got Unknown ColorMode = ((BaseUnityPlugin)this).Config.Bind("General", "ColorMode", "Static", new ConfigDescription("Способ выбора цвета прицела при наведении на игрока", (AcceptableValueBase)(object)new AcceptableValueList(new string[2] { "Static", "Custom" }), Array.Empty())); StaticColor = ((BaseUnityPlugin)this).Config.Bind("General", "StaticColor", "Red", new ConfigDescription("Статичный цвет (используется если ColorMode = Static)", (AcceptableValueBase)(object)new AcceptableValueList(new string[8] { "Red", "Green", "Blue", "Yellow", "Cyan", "Magenta", "Orange", "Purple" }), Array.Empty())); CustomR = ((BaseUnityPlugin)this).Config.Bind("Custom Color", "R", 255, new ConfigDescription("Красный компонент (0–255)", (AcceptableValueBase)(object)new AcceptableValueRange(0, 255), Array.Empty())); CustomG = ((BaseUnityPlugin)this).Config.Bind("Custom Color", "G", 0, new ConfigDescription("Зелёный компонент (0–255)", (AcceptableValueBase)(object)new AcceptableValueRange(0, 255), Array.Empty())); CustomB = ((BaseUnityPlugin)this).Config.Bind("Custom Color", "B", 0, new ConfigDescription("Синий компонент (0–255)", (AcceptableValueBase)(object)new AcceptableValueRange(0, 255), Array.Empty())); bool flag = false; if (CustomR.Value < 0 || CustomR.Value > 255) { CustomR.Value = Mathf.Clamp(CustomR.Value, 0, 255); flag = true; ((BaseUnityPlugin)this).Logger.LogWarning((object)("Значение R было скорректировано до " + CustomR.Value)); } if (CustomG.Value < 0 || CustomG.Value > 255) { CustomG.Value = Mathf.Clamp(CustomG.Value, 0, 255); flag = true; ((BaseUnityPlugin)this).Logger.LogWarning((object)("Значение G было скорректировано до " + CustomG.Value)); } if (CustomB.Value < 0 || CustomB.Value > 255) { CustomB.Value = Mathf.Clamp(CustomB.Value, 0, 255); flag = true; ((BaseUnityPlugin)this).Logger.LogWarning((object)("Значение B было скорректировано до " + CustomB.Value)); } if (flag) { ((BaseUnityPlugin)this).Config.Save(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Конфигурация сохранена с корректными значениями RGB."); } string value = ColorMode.Value; string value2 = StaticColor.Value; int value3 = CustomR.Value; int value4 = CustomG.Value; int value5 = CustomB.Value; ((BaseUnityPlugin)this).Config.Save(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Конфигурация инициализирована."); } } [HarmonyPatch] public static class CrosshairColorPatch { private static readonly Color defaultCrosshairColor; private static Image currentCrosshairImage; private static bool wasAimingAtPlayer; private static bool searched; private static GameObject reticleShootObject; static CrosshairColorPatch() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) defaultCrosshairColor = new Color(0.8742f, 0.8567f, 0.7615f, 1f); wasAimingAtPlayer = false; searched = false; SceneManager.sceneLoaded += OnSceneLoaded; } private static void OnSceneLoaded(Scene scene, LoadSceneMode mode) { ResetCrosshairSearch(); } private static void ResetCrosshairSearch() { currentCrosshairImage = null; searched = false; reticleShootObject = null; wasAimingAtPlayer = false; Debug.Log((object)"[RescueClawMod] Состояние сброшено (новая сцена)"); } private static Color GetSelectedColor() { //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: 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_0167: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_0156: 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_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0173: 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_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) if (RescueClawMod.ColorMode.Value == "Static") { return (Color)(RescueClawMod.StaticColor.Value switch { "Red" => Color.red, "Green" => Color.green, "Blue" => Color.blue, "Yellow" => Color.yellow, "Cyan" => Color.cyan, "Magenta" => Color.magenta, "Orange" => new Color(1f, 0.5f, 0f), "Purple" => new Color(0.5f, 0f, 0.5f), _ => Color.red, }); } return new Color((float)RescueClawMod.CustomR.Value / 255f, (float)RescueClawMod.CustomG.Value / 255f, (float)RescueClawMod.CustomB.Value / 255f, 1f); } private static void FindCrosshairImage() { if (searched) { return; } searched = true; GUIManager instance = GUIManager.instance; if ((Object)(object)instance == (Object)null) { return; } FieldInfo field = typeof(GUIManager).GetField("reticleShoot", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null) { object? value = field.GetValue(instance); reticleShootObject = (GameObject)((value is GameObject) ? value : null); if ((Object)(object)reticleShootObject != (Object)null) { currentCrosshairImage = reticleShootObject.GetComponentInChildren(); if ((Object)(object)currentCrosshairImage != (Object)null) { Debug.Log((object)"[RescueClawMod] Найден прицел для стрельбы."); return; } } } if ((Object)(object)instance.reticleDefaultImage != (Object)null) { currentCrosshairImage = instance.reticleDefaultImage; Debug.Log((object)"[RescueClawMod] Использую reticleDefaultImage."); } else { Debug.LogWarning((object)"[RescueClawMod] Прицел не найден!"); } } private static bool IsHoldingRescueHook() { Character localCharacter = Character.localCharacter; if ((Object)(object)localCharacter == (Object)null) { return false; } Item currentItem = localCharacter.data.currentItem; if ((Object)(object)currentItem == (Object)null) { return false; } return (Object)(object)((Component)currentItem).GetComponent() != (Object)null; } private static void ResetCrosshair() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)currentCrosshairImage != (Object)null) { ((Graphic)currentCrosshairImage).color = defaultCrosshairColor; } wasAimingAtPlayer = false; Debug.Log((object)"[RescueClawMod] Сброс цвета (локальный игрок убрал крюк)"); } [HarmonyPatch(typeof(RescueHook), "GetHit")] [HarmonyPostfix] public static void AfterGetHit(RescueHook __instance, ref RaycastHit __result) { //IL_00a2: 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) if (!IsHoldingRescueHook()) { return; } if ((Object)(object)currentCrosshairImage == (Object)null) { FindCrosshairImage(); } if (!((Object)(object)currentCrosshairImage == (Object)null)) { bool flag = false; Character val = default(Character); if ((Object)(object)((RaycastHit)(ref __result)).collider != (Object)null && CharacterRagdoll.TryGetCharacterFromCollider(((RaycastHit)(ref __result)).collider, ref val) && (Object)(object)val != (Object)(object)__instance.playerHoldingItem) { flag = true; } if (flag != wasAimingAtPlayer) { wasAimingAtPlayer = flag; ((Graphic)currentCrosshairImage).color = (flag ? GetSelectedColor() : defaultCrosshairColor); Debug.Log((object)(flag ? "[RescueClawMod] Цвет изменён (игрок)" : "[RescueClawMod] Цвет сброшен")); } } } [HarmonyPatch(typeof(GUIManager), "OnSlotEquipped")] [HarmonyPostfix] public static void OnSlotEquippedPostfix(GUIManager __instance) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) if (!IsHoldingRescueHook()) { ResetCrosshair(); } else if (wasAimingAtPlayer) { wasAimingAtPlayer = false; if ((Object)(object)currentCrosshairImage != (Object)null) { ((Graphic)currentCrosshairImage).color = defaultCrosshairColor; } Debug.Log((object)"[RescueClawMod] Сброс флага при экипировке RescueHook"); } } [HarmonyPatch(typeof(GUIManager), "SetReticle")] [HarmonyPostfix] public static void AfterSetReticle(GUIManager __instance, GameObject activeReticle) { //IL_0063: Unknown result type (might be due to invalid IL or missing references) if (IsHoldingRescueHook() && !((Object)(object)currentCrosshairImage == (Object)null) && wasAimingAtPlayer && ((Object)(object)activeReticle == (Object)(object)reticleShootObject || ((Object)(object)activeReticle != (Object)null && (Object)(object)activeReticle.GetComponentInChildren() == (Object)(object)currentCrosshairImage))) { ((Graphic)currentCrosshairImage).color = GetSelectedColor(); Debug.Log((object)"[RescueClawMod] Восстановлен цвет после SetReticle"); } } [HarmonyPatch(typeof(GUIManager), "UpdateReticle")] [HarmonyPostfix] public static void AfterUpdateReticle(GUIManager __instance) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) if (IsHoldingRescueHook() && !((Object)(object)currentCrosshairImage == (Object)null) && wasAimingAtPlayer) { ((Graphic)currentCrosshairImage).color = GetSelectedColor(); Debug.Log((object)"[RescueClawMod] Восстановлен цвет после UpdateReticle"); } } } }