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 TrueFlightCrosshair v0.9.3
DynamicAimPoint.dll
Decompiled 5 days agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Configuration; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyVersion("0.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace DynamicAimPoint { internal enum CrosshairPreset { MainCrosshair80, BurgundyDot, Diamond, Classic, Circle, CyanFourPoint, CyanThreePoint, CyanTwoPointVertical, MinusStyle, CyanTwoPointHorizontal, Custom } internal struct CrosshairStyle { internal bool UseMainCrosshair; internal bool North; internal bool South; internal bool East; internal bool West; internal float ArmLength; internal float ArmThickness; internal float Gap; internal float CircleDiameter; internal float CircleThickness; internal float DiamondDiameter; internal float DiamondThickness; internal float CenterDotDiameter; internal Color Color; internal float OutlineThickness; internal Color OutlineColor; internal static CrosshairStyle MainCopy() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) return new CrosshairStyle { UseMainCrosshair = true, Color = new Color(1f, 1f, 1f, 0.8f) }; } internal static CrosshairStyle Dot(Color color, float diameter) { //IL_001e: 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) return new CrosshairStyle { CenterDotDiameter = diameter, ArmThickness = 2f, Color = color }; } internal static CrosshairStyle Arms(bool north, bool south, bool east, bool west, Color color) { //IL_004e: 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) return new CrosshairStyle { North = north, South = south, East = east, West = west, ArmLength = 6f, ArmThickness = 2f, Gap = 3f, Color = color }; } internal static CrosshairStyle Circle(Color color, float diameter, float thickness) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) return new CrosshairStyle { CircleDiameter = diameter, CircleThickness = thickness, Color = color }; } internal static CrosshairStyle Diamond(Color color, float diameter, float thickness) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) return new CrosshairStyle { DiamondDiameter = diameter, DiamondThickness = thickness, Color = color }; } } [BepInPlugin("com.valheimcrewman.dynamicaimpoint", "TrueFlight Crosshair", "0.9.3")] public sealed class DynamicAimPointPlugin : BaseUnityPlugin { public const string PluginGuid = "com.valheimcrewman.dynamicaimpoint"; public const string PluginName = "TrueFlight Crosshair"; public const string PluginVersion = "0.9.3"; private ConfigEntry<bool> _enabled; private ConfigEntry<float> _maximumDistance; private ConfigEntry<float> _closeRangeDistance; private ConfigEntry<float> _muzzlePoseTolerance; private ConfigEntry<CrosshairPreset> _preset; private ConfigEntry<float> _ghostScale; private ConfigEntry<Color> _customColor; private ConfigEntry<float> _customOpacity; private ConfigEntry<bool> _customNorth; private ConfigEntry<bool> _customSouth; private ConfigEntry<bool> _customEast; private ConfigEntry<bool> _customWest; private ConfigEntry<float> _customArmLength; private ConfigEntry<float> _customArmThickness; private ConfigEntry<float> _customGap; private ConfigEntry<float> _customCircleDiameter; private ConfigEntry<float> _customCircleThickness; private ConfigEntry<float> _customDotThickness; private ConfigEntry<float> _customOutlineThickness; private ConfigEntry<Color> _customOutlineColor; private ConfigEntry<float> _customOutlineOpacity; private ConfigEntry<KeyboardShortcut> _customizerHotkey; private GhostCrosshairView _view; private Texture2D _customPreview; private bool _customPreviewDirty = true; private bool _customizerVisible; private bool _advancedCustomizer; private Rect _customizerRect = new Rect(30f, 80f, 420f, 620f); private Vector2 _customizerScroll; private GUISkin _customizerSkin; private readonly List<Texture2D> _customizerTextures = new List<Texture2D>(); private CursorLockMode _previousCursorLock; private bool _previousCursorVisible; private bool _previousSaveOnConfigSet; private string _lastLoggedError; private void Awake() { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Expected O, but got Unknown //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Expected O, but got Unknown //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Expected O, but got Unknown //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Expected O, but got Unknown //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Expected O, but got Unknown //IL_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Expected O, but got Unknown //IL_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_02ea: Expected O, but got Unknown //IL_031e: Unknown result type (might be due to invalid IL or missing references) //IL_0328: Expected O, but got Unknown //IL_035c: Unknown result type (might be due to invalid IL or missing references) //IL_0366: Expected O, but got Unknown //IL_039a: Unknown result type (might be due to invalid IL or missing references) //IL_03a4: Expected O, but got Unknown //IL_03d8: Unknown result type (might be due to invalid IL or missing references) //IL_03e2: Expected O, but got Unknown //IL_03f8: Unknown result type (might be due to invalid IL or missing references) //IL_043b: Unknown result type (might be due to invalid IL or missing references) //IL_0445: Expected O, but got Unknown //IL_0465: Unknown result type (might be due to invalid IL or missing references) _enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Show the true projectile aim marker for supported weapons."); _maximumDistance = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Maximum distance", 20f, new ConfigDescription("Maximum projectile-path distance checked for an impact.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 200f), Array.Empty<object>())); _closeRangeDistance = ((BaseUnityPlugin)this).Config.Bind<float>("Prediction", "Close range distance", 5f, new ConfigDescription("Distance over which the muzzle-pose tolerance is applied.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 15f), Array.Empty<object>())); _muzzlePoseTolerance = ((BaseUnityPlugin)this).Config.Bind<float>("Prediction", "Muzzle pose tolerance", 0.108f, new ConfigDescription("Extra collision clearance in metres near the muzzle. This compensates for the firing animation moving the projectile origin after the idle preview. Set to zero for an exact centerline without conservative clearance.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); _preset = ((BaseUnityPlugin)this).Config.Bind<CrosshairPreset>("Appearance", "Preset", CrosshairPreset.Circle, "Marker design. Select Custom to use the settings in the Custom section."); _ghostScale = ((BaseUnityPlugin)this).Config.Bind<float>("Appearance", "Scale", 1.5f, new ConfigDescription("Size relative to Valheim's normal crosshair.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.25f, 2f), Array.Empty<object>())); _customColor = ((BaseUnityPlugin)this).Config.Bind<Color>("Custom", "Color", new Color(0.45f, 0.9f, 1f, 1f), "Custom marker RGB color. Opacity is configured separately."); _customOpacity = ((BaseUnityPlugin)this).Config.Bind<float>("Custom", "Opacity", 0.8f, new ConfigDescription("Custom marker opacity.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); _customNorth = ((BaseUnityPlugin)this).Config.Bind<bool>("Custom", "North arm", true, "Draw the upper arm."); _customSouth = ((BaseUnityPlugin)this).Config.Bind<bool>("Custom", "South arm", true, "Draw the lower arm."); _customEast = ((BaseUnityPlugin)this).Config.Bind<bool>("Custom", "East arm", true, "Draw the right arm."); _customWest = ((BaseUnityPlugin)this).Config.Bind<bool>("Custom", "West arm", true, "Draw the left arm."); _customArmLength = ((BaseUnityPlugin)this).Config.Bind<float>("Custom", "Arm length", 8f, new ConfigDescription("Length of each enabled arm in pixels.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 64f), Array.Empty<object>())); _customArmThickness = ((BaseUnityPlugin)this).Config.Bind<float>("Custom", "Arm thickness", 2f, new ConfigDescription("Thickness of the crosshair arms in pixels.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 16f), Array.Empty<object>())); _customGap = ((BaseUnityPlugin)this).Config.Bind<float>("Custom", "Center gap", 4f, new ConfigDescription("Distance from the center to the start of each arm in pixels.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 64f), Array.Empty<object>())); _customCircleDiameter = ((BaseUnityPlugin)this).Config.Bind<float>("Custom", "Circle diameter", 0f, new ConfigDescription("Diameter of an optional center ring in pixels; zero disables it.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 128f), Array.Empty<object>())); _customCircleThickness = ((BaseUnityPlugin)this).Config.Bind<float>("Custom", "Circle thickness", 2f, new ConfigDescription("Line thickness of the optional center circle in pixels.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 16f), Array.Empty<object>())); _customDotThickness = ((BaseUnityPlugin)this).Config.Bind<float>("Custom", "Dot thickness", 0f, new ConfigDescription("Diameter/thickness of the filled center dot in pixels; zero disables it.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 32f), Array.Empty<object>())); _customOutlineThickness = ((BaseUnityPlugin)this).Config.Bind<float>("Custom", "Outline thickness", 0f, new ConfigDescription("Border thickness around all enabled custom shapes; zero disables it.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 8f), Array.Empty<object>())); _customOutlineColor = ((BaseUnityPlugin)this).Config.Bind<Color>("Custom", "Outline color", Color.black, "RGB color of the border outline. Opacity is configured separately."); _customOutlineOpacity = ((BaseUnityPlugin)this).Config.Bind<float>("Custom", "Outline opacity", 0.9f, new ConfigDescription("Opacity of the border outline.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); _customizerHotkey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Appearance", "Customizer hotkey", new KeyboardShortcut((KeyCode)289, Array.Empty<KeyCode>()), "Open or close the live custom-crosshair editor. Opening it selects the Custom preset."); _preset.SettingChanged += OnPresetChanged; _customColor.SettingChanged += InvalidateView; _customOpacity.SettingChanged += InvalidateView; _customNorth.SettingChanged += InvalidateView; _customSouth.SettingChanged += InvalidateView; _customEast.SettingChanged += InvalidateView; _customWest.SettingChanged += InvalidateView; _customArmLength.SettingChanged += InvalidateView; _customArmThickness.SettingChanged += InvalidateView; _customGap.SettingChanged += InvalidateView; _customCircleDiameter.SettingChanged += InvalidateView; _customCircleThickness.SettingChanged += InvalidateView; _customDotThickness.SettingChanged += InvalidateView; _customOutlineThickness.SettingChanged += InvalidateView; _customOutlineColor.SettingChanged += InvalidateView; _customOutlineOpacity.SettingChanged += InvalidateView; if (!ValheimAccess.IsCompatible(out var error)) { ((BaseUnityPlugin)this).Logger.LogError((object)error); ((Behaviour)this).enabled = false; } } private void LateUpdate() { //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_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0130: 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_0140: Unknown result type (might be due to invalid IL or missing references) //IL_014e: 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_016a: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) try { KeyboardShortcut value = _customizerHotkey.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { SetCustomizerVisible(!_customizerVisible); if (_customizerVisible && _preset.Value != CrosshairPreset.Custom) { _preset.Value = CrosshairPreset.Custom; } } if (_customizerVisible) { Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; } if (!_enabled.Value || !TryResolveFrame(out var player, out var attack, out var camera)) { _view?.Hide(); return; } if (_view == null || !_view.BelongsTo(Hud.instance)) { _view?.Dispose(); _view = GhostCrosshairView.TryCreate(Hud.instance, ResolveStyle()); } if (_view == null || !ProjectileAimResolver.TryBuildLaunch(player, attack, out var launch) || !ProjectileAimResolver.TryFindImpact(player, launch, _maximumDistance.Value, _closeRangeDistance.Value, _muzzlePoseTolerance.Value, out var impact)) { _view?.Hide(); return; } Vector3 val = camera.WorldToViewportPoint(((RaycastHit)(ref impact)).point); if (val.z <= 0f || val.x < 0f || val.x > 1f || val.y < 0f || val.y > 1f) { _view.Hide(); return; } _view.Show(((RaycastHit)(ref impact)).point, camera, _ghostScale.Value); _lastLoggedError = null; } catch (Exception ex) { _view?.Hide(); LogOnce(ex.GetBaseException().Message); } } private static bool TryResolveFrame(out Player player, out Attack attack, out Camera camera) { player = Player.m_localPlayer; attack = null; camera = null; if ((Object)(object)player == (Object)null || (Object)(object)Hud.instance == (Object)null || !Hud.instance.IsVisible()) { return false; } ItemData currentWeapon = ((Humanoid)player).GetCurrentWeapon(); if (currentWeapon?.m_shared == null) { return false; } if (ValheimAccess.TryGetCurrentAttack(player, out var attack2) && attack2.GetWeapon() == currentWeapon && IsProjectileAttack(attack2)) { attack = attack2; } else if (!TrySelectEquippedProjectileAttack(currentWeapon, out attack)) { return false; } GameCamera instance = GameCamera.instance; camera = (((Object)(object)instance != (Object)null) ? ((Component)instance).GetComponent<Camera>() : Camera.main); return (Object)(object)camera != (Object)null; } private static bool TrySelectEquippedProjectileAttack(ItemData weapon, out Attack attack) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Invalid comparison between Unknown and I4 attack = null; Attack attack2 = weapon.m_shared.m_attack; Attack secondaryAttack = weapon.m_shared.m_secondaryAttack; if ((int)weapon.m_shared.m_skillType == 5 && IsProjectileAttack(secondaryAttack)) { attack = secondaryAttack; return true; } if (IsProjectileAttack(attack2)) { attack = attack2; return true; } if (IsProjectileAttack(secondaryAttack)) { attack = secondaryAttack; return true; } return false; } private static bool IsProjectileAttack(Attack attack) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Invalid comparison between Unknown and I4 //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Invalid comparison between Unknown and I4 if (attack != null) { if ((int)attack.m_attackType != 2 && (int)attack.m_attackType != 5 && !((Object)(object)attack.m_attackProjectile != (Object)null)) { return attack.m_bowDraw; } return true; } return false; } private CrosshairStyle ResolveStyle() { //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_02c2: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_019a: 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_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_029b: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Unknown result type (might be due to invalid IL or missing references) //IL_02b5: Unknown result type (might be due to invalid IL or missing references) //IL_02b6: Unknown result type (might be due to invalid IL or missing references) Color color = default(Color); ((Color)(ref color))..ctor(0.25f, 0.95f, 1f, 0.82f); switch (_preset.Value) { case CrosshairPreset.MainCrosshair80: return CrosshairStyle.MainCopy(); case CrosshairPreset.BurgundyDot: return CrosshairStyle.Dot(new Color(0.5f, 0.035f, 0.12f, 0.9f), 6f); case CrosshairPreset.Diamond: return CrosshairStyle.Diamond(new Color(0.29411766f, 1f, 0.5294118f, 1f), 8.75f, 1.6f); case CrosshairPreset.Classic: return new CrosshairStyle { North = true, South = true, East = true, West = true, ArmLength = 5f, ArmThickness = 1.25f, Gap = 1.25f, Color = new Color(0f, 1f, 0f, 1f) }; case CrosshairPreset.Circle: return CrosshairStyle.Circle(Color.white, 7.5f, 1.25f); case CrosshairPreset.CyanThreePoint: return CrosshairStyle.Arms(north: false, south: true, east: true, west: true, color); case CrosshairPreset.CyanTwoPointVertical: return CrosshairStyle.Arms(north: true, south: true, east: false, west: false, color); case CrosshairPreset.MinusStyle: return new CrosshairStyle { East = true, West = true, ArmLength = 5f, ArmThickness = 1.25f, Gap = 1.25f, Color = Color.white }; case CrosshairPreset.CyanTwoPointHorizontal: return CrosshairStyle.Arms(north: false, south: false, east: true, west: true, color); case CrosshairPreset.Custom: { Color value = _customColor.Value; value.a = _customOpacity.Value; Color value2 = _customOutlineColor.Value; value2.a = _customOutlineOpacity.Value; return new CrosshairStyle { North = _customNorth.Value, South = _customSouth.Value, East = _customEast.Value, West = _customWest.Value, ArmLength = _customArmLength.Value, ArmThickness = _customArmThickness.Value, Gap = _customGap.Value, CircleDiameter = _customCircleDiameter.Value, CircleThickness = _customCircleThickness.Value, CenterDotDiameter = _customDotThickness.Value, Color = value, OutlineThickness = _customOutlineThickness.Value, OutlineColor = value2 }; } default: return CrosshairStyle.Arms(north: true, south: true, east: true, west: true, color); } } private void LogOnce(string message) { if (!string.Equals(message, _lastLoggedError, StringComparison.Ordinal)) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Could not update projectile aim marker: " + message)); _lastLoggedError = message; } } private void InvalidateView(object sender, EventArgs eventArgs) { _view?.Dispose(); _view = null; _customPreviewDirty = true; } private void OnPresetChanged(object sender, EventArgs eventArgs) { InvalidateView(sender, eventArgs); if (_preset.Value == CrosshairPreset.Custom) { SetCustomizerVisible(visible: true); } } private void OnGUI() { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) if (_customizerVisible) { int depth = GUI.depth; GUISkin skin = GUI.skin; GUI.depth = -1000; EnsureCustomizerSkin(); GUI.skin = _customizerSkin; _customizerRect = GUILayout.Window(((Object)this).GetInstanceID(), _customizerRect, new WindowFunction(DrawCustomizerWindow), "TrueFlight Crosshair | Custom", Array.Empty<GUILayoutOption>()); GUI.skin = skin; GUI.depth = depth; ((Rect)(ref _customizerRect)).x = Mathf.Clamp(((Rect)(ref _customizerRect)).x, 0f, Mathf.Max(0f, (float)Screen.width - ((Rect)(ref _customizerRect)).width)); ((Rect)(ref _customizerRect)).y = Mathf.Clamp(((Rect)(ref _customizerRect)).y, 0f, Mathf.Max(0f, (float)Screen.height - ((Rect)(ref _customizerRect)).height)); } } private void DrawCustomizerWindow(int windowId) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: 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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0182: 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_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_02e9: Unknown result type (might be due to invalid IL or missing references) //IL_0301: Unknown result type (might be due to invalid IL or missing references) //IL_0306: Unknown result type (might be due to invalid IL or missing references) //IL_0555: Unknown result type (might be due to invalid IL or missing references) //IL_0597: Unknown result type (might be due to invalid IL or missing references) EnsureCustomPreview(); GUILayout.Space(3f); Rect rect = GUILayoutUtility.GetRect(94f, 94f, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); GUI.Box(rect, GUIContent.none); if ((Object)(object)_customPreview != (Object)null) { GUI.DrawTexture(rect, (Texture)(object)_customPreview, (ScaleMode)2, true); } GUILayout.Label("SHAPE", Array.Empty<GUILayoutOption>()); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); if (GUILayout.Button("Cross", Array.Empty<GUILayoutOption>())) { ApplyArmLayout(north: true, south: true, east: true, west: true); } if (GUILayout.Button("T-shape", Array.Empty<GUILayoutOption>())) { ApplyArmLayout(north: false, south: true, east: true, west: true); } if (GUILayout.Button("Minus", Array.Empty<GUILayoutOption>())) { ApplyArmLayout(north: false, south: false, east: true, west: true); } if (GUILayout.Button("Vertical", Array.Empty<GUILayoutOption>())) { ApplyArmLayout(north: true, south: true, east: false, west: false); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); if (GUILayout.Button("Dot", Array.Empty<GUILayoutOption>())) { ApplyDotLayout(); } if (GUILayout.Button("Circle", Array.Empty<GUILayoutOption>())) { ApplyCircleLayout(); } if (GUILayout.Button("No outline", Array.Empty<GUILayoutOption>())) { _customOutlineThickness.Value = 0f; } GUILayout.EndHorizontal(); GUILayout.Label("COLOR", Array.Empty<GUILayoutOption>()); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); if (GUILayout.Button("Cyan", Array.Empty<GUILayoutOption>())) { _customColor.Value = new Color(0.25f, 0.95f, 1f, 1f); } if (GUILayout.Button("Green", Array.Empty<GUILayoutOption>())) { _customColor.Value = Color.green; } if (GUILayout.Button("White", Array.Empty<GUILayoutOption>())) { _customColor.Value = Color.white; } if (GUILayout.Button("Burgundy", Array.Empty<GUILayoutOption>())) { _customColor.Value = new Color(0.5f, 0.035f, 0.12f, 1f); } GUILayout.EndHorizontal(); DrawSlider("Length", _customArmLength, 1f, 64f, "0.0"); DrawSlider("Thickness", _customArmThickness, 1f, 16f, "0.0"); DrawSlider("Gap", _customGap, 0f, 64f, "0.0"); DrawSlider("Opacity", _customOpacity, 0f, 1f, "0.00"); DrawSlider("Scale", _ghostScale, 0.25f, 2f, "0.00x"); GUILayout.Space(4f); if (GUILayout.Button(_advancedCustomizer ? "− Hide advanced" : "+ Advanced", Array.Empty<GUILayoutOption>())) { _advancedCustomizer = !_advancedCustomizer; } if (_advancedCustomizer) { _customizerScroll = GUILayout.BeginScrollView(_customizerScroll, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(185f) }); GUILayout.Label("INDIVIDUAL ARMS", Array.Empty<GUILayoutOption>()); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); SetIfChanged(_customNorth, GUILayout.Toggle(_customNorth.Value, "North: " + (_customNorth.Value ? "On" : "Off"), GUI.skin.button, Array.Empty<GUILayoutOption>())); SetIfChanged(_customSouth, GUILayout.Toggle(_customSouth.Value, "South: " + (_customSouth.Value ? "On" : "Off"), GUI.skin.button, Array.Empty<GUILayoutOption>())); SetIfChanged(_customWest, GUILayout.Toggle(_customWest.Value, "West: " + (_customWest.Value ? "On" : "Off"), GUI.skin.button, Array.Empty<GUILayoutOption>())); SetIfChanged(_customEast, GUILayout.Toggle(_customEast.Value, "East: " + (_customEast.Value ? "On" : "Off"), GUI.skin.button, Array.Empty<GUILayoutOption>())); GUILayout.EndHorizontal(); DrawSlider("Dot", _customDotThickness, 0f, 32f, "0.0"); DrawSlider("Circle size", _customCircleDiameter, 0f, 128f, "0.0"); DrawSlider("Circle line", _customCircleThickness, 1f, 16f, "0.0"); DrawSlider("Outline", _customOutlineThickness, 0f, 8f, "0.0"); DrawColorControls("Crosshair", _customColor, _customOpacity); DrawColorControls("Outline", _customOutlineColor, _customOutlineOpacity); GUILayout.EndScrollView(); } GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); if (GUILayout.Button("Reset Custom", Array.Empty<GUILayoutOption>())) { ResetCustomSettings(); } if (GUILayout.Button("Close", Array.Empty<GUILayoutOption>())) { SetCustomizerVisible(visible: false); } GUILayout.EndHorizontal(); GUILayout.Label($"{_customizerHotkey.Value} Open / close", GUI.skin.GetStyle("hint"), Array.Empty<GUILayoutOption>()); GUI.DragWindow(new Rect(0f, 0f, ((Rect)(ref _customizerRect)).width, 24f)); } private void DrawColorControls(string label, ConfigEntry<Color> colorEntry, ConfigEntry<float> opacityEntry) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: 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_0047: 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_00af: 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_00ba: Unknown result type (might be due to invalid IL or missing references) GUILayout.Label(label + " color", Array.Empty<GUILayoutOption>()); Color value = colorEntry.Value; float num = DrawRawSlider("R", value.r * 255f, 0f, 255f, "0"); float num2 = DrawRawSlider("G", value.g * 255f, 0f, 255f, "0"); float num3 = DrawRawSlider("B", value.b * 255f, 0f, 255f, "0"); Color val = default(Color); ((Color)(ref val))..ctor(num / 255f, num2 / 255f, num3 / 255f, 1f); if (val != value) { colorEntry.Value = val; } DrawSlider(label + " opacity", opacityEntry, 0f, 1f, "0.00"); } private void ApplyArmLayout(bool north, bool south, bool east, bool west) { _customNorth.Value = north; _customSouth.Value = south; _customEast.Value = east; _customWest.Value = west; _customDotThickness.Value = 0f; _customCircleDiameter.Value = 0f; } private void ApplyDotLayout() { ApplyArmLayout(north: false, south: false, east: false, west: false); _customDotThickness.Value = Mathf.Max(6f, _customDotThickness.Value); } private void ApplyCircleLayout() { ApplyArmLayout(north: false, south: false, east: false, west: false); _customCircleDiameter.Value = Mathf.Max(8f, _customCircleDiameter.Value); } private void EnsureCustomizerSkin() { //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0130: 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_028b: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Expected O, but got Unknown //IL_02a4: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Expected O, but got Unknown //IL_02d3: Unknown result type (might be due to invalid IL or missing references) //IL_02ec: Unknown result type (might be due to invalid IL or missing references) //IL_030b: Unknown result type (might be due to invalid IL or missing references) //IL_0315: Expected O, but got Unknown //IL_0326: Unknown result type (might be due to invalid IL or missing references) //IL_0328: Unknown result type (might be due to invalid IL or missing references) //IL_0329: Unknown result type (might be due to invalid IL or missing references) //IL_0441: Unknown result type (might be due to invalid IL or missing references) //IL_044b: Expected O, but got Unknown //IL_045a: Unknown result type (might be due to invalid IL or missing references) //IL_0464: Expected O, but got Unknown //IL_0473: Unknown result type (might be due to invalid IL or missing references) //IL_047d: Expected O, but got Unknown //IL_04b4: Unknown result type (might be due to invalid IL or missing references) //IL_0502: Unknown result type (might be due to invalid IL or missing references) //IL_051b: Unknown result type (might be due to invalid IL or missing references) //IL_053a: Unknown result type (might be due to invalid IL or missing references) //IL_0544: Expected O, but got Unknown //IL_055a: Unknown result type (might be due to invalid IL or missing references) //IL_055b: Unknown result type (might be due to invalid IL or missing references) //IL_0763: Unknown result type (might be due to invalid IL or missing references) //IL_0768: Unknown result type (might be due to invalid IL or missing references) //IL_0773: Unknown result type (might be due to invalid IL or missing references) //IL_077a: Unknown result type (might be due to invalid IL or missing references) //IL_0784: Expected O, but got Unknown //IL_078b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_customizerSkin != (Object)null) { return; } _customizerSkin = Object.Instantiate<GUISkin>(GUI.skin); ((Object)_customizerSkin).name = "DynamicAimPoint_ValheimSkin"; Font val = null; Font[] array = Resources.FindObjectsOfTypeAll<Font>(); foreach (Font val2 in array) { string text = ((Object)val2).name.ToLowerInvariant(); if (text.Contains("averia") || text.Contains("norse")) { val = val2; break; } } if ((Object)(object)val != (Object)null) { _customizerSkin.font = val; } Color val3 = default(Color); ((Color)(ref val3))..ctor(0.91f, 0.82f, 0.64f, 1f); Color textColor = default(Color); ((Color)(ref textColor))..ctor(0.68f, 0.59f, 0.45f, 1f); Color val4 = default(Color); ((Color)(ref val4))..ctor(0.72f, 0.47f, 0.18f, 1f); Color center = default(Color); ((Color)(ref center))..ctor(0.075f, 0.055f, 0.04f, 0.96f); Color center2 = default(Color); ((Color)(ref center2))..ctor(0.18f, 0.115f, 0.065f, 0.98f); _customizerSkin.window.normal.background = CreateUiTexture(center, val4, 1); _customizerSkin.window.normal.textColor = val3; CopyStyleState(_customizerSkin.window.normal, _customizerSkin.window.hover); CopyStyleState(_customizerSkin.window.normal, _customizerSkin.window.active); CopyStyleState(_customizerSkin.window.normal, _customizerSkin.window.focused); CopyStyleState(_customizerSkin.window.normal, _customizerSkin.window.onNormal); CopyStyleState(_customizerSkin.window.normal, _customizerSkin.window.onHover); CopyStyleState(_customizerSkin.window.normal, _customizerSkin.window.onActive); CopyStyleState(_customizerSkin.window.normal, _customizerSkin.window.onFocused); _customizerSkin.window.alignment = (TextAnchor)1; _customizerSkin.window.fontSize = 18; _customizerSkin.window.padding = new RectOffset(14, 14, 30, 12); _customizerSkin.window.border = new RectOffset(2, 2, 2, 2); _customizerSkin.box.normal.background = CreateUiTexture(new Color(0.025f, 0.02f, 0.015f, 0.88f), new Color(0.42f, 0.28f, 0.12f, 1f), 1); _customizerSkin.box.border = new RectOffset(2, 2, 2, 2); ConfigureButtonState(_customizerSkin.button.normal, center2, val4, val3); CopyStyleState(_customizerSkin.button.normal, _customizerSkin.button.hover); CopyStyleState(_customizerSkin.button.normal, _customizerSkin.button.active); CopyStyleState(_customizerSkin.button.normal, _customizerSkin.button.focused); CopyStyleState(_customizerSkin.button.normal, _customizerSkin.button.onNormal); CopyStyleState(_customizerSkin.button.normal, _customizerSkin.button.onHover); CopyStyleState(_customizerSkin.button.normal, _customizerSkin.button.onActive); CopyStyleState(_customizerSkin.button.normal, _customizerSkin.button.onFocused); _customizerSkin.button.border = new RectOffset(2, 2, 2, 2); _customizerSkin.button.margin = new RectOffset(2, 2, 2, 2); _customizerSkin.button.padding = new RectOffset(8, 8, 4, 4); _customizerSkin.button.fixedHeight = 27f; _customizerSkin.button.fontSize = 14; _customizerSkin.label.normal.textColor = val3; _customizerSkin.label.fontSize = 14; _customizerSkin.label.alignment = (TextAnchor)3; _customizerSkin.horizontalSlider.normal.background = CreateUiTexture(new Color(0.035f, 0.025f, 0.018f, 1f), new Color(0.36f, 0.23f, 0.1f, 1f), 1); _customizerSkin.horizontalSlider.border = new RectOffset(2, 2, 2, 2); _customizerSkin.horizontalSlider.fixedHeight = 8f; Texture2D background = CreateUiTexture(val4, val3, 1); _customizerSkin.horizontalSliderThumb.normal.background = background; CopyStyleState(_customizerSkin.horizontalSliderThumb.normal, _customizerSkin.horizontalSliderThumb.hover); CopyStyleState(_customizerSkin.horizontalSliderThumb.normal, _customizerSkin.horizontalSliderThumb.active); CopyStyleState(_customizerSkin.horizontalSliderThumb.normal, _customizerSkin.horizontalSliderThumb.focused); CopyStyleState(_customizerSkin.horizontalSliderThumb.normal, _customizerSkin.horizontalSliderThumb.onNormal); CopyStyleState(_customizerSkin.horizontalSliderThumb.normal, _customizerSkin.horizontalSliderThumb.onHover); CopyStyleState(_customizerSkin.horizontalSliderThumb.normal, _customizerSkin.horizontalSliderThumb.onActive); CopyStyleState(_customizerSkin.horizontalSliderThumb.normal, _customizerSkin.horizontalSliderThumb.onFocused); _customizerSkin.horizontalSliderThumb.fixedWidth = 14f; _customizerSkin.horizontalSliderThumb.fixedHeight = 20f; NeutralizeStyle(_customizerSkin.window); NeutralizeStyle(_customizerSkin.box); NeutralizeStyle(_customizerSkin.button); NeutralizeStyle(_customizerSkin.label); NeutralizeStyle(_customizerSkin.horizontalSlider); NeutralizeStyle(_customizerSkin.horizontalSliderThumb); NeutralizeStyle(_customizerSkin.verticalScrollbar); NeutralizeStyle(_customizerSkin.verticalScrollbarThumb); NeutralizeStyle(_customizerSkin.verticalScrollbarUpButton); NeutralizeStyle(_customizerSkin.verticalScrollbarDownButton); NeutralizeStyle(_customizerSkin.scrollView); GUIStyle val5 = new GUIStyle(_customizerSkin.label) { name = "hint", alignment = (TextAnchor)4, fontSize = 12 }; val5.normal.textColor = textColor; List<GUIStyle> list = new List<GUIStyle>((IEnumerable<GUIStyle>)(((object)_customizerSkin.customStyles) ?? ((object)new GUIStyle[0]))) { val5 }; _customizerSkin.customStyles = list.ToArray(); } private void ConfigureButtonState(GUIStyleState state, Color center, Color border, Color text) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) state.background = CreateUiTexture(center, border, 1); state.textColor = text; } private static void CopyStyleState(GUIStyleState source, GUIStyleState destination) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) destination.background = source.background; destination.textColor = source.textColor; } private static void NeutralizeStyle(GUIStyle style) { CopyStyleState(style.normal, style.hover); CopyStyleState(style.normal, style.active); CopyStyleState(style.normal, style.focused); CopyStyleState(style.normal, style.onNormal); CopyStyleState(style.normal, style.onHover); CopyStyleState(style.normal, style.onActive); CopyStyleState(style.normal, style.onFocused); } private Texture2D CreateUiTexture(Color center, Color border, int borderWidth) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Expected O, but got Unknown //IL_005c: 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_005d: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(8, 8, (TextureFormat)4, false); ((Object)val).name = "DynamicAimPoint_ValheimUi"; ((Texture)val).filterMode = (FilterMode)0; ((Texture)val).wrapMode = (TextureWrapMode)1; Color[] array = (Color[])(object)new Color[64]; for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { bool flag = j < borderWidth || i < borderWidth || j >= 8 - borderWidth || i >= 8 - borderWidth; array[i * 8 + j] = (flag ? border : center); } } val.SetPixels(array); val.Apply(false, true); _customizerTextures.Add(val); return val; } private static float DrawRawSlider(string label, float value, float minimum, float maximum, string format) { GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label(label, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(145f) }); float result = GUILayout.HorizontalSlider(value, minimum, maximum, Array.Empty<GUILayoutOption>()); GUILayout.Label(result.ToString(format), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(58f) }); GUILayout.EndHorizontal(); return result; } private static void DrawSlider(string label, ConfigEntry<float> entry, float minimum, float maximum, string format) { float num = DrawRawSlider(label, entry.Value, minimum, maximum, format); if (!Mathf.Approximately(num, entry.Value)) { entry.Value = num; } } private static void SetIfChanged(ConfigEntry<bool> entry, bool value) { if (entry.Value != value) { entry.Value = value; } } private void EnsureCustomPreview() { if (_customPreviewDirty || !((Object)(object)_customPreview != (Object)null)) { if ((Object)(object)_customPreview != (Object)null) { Object.Destroy((Object)(object)_customPreview); } _customPreview = GhostCrosshairView.CreatePreviewTexture(ResolveStyle()); _customPreviewDirty = false; } } private void SetCustomizerVisible(bool visible) { //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0015: 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) if (_customizerVisible != visible) { _customizerVisible = visible; if (visible) { _previousCursorLock = Cursor.lockState; _previousCursorVisible = Cursor.visible; _previousSaveOnConfigSet = ((BaseUnityPlugin)this).Config.SaveOnConfigSet; ((BaseUnityPlugin)this).Config.SaveOnConfigSet = false; Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; _customPreviewDirty = true; } else { ((BaseUnityPlugin)this).Config.Save(); ((BaseUnityPlugin)this).Config.SaveOnConfigSet = _previousSaveOnConfigSet; Cursor.lockState = _previousCursorLock; Cursor.visible = _previousCursorVisible; } } } private void ResetCustomSettings() { //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) _customNorth.Value = true; _customSouth.Value = true; _customEast.Value = true; _customWest.Value = true; _customArmLength.Value = 8f; _customArmThickness.Value = 2f; _customGap.Value = 4f; _customCircleDiameter.Value = 0f; _customCircleThickness.Value = 2f; _customDotThickness.Value = 0f; _customColor.Value = new Color(0.45f, 0.9f, 1f, 1f); _customOpacity.Value = 0.8f; _customOutlineThickness.Value = 0f; _customOutlineColor.Value = Color.black; _customOutlineOpacity.Value = 0.9f; _ghostScale.Value = 1.5f; } private void OnDestroy() { SetCustomizerVisible(visible: false); _view?.Dispose(); _view = null; if ((Object)(object)_customPreview != (Object)null) { Object.Destroy((Object)(object)_customPreview); _customPreview = null; } if ((Object)(object)_customizerSkin != (Object)null) { Object.Destroy((Object)(object)_customizerSkin); _customizerSkin = null; } foreach (Texture2D customizerTexture in _customizerTextures) { if ((Object)(object)customizerTexture != (Object)null) { Object.Destroy((Object)(object)customizerTexture); } } _customizerTextures.Clear(); } } internal sealed class GhostCrosshairView : IDisposable { private const float MinimumSurfaceClearance = 0.035f; private const float MinimumPixelSize = 8f; private readonly Hud _hud; private readonly GameObject _gameObject; private readonly Transform _transform; private readonly SpriteRenderer _renderer; private readonly float _sourcePixelHeight; private readonly Sprite _ownedSprite; private readonly Texture2D _ownedTexture; private GhostCrosshairView(Hud hud, GameObject gameObject, SpriteRenderer renderer, float sourcePixelHeight, Sprite ownedSprite, Texture2D ownedTexture) { _hud = hud; _gameObject = gameObject; _transform = gameObject.transform; _renderer = renderer; _sourcePixelHeight = sourcePixelHeight; _ownedSprite = ownedSprite; _ownedTexture = ownedTexture; } internal static GhostCrosshairView TryCreate(Hud hud, CrosshairStyle style) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown //IL_00da: 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_007c: 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_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) Image val = (((Object)(object)hud != (Object)null) ? hud.m_crosshair : null); if ((Object)(object)val == (Object)null || (Object)(object)val.sprite == (Object)null) { return null; } GameObject val2 = new GameObject("DynamicAimPoint_WorldImpactMarker", new Type[1] { typeof(SpriteRenderer) }); SpriteRenderer component = val2.GetComponent<SpriteRenderer>(); Sprite ownedSprite = null; Texture2D texture = null; float pixelHeight; if (style.UseMainCrosshair) { component.sprite = val.sprite; Color color = ((Graphic)val).color; color.a *= style.Color.a; component.color = color; Rect rect = ((Graphic)val).rectTransform.rect; pixelHeight = ((Rect)(ref rect)).height; if (pixelHeight < 8f) { rect = val.sprite.rect; pixelHeight = ((Rect)(ref rect)).height; } } else { ownedSprite = (component.sprite = CreateProceduralSprite(style, out texture, out pixelHeight)); component.color = Color.white; } if ((Object)(object)component.sprite == (Object)null) { Object.Destroy((Object)(object)val2); return null; } ((Renderer)component).sortingOrder = 32767; ((Renderer)component).enabled = false; return new GhostCrosshairView(hud, val2, component, Mathf.Max(8f, pixelHeight), ownedSprite, texture); } private static Sprite CreateProceduralSprite(CrosshairStyle style, out Texture2D texture, out float pixelHeight) { //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Expected O, but got Unknown //IL_0414: Unknown result type (might be due to invalid IL or missing references) //IL_0423: Unknown result type (might be due to invalid IL or missing references) //IL_033d: Unknown result type (might be due to invalid IL or missing references) //IL_0342: Unknown result type (might be due to invalid IL or missing references) //IL_03cc: Unknown result type (might be due to invalid IL or missing references) //IL_03c4: Unknown result type (might be due to invalid IL or missing references) //IL_03d1: Unknown result type (might be due to invalid IL or missing references) float num = style.Gap + style.ArmLength + style.ArmThickness * 0.5f; float num2 = style.CircleDiameter * 0.5f + style.CircleThickness * 0.5f; float num3 = style.DiamondDiameter * 0.5f + style.DiamondThickness * 0.5f; float num4 = style.CenterDotDiameter * 0.5f; int num5 = Mathf.Clamp(Mathf.CeilToInt((Mathf.Max(num, Mathf.Max(num2, Mathf.Max(num3, num4))) + style.OutlineThickness) * 2f + 4f), 8, 256); pixelHeight = num5; texture = new Texture2D(num5, num5, (TextureFormat)4, false); ((Object)texture).name = "DynamicAimPoint_CustomCrosshair"; ((Texture)texture).filterMode = (FilterMode)0; ((Texture)texture).wrapMode = (TextureWrapMode)1; Color[] array = (Color[])(object)new Color[num5 * num5]; bool[] array2 = new bool[num5 * num5]; float num6 = ((float)num5 - 1f) * 0.5f; float num7 = Mathf.Max(0.5f, style.ArmThickness * 0.5f); float num8 = Mathf.Max(0.5f, style.CircleThickness * 0.5f); float num9 = style.CircleDiameter * 0.5f; float num10 = style.DiamondDiameter * 0.5f; float num11 = Mathf.Max(0.5f, style.DiamondThickness * 0.5f); float num12 = style.CenterDotDiameter * 0.5f; for (int i = 0; i < num5; i++) { float num13 = (float)i - num6; for (int j = 0; j < num5; j++) { float num14 = (float)j - num6; float num15 = Mathf.Sqrt(num14 * num14 + num13 * num13); bool flag = num12 > 0f && num15 <= num12; flag |= num9 > 0f && Mathf.Abs(num15 - num9) <= num8; flag |= num10 > 0f && Mathf.Abs(Mathf.Abs(num14) + Mathf.Abs(num13) - num10) <= num11; flag |= style.East && num14 >= style.Gap && num14 <= style.Gap + style.ArmLength && Mathf.Abs(num13) <= num7; flag |= style.West && 0f - num14 >= style.Gap && 0f - num14 <= style.Gap + style.ArmLength && Mathf.Abs(num13) <= num7; flag |= style.North && num13 >= style.Gap && num13 <= style.Gap + style.ArmLength && Mathf.Abs(num14) <= num7; flag |= style.South && 0f - num13 >= style.Gap && 0f - num13 <= style.Gap + style.ArmLength && Mathf.Abs(num14) <= num7; array2[i * num5 + j] = flag; } } int num16 = Mathf.CeilToInt(style.OutlineThickness); float num17 = style.OutlineThickness * style.OutlineThickness; for (int k = 0; k < num5; k++) { for (int l = 0; l < num5; l++) { int num18 = k * num5 + l; if (array2[num18]) { array[num18] = style.Color; continue; } bool flag2 = false; for (int m = -num16; m <= num16; m++) { if (flag2) { break; } int num19 = k + m; if (num19 < 0 || num19 >= num5) { continue; } for (int n = -num16; n <= num16; n++) { int num20 = l + n; if (num20 >= 0 && num20 < num5 && !((float)(n * n + m * m) > num17) && array2[num19 * num5 + num20]) { flag2 = true; break; } } } array[num18] = (flag2 ? style.OutlineColor : Color.clear); } } texture.SetPixels(array); texture.Apply(false, true); return Sprite.Create(texture, new Rect(0f, 0f, (float)num5, (float)num5), new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)0); } internal static Texture2D CreatePreviewTexture(CrosshairStyle style) { Texture2D texture; float pixelHeight; Sprite val = CreateProceduralSprite(style, out texture, out pixelHeight); if ((Object)(object)val != (Object)null) { Object.Destroy((Object)(object)val); } return texture; } internal bool BelongsTo(Hud hud) { if ((Object)(object)_hud == (Object)(object)hud) { return (Object)(object)_gameObject != (Object)null; } return false; } internal void Show(Vector3 impactPoint, Camera camera, float scale) { //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_00a2: 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_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: 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) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: 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) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0138: 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) if (!((Object)(object)_gameObject == (Object)null) && !((Object)(object)camera == (Object)null) && !((Object)(object)_renderer.sprite == (Object)null)) { float num = Vector3.Distance(((Component)camera).transform.position, impactPoint); float num2 = ((!camera.orthographic) ? (2f * num * Mathf.Tan(camera.fieldOfView * 0.5f * ((float)Math.PI / 180f)) * (_sourcePixelHeight / (float)camera.pixelHeight)) : (camera.orthographicSize * 2f * (_sourcePixelHeight / (float)camera.pixelHeight))); Bounds bounds = _renderer.sprite.bounds; float num3 = Mathf.Max(0.0001f, ((Bounds)(ref bounds)).size.y); float num4 = num2 / num3 * scale; float num5 = Mathf.Max(0.035f, num2 * scale * 0.75f); Vector3 val = ((Component)camera).transform.position - impactPoint; Vector3 normalized = ((Vector3)(ref val)).normalized; _transform.position = impactPoint + normalized * num5; _transform.rotation = Quaternion.LookRotation(((Component)camera).transform.forward, ((Component)camera).transform.up); _transform.localScale = Vector3.one * num4; ((Renderer)_renderer).enabled = true; } } internal void Hide() { if ((Object)(object)_renderer != (Object)null) { ((Renderer)_renderer).enabled = false; } } public void Dispose() { if ((Object)(object)_gameObject != (Object)null) { Object.Destroy((Object)(object)_gameObject); } if ((Object)(object)_ownedSprite != (Object)null) { Object.Destroy((Object)(object)_ownedSprite); } if ((Object)(object)_ownedTexture != (Object)null) { Object.Destroy((Object)(object)_ownedTexture); } } } internal struct LaunchData { internal Vector3 Origin; internal Vector3 Direction; internal float Speed; internal float Gravity; internal float Drag; internal float TimeToLive; internal float Radius; internal bool OwnerRayTest; internal bool HasBallistics; } internal static class ProjectileAimResolver { private const int HitBufferSize = 64; private const float MinimumStepDistance = 0.0001f; private const float MaximumSimulationTime = 15f; private static readonly RaycastHit[] HitBuffer = (RaycastHit[])(object)new RaycastHit[64]; private static readonly int ProjectileMask = LayerMask.GetMask(new string[12] { "Default", "static_solid", "Default_small", "piece", "piece_nonsolid", "terrain", "character", "character_net", "character_ghost", "hitbox", "character_noenv", "vehicle" }); internal static bool TryBuildLaunch(Player player, Attack attack, out LaunchData launch) { //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: 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_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) launch = default(LaunchData); if (!ValheimAccess.TryGetProjectileSpawnPoint(player, attack, out var spawnPoint, out var aimDirection)) { return false; } ItemData obj = ValheimAccess.GetAttackAmmo(attack) ?? ((Humanoid)player).GetAmmoItem(); GameObject attackProjectile = attack.m_attackProjectile; float num = attack.m_projectileVel; float num2 = attack.m_projectileVelMin; AnimationCurve drawVelocityCurve = attack.m_drawVelocityCurve; Attack val = obj?.m_shared?.m_attack; if (val != null && (Object)(object)val.m_attackProjectile != (Object)null) { attackProjectile = val.m_attackProjectile; num += val.m_projectileVel; num2 += val.m_projectileVelMin; drawVelocityCurve = val.m_drawVelocityCurve; } if (!Mathf.Approximately(attack.m_launchAngle, 0f)) { Vector3 val2 = Vector3.Cross(Vector3.up, aimDirection); if (((Vector3)(ref val2)).sqrMagnitude > 0.0001f) { aimDirection = Quaternion.AngleAxis(attack.m_launchAngle, val2) * aimDirection; } } float num3 = num; if (attack.m_bowDraw) { float num4 = (ValheimAccess.IsCurrentAttack(player, attack) ? Mathf.Clamp01(((Humanoid)player).GetAttackDrawPercentage()) : 1f); float num5 = ((drawVelocityCurve != null && drawVelocityCurve.length > 0) ? drawVelocityCurve.Evaluate(num4) : num4); num3 = Mathf.Lerp(num2, num, num5); } Projectile val3 = (((Object)(object)attackProjectile != (Object)null) ? attackProjectile.GetComponent<Projectile>() : null); launch.Origin = spawnPoint; launch.Direction = ((Vector3)(ref aimDirection)).normalized; launch.Speed = num3; launch.Gravity = (((Object)(object)val3 != (Object)null) ? val3.m_gravity : 0f); launch.Drag = (((Object)(object)val3 != (Object)null) ? val3.m_drag : 0f); launch.TimeToLive = (((Object)(object)val3 != (Object)null && val3.m_ttl > 0f) ? val3.m_ttl : 15f); launch.Radius = (((Object)(object)val3 != (Object)null) ? Mathf.Max(0f, val3.m_rayRadius) : 0f); launch.OwnerRayTest = (Object)(object)val3 != (Object)null && val3.m_doOwnerRaytest; launch.HasBallistics = (Object)(object)val3 != (Object)null && num3 > 0.01f; return ((Vector3)(ref launch.Direction)).sqrMagnitude > 0.0001f; } internal static bool TryFindImpact(Player owner, LaunchData launch, float maximumDistance, float closeRangeDistance, float muzzlePoseTolerance, out RaycastHit impact) { //IL_0047: 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_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) //IL_005e: 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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: 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_00cb: 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_00db: Unknown result type (might be due to invalid IL or missing references) //IL_0084: 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_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0283: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: 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) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0158: 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_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0168: 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_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0147: 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_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_0198: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_019c: 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_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) if (!launch.HasBallistics) { float num = Mathf.Min(maximumDistance, closeRangeDistance); if (num > 0f && TryCast(owner, launch.Origin, launch.Direction, num, launch.Radius + muzzlePoseTolerance, out impact)) { return true; } float num2 = maximumDistance - num; Vector3 origin = launch.Origin + launch.Direction * num; if (num2 > 0f) { return TryCast(owner, origin, launch.Direction, num2, launch.Radius, out impact); } impact = default(RaycastHit); return false; } float num3 = ((Time.fixedDeltaTime > 0f) ? Time.fixedDeltaTime : 0.02f); float num4 = Mathf.Min(launch.TimeToLive, 15f); float num5 = 0f; float num6 = 0f; Vector3 val = launch.Origin; Vector3 val2 = launch.Direction * launch.Speed; bool flag = launch.OwnerRayTest; for (; num5 < num4; num5 += num3) { if (!(num6 < maximumDistance)) { break; } val2 += Vector3.down * (launch.Gravity * num3); if (!Mathf.Approximately(launch.Drag, 0f) && ((Vector3)(ref val2)).sqrMagnitude > 0.0001f) { float num7 = ((Vector3)(ref val2)).sqrMagnitude * launch.Drag * num3; val2 -= ((Vector3)(ref val2)).normalized * num7; } Vector3 val3 = val + val2 * num3; Vector3 val4 = val3 - val; float num8 = ((Vector3)(ref val4)).magnitude; if (num8 <= 0.0001f) { break; } float num9 = maximumDistance - num6; if (num8 > num9) { val4 = ((Vector3)(ref val4)).normalized * num9; val3 = val + val4; num8 = num9; } Vector3 val5; float num10; Vector3 val7; if (flag) { val5 = ((Character)owner).GetCenterPoint(); val5.y = launch.Origin.y; Vector3 val6 = val3 - val5; num10 = ((Vector3)(ref val6)).magnitude; val7 = ((num10 > 0.0001f) ? (val6 / num10) : ((Vector3)(ref val4)).normalized); } else { val7 = ((Vector3)(ref val4)).normalized; val5 = val - val7 * (num8 * 0.5f); num10 = ((launch.Radius > 0f) ? num8 : (num8 * 1.5f)); } float num11 = launch.Radius; if (num6 < closeRangeDistance) { num11 += muzzlePoseTolerance; } if (num10 > 0.0001f && TryCast(owner, val5, val7, num10, num11, out impact)) { return true; } flag = false; val = val3; num6 += num8; } impact = default(RaycastHit); return false; } private static bool TryCast(Player owner, Vector3 origin, Vector3 direction, float distance, float radius, out RaycastHit closestHit) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0029: 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_0012: 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_0051: 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_008a: Unknown result type (might be due to invalid IL or missing references) closestHit = default(RaycastHit); int num = ((radius > 0f) ? Physics.SphereCastNonAlloc(origin, radius, direction, HitBuffer, distance, ProjectileMask, (QueryTriggerInteraction)0) : Physics.RaycastNonAlloc(origin, direction, HitBuffer, distance, ProjectileMask, (QueryTriggerInteraction)0)); float num2 = float.MaxValue; for (int i = 0; i < num; i++) { RaycastHit val = HitBuffer[i]; if (!((Object)(object)((RaycastHit)(ref val)).collider == (Object)null) && !(((RaycastHit)(ref val)).distance >= num2) && !((Object)(object)((Component)((RaycastHit)(ref val)).collider).GetComponentInParent<Character>() == (Object)(object)owner)) { num2 = ((RaycastHit)(ref val)).distance; closestHit = val; } } return num2 < float.MaxValue; } } internal static class ValheimAccess { private const BindingFlags InstanceMembers = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; private static readonly FieldInfo CurrentAttackField = typeof(Humanoid).GetField("m_currentAttack", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); private static readonly FieldInfo AttackAmmoField = typeof(Attack).GetField("m_ammoItem", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); internal static bool IsCompatible(out string error) { if (CurrentAttackField == null || AttackAmmoField == null) { error = "TrueFlight Crosshair is incompatible with this Valheim version: required attack members were not found."; return false; } error = null; return true; } internal static bool TryGetCurrentAttack(Player player, out Attack attack) { object? value = CurrentAttackField.GetValue(player); attack = (Attack)((value is Attack) ? value : null); return attack != null; } internal static bool IsCurrentAttack(Player player, Attack attack) { object? value = CurrentAttackField.GetValue(player); return ((value is Attack) ? value : null) == attack; } internal static ItemData GetAttackAmmo(Attack attack) { object? value = AttackAmmoField.GetValue(attack); return (ItemData)((value is ItemData) ? value : null); } internal static bool TryGetProjectileSpawnPoint(Player player, Attack attack, out Vector3 spawnPoint, out Vector3 aimDirection) { //IL_0008: 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_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Invalid comparison between Unknown and I4 //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Invalid comparison between Unknown and I4 //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0039: 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_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: 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_0090: 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_0098: Unknown result type (might be due to invalid IL or missing references) //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_00a8: 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_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: 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_00c2: Unknown result type (might be due to invalid IL or missing references) //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_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: 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_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00de: 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_00eb: 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) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: 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_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0126: 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_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) Transform transform = ((Component)player).transform; Quaternion rotation = transform.rotation; Quaternion val = (((int)attack.m_attackType != 3 && (!player.AttackTowardsPlayerLookDir || (int)attack.m_attackType == 2)) ? ((Character)player).GetLookYaw() : rotation); Quaternion val2 = val * Quaternion.Inverse(rotation); Transform val3 = transform; if (!string.IsNullOrEmpty(attack.m_attackOriginJoint)) { GameObject visual = ((Character)player).GetVisual(); Transform val4 = (((Object)(object)visual != (Object)null) ? Utils.FindChild(visual.transform, attack.m_attackOriginJoint, (IterativeSearchType)0) : null); if ((Object)(object)val4 != (Object)null) { val3 = val4; } } Vector3 val5 = transform.position + val2 * (val3.position - transform.position); Vector3 val6 = val * Vector3.up; Vector3 val7 = val * Vector3.forward; Vector3 val8 = val * Vector3.right; spawnPoint = val5 + val6 * attack.m_attackHeight + val7 * attack.m_attackRange + val8 * attack.m_attackOffset; aimDirection = ((Humanoid)player).GetAimDir(spawnPoint); if (attack.m_useCharacterFacing) { Vector3 forward = Vector3.forward; if (attack.m_useCharacterFacingYAim) { forward.y = aimDirection.y; } aimDirection = val * forward; } return ((Vector3)(ref aimDirection)).sqrMagnitude > 0.0001f; } } }