using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using Cleverous.Prodigy;
using Cleverous.Prodigy.Input;
using Cleverous.VaultInventory;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Tableflip;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.SceneManagement;
[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("MikhailKillsZombies")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyCopyright("Copyright (c) 2026 MikhailKillsZombies")]
[assembly: AssemblyFileVersion("0.5.6.0")]
[assembly: AssemblyInformationalVersion("0.5.6")]
[assembly: AssemblyProduct("mikhailkillszombies.FateAiming")]
[assembly: AssemblyTitle("mikhailkillszombies.FateAiming")]
[assembly: AssemblyVersion("0.5.6.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 MikhailKillsZombies.FateAiming
{
[BepInPlugin("mikhailkillszombies.fate.aiming", "FATE Aiming", "0.5.6")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public sealed class AimingPlugin : BaseUnityPlugin
{
private sealed class Driver : MonoBehaviour
{
private void Update()
{
active?.Tick();
}
private void LateUpdate()
{
active?.LateTick();
}
private void OnGUI()
{
active?.Draw();
}
private void OnApplicationFocus(bool focused)
{
active?.Focus(focused);
}
}
public const string Guid = "mikhailkillszombies.fate.aiming";
private const float MaxRange = 100f;
private const int RingSteps = 100;
private static AimingPlugin active;
private Harmony harmony;
private InputAction toggle;
private InputAction attack;
private InputAction interact;
private object provider;
private ConfigEntry<bool> modEnabled;
private ConfigEntry<bool> hold;
private ConfigEntry<bool> separate;
private ConfigEntry<bool> clickToWalk;
private ConfigEntry<bool> invertVertical;
private ConfigEntry<bool> bindingMigrated;
private ConfigEntry<bool> debug;
private ConfigEntry<string> binding;
private ConfigEntry<string> attackBinding;
private ConfigEntry<string> interactBinding;
private ConfigEntry<float> yawSpeed;
private ConfigEntry<float> verticalSpeed;
private ConfigEntry<float> reticleSize;
private ConfigEntry<float> reticleRotation;
private ConfigEntry<float> reticleOpacity;
private ConfigEntry<float> ringOpacity;
private ConfigEntry<float> ringThickness;
private ConfigEntry<float> ringScale;
private ConfigEntry<float> crosshairRed;
private ConfigEntry<float> crosshairGreen;
private ConfigEntry<float> crosshairBlue;
private ConfigEntry<float> ringRed;
private ConfigEntry<float> ringGreen;
private ConfigEntry<float> ringBlue;
private ConfigEntry<bool> ringThicknessMigrated;
private bool armed;
private bool applied;
private bool restoring;
private float yaw;
private float aimUp;
private float lastX;
private float lastY;
private float lastDx;
private float lastDy;
private int settle;
private CursorLockMode lastLock;
private float nextReport;
private int camHits;
private int clickHits;
private int locHits;
private int moveGates;
private float reticleX;
private float reticleY = float.NaN;
private InteractableSceneObject hover;
private bool selfAttack;
private bool clickMove;
private float releasePin;
private static bool controllerSeen;
private static Texture2D pixel;
private static Texture2D ringTexture;
private static int ringTextureThickness;
private Driver driver;
private static readonly FieldInfo DamageableField = AccessTools.Field(typeof(InputBroker), "damageableTarget");
private static readonly FieldInfo CharacterTargetField = AccessTools.Field(typeof(InputBroker), "characterTarget");
private static readonly FieldInfo HoveredField = AccessTools.Field(typeof(InputBroker), "hoveredInteractable");
private static readonly MethodInfo LookDestination = AccessTools.Method(typeof(InputBroker), "SetLookDestination", (Type[])null, (Type[])null);
private static readonly FieldRef<InputBroker, LayerMask> NavigationLayers = AccessTools.FieldRefAccess<InputBroker, LayerMask>("NavigationLayers");
private static readonly FieldRef<ProdigyCamera, Quaternion> OriginalRotation = AccessTools.FieldRefAccess<ProdigyCamera, Quaternion>("originalRotation");
private static readonly FieldRef<ProdigyCamera, float> OriginalYaw = AccessTools.FieldRefAccess<ProdigyCamera, float>("originalYRotation");
private static readonly FieldRef<MiniMapIconUI, Quaternion> SavedRotation = AccessTools.FieldRefAccess<MiniMapIconUI, Quaternion>("savedRotation");
private static readonly MethodInfo MoveDestination = AccessTools.Method(typeof(InputBroker), "SetMoveDestination", new Type[1] { typeof(Vector3) }, (Type[])null);
private static Type turnType;
private static FieldInfo turnActive;
private static FieldInfo turnYaw;
private static Type cursorType;
private static PropertyInfo cursorInstance;
private static PropertyInfo cursorVirtual;
private static PropertyInfo cursorCurrent;
private static object cursorManagerInstance;
private static MethodInfo cursorVisible;
private static MethodInfo cursorUpdateState;
private static Type rebindType;
private static PropertyInfo rebindBlocked;
private static float nextRebindProbe;
private static bool rebindBlockedNow;
private float nextRebindRegister;
private object menuModule;
private float nextMenuRegister;
private static Type modMenuType;
private static PropertyInfo modMenuBlocked;
private static float nextModMenuProbe;
private static bool modMenuBlockedNow;
private static readonly Dictionary<string, Type> foundTypes = new Dictionary<string, Type>(StringComparer.Ordinal);
private void Awake()
{
//IL_010b: Unknown result type (might be due to invalid IL or missing references)
//IL_0115: Expected O, but got Unknown
//IL_0149: Unknown result type (might be due to invalid IL or missing references)
//IL_0153: Expected O, but got Unknown
//IL_0187: Unknown result type (might be due to invalid IL or missing references)
//IL_0191: Expected O, but got Unknown
//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
//IL_01cf: Expected O, but got Unknown
//IL_0203: Unknown result type (might be due to invalid IL or missing references)
//IL_020d: Expected O, but got Unknown
//IL_0241: Unknown result type (might be due to invalid IL or missing references)
//IL_024b: Expected O, but got Unknown
//IL_0417: Unknown result type (might be due to invalid IL or missing references)
//IL_0421: Expected O, but got Unknown
//IL_0509: Unknown result type (might be due to invalid IL or missing references)
//IL_0513: Expected O, but got Unknown
//IL_0585: Unknown result type (might be due to invalid IL or missing references)
//IL_058f: Expected O, but got Unknown
//IL_0540: Unknown result type (might be due to invalid IL or missing references)
//IL_054a: Expected O, but got Unknown
//IL_055f: Unknown result type (might be due to invalid IL or missing references)
//IL_0569: Expected O, but got Unknown
modEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Aiming", "Enabled", true, "Enable target aiming mode. Requires FATE WASD and FATE Camera Turn.");
if (!modEnabled.Value)
{
return;
}
active = this;
hold = ((BaseUnityPlugin)this).Config.Bind<bool>("Aiming", "HoldToAim", false, "Checked: hold the key to aim. Unchecked: the key toggles aiming on and off.");
binding = ((BaseUnityPlugin)this).Config.Bind<string>("Aiming", "Binding", "<Mouse>/middleButton", "Aim key when FATE Rebind is not installed. FATE Rebind exposes it as 'Toggle aiming mode'.");
bindingMigrated = ((BaseUnityPlugin)this).Config.Bind<bool>("Internal", "BindingMigrated", false, "Internal marker. Leave checked: it records that the default aim key was moved to the middle mouse button.");
if (!bindingMigrated.Value)
{
if (binding.Value == "<Keyboard>/leftAlt")
{
binding.Value = "<Mouse>/middleButton";
}
bindingMigrated.Value = true;
}
yawSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Aiming", "MouseSensitivity", 0.25f, new ConfigDescription("Camera degrees per pixel of horizontal mouse movement.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.02f, 3f), Array.Empty<object>()));
verticalSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Aiming", "VerticalSensitivity", 0.6f, new ConfigDescription("Reticle pixels per pixel of vertical mouse movement.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 3f), Array.Empty<object>()));
reticleSize = ((BaseUnityPlugin)this).Config.Bind<float>("Aiming", "ReticleSize", 1f, new ConfigDescription("Reticle scale.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 3f), Array.Empty<object>()));
reticleRotation = ((BaseUnityPlugin)this).Config.Bind<float>("Reticle", "Rotation", 0f, new ConfigDescription("Crosshair rotation in degrees.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-180f, 180f), Array.Empty<object>()));
reticleOpacity = ((BaseUnityPlugin)this).Config.Bind<float>("Reticle", "Opacity", 1f, new ConfigDescription("Crosshair opacity.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.05f, 1f), Array.Empty<object>()));
ringOpacity = ((BaseUnityPlugin)this).Config.Bind<float>("Reticle", "RingOpacity", 0.6f, new ConfigDescription("Outer ring opacity. Set to 0 to hide the ring.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
ringThickness = ((BaseUnityPlugin)this).Config.Bind<float>("Reticle", "RingThickness", 0.1f, "Outer ring thickness as a share of the ring radius, 0.01 to 1. 1 fills the circle completely.");
ringThicknessMigrated = ((BaseUnityPlugin)this).Config.Bind<bool>("Internal", "RingThicknessMigrated", false, "Internal marker. Leave checked: it records that RingThickness was converted from pixels to a share of the radius.");
if (!ringThicknessMigrated.Value)
{
if (ringThickness.Value > 1f)
{
ringThickness.Value = Mathf.Clamp(ringThickness.Value / 20f, 0.01f, 1f);
}
ringThicknessMigrated.Value = true;
}
crosshairRed = ((BaseUnityPlugin)this).Config.Bind<float>("Reticle", "CrosshairRed", 1f, Amount("Red amount of the crosshair, 0 to 1."));
crosshairGreen = ((BaseUnityPlugin)this).Config.Bind<float>("Reticle", "CrosshairGreen", 0.86f, Amount("Green amount of the crosshair, 0 to 1."));
crosshairBlue = ((BaseUnityPlugin)this).Config.Bind<float>("Reticle", "CrosshairBlue", 0.55f, Amount("Blue amount of the crosshair, 0 to 1."));
ringRed = ((BaseUnityPlugin)this).Config.Bind<float>("Reticle", "RingRed", 1f, Amount("Red amount of the circle, 0 to 1."));
ringGreen = ((BaseUnityPlugin)this).Config.Bind<float>("Reticle", "RingGreen", 0.86f, Amount("Green amount of the circle, 0 to 1."));
ringBlue = ((BaseUnityPlugin)this).Config.Bind<float>("Reticle", "RingBlue", 0.55f, Amount("Blue amount of the circle, 0 to 1."));
ringScale = ((BaseUnityPlugin)this).Config.Bind<float>("Reticle", "RingScale", 1.6f, new ConfigDescription("Outer ring size relative to the crosshair.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 4f), Array.Empty<object>()));
invertVertical = ((BaseUnityPlugin)this).Config.Bind<bool>("Aiming", "InvertVertical", false, "Checked: moving the mouse up lowers the reticle (inverted aim). Unchecked: moving the mouse up raises it.");
separate = ((BaseUnityPlugin)this).Config.Bind<bool>("Aiming", "SeparateActionButtons", false, "Checked: Attack and Interact use their own buttons. Unchecked: the game's single context-sensitive click does both.");
attackBinding = ((BaseUnityPlugin)this).Config.Bind<string>("Aiming", "AttackBinding", "<Mouse>/leftButton", "Attack button used when actions are separated. FATE Rebind overrides it when installed.");
interactBinding = ((BaseUnityPlugin)this).Config.Bind<string>("Aiming", "InteractBinding", "<Keyboard>/e", "Interact button used when actions are separated. FATE Rebind overrides it when installed.");
clickToWalk = ((BaseUnityPlugin)this).Config.Bind<bool>("Controls", "ClickToWalk", false, "Checked: the mouse may walk the player, as in the unmodded game. Unchecked: clicks still select, attack and interact, but never move the player. The walk a click asks for is dropped before it reaches the player, so clicking the hotbar, the spell wheel or any menu leaves movement alone.");
debug = ((BaseUnityPlugin)this).Config.Bind<bool>("Aiming", "Diagnostics", true, "Log aiming state to the BepInEx log every couple of seconds and on every aim-key press. Turn off once aiming works.");
toggle = new InputAction("aim.toggle", (InputActionType)1, binding.Value, (string)null, (string)null, (string)null);
toggle.Enable();
if (separate.Value)
{
attack = new InputAction("aim.attack", (InputActionType)1, attackBinding.Value, (string)null, (string)null, (string)null);
interact = new InputAction("aim.interact", (InputActionType)1, interactBinding.Value, (string)null, (string)null, (string)null);
attack.Enable();
interact.Enable();
}
harmony = new Harmony("mikhailkillszombies.fate.aiming");
EnsureDriver();
Patch(AccessTools.Method(typeof(ProdigyCamera), "UpdateCameraRotation", (Type[])null, (Type[])null), "Camera", null, 600);
Patch(AccessTools.Method(typeof(MiniMapIconUI), "LateUpdate", (Type[])null, (Type[])null), null, "Minimap", 200);
Patch(AccessTools.Method(typeof(InputBroker), "GetMouseLocation", (Type[])null, (Type[])null), null, "Location");
Patch(AccessTools.Method(typeof(InputBroker), "ParseClickToMove", (Type[])null, (Type[])null), "BeforeClickMove", "AfterClickMove", 200);
Patch(MoveDestination, "GateMoveDestination", null, 600);
Patch(AccessTools.Method(typeof(CursorManager), "SetCursorVisible", (Type[])null, (Type[])null), "CursorRequest");
Patch(AccessTools.Method(typeof(CursorManager), "InputTick", (Type[])null, (Type[])null), "SkipCursorTick");
if (separate.Value)
{
Patch(AccessTools.Method(typeof(InputBroker), "UpdateClickToMoveTargets", (Type[])null, (Type[])null), null, "Targets");
Patch(AccessTools.Method(typeof(Player), "StartAttack", Type.EmptyTypes, (Type[])null), "GateAttack");
}
EnsureRebind();
EnsureModMenu();
SceneManager.sceneLoaded += OnSceneLoaded;
((BaseUnityPlugin)this).Logger.LogInfo((object)("FATE Aiming 0.5.6 ready; WASD and Camera Turn required and present." + (ControllerConnected() ? " A controller is connected, so aiming stays off until it is unplugged." : "")));
}
private void Patch(MethodInfo target, string prefix = null, string postfix = null, int priority = 400)
{
//IL_0031: 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_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
if (target == null)
{
((BaseUnityPlugin)this).Logger.LogWarning((object)"A game method FATE Aiming uses is missing; one feature is off.");
return;
}
try
{
harmony.Patch((MethodBase)target, (prefix == null) ? ((HarmonyMethod)null) : new HarmonyMethod(typeof(AimingPlugin), prefix, (Type[])null)
{
priority = priority
}, (postfix == null) ? ((HarmonyMethod)null) : new HarmonyMethod(typeof(AimingPlugin), postfix, (Type[])null)
{
priority = priority
}, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
}
catch (Exception ex)
{
((BaseUnityPlugin)this).Logger.LogWarning((object)("Could not patch " + target.DeclaringType.Name + "." + target.Name + ": " + ex.Message));
}
}
private void EnsureDriver()
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Expected O, but got Unknown
if (!((Object)(object)driver != (Object)null))
{
GameObject val = new GameObject("FATE.AimDriver");
Object.DontDestroyOnLoad((Object)(object)val);
driver = val.AddComponent<Driver>();
((BaseUnityPlugin)this).Logger.LogInfo((object)"Aiming driver attached; per-frame update running.");
}
}
private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
if (applied)
{
Stop();
}
armed = false;
EnsureDriver();
}
private void EnsureRebind()
{
if (provider == null && !(Time.unscaledTime < nextRebindRegister))
{
nextRebindRegister = Time.unscaledTime + 2f;
RegisterRebind();
}
}
private void RegisterRebind()
{
Type type = FindType("ZombieGhost.Rebind.RebindApi");
if (type == null)
{
return;
}
try
{
MethodInfo method = type.GetMethod("RegisterProvider", new Type[2]
{
typeof(string),
typeof(string)
});
if (!(method == null))
{
provider = method.Invoke(null, new object[2] { "mikhailkillszombies.fate.aiming", "FATE Aiming" });
MethodInfo method2 = provider.GetType().GetMethod("RegisterAction");
method2?.Invoke(provider, new object[5] { "aim.toggle", toggle, "Toggle aiming mode", "Aiming", null });
if (separate.Value)
{
method2?.Invoke(provider, new object[5] { "aim.attack", attack, "Attack (aiming)", "Combat", null });
method2?.Invoke(provider, new object[5] { "aim.interact", interact, "Interact (aiming)", "Combat", null });
}
((BaseUnityPlugin)this).Logger.LogInfo((object)"FATE Aiming registered its aim key with FATE Rebind.");
}
}
catch (Exception ex)
{
((BaseUnityPlugin)this).Logger.LogWarning((object)("FATE Rebind registration skipped: " + ex.Message));
provider = null;
nextRebindRegister = Time.unscaledTime + 30f;
}
}
private void EnsureModMenu()
{
if (menuModule == null && !(Time.unscaledTime < nextMenuRegister))
{
nextMenuRegister = Time.unscaledTime + 2f;
RegisterModMenu();
}
}
private void RegisterModMenu()
{
Type type = FindType("ZombieGhost.ModMenu.ModMenuApi");
if (type == null)
{
return;
}
try
{
MethodInfo method = type.GetMethod("RegisterModule", new Type[2]
{
typeof(string),
typeof(string)
});
if (method == null)
{
return;
}
menuModule = method.Invoke(null, new object[2] { "mikhailkillszombies.fate.aiming", "FATE Aiming" });
Type type2 = menuModule.GetType();
MethodInfo method2 = type2.GetMethod("RegisterToggle");
if (method2 != null)
{
method2.Invoke(menuModule, new object[5]
{
"aim.invert-vertical",
"Invert up/down aim",
(Func<bool>)(() => invertVertical.Value),
(Action<bool>)delegate(bool value)
{
invertVertical.Value = value;
},
"Aim"
});
method2.Invoke(menuModule, new object[5]
{
"aim.hold",
"Hold the key to aim",
(Func<bool>)(() => hold.Value),
(Action<bool>)delegate(bool value)
{
hold.Value = value;
},
"Aim"
});
}
MethodInfo addSlider = type2.GetMethod("RegisterSlider");
if (addSlider == null)
{
((BaseUnityPlugin)this).Logger.LogWarning((object)"Installed FATE Mod Menu has no RegisterSlider: update it to show the reticle sliders.");
}
else
{
Action<string, string, Func<float>, Action<float>, float, float, float, string> obj = delegate(string id, string label, Func<float> get, Action<float> set, float min, float max, float step, string category)
{
try
{
addSlider.Invoke(menuModule, new object[9] { id, label, get, set, min, max, step, category, null });
}
catch (Exception ex2)
{
((BaseUnityPlugin)this).Logger.LogWarning((object)("FATE Mod Menu could not add the " + id + " slider: " + ex2.Message));
}
};
obj("reticle.rotation", "Rotation", () => reticleRotation.Value, delegate(float value)
{
reticleRotation.Value = value;
}, -180f, 180f, 1f, "Crosshair");
obj("reticle.scale", "Crosshair scale", () => reticleSize.Value, delegate(float value)
{
reticleSize.Value = value;
}, 0.5f, 3f, 0.05f, "Crosshair");
obj("reticle.opacity", "Crosshair opacity", () => reticleOpacity.Value, delegate(float value)
{
reticleOpacity.Value = value;
}, 0.05f, 1f, 0.01f, "Crosshair");
obj("ring.opacity", "Circle opacity", () => ringOpacity.Value, delegate(float value)
{
ringOpacity.Value = value;
}, 0f, 1f, 0.01f, "Circle");
obj("ring.thickness", "Circle thickness", () => ringThickness.Value, delegate(float value)
{
ringThickness.Value = value;
}, 0.01f, 1f, 0.01f, "Circle");
obj("ring.scale", "Circle size", () => ringScale.Value, delegate(float value)
{
ringScale.Value = value;
}, 1f, 4f, 0.05f, "Circle");
}
MethodInfo method3 = type2.GetMethod("RegisterColor");
if (method3 == null)
{
((BaseUnityPlugin)this).Logger.LogWarning((object)"Installed FATE Mod Menu has no RegisterColor: update it to show the reticle colours.");
}
else
{
method3.Invoke(menuModule, new object[5]
{
"reticle.crosshair-colour",
"Crosshair colour",
new Func<Color>(CrosshairColour),
new Action<Color>(SetCrosshairColour),
"Crosshair"
});
method3.Invoke(menuModule, new object[5]
{
"ring.colour",
"Circle colour",
new Func<Color>(RingColour),
new Action<Color>(SetRingColour),
"Circle"
});
}
MethodInfo method4 = type2.GetMethod("RegisterPreview");
if (method4 != null)
{
method4.Invoke(menuModule, new object[5]
{
"reticle.preview",
"What it looks like",
new Func<Texture2D>(PreviewTexture),
"Crosshair",
170f
});
}
((BaseUnityPlugin)this).Logger.LogInfo((object)"FATE Aiming registered its reticle settings with FATE Mod Menu.");
}
catch (Exception ex)
{
((BaseUnityPlugin)this).Logger.LogWarning((object)("FATE Mod Menu registration skipped: " + ex.Message));
menuModule = null;
nextMenuRegister = Time.unscaledTime + 30f;
}
}
private static ConfigDescription Amount(string description)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
return new ConfigDescription(description, (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>());
}
private static Color Colour(ConfigEntry<float> red, ConfigEntry<float> green, ConfigEntry<float> blue)
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
return new Color(Mathf.Clamp01(red.Value), Mathf.Clamp01(green.Value), Mathf.Clamp01(blue.Value), 1f);
}
private static Color CrosshairColour()
{
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
AimingPlugin aimingPlugin = active;
if (aimingPlugin == null)
{
return Color.white;
}
return Colour(aimingPlugin.crosshairRed, aimingPlugin.crosshairGreen, aimingPlugin.crosshairBlue);
}
private static Color RingColour()
{
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
AimingPlugin aimingPlugin = active;
if (aimingPlugin == null)
{
return Color.white;
}
return Colour(aimingPlugin.ringRed, aimingPlugin.ringGreen, aimingPlugin.ringBlue);
}
private static void SetCrosshairColour(Color value)
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
AimingPlugin aimingPlugin = active;
if (aimingPlugin != null)
{
aimingPlugin.crosshairRed.Value = value.r;
aimingPlugin.crosshairGreen.Value = value.g;
aimingPlugin.crosshairBlue.Value = value.b;
}
}
private static void SetRingColour(Color value)
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
AimingPlugin aimingPlugin = active;
if (aimingPlugin != null)
{
aimingPlugin.ringRed.Value = value.r;
aimingPlugin.ringGreen.Value = value.g;
aimingPlugin.ringBlue.Value = value.b;
}
}
private static Texture2D PreviewTexture()
{
//IL_019b: 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)
AimingPlugin aimingPlugin = active;
if (aimingPlugin == null)
{
return null;
}
return ReticlePreview.Render(aimingPlugin.crosshairRed.Value + "/" + aimingPlugin.crosshairGreen.Value + "/" + aimingPlugin.crosshairBlue.Value + "|" + aimingPlugin.reticleOpacity.Value + "|" + aimingPlugin.reticleSize.Value + "|" + aimingPlugin.reticleRotation.Value + "|" + aimingPlugin.ringRed.Value + "/" + aimingPlugin.ringGreen.Value + "/" + aimingPlugin.ringBlue.Value + "|" + aimingPlugin.ringOpacity.Value + "|" + aimingPlugin.ringThickness.Value + "|" + aimingPlugin.ringScale.Value, aimingPlugin.reticleRotation.Value, aimingPlugin.reticleSize.Value, CrosshairColour(), aimingPlugin.reticleOpacity.Value, aimingPlugin.ringScale.Value, RingColour(), aimingPlugin.ringOpacity.Value, aimingPlugin.ringThickness.Value);
}
private void Tick()
{
if (!modEnabled.Value)
{
if (applied)
{
Stop();
}
return;
}
EnsureRebind();
EnsureModMenu();
bool flag = ControllerConnected();
NoticeController(flag);
if (flag)
{
armed = false;
}
bool flag2 = Blocked();
if (!flag2 && !toggle.enabled)
{
toggle.Enable();
}
bool flag3 = !flag2 && toggle.WasPressedThisFrame();
if (debug.Value)
{
Report(flag3, flag2);
}
if (!hold.Value && flag3)
{
armed = !armed;
}
bool flag4 = Application.isFocused && !flag2 && (hold.Value ? toggle.IsPressed() : armed);
if (flag4 && !applied)
{
Start();
((BaseUnityPlugin)this).Logger.LogInfo((object)"Aiming on.");
}
else if (!flag4 && applied)
{
Stop();
((BaseUnityPlugin)this).Logger.LogInfo((object)"Aiming off.");
}
if (applied)
{
if (separate.Value)
{
ActionPresses();
}
HideGameCursor();
}
}
private static bool Blocked()
{
return BlockReason() != "none";
}
private static bool ControllerConnected()
{
Gamepad current = Gamepad.current;
if (current != null && ((InputDevice)current).added)
{
return true;
}
Joystick current2 = Joystick.current;
if (current2 != null)
{
return ((InputDevice)current2).added;
}
return false;
}
private void NoticeController(bool connected)
{
if (connected != controllerSeen)
{
controllerSeen = connected;
if (connected)
{
((BaseUnityPlugin)this).Logger.LogInfo((object)"A controller is connected: FATE Aiming is off until it is disconnected.");
}
else
{
((BaseUnityPlugin)this).Logger.LogInfo((object)"Controller disconnected: FATE Aiming is available again.");
}
}
}
private static string BlockReason()
{
if (RebindBlocking())
{
return "rebind";
}
if (ModMenuBlocking())
{
return "modmenu";
}
if (InputBlocker.AnyBlockingUiMenuIsOpen)
{
return "menu";
}
if (ControllerConnected())
{
return "controller";
}
if (InventoryUI.IsDraggingItem)
{
return "dragging";
}
Player playerChar = Player.PlayerChar;
if ((Object)(object)playerChar != (Object)null && (Object)(object)((Character)playerChar).MyVitals != (Object)null && ((Character)playerChar).MyVitals.IsDead)
{
return "dead";
}
InputBroker instance = SingletonBehaviour<InputBroker>.Instance;
if ((Object)(object)instance != (Object)null && instance.HoldingSpellWheel)
{
return "spellwheel";
}
return "none";
}
private static Type FindType(string name)
{
if (foundTypes.TryGetValue(name, out var value))
{
return value;
}
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
foreach (Assembly assembly in assemblies)
{
try
{
value = assembly.GetType(name, throwOnError: false);
}
catch
{
value = null;
}
if (!(value == null))
{
foundTypes[name] = value;
return value;
}
}
return null;
}
private static bool ModMenuBlocking()
{
if (modMenuBlocked == null)
{
if (Time.unscaledTime < nextModMenuProbe)
{
return false;
}
nextModMenuProbe = Time.unscaledTime + 2f;
modMenuType = modMenuType ?? FindType("ZombieGhost.ModMenu.ModMenuApi");
modMenuBlocked = modMenuType?.GetProperty("IsInputBlocked", BindingFlags.Static | BindingFlags.Public);
if (modMenuBlocked == null)
{
return false;
}
}
try
{
modMenuBlockedNow = (bool)modMenuBlocked.GetValue(null);
}
catch
{
modMenuBlockedNow = false;
}
return modMenuBlockedNow;
}
private static bool RebindBlocking()
{
if (rebindBlocked == null)
{
if (Time.unscaledTime < nextRebindProbe)
{
return false;
}
nextRebindProbe = Time.unscaledTime + 2f;
rebindType = rebindType ?? FindType("ZombieGhost.Rebind.RebindApi");
rebindBlocked = rebindType?.GetProperty("IsInputBlocked", BindingFlags.Static | BindingFlags.Public);
if (rebindBlocked == null)
{
return false;
}
}
try
{
rebindBlockedNow = (bool)rebindBlocked.GetValue(null);
}
catch
{
rebindBlockedNow = false;
}
return rebindBlockedNow;
}
private void Report(bool press, bool blocked)
{
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
//IL_02db: Unknown result type (might be due to invalid IL or missing references)
//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
//IL_0378: Unknown result type (might be due to invalid IL or missing references)
//IL_037d: Unknown result type (might be due to invalid IL or missing references)
//IL_03a0: Unknown result type (might be due to invalid IL or missing references)
//IL_03a5: Unknown result type (might be due to invalid IL or missing references)
if (press)
{
((BaseUnityPlugin)this).Logger.LogInfo((object)("aim key pressed: blocked=" + blocked + " reason=" + BlockReason() + " armed=" + armed + " applied=" + applied));
}
if (!(Time.unscaledTime < nextReport))
{
nextReport = Time.unscaledTime + 2f;
_ = Keyboard.current;
Mouse current = Mouse.current;
InputBroker instance = SingletonBehaviour<InputBroker>.Instance;
object obj;
if (toggle.bindings.Count <= 0)
{
obj = "none";
}
else
{
InputBinding val = toggle.bindings[0];
obj = ((InputBinding)(ref val)).effectivePath;
}
string text = (string)obj;
string text2 = ((toggle.activeControl == null) ? "none" : toggle.activeControl.displayName);
Type type = cursorType ?? FindType("Tableflip.CursorManager");
object obj2 = ((type == null) ? null : ManagerInstance(type));
object obj3 = ((obj2 == null) ? null : CurrentCursor(obj2));
((BaseUnityPlugin)this).Logger.LogInfo((object)("aim state: applied=" + applied + " armed=" + armed + " hold=" + hold.Value + " toggleEnabled=" + toggle.enabled + " bound=" + text + " active=" + text2 + " focus=" + Application.isFocused + " blocked=" + blocked + " reason=" + BlockReason() + " rebindBlocked=" + rebindBlockedNow + " modMenuBlocked=" + modMenuBlockedNow + " clickToWalk=" + clickToWalk.Value + " invertVertical=" + invertVertical.Value + " moveGates=" + moveGates + " controller=" + ControllerConnected() + " mode=" + (((Object)(object)instance == (Object)null) ? "no-broker" : (((object)instance.ActiveInputMode/*cast due to .constrained prefix*/).ToString() + "/" + ((object)instance.LocalInputBehavior/*cast due to .constrained prefix*/).ToString())) + " cursorMode=" + ((obj3 == null) ? "none" : obj3.ToString()) + " cam=" + camHits + " click=" + clickHits + " loc=" + locHits + " cursor=" + ((current == null) ? "no-mouse" : ((object)((InputControl<Vector2>)(object)((Pointer)current).position).ReadValue()/*cast due to .constrained prefix*/).ToString()) + " lock=" + ((object)Cursor.lockState/*cast due to .constrained prefix*/).ToString() + " yaw=" + yaw.ToString("0.0") + " aimUp=" + aimUp.ToString("0.0") + " dx=" + lastDx.ToString("0.0") + " dy=" + lastDy.ToString("0.0") + " screen=" + Screen.width + "x" + Screen.height + " turnYaw=" + ReadTurnYaw().ToString("0.0")));
}
}
private void Start()
{
//IL_0082: 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_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
applied = true;
aimUp = 0f;
reticleX = (float)Screen.width * 0.5f;
reticleY = (float)Screen.height * 0.5f;
yaw = ReadTurnYaw();
Mouse current = Mouse.current;
if (current != null)
{
Vector2 val = MouseWarpPoint();
current.WarpCursorPosition(val);
lastX = val.x;
lastY = val.y;
}
EnterHiddenCursorState();
HideGameCursor();
settle = 3;
lastLock = Cursor.lockState;
}
private void Stop()
{
if (applied)
{
applied = false;
RestoreGameCursor();
}
}
private void ReleaseForUi()
{
if (applied)
{
applied = false;
RestoreGameCursor();
((BaseUnityPlugin)this).Logger.LogInfo((object)"Aiming suspended for a menu; cursor returned.");
}
}
private void Focus(bool focused)
{
if (!focused)
{
if (applied)
{
Stop();
((BaseUnityPlugin)this).Logger.LogInfo((object)"Aiming cancelled: window lost focus.");
}
armed = false;
Cursor.visible = true;
}
}
private void Track(Mouse mouse)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//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)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Invalid comparison between Unknown and I4
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: 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_00ad: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: 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_01b2: Invalid comparison between Unknown and I4
//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
Vector2 val = ((InputControl<Vector2>)(object)((Pointer)mouse).position).ReadValue();
if (Cursor.lockState != lastLock)
{
lastLock = Cursor.lockState;
settle = 3;
}
if (settle > 0)
{
settle--;
Vector2 val2 = MouseWarpPoint();
mouse.WarpCursorPosition(val2);
lastX = val2.x;
lastY = val2.y;
lastDx = 0f;
lastDy = 0f;
return;
}
float num = val.x - lastX;
float num2 = val.y - lastY;
if ((int)Cursor.lockState == 1)
{
Vector2 val3 = ((InputControl<Vector2>)(object)((Pointer)mouse).delta).ReadValue();
num = val3.x;
num2 = val3.y;
}
if (Mathf.Abs(num) > (float)Screen.width * 0.5f || Mathf.Abs(num2) > (float)Screen.height * 0.5f)
{
num = 0f;
num2 = 0f;
}
lastDx = num;
lastDy = num2;
yaw = Mathf.Repeat(yaw + num * yawSpeed.Value + 180f, 360f) - 180f;
float num3 = (float)Screen.height * 0.46f;
float num4 = num2 * (invertVertical.Value ? (-1f) : 1f);
aimUp = Mathf.Clamp(aimUp + num4 * verticalSpeed.Value, 0f, num3);
reticleX = (float)Screen.width * 0.5f;
reticleY = (float)Screen.height * 0.5f + aimUp;
if ((int)Cursor.lockState != 1)
{
Vector2 val4 = MouseWarpPoint();
mouse.WarpCursorPosition(val4);
lastX = val4.x;
lastY = val4.y;
}
}
private Vector2 MouseWarpPoint()
{
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
float num = Mathf.Clamp(Mathf.Round(reticleX), 0f, (float)Mathf.Max(0, Screen.width - 1));
float num2 = Mathf.Clamp(Mathf.Round(reticleY), 0f, (float)Mathf.Max(0, Screen.height - 1));
return new Vector2(num, num2);
}
private void ActionPresses()
{
InputBroker instance = SingletonBehaviour<InputBroker>.Instance;
if (!((Object)(object)instance == (Object)null))
{
if (interact != null && interact.WasPressedThisFrame())
{
InteractWith(instance);
}
if (attack != null && attack.WasPressedThisFrame())
{
AttackTarget(instance);
}
}
}
private void InteractWith(InputBroker broker)
{
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
InteractableSceneObject val = hover;
Player playerChar = Player.PlayerChar;
if (!((Object)(object)val == (Object)null) && !((Object)(object)playerChar == (Object)null) && val.CanInteract && !(Vector3.Distance(((Component)playerChar).transform.position, val.GetCenterPosition()) >= val.InteractRange))
{
val.Interact((Character)(object)playerChar);
}
}
private void AttackTarget(InputBroker broker)
{
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
object? obj = DamageableField?.GetValue(broker);
Component val = (Component)((obj is Component) ? obj : null);
Player playerChar = Player.PlayerChar;
if ((Object)(object)val == (Object)null || (Object)(object)playerChar == (Object)null || !playerChar.InAttackRange(val.gameObject))
{
return;
}
object? obj2 = CharacterTargetField?.GetValue(broker);
Character val2 = (Character)((obj2 is Character) ? obj2 : null);
if ((Object)(object)val2 != (Object)null)
{
((Character)playerChar).SetTarget(val2, true, true);
}
LookDestination?.Invoke(broker, new object[1] { val.transform.position });
selfAttack = true;
try
{
((Character)playerChar).SelectAttack();
playerChar.StartAttack();
}
finally
{
selfAttack = false;
}
}
private static void Targets(InputBroker __instance)
{
AimingPlugin aimingPlugin = active;
if (aimingPlugin != null && aimingPlugin.applied && aimingPlugin.separate.Value)
{
ref InteractableSceneObject reference = ref aimingPlugin.hover;
object? obj = HoveredField?.GetValue(__instance);
reference = (InteractableSceneObject)((obj is InteractableSceneObject) ? obj : null);
Mouse current = Mouse.current;
if ((Object)(object)aimingPlugin.hover != (Object)null && current != null && current.leftButton.wasPressedThisFrame)
{
HoveredField.SetValue(__instance, null);
}
}
}
private static bool GateAttack()
{
AimingPlugin aimingPlugin = active;
if (aimingPlugin == null || !aimingPlugin.applied || !aimingPlugin.separate.Value)
{
return true;
}
return aimingPlugin.selfAttack;
}
private static bool Camera(ProdigyCamera __instance)
{
AimingPlugin aimingPlugin = active;
if (aimingPlugin == null)
{
return true;
}
aimingPlugin.camHits++;
if (!aimingPlugin.applied || !Application.isFocused)
{
return true;
}
Mouse current = Mouse.current;
if (current == null)
{
return true;
}
aimingPlugin.Track(current);
WriteTurnYaw(aimingPlugin.yaw);
return true;
}
private static void CursorRequest(ref bool __0)
{
AimingPlugin aimingPlugin = active;
if (aimingPlugin != null && aimingPlugin.applied && !aimingPlugin.restoring)
{
if (__0)
{
aimingPlugin.ReleaseForUi();
}
else
{
HideGameCursor();
}
}
}
private static bool SkipCursorTick()
{
AimingPlugin aimingPlugin = active;
if (aimingPlugin != null)
{
return !aimingPlugin.applied;
}
return true;
}
private void LateTick()
{
if (applied)
{
HideGameCursor();
}
else if (!(releasePin <= 0f))
{
releasePin -= Time.unscaledDeltaTime;
PinCursorRect();
}
}
private static void PinCursorRect()
{
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
Mouse current = Mouse.current;
Type type = cursorType ?? FindType("Tableflip.CursorManager");
if (current != null && !(type == null))
{
cursorType = type;
object obj = ManagerInstance(type);
if (obj != null)
{
PlaceCursorRect(obj, ((InputControl<Vector2>)(object)((Pointer)current).position).ReadValue());
}
}
}
private static void Minimap(MiniMapIconUI __instance)
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: 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_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_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
AimingPlugin aimingPlugin = active;
if (aimingPlugin != null && aimingPlugin.applied && !((Object)(object)ProdigyCamera.GameCamera == (Object)null))
{
Quaternion val = SavedRotation.Invoke(__instance);
if (__instance.isCamera)
{
((Component)__instance).transform.rotation = Quaternion.AngleAxis(aimingPlugin.yaw, Vector3.up) * val;
return;
}
Vector3 val2 = val * Vector3.up;
float num = Mathf.Atan2(val2.x, val2.z) * 57.29578f;
((Component)__instance).transform.rotation = Quaternion.AngleAxis(((Component)ProdigyCamera.GameCamera).transform.eulerAngles.y - num, Vector3.up) * val;
}
}
private static void Location(InputBroker __instance, ref Vector3 __result)
{
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
AimingPlugin aimingPlugin = active;
if (aimingPlugin == null)
{
return;
}
aimingPlugin.locHits++;
if (aimingPlugin.applied)
{
Camera gameCamera = ProdigyCamera.GameCamera;
if (!((Object)(object)gameCamera == (Object)null))
{
Ray val = gameCamera.ScreenPointToRay(new Vector3(aimingPlugin.reticleX, aimingPlugin.reticleY, 0f));
RaycastHit val2 = default(RaycastHit);
__result = (Physics.Raycast(val, ref val2, 100f, LayerMask.op_Implicit(NavigationLayers.Invoke(__instance))) ? ((RaycastHit)(ref val2)).point : ((Ray)(ref val)).GetPoint(100f));
}
}
}
private static void BeforeClickMove()
{
AimingPlugin aimingPlugin = active;
if (aimingPlugin != null)
{
aimingPlugin.clickHits++;
aimingPlugin.clickMove = true;
}
}
private static void AfterClickMove()
{
AimingPlugin aimingPlugin = active;
if (aimingPlugin != null)
{
aimingPlugin.clickMove = false;
}
}
private static bool GateMoveDestination()
{
AimingPlugin aimingPlugin = active;
if (aimingPlugin == null || aimingPlugin.clickToWalk.Value || !aimingPlugin.clickMove)
{
return true;
}
Mouse current = Mouse.current;
if (current == null || !current.leftButton.isPressed)
{
return true;
}
aimingPlugin.moveGates++;
return false;
}
private static float ReadTurnYaw()
{
try
{
turnType = turnType ?? FindType("PartGhost.FateControls.CameraTurnPlugin");
turnActive = turnActive ?? turnType?.GetField("active", BindingFlags.Static | BindingFlags.NonPublic);
turnYaw = turnYaw ?? turnType?.GetField("yaw", BindingFlags.Instance | BindingFlags.NonPublic);
object obj = turnActive?.GetValue(null);
if (obj != null && turnYaw != null)
{
return (float)turnYaw.GetValue(obj);
}
}
catch
{
}
return 0f;
}
private static void WriteTurnYaw(float value)
{
try
{
object obj = turnActive?.GetValue(null);
if (obj != null && turnYaw != null)
{
turnYaw.SetValue(obj, value);
}
}
catch
{
}
}
private static object ManagerInstance(Type type)
{
//IL_0028: 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)
//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)
object obj = cursorManagerInstance;
Component val = (Component)((obj is Component) ? obj : null);
Scene scene;
try
{
if ((Object)(object)val != (Object)null && (Object)(object)val.gameObject != (Object)null)
{
scene = val.gameObject.scene;
if (((Scene)(ref scene)).IsValid())
{
return val;
}
}
}
catch
{
}
cursorManagerInstance = null;
try
{
cursorInstance = cursorInstance ?? type.GetProperty("Instance", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
object obj3 = cursorInstance?.GetValue(null);
if (obj3 != null)
{
cursorManagerInstance = obj3;
return obj3;
}
}
catch
{
}
try
{
Component val2 = null;
Object[] array = Resources.FindObjectsOfTypeAll(type);
foreach (Object obj5 in array)
{
Component val3 = (Component)(object)((obj5 is Component) ? obj5 : null);
if ((Object)(object)val3 == (Object)null || (Object)(object)val3.gameObject == (Object)null)
{
continue;
}
scene = val3.gameObject.scene;
if (((Scene)(ref scene)).IsValid())
{
if (val3.gameObject.activeInHierarchy)
{
cursorManagerInstance = val3;
return val3;
}
val2 = val2 ?? val3;
}
}
if ((Object)(object)val2 != (Object)null)
{
cursorManagerInstance = val2;
return val2;
}
}
catch
{
}
return null;
}
private static object CurrentCursor(object manager)
{
try
{
cursorCurrent = cursorCurrent ?? manager.GetType().GetProperty("CurrentCursor", BindingFlags.Instance | BindingFlags.Public);
return cursorCurrent?.GetValue(manager);
}
catch
{
return null;
}
}
private static void EnterHiddenCursorState()
{
//IL_0100: Unknown result type (might be due to invalid IL or missing references)
//IL_0105: Unknown result type (might be due to invalid IL or missing references)
try
{
Type type = cursorType ?? FindType("Tableflip.CursorManager");
if (type != null)
{
cursorType = type;
object obj = ManagerInstance(type);
cursorUpdateState = cursorUpdateState ?? type.GetMethod("UpdateCursorState", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
if (obj != null && cursorUpdateState != null)
{
ParameterInfo parameterInfo = cursorUpdateState.GetParameters()[0];
object obj2 = (parameterInfo.ParameterType.IsEnum ? Enum.ToObject(parameterInfo.ParameterType, 2) : Convert.ChangeType(2, parameterInfo.ParameterType));
cursorUpdateState.Invoke(obj, new object[1] { obj2 });
}
if (active != null)
{
((BaseUnityPlugin)active).Logger.LogInfo((object)("Hidden cursor state: manager=" + (obj != null) + " updateState=" + (cursorUpdateState != null) + " lock=" + ((object)Cursor.lockState/*cast due to .constrained prefix*/).ToString()));
}
}
}
catch (Exception ex)
{
if (active != null)
{
((BaseUnityPlugin)active).Logger.LogWarning((object)("Could not enter the game's hidden cursor state: " + ex.Message));
}
}
Cursor.visible = false;
Cursor.lockState = (CursorLockMode)2;
}
private static void HideGameCursor()
{
Cursor.visible = false;
Cursor.lockState = (CursorLockMode)2;
Type type = cursorType ?? FindType("Tableflip.CursorManager");
if (type == null)
{
return;
}
cursorType = type;
object obj = ManagerInstance(type);
if (obj == null)
{
return;
}
try
{
cursorVirtual = cursorVirtual ?? type.GetProperty("VirtualCursor", BindingFlags.Instance | BindingFlags.Public);
object? obj2 = cursorVirtual?.GetValue(obj);
RectTransform val = (RectTransform)((obj2 is RectTransform) ? obj2 : null);
if ((Object)(object)val != (Object)null && ((Component)val).gameObject.activeSelf)
{
((Component)val).gameObject.SetActive(false);
}
}
catch
{
}
}
private void RestoreGameCursor()
{
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Invalid comparison between Unknown and I4
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: 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)
//IL_014b: Unknown result type (might be due to invalid IL or missing references)
//IL_01db: Unknown result type (might be due to invalid IL or missing references)
releasePin = 0.25f;
Vector2 val = default(Vector2);
((Vector2)(ref val))..ctor(Mathf.Clamp(reticleX, 1f, (float)Mathf.Max(1, Screen.width - 2)), Mathf.Clamp(reticleY, 1f, (float)Mathf.Max(1, Screen.height - 2)));
if ((int)Cursor.lockState == 1)
{
Cursor.lockState = (CursorLockMode)2;
Cursor.visible = false;
}
Mouse current = Mouse.current;
if (current != null)
{
current.WarpCursorPosition(val);
lastX = val.x;
lastY = val.y;
}
Type type = cursorType ?? FindType("Tableflip.CursorManager");
if (type == null)
{
Cursor.visible = false;
Cursor.lockState = (CursorLockMode)2;
return;
}
cursorType = type;
object obj = ManagerInstance(type);
if (obj == null)
{
return;
}
restoring = true;
try
{
cursorUpdateState = cursorUpdateState ?? type.GetMethod("UpdateCursorState", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
if (cursorUpdateState != null)
{
ParameterInfo parameterInfo = cursorUpdateState.GetParameters()[0];
object obj2 = (parameterInfo.ParameterType.IsEnum ? Enum.ToObject(parameterInfo.ParameterType, 1) : Convert.ChangeType(1, parameterInfo.ParameterType));
cursorUpdateState.Invoke(obj, new object[1] { obj2 });
PlaceCursorRect(obj, val);
}
else
{
cursorCurrent = cursorCurrent ?? type.GetProperty("CurrentCursor", BindingFlags.Instance | BindingFlags.Public);
cursorCurrent?.SetValue(obj, Enum.ToObject(cursorCurrent.PropertyType, 1));
cursorVisible = cursorVisible ?? type.GetMethod("SetCursorVisible", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
cursorVisible?.Invoke(obj, new object[1] { true });
Cursor.visible = false;
Cursor.lockState = (CursorLockMode)2;
PlaceCursorRect(obj, val);
}
}
catch (Exception ex)
{
((BaseUnityPlugin)this).Logger.LogWarning((object)("Cursor state restore failed, applying direct fallback: " + ex.Message));
ForceCursorVisible(type, obj);
}
finally
{
restoring = false;
}
}
private static void PlaceCursorRect(object instance, Vector2 point)
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Invalid comparison between Unknown and I4
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
try
{
InputBroker instance2 = SingletonBehaviour<InputBroker>.Instance;
if ((!((Object)(object)instance2 != (Object)null) || (int)instance2.LocalInputBehavior == 1) && !(cursorType == null))
{
cursorVirtual = cursorVirtual ?? cursorType.GetProperty("VirtualCursor", BindingFlags.Instance | BindingFlags.Public);
object? obj = cursorVirtual?.GetValue(instance);
RectTransform val = (RectTransform)((obj is RectTransform) ? obj : null);
if (!((Object)(object)val == (Object)null))
{
((Component)val).gameObject.SetActive(true);
((Transform)val).position = new Vector3(point.x, point.y, 0f);
}
}
}
catch
{
}
}
private static void ForceCursorVisible(Type type, object instance)
{
try
{
cursorVisible = cursorVisible ?? type.GetMethod("SetCursorVisible", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
cursorVisible?.Invoke(instance, new object[1] { true });
}
catch
{
}
try
{
cursorVirtual = cursorVirtual ?? type.GetProperty("VirtualCursor", BindingFlags.Instance | BindingFlags.Public);
object? obj2 = cursorVirtual?.GetValue(instance);
RectTransform val = (RectTransform)((obj2 is RectTransform) ? obj2 : null);
if ((Object)(object)val != (Object)null)
{
((Component)val).gameObject.SetActive(true);
}
}
catch
{
}
Cursor.visible = false;
Cursor.lockState = (CursorLockMode)2;
}
private void Draw()
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Invalid comparison between Unknown and I4
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Invalid comparison between Unknown and I4
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Expected O, but got Unknown
//IL_0057: 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)
//IL_0137: Unknown result type (might be due to invalid IL or missing references)
//IL_013c: 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_0145: Unknown result type (might be due to invalid IL or missing references)
//IL_014c: 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_00e1: Unknown result type (might be due to invalid IL or missing references)
if (!applied)
{
return;
}
if (Cursor.visible || (int)Cursor.lockState != 2)
{
Cursor.visible = false;
Cursor.lockState = (CursorLockMode)2;
}
Event current = Event.current;
if (current != null && (int)current.type == 7)
{
if ((Object)(object)pixel == (Object)null)
{
pixel = new Texture2D(1, 1);
pixel.SetPixel(0, 0, Color.white);
pixel.Apply();
}
float value = reticleSize.Value;
float num = 12f * value;
float gap = num * 0.4f;
float num2 = Mathf.Max(3f, Mathf.Round(num / 4f));
float num3 = reticleX;
float num4 = (float)Screen.height - reticleY;
Color color = GUI.color;
Matrix4x4 matrix = GUI.matrix;
float value2 = reticleRotation.Value;
if (Mathf.Abs(value2) > 0.01f)
{
GUIUtility.RotateAroundPivot(value2, new Vector2(num3, num4));
}
float num5 = Mathf.Clamp01(reticleOpacity.Value);
GUI.color = new Color(0f, 0f, 0f, 0.6f * num5);
Arms(num3, num4, num + 2f, gap, num2 + 2f);
Color val = CrosshairColour();
GUI.color = new Color(val.r, val.g, val.b, 0.95f * num5);
Arms(num3, num4, num, gap, num2);
GUI.matrix = matrix;
DrawRing(num3, num4, value);
GUI.color = color;
}
}
private void DrawRing(float cx, float cy, float scale)
{
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: 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)
float num = Mathf.Clamp01(ringOpacity.Value);
if (num <= 0.001f)
{
return;
}
int num2 = Mathf.Clamp(Mathf.RoundToInt(Mathf.Clamp(ringThickness.Value, 0.01f, 1f) * 100f), 1, 100);
if ((Object)(object)ringTexture == (Object)null || ringTextureThickness != num2)
{
if ((Object)(object)ringTexture != (Object)null)
{
Object.Destroy((Object)(object)ringTexture);
}
ringTexture = MakeRing(num2);
ringTextureThickness = num2;
}
float num3 = 12f * scale * ringScale.Value + 1f;
Color val = RingColour();
GUI.color = new Color(val.r, val.g, val.b, num);
GUI.DrawTexture(new Rect(cx - num3, cy - num3, num3 * 2f, num3 * 2f), (Texture)(object)ringTexture);
}
private static Texture2D MakeRing(int steps)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Expected O, but got Unknown
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
Texture2D val = new Texture2D(128, 128, (TextureFormat)4, false);
((Texture)val).wrapMode = (TextureWrapMode)1;
((Texture)val).filterMode = (FilterMode)1;
float num = 63.5f;
float num2 = num - 1f;
float num3 = num2 * (1f - (float)steps / 100f);
Color32[] array = (Color32[])(object)new Color32[16384];
for (int i = 0; i < 128; i++)
{
for (int j = 0; j < 128; j++)
{
float num4 = (float)j - num;
float num5 = (float)i - num;
float num6 = Mathf.Sqrt(num4 * num4 + num5 * num5);
float num7 = Mathf.Clamp01(num2 - num6 + 0.5f) * ((num3 <= 0f) ? 1f : Mathf.Clamp01(num6 - num3 + 0.5f));
array[i * 128 + j] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)Mathf.RoundToInt(num7 * 255f));
}
}
val.SetPixels32(array);
val.Apply();
return val;
}
private static void Arms(float cx, float cy, float arm, float gap, float thick)
{
Bar(cx - gap - arm, cy - thick * 0.5f, arm, thick);
Bar(cx + gap, cy - thick * 0.5f, arm, thick);
Bar(cx - thick * 0.5f, cy - gap - arm, thick, arm);
Bar(cx - thick * 0.5f, cy + gap, thick, arm);
Bar(cx - thick * 0.5f, cy - thick * 0.5f, thick, thick);
}
private static void Bar(float x, float y, float width, float height)
{
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
GUI.DrawTexture(new Rect(x, y, width, height), (Texture)(object)pixel);
}
private void Shutdown()
{
SceneManager.sceneLoaded -= OnSceneLoaded;
if ((Object)(object)driver != (Object)null)
{
Object.Destroy((Object)(object)((Component)driver).gameObject);
driver = null;
}
if (applied)
{
Stop();
}
(provider as IDisposable)?.Dispose();
provider = null;
(menuModule as IDisposable)?.Dispose();
menuModule = null;
InputAction obj = toggle;
if (obj != null)
{
obj.Dispose();
}
toggle = null;
InputAction obj2 = attack;
if (obj2 != null)
{
obj2.Dispose();
}
attack = null;
InputAction obj3 = interact;
if (obj3 != null)
{
obj3.Dispose();
}
interact = null;
active = null;
}
private void OnApplicationQuit()
{
Harmony obj = harmony;
if (obj != null)
{
obj.UnpatchSelf();
}
Shutdown();
}
}
internal static class ReticlePreview
{
private const int Size = 160;
private static string cachedKey;
private static Texture2D cached;
internal static Texture2D Render(string key, float rotation, float scale, Color crosshair, float crosshairOpacity, float ringScale, Color ring, float ringOpacity, float thicknessShare)
{
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)cached != (Object)null && cachedKey == key)
{
return cached;
}
if ((Object)(object)cached != (Object)null)
{
Object.Destroy((Object)(object)cached);
}
cached = Raster(rotation, scale, crosshair, crosshairOpacity, ringScale, ring, ringOpacity, thicknessShare);
cachedKey = key;
return cached;
}
private static Texture2D Raster(float rotation, float scale, Color crosshair, float crosshairOpacity, float ringScale, Color ring, float ringOpacity, float thicknessShare)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Expected O, but got Unknown
//IL_0167: Unknown result type (might be due to invalid IL or missing references)
//IL_016d: 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_0185: Unknown result type (might be due to invalid IL or missing references)
//IL_018c: 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_01b0: Unknown result type (might be due to invalid IL or missing references)
//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
Texture2D val = new Texture2D(160, 160, (TextureFormat)4, false);
((Texture)val).wrapMode = (TextureWrapMode)1;
((Texture)val).filterMode = (FilterMode)1;
Color32[] array = (Color32[])(object)new Color32[25600];
float num = 79.5f;
float num2 = num - 4f;
float num3 = 12f * scale;
float num4 = num3 * ringScale;
float num5 = Mathf.Min(1f, num2 / Mathf.Max(num3, Mathf.Max(num4, 1f)));
num3 *= num5;
num4 *= num5;
float num6 = Mathf.Clamp01(thicknessShare) * num4;
float num7 = num4 - num6;
float gap = num3 * 0.4f;
float bar = Mathf.Max(2f, num3 / 4f);
float num8 = Mathf.Sin((0f - rotation) * (MathF.PI / 180f));
float num9 = Mathf.Cos((0f - rotation) * (MathF.PI / 180f));
float num10 = Mathf.Clamp01(crosshairOpacity) * 0.95f;
float num11 = Mathf.Clamp01(ringOpacity);
Color behind = default(Color);
Color front = default(Color);
for (int i = 0; i < 160; i++)
{
for (int j = 0; j < 160; j++)
{
float num12 = (float)j - num;
float num13 = (float)i - num;
float x = num12 * num9 - num13 * num8;
float y = num12 * num8 + num13 * num9;
float num14 = Arm(x, y, gap, bar, num3);
float num15 = Mathf.Sqrt(num12 * num12 + num13 * num13);
float num16 = Mathf.Clamp01(num4 - num15 + 0.5f) * ((num7 <= 0f) ? 1f : Mathf.Clamp01(num15 - num7 + 0.5f));
((Color)(ref behind))..ctor(crosshair.r, crosshair.g, crosshair.b, num14 * num10);
((Color)(ref front))..ctor(ring.r, ring.g, ring.b, num16 * num11);
array[i * 160 + j] = Over(front, behind);
}
}
val.SetPixels32(array);
val.Apply();
return val;
}
private static float Arm(float x, float y, float gap, float bar, float arm)
{
float num = bar * 0.5f;
return Mathf.Max(Mathf.Max(Mathf.Max(Mathf.Max(Bar(x, y, gap, gap + arm, 0f - num, num), Bar(x, y, 0f - gap - arm, 0f - gap, 0f - num, num)), Bar(x, y, 0f - num, num, gap, gap + arm)), Bar(x, y, 0f - num, num, 0f - gap - arm, 0f - gap)), Bar(x, y, 0f - num, num, 0f - num, num));
}
private static float Bar(float x, float y, float left, float right, float bottom, float top)
{
float num = Mathf.Clamp(x, left, right);
float num2 = Mathf.Clamp(y, bottom, top);
float num3 = x - num;
float num4 = y - num2;
return Mathf.Clamp01(0.5f - Mathf.Sqrt(num3 * num3 + num4 * num4));
}
private static Color32 Over(Color front, Color behind)
{
//IL_0000: 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_0011: 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)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: 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_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
float num = front.a + behind.a * (1f - front.a);
if (num <= 0.001f)
{
return new Color32((byte)0, (byte)0, (byte)0, (byte)0);
}
float value = (front.r * front.a + behind.r * behind.a * (1f - front.a)) / num;
float value2 = (front.g * front.a + behind.g * behind.a * (1f - front.a)) / num;
float value3 = (front.b * front.a + behind.b * behind.a * (1f - front.a)) / num;
return new Color32(ToByte(value), ToByte(value2), ToByte(value3), ToByte(num));
}
private static byte ToByte(float value)
{
return (byte)Mathf.RoundToInt(Mathf.Clamp01(value) * 255f);
}
}
}