using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("AimUrWay")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0")]
[assembly: AssemblyProduct("How to Fish - Aim Ur Way")]
[assembly: AssemblyTitle("AimUrWay")]
[assembly: AssemblyVersion("0.1.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 AimUrWay
{
internal static class AimAssist
{
private static readonly List<Target> Candidates = new List<Target>(128);
private static object _target;
private static float _nextScanTime;
private static float _lastAssistTime;
private static float _assistWork;
private static float _playerWork;
public static bool HasTarget
{
get
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
if (_target != null)
{
return (Object)_target != (Object)null;
}
return false;
}
}
public static bool GateOpen
{
get
{
if (Plug.Cfg != null && Plug.Cfg.Enabled.Value)
{
return Bind.Ready;
}
return false;
}
}
public static float AssistShare
{
get
{
float num = _assistWork + _playerWork;
if (num <= 0.0001f)
{
return 0f;
}
return Mathf.Clamp01(_assistWork / num);
}
}
public static float LookDeltaDegrees { get; private set; }
public static bool RecentlyActive => Time.unscaledTime - _lastAssistTime < 2f;
public static void Reset()
{
_target = null;
_nextScanTime = 0f;
_assistWork = 0f;
_playerWork = 0f;
}
public static void GetRotationDeltaPostfix(object __instance, Vector3 cameraPosition, Vector3 cameraEuler, float manualLookAmount, ref Vector2 __result)
{
//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
//IL_0116: Unknown result type (might be due to invalid IL or missing references)
//IL_0117: Unknown result type (might be due to invalid IL or missing references)
//IL_015c: Unknown result type (might be due to invalid IL or missing references)
//IL_015d: Unknown result type (might be due to invalid IL or missing references)
//IL_0191: 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_0194: Unknown result type (might be due to invalid IL or missing references)
//IL_0199: Unknown result type (might be due to invalid IL or missing references)
//IL_019e: Unknown result type (might be due to invalid IL or missing references)
//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
//IL_0250: Unknown result type (might be due to invalid IL or missing references)
//IL_0268: Unknown result type (might be due to invalid IL or missing references)
//IL_0285: Unknown result type (might be due to invalid IL or missing references)
//IL_028a: Unknown result type (might be due to invalid IL or missing references)
//IL_028e: Unknown result type (might be due to invalid IL or missing references)
//IL_0290: Unknown result type (might be due to invalid IL or missing references)
try
{
Decay();
Cfg cfg = Plug.Cfg;
if (!cfg.Enabled.Value || !Bind.Ready)
{
return;
}
if (((Vector2)(ref __result)).sqrMagnitude > 1E-06f)
{
Credit(((Vector2)(ref __result)).magnitude, 0f);
return;
}
object localPlayer = Bind.LocalPlayer;
if (localPlayer == null || !IsLocalInstance(__instance, localPlayer) || (Bind.IsUsingController() && !cfg.AlsoAssistController.Value))
{
return;
}
if (!Bind.CanAssistNow(localPlayer))
{
_target = null;
return;
}
if (!Bind.TryGetHeldWeapon(localPlayer, out var _, out var isAds))
{
_target = null;
return;
}
if (!isAds && !cfg.AssistFromHip.Value)
{
_target = null;
return;
}
LookDeltaDegrees = Bind.GetLookDeltaDegrees(localPlayer);
Vector3 forward = Quaternion.Euler(cameraEuler) * Vector3.forward;
float acquireCos = Mathf.Cos(cfg.AcquireAngle.Value * (MathF.PI / 180f));
float breakCos = Mathf.Cos(cfg.BreakAngle.Value * (MathF.PI / 180f));
if (HasTarget && !StillValid(_target, cameraPosition, forward, breakCos, cfg))
{
_target = null;
}
if (!HasTarget && Time.unscaledTime >= _nextScanTime)
{
_nextScanTime = Time.unscaledTime + Mathf.Max(0.02f, cfg.ScanInterval.Value);
_target = FindBest(cameraPosition, forward, acquireCos, cfg);
}
if (!HasTarget)
{
return;
}
if (!TryTargetPosition(_target, out var position))
{
_target = null;
return;
}
Quaternion val = Quaternion.LookRotation(position - cameraPosition, Vector3.up);
Vector3 eulerAngles = ((Quaternion)(ref val)).eulerAngles;
Vector2 val2 = default(Vector2);
((Vector2)(ref val2))..ctor(Mathf.DeltaAngle(cameraEuler.x, eulerAngles.x), Mathf.DeltaAngle(cameraEuler.y, eulerAngles.y));
float deltaTime = Time.deltaTime;
if (!(deltaTime <= 0f))
{
float num = Mathf.Max(manualLookAmount, MouseLookAmount(deltaTime, cfg));
float num2 = 1f - Mathf.Clamp01(num);
if (num2 <= 0f)
{
Credit(0f, LookDeltaDegrees);
return;
}
float num3 = 1f - Mathf.Exp((0f - Mathf.Max(0.01f, cfg.Sharpness.Value)) * deltaTime);
Vector2 val3 = (__result = Vector2.ClampMagnitude(val2 * (num3 * num2 * Mathf.Clamp01(cfg.Strength.Value)), Mathf.Max(0f, cfg.MaxRotationSpeed.Value) * deltaTime));
_lastAssistTime = Time.unscaledTime;
Credit(((Vector2)(ref val3)).magnitude, LookDeltaDegrees);
}
}
catch
{
__result = Vector2.zero;
}
}
private static bool IsLocalInstance(object aimAssist, object localPlayer)
{
Component val = (Component)((aimAssist is Component) ? aimAssist : null);
if ((Object)(object)val == (Object)null)
{
return false;
}
if (Bind.TPlayer == null)
{
return true;
}
Component component = val.GetComponent(Bind.TPlayer);
if ((Object)(object)component != (Object)null)
{
return component == localPlayer;
}
return false;
}
private static object FindBest(Vector3 from, Vector3 forward, float acquireCos, Cfg cfg)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
Bind.CollectTargets(from, cfg.MaxDistance.Value, Candidates);
if (Candidates.Count == 0)
{
return null;
}
object result = null;
float num = float.MaxValue;
float num2 = Mathf.Max(1f, cfg.MaxDistance.Value);
for (int i = 0; i < Candidates.Count; i++)
{
Target target = Candidates[i];
Vector3 val = target.Position - from;
float num3 = Vector3.Dot(forward, val) / target.Distance;
if (!(num3 < acquireCos) && Bind.HasLineOfSight(from, target.Position))
{
float num4 = (1f - num3) / Mathf.Max(0.0001f, 1f - acquireCos) + target.Distance / num2 * 0.1f;
if (num4 < num)
{
num = num4;
result = target.Handle;
}
}
}
return result;
}
private static bool StillValid(object target, Vector3 from, Vector3 forward, float breakCos, Cfg cfg)
{
//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_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: 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)
if (!TryTargetPosition(target, out var position))
{
return false;
}
Vector3 val = position - from;
float magnitude = ((Vector3)(ref val)).magnitude;
if (magnitude <= Mathf.Epsilon || magnitude > cfg.MaxDistance.Value)
{
return false;
}
if (Vector3.Dot(forward, val) / magnitude < breakCos)
{
return false;
}
return Bind.HasLineOfSight(from, position);
}
private static bool TryTargetPosition(object target, out Vector3 position)
{
return Bind.TryGetTargetPosition(target, out position);
}
private static float MouseLookAmount(float dt, Cfg cfg)
{
float num = LookDeltaDegrees / dt;
float num2 = Mathf.Max(1f, cfg.ManualOverrideDegPerSec.Value);
return Mathf.Clamp01(num / num2);
}
private static void Credit(float assistDegrees, float manualDegrees)
{
_assistWork += assistDegrees;
_playerWork += manualDegrees;
}
private static void Decay()
{
float num = Mathf.Max(0.1f, Plug.Cfg.PenaltyWindowSeconds.Value);
float num2 = Mathf.Exp((0f - Time.unscaledDeltaTime) / num);
_assistWork *= num2;
_playerWork *= num2;
}
}
internal struct Target
{
public Vector3 Position;
public object Handle;
public float Distance;
public bool IsPlayer;
}
internal static class Bind
{
public static Type TPlayer;
public static Type TPlayerCamera;
public static Type TPlayerAimAssist;
public static Type TItem;
public static Type TCreature;
public static Type TAttachments;
public static Type TWeapon;
private static Member _localPlayer;
private static Member _blockInputs;
private static Member _holding;
private static Member _heldItem;
private static Member _itemWeapon;
private static Member _weaponIsAds;
private static Member _playerCamera;
private static Member _camTransform;
private static Member _mouseLocked;
private static Member _sensitivity;
private static Member _sensMulti;
private static Member _camLookInput;
private static MethodInfo _setSensitivity;
private static Member _itemManagerItems;
private static Member _itemCreature;
private static Member _creatureIsDead;
private static Member _creatureRig;
private static Member _creatureTransform;
private static Member _levelLayer;
private static Member _boatLayer;
private static Member _gameInfoInput;
private static Member _attachmentsWeapon;
private static Member _itemHolder;
private static Member _origFov;
private static Member _weaponAdsFov;
private static Member _fovSlider;
private static MethodInfo _setFov;
private static int _cachedLosMask = -1;
public static bool Ready { get; private set; }
public static string Status { get; private set; } = "not initialised";
public static object LocalPlayer
{
get
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Expected O, but got Unknown
if (!Ready)
{
return null;
}
object obj = _localPlayer.Get(null);
if (!((Object)obj == (Object)null))
{
return obj;
}
return null;
}
}
public static bool Initialise()
{
List<string> list = new List<string>();
TPlayer = Reflect.FindType("Player");
TPlayerCamera = Reflect.FindType("PlayerCamera");
TPlayerAimAssist = Reflect.FindType("PlayerAimAssist");
TItem = Reflect.FindType("Item");
TCreature = Reflect.FindType("Creature");
TAttachments = Reflect.FindType("Attachments");
TWeapon = Reflect.FindType("Weapon");
Type owner = Reflect.FindType("ItemManager");
Type owner2 = Reflect.FindType("GameInfo");
Type type = Reflect.FindType("PlayerHolding");
if (TPlayer == null)
{
list.Add("type Player");
}
if (TPlayerAimAssist == null)
{
list.Add("type PlayerAimAssist");
}
_localPlayer = Reflect.Bind(TPlayer, true, TPlayer, "localplayer", "LocalPlayer");
_blockInputs = Reflect.Bind(TPlayer, false, typeof(bool), null, "BlockInputs");
_holding = Reflect.Bind(TPlayer, false, type, "holding", "Holding");
_heldItem = Reflect.Bind(type, false, TItem, "helditem", "HeldItem");
_itemWeapon = Reflect.Bind(TItem, false, TWeapon, "weapon", "Weapon");
_weaponIsAds = Reflect.Bind(TWeapon, false, typeof(bool), null, "IsAds");
_itemHolder = Reflect.Bind(TItem, false, TPlayer, "holder", "Holder");
_playerCamera = Reflect.Bind(TPlayer, false, TPlayerCamera, null, "Camera");
_camTransform = Reflect.Bind(TPlayerCamera, false, typeof(Transform), null, "CamTransform");
_mouseLocked = Reflect.Bind(TPlayerCamera, false, typeof(bool), null, "MouseLocked");
_sensitivity = Reflect.Bind(TPlayerCamera, false, typeof(float), null, "Sensitivity");
_sensMulti = Reflect.Bind(TPlayerCamera, false, typeof(float), null, "SensMulti");
_camLookInput = Reflect.Bind(TPlayerCamera, false, typeof(Vector2), null, "LookInput");
_setSensitivity = Reflect.BindMethod(TPlayerCamera, "SetSensitivity", typeof(float));
_itemManagerItems = Reflect.Bind(owner, true, null, null, "Items");
_itemCreature = Reflect.Bind(TItem, false, TCreature, "creature", "Creature");
_creatureIsDead = Reflect.Bind(TCreature, false, typeof(bool), null, "IsDead");
_creatureRig = Reflect.Bind(TCreature, false, typeof(Rigidbody), null, "Rig");
_creatureTransform = Reflect.Bind(TCreature, false, typeof(Transform), null, "Transform");
_levelLayer = Reflect.Bind(owner2, true, typeof(LayerMask), null, "LevelLayer");
_boatLayer = Reflect.Bind(owner2, true, typeof(LayerMask), null, "BoatLayer");
_gameInfoInput = Reflect.Bind(owner2, true, null, null, "Input");
_attachmentsWeapon = Reflect.Bind(TAttachments, false, TWeapon, "weapon", "Weapon");
_origFov = Reflect.Bind(TPlayerCamera, true, typeof(float), "origfov", "_origFov");
_setFov = Reflect.BindMethod(TPlayerCamera, "SetFOV", typeof(float));
_weaponAdsFov = Reflect.Bind(TWeapon, false, typeof(float), null, "AdsFov");
_fovSlider = Reflect.Bind(Reflect.FindType("ButtonManager"), false, null, "fovslider", "_fovSlider");
if (_localPlayer == null)
{
list.Add("Player.LocalPlayer");
}
if (_itemManagerItems == null)
{
list.Add("ItemManager.Items");
}
if (_itemCreature == null)
{
list.Add("Item.Creature");
}
Ready = list.Count == 0;
Status = (Ready ? "bound cleanly" : ("could not bind: " + string.Join(", ", list.ToArray())));
if (!Ready)
{
Plug.Log.LogError((object)("Aim Ur Way is inactive - " + Status + ". The game was probably updated; check for a mod update."));
}
else if (_setSensitivity == null)
{
Plug.Log.LogWarning((object)"PlayerCamera.SetSensitivity not found - the converter can still calculate values, but cannot apply them for you.");
}
return Ready;
}
public static bool CanAssistNow(object player)
{
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Expected O, but got Unknown
try
{
if (player == null)
{
return false;
}
if (_blockInputs != null && _blockInputs.GetBool(player))
{
return false;
}
object obj = ((_playerCamera != null) ? _playerCamera.Get(player) : null);
if ((Object)obj == (Object)null)
{
return false;
}
if (_mouseLocked != null && !_mouseLocked.GetBool(obj))
{
return false;
}
return true;
}
catch
{
return false;
}
}
public static bool TryGetHeldWeapon(object player, out object weapon, out bool isAds)
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Expected O, but got Unknown
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Expected O, but got Unknown
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Expected O, but got Unknown
weapon = null;
isAds = false;
try
{
object obj = ((_holding != null) ? _holding.Get(player) : null);
if ((Object)obj == (Object)null)
{
return false;
}
object obj2 = ((_heldItem != null) ? _heldItem.Get(obj) : null);
if ((Object)obj2 == (Object)null)
{
return false;
}
object obj3 = ((_itemWeapon != null) ? _itemWeapon.Get(obj2) : null);
if ((Object)obj3 == (Object)null)
{
return false;
}
weapon = obj3;
isAds = _weaponIsAds != null && _weaponIsAds.GetBool(obj3);
return true;
}
catch
{
return false;
}
}
public static bool IsUsingController()
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Expected O, but got Unknown
try
{
if (_gameInfoInput == null)
{
return false;
}
object obj = _gameInfoInput.Get(null);
if ((Object)obj == (Object)null)
{
return false;
}
PropertyInfo property = obj.GetType().GetProperty("currentControlScheme");
return ((property != null) ? (property.GetValue(obj, null) as string) : null) == "Controller";
}
catch
{
return false;
}
}
public static float GetSensitivity()
{
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Expected O, but got Unknown
try
{
object localPlayer = LocalPlayer;
if (localPlayer == null || _playerCamera == null || _sensitivity == null)
{
return float.NaN;
}
object obj = _playerCamera.Get(localPlayer);
if ((Object)obj == (Object)null)
{
return float.NaN;
}
return _sensitivity.GetFloat(obj);
}
catch
{
return float.NaN;
}
}
public static bool SetSensitivity(float value)
{
if (_setSensitivity == null)
{
return false;
}
try
{
_setSensitivity.Invoke(null, new object[1] { value });
return true;
}
catch (Exception ex)
{
Plug.Log.LogWarning((object)("Could not apply sensitivity: " + ex.Message));
return false;
}
}
public static float GetBaseFov()
{
try
{
return (_origFov != null) ? _origFov.GetFloat(null) : float.NaN;
}
catch
{
return float.NaN;
}
}
public static bool SetBaseFov(float verticalFov)
{
if (_setFov == null)
{
return false;
}
try
{
verticalFov = ((!TryGetFovRange(out var min, out var max)) ? Mathf.Clamp(verticalFov, 40f, 140f) : Mathf.Clamp(verticalFov, min, max));
_setFov.Invoke(null, new object[1] { verticalFov });
return true;
}
catch
{
return false;
}
}
public static void GetFovLimits(out float min, out float max)
{
if (!TryGetFovRange(out min, out max))
{
min = 40f;
max = 140f;
}
}
public static float GetHeldAdsFov()
{
try
{
object localPlayer = LocalPlayer;
if (localPlayer == null || _weaponAdsFov == null)
{
return float.NaN;
}
if (!TryGetHeldWeapon(localPlayer, out var weapon, out var _))
{
return float.NaN;
}
return _weaponAdsFov.GetFloat(weapon);
}
catch
{
return float.NaN;
}
}
public static bool TryGetFovRange(out float min, out float max)
{
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Expected O, but got Unknown
min = 0f;
max = 0f;
if (_fovSlider == null)
{
return false;
}
try
{
Type type = Reflect.FindType("ButtonManager");
if (type == null)
{
return false;
}
Object[] array = Object.FindObjectsByType(type, (FindObjectsInactive)1);
if (array == null || array.Length == 0)
{
return false;
}
object obj = _fovSlider.Get(array[0]);
if ((Object)obj == (Object)null)
{
return false;
}
Type type2 = obj.GetType();
PropertyInfo property = type2.GetProperty("minValue");
PropertyInfo property2 = type2.GetProperty("maxValue");
if (property == null || property2 == null)
{
return false;
}
min = Convert.ToSingle(property.GetValue(obj, null));
max = Convert.ToSingle(property2.GetValue(obj, null));
return max > min;
}
catch
{
return false;
}
}
public static bool RepairFovPersistence(out float restored)
{
restored = float.NaN;
try
{
bool num = PlayerPrefs.HasKey("FOV");
bool flag = PlayerPrefs.HasKey("Fov");
if (!num)
{
return false;
}
int num2 = PlayerPrefs.GetInt("FOV");
int num3 = (flag ? PlayerPrefs.GetInt("Fov", -1) : (-1));
if (num2 == num3)
{
return false;
}
PlayerPrefs.SetInt("Fov", num2);
PlayerPrefs.Save();
restored = num2;
return true;
}
catch
{
return false;
}
}
public static void CollectTargets(Vector3 from, float maxDistance, List<Target> into)
{
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Expected O, but got Unknown
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Expected O, but got Unknown
//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: 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_00d6: Unknown result type (might be due to invalid IL or missing references)
//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
into.Clear();
if (!Ready)
{
return;
}
IDictionary dictionary;
try
{
dictionary = _itemManagerItems.Get(null) as IDictionary;
}
catch
{
return;
}
if (dictionary == null)
{
return;
}
float num = maxDistance * maxDistance;
foreach (DictionaryEntry item in dictionary)
{
object value = item.Value;
if ((Object)value == (Object)null)
{
continue;
}
object obj2;
try
{
obj2 = _itemCreature.Get(value);
}
catch
{
continue;
}
if ((Object)obj2 == (Object)null)
{
continue;
}
try
{
Behaviour val = (Behaviour)((obj2 is Behaviour) ? obj2 : null);
if (!((Object)(object)val == (Object)null) && val.isActiveAndEnabled && (_creatureIsDead == null || !_creatureIsDead.GetBool(obj2)))
{
Vector3 val2 = CreatureCentre(obj2);
Vector3 val3 = val2 - from;
float sqrMagnitude = ((Vector3)(ref val3)).sqrMagnitude;
if (!(sqrMagnitude <= Mathf.Epsilon) && !(sqrMagnitude > num))
{
into.Add(new Target
{
Position = val2,
Handle = obj2,
Distance = Mathf.Sqrt(sqrMagnitude),
IsPlayer = false
});
}
}
}
catch
{
}
}
}
public static bool TryGetTargetPosition(object creature, out Vector3 position)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Expected O, but got Unknown
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
position = Vector3.zero;
if (!Ready || (Object)creature == (Object)null)
{
return false;
}
try
{
Behaviour val = (Behaviour)((creature is Behaviour) ? creature : null);
if ((Object)(object)val == (Object)null || !val.isActiveAndEnabled)
{
return false;
}
if (_creatureIsDead != null && _creatureIsDead.GetBool(creature))
{
return false;
}
position = CreatureCentre(creature);
return true;
}
catch
{
return false;
}
}
public static float GetLookDeltaDegrees(object player)
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Expected O, but got Unknown
//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)
try
{
if (_playerCamera == null || _camLookInput == null)
{
return 0f;
}
object obj = _playerCamera.Get(player);
if ((Object)obj == (Object)null)
{
return 0f;
}
return (_camLookInput.Get(obj) is Vector2 val) ? ((Vector2)(ref val)).magnitude : 0f;
}
catch
{
return 0f;
}
}
private static Vector3 CreatureCentre(object creature)
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
if (_creatureRig != null)
{
object obj = _creatureRig.Get(creature);
Rigidbody val = (Rigidbody)((obj is Rigidbody) ? obj : null);
if ((Object)(object)val != (Object)null)
{
return val.worldCenterOfMass;
}
}
if (_creatureTransform != null)
{
object obj2 = _creatureTransform.Get(creature);
Transform val2 = (Transform)((obj2 is Transform) ? obj2 : null);
if ((Object)(object)val2 != (Object)null)
{
return val2.position;
}
}
Component val3 = (Component)((creature is Component) ? creature : null);
if (!((Object)(object)val3 != (Object)null))
{
return Vector3.zero;
}
return val3.transform.position;
}
public static bool HasLineOfSight(Vector3 from, Vector3 to)
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
int num = LosMask();
if (num == 0)
{
return true;
}
return !Physics.Linecast(from, to, num, (QueryTriggerInteraction)1);
}
private static int LosMask()
{
if (_cachedLosMask >= 0)
{
return _cachedLosMask;
}
try
{
int num = MaskOf(_levelLayer) | MaskOf(_boatLayer);
if (num != 0)
{
_cachedLosMask = num;
}
return num;
}
catch
{
return 0;
}
}
private static int MaskOf(Member m)
{
//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)
if (m == null)
{
return 0;
}
object obj = m.Get(null);
if (!(obj is LayerMask val))
{
return Convert.ToInt32(obj);
}
return ((LayerMask)(ref val)).value;
}
public static bool AttachmentsBelongToLocalPlayer(object attachments)
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Expected O, but got Unknown
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Expected O, but got Unknown
try
{
if (_attachmentsWeapon == null || _itemHolder == null)
{
return false;
}
object obj = _attachmentsWeapon.Get(attachments);
if ((Object)obj == (Object)null)
{
return false;
}
object obj2 = _itemHolder.Get(obj);
if ((Object)obj2 == (Object)null)
{
return false;
}
return obj2 == LocalPlayer;
}
catch
{
return false;
}
}
}
internal sealed class Cfg
{
public readonly ConfigEntry<bool> Enabled;
public readonly ConfigEntry<string> ToggleAssistKey;
public readonly ConfigEntry<string> PanelKey;
public readonly ConfigEntry<float> Strength;
public readonly ConfigEntry<float> Sharpness;
public readonly ConfigEntry<float> MaxRotationSpeed;
public readonly ConfigEntry<float> ManualOverrideDegPerSec;
public readonly ConfigEntry<float> AcquireAngle;
public readonly ConfigEntry<float> BreakAngle;
public readonly ConfigEntry<float> MaxDistance;
public readonly ConfigEntry<float> ScanInterval;
public readonly ConfigEntry<bool> AssistFromHip;
public readonly ConfigEntry<bool> AlsoAssistController;
public readonly ConfigEntry<bool> DamagePenalty;
public readonly ConfigEntry<float> MaxDamagePenalty;
public readonly ConfigEntry<float> PenaltyWindowSeconds;
public readonly ConfigEntry<string> SourceGame;
public readonly ConfigEntry<float> SourceSensitivity;
public readonly ConfigEntry<float> MouseDpi;
public readonly ConfigEntry<float> TargetCm360;
public readonly ConfigEntry<bool> ApplyOnStart;
public readonly ConfigEntry<bool> UseMonitorMatch;
public readonly ConfigEntry<float> MonitorMatchPercent;
public readonly ConfigEntry<float> SourceHorizontalFov;
public readonly ConfigEntry<bool> FixFovPersistence;
public readonly ConfigEntry<bool> ShowDebugText;
public readonly ConfigEntry<bool> SelfTest;
public Cfg(ConfigFile file)
{
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Expected O, but got Unknown
//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: Expected O, but got Unknown
//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0108: Expected O, but got Unknown
//IL_0137: Unknown result type (might be due to invalid IL or missing references)
//IL_0141: Expected O, but got Unknown
//IL_0170: Unknown result type (might be due to invalid IL or missing references)
//IL_017a: Expected O, but got Unknown
//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
//IL_01b3: Expected O, but got Unknown
//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
//IL_01ec: Expected O, but got Unknown
//IL_021b: Unknown result type (might be due to invalid IL or missing references)
//IL_0225: Expected O, but got Unknown
//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
//IL_02b2: Expected O, but got Unknown
//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
//IL_02eb: Expected O, but got Unknown
//IL_033a: Unknown result type (might be due to invalid IL or missing references)
//IL_0344: Expected O, but got Unknown
//IL_0373: Unknown result type (might be due to invalid IL or missing references)
//IL_037d: Expected O, but got Unknown
//IL_03ac: Unknown result type (might be due to invalid IL or missing references)
//IL_03b6: Expected O, but got Unknown
//IL_041d: Unknown result type (might be due to invalid IL or missing references)
//IL_0427: Expected O, but got Unknown
//IL_0456: Unknown result type (might be due to invalid IL or missing references)
//IL_0460: Expected O, but got Unknown
Enabled = file.Bind<bool>("General", "Enabled", true, "Master switch for the aim assist. The sensitivity converter still works with this off.");
ToggleAssistKey = file.Bind<string>("General", "ToggleAssistKey", "F9", "Key that turns the assist on and off in game. Empty to disable the shortcut.");
PanelKey = file.Bind<string>("General", "PanelKey", "F10", "Key that opens the sensitivity converter panel. Empty to disable.");
Strength = file.Bind<float>("Assist", "Strength", 0.55f, new ConfigDescription("How much of the pull to apply. 0 is off, 1 matches the game's own controller assist. Below 1 always leaves the last of the aiming to you.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
Sharpness = file.Bind<float>("Assist", "Sharpness", 8f, new ConfigDescription("How eagerly the pull closes the gap. Higher feels stickier; too high starts to feel like it is aiming for you.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 30f), Array.Empty<object>()));
MaxRotationSpeed = file.Bind<float>("Assist", "MaxRotationSpeed", 90f, new ConfigDescription("Hard ceiling on how fast the assist may turn the camera, in degrees per second. This is what stops it ever snapping.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(5f, 400f), Array.Empty<object>()));
ManualOverrideDegPerSec = file.Bind<float>("Assist", "ManualOverrideDegPerSec", 140f, new ConfigDescription("Turn this fast yourself and the assist steps aside completely. Lower means it yields sooner.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(20f, 1000f), Array.Empty<object>()));
AcquireAngle = file.Bind<float>("Assist", "AcquireAngle", 12f, new ConfigDescription("Half-angle of the cone in which a target can be picked up, in degrees. Keep this small - it is the difference between an aim aid and an aimbot.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 45f), Array.Empty<object>()));
BreakAngle = file.Bind<float>("Assist", "BreakAngle", 35f, new ConfigDescription("Once locked, the target is dropped past this angle. Larger than AcquireAngle so tracking does not flicker.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(5f, 90f), Array.Empty<object>()));
MaxDistance = file.Bind<float>("Assist", "MaxDistance", 60f, new ConfigDescription("Furthest a target can be, in metres. Matches the game's own default.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(5f, 200f), Array.Empty<object>()));
ScanInterval = file.Bind<float>("Assist", "ScanInterval", 0.1f, new ConfigDescription("Seconds between searches for a new target when nothing is locked.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.02f, 1f), Array.Empty<object>()));
AssistFromHip = file.Bind<bool>("Assist", "AssistFromHip", false, "Assist while hip firing too. The game's own assist is aim-down-sights only, and leaving this off keeps the mod closer to intended behaviour.");
AlsoAssistController = file.Bind<bool>("Assist", "AlsoAssistController", false, "Also run this assist on a controller. Off by default because the game already has its own controller assist and stacking the two feels wrong.");
DamagePenalty = file.Bind<bool>("Fairness", "DamagePenalty", true, "Trade damage for aim help. The penalty scales with how much of your aiming the assist actually did, so a clean manual flick is never punished.");
MaxDamagePenalty = file.Bind<float>("Fairness", "MaxDamagePenalty", 0.3f, new ConfigDescription("Largest damage reduction, applied when the assist did all the aiming. 0.3 means -30%.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 0.9f), Array.Empty<object>()));
PenaltyWindowSeconds = file.Bind<float>("Fairness", "PenaltyWindowSeconds", 1.5f, new ConfigDescription("How long assist usage keeps counting against you. Shorter forgives faster.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.2f, 10f), Array.Empty<object>()));
SourceGame = file.Bind<string>("Sensitivity", "SourceGame", "Counter-Strike 2 / CS:GO", "Game to convert from. Must match one of the names listed in the converter panel, or be empty to use TargetCm360 instead.");
SourceSensitivity = file.Bind<float>("Sensitivity", "SourceSensitivity", 1f, new ConfigDescription("Your in-game sensitivity in that game.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.001f, 100f), Array.Empty<object>()));
MouseDpi = file.Bind<float>("Sensitivity", "MouseDpi", 800f, new ConfigDescription("Your mouse DPI. Only used to express results as a physical distance; the game-to-game conversion is exact regardless.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(100f, 32000f), Array.Empty<object>()));
TargetCm360 = file.Bind<float>("Sensitivity", "TargetCm360", 0f, new ConfigDescription("Convert from a cm/360 figure instead of a game preset. Any value above 0 takes priority over SourceGame, and works for every game ever made.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 500f), Array.Empty<object>()));
ApplyOnStart = file.Bind<bool>("Sensitivity", "ApplyOnStart", false, "Apply the converted sensitivity automatically on load. Off by default so the mod does not silently change your settings - open the panel and press Apply instead.");
UseMonitorMatch = file.Bind<bool>("FieldOfView", "AdjustForFovDifference", false, "false - keep the same turning speed as your other game. Ignores FOV, and is exact.\ntrue - allow for the two games having different FOV, so aiming feels the same on screen rather than turning at the same rate.");
MonitorMatchPercent = file.Bind<float>("FieldOfView", "FovAdjustStrength", 0f, new ConfigDescription("Only used when AdjustForFovDifference is on. 0 accounts for the FOV difference fully at the centre of the screen; 100 matches the screen edge instead. Leave it alone unless you already know you want something else.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>()));
SourceHorizontalFov = file.Bind<float>("FieldOfView", "OtherGameFov", 106.26f, new ConfigDescription("Your other game's FOV, measured left-to-right at 16:9. Only used when AdjustForFovDifference is on. Note that CS-style games quote FOV at 4:3, so 'fov 90' there is 106.26 here.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(40f, 170f), Array.Empty<object>()));
FixFovPersistence = file.Bind<bool>("FieldOfView", "FixFovPersistence", true, "Works around a game bug: the options menu saves your FOV under one key but loads it from another, and the two differ only in capitalisation - so your FOV quietly resets every launch. This copies the saved value across so it sticks. Worth having, because your FOV also changes how fast your aim moves while aiming down sights.");
SelfTest = file.Bind<bool>("Diagnostics", "SelfTest", false, "Run a one-off check at start-up that the on/off state and what gets reported agree, then put the setting back. Writes the result to the log.");
ShowDebugText = file.Bind<bool>("Diagnostics", "ShowDebugText", false, "Show the live target, assist share and current damage multiplier on screen.");
}
}
internal static class DamagePenalty
{
public static float LastMultiplier { get; private set; } = 1f;
public static void DamagePostfix(object __instance, ref int __result)
{
try
{
Cfg cfg = Plug.Cfg;
if (cfg.Enabled.Value && cfg.DamagePenalty.Value && Bind.Ready && AimAssist.RecentlyActive)
{
float assistShare = AimAssist.AssistShare;
if (!(assistShare <= 0.001f) && Bind.AttachmentsBelongToLocalPlayer(__instance))
{
float num = Mathf.Clamp01(cfg.MaxDamagePenalty.Value);
float num2 = (LastMultiplier = 1f - num * assistShare);
__result = Mathf.Max(1, Mathf.RoundToInt((float)__result * num2));
}
}
}
catch
{
}
}
}
internal static class Hotkey
{
private const float GraceSeconds = 3f;
private static bool _resolved;
private static bool _legacyBroken;
private static bool _newInputUsable = true;
private static MethodInfo _keyboardCurrent;
private static MethodInfo _keyIndexer;
private static MethodInfo _isPressed;
private static Type _keyEnumType;
private static readonly object[] IndexArgs = new object[1];
private static readonly Dictionary<string, bool> WasHeld = new Dictionary<string, bool>(4);
private static string _cachedName;
private static object _cachedNewKey;
private static KeyCode _cachedLegacy;
private static bool _cachedValid;
public static string LastBackend { get; private set; } = "none";
public static bool Pressed(string keyName)
{
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
if (string.IsNullOrEmpty(keyName))
{
return false;
}
if (!_resolved)
{
Resolve();
}
if (!Parse(keyName, out var newKey, out var legacyKey))
{
return false;
}
bool flag;
string lastBackend;
if (_newInputUsable && newKey != null)
{
flag = ReadNewInputHeld(newKey);
lastBackend = "InputSystem";
}
else
{
flag = ReadLegacyHeld(legacyKey);
lastBackend = "legacy";
}
WasHeld.TryGetValue(keyName, out var value);
WasHeld[keyName] = flag;
if (Time.realtimeSinceStartup < 3f)
{
return false;
}
int num;
if (flag)
{
num = ((!value) ? 1 : 0);
if (num != 0)
{
LastBackend = lastBackend;
}
}
else
{
num = 0;
}
return (byte)num != 0;
}
private static bool ReadNewInputHeld(object key)
{
try
{
object obj = _keyboardCurrent.Invoke(null, null);
if (obj == null)
{
return false;
}
IndexArgs[0] = key;
object obj2 = _keyIndexer.Invoke(obj, IndexArgs);
if (obj2 == null)
{
return false;
}
return (bool)_isPressed.Invoke(obj2, null);
}
catch
{
_newInputUsable = false;
return false;
}
}
private static bool ReadLegacyHeld(KeyCode key)
{
//IL_0007: 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)
if (_legacyBroken || (int)key == 0)
{
return false;
}
try
{
return Input.GetKey(key);
}
catch
{
_legacyBroken = true;
return false;
}
}
private static void Resolve()
{
_resolved = true;
try
{
Type type = Reflect.FindType("UnityEngine.InputSystem.Keyboard");
_keyEnumType = Reflect.FindType("UnityEngine.InputSystem.Key");
if (type == null || _keyEnumType == null)
{
_newInputUsable = false;
return;
}
PropertyInfo property = type.GetProperty("current", BindingFlags.DeclaredOnly | BindingFlags.Static | BindingFlags.Public);
_keyboardCurrent = ((property != null) ? property.GetGetMethod() : null);
_keyIndexer = type.GetMethod("get_Item", BindingFlags.Instance | BindingFlags.Public, null, new Type[1] { _keyEnumType }, null);
Type type2 = Reflect.FindType("UnityEngine.InputSystem.Controls.ButtonControl");
PropertyInfo propertyInfo = ((type2 != null) ? type2.GetProperty("isPressed", BindingFlags.Instance | BindingFlags.Public) : null);
_isPressed = ((propertyInfo != null) ? propertyInfo.GetGetMethod() : null);
if (_keyboardCurrent == null || _keyIndexer == null || _isPressed == null)
{
_newInputUsable = false;
}
}
catch (Exception ex)
{
_newInputUsable = false;
Plug.Log.LogWarning((object)("Could not attach to the Input System package: " + ex.Message));
}
}
private static bool Parse(string keyName, out object newKey, out KeyCode legacyKey)
{
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Expected I4, but got Unknown
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Invalid comparison between Unknown and I4
if (keyName != _cachedName)
{
_cachedName = keyName;
_cachedNewKey = null;
_cachedLegacy = (KeyCode)0;
string value = keyName.Trim();
if (_newInputUsable && _keyEnumType != null)
{
try
{
_cachedNewKey = Enum.Parse(_keyEnumType, value, ignoreCase: true);
}
catch
{
_cachedNewKey = null;
}
}
try
{
_cachedLegacy = (KeyCode)Enum.Parse(typeof(KeyCode), value, ignoreCase: true);
}
catch
{
_cachedLegacy = (KeyCode)0;
}
_cachedValid = _cachedNewKey != null || (int)_cachedLegacy > 0;
if (!_cachedValid)
{
Plug.Log.LogWarning((object)("'" + keyName + "' is not a key name I recognise. Try F9, H or Backquote."));
}
}
newKey = _cachedNewKey;
legacyKey = (KeyCode)(int)_cachedLegacy;
return _cachedValid;
}
}
[BepInPlugin("howtofish.aimurway", "Aim Ur Way", "0.1.0")]
[BepInProcess("How to Fish.exe")]
public sealed class Plug : BaseUnityPlugin
{
public const string Guid = "howtofish.aimurway";
public const string Name = "Aim Ur Way";
public const string Version = "0.1.0";
internal static ManualLogSource Log;
internal static Cfg Cfg;
private Harmony _harmony;
private float _repairedFov = float.NaN;
private void Awake()
{
Log = ((BaseUnityPlugin)this).Logger;
Cfg = new Cfg(((BaseUnityPlugin)this).Config);
if (Cfg.FixFovPersistence.Value)
{
RepairFov();
}
((MonoBehaviour)this).StartCoroutine(SetUpWhenReady());
}
private IEnumerator SetUpWhenReady()
{
int waited = 0;
while (Reflect.FindType("Player") == null)
{
int num = waited + 1;
waited = num;
if (num > 600)
{
Log.LogError((object)"Gave up waiting for the game's script assembly. Aim Ur Way is inactive.");
yield break;
}
yield return null;
}
if (Bind.Initialise())
{
ApplyPatches();
SensPanel.Create();
if (Cfg.ApplyOnStart.Value)
{
ApplyConfiguredSensitivity();
}
Log.LogInfo((object)("Aim Ur Way 0.1.0 ready. Aim assist starts " + (Cfg.Enabled.Value ? "ON" : "OFF") + " (remembered from your config). " + Cfg.ToggleAssistKey.Value + " toggles it, " + Cfg.PanelKey.Value + " opens the sensitivity panel."));
if (Cfg.SelfTest.Value)
{
RunToggleSelfTest();
}
((MonoBehaviour)this).StartCoroutine(ReportFovWhenKnown());
}
}
private void RunToggleSelfTest()
{
bool value = Cfg.Enabled.Value;
Log.LogInfo((object)"--- self-test: does the reported state match reality? ---");
Log.LogInfo((object)(" starting state: " + (value ? "ON" : "OFF")));
bool flag = true;
for (int i = 0; i < 4; i++)
{
bool value2 = Cfg.Enabled.Value;
Cfg.Enabled.Value = !value2;
bool value3 = Cfg.Enabled.Value;
string text = (value3 ? "enabled" : "disabled");
bool gateOpen = AimAssist.GateOpen;
bool num = value3 != value2;
bool flag2 = text == "enabled" == value3;
bool flag3 = gateOpen == value3;
bool flag4 = num && flag2 && flag3;
if (!flag4)
{
flag = false;
}
Log.LogInfo((object)(" " + (value2 ? "ON " : "OFF") + " -> " + (value3 ? "ON " : "OFF") + " | says \"" + text + "\" | assist gate " + (gateOpen ? "open" : "closed") + " | " + (flag4 ? "OK" : "MISMATCH")));
}
Cfg.Enabled.Value = value;
Log.LogInfo((object)(" restored to " + (value ? "ON" : "OFF")));
Log.LogInfo((object)(flag ? "--- self-test PASSED: state, message and behaviour all agree ---" : "--- self-test FAILED: reporting does not match state ---"));
}
private IEnumerator ReportFovWhenKnown()
{
float waited = 0f;
while (waited < 120f)
{
float baseFov = Bind.GetBaseFov();
if (!float.IsNaN(baseFov) && baseFov > 1f)
{
if (!float.IsNaN(_repairedFov) && Mathf.Abs(baseFov - _repairedFov) > 0.5f && Bind.SetBaseFov(_repairedFov))
{
Log.LogInfo((object)("Applied FOV " + _repairedFov.ToString("0.##") + " for this session (the menu had already loaded " + baseFov.ToString("0.##") + ")."));
}
LogFovContext();
break;
}
waited += 1f;
yield return (object)new WaitForSeconds(1f);
}
}
private void RepairFov()
{
if (Bind.RepairFovPersistence(out var restored))
{
_repairedFov = restored;
Log.LogInfo((object)("Restored FOV " + restored.ToString("0.##") + ". The game saves FOV under the key 'FOV' but reads it from 'Fov', so it was resetting to 74 every launch. This also changes aimed sensitivity, which is scaled by AdsFov / baseFov."));
}
}
private void ApplyPatches()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Expected O, but got Unknown
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Expected O, but got Unknown
//IL_015b: Unknown result type (might be due to invalid IL or missing references)
//IL_0168: Expected O, but got Unknown
_harmony = new Harmony("howtofish.aimurway");
MethodInfo methodInfo = Reflect.BindMethod(Bind.TPlayerAimAssist, "GetRotationDelta", typeof(Vector3), typeof(Vector3), typeof(float));
if (methodInfo == null)
{
Log.LogError((object)"PlayerAimAssist.GetRotationDelta not found - the aim assist is unavailable. The sensitivity converter still works.");
}
else
{
try
{
_harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(typeof(AimAssist).GetMethod("GetRotationDeltaPostfix", BindingFlags.Static | BindingFlags.Public)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
Log.LogInfo((object)("Patched " + methodInfo.DeclaringType.Name + "." + methodInfo.Name));
}
catch (Exception ex)
{
Log.LogError((object)("Could not patch the aim assist hook: " + ex.Message));
}
}
PropertyInfo propertyInfo = ((Bind.TAttachments != null) ? Bind.TAttachments.GetProperty("Damage", BindingFlags.Instance | BindingFlags.Public) : null);
MethodInfo methodInfo2 = ((propertyInfo != null) ? propertyInfo.GetGetMethod(nonPublic: true) : null);
if (methodInfo2 == null)
{
Log.LogWarning((object)"Attachments.Damage not found - the damage penalty cannot be applied, so the assist would be a straight advantage. Disabling the assist to stay honest.");
Cfg.Enabled.Value = false;
return;
}
try
{
_harmony.Patch((MethodBase)methodInfo2, (HarmonyMethod)null, new HarmonyMethod(typeof(DamagePenalty).GetMethod("DamagePostfix", BindingFlags.Static | BindingFlags.Public)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
Log.LogInfo((object)"Patched Attachments.get_Damage for the damage penalty");
}
catch (Exception ex2)
{
Log.LogError((object)("Could not patch the damage penalty: " + ex2.Message + ". Disabling the assist to stay honest."));
Cfg.Enabled.Value = false;
}
}
private void LogFovContext()
{
float baseFov = Bind.GetBaseFov();
if (!float.IsNaN(baseFov) && !(baseFov <= 0f))
{
float aspect = SensConverter.CurrentAspect();
Log.LogInfo((object)("FOV " + baseFov.ToString("0.##") + " vertical = " + SensConverter.VerticalToHorizontalFov(baseFov, aspect).ToString("0.##") + " horizontal at " + Screen.width + "x" + Screen.height + " (aspect " + aspect.ToString("0.###") + ")"));
if (Bind.TryGetFovRange(out var min, out var max))
{
Log.LogInfo((object)("FOV slider range " + min.ToString("0") + "-" + max.ToString("0") + " vertical = " + SensConverter.VerticalToHorizontalFov(min, aspect).ToString("0") + "-" + SensConverter.VerticalToHorizontalFov(max, aspect).ToString("0") + " horizontal"));
}
float sensitivity = Bind.GetSensitivity();
if (!float.IsNaN(sensitivity))
{
Log.LogInfo((object)("Sensitivity " + sensitivity.ToString("0.####") + " = " + SensConverter.GameSensToCm360(sensitivity, Cfg.MouseDpi.Value).ToString("0.##") + " cm/360 at " + Cfg.MouseDpi.Value.ToString("0") + " DPI"));
}
}
}
private void ApplyConfiguredSensitivity()
{
float value = Cfg.MouseDpi.Value;
float value2;
if (Cfg.TargetCm360.Value > 0f)
{
value2 = SensConverter.GameSensForCm360(Cfg.TargetCm360.Value, value);
}
else
{
SensPreset sensPreset = SensConverter.Presets.Find((SensPreset p) => p.Name == Cfg.SourceGame.Value);
if (sensPreset == null)
{
Log.LogWarning((object)("SourceGame '" + Cfg.SourceGame.Value + "' is not a known preset; not applying a sensitivity."));
return;
}
value2 = SensConverter.OtherGameToGameSens(sensPreset, Cfg.SourceSensitivity.Value);
}
float sensitivity = SensConverter.ClampGameSens(value2);
if (Bind.SetSensitivity(sensitivity))
{
Log.LogInfo((object)("Applied converted sensitivity " + sensitivity.ToString("0.####") + "."));
}
}
private void OnDestroy()
{
if (_harmony != null)
{
_harmony.UnpatchSelf();
}
}
}
internal sealed class Member
{
private readonly FieldInfo _field;
private readonly MethodInfo _getter;
private readonly MethodInfo _setter;
public string Path { get; }
public bool ExactName { get; }
public bool CanWrite
{
get
{
if (!(_field != null))
{
return _setter != null;
}
return true;
}
}
internal Member(string path, FieldInfo field, MethodInfo getter, MethodInfo setter, bool exactName)
{
Path = path;
_field = field;
_getter = getter;
_setter = setter;
ExactName = exactName;
}
public object Get(object instance)
{
if (!(_field != null))
{
return _getter.Invoke(instance, null);
}
return _field.GetValue(instance);
}
public void Set(object instance, object value)
{
if (_field != null)
{
_field.SetValue(instance, value);
}
else if (_setter != null)
{
_setter.Invoke(instance, new object[1] { value });
}
}
public float GetFloat(object i)
{
return Convert.ToSingle(Get(i));
}
public int GetInt(object i)
{
return Convert.ToInt32(Get(i));
}
public bool GetBool(object i)
{
return (bool)Get(i);
}
}
internal static class Reflect
{
private const BindingFlags Declared = BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.NonPublic;
public static Type FindType(string name)
{
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
Assembly[] array = assemblies;
foreach (Assembly assembly in array)
{
if (!(assembly.GetName().Name != "Assembly-CSharp"))
{
Type type = Safe(assembly, name);
if (type != null)
{
return type;
}
}
}
array = assemblies;
for (int i = 0; i < array.Length; i++)
{
Type type2 = Safe(array[i], name);
if (type2 != null)
{
return type2;
}
}
return null;
}
private static Type Safe(Assembly asm, string name)
{
try
{
return asm.GetType(name, throwOnError: false);
}
catch
{
return null;
}
}
public static Member Bind(Type owner, bool isStatic, Type valueType, string keyword, params string[] candidates)
{
if (owner == null)
{
return null;
}
BindingFlags bindingFlags = (isStatic ? BindingFlags.Static : BindingFlags.Instance);
foreach (string name in candidates)
{
Type type = owner;
while (type != null && type != typeof(object))
{
FieldInfo field = type.GetField(name, BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.NonPublic | bindingFlags);
if (field != null && Matches(field.FieldType, valueType))
{
return new Member(type.Name + "." + field.Name, field, null, null, exactName: true);
}
PropertyInfo property = type.GetProperty(name, BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.NonPublic | bindingFlags);
if (property != null && property.CanRead && Matches(property.PropertyType, valueType))
{
MethodInfo getMethod = property.GetGetMethod(nonPublic: true);
if (getMethod != null)
{
return new Member(type.Name + "." + property.Name, null, getMethod, property.GetSetMethod(nonPublic: true), exactName: true);
}
}
type = type.BaseType;
}
}
if (string.IsNullOrEmpty(keyword))
{
return null;
}
Type type2 = owner;
while (type2 != null && type2 != typeof(object))
{
FieldInfo[] fields = type2.GetFields(BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.NonPublic | bindingFlags);
foreach (FieldInfo fieldInfo in fields)
{
if (Contains(fieldInfo.Name, keyword) && Matches(fieldInfo.FieldType, valueType))
{
return new Member(type2.Name + "." + fieldInfo.Name, fieldInfo, null, null, exactName: false);
}
}
PropertyInfo[] properties = type2.GetProperties(BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.NonPublic | bindingFlags);
foreach (PropertyInfo propertyInfo in properties)
{
if (propertyInfo.CanRead && Contains(propertyInfo.Name, keyword) && Matches(propertyInfo.PropertyType, valueType))
{
MethodInfo getMethod2 = propertyInfo.GetGetMethod(nonPublic: true);
if (getMethod2 != null)
{
return new Member(type2.Name + "." + propertyInfo.Name, null, getMethod2, propertyInfo.GetSetMethod(nonPublic: true), exactName: false);
}
}
}
type2 = type2.BaseType;
}
return null;
}
public static MethodInfo BindMethod(Type owner, string name, params Type[] parameters)
{
if (owner == null)
{
return null;
}
Type type = owner;
while (type != null && type != typeof(object))
{
MethodInfo method = type.GetMethod(name, BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, null, parameters, null);
if (method != null)
{
return method;
}
type = type.BaseType;
}
return null;
}
private static bool Contains(string haystack, string needle)
{
return haystack.IndexOf(needle, StringComparison.OrdinalIgnoreCase) >= 0;
}
private static bool Matches(Type actual, Type expected)
{
if (expected == null || expected == actual)
{
return true;
}
return expected.IsAssignableFrom(actual);
}
}
internal sealed class SensPreset
{
public readonly string Name;
public readonly float DegreesPerCountAtOne;
public readonly float DefaultHorizontalFov;
public readonly string Note;
public SensPreset(string name, float degreesPerCountAtOne, float defaultHorizontalFov, string note = null)
{
Name = name;
DegreesPerCountAtOne = degreesPerCountAtOne;
DefaultHorizontalFov = defaultHorizontalFov;
Note = note;
}
}
internal static class SensConverter
{
public const float GameDegreesPerCountAtOne = 0.025f;
private const float CmPerInch = 2.54f;
public static readonly List<SensPreset> Presets = new List<SensPreset>
{
new SensPreset("Counter-Strike 2 / CS:GO", 0.022f, 106.26f, "fov 90 at 4:3 = 106.26 at 16:9"),
new SensPreset("Valorant", 0.07f, 103f, "FOV is fixed at 103"),
new SensPreset("Apex Legends", 0.022f, 106.26f, "Source engine; edit FOV for your slider"),
new SensPreset("Overwatch 2", 0.0066f, 103f, "default slider maximum"),
new SensPreset("Team Fortress 2", 0.022f, 106.26f, "fov_desired 90"),
new SensPreset("Quake Live / Champions", 0.022f, 106.26f, "cg_fov 90, m_yaw 0.022")
};
public static readonly float[] MonitorMatchPresets = new float[4] { 0f, 0.5625f, 0.75f, 1f };
public static readonly string[] MonitorMatchLabels = new string[4] { "0%", "56.25%", "75%", "100%" };
public static float CountsPerCm(float dpi)
{
return dpi / 2.54f;
}
public static float Cm360(float degreesPerCount, float dpi)
{
float num = degreesPerCount * CountsPerCm(dpi);
if (!(num <= 0f))
{
return 360f / num;
}
return float.PositiveInfinity;
}
public static float DegreesPerCountForCm360(float cm360, float dpi)
{
float num = cm360 * CountsPerCm(dpi);
if (!(num <= 0f))
{
return 360f / num;
}
return 0f;
}
public static float GameSensForCm360(float cm360, float dpi)
{
return DegreesPerCountForCm360(cm360, dpi) / 0.025f;
}
public static float GameSensToCm360(float gameSens, float dpi)
{
return Cm360(gameSens * 0.025f, dpi);
}
public static float OtherGameToCm360(SensPreset preset, float theirSens, float dpi)
{
return Cm360(preset.DegreesPerCountAtOne * theirSens, dpi);
}
public static float OtherGameToGameSens(SensPreset preset, float theirSens)
{
return preset.DegreesPerCountAtOne * theirSens / 0.025f;
}
public static float CmToInches(float cm)
{
return cm / 2.54f;
}
public static float VerticalToHorizontalFov(float verticalFov, float aspect)
{
float num = verticalFov * 0.5f * (MathF.PI / 180f);
return 2f * Mathf.Atan(Mathf.Tan(num) * aspect) * 57.29578f;
}
public static float HorizontalToVerticalFov(float horizontalFov, float aspect)
{
float num = horizontalFov * 0.5f * (MathF.PI / 180f);
return 2f * Mathf.Atan(Mathf.Tan(num) / aspect) * 57.29578f;
}
public static float Fov43ToAspect(float horizontalFov43, float aspect)
{
return VerticalToHorizontalFov(HorizontalToVerticalFov(horizontalFov43, 1.3333334f), aspect);
}
public static float CurrentAspect()
{
if (Screen.height <= 0)
{
return 1.7777778f;
}
return (float)Screen.width / (float)Screen.height;
}
private static float ViewAngleAt(float fovDegrees, float fraction)
{
float num = Mathf.Tan(fovDegrees * 0.5f * (MathF.PI / 180f));
return Mathf.Atan(Mathf.Max(0.0001f, fraction) * num);
}
public static float MonitorMatchGameSens(SensPreset preset, float theirSens, float theirHorizontalFov, float ourHorizontalFov, float monitorFraction)
{
if (theirHorizontalFov <= 0f || ourHorizontalFov <= 0f)
{
return float.NaN;
}
float num = ViewAngleAt(theirHorizontalFov, monitorFraction);
float num2 = ViewAngleAt(ourHorizontalFov, monitorFraction);
if (num <= 0f)
{
return float.NaN;
}
return OtherGameToGameSens(preset, theirSens) * (num2 / num);
}
public static float AdsSensMultiplier(float baseFov, float adsFov)
{
if (baseFov <= 0f || adsFov <= 0f)
{
return 1f;
}
return adsFov / baseFov;
}
public static float ClampGameSens(float value)
{
return Mathf.Clamp(value, 0.01f, 20f);
}
}
internal sealed class SensPanel : MonoBehaviour
{
private const int WindowId = 1096111905;
private bool _open;
private Rect _window = new Rect(60f, 60f, 460f, 520f);
private Vector2 _scroll;
private string _sens = "1";
private string _dpi = "800";
private string _cm360 = "";
private string _theirFov = "106.26";
private string _fovBox = "";
private int _presetIndex;
private bool _matchOnScreenFeel;
private string _status;
private int _toggleCount;
public static SensPanel Create()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Expected O, but got Unknown
GameObject val = new GameObject("AimUrWay");
Object.DontDestroyOnLoad((Object)val);
SensPanel sensPanel = val.AddComponent<SensPanel>();
sensPanel.LoadFromConfig();
return sensPanel;
}
private void LoadFromConfig()
{
Cfg cfg = Plug.Cfg;
_sens = cfg.SourceSensitivity.Value.ToString("0.####");
_dpi = cfg.MouseDpi.Value.ToString("0");
_cm360 = ((cfg.TargetCm360.Value > 0f) ? cfg.TargetCm360.Value.ToString("0.##") : "");
_theirFov = cfg.SourceHorizontalFov.Value.ToString("0.##");
_matchOnScreenFeel = cfg.UseMonitorMatch.Value;
for (int i = 0; i < SensConverter.Presets.Count; i++)
{
if (SensConverter.Presets[i].Name == cfg.SourceGame.Value)
{
_presetIndex = i;
}
}
}
private void Update()
{
Cfg cfg = Plug.Cfg;
if (Hotkey.Pressed(cfg.ToggleAssistKey.Value))
{
bool value = cfg.Enabled.Value;
cfg.Enabled.Value = !value;
AimAssist.Reset();
_toggleCount++;
Plug.Log.LogInfo((object)("Aim assist " + (value ? "ON" : "OFF") + " -> " + (cfg.Enabled.Value ? "ON" : "OFF") + " (press #" + _toggleCount + " of " + cfg.ToggleAssistKey.Value + ")"));
}
if (!Hotkey.Pressed(cfg.PanelKey.Value))
{
return;
}
_open = !_open;
if (_open)
{
float baseFov = Bind.GetBaseFov();
if (!float.IsNaN(baseFov) && baseFov > 1f)
{
_fovBox = baseFov.ToString("0");
}
}
}
private void OnGUI()
{
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Expected O, but got Unknown
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
if (Plug.Cfg.ShowDebugText.Value)
{
DrawDebug();
}
if (_open)
{
((Rect)(ref _window)).height = Mathf.Min(560f, (float)Screen.height - 120f);
_window = GUILayout.Window(1096111905, _window, new WindowFunction(DrawWindow), "Aim Ur Way", Array.Empty<GUILayoutOption>());
}
}
private void DrawDebug()
{
//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
//IL_0114: Unknown result type (might be due to invalid IL or missing references)
float assistShare = AimAssist.AssistShare;
float num = (AimAssist.RecentlyActive ? (1f - Mathf.Clamp01(Plug.Cfg.MaxDamagePenalty.Value) * assistShare) : 1f);
string text = "Aim Ur Way\nassist " + (Plug.Cfg.Enabled.Value ? "on" : "off") + "\ntarget " + (AimAssist.HasTarget ? "locked" : "none") + "\nhelped " + (assistShare * 100f).ToString("0") + "% of your aiming\ndamage x" + num.ToString("0.00");
Rect val = default(Rect);
((Rect)(ref val))..ctor(14f, 200f, 300f, 96f);
GUI.Box(val, GUIContent.none);
GUI.Label(new Rect(((Rect)(ref val)).x + 8f, ((Rect)(ref val)).y + 6f, ((Rect)(ref val)).width - 16f, ((Rect)(ref val)).height - 12f), text);
}
private void DrawWindow(int id)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_08fc: Unknown result type (might be due to invalid IL or missing references)
Cfg cfg = Plug.Cfg;
_scroll = GUILayout.BeginScrollView(_scroll, Array.Empty<GUILayoutOption>());
float aspect = SensConverter.CurrentAspect();
float baseFov = Bind.GetBaseFov();
bool flag = !float.IsNaN(baseFov) && baseFov > 1f;
float ourHorizontalFov = (flag ? SensConverter.VerticalToHorizontalFov(baseFov, aspect) : 0f);
float result;
bool flag2 = float.TryParse(_dpi, out result) && result > 0f;
GUILayout.Label("YOUR SETUP", Array.Empty<GUILayoutOption>());
float sensitivity = Bind.GetSensitivity();
if (!float.IsNaN(sensitivity))
{
string text = "Sensitivity " + sensitivity.ToString("0.####");
if (flag2)
{
text = text + " = " + SensConverter.GameSensToCm360(sensitivity, result).ToString("0.#") + " cm per 360";
}
GUILayout.Label(text, Array.Empty<GUILayoutOption>());
}
if (flag)
{
GUILayout.Label("FOV " + baseFov.ToString("0") + " (that is " + ourHorizontalFov.ToString("0") + " measured left-to-right on your " + Screen.width + "x" + Screen.height + " screen)", Array.Empty<GUILayoutOption>());
float heldAdsFov = Bind.GetHeldAdsFov();
if (!float.IsNaN(heldAdsFov) && heldAdsFov > 0f)
{
GUILayout.Label("Aiming down sights slows your sensitivity to x" + SensConverter.AdsSensMultiplier(baseFov, heldAdsFov).ToString("0.00") + ". A higher FOV makes aiming slower.", Array.Empty<GUILayoutOption>());
}
}
else
{
GUILayout.Label("Load into a game to see your FOV and sensitivity.", Array.Empty<GUILayoutOption>());
}
Bind.GetFovLimits(out var min, out var max);
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
GUILayout.Label("Change FOV to", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(110f) });
_fovBox = GUILayout.TextField(_fovBox, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) });
GUILayout.Label("(" + min.ToString("0") + "-" + max.ToString("0") + ")", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(70f) });
if (GUILayout.Button("Set", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(60f) }) && float.TryParse(_fovBox, out var result2) && result2 > 1f)
{
float num = Mathf.Clamp(result2, min, max);
if (Bind.SetBaseFov(num))
{
PlayerPrefs.SetInt("Fov", (int)num);
PlayerPrefs.SetInt("FOV", (int)num);
PlayerPrefs.Save();
_fovBox = num.ToString("0");
_status = "FOV set to " + num.ToString("0") + " and saved so it sticks next launch.";
}
else
{
_status = "Could not change FOV.";
}
}
GUILayout.EndHorizontal();
GUILayout.Label("This uses the game's own limits - the mod does not widen them.", Array.Empty<GUILayoutOption>());
GUILayout.Space(10f);
GUILayout.Label("BRING YOUR AIM OVER FROM ANOTHER GAME", Array.Empty<GUILayoutOption>());
string[] array = new string[SensConverter.Presets.Count];
for (int i = 0; i < array.Length; i++)
{
array[i] = SensConverter.Presets[i].Name;
}
_presetIndex = Mathf.Clamp(_presetIndex, 0, array.Length - 1);
int num2 = GUILayout.SelectionGrid(_presetIndex, array, 2, Array.Empty<GUILayoutOption>());
if (num2 != _presetIndex)
{
_presetIndex = num2;
_theirFov = SensConverter.Presets[_presetIndex].DefaultHorizontalFov.ToString("0.##");
}
SensPreset sensPreset = SensConverter.Presets[_presetIndex];
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
GUILayout.Label("Your sensitivity there", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(160f) });
_sens = GUILayout.TextField(_sens, Array.Empty<GUILayoutOption>());
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
GUILayout.Label("Your mouse DPI", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(160f) });
_dpi = GUILayout.TextField(_dpi, Array.Empty<GUILayoutOption>());
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
GUILayout.Label("or your cm per 360", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(160f) });
_cm360 = GUILayout.TextField(_cm360, Array.Empty<GUILayoutOption>());
GUILayout.EndHorizontal();
GUILayout.Label("(cm per 360 is how far you drag the mouse to spin all the way round)", Array.Empty<GUILayoutOption>());
GUILayout.Space(8f);
bool num3 = GUILayout.Toggle(!_matchOnScreenFeel, " Keep the same turning speed (recommended)", Array.Empty<GUILayoutOption>());
bool flag3 = GUILayout.Toggle(_matchOnScreenFeel, " Adjust for the FOV difference instead", Array.Empty<GUILayoutOption>());
if (num3 && _matchOnScreenFeel)
{
_matchOnScreenFeel = false;
}
else if (flag3 && !_matchOnScreenFeel)
{
_matchOnScreenFeel = true;
}
if (_matchOnScreenFeel)
{
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
GUILayout.Label("That game's FOV", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(160f) });
_theirFov = GUILayout.TextField(_theirFov, Array.Empty<GUILayoutOption>());
GUILayout.EndHorizontal();
GUILayout.Label("(left-to-right, at 16:9. " + sensPreset.Name + " is about " + sensPreset.DefaultHorizontalFov.ToString("0") + ")", Array.Empty<GUILayoutOption>());
}
GUILayout.Space(10f);
GUILayout.Label("RESULT", Array.Empty<GUILayoutOption>());
float result3;
bool flag4 = float.TryParse(_sens, out result3) && result3 > 0f;
float result4;
bool flag5 = float.TryParse(_cm360, out result4) && result4 > 0f;
float result5;
bool flag6 = float.TryParse(_theirFov, out result5) && result5 > 0f;
float num4 = float.NaN;
if (flag5 && flag2)
{
num4 = SensConverter.GameSensForCm360(result4, result);
}
else if (flag4)
{
if (!_matchOnScreenFeel)
{
num4 = SensConverter.OtherGameToGameSens(sensPreset, result3);
}
else if (flag && flag6)
{
num4 = SensConverter.MonitorMatchGameSens(sensPreset, result3, result5, ourHorizontalFov, Mathf.Clamp01(cfg.MonitorMatchPercent.Value / 100f));
}
else
{
GUILayout.Label(flag ? "Enter that game's FOV." : "Load into a game first.", Array.Empty<GUILayoutOption>());
}
}
else
{
GUILayout.Label("Enter your sensitivity, or your cm per 360.", Array.Empty<GUILayoutOption>());
}
if (!float.IsNaN(num4))
{
float num5 = SensConverter.ClampGameSens(num4);
GUILayout.Label("Set your sensitivity in this game to " + num5.ToString("0.###"), Array.Empty<GUILayoutOption>());
if (flag2)
{
GUILayout.Label("That is " + SensConverter.GameSensToCm360(num5, result).ToString("0.#") + " cm per 360 at " + result.ToString("0") + " DPI.", Array.Empty<GUILayoutOption>());
}
if (GUILayout.Button("Set it for me", Array.Empty<GUILayoutOption>()))
{
_status = (Bind.SetSensitivity(num5) ? ("Sensitivity set to " + num5.ToString("0.###") + ".") : "Could not set it - enter it in Options instead.");
}
GUILayout.Label("Touching the Options sensitivity slider will overwrite this.", Array.Empty<GUILayoutOption>());
}
GUILayout.Space(10f);
if (GUILayout.Button("Remember these settings", Array.Empty<GUILayoutOption>()))
{
if (flag4)
{
cfg.SourceSensitivity.Value = result3;
}
if (flag2)
{
cfg.MouseDpi.Value = result;
}
if (flag6)
{
cfg.SourceHorizontalFov.Value = result5;
}
cfg.TargetCm360.Value = (flag5 ? result4 : 0f);
cfg.SourceGame.Value = sensPreset.Name;
cfg.UseMonitorMatch.Value = _matchOnScreenFeel;
_status = "Saved.";
}
GUILayout.Space(6f);
GUILayout.Label("SOFT AIM ASSIST", Array.Empty<GUILayoutOption>());
GUILayout.Label("Press " + cfg.ToggleAssistKey.Value + " any time.", Array.Empty<GUILayoutOption>());
if (GUILayout.Button("Toggle", Array.Empty<GUILayoutOption>()))
{
cfg.Enabled.Value = !cfg.Enabled.Value;
AimAssist.Reset();
}
if (!string.IsNullOrEmpty(_status))
{
GUILayout.Space(6f);
GUILayout.Label(_status, Array.Empty<GUILayoutOption>());
}
GUILayout.Space(4f);
if (GUILayout.Button("Close", Array.Empty<GUILayoutOption>()))
{
_open = false;
}
GUILayout.EndScrollView();
GUI.DragWindow(new Rect(0f, 0f, 10000f, 20f));
}
}
}