Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of CrosshairAimAlign v1.0.0
CrosshairAimAlign.dll
Decompiled 6 hours agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; 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: IgnoresAccessChecksTo("assembly_valheim")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("Valheim Overhaul")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Aligns bow, crossbow, spear and magic projectiles to the camera crosshair without changing camera style.")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("CrosshairAimAlign")] [assembly: AssemblyTitle("CrosshairAimAlign")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [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 CrosshairAimAlign { [HarmonyPatch(typeof(Attack), "GetProjectileSpawnPoint")] internal static class AttackGetProjectileSpawnPointPatch { private static int _aimMask; private static bool _aimMaskReady; private static void Postfix(Attack __instance, ref Vector3 spawnPoint, ref Vector3 aimDir) { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0078: 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_0089: 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_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.Enabled.Value || __instance == null || (Object)(object)__instance.m_character == (Object)null) { return; } Humanoid character = __instance.m_character; Player val = (Player)(object)((character is Player) ? character : null); if ((Object)(object)val == (Object)null || (Object)(object)val != (Object)(object)Player.m_localPlayer) { return; } ItemData val2 = __instance.m_weapon ?? ((Humanoid)val).GetCurrentWeapon(); if (val2?.m_shared == null) { return; } SkillType skillType = val2.m_shared.m_skillType; if (!Plugin.IsSkillEnabled(skillType) || !TryGetCrosshairAimPoint(spawnPoint, out var aimPoint)) { return; } Vector3 val3 = aimPoint - spawnPoint; if (!(((Vector3)(ref val3)).sqrMagnitude < 0.0001f)) { aimDir = ((Vector3)(ref val3)).normalized; if (Plugin.DebugLog.Value) { Plugin.Log.LogInfo((object)$"Aim aligned ({skillType}): spawn={spawnPoint} target={aimPoint} dir={aimDir}"); } } } private static bool TryGetCrosshairAimPoint(Vector3 spawnPoint, out Vector3 aimPoint) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_003b: 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_0045: 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_0110: 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_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_013a: 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_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: 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_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) aimPoint = default(Vector3); GameCamera instance = GameCamera.instance; Camera val = (((Object)(object)instance != (Object)null) ? instance.m_camera : null); if ((Object)(object)val == (Object)null) { return false; } Ray val2 = val.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0f)); float value = Plugin.MaxAimDistance.Value; int aimMask = GetAimMask(); RaycastHit[] array = Physics.RaycastAll(val2, value, aimMask, (QueryTriggerInteraction)1); if (array != null && array.Length != 0) { Array.Sort(array, (RaycastHit a, RaycastHit b) => ((RaycastHit)(ref a)).distance.CompareTo(((RaycastHit)(ref b)).distance)); RaycastHit[] array2 = array; for (int num = 0; num < array2.Length; num++) { RaycastHit val3 = array2[num]; if (((RaycastHit)(ref val3)).distance <= 0.35f) { continue; } if ((Object)(object)((RaycastHit)(ref val3)).collider != (Object)null) { Character componentInParent = ((Component)((RaycastHit)(ref val3)).collider).GetComponentInParent<Character>(); if ((Object)(object)componentInParent != (Object)null && (Object)(object)componentInParent == (Object)(object)Player.m_localPlayer) { continue; } } aimPoint = ((RaycastHit)(ref val3)).point; return true; } } aimPoint = ((Ray)(ref val2)).origin + ((Ray)(ref val2)).direction * value; if (Vector3.Dot(aimPoint - spawnPoint, ((Ray)(ref val2)).direction) < 0f) { aimPoint = spawnPoint + ((Ray)(ref val2)).direction * value; } return true; } private static int GetAimMask() { if (_aimMaskReady) { return _aimMask; } _aimMask = LayerMask.GetMask(new string[12] { "Default", "static_solid", "Default_small", "piece", "terrain", "vehicle", "character", "character_net", "character_ghost", "hitbox", "character_noenv", "item" }); if (_aimMask == 0) { _aimMask = -5; } _aimMaskReady = true; return _aimMask; } } [BepInPlugin("valheimoverhaul.crosshair.aimalign", "Crosshair Aim Align", "1.0.0")] public sealed class Plugin : BaseUnityPlugin { public const string PluginGuid = "valheimoverhaul.crosshair.aimalign"; public const string PluginName = "Crosshair Aim Align"; public const string PluginVersion = "1.0.0"; internal static Plugin Instance; internal static ManualLogSource Log; internal static ConfigEntry<bool> Enabled; internal static ConfigEntry<float> MaxAimDistance; internal static ConfigEntry<bool> Bows; internal static ConfigEntry<bool> Crossbows; internal static ConfigEntry<bool> Spears; internal static ConfigEntry<bool> ElementalMagic; internal static ConfigEntry<bool> BloodMagic; internal static ConfigEntry<bool> DebugLog; private void Awake() { //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Expected O, but got Unknown //IL_0133: Unknown result type (might be due to invalid IL or missing references) Instance = this; Log = ((BaseUnityPlugin)this).Logger; Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Align local player projectiles to the camera crosshair."); MaxAimDistance = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Max Aim Distance", 200f, new ConfigDescription("How far the crosshair raycast looks for a target point.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(20f, 500f), Array.Empty<object>())); Bows = ((BaseUnityPlugin)this).Config.Bind<bool>("Weapons", "Bows", true, "Align bow arrows to the crosshair."); Crossbows = ((BaseUnityPlugin)this).Config.Bind<bool>("Weapons", "Crossbows", true, "Align crossbow bolts to the crosshair."); Spears = ((BaseUnityPlugin)this).Config.Bind<bool>("Weapons", "Spears", true, "Align thrown spears to the crosshair."); ElementalMagic = ((BaseUnityPlugin)this).Config.Bind<bool>("Weapons", "Elemental Magic", true, "Align elemental magic projectiles to the crosshair."); BloodMagic = ((BaseUnityPlugin)this).Config.Bind<bool>("Weapons", "Blood Magic", true, "Align blood magic projectiles to the crosshair."); DebugLog = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "Log Aim Corrections", false, "Log aim corrections to BepInEx log."); new Harmony("valheimoverhaul.crosshair.aimalign").PatchAll(); Log.LogInfo((object)"Crosshair Aim Align 1.0.0 loaded."); } internal static bool IsSkillEnabled(SkillType skill) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected I4, but got Unknown //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Invalid comparison between Unknown and I4 switch (skill - 5) { default: if ((int)skill != 14) { break; } return Crossbows.Value; case 3: return Bows.Value; case 0: return Spears.Value; case 4: return ElementalMagic.Value; case 5: return BloodMagic.Value; case 1: case 2: break; } return false; } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }