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("nixi.PeakRescueClawMod")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+7f6a0ba7034fc4862f0a22bf18da2de9a2b6ef81")]
[assembly: AssemblyProduct("nixi.PeakRescueClawMod")]
[assembly: AssemblyTitle("nixi.PeakRescueClawMod")]
[assembly: AssemblyVersion("1.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 PeakRescueClawMod
{
[BepInPlugin("nixi.peakrescueclawmod", "Rescue Claw Crosshair Mod", "1.0.2")]
public class RescueClawMod : BaseUnityPlugin
{
internal static ConfigEntry<string> ColorMode;
internal static ConfigEntry<string> StaticColor;
internal static ConfigEntry<int> CustomR;
internal static ConfigEntry<int> CustomG;
internal static ConfigEntry<int> 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();
Debug.Log((object)"[RescueClawMod] Загружен v1.0.2");
}
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<string>("General", "ColorMode", "Static", new ConfigDescription("Способ выбора цвета прицела при наведении на игрока", (AcceptableValueBase)(object)new AcceptableValueList<string>(new string[2] { "Static", "Custom" }), Array.Empty<object>()));
StaticColor = ((BaseUnityPlugin)this).Config.Bind<string>("General", "StaticColor", "Red", new ConfigDescription("Статичный цвет (используется если ColorMode = Static)", (AcceptableValueBase)(object)new AcceptableValueList<string>(new string[8] { "Red", "Green", "Blue", "Yellow", "Cyan", "Magenta", "Orange", "Purple" }), Array.Empty<object>()));
CustomR = ((BaseUnityPlugin)this).Config.Bind<int>("Custom Color", "R", 255, new ConfigDescription("Красный компонент (0–255)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 255), Array.Empty<object>()));
CustomG = ((BaseUnityPlugin)this).Config.Bind<int>("Custom Color", "G", 0, new ConfigDescription("Зелёный компонент (0–255)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 255), Array.Empty<object>()));
CustomB = ((BaseUnityPlugin)this).Config.Bind<int>("Custom Color", "B", 0, new ConfigDescription("Синий компонент (0–255)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 255), Array.Empty<object>()));
bool flag = false;
if (CustomR.Value < 0 || CustomR.Value > 255)
{
CustomR.Value = Mathf.Clamp(CustomR.Value, 0, 255);
flag = true;
}
if (CustomG.Value < 0 || CustomG.Value > 255)
{
CustomG.Value = Mathf.Clamp(CustomG.Value, 0, 255);
flag = true;
}
if (CustomB.Value < 0 || CustomB.Value > 255)
{
CustomB.Value = Mathf.Clamp(CustomB.Value, 0, 255);
flag = true;
}
if (flag)
{
((BaseUnityPlugin)this).Config.Save();
}
string value = ColorMode.Value;
string value2 = StaticColor.Value;
int value3 = CustomR.Value;
int value4 = CustomG.Value;
int value5 = CustomB.Value;
((BaseUnityPlugin)this).Config.Save();
}
}
[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;
private static bool subscribedToItemSwitch;
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;
subscribedToItemSwitch = 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;
}
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<Image>();
if ((Object)(object)currentCrosshairImage != (Object)null)
{
return;
}
}
}
if ((Object)(object)instance.reticleDefaultImage != (Object)null)
{
currentCrosshairImage = instance.reticleDefaultImage;
}
}
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<RescueHook>() != (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;
}
private static void OnLocalSlotEquipped()
{
//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;
}
}
}
private static Camera GetMainCamera()
{
Type type = Type.GetType("MainCamera, Assembly-CSharp");
if (type != null)
{
PropertyInfo property = type.GetProperty("instance", BindingFlags.Static | BindingFlags.Public);
if (property != null)
{
object value = property.GetValue(null);
if (value != null)
{
FieldInfo field = type.GetField("cam", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
if (field != null)
{
object? value2 = field.GetValue(value);
return (Camera)((value2 is Camera) ? value2 : null);
}
}
}
}
return Camera.main;
}
[HarmonyPatch(typeof(GUIManager), "LateUpdate")]
[HarmonyPostfix]
public static void OnLocalCharacterReady(GUIManager __instance)
{
if (!((Object)(object)__instance != (Object)(object)GUIManager.instance) && !subscribedToItemSwitch && (Object)(object)Character.localCharacter != (Object)null && (Object)(object)Character.localCharacter.refs.items != (Object)null)
{
CharacterItems items = Character.localCharacter.refs.items;
items.onSlotEquipped = (Action)Delegate.Combine(items.onSlotEquipped, new Action(OnLocalSlotEquipped));
subscribedToItemSwitch = true;
}
}
[HarmonyPatch(typeof(RescueHook), "GetHit")]
[HarmonyPostfix]
public static void AfterGetHit(RescueHook __instance, ref RaycastHit __result)
{
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00c5: 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_0139: Unknown result type (might be due to invalid IL or missing references)
//IL_0132: 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)
{
return;
}
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)
{
Camera mainCamera = GetMainCamera();
if ((Object)(object)mainCamera != (Object)null)
{
Ray val2 = mainCamera.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0f));
float range = __instance.range;
int num = LayerMask.op_Implicit(HelperFunctions.GetMask((LayerType)7));
RaycastHit val3 = default(RaycastHit);
Character val4 = default(Character);
if (Physics.Raycast(val2, ref val3, range, num) && CharacterRagdoll.TryGetCharacterFromCollider(((RaycastHit)(ref val3)).collider, ref val4) && (Object)(object)val4 != (Object)(object)__instance.playerHoldingItem)
{
flag = true;
}
}
}
if (flag != wasAimingAtPlayer)
{
wasAimingAtPlayer = flag;
((Graphic)currentCrosshairImage).color = (flag ? GetSelectedColor() : defaultCrosshairColor);
}
}
[HarmonyPatch(typeof(GUIManager), "SetReticle")]
[HarmonyPostfix]
public static void AfterSetReticle(GUIManager __instance, GameObject activeReticle)
{
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
if (!IsHoldingRescueHook())
{
if ((Object)(object)currentCrosshairImage != (Object)null && wasAimingAtPlayer)
{
((Graphic)currentCrosshairImage).color = defaultCrosshairColor;
wasAimingAtPlayer = false;
}
}
else if (!((Object)(object)currentCrosshairImage == (Object)null) && wasAimingAtPlayer && ((Object)(object)activeReticle == (Object)(object)reticleShootObject || ((Object)(object)activeReticle != (Object)null && (Object)(object)activeReticle.GetComponentInChildren<Image>() == (Object)(object)currentCrosshairImage)))
{
((Graphic)currentCrosshairImage).color = GetSelectedColor();
}
}
[HarmonyPatch(typeof(GUIManager), "UpdateReticle")]
[HarmonyPostfix]
public static void AfterUpdateReticle(GUIManager __instance)
{
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
if (!IsHoldingRescueHook())
{
if ((Object)(object)currentCrosshairImage != (Object)null && wasAimingAtPlayer)
{
((Graphic)currentCrosshairImage).color = defaultCrosshairColor;
wasAimingAtPlayer = false;
}
}
else if (!((Object)(object)currentCrosshairImage == (Object)null) && wasAimingAtPlayer)
{
((Graphic)currentCrosshairImage).color = GetSelectedColor();
}
}
}
}