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 AxtralProjection v0.2.1
BepInEx/plugins/Haragon-AxtralProjection/AxtralProjection.Core.dll
Decompiled 18 hours agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using Microsoft.CodeAnalysis; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")] [assembly: AssemblyCompany("AxtralProjection.Core")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+446011a9c1867e7a5f5616b6cf2079108c0d6003")] [assembly: AssemblyProduct("AxtralProjection.Core")] [assembly: AssemblyTitle("AxtralProjection.Core")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [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 AxtralProjection.Core { public static class AimInput { public static bool CanBegin(bool mainKeyDown, IEnumerable<bool> configuredModifiersHeld) { if (mainKeyDown) { return configuredModifiersHeld.All((bool held) => held); } return false; } public static bool Held(bool controllerAim, bool mainKeyHeld, bool controllerHeld) { if (!controllerAim) { return mainKeyHeld; } return controllerHeld; } } public enum CastFailure { None, InvalidState, Cooldown, Skill, Axe, NoTargets, Elder } public sealed class CastGate { public bool Aiming { get; private set; } public CastFailure Begin(double skill, bool axe, double requiredSkill, bool exhausted, bool elderAllowed = true) { if (Aiming) { return CastFailure.InvalidState; } CastFailure castFailure = Check(skill, axe, requiredSkill, exhausted, elderAllowed); Aiming = castFailure == CastFailure.None; return castFailure; } public CastFailure Release(double skill, bool axe, double requiredSkill, bool exhausted, int targets, bool elderAllowed = true) { if (!Aiming) { return CastFailure.InvalidState; } Aiming = false; CastFailure castFailure = Check(skill, axe, requiredSkill, exhausted, elderAllowed); if (castFailure == CastFailure.None) { if (targets <= 0) { return CastFailure.NoTargets; } return CastFailure.None; } return castFailure; } private static CastFailure Check(double skill, bool axe, double requiredSkill, bool exhausted, bool elderAllowed = true) { if (double.IsNaN(skill) || double.IsInfinity(skill) || double.IsNaN(requiredSkill) || double.IsInfinity(requiredSkill) || requiredSkill < 0.0) { return CastFailure.InvalidState; } if (!elderAllowed) { return CastFailure.Elder; } if (exhausted) { return CastFailure.Cooldown; } if (skill < requiredSkill) { return CastFailure.Skill; } if (!axe) { return CastFailure.Axe; } return CastFailure.None; } public void Cancel() { Aiming = false; } } public static class Cone { public static bool Contains(double dx, double dy, double dz, double forwardX, double forwardZ, double range, double fullAngleDegrees) { if (!Finite(dx) || !Finite(dy) || !Finite(dz) || !Finite(forwardX) || !Finite(forwardZ) || !Finite(range) || !Finite(fullAngleDegrees) || range <= 0.0 || fullAngleDegrees <= 0.0 || fullAngleDegrees > 180.0) { return false; } double num = Math.Sqrt(forwardX * forwardX + forwardZ * forwardZ); if (num < 1E-08 || dx * dx + dy * dy + dz * dz > range * range + 1E-08) { return false; } double num2 = Math.Sqrt(dx * dx + dz * dz); if (num2 < 1E-08) { return true; } return (dx * forwardX + dz * forwardZ) / (num2 * num) + 1E-08 >= Math.Cos(fullAngleDegrees * Math.PI / 360.0); } private static bool Finite(double v) { if (!double.IsNaN(v)) { return !double.IsInfinity(v); } return false; } } public static class ConfigBounds { public static float Clamp(float value, float min, float max, float fallback) { if (!float.IsNaN(value) && !float.IsInfinity(value)) { return Math.Max(min, Math.Min(max, value)); } return fallback; } public static int Clamp(int value, int min, int max) { return Math.Max(min, Math.Min(max, value)); } } public static class DurabilityRules { public static float Cost(float max, float percent) { return Math.Max(0f, max) * ConfigBounds.Clamp(percent, 0f, 25f, 0f) / 100f; } public static bool CanHit(bool present, bool usesDurability, float current) { if (present) { if (usesDurability) { return current > 0f; } return true; } return false; } public static float AfterHit(float current, float max, float percent, bool usesDurability, bool stump) { if (!(!usesDurability || stump) && !(percent <= 0f)) { return Math.Max(0f, current - Cost(max, percent)); } return current; } } public enum ElderRequirement { None, Slotted, Active } public static class ElderRules { public static bool Allowed(ElderRequirement mode, bool slotted, bool active) { return mode switch { ElderRequirement.None => true, ElderRequirement.Slotted => slotted, ElderRequirement.Active => active, _ => false, }; } } public static class TargetRules { public static bool IsStump(string prefabName) { if (!string.IsNullOrEmpty(prefabName)) { return prefabName.EndsWith("Stub", StringComparison.OrdinalIgnoreCase); } return false; } public static bool Eligible(bool supportedKind, bool wardAllowed, int minimumTier, int axeTier) { if (supportedKind && wardAllowed && axeTier >= 0 && minimumTier >= 0) { return axeTier >= minimumTier; } return false; } } public static class TargetSelection { public static string Name(string name) { return name.Replace("(Clone)", "").Trim(); } public static HashSet<string> Parse(string names) { return new HashSet<string>(from n in (names ?? "").Split(new char[1] { ',' }).Select(Name) where n.Length > 0 select n, StringComparer.Ordinal); } public static bool Allowed(string name, bool tree, bool stump, bool clearStumps, ISet<string> additional, ISet<string> excluded) { name = Name(name); if (excluded.Contains(name) || (stump && !clearStumps)) { return false; } if (!tree && !(stump && clearStumps) && !IsUncappedSapling(name)) { return additional.Contains(name); } return true; } public static bool IsUncappedSapling(string name) { if (!(Name(name) == "Beech_small1")) { return Name(name) == "Beech_small2"; } return true; } public static List<T> Nearest<T>(IEnumerable<T> targets, Func<T, double> forward, int maximum, Func<T, bool>? countsTowardLimit = null) { int num = Math.Max(0, maximum); List<T> list = new List<T>(); foreach (T item in targets.OrderBy(forward)) { if (countsTowardLimit == null || countsTowardLimit(item)) { if (num == 0) { continue; } num--; } list.Add(item); } return list; } } public static class Trapezoid { public static bool Contains(double dx, double dy, double dz, double fx, double fz, double range, double width, double angle) { double[] array = new double[8] { dx, dy, dz, fx, fz, range, width, angle }; foreach (double d in array) { if (double.IsNaN(d) || double.IsInfinity(d)) { return false; } } double num = Math.Sqrt(fx * fx + fz * fz); if (num <= 0.0 || range < 0.0 || width < 0.0 || angle < 0.0 || angle >= 180.0 || Math.Abs(dy) > 10.0) { return false; } fx /= num; fz /= num; double num2 = dx * fx + dz * fz; if (num2 < 0.0 || num2 > range) { return false; } return Math.Abs(dx * fz - dz * fx) <= width / 2.0 + Math.Max(num2, 0.0) * Math.Tan(angle * Math.PI / 360.0); } } }
BepInEx/plugins/Haragon-AxtralProjection/AxtralProjection.dll
Decompiled 18 hours agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using AxtralProjection.Core; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Jotunn.Utils; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("AxtralProjection")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.2.1.0")] [assembly: AssemblyInformationalVersion("0.2.1+446011a9c1867e7a5f5616b6cf2079108c0d6003")] [assembly: AssemblyProduct("AxtralProjection")] [assembly: AssemblyTitle("AxtralProjection")] [assembly: AssemblyVersion("0.2.1.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [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 AxtralProjection { internal sealed class PreviewEffects { private sealed class Highlight { private readonly List<(Renderer renderer, MaterialPropertyBlock original)> blocks = new List<(Renderer, MaterialPropertyBlock)>(); private readonly GameObject marker; public Highlight(Target target, Material? mat) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Expected O, but got Unknown //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0081: 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_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_011f: 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_013d: 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) Renderer[] componentsInChildren = target.Object.GetComponentsInChildren<Renderer>(); foreach (Renderer val in componentsInChildren) { MaterialPropertyBlock val2 = new MaterialPropertyBlock(); val.GetPropertyBlock(val2); MaterialPropertyBlock val3 = new MaterialPropertyBlock(); val.GetPropertyBlock(val3); val3.SetColor("_Color", new Color(0.15f, 1f, 0.3f)); val3.SetColor("_EmissionColor", new Color(0f, 0.7f, 0.1f)); val.SetPropertyBlock(val3); blocks.Add((val, val2)); } LineRenderer val4 = SpellEffects.Line("Axtral eligible target", mat, 0.09f); marker = ((Component)val4).gameObject; val4.positionCount = 33; Vector3 val5 = target.Position + Vector3.up * 0.25f; Vector3[] array = (Vector3[])(object)new Vector3[33]; for (int j = 0; j < 33; j++) { float num = (float)j * (float)Math.PI * 2f / 32f; array[j] = val5 + new Vector3(Mathf.Sin(num), 0f, Mathf.Cos(num)) * 0.8f; } val4.SetPositions(array); } public void Dispose() { foreach (var block in blocks) { if (Object.op_Implicit((Object)(object)block.renderer)) { block.renderer.SetPropertyBlock(block.original); } } if (Object.op_Implicit((Object)(object)marker)) { Object.Destroy((Object)(object)marker); } } } private readonly Dictionary<int, Highlight> highlights = new Dictionary<int, Highlight>(); private Material? material; private LineRenderer? cone; public void Set(List<Target> targets, Vector3 origin, Vector3 forward, float range, float angle, float width) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: 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_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: 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_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: 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_01fe: 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_0206: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0212: 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_021a: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_024c: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_0272: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_02f8: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: Unknown result type (might be due to invalid IL or missing references) //IL_02b3: Unknown result type (might be due to invalid IL or missing references) //IL_02cf: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)material)) { material = SpellEffects.Material(new Color(0.15f, 1f, 0.3f)); } HashSet<int> ids = new HashSet<int>(from t in targets where Object.op_Implicit((Object)(object)t.Object) select ((Object)t.Object).GetInstanceID()); int[] array = highlights.Keys.Where((int id) => !ids.Contains(id)).ToArray(); foreach (int key in array) { highlights[key].Dispose(); highlights.Remove(key); } foreach (Target target in targets) { if (Object.op_Implicit((Object)(object)target.Object) && !highlights.ContainsKey(((Object)target.Object).GetInstanceID())) { highlights.Add(((Object)target.Object).GetInstanceID(), new Highlight(target, material)); } } if (!Object.op_Implicit((Object)(object)cone)) { cone = SpellEffects.Line("Axtral aim cone", material, 0.06f); } Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(forward.z, 0f, 0f - forward.x); Vector3 val2 = origin + Vector3.up * 0.2f; float num2 = width / 2f; float num3 = num2 + range * Mathf.Tan(angle * ((float)Math.PI / 180f) / 2f); Vector3[] array2 = (Vector3[])(object)new Vector3[4] { val2 - val * num2, val2 + val * num2, val2 + forward * range + val * num3, val2 + forward * range - val * num3 }; List<Vector3> list = new List<Vector3>(); float num7 = default(float); for (int num4 = 0; num4 < array2.Length; num4++) { Vector3 val3 = array2[num4]; Vector3 val4 = array2[(num4 + 1) % array2.Length]; int num5 = Mathf.Max(1, Mathf.CeilToInt(Vector3.Distance(val3, val4))); for (int num6 = 0; num6 < num5; num6++) { Vector3 val5 = Vector3.Lerp(val3, val4, (float)num6 / (float)num5); if (Heightmap.GetHeight(val5, ref num7)) { val5.y = num7 + 0.2f; } list.Add(val5); } } list.Add(list[0]); cone.positionCount = list.Count; cone.SetPositions(list.ToArray()); } public void Clear() { foreach (Highlight value in highlights.Values) { value.Dispose(); } highlights.Clear(); if (Object.op_Implicit((Object)(object)cone)) { Object.Destroy((Object)(object)((Component)cone).gameObject); } cone = null; } public void Dispose() { Clear(); if (Object.op_Implicit((Object)(object)material)) { Object.Destroy((Object)(object)material); } material = null; } } internal static class SpellEffects { public static Material? Material(Color color) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown Shader val = Shader.Find("Unlit/Color") ?? Shader.Find("Sprites/Default") ?? Shader.Find("Standard"); if (!Object.op_Implicit((Object)(object)val)) { return null; } return new Material(val) { color = color }; } public static LineRenderer Line(string name, Material? material, float width) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_002f: 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) LineRenderer obj = new GameObject(name) { layer = 2 }.AddComponent<LineRenderer>(); obj.useWorldSpace = true; obj.startWidth = width; obj.endWidth = width; ((Renderer)obj).sharedMaterial = material; obj.startColor = Color.white; obj.endColor = Color.white; return obj; } public static GameObject CreateAxe() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0079: 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_00ab: Expected O, but got Unknown //IL_00bd: 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_00cf: Expected O, but got Unknown //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: 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_0108: Unknown result type (might be due to invalid IL or missing references) //IL_011e: 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_0139: 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_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("Axtral astral axe") { layer = 2 }; GeneratedAssets generatedAssets = val.AddComponent<GeneratedAssets>(); Material val2 = (generatedAssets.Material = Material(new Color(0.25f, 0.8f, 1f))); GameObject obj = GameObject.CreatePrimitive((PrimitiveType)2); ((Object)obj).name = "Astral axe shaft"; obj.layer = 2; obj.transform.SetParent(val.transform, false); obj.transform.localScale = new Vector3(0.09f, 0.65f, 0.09f); Object.Destroy((Object)(object)obj.GetComponent<Collider>()); obj.GetComponent<Renderer>().sharedMaterial = val2; GameObject val3 = new GameObject("Astral crescent blade") { layer = 2 }; val3.transform.SetParent(val.transform, false); Mesh val4 = new Mesh { name = "Axtral procedural blade" }; val4.vertices = (Vector3[])(object)new Vector3[5] { new Vector3(0f, 0.6f, 0f), new Vector3(0.85f, 0.95f, 0f), new Vector3(1.05f, 0.5f, 0f), new Vector3(0.85f, 0.05f, 0f), new Vector3(0f, 0.3f, 0f) }; val4.triangles = new int[18] { 0, 1, 2, 0, 2, 4, 4, 2, 3, 2, 1, 0, 4, 2, 0, 3, 2, 4 }; val4.RecalculateNormals(); val4.RecalculateBounds(); generatedAssets.Mesh = val4; val3.AddComponent<MeshFilter>().sharedMesh = val4; ((Renderer)val3.AddComponent<MeshRenderer>()).sharedMaterial = val2; TrailRenderer obj2 = val.AddComponent<TrailRenderer>(); ((Renderer)obj2).sharedMaterial = val2; obj2.time = 0.25f; obj2.startWidth = 0.4f; obj2.endWidth = 0f; LineRenderer obj3 = Line("Axtral cutting wave", val2, 0.12f); ((Component)obj3).transform.SetParent(val.transform, false); obj3.positionCount = 25; return val; } public static void MoveAxe(GameObject axe, Vector3 position, Vector3 forward, float distance, float fullAngle) { //IL_0006: 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_0013: 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_002e: 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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: 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_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0071: 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_007b: 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_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_008c: Unknown result type (might be due to invalid IL or missing references) axe.transform.position = position; axe.transform.rotation = Quaternion.LookRotation(forward) * Quaternion.Euler(0f, 0f, distance * 100f); LineRenderer componentInChildren = axe.GetComponentInChildren<LineRenderer>(); Vector3[] array = (Vector3[])(object)new Vector3[25]; Vector3 val = position - forward * distance; for (int i = 0; i < 25; i++) { array[i] = val + Quaternion.AngleAxis((0f - fullAngle) / 2f + fullAngle * (float)i / 24f, Vector3.up) * forward * distance; } componentInChildren.SetPositions(array); } } public sealed class GeneratedAssets : MonoBehaviour { public Material? Material; public Mesh? Mesh; private void OnDestroy() { if (Object.op_Implicit((Object)(object)Material)) { Object.Destroy((Object)(object)Material); } if (Object.op_Implicit((Object)(object)Mesh)) { Object.Destroy((Object)(object)Mesh); } } } internal static class GameCompat { private static MethodInfo? message; private static ParameterInfo[]? parameters; public static ManualLogSource? Log { get; set; } public static void Message(Character character, MessageType type, string text) { //IL_0098: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)character)) { return; } try { if (message == null) { message = (from m in typeof(Character).GetMethods(BindingFlags.Instance | BindingFlags.Public) where m.Name == "Message" && m.GetParameters().Length >= 2 && m.GetParameters()[0].ParameterType == typeof(MessageType) && m.GetParameters()[1].ParameterType == typeof(string) orderby m.GetParameters().Length select m).First(); parameters = message.GetParameters(); } object[] array = new object[parameters.Length]; array[0] = type; array[1] = text; for (int num = 2; num < array.Length; num++) { array[num] = (parameters[num].HasDefaultValue ? parameters[num].DefaultValue : (parameters[num].ParameterType.IsValueType ? Activator.CreateInstance(parameters[num].ParameterType) : null)); } message.Invoke(character, array); } catch (Exception ex) { ManualLogSource? log = Log; if (log != null) { log.LogWarning((object)("HUD message failed: " + (ex.InnerException ?? ex).Message)); } } } public static void RaiseWoodCutting(Player player, float amount) { if (amount > 0f) { ((Character)player).RaiseSkill((SkillType)13, amount); } } } [BepInPlugin("haragon.AxtralProjectionValheim", "Axtral Projection", "0.2.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] public sealed class Plugin : BaseUnityPlugin { [HarmonyPatch(typeof(Humanoid), "StartAttack")] private static class PreventAttackWhileAiming { private static bool Prefix(Humanoid __instance) { if (!((Object)(object)instance == (Object)null) && instance.gate.Aiming) { return (Object)(object)__instance != (Object)(object)Player.m_localPlayer; } return true; } } public const string Version = "0.2.1"; public const string Guid = "haragon.AxtralProjectionValheim"; private static Plugin? instance; private Harmony harmony; private string gamepadButton = ""; private bool controllerAim; private ConfigEntry<KeyboardShortcut> castKey; private ConfigEntry<GamepadButton> gamepad; private ConfigEntry<float> range; private ConfigEntry<float> angle; private ConfigEntry<float> cooldown; private ConfigEntry<float> skill; private ConfigEntry<float> speed; private ConfigEntry<float> startWidth; private ConfigEntry<float> durability; private ConfigEntry<float> xp; private ConfigEntry<int> maxTrees; private ConfigEntry<ElderRequirement> elder; private ConfigEntry<bool> stumps; private ConfigEntry<string> additional; private ConfigEntry<string> excluded; private Player? player; private CastGate gate = new CastGate(); private ItemData? aimAxe; private List<Target> preview = new List<Target>(); private readonly PreviewEffects effects = new PreviewEffects(); private float nextPreview; private Coroutine? flight; private bool casting; private GameObject? axeVisual; private Exhaustion exhaustion; private Transform? posedArm; private Transform? posedForearm; private Quaternion originalArm; private Quaternion originalForearm; private float Range => ConfigBounds.Clamp(range.Value, 10f, 50f, 15f); private float Angle => ConfigBounds.Clamp(angle.Value, 0f, 45f, 30f); private float Cooldown => ConfigBounds.Clamp(cooldown.Value, 0f, 600f, 180f); private float RequiredSkill => ConfigBounds.Clamp(skill.Value, 0f, 100f, 15f); private float Speed => ConfigBounds.Clamp(speed.Value, 1f, 50f, 10f); private float StartWidth => ConfigBounds.Clamp(startWidth.Value, 0f, 3f, 1f); private float DurabilityPercent => ConfigBounds.Clamp(durability.Value, 0f, 25f, 2f); private float SkillXp => ConfigBounds.Clamp(xp.Value, 0f, 1f, 0f); private int MaxTrees => ConfigBounds.Clamp(maxTrees.Value, 2, 50); private bool IsExhausted(Player p) { return ((Character)p).GetSEMan().HaveStatusEffect(Exhaustion.Hash); } private void Awake() { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006e: 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_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Expected O, but got Unknown //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Expected O, but got Unknown //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Expected O, but got Unknown //IL_01ec: 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_01f9: Expected O, but got Unknown //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Expected O, but got Unknown //IL_029f: Unknown result type (might be due to invalid IL or missing references) //IL_02a4: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Expected O, but got Unknown //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02b6: Expected O, but got Unknown //IL_02df: Unknown result type (might be due to invalid IL or missing references) //IL_02e4: Unknown result type (might be due to invalid IL or missing references) //IL_02ec: Expected O, but got Unknown //IL_02ec: Unknown result type (might be due to invalid IL or missing references) //IL_02f6: Expected O, but got Unknown //IL_031b: Unknown result type (might be due to invalid IL or missing references) //IL_0320: Unknown result type (might be due to invalid IL or missing references) //IL_0328: Expected O, but got Unknown //IL_0328: Unknown result type (might be due to invalid IL or missing references) //IL_0332: Expected O, but got Unknown //IL_0348: Unknown result type (might be due to invalid IL or missing references) //IL_0352: Expected O, but got Unknown instance = this; GameCompat.Log = ((BaseUnityPlugin)this).Logger; castKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Controls", "CastKey", new KeyboardShortcut((KeyCode)103, Array.Empty<KeyCode>()), "Hold to aim; release to cast. Right mouse or Escape cancels."); gamepad = ((BaseUnityPlugin)this).Config.Bind<GamepadButton>("Controls", "GamepadButton", (GamepadButton)0, "Optional gamepad cast binding; None disables it to avoid vanilla conflicts."); ButtonConfig val = new ButtonConfig { Name = "AxtralProjectionGamepad", GamepadConfig = gamepad, ActiveInGUI = false, ActiveInCustomGUI = false }; InputManager.Instance.AddButton("haragon.AxtralProjectionValheim", val); gamepadButton = val.Name; castKey.SettingChanged += ControlsChanged; gamepad.SettingChanged += ControlsChanged; range = Synced("Range", 15f, 10f, 50f, "Maximum range in meters."); angle = Synced("ConeAngle", 30f, 0f, 45f, "Full cone width in degrees, not half-angle."); cooldown = Synced("Cooldown", 180f, 0f, 600f, "Cooldown in seconds after a successful cast."); skill = Synced("WoodCuttingLevel", 15f, 0f, 100f, "Required wood cutting skill level."); speed = Synced("TravelSpeed", 10f, 1f, 50f, "Astral wave travel speed in meters per second."); stumps = ((BaseUnityPlugin)this).Config.Bind<bool>("Spell", "ClearStumps", false, new ConfigDescription("Include existing tree stumps. Newly spawned stumps are left for a later cast.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); additional = ((BaseUnityPlugin)this).Config.Bind<string>("Spell", "AdditionalPrefabs", "", new ConfigDescription("Comma-separated exact Destructible prefab names from other mods.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); startWidth = Synced("StartWidth", 1f, 0f, 3f, "Full starting width in meters."); durability = Synced("DurabilityCostPercent", 2f, 0f, 25f, "Percent of axe max durability per tree hit; 0 disables."); xp = Synced("SkillXpPerTree", 0f, 0f, 1f, "Wood cutting skill gain per tree hit; 0 disables."); maxTrees = ((BaseUnityPlugin)this).Config.Bind<int>("Spell", "MaxTrees", 15, new ConfigDescription("Maximum counted targets per cast, nearest forward first. Beech_small1 and Beech_small2 do not consume a slot.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(2, 50), new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); excluded = ((BaseUnityPlugin)this).Config.Bind<string>("Spell", "ExcludedPrefabs", "", new ConfigDescription("Comma-separated exact prefab names to never fell. Exclusion wins.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); elder = ((BaseUnityPlugin)this).Config.Bind<ElderRequirement>("Spell", "ElderRequirement", (ElderRequirement)2, new ConfigDescription("None, Slotted (chosen Forsaken Power), or Active.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); exhaustion = new Exhaustion(); harmony = new Harmony("haragon.AxtralProjectionValheim"); harmony.PatchAll(typeof(Plugin).Assembly); SceneManager.sceneUnloaded += SceneUnloaded; ((BaseUnityPlugin)this).Logger.LogInfo((object)"Axtral Projection 0.2.1 loaded. Hold the configured shortcut to aim; release to cast."); } private ConfigEntry<float> Synced(string name, float value, float min, float max, string description) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown return ((BaseUnityPlugin)this).Config.Bind<float>("Spell", name, value, new ConfigDescription(description, (AcceptableValueBase)(object)new AcceptableValueRange<float>(min, max), new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); } private static bool InputBlocked() { if (Application.isFocused && Time.timeScale != 0f && !Console.IsVisible() && !InventoryGui.IsVisible() && !Menu.IsVisible() && !TextInput.IsVisible() && (!Object.op_Implicit((Object)(object)Chat.instance) || !Chat.instance.HasFocus())) { if (Object.op_Implicit((Object)(object)Minimap.instance)) { return Minimap.InTextInput(); } return false; } return true; } private static bool Unsafe(Player p) { if (!((Character)p).IsDead() && !((Character)p).IsTeleporting() && !((Character)p).InCutscene() && !((Character)p).InPlaceMode() && !((Character)p).InDodge() && !((Character)p).IsSwimming() && !((Character)p).IsAttached()) { return ((Character)p).InAttack(); } return true; } private static ItemData? BestAxe(Player p) { return (from i in ((Humanoid)p).GetInventory().GetAllItems() where (int)i.m_shared.m_skillType == 7 && i.GetDamage().m_chop > 0f && (!i.m_shared.m_useDurability || i.m_durability > 0f) orderby i.m_shared.m_toolTier descending, i.GetDamage().m_chop descending select i).FirstOrDefault(); } private static Vector3 Direction(Player p) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_003b: 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) //IL_002c: Unknown result type (might be due to invalid IL or missing references) Vector3 val = ((Character)p).GetLookDir(); val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude <= 0.001f) { val = ((Component)p).transform.forward; val.y = 0f; } return ((Vector3)(ref val)).normalized; } private bool HasElder(Player p) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return ElderRules.Allowed(elder.Value, p.GetGuardianPowerName() == "GP_TheElder", ((Character)p).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("GP_TheElder"))); } private bool KeyboardDown() { //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_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) KeyboardShortcut value = castKey.Value; if ((int)((KeyboardShortcut)(ref value)).MainKey != 0) { return AimInput.CanBegin(UnityInput.Current.GetKeyDown(((KeyboardShortcut)(ref value)).MainKey), ((KeyboardShortcut)(ref value)).Modifiers.Select((Func<KeyCode, bool>)UnityInput.Current.GetKey)); } return false; } private void Update() { try { RestorePose(); Tick(); } catch (Exception ex) { Cancel(); StopFlight(); ((BaseUnityPlugin)this).Logger.LogError((object)ex); Show("Axtral Projection failed; see BepInEx log."); } } private void Tick() { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_026d: 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_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_0161: 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_01db: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer != (Object)(object)player) { Cancel(); StopFlight(); player = localPlayer; gate = new CastGate(); } if (!Object.op_Implicit((Object)(object)player)) { return; } if (InputBlocked() || Unsafe(player)) { Cancel(); if (((Character)player).IsDead() || ((Character)player).IsTeleporting()) { StopFlight(); } return; } bool flag = KeyboardDown(); bool flag2 = (int)gamepad.Value != 0 && ZInput.GetButtonDown(gamepadButton); if (gate.Aiming) { if (Input.GetKeyDown((KeyCode)27) || Input.GetMouseButtonDown(1)) { Cancel(); return; } if (((Humanoid)player).GetCurrentWeapon() != aimAxe || BestAxe(player) != aimAxe) { Cancel(); Show("Axe changed: spell cancelled."); return; } bool num = controllerAim; IInputSystem current = UnityInput.Current; KeyboardShortcut value = castKey.Value; if (!AimInput.Held(num, current.GetKey(((KeyboardShortcut)(ref value)).MainKey), ZInput.GetButton(gamepadButton))) { Release(); } else if (Time.unscaledTime >= nextPreview) { preview = Targets.Find(((Component)player).transform.position, Direction(player), Range, Angle, aimAxe.m_shared.m_toolTier, stumps.Value, additional.Value, excluded.Value, StartWidth, MaxTrees); effects.Set(preview, ((Component)player).transform.position, Direction(player), Range, Angle, StartWidth); nextPreview = Time.unscaledTime + 0.1f; } } else if ((flag || flag2) && !casting) { ItemData val = BestAxe(player); CastFailure val2 = gate.Begin((double)((Character)player).GetSkillLevel((SkillType)13), val != null, (double)RequiredSkill, IsExhausted(player), HasElder(player)); if ((int)val2 != 0) { ShowFailure(val2); } else if (val == null || (((Humanoid)player).GetCurrentWeapon() != val && !((Humanoid)player).EquipItem(val, true))) { Cancel(); Show("Unable to equip axe."); } else { aimAxe = val; controllerAim = !flag && flag2; nextPreview = 0f; } } } private void Release() { //IL_0021: 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_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_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0131: 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_0155: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)player)) { Cancel(); return; } Player val = player; Vector3 position = ((Component)val).transform.position; Vector3 val2 = Direction(val); ItemData val3 = aimAxe; if (val3 == null || ((Humanoid)val).GetCurrentWeapon() != val3 || !((Humanoid)val).GetInventory().ContainsItem(val3) || (val3.m_shared.m_useDurability && val3.m_durability <= 0f)) { Cancel(); Show("Requires an equipped, unbroken woodcutting axe."); return; } if (!HasElder(val)) { Cancel(); ShowFailure((CastFailure)6); return; } float castRange = Range; float castAngle = Angle; float castSpeed = Speed; float castWidth = StartWidth; List<Target> list = Targets.Find(position, val2, castRange, castAngle, val3?.m_shared.m_toolTier ?? (-1), stumps.Value, additional.Value, excluded.Value, StartWidth, MaxTrees); CastFailure val4 = gate.Release((double)((Character)val).GetSkillLevel((SkillType)13), val3 != null, (double)RequiredSkill, IsExhausted(val), list.Count, HasElder(val)); effects.Clear(); preview.Clear(); aimAxe = null; if ((int)val4 != 0) { ShowFailure(val4); return; } if (!exhaustion.Apply(val, Cooldown)) { Show("Unable to apply Axtral Exhaustion; spell cancelled."); return; } Show("Axtral Projection cast!"); casting = true; flight = ((MonoBehaviour)this).StartCoroutine(Launch(val, position, val2, val3, list, castRange, castAngle, castSpeed, castWidth, DurabilityPercent, SkillXp)); } private IEnumerator Launch(Player p, Vector3 origin, Vector3 dir, ItemData axe, List<Target> targets, float castRange, float castAngle, float castSpeed, float castWidth, float costPercent, float xpPerTree) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) try { axeVisual = SpellEffects.CreateAxe(); float traveled = 0f; int index = 0; int tier = axe.m_shared.m_toolTier; float end = Mathf.Max(castRange, (targets.Count > 0) ? targets[targets.Count - 1].ForwardDistance(origin, dir) : 0f); while (traveled <= end && Object.op_Implicit((Object)(object)p) && !((Object)(object)p != (Object)(object)Player.m_localPlayer) && !((Character)p).IsDead() && !((Character)p).IsTeleporting() && DurabilityRules.CanHit(((Humanoid)p).GetInventory().ContainsItem(axe), axe.m_shared.m_useDurability, axe.m_durability)) { SpellEffects.MoveAxe(axeVisual, origin + Vector3.up * 1.5f + dir * traveled, dir, traveled, castAngle); while (index < targets.Count && (!Object.op_Implicit((Object)(object)targets[index].Object) || targets[index].ForwardDistance(origin, dir) <= traveled)) { if (!Object.op_Implicit((Object)(object)p) || (Object)(object)p != (Object)(object)Player.m_localPlayer || ((Character)p).IsDead() || ((Character)p).IsTeleporting()) { yield break; } Target target = targets[index++]; if (!Object.op_Implicit((Object)(object)target.Object)) { continue; } if (!DurabilityRules.CanHit(((Humanoid)p).GetInventory().ContainsItem(axe), axe.m_shared.m_useDurability, axe.m_durability)) { yield break; } bool flag = false; try { flag = Targets.Hit(target, p, origin, dir, tier, castRange, castAngle, castWidth); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Could not hit target: " + ex.Message)); } if (flag && !target.IsStump) { if (costPercent > 0f && axe.m_shared.m_useDurability) { axe.m_durability = DurabilityRules.AfterHit(axe.m_durability, axe.GetMaxDurability(), costPercent, true, false); } try { GameCompat.RaiseWoodCutting(p, xpPerTree); } catch (Exception ex2) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Wood cutting XP failed: " + ex2.Message)); } if (axe.m_shared.m_useDurability && axe.m_durability <= 0f) { Show("Your axe broke; Axtral Projection stopped."); yield break; } } } if (!(traveled >= end)) { yield return null; traveled = Mathf.Min(end, traveled + Time.deltaTime * castSpeed); continue; } break; } } finally { Plugin plugin = this; if (Object.op_Implicit((Object)(object)plugin.axeVisual)) { Object.Destroy((Object)(object)plugin.axeVisual); } plugin.axeVisual = null; plugin.flight = null; plugin.casting = false; } } private void Cancel() { RestorePose(); gate.Cancel(); effects.Clear(); preview.Clear(); aimAxe = null; } private void StopFlight() { if (flight != null) { ((MonoBehaviour)this).StopCoroutine(flight); } flight = null; casting = false; if (Object.op_Implicit((Object)(object)axeVisual)) { Object.Destroy((Object)(object)axeVisual); } axeVisual = null; } private void LateUpdate() { //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_0067: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: 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_00a0: 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_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) if (!gate.Aiming || !Object.op_Implicit((Object)(object)player)) { return; } Animator componentInChildren = ((Component)player).GetComponentInChildren<Animator>(); if (Object.op_Implicit((Object)(object)componentInChildren) && componentInChildren.isHuman) { Transform boneTransform = componentInChildren.GetBoneTransform((HumanBodyBones)14); Transform boneTransform2 = componentInChildren.GetBoneTransform((HumanBodyBones)16); if (Object.op_Implicit((Object)(object)boneTransform)) { posedArm = boneTransform; originalArm = boneTransform.localRotation; boneTransform.localRotation = originalArm * Quaternion.Euler(-95f, 0f, -25f); } if (Object.op_Implicit((Object)(object)boneTransform2)) { posedForearm = boneTransform2; originalForearm = boneTransform2.localRotation; boneTransform2.localRotation = originalForearm * Quaternion.Euler(-40f, 0f, 0f); } } } private void RestorePose() { //IL_0014: 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) if (Object.op_Implicit((Object)(object)posedArm)) { posedArm.localRotation = originalArm; } if (Object.op_Implicit((Object)(object)posedForearm)) { posedForearm.localRotation = originalForearm; } posedArm = null; posedForearm = null; } private void Show(string message) { if (Object.op_Implicit((Object)(object)player)) { GameCompat.Message((Character)(object)player, (MessageType)2, message); } } private void ShowFailure(CastFailure failure) { //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_001c: Expected I4, but got Unknown //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Invalid comparison between Unknown and I4 switch (failure - 2) { case 0: { float num; if (!Object.op_Implicit((Object)(object)player)) { num = 0f; } else { StatusEffect statusEffect = ((Character)player).GetSEMan().GetStatusEffect(Exhaustion.Hash); num = ((statusEffect != null) ? statusEffect.GetRemaningTime() : 0f); } Show($"Axtral Projection: {Math.Ceiling(num)}s cooldown."); break; } case 1: Show($"Requires Woodcutting level {RequiredSkill}."); break; case 2: Show("Requires an unbroken woodcutting axe in inventory."); break; case 4: Show(((int)elder.Value == 2) ? "Requires the Elder's power to be active." : "Requires the Elder's power to be your Forsaken Power."); break; case 3: Show("No eligible trees or stumps in the targeting volume."); break; default: Show("Spell cancelled."); break; } } private void OnGUI() { //IL_004a: 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_009a: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: 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_007f: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)player) && !InputBlocked() && gate.Aiming) { Rect val = new Rect((float)Screen.width / 2f - 220f, (float)Screen.height * 0.72f, 440f, 55f); object arg = preview.Count; string? arg2; if (!controllerAim) { KeyboardShortcut value = castKey.Value; arg2 = ((object)((KeyboardShortcut)(ref value)).MainKey/*cast due to .constrained prefix*/).ToString(); } else { arg2 = ((object)gamepad.Value/*cast due to .constrained prefix*/).ToString(); } GUI.Box(val, $"Axtral Projection — {arg} targets\nRelease {arg2} to cast · Right mouse to cancel"); } } private void ControlsChanged(object sender, EventArgs e) { Cancel(); } private void SceneUnloaded(Scene scene) { Cancel(); StopFlight(); } private void OnDisable() { Cancel(); StopFlight(); } private void OnDestroy() { SceneManager.sceneUnloaded -= SceneUnloaded; castKey.SettingChanged -= ControlsChanged; gamepad.SettingChanged -= ControlsChanged; Cancel(); StopFlight(); effects.Dispose(); Harmony obj = harmony; if (obj != null) { obj.UnpatchSelf(); } instance = null; } } public sealed class SE_AxtralExhaustion : StatusEffect { } internal sealed class Exhaustion { public const string EffectName = "SE_AxtralExhaustion"; private readonly SE_AxtralExhaustion template; public static int Hash => StringExtensionMethods.GetStableHashCode("SE_AxtralExhaustion"); public Exhaustion() { //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Expected O, but got Unknown template = ScriptableObject.CreateInstance<SE_AxtralExhaustion>(); ((Object)template).name = "SE_AxtralExhaustion"; ((StatusEffect)template).m_name = "Axtral Exhaustion"; ((StatusEffect)template).m_tooltip = "Axtral Projection is recharging."; ((StatusEffect)template).m_icon = CreateIcon(); ((StatusEffect)template).m_ttl = 180f; if (!ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)template, false))) { throw new InvalidOperationException("Axtral Exhaustion registration failed."); } } public bool Apply(Player player, float seconds) { if (seconds <= 0f) { return true; } StatusEffect val = (Object.op_Implicit((Object)(object)ObjectDB.instance) ? ObjectDB.instance.GetStatusEffect(Hash) : null); if (!Object.op_Implicit((Object)(object)val)) { return false; } val.m_ttl = seconds; return (Object)(object)((Character)player).GetSEMan().AddStatusEffect(Hash, true, 0, 0f, (short)(-1)) != (Object)null; } private static Sprite CreateIcon() { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("AxtralProjection.exhaustion_icon.png") ?? throw new InvalidOperationException("Missing embedded exhaustion icon."); using MemoryStream memoryStream = new MemoryStream(); stream.CopyTo(memoryStream); Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false); if (!AssetUtils.LoadImage(val, memoryStream.ToArray())) { Object.Destroy((Object)(object)val); throw new InvalidOperationException("Invalid exhaustion icon."); } return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f)); } } internal sealed class Target { public Component Object { get; } public IDestructible Damageable { get; } public Collider Collider { get; } public int MinimumTier { get; } public bool IsStump { get; } public bool CountsTowardLimit => !TargetSelection.IsUncappedSapling(((Object)Object.gameObject).name); public Vector3 Position => Object.transform.position; public float ForwardDistance(Vector3 origin, Vector3 forward) { //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_0011: Unknown result type (might be due to invalid IL or missing references) return Mathf.Max(0f, Vector3.Dot(Position - origin, forward)); } public Target(Component obj, IDestructible damageable, Collider collider, int tier, bool stump) { Object = obj; Damageable = damageable; Collider = collider; MinimumTier = tier; IsStump = stump; } } internal static class Targets { public static List<Target> Find(Vector3 origin, Vector3 forward, float range, float angle, int tier, bool stumps, string additionalNames, string excludedNames, float width, int maxTrees) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: 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) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Invalid comparison between Unknown and I4 //IL_01a9: 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_0213: 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_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_0235: 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) HashSet<string> hashSet = TargetSelection.Parse(additionalNames); HashSet<string> hashSet2 = TargetSelection.Parse(excludedNames); HashSet<int> hashSet3 = new HashSet<int>(); List<Target> list = new List<Target>(); Collider[] array = Physics.OverlapSphere(origin, Mathf.Sqrt(range * range + Mathf.Pow(width / 2f + range * Mathf.Tan(angle * ((float)Math.PI / 180f) / 2f), 2f) + 100f) + 2f, -1, (QueryTriggerInteraction)1); foreach (Collider val in array) { Component val2 = null; IDestructible val3 = null; int num = 0; bool flag = false; TreeBase componentInParent = ((Component)val).GetComponentInParent<TreeBase>(); if (Object.op_Implicit((Object)(object)componentInParent)) { val2 = (Component)(object)componentInParent; val3 = (IDestructible)(object)componentInParent; num = componentInParent.m_minToolTier; } else { Destructible componentInParent2 = ((Component)val).GetComponentInParent<Destructible>(); if (!Object.op_Implicit((Object)(object)componentInParent2) || Object.op_Implicit((Object)(object)((Component)componentInParent2).GetComponentInParent<Piece>()) || Object.op_Implicit((Object)(object)((Component)componentInParent2).GetComponentInParent<Character>()) || Object.op_Implicit((Object)(object)((Component)componentInParent2).GetComponentInParent<ItemDrop>())) { continue; } string text = ((Object)((Component)componentInParent2).gameObject).name.Replace("(Clone)", "").Trim(); flag = (int)componentInParent2.m_destructibleType == 2 && TargetRules.IsStump(text); val2 = (Component)(object)componentInParent2; val3 = (IDestructible)(object)componentInParent2; num = componentInParent2.m_minToolTier; } if ((Object)(object)val2 == (Object)null || val3 == null || !hashSet3.Add(((Object)val2).GetInstanceID()) || !TargetSelection.Allowed(((Object)val2.gameObject).name, Object.op_Implicit((Object)(object)componentInParent), flag, stumps, (ISet<string>)hashSet, (ISet<string>)hashSet2)) { continue; } Vector3 basePosition = val2.transform.position; Collider collider = val2.GetComponentsInChildren<Collider>().Where(delegate(Collider c) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0011: 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_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) if (!c.isTrigger) { Bounds bounds = c.bounds; if (((Bounds)(ref bounds)).min.y <= basePosition.y + 1.5f) { bounds = c.bounds; return ((Bounds)(ref bounds)).max.y >= basePosition.y - 0.5f; } } return false; }).OrderBy(delegate(Collider c) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0020: 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_0028: 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) //IL_0043: Unknown result type (might be due to invalid IL or missing references) Bounds bounds = c.bounds; float num2 = ((Bounds)(ref bounds)).center.x - basePosition.x; bounds = c.bounds; Vector2 val5 = new Vector2(num2, ((Bounds)(ref bounds)).center.z - basePosition.z); return ((Vector2)(ref val5)).sqrMagnitude; }) .FirstOrDefault() ?? val; ZNetView component = val2.GetComponent<ZNetView>(); if (Object.op_Implicit((Object)(object)component) && component.IsValid()) { Vector3 val4 = val2.transform.position - origin; if (Trapezoid.Contains((double)val4.x, (double)val4.y, (double)val4.z, (double)forward.x, (double)forward.z, (double)range, (double)width, (double)angle) && TargetRules.Eligible(true, PrivateArea.CheckAccess(val2.transform.position, 0f, false, false), num, tier)) { list.Add(new Target(val2, val3, collider, num, flag)); } } } return TargetSelection.Nearest<Target>((IEnumerable<Target>)list, (Func<Target, double>)((Target t) => t.ForwardDistance(origin, forward)), maxTrees, (Func<Target, bool>)((Target t) => t.CountsTowardLimit)); } public static bool Hit(Target target, Player player, Vector3 origin, Vector3 forward, int tier, float range, float angle, float width) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_005f: 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_0065: 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_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0080: 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_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_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: 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_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: 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_00f6: Expected O, but got Unknown if (!Object.op_Implicit((Object)(object)target.Object) || !Object.op_Implicit((Object)(object)player) || ((Character)player).IsDead() || !Object.op_Implicit((Object)(object)target.Collider)) { return false; } ZNetView component = target.Object.GetComponent<ZNetView>(); if (!Object.op_Implicit((Object)(object)component) || !component.IsValid() || !PrivateArea.CheckAccess(target.Position, 0f, false, false)) { return false; } Vector3 val = target.Position - origin; if (!Trapezoid.Contains((double)val.x, (double)val.y, (double)val.z, (double)forward.x, (double)forward.z, (double)range, (double)width, (double)angle) || tier < target.MinimumTier) { return false; } HitData val2 = new HitData { m_toolTier = (short)Math.Min(tier, 32767), m_point = target.Collider.ClosestPoint(target.Position + Vector3.up), m_dir = forward, m_pushForce = 0f }; val2.m_damage.m_chop = 1000000f; val2.SetAttacker((Character)(object)player); target.Damageable.Damage(val2); return true; } } }