diff --git a/AmeisenBotX.BehaviorTree/Objects/Annotator.cs b/AmeisenBotX.BehaviorTree/Objects/Annotator.cs index 4ab7f2ad..59f91088 100644 --- a/AmeisenBotX.BehaviorTree/Objects/Annotator.cs +++ b/AmeisenBotX.BehaviorTree/Objects/Annotator.cs @@ -6,17 +6,11 @@ namespace AmeisenBotX.BehaviorTree.Objects /// BehaviorTree Node that executes a node before executing annother node. Use this to update /// stuff before executing a node. /// - public class Annotator : INode + public class Annotator(INode annotationNode, INode child) : INode { - public Annotator(INode annotationNode, INode child) : base() - { - AnnotationNode = annotationNode; - Child = child; - } - - public INode AnnotationNode { get; set; } + public INode AnnotationNode { get; set; } = annotationNode; - public INode Child { get; set; } + public INode Child { get; set; } = child; public BtStatus Execute() { @@ -30,17 +24,11 @@ public INode GetNodeToExecute() } } - public class Annotator : INode + public class Annotator(INode annotationNode, INode child) : INode { - public Annotator(INode annotationNode, INode child) : base() - { - AnnotationNode = annotationNode; - Child = child; - } - - public INode AnnotationNode { get; set; } + public INode AnnotationNode { get; set; } = annotationNode; - public INode Child { get; set; } + public INode Child { get; set; } = child; public BtStatus Execute(T blackboard) { diff --git a/AmeisenBotX.BehaviorTree/Objects/DualSelector.cs b/AmeisenBotX.BehaviorTree/Objects/DualSelector.cs index ee22e0f4..c31861b7 100644 --- a/AmeisenBotX.BehaviorTree/Objects/DualSelector.cs +++ b/AmeisenBotX.BehaviorTree/Objects/DualSelector.cs @@ -7,20 +7,13 @@ namespace AmeisenBotX.BehaviorTree.Objects /// Special selector that executes nodeNone when input is 0|0, nodeA when input is 1|0, nodeB /// when input is 0|1 and nodeBoth when input is 1|1. /// - public class DualSelector : IComposite + public class DualSelector(Func conditionA, Func conditionB, INode nodeNone, INode nodeA, INode nodeB, INode nodeBoth) : IComposite { - public DualSelector(Func conditionA, Func conditionB, INode nodeNone, INode nodeA, INode nodeB, INode nodeBoth) : base() - { - ConditionA = conditionA; - ConditionB = conditionB; - Children = new INode[] { nodeNone, nodeA, nodeB, nodeBoth }; - } - - public INode[] Children { get; } + public INode[] Children { get; } = [nodeNone, nodeA, nodeB, nodeBoth]; - public Func ConditionA { get; } + public Func ConditionA { get; } = conditionA; - public Func ConditionB { get; } + public Func ConditionB { get; } = conditionB; public BtStatus Execute() { @@ -35,20 +28,13 @@ public INode GetNodeToExecute() } } - public class DualSelector : IComposite + public class DualSelector(Func conditionA, Func conditionB, INode nodeNone, INode nodeA, INode nodeB, INode nodeBoth) : IComposite { - public DualSelector(Func conditionA, Func conditionB, INode nodeNone, INode nodeA, INode nodeB, INode nodeBoth) : base() - { - ConditionA = conditionA; - ConditionB = conditionB; - Children = new INode[] { nodeNone, nodeA, nodeB, nodeBoth }; - } - - public INode[] Children { get; } + public INode[] Children { get; } = [nodeNone, nodeA, nodeB, nodeBoth]; - public Func ConditionA { get; } + public Func ConditionA { get; } = conditionA; - public Func ConditionB { get; } + public Func ConditionB { get; } = conditionB; public BtStatus Execute(T blackboard) { diff --git a/AmeisenBotX.BehaviorTree/Objects/Inverter.cs b/AmeisenBotX.BehaviorTree/Objects/Inverter.cs index b75c9387..a14be7cb 100644 --- a/AmeisenBotX.BehaviorTree/Objects/Inverter.cs +++ b/AmeisenBotX.BehaviorTree/Objects/Inverter.cs @@ -5,14 +5,9 @@ namespace AmeisenBotX.BehaviorTree.Objects /// /// Inverts the status of a node. Ongoing state will remain Onging. /// - public class Inverter : INode + public class Inverter(INode child) : INode { - public Inverter(INode child) : base() - { - Child = child; - } - - public INode Child { get; } + public INode Child { get; } = child; public BtStatus Execute() { @@ -36,14 +31,9 @@ public INode GetNodeToExecute() } } - public class Inverter : INode + public class Inverter(INode child) : INode { - public Inverter(INode child) : base() - { - Child = child; - } - - public INode Child { get; } + public INode Child { get; } = child; public BtStatus Execute(T blackboard) { diff --git a/AmeisenBotX.BehaviorTree/Objects/Leaf.cs b/AmeisenBotX.BehaviorTree/Objects/Leaf.cs index 31dab79b..fe86297d 100644 --- a/AmeisenBotX.BehaviorTree/Objects/Leaf.cs +++ b/AmeisenBotX.BehaviorTree/Objects/Leaf.cs @@ -3,14 +3,9 @@ namespace AmeisenBotX.BehaviorTree.Objects { - public class Leaf : INode + public class Leaf(Func behaviorTreeAction) : INode { - public Leaf(Func behaviorTreeAction) : base() - { - BehaviorTreeAction = behaviorTreeAction; - } - - public Func BehaviorTreeAction { get; set; } + public Func BehaviorTreeAction { get; set; } = behaviorTreeAction; public BtStatus Execute() { @@ -23,14 +18,9 @@ public INode GetNodeToExecute() } } - public class Leaf : INode + public class Leaf(Func behaviorTreeAction) : INode { - public Leaf(Func behaviorTreeAction) : base() - { - BehaviorTreeAction = behaviorTreeAction; - } - - public Func BehaviorTreeAction { get; set; } + public Func BehaviorTreeAction { get; set; } = behaviorTreeAction; public BtStatus Execute(T blackboard) { diff --git a/AmeisenBotX.BehaviorTree/Objects/Selector.cs b/AmeisenBotX.BehaviorTree/Objects/Selector.cs index f4de289e..d2241c4a 100644 --- a/AmeisenBotX.BehaviorTree/Objects/Selector.cs +++ b/AmeisenBotX.BehaviorTree/Objects/Selector.cs @@ -6,17 +6,11 @@ namespace AmeisenBotX.BehaviorTree.Objects /// /// Executes a when input is true and b when it is false. /// - public class Selector : IComposite + public class Selector(Func condition, INode nodeA, INode nodeB) : IComposite { - public Selector(Func condition, INode nodeA, INode nodeB) : base() - { - Condition = condition; - Children = new INode[] { nodeA, nodeB }; - } - - public INode[] Children { get; } + public INode[] Children { get; } = [nodeA, nodeB]; - public Func Condition { get; } + public Func Condition { get; } = condition; public BtStatus Execute() { @@ -29,17 +23,11 @@ public INode GetNodeToExecute() } } - public class Selector : IComposite + public class Selector(Func condition, INode nodeA, INode nodeB) : IComposite { - public Selector(Func condition, INode nodeA, INode nodeB) : base() - { - Condition = condition; - Children = new INode[] { nodeA, nodeB }; - } - - public INode[] Children { get; } + public INode[] Children { get; } = [nodeA, nodeB]; - public Func Condition { get; } + public Func Condition { get; } = condition; public BtStatus Execute(T blackboard) { diff --git a/AmeisenBotX.BehaviorTree/Objects/Sequence.cs b/AmeisenBotX.BehaviorTree/Objects/Sequence.cs index 21eddbd6..727933a8 100644 --- a/AmeisenBotX.BehaviorTree/Objects/Sequence.cs +++ b/AmeisenBotX.BehaviorTree/Objects/Sequence.cs @@ -6,14 +6,9 @@ namespace AmeisenBotX.BehaviorTree.Objects /// Executes a sequence of nodes until all nodes returned success. If a node fails or the /// sequence finished, it gets resetted. /// - public class Sequence : IComposite + public class Sequence(params INode[] children) : IComposite { - public Sequence(params INode[] children) - { - Children = children; - } - - public INode[] Children { get; } + public INode[] Children { get; } = children; public int Counter { get; private set; } @@ -55,14 +50,9 @@ public INode GetNodeToExecute() } } - public class Sequence : IComposite + public class Sequence(params INode[] children) : IComposite { - public Sequence(params INode[] children) - { - Children = children; - } - - public INode[] Children { get; } + public INode[] Children { get; } = children; public int Counter { get; private set; } diff --git a/AmeisenBotX.BehaviorTree/Objects/Waterfall.cs b/AmeisenBotX.BehaviorTree/Objects/Waterfall.cs index 04321283..69a843de 100644 --- a/AmeisenBotX.BehaviorTree/Objects/Waterfall.cs +++ b/AmeisenBotX.BehaviorTree/Objects/Waterfall.cs @@ -7,19 +7,13 @@ namespace AmeisenBotX.BehaviorTree.Objects /// Special selector that runs the first node where the condition returns true. If none returned /// true, the fallbackNode will be executed /// - public class Waterfall : IComposite + public class Waterfall(INode fallbackNode, params (Func condition, INode node)[] conditionNodePairs) : IComposite { - public Waterfall(INode fallbackNode, params (Func condition, INode node)[] conditionNodePairs) : base() - { - FallbackNode = fallbackNode; - ConditionNodePairs = conditionNodePairs; - } - public INode[] Children { get; } - public (Func condition, INode node)[] ConditionNodePairs { get; } + public (Func condition, INode node)[] ConditionNodePairs { get; } = conditionNodePairs; - public INode FallbackNode { get; } + public INode FallbackNode { get; } = fallbackNode; public BtStatus Execute() { @@ -40,19 +34,13 @@ public INode GetNodeToExecute() } } - public class Waterfall : IComposite + public class Waterfall(INode fallbackNode, params (Func condition, INode node)[] conditionNodePairs) : IComposite { - public Waterfall(INode fallbackNode, params (Func condition, INode node)[] conditionNodePairs) : base() - { - FallbackNode = fallbackNode; - ConditionNodePairs = conditionNodePairs; - } - public INode[] Children { get; } - public (Func condition, INode node)[] ConditionNodePairs { get; } + public (Func condition, INode node)[] ConditionNodePairs { get; } = conditionNodePairs; - public INode FallbackNode { get; } + public INode FallbackNode { get; } = fallbackNode; public BtStatus Execute(T blackboard) { diff --git a/AmeisenBotX.BehaviorTree/Tree.cs b/AmeisenBotX.BehaviorTree/Tree.cs index c633370e..311fdf8d 100644 --- a/AmeisenBotX.BehaviorTree/Tree.cs +++ b/AmeisenBotX.BehaviorTree/Tree.cs @@ -80,19 +80,13 @@ public BtStatus Tick() } } - public class Tree + public class Tree(INode node, bool resumeOngoingNodes = false) { - public Tree(INode node, bool resumeOngoingNodes = false) - { - RootNode = node; - ResumeOngoingNodes = resumeOngoingNodes; - } - public INode OngoingNode { get; private set; } - public bool ResumeOngoingNodes { get; set; } + public bool ResumeOngoingNodes { get; set; } = resumeOngoingNodes; - public INode RootNode { get; set; } + public INode RootNode { get; set; } = node; public BtStatus Tick() { diff --git a/AmeisenBotX.Common/Keyboard/Enums/KeyCode.cs b/AmeisenBotX.Common/Keyboard/Enums/KeyCode.cs index 267810a8..04c74e58 100644 --- a/AmeisenBotX.Common/Keyboard/Enums/KeyCode.cs +++ b/AmeisenBotX.Common/Keyboard/Enums/KeyCode.cs @@ -1,5 +1,6 @@ using System; +#pragma warning disable CA1069 namespace AmeisenBotX.Common.Keyboard.Enums { [Flags] @@ -200,4 +201,5 @@ public enum KeyCode // todo: rewrite, messy Z = 90, Zoom = 0xfb } -} \ No newline at end of file +} +#pragma warning restore CA1069 diff --git a/AmeisenBotX.Common/Keyboard/KeyboardHook.cs b/AmeisenBotX.Common/Keyboard/KeyboardHook.cs index 3c3191d1..2dfd6800 100644 --- a/AmeisenBotX.Common/Keyboard/KeyboardHook.cs +++ b/AmeisenBotX.Common/Keyboard/KeyboardHook.cs @@ -10,7 +10,7 @@ namespace AmeisenBotX.Common.Keyboard /// /// This is a global keyboard hook used to manage hotkeys. /// - public class KeyboardHook + public partial class KeyboardHook { public KeyboardHook() { @@ -56,7 +56,7 @@ public void Disable() { if (HookPtr != nint.Zero) { - UnhookWindowsHookEx(HookPtr); + _ = UnhookWindowsHookEx(HookPtr); } } @@ -74,20 +74,20 @@ public void Enable() } } - [DllImport("user32", SetLastError = true)] - private static extern int CallNextHookEx(nint hHook, int nCode, nint wParam, ref LowLevelKeyboardInput lParam); + [LibraryImport("user32")] + private static partial int CallNextHookEx(nint hHook, int nCode, nint wParam, ref LowLevelKeyboardInput lParam); - [DllImport("user32", SetLastError = true)] - private static extern short GetKeyState(KeyCode nVirtKey); + [LibraryImport("user32")] + private static partial short GetKeyState(KeyCode nVirtKey); - [DllImport("kernel32", CharSet = CharSet.Auto, SetLastError = true)] - private static extern nint GetModuleHandle(string lpModuleName); + [LibraryImport("kernel32", EntryPoint = "GetModuleHandleA", StringMarshalling = StringMarshalling.Utf16)] + private static partial nint GetModuleHandle(string lpModuleName); - [DllImport("user32", SetLastError = true)] - private static extern nint SetWindowsHookEx(int idHook, LowLevelKeyboardProc lpfn, nint hMod, int dwThreadId); + [LibraryImport("user32", EntryPoint = "SetWindowsHookExA")] + private static partial nint SetWindowsHookEx(int idHook, LowLevelKeyboardProc lpfn, nint hMod, int dwThreadId); - [DllImport("user32", SetLastError = true)] - private static extern int UnhookWindowsHookEx(nint hHook); + [LibraryImport("user32")] + private static partial int UnhookWindowsHookEx(nint hHook); private int LowLevelKeyboardCallback(int nCode, nint wParam, ref LowLevelKeyboardInput lParam) { diff --git a/AmeisenBotX.Common/Math/BotMath.cs b/AmeisenBotX.Common/Math/BotMath.cs index 99e0f31c..0174e1b5 100644 --- a/AmeisenBotX.Common/Math/BotMath.cs +++ b/AmeisenBotX.Common/Math/BotMath.cs @@ -118,9 +118,7 @@ public static double SlopeGradientAngle(Vector3 startPoint, Vector3 endPoint) // calculates the arctan to get the radians (arctan(alpha) = rise / run) double radAngle = System.Math.Atan(slope / 100); // converts the radians in degrees - double degAngle = radAngle * 180 / System.Math.PI; - - return degAngle; + return radAngle * 180 / System.Math.PI; } } } \ No newline at end of file diff --git a/AmeisenBotX.Common/Math/Matrix3x3.cs b/AmeisenBotX.Common/Math/Matrix3x3.cs index 4bf91437..d85cc3ea 100644 --- a/AmeisenBotX.Common/Math/Matrix3x3.cs +++ b/AmeisenBotX.Common/Math/Matrix3x3.cs @@ -1,39 +1,24 @@ namespace AmeisenBotX.Common.Math { - public struct Matrix3x3 + public struct Matrix3x3(float x1, float x2, float x3, float y1, float y2, float y3, float z1, float z2, float z3) { - public Matrix3x3(float x1, float x2, float x3, float y1, float y2, float y3, float z1, float z2, float z3) - { - X1 = x1; - X2 = x2; - X3 = x3; - Y1 = y1; - Y2 = y2; - Y3 = y3; - Z1 = z1; - Z2 = z2; - Z3 = z3; - } - - public Vector3 FirstCol => new(X1, Y1, Z1); - - public float X1 { get; set; } + public float X1 { get; set; } = x1; - public float X2 { get; set; } + public float X2 { get; set; } = x2; - public float X3 { get; set; } + public float X3 { get; set; } = x3; - public float Y1 { get; set; } + public float Y1 { get; set; } = y1; - public float Y2 { get; set; } + public float Y2 { get; set; } = y2; - public float Y3 { get; set; } + public float Y3 { get; set; } = y3; - public float Z1 { get; set; } + public float Z1 { get; set; } = z1; - public float Z2 { get; set; } + public float Z2 { get; set; } = z2; - public float Z3 { get; set; } + public float Z3 { get; set; } = z3; public static Vector3 operator *(Vector3 v, Matrix3x3 m) { @@ -42,13 +27,13 @@ public Matrix3x3(float x1, float x2, float x3, float y1, float y2, float y3, flo m.X3 * v.X + m.Y3 * v.Y + m.Z3 * v.Z); } - public float Dot() + public readonly float Dot() { return (X1 * Y2 * Z3) + (X2 * Y3 * Z1) + (X3 * Y1 * Z2) - (X3 * Y2 * Z1) - (X2 * Y1 * Z3) - (X1 * Y3 * Z2); } - public Matrix3x3 Inverse() + public readonly Matrix3x3 Inverse() { float d = 1 / Dot(); return new(d * (Y2 * Z3 - Y3 * Z2), d * (X3 * Z2 - X2 * Z3), d * (X2 * Y3 - X3 * Y2), diff --git a/AmeisenBotX.Common/Math/Vector3.cs b/AmeisenBotX.Common/Math/Vector3.cs index 32f2c289..601ffa56 100644 --- a/AmeisenBotX.Common/Math/Vector3.cs +++ b/AmeisenBotX.Common/Math/Vector3.cs @@ -8,7 +8,7 @@ namespace AmeisenBotX.Common.Math [StructLayout(LayoutKind.Sequential)] public struct Vector3 : IEquatable { - public static Vector3 Zero { get; } = new(0, 0, 0); + public static readonly Vector3 Zero = new(0, 0, 0); public Vector3(float a) { @@ -24,12 +24,16 @@ public Vector3(float x, float y, float z) Z = z; } - public bool AnySubZero() + public readonly bool AnySubZero() { return X < 0.0f || Y < 0.0f || Z < 0.0f; } - public Vector3(Vector3 position) : this(position.X, position.Y, position.Z) + public Vector3(Vector3 v3) : this(v3.X, v3.Y, v3.Z) + { + } + + public Vector3(float[] array) : this(array[0], array[1], array[2]) { } @@ -39,12 +43,6 @@ public Vector3(Vector3 position) : this(position.X, position.Y, position.Z) public float Z { get; set; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector3 FromArray(float[] array) - { - return new(array[0], array[1], array[2]); - } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Vector3 operator -(Vector3 a, Vector3 b) { @@ -202,19 +200,19 @@ public Vector3 AdjustedZ(float z) } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public float GetDistance(Vector3 v) + public readonly float GetDistance(Vector3 v) { return MathF.Sqrt(MathF.Pow(X - v.X, 2) + MathF.Pow(Y - v.Y, 2) + MathF.Pow(Z - v.Z, 2)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public float GetDistance2D(Vector3 v) + public readonly float GetDistance2D(Vector3 v) { return MathF.Sqrt(MathF.Pow(X - v.X, 2) + MathF.Pow(Y - v.Y, 2)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public override int GetHashCode() + public override readonly int GetHashCode() { unchecked { @@ -223,25 +221,25 @@ public override int GetHashCode() } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public float Dot() + public readonly float Dot() { return MathF.Pow(X, 2) + MathF.Pow(Y, 2) + MathF.Pow(Z, 2); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public float Dot2D() + public readonly float Dot2D() { return MathF.Pow(X, 2) + MathF.Pow(Y, 2); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public float GetMagnitude() + public readonly float GetMagnitude() { return MathF.Sqrt(Dot()); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public float GetMagnitude2D() + public readonly float GetMagnitude2D() { return MathF.Sqrt(Dot2D()); } @@ -351,23 +349,23 @@ public void Subtract(Vector3 vector) } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public float[] ToArray() + public readonly float[] ToArray() { - return new float[3] { X, Y, Z }; + return [X, Y, Z]; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public override string ToString() + public override readonly string ToString() { return $"{X}, {Y}, {Z}"; } - public override bool Equals(object obj) + public override readonly bool Equals(object obj) { return obj is Vector3 vector && this == vector; } - public bool Equals(Vector3 other) + public readonly bool Equals(Vector3 other) { return this == other; } diff --git a/AmeisenBotX.Common/Storage/SimpleConfigurable.cs b/AmeisenBotX.Common/Storage/SimpleConfigurable.cs index 1a81bbcd..3e5fb2c0 100644 --- a/AmeisenBotX.Common/Storage/SimpleConfigurable.cs +++ b/AmeisenBotX.Common/Storage/SimpleConfigurable.cs @@ -10,9 +10,9 @@ public abstract class SimpleConfigurable : IStoreable public virtual void Load(Dictionary objects) { - if (objects.ContainsKey("Configurables")) + if (objects.TryGetValue("Configurables", out JsonElement value)) { - foreach (KeyValuePair x in objects["Configurables"].ToDyn()) + foreach (KeyValuePair x in value.ToDyn()) { if (Configurables.ContainsKey(x.Key)) { diff --git a/AmeisenBotX.Common/Storage/StorageManager.cs b/AmeisenBotX.Common/Storage/StorageManager.cs index 23398555..8dfaa166 100644 --- a/AmeisenBotX.Common/Storage/StorageManager.cs +++ b/AmeisenBotX.Common/Storage/StorageManager.cs @@ -6,30 +6,29 @@ namespace AmeisenBotX.Common.Storage { - public class StorageManager + /// + /// Helper class used to save configureable values in json files. Files will be named after + /// their full class name (including namespace). + /// + /// Folder to save the json files in. + /// + /// Strings that are going to be removed from the final filename, use this to remove + /// namespace parts from them. + /// + public class StorageManager(string basePath, IEnumerable partsToRemove = null) { - /// - /// Helper class used to save configureable values in json files. Files will be named after - /// their full class name (including namespace). - /// - /// Folder to save the json files in. - /// - /// Strings that are going to be removed from the final filename, use this to remove - /// namespace parts from them. - /// - public StorageManager(string basePath, IEnumerable partsToRemove = null) + private static readonly JsonSerializerOptions Options = new() { - BasePath = basePath; - PartsToRemove = partsToRemove; + AllowTrailingCommas = true, + WriteIndented = true, + NumberHandling = JsonNumberHandling.AllowReadingFromString + }; - Storeables = []; - } - - private string BasePath { get; } + private string BasePath { get; } = basePath; - private IEnumerable PartsToRemove { get; } + private IEnumerable PartsToRemove { get; } = partsToRemove; - private List Storeables { get; set; } + private List Storeables { get; set; } = []; public void Load(IStoreable s) { @@ -49,13 +48,9 @@ public void Load(IStoreable s) return; } - s.Load(JsonSerializer.Deserialize>(File.ReadAllText(fullPath), new JsonSerializerOptions() { AllowTrailingCommas = true, NumberHandling = JsonNumberHandling.AllowReadingFromString })); - } - catch - { - // AmeisenLogger.I.Log("CombatClass", $"Failed to load {s.GetType().Name} - // ({fullPath}):\n{ex}", LogLevel.Error); + s.Load(JsonSerializer.Deserialize>(File.ReadAllText(fullPath), Options)); } + catch { } } public void LoadAll() @@ -90,13 +85,9 @@ public void Save(IStoreable s) } IOUtils.CreateDirectoryIfNotExists(Path.GetDirectoryName(fullPath)); - File.WriteAllText(fullPath, JsonSerializer.Serialize(data, new JsonSerializerOptions() { WriteIndented = true })); - } - catch - { - // AmeisenLogger.I.Log("CombatClass", $"Failed to save {s.GetType().Name} - // ({fullPath}):\n{ex}", LogLevel.Error); + File.WriteAllText(fullPath, JsonSerializer.Serialize(data, Options)); } + catch { } } public void SaveAll() diff --git a/AmeisenBotX.Common/Utils/BotUtils.cs b/AmeisenBotX.Common/Utils/BotUtils.cs index 42993e6c..dc14b0bd 100644 --- a/AmeisenBotX.Common/Utils/BotUtils.cs +++ b/AmeisenBotX.Common/Utils/BotUtils.cs @@ -8,7 +8,7 @@ namespace AmeisenBotX.Common.Utils { - public static class BotUtils + public static partial class BotUtils { private const uint WM_KEYDOWN = 0x100; private const uint WM_KEYUP = 0x101; @@ -159,7 +159,7 @@ public static void SendKey(nint windowHandle, nint key, int minDelay = 20, int m SendMessage(windowHandle, WM_KEYUP, key, nint.Zero); } - [DllImport("user32", SetLastError = true)] - private static extern nint SendMessage(nint windowHandle, uint msg, nint param, nint parameter); + [LibraryImport("user32")] + private static partial nint SendMessage(nint windowHandle, uint msg, nint param, nint parameter); } } \ No newline at end of file diff --git a/AmeisenBotX.Core/AmeisenBot.cs b/AmeisenBotX.Core/AmeisenBot.cs index e106e1ec..3e9eceb3 100644 --- a/AmeisenBotX.Core/AmeisenBot.cs +++ b/AmeisenBotX.Core/AmeisenBot.cs @@ -86,8 +86,8 @@ public class AmeisenBot public AmeisenBot(string instanceName, AmeisenBotConfig config, string logfilePath = "DEFAULT", LogLevel initialLogLevel = LogLevel.Verbose) { if (string.IsNullOrWhiteSpace(instanceName)) { throw new ArgumentException("instanceName cannot be empty or whitespace", nameof(config)); } - if (string.IsNullOrWhiteSpace(config.Path)) { throw new ArgumentException("config.Path cannot be empty, make sure you set it after loading the config", nameof(config)); } - if (!File.Exists(config.Path)) { throw new ArgumentException("config.Path does not exist", nameof(config)); } + if (string.IsNullOrWhiteSpace(config.Path)) { throw new ArgumentException("config path cannot be empty, make sure you set it after loading the config", nameof(config)); } + if (!File.Exists(config.Path)) { throw new ArgumentException("config path does not exist", nameof(config)); } Config = config ?? throw new ArgumentException("config cannot be null", nameof(config)); @@ -708,8 +708,8 @@ private void OnLootRollStarted(long timestamp, List args) // get the item id and try again itemJson = Bot.Wow.GetItemByNameOrLink ( - itemLink.Split(new string[] { "Hitem:" }, StringSplitOptions.RemoveEmptyEntries)[1] - .Split(new string[] { ":" }, StringSplitOptions.RemoveEmptyEntries)[0] + itemLink.Split(["Hitem:"], StringSplitOptions.RemoveEmptyEntries)[1] + .Split([":"], StringSplitOptions.RemoveEmptyEntries)[0] ); item = ItemFactory.BuildSpecificItem(ItemFactory.ParseItem(itemJson)); @@ -1005,7 +1005,7 @@ private void RconClientTimerTick() Bot.Rcon.PullPendingActions(); - if (Bot.Rcon.PendingActions.Any()) + if (Bot.Rcon.PendingActions.Count != 0) { switch (Bot.Rcon.PendingActions.First()) { diff --git a/AmeisenBotX.Core/Engines/Battleground/Jannis/CtfBlackboard.cs b/AmeisenBotX.Core/Engines/Battleground/Jannis/CtfBlackboard.cs index 1808060d..9ba30405 100644 --- a/AmeisenBotX.Core/Engines/Battleground/Jannis/CtfBlackboard.cs +++ b/AmeisenBotX.Core/Engines/Battleground/Jannis/CtfBlackboard.cs @@ -6,13 +6,8 @@ namespace AmeisenBotX.Core.Engines.Battleground.Jannis { - public class CtfBlackboard : IBlackboard + public class CtfBlackboard(Action updateAction) : IBlackboard { - public CtfBlackboard(Action updateAction) - { - UpdateAction = updateAction; - } - public IWowUnit EnemyTeamFlagCarrier { get; set; } public Vector3 EnemyTeamFlagPos { get; set; } @@ -35,7 +30,7 @@ public CtfBlackboard(Action updateAction) public IEnumerable NearFlags { get; set; } - private Action UpdateAction { get; } + private Action UpdateAction { get; } = updateAction; public void Update() { diff --git a/AmeisenBotX.Core/Engines/Battleground/Jannis/Profiles/WarsongGulchProfile.cs b/AmeisenBotX.Core/Engines/Battleground/Jannis/Profiles/WarsongGulchProfile.cs index a1fc6aae..f9c379b5 100644 --- a/AmeisenBotX.Core/Engines/Battleground/Jannis/Profiles/WarsongGulchProfile.cs +++ b/AmeisenBotX.Core/Engines/Battleground/Jannis/Profiles/WarsongGulchProfile.cs @@ -18,6 +18,12 @@ namespace AmeisenBotX.Core.Engines.Battleground.Jannis.Profiles { public class WarsongGulchProfile : IBattlegroundProfile { + private static readonly JsonSerializerOptions Options = new() + { + AllowTrailingCommas = true, + NumberHandling = JsonNumberHandling.AllowReadingFromString + }; + public WarsongGulchProfile(AmeisenBotInterfaces bot) { Bot = bot; @@ -383,7 +389,7 @@ private void UpdateBattlegroundInfo() { if (Bot.Wow.ExecuteLuaAndRead(BotUtils.ObfuscateLua($"{{v:0}}=\"{{\"_,stateA,textA,_,_,_,_,_,_,_,_,_=GetWorldStateUIInfo(2)_,stateH,textH,_,_,_,_,_,_,_,_,_=GetWorldStateUIInfo(3)flagXA,flagYA=GetBattlefieldFlagPosition(1)flagXH,flagYH=GetBattlefieldFlagPosition(2){{v:0}}={{v:0}}..\"\\\"allianceState\\\" : \\\"\"..stateA..\"\\\",\"{{v:0}}={{v:0}}..\"\\\"allianceText\\\" : \\\"\"..textA..\"\\\",\"{{v:0}}={{v:0}}..\"\\\"hordeState\\\" : \\\"\"..stateH..\"\\\",\"{{v:0}}={{v:0}}..\"\\\"hordeText\\\" : \\\"\"..textH..\"\\\",\"{{v:0}}={{v:0}}..\"\\\"allianceFlagX\\\" : \\\"\"..flagXA..\"\\\",\"{{v:0}}={{v:0}}..\"\\\"allianceFlagY\\\" : \\\"\"..flagYA..\"\\\",\"{{v:0}}={{v:0}}..\"\\\"hordeFlagX\\\" : \\\"\"..flagXH..\"\\\",\"{{v:0}}={{v:0}}..\"\\\"hordeFlagY\\\" : \\\"\"..flagYH..\"\\\"\"{{v:0}}={{v:0}}..\"}}\""), out string result)) { - Dictionary bgState = JsonSerializer.Deserialize(result, new JsonSerializerOptions() { AllowTrailingCommas = true, NumberHandling = JsonNumberHandling.AllowReadingFromString }).ToDyn(); + Dictionary bgState = JsonSerializer.Deserialize(result, Options).ToDyn(); string[] splittedScoreH = ((string)bgState["hordeText"]).Split('/'); string[] splittedScoreA = ((string)bgState["allianceText"]).Split('/'); @@ -434,9 +440,7 @@ private void UpdateBattlegroundInfo() or ((int)WowGameObjectDisplayId.WsgHordeFlag)); } } - catch (Exception ex) - { - } + catch { } } private BtStatus UseNearestFlag(CtfBlackboard blackboard) diff --git a/AmeisenBotX.Core/Engines/Battleground/Jannis/UniversalBattlegroundEngine.cs b/AmeisenBotX.Core/Engines/Battleground/Jannis/UniversalBattlegroundEngine.cs index a221ea76..ff2ce1e4 100644 --- a/AmeisenBotX.Core/Engines/Battleground/Jannis/UniversalBattlegroundEngine.cs +++ b/AmeisenBotX.Core/Engines/Battleground/Jannis/UniversalBattlegroundEngine.cs @@ -3,13 +3,8 @@ namespace AmeisenBotX.Core.Engines.Battleground.Jannis { - public class UniversalBattlegroundEngine : IBattlegroundEngine + public class UniversalBattlegroundEngine(AmeisenBotInterfaces bot) : IBattlegroundEngine { - public UniversalBattlegroundEngine(AmeisenBotInterfaces bot) - { - Bot = bot; - } - public string Author => "Jannis"; public string Description => "Working battlegrounds:\n - Warsong Gulch"; @@ -18,7 +13,7 @@ public UniversalBattlegroundEngine(AmeisenBotInterfaces bot) public IBattlegroundProfile Profile { get; set; } - private AmeisenBotInterfaces Bot { get; } + private AmeisenBotInterfaces Bot { get; } = bot; public void Execute() { diff --git a/AmeisenBotX.Core/Engines/Battleground/KamelBG/ArathiBasin.cs b/AmeisenBotX.Core/Engines/Battleground/KamelBG/ArathiBasin.cs index 985e23ba..7407c536 100644 --- a/AmeisenBotX.Core/Engines/Battleground/KamelBG/ArathiBasin.cs +++ b/AmeisenBotX.Core/Engines/Battleground/KamelBG/ArathiBasin.cs @@ -9,22 +9,13 @@ namespace AmeisenBotX.Core.Engines.Battleground.KamelBG { - internal class ArathiBasin : IBattlegroundEngine + internal class ArathiBasin(AmeisenBotInterfaces bot) : IBattlegroundEngine { - public ArathiBasin(AmeisenBotInterfaces bot) - { - Bot = bot; - - CaptureFlagEvent = new(TimeSpan.FromSeconds(1)); - CombatEvent = new(TimeSpan.FromSeconds(2)); - FlagsNodelist = []; - } - public string Author => "Lukas"; public string Description => "Arathi Basin"; - public List FlagsNodelist { get; set; } + public List FlagsNodelist { get; set; } = []; public string Name => "Arathi Basin"; @@ -37,11 +28,11 @@ public ArathiBasin(AmeisenBotInterfaces bot) new(1166, 1203, -56) // Stable ]; - private AmeisenBotInterfaces Bot { get; } + private AmeisenBotInterfaces Bot { get; } = bot; - private TimegatedEvent CaptureFlagEvent { get; } + private TimegatedEvent CaptureFlagEvent { get; } = new(TimeSpan.FromSeconds(1)); - private TimegatedEvent CombatEvent { get; } + private TimegatedEvent CombatEvent { get; } = new(TimeSpan.FromSeconds(2)); private int CurrentNodeCounter { get; set; } diff --git a/AmeisenBotX.Core/Engines/Battleground/KamelBG/EyeOfTheStorm.cs b/AmeisenBotX.Core/Engines/Battleground/KamelBG/EyeOfTheStorm.cs index 2fef87c3..2fff3f2e 100644 --- a/AmeisenBotX.Core/Engines/Battleground/KamelBG/EyeOfTheStorm.cs +++ b/AmeisenBotX.Core/Engines/Battleground/KamelBG/EyeOfTheStorm.cs @@ -9,16 +9,8 @@ namespace AmeisenBotX.Core.Engines.Battleground.KamelBG { - internal class EyeOfTheStorm : IBattlegroundEngine + internal class EyeOfTheStorm(AmeisenBotInterfaces bot) : IBattlegroundEngine { - public EyeOfTheStorm(AmeisenBotInterfaces bot) - { - Bot = bot; - - CaptureFlagEvent = new(TimeSpan.FromSeconds(1)); - CombatEvent = new(TimeSpan.FromSeconds(2)); - } - public string Author => "Lukas"; public string Description => "Eye of the Storm"; @@ -38,11 +30,11 @@ public EyeOfTheStorm(AmeisenBotInterfaces bot) new Vector3(2176, 1570, 1159)//Flag ]; - private AmeisenBotInterfaces Bot { get; } + private AmeisenBotInterfaces Bot { get; } = bot; - private TimegatedEvent CaptureFlagEvent { get; } + private TimegatedEvent CaptureFlagEvent { get; } = new(TimeSpan.FromSeconds(1)); - private TimegatedEvent CombatEvent { get; } + private TimegatedEvent CombatEvent { get; } = new(TimeSpan.FromSeconds(2)); private int CurrentNodeCounter { get; set; } diff --git a/AmeisenBotX.Core/Engines/Battleground/KamelBG/StrandOfTheAncients.cs b/AmeisenBotX.Core/Engines/Battleground/KamelBG/StrandOfTheAncients.cs index 13fed23e..0a37c52e 100644 --- a/AmeisenBotX.Core/Engines/Battleground/KamelBG/StrandOfTheAncients.cs +++ b/AmeisenBotX.Core/Engines/Battleground/KamelBG/StrandOfTheAncients.cs @@ -9,18 +9,11 @@ namespace AmeisenBotX.Core.Engines.Battleground.KamelBG { - internal class StrandOfTheAncients : IBattlegroundEngine + internal class StrandOfTheAncients(AmeisenBotInterfaces bot) : IBattlegroundEngine { - public StrandOfTheAncients(AmeisenBotInterfaces bot) - { - Bot = bot; - - CombatEvent = new(TimeSpan.FromSeconds(2)); - } - public string Author => "Lukas"; - public AmeisenBotInterfaces Bot { get; } + public AmeisenBotInterfaces Bot { get; } = bot; public string Description => "Strand of the Ancients"; @@ -31,7 +24,7 @@ public StrandOfTheAncients(AmeisenBotInterfaces bot) new(1403, 69, 30) ]; - private TimegatedEvent CombatEvent { get; } + private TimegatedEvent CombatEvent { get; } = new(TimeSpan.FromSeconds(2)); public void Combat() { diff --git a/AmeisenBotX.Core/Engines/Combat/Classes/Bia10/DataConstants.cs b/AmeisenBotX.Core/Engines/Combat/Classes/Bia10/DataConstants.cs index 0868bed7..eb9dc031 100644 --- a/AmeisenBotX.Core/Engines/Combat/Classes/Bia10/DataConstants.cs +++ b/AmeisenBotX.Core/Engines/Combat/Classes/Bia10/DataConstants.cs @@ -2,28 +2,51 @@ { public static class DataConstants { - public static readonly int[] usableHealingItems = { + public static readonly int[] usableHealingItems = [ // food 117, // potions - 118, 929, 1710, 2938, 3928, 4596, 5509, 13446, 22829, 33447, + 118, + 929, + 1710, + 2938, + 3928, + 4596, + 5509, + 13446, + 22829, + 33447, // healthstones - 5509, 5510, 5511, 5512, 9421, 19013, 22103, 36889, 36892, - }; + 5509, + 5510, + 5511, + 5512, + 9421, + 19013, + 22103, + 36889, + 36892, + ]; - public static readonly int[] usableManaItems = { + public static readonly int[] usableManaItems = [ // drinks 159, // potions - 2245, 3385, 3827, 6149, 13443, 13444, 33448, 22832, - }; + 2245, + 3385, + 3827, + 6149, + 13443, + 13444, + 33448, + 22832, + ]; internal const int HealSelfPercentage = 60; public static string GetCastSpellString(string spellName, bool castOnSelf) { - return - $"{{v:3}},{{v:4}}=GetSpellCooldown(\"{spellName}\"){{v:2}}=({{v:3}}+{{v:4}}-GetTime())*1000;if {{v:2}}<=0 then {{v:2}}=0;CastSpellByName(\"{spellName}\"{(castOnSelf ? ", \"player\"" : string.Empty)}){{v:5}},{{v:6}}=GetSpellCooldown(\"{spellName}\"){{v:1}}=({{v:5}}+{{v:6}}-GetTime())*1000;{{v:0}}=\"1;\"..{{v:1}} else {{v:0}}=\"0;\"..{{v:2}} end"; + return $"{{v:3}},{{v:4}}=GetSpellCooldown(\"{spellName}\"){{v:2}}=({{v:3}}+{{v:4}}-GetTime())*1000;if {{v:2}}<=0 then {{v:2}}=0;CastSpellByName(\"{spellName}\"{(castOnSelf ? ", \"player\"" : string.Empty)}){{v:5}},{{v:6}}=GetSpellCooldown(\"{spellName}\"){{v:1}}=({{v:5}}+{{v:6}}-GetTime())*1000;{{v:0}}=\"1;\"..{{v:1}} else {{v:0}}=\"0;\"..{{v:2}} end"; } } } \ No newline at end of file diff --git a/AmeisenBotX.Core/Engines/Combat/Classes/Jannis/BasicCombatClass.cs b/AmeisenBotX.Core/Engines/Combat/Classes/Jannis/BasicCombatClass.cs index e0703f43..d8769976 100644 --- a/AmeisenBotX.Core/Engines/Combat/Classes/Jannis/BasicCombatClass.cs +++ b/AmeisenBotX.Core/Engines/Combat/Classes/Jannis/BasicCombatClass.cs @@ -22,19 +22,19 @@ namespace AmeisenBotX.Core.Engines.Combat.Classes.Jannis { public abstract class BasicCombatClass : SimpleConfigurable, ICombatClass { - private readonly int[] useableHealingItems = new int[] - { + private readonly int[] useableHealingItems = + [ // potions 118, 929, 1710, 2938, 3928, 4596, 5509, 13446, 22829, 33447, // healthstones 5509, 5510, 5511, 5512, 9421, 19013, 22103, 36889, 36892, - }; + ]; - private readonly int[] useableManaItems = new int[] - { + private readonly int[] useableManaItems = + [ // potions 2245, 3385, 3827, 6149, 13443, 13444, 33448, 22832, - }; + ]; protected BasicCombatClass(AmeisenBotInterfaces bot) { @@ -276,9 +276,9 @@ public override string ToString() protected bool CheckForWeaponEnchantment(WowEquipmentSlot slot, string enchantmentName, string spellToCastEnchantment) { - if (Bot.Character.Equipment.Items.ContainsKey(slot)) + if (Bot.Character.Equipment.Items.TryGetValue(slot, out IWowInventoryItem value)) { - int itemId = Bot.Character.Equipment.Items[slot].Id; + int itemId = value.Id; if (itemId > 0) { @@ -316,13 +316,14 @@ protected bool HandleDeadPartymembers(string spellName) { if (Bot.Db.GetUnitName(player, out string name)) { - if (!RessurrectionTargets.ContainsKey(name)) + if (!RessurrectionTargets.TryGetValue(name, out DateTime value)) { - RessurrectionTargets.Add(name, DateTime.UtcNow + TimeSpan.FromSeconds(10)); + value = DateTime.UtcNow + TimeSpan.FromSeconds(10); + RessurrectionTargets.Add(name, value); return TryCastSpell(spellName, player.Guid, true); } - if (RessurrectionTargets[name] < DateTime.UtcNow) + if (value < DateTime.UtcNow) { return TryCastSpell(spellName, player.Guid, true); } diff --git a/AmeisenBotX.Core/Engines/Combat/Classes/Jannis/Wotlk335a/PriestHoly.cs b/AmeisenBotX.Core/Engines/Combat/Classes/Jannis/Wotlk335a/PriestHoly.cs index 0ea5796d..8cad3ab0 100644 --- a/AmeisenBotX.Core/Engines/Combat/Classes/Jannis/Wotlk335a/PriestHoly.cs +++ b/AmeisenBotX.Core/Engines/Combat/Classes/Jannis/Wotlk335a/PriestHoly.cs @@ -163,7 +163,7 @@ private bool NeedToHealSomeone() } double healthDifference = target.MaxHealth - target.Health; - List> spellsToTry = SpellUsageHealDict.Where(e => e.Key <= healthDifference).OrderByDescending(e => e.Key).ToList(); + List> spellsToTry = [.. SpellUsageHealDict.Where(e => e.Key <= healthDifference).OrderByDescending(e => e.Key)]; foreach (KeyValuePair keyValuePair in spellsToTry) { diff --git a/AmeisenBotX.Core/Engines/Combat/Classes/Kamel/BasicKamelClass.cs b/AmeisenBotX.Core/Engines/Combat/Classes/Kamel/BasicKamelClass.cs index 00124032..5b57a016 100644 --- a/AmeisenBotX.Core/Engines/Combat/Classes/Kamel/BasicKamelClass.cs +++ b/AmeisenBotX.Core/Engines/Combat/Classes/Kamel/BasicKamelClass.cs @@ -51,19 +51,19 @@ public abstract class BasicKamelClass : ICombatClass public readonly Dictionary spellCoolDown = []; - private readonly int[] useableHealingItems = new int[] - { + private readonly int[] useableHealingItems = + [ // potions 118, 929, 1710, 2938, 3928, 4596, 5509, 13446, 22829, 33447, // healthstones 5509, 5510, 5511, 5512, 9421, 19013, 22103, 36889, 36892, - }; + ]; - private readonly int[] useableManaItems = new int[] - { + private readonly int[] useableManaItems = + [ // potions 2245, 3385, 3827, 6149, 13443, 13444, 33448, 22832, - }; + ]; protected BasicKamelClass() { @@ -177,9 +177,9 @@ public void ChangeTargetToAttack() public bool CheckForWeaponEnchantment(WowEquipmentSlot slot, string enchantmentName, string spellToCastEnchantment) { - if (Bot.Character.Equipment.Items.ContainsKey(slot)) + if (Bot.Character.Equipment.Items.TryGetValue(slot, out IWowInventoryItem value)) { - int itemId = Bot.Character.Equipment.Items[slot].Id; + int itemId = value.Id; if (itemId > 0) { @@ -324,7 +324,7 @@ public void RevivePartyMember(string reviveSpellName) Bot.Player }; - partyMemberToHeal = partyMemberToHeal.Where(e => e.IsDead).OrderBy(e => e.HealthPercentage).ToList(); + partyMemberToHeal = [.. partyMemberToHeal.Where(e => e.IsDead).OrderBy(e => e.HealthPercentage)]; if (RevivePlayerEvent.Run() && partyMemberToHeal.Count > 0) { diff --git a/AmeisenBotX.Core/Engines/Combat/Classes/Kamel/DeathknightBlood.cs b/AmeisenBotX.Core/Engines/Combat/Classes/Kamel/DeathknightBlood.cs index f848d611..23411312 100644 --- a/AmeisenBotX.Core/Engines/Combat/Classes/Kamel/DeathknightBlood.cs +++ b/AmeisenBotX.Core/Engines/Combat/Classes/Kamel/DeathknightBlood.cs @@ -13,14 +13,8 @@ namespace AmeisenBotX.Core.Engines.Combat.Classes.Kamel { - public class DeathknightBlood : ICombatClass + public class DeathknightBlood(AmeisenBotInterfaces bot) : ICombatClass { - public DeathknightBlood(AmeisenBotInterfaces bot) - { - Bot = bot; - TargetProvider = new TargetManager(new SimpleDpsTargetSelectionLogic(bot), TimeSpan.FromMilliseconds(250));//Heal/Tank/DPS - } - public string Author => "Kamel"; public IEnumerable BlacklistedTargetDisplayIds { get; set; } @@ -47,7 +41,7 @@ public DeathknightBlood(AmeisenBotInterfaces bot) public bool TargetInLineOfSight { get; set; } - public ITargetProvider TargetProvider { get; internal set; } + public ITargetProvider TargetProvider { get; internal set; } = new TargetManager(new SimpleDpsTargetSelectionLogic(bot), TimeSpan.FromMilliseconds(250));//Heal/Tank/DPS public string Version => "1.0"; @@ -55,7 +49,7 @@ public DeathknightBlood(AmeisenBotInterfaces bot) public WowClass WowClass => WowClass.Deathknight; - private AmeisenBotInterfaces Bot { get; } + private AmeisenBotInterfaces Bot { get; } = bot; public void AttackTarget() { diff --git a/AmeisenBotX.Core/Engines/Combat/Classes/Kamel/PaladinProtection.cs b/AmeisenBotX.Core/Engines/Combat/Classes/Kamel/PaladinProtection.cs index 3656e8f9..d03f8991 100644 --- a/AmeisenBotX.Core/Engines/Combat/Classes/Kamel/PaladinProtection.cs +++ b/AmeisenBotX.Core/Engines/Combat/Classes/Kamel/PaladinProtection.cs @@ -167,7 +167,10 @@ private void BuffManager() Bot.Player }; - CastBuff = CastBuff.Where(e => !e.Auras.Any(e => Bot.Db.GetSpellName(e.SpellId) == "Blessing of Kings") && !e.IsDead).OrderBy(e => e.HealthPercentage).ToList(); + CastBuff = + [ + .. CastBuff.Where(e => !e.Auras.Any(e => Bot.Db.GetSpellName(e.SpellId) == "Blessing of Kings") && !e.IsDead).OrderBy(e => e.HealthPercentage), + ]; if (CastBuff != null) { diff --git a/AmeisenBotX.Core/Engines/Combat/Classes/Kamel/PriestHoly.cs b/AmeisenBotX.Core/Engines/Combat/Classes/Kamel/PriestHoly.cs index a6fc3d13..291ec069 100644 --- a/AmeisenBotX.Core/Engines/Combat/Classes/Kamel/PriestHoly.cs +++ b/AmeisenBotX.Core/Engines/Combat/Classes/Kamel/PriestHoly.cs @@ -180,7 +180,10 @@ private void BuffManager() Bot.Player }; - CastBuff = CastBuff.Where(e => (!e.Auras.Any(e => Bot.Db.GetSpellName(e.SpellId) == "Prayer of Fortitude") || !e.Auras.Any(e => Bot.Db.GetSpellName(e.SpellId) == "Prayer of Shadow Protection")) && !e.IsDead).OrderBy(e => e.HealthPercentage).ToList(); + CastBuff = + [ + .. CastBuff.Where(e => (!e.Auras.Any(e => Bot.Db.GetSpellName(e.SpellId) == "Prayer of Fortitude") || !e.Auras.Any(e => Bot.Db.GetSpellName(e.SpellId) == "Prayer of Shadow Protection")) && !e.IsDead).OrderBy(e => e.HealthPercentage), + ]; if (CastBuff != null) { @@ -274,7 +277,7 @@ private void StartHeal() Bot.Player }; - partyMemberToHeal = partyMemberToHeal.Where(e => e.HealthPercentage <= 94 && !e.IsDead).OrderBy(e => e.HealthPercentage).ToList(); + partyMemberToHeal = [.. partyMemberToHeal.Where(e => e.HealthPercentage <= 94 && !e.IsDead).OrderBy(e => e.HealthPercentage)]; if (partyMemberToHeal.Count > 0) { diff --git a/AmeisenBotX.Core/Engines/Combat/Classes/Kamel/RestorationShaman .cs b/AmeisenBotX.Core/Engines/Combat/Classes/Kamel/RestorationShaman .cs index 1cbeb07b..25b3789e 100644 --- a/AmeisenBotX.Core/Engines/Combat/Classes/Kamel/RestorationShaman .cs +++ b/AmeisenBotX.Core/Engines/Combat/Classes/Kamel/RestorationShaman .cs @@ -209,7 +209,7 @@ private void StartHeal() Bot.Player }; - partyMemberToHeal = partyMemberToHeal.Where(e => e.HealthPercentage <= 94 && !e.IsDead).OrderBy(e => e.HealthPercentage).ToList(); + partyMemberToHeal = [.. partyMemberToHeal.Where(e => e.HealthPercentage <= 94 && !e.IsDead).OrderBy(e => e.HealthPercentage)]; if (partyMemberToHeal.Count > 0) { diff --git a/AmeisenBotX.Core/Engines/Combat/Classes/Shino/TemplateCombatClass.cs b/AmeisenBotX.Core/Engines/Combat/Classes/Shino/TemplateCombatClass.cs index 9b978181..cd606ec9 100644 --- a/AmeisenBotX.Core/Engines/Combat/Classes/Shino/TemplateCombatClass.cs +++ b/AmeisenBotX.Core/Engines/Combat/Classes/Shino/TemplateCombatClass.cs @@ -11,14 +11,8 @@ namespace AmeisenBotX.Core.Engines.Combat.Classes.Shino { - public abstract class TemplateCombatClass : BasicCombatClass + public abstract class TemplateCombatClass(AmeisenBotInterfaces bot) : BasicCombatClass(bot) { - public TemplateCombatClass(AmeisenBotInterfaces bot) : base(bot) - { - //this line cause a bug because it run out of index - //Bot.EventHookManager.Subscribe("UI_ERROR_MESSAGE", (t, a) => OnUIErrorMessage(a[0])); - } - public new string Author { get; } = "Shino"; private DateTime LastFailedOpener { get; set; } = DateTime.Now; diff --git a/AmeisenBotX.Core/Engines/Combat/Classes/einTyp/PaladinProtection.cs b/AmeisenBotX.Core/Engines/Combat/Classes/einTyp/PaladinProtection.cs index 62211ed6..fbf655b5 100644 --- a/AmeisenBotX.Core/Engines/Combat/Classes/einTyp/PaladinProtection.cs +++ b/AmeisenBotX.Core/Engines/Combat/Classes/einTyp/PaladinProtection.cs @@ -12,21 +12,16 @@ namespace AmeisenBotX.Core.Engines.Combat.Classes.einTyp { - public class PaladinProtection : ICombatClass + public class PaladinProtection(AmeisenBotInterfaces bot) : ICombatClass { - private readonly AmeisenBotInterfaces Bot; - private readonly string[] runningEmotes = { "/question", "/talk" }; - private readonly string[] standingEmotes = { "/bow" }; + private readonly AmeisenBotInterfaces Bot = bot; + private readonly string[] runningEmotes = ["/question", "/talk"]; + private readonly string[] standingEmotes = ["/bow"]; private bool computeNewRoute = false; private double distanceToTarget = 0; private bool multipleTargets = false; private bool standing = false; - public PaladinProtection(AmeisenBotInterfaces bot) - { - Bot = bot; - } - public string Author => "einTyp"; public IEnumerable BlacklistedTargetDisplayIds { get; set; } diff --git a/AmeisenBotX.Core/Engines/Combat/Classes/einTyp/RogueAssassination.cs b/AmeisenBotX.Core/Engines/Combat/Classes/einTyp/RogueAssassination.cs index eb5390bb..8fccf5c8 100644 --- a/AmeisenBotX.Core/Engines/Combat/Classes/einTyp/RogueAssassination.cs +++ b/AmeisenBotX.Core/Engines/Combat/Classes/einTyp/RogueAssassination.cs @@ -12,12 +12,12 @@ namespace AmeisenBotX.Core.Engines.Combat.Classes.einTyp { - public class RogueAssassination : ICombatClass + public class RogueAssassination(AmeisenBotInterfaces bot) : ICombatClass { - private readonly AmeisenBotInterfaces Bot; + private readonly AmeisenBotInterfaces Bot = bot; private readonly bool hasTargetMoved = false; - private readonly RogueAssassinSpells spells; - private readonly string[] standingEmotes = { "/bored" }; + private readonly RogueAssassinSpells spells = new(bot); + private readonly string[] standingEmotes = ["/bored"]; private bool computeNewRoute = false; private double distanceToBehindTarget = 0; @@ -33,13 +33,6 @@ public class RogueAssassination : ICombatClass private bool wasInStealth = false; - public RogueAssassination(AmeisenBotInterfaces bot) - { - Bot = bot; - - spells = new RogueAssassinSpells(bot); - } - public string Author => "einTyp"; public IEnumerable BlacklistedTargetDisplayIds { get; set; } diff --git a/AmeisenBotX.Core/Engines/Combat/Classes/einTyp/WarriorArms.cs b/AmeisenBotX.Core/Engines/Combat/Classes/einTyp/WarriorArms.cs index 4d5d149f..308b3ef1 100644 --- a/AmeisenBotX.Core/Engines/Combat/Classes/einTyp/WarriorArms.cs +++ b/AmeisenBotX.Core/Engines/Combat/Classes/einTyp/WarriorArms.cs @@ -12,25 +12,18 @@ namespace AmeisenBotX.Core.Engines.Combat.Classes.einTyp { - public class WarriorArms : ICombatClass + public class WarriorArms(AmeisenBotInterfaces bot) : ICombatClass { - private readonly AmeisenBotInterfaces Bot; - private readonly string[] runningEmotes = { "/fart", "/burp", "/moo" }; - private readonly WarriorArmSpells spells; - private readonly string[] standingEmotes = { "/chug", "/pick", "/whistle", "/violin" }; + private readonly AmeisenBotInterfaces Bot = bot; + private readonly string[] runningEmotes = ["/fart", "/burp", "/moo"]; + private readonly WarriorArmSpells spells = new(bot); + private readonly string[] standingEmotes = ["/chug", "/pick", "/whistle", "/violin"]; private bool computeNewRoute = false; private double distanceToTarget = 0; private double distanceTraveled = 0; private bool multipleTargets = false; private bool standing = false; - public WarriorArms(AmeisenBotInterfaces bot) - { - Bot = bot; - - spells = new WarriorArmSpells(bot); - } - public string Author => "einTyp"; public IEnumerable BlacklistedTargetDisplayIds { get; set; } diff --git a/AmeisenBotX.Core/Engines/Combat/Classes/einTyp/WarriorFury.cs b/AmeisenBotX.Core/Engines/Combat/Classes/einTyp/WarriorFury.cs index 77188390..b44995ce 100644 --- a/AmeisenBotX.Core/Engines/Combat/Classes/einTyp/WarriorFury.cs +++ b/AmeisenBotX.Core/Engines/Combat/Classes/einTyp/WarriorFury.cs @@ -12,12 +12,12 @@ namespace AmeisenBotX.Core.Engines.Combat.Classes.einTyp { - public class WarriorFury : ICombatClass + public class WarriorFury(AmeisenBotInterfaces bot) : ICombatClass { - private readonly AmeisenBotInterfaces Bot; - private readonly string[] runningEmotes = { "/train", "/cackle", "/silly" }; - private readonly WarriorFurySpells spells; - private readonly string[] standingEmotes = { "/shimmy", "/dance", "/twiddle", "/highfive" }; + private readonly AmeisenBotInterfaces Bot = bot; + private readonly string[] runningEmotes = ["/train", "/cackle", "/silly"]; + private readonly WarriorFurySpells spells = new(bot); + private readonly string[] standingEmotes = ["/shimmy", "/dance", "/twiddle", "/highfive"]; private bool computeNewRoute = false; private double distanceToTarget = 0; @@ -26,13 +26,6 @@ public class WarriorFury : ICombatClass private bool multipleTargets = false; private bool standing = false; - public WarriorFury(AmeisenBotInterfaces bot) - { - Bot = bot; - - spells = new WarriorFurySpells(bot); - } - public string Author => "einTyp"; public IEnumerable BlacklistedTargetDisplayIds { get; set; } diff --git a/AmeisenBotX.Core/Engines/Combat/Helpers/Aura/AuraManager.cs b/AmeisenBotX.Core/Engines/Combat/Helpers/Aura/AuraManager.cs index 6f56c937..c16e020c 100644 --- a/AmeisenBotX.Core/Engines/Combat/Helpers/Aura/AuraManager.cs +++ b/AmeisenBotX.Core/Engines/Combat/Helpers/Aura/AuraManager.cs @@ -4,17 +4,11 @@ namespace AmeisenBotX.Core.Engines.Combat.Helpers.Aura { - public class AuraManager + public class AuraManager(AmeisenBotInterfaces bot) { - public AuraManager(AmeisenBotInterfaces bot) - { - Bot = bot; - Jobs = []; - } - - public AmeisenBotInterfaces Bot { get; } + public AmeisenBotInterfaces Bot { get; } = bot; - public List Jobs { get; set; } + public List Jobs { get; set; } = []; public bool Tick(IEnumerable auras) { diff --git a/AmeisenBotX.Core/Engines/Combat/Helpers/Aura/GroupAuraManager.cs b/AmeisenBotX.Core/Engines/Combat/Helpers/Aura/GroupAuraManager.cs index d44a9bbd..9399a8fa 100644 --- a/AmeisenBotX.Core/Engines/Combat/Helpers/Aura/GroupAuraManager.cs +++ b/AmeisenBotX.Core/Engines/Combat/Helpers/Aura/GroupAuraManager.cs @@ -7,25 +7,17 @@ namespace AmeisenBotX.Core.Engines.Combat.Helpers.Aura { - public class GroupAuraManager + public class GroupAuraManager(AmeisenBotInterfaces bot) { - public GroupAuraManager(AmeisenBotInterfaces bot) - { - Bot = bot; - SpellsToKeepActiveOnParty = []; - RemoveBadAurasSpells = []; - LastBuffed = []; - } - public delegate bool CastSpellOnUnit(string spellName, ulong guid); - public List<((string, WowDispelType), CastSpellOnUnit)> RemoveBadAurasSpells { get; private set; } + public List<((string, WowDispelType), CastSpellOnUnit)> RemoveBadAurasSpells { get; private set; } = []; - public List<(string, CastSpellOnUnit)> SpellsToKeepActiveOnParty { get; private set; } + public List<(string, CastSpellOnUnit)> SpellsToKeepActiveOnParty { get; private set; } = []; - private AmeisenBotInterfaces Bot { get; } + private AmeisenBotInterfaces Bot { get; } = bot; - private Dictionary LastBuffed { get; } + private Dictionary LastBuffed { get; } = []; public bool Tick() { @@ -37,11 +29,11 @@ public bool Tick() { if (!wowUnit.Auras.Any(e => Bot.Db.GetSpellName(e.SpellId) == auraCombo.Item1)) { - if (!LastBuffed.ContainsKey(wowUnit.Guid)) + if (!LastBuffed.TryGetValue(wowUnit.Guid, out TimegatedEvent value)) { LastBuffed.Add(wowUnit.Guid, new(TimeSpan.FromSeconds(30))); } - else if (LastBuffed[wowUnit.Guid].Run()) + else if (value.Run()) { return auraCombo.Item2.Invoke(auraCombo.Item1, wowUnit.Guid); } diff --git a/AmeisenBotX.Core/Engines/Combat/Helpers/Aura/Objects/KeepActiveAuraJob.cs b/AmeisenBotX.Core/Engines/Combat/Helpers/Aura/Objects/KeepActiveAuraJob.cs index 6e2cd0fb..9c09f754 100644 --- a/AmeisenBotX.Core/Engines/Combat/Helpers/Aura/Objects/KeepActiveAuraJob.cs +++ b/AmeisenBotX.Core/Engines/Combat/Helpers/Aura/Objects/KeepActiveAuraJob.cs @@ -6,20 +6,13 @@ namespace AmeisenBotX.Core.Engines.Combat.Helpers.Aura.Objects { - public class KeepActiveAuraJob : IAuraJob + public class KeepActiveAuraJob(IAmeisenBotDb db, string name, Func action) : IAuraJob { - public KeepActiveAuraJob(IAmeisenBotDb db, string name, Func action) - { - Db = db; - Name = name; - Action = action; - } - - public Func Action { get; set; } + public Func Action { get; set; } = action; - public string Name { get; set; } + public string Name { get; set; } = name; - private IAmeisenBotDb Db { get; } + private IAmeisenBotDb Db { get; } = db; public bool Run(IEnumerable auras) { diff --git a/AmeisenBotX.Core/Engines/Combat/Helpers/Aura/Objects/KeepBestActiveAuraJob.cs b/AmeisenBotX.Core/Engines/Combat/Helpers/Aura/Objects/KeepBestActiveAuraJob.cs index fb5723c6..640263fe 100644 --- a/AmeisenBotX.Core/Engines/Combat/Helpers/Aura/Objects/KeepBestActiveAuraJob.cs +++ b/AmeisenBotX.Core/Engines/Combat/Helpers/Aura/Objects/KeepBestActiveAuraJob.cs @@ -6,17 +6,11 @@ namespace AmeisenBotX.Core.Engines.Combat.Helpers.Aura.Objects { - public class KeepBestActiveAuraJob : IAuraJob + public class KeepBestActiveAuraJob(IAmeisenBotDb db, IEnumerable<(string, Func)> actions) : IAuraJob { - public KeepBestActiveAuraJob(IAmeisenBotDb db, IEnumerable<(string, Func)> actions) - { - Db = db; - Actions = actions; - } - - public IEnumerable<(string, Func)> Actions { get; set; } + public IEnumerable<(string, Func)> Actions { get; set; } = actions; - private IAmeisenBotDb Db { get; } + private IAmeisenBotDb Db { get; } = db; public bool Run(IEnumerable auras) { diff --git a/AmeisenBotX.Core/Engines/Combat/Helpers/PetManager.cs b/AmeisenBotX.Core/Engines/Combat/Helpers/PetManager.cs index 120ff59a..5dfe5bd6 100644 --- a/AmeisenBotX.Core/Engines/Combat/Helpers/PetManager.cs +++ b/AmeisenBotX.Core/Engines/Combat/Helpers/PetManager.cs @@ -3,32 +3,21 @@ namespace AmeisenBotX.Core.Engines.Combat.Helpers { - public class PetManager + public class PetManager(AmeisenBotInterfaces bot, TimeSpan healPetCooldown, Func castMendPetFunction, Func castCallPetFunction, Func castRevivePetFunction) { - public PetManager(AmeisenBotInterfaces bot, TimeSpan healPetCooldown, Func castMendPetFunction, Func castCallPetFunction, Func castRevivePetFunction) - { - Bot = bot; - HealPetCooldown = healPetCooldown; - CastMendPet = castMendPetFunction; - CastCallPet = castCallPetFunction; - CastRevivePet = castRevivePetFunction; - - CallPetEvent = new(TimeSpan.FromSeconds(8)); - } - - public AmeisenBotInterfaces Bot { get; set; } + public AmeisenBotInterfaces Bot { get; set; } = bot; - public Func CastCallPet { get; set; } + public Func CastCallPet { get; set; } = castCallPetFunction; - public Func CastMendPet { get; set; } + public Func CastMendPet { get; set; } = castMendPetFunction; - public Func CastRevivePet { get; set; } + public Func CastRevivePet { get; set; } = castRevivePetFunction; - public TimeSpan HealPetCooldown { get; set; } + public TimeSpan HealPetCooldown { get; set; } = healPetCooldown; public DateTime LastMendPetUsed { get; private set; } - private TimegatedEvent CallPetEvent { get; } + private TimegatedEvent CallPetEvent { get; } = new(TimeSpan.FromSeconds(8)); private bool CallReviveToggle { get; set; } diff --git a/AmeisenBotX.Core/Engines/Combat/Helpers/Targets/Logics/BasicTargetSelectionLogic.cs b/AmeisenBotX.Core/Engines/Combat/Helpers/Targets/Logics/BasicTargetSelectionLogic.cs index 30671b88..f60623f0 100644 --- a/AmeisenBotX.Core/Engines/Combat/Helpers/Targets/Logics/BasicTargetSelectionLogic.cs +++ b/AmeisenBotX.Core/Engines/Combat/Helpers/Targets/Logics/BasicTargetSelectionLogic.cs @@ -8,24 +8,17 @@ namespace AmeisenBotX.Core.Engines.Combat.Helpers.Targets.Logics { - public abstract class BasicTargetSelectionLogic + public abstract class BasicTargetSelectionLogic(AmeisenBotInterfaces bot) { - public BasicTargetSelectionLogic(AmeisenBotInterfaces bot) - { - Bot = bot; - TargetValidator = new(new IsValidAliveTargetValidator()); - TargetPrioritizer = new(); - } - public IEnumerable BlacklistedTargets { get; set; } - public AmeisenBotInterfaces Bot { get; } + public AmeisenBotInterfaces Bot { get; } = bot; public IEnumerable PriorityTargets { get; set; } - public TargetPriorityManager TargetPrioritizer { get; set; } + public TargetPriorityManager TargetPrioritizer { get; set; } = new(); - public TargetValidationManager TargetValidator { get; set; } + public TargetValidationManager TargetValidator { get; set; } = new(new IsValidAliveTargetValidator()); public abstract bool SelectTarget(out IEnumerable wowUnit); diff --git a/AmeisenBotX.Core/Engines/Combat/Helpers/Targets/Logics/Heal/SimpleHealTargetSelectionLogic.cs b/AmeisenBotX.Core/Engines/Combat/Helpers/Targets/Logics/Heal/SimpleHealTargetSelectionLogic.cs index 430832e9..de82dfa1 100644 --- a/AmeisenBotX.Core/Engines/Combat/Helpers/Targets/Logics/Heal/SimpleHealTargetSelectionLogic.cs +++ b/AmeisenBotX.Core/Engines/Combat/Helpers/Targets/Logics/Heal/SimpleHealTargetSelectionLogic.cs @@ -4,12 +4,8 @@ namespace AmeisenBotX.Core.Engines.Combat.Helpers.Targets.Logics.Heal { - public class SimpleHealTargetSelectionLogic : BasicTargetSelectionLogic + public class SimpleHealTargetSelectionLogic(AmeisenBotInterfaces bot) : BasicTargetSelectionLogic(bot) { - public SimpleHealTargetSelectionLogic(AmeisenBotInterfaces bot) : base(bot) - { - } - public override bool SelectTarget(out IEnumerable possibleTargets) { List healableUnits = new(Bot.Objects.Partymembers) diff --git a/AmeisenBotX.Core/Engines/Combat/Helpers/Targets/Priority/Basic/ListTargetPrioritizer.cs b/AmeisenBotX.Core/Engines/Combat/Helpers/Targets/Priority/Basic/ListTargetPrioritizer.cs index ddc1400d..70ed7c83 100644 --- a/AmeisenBotX.Core/Engines/Combat/Helpers/Targets/Priority/Basic/ListTargetPrioritizer.cs +++ b/AmeisenBotX.Core/Engines/Combat/Helpers/Targets/Priority/Basic/ListTargetPrioritizer.cs @@ -4,14 +4,9 @@ namespace AmeisenBotX.Core.Engines.Combat.Helpers.Targets.Priority.Basic { - public class ListTargetPrioritizer : ITargetPrioritizer + public class ListTargetPrioritizer(IEnumerable priorityDisplayIds = null) : ITargetPrioritizer { - public ListTargetPrioritizer(IEnumerable priorityDisplayIds = null) - { - PriorityDisplayIds = priorityDisplayIds ?? new List(); - } - - public IEnumerable PriorityDisplayIds { get; set; } + public IEnumerable PriorityDisplayIds { get; set; } = priorityDisplayIds ?? new List(); public bool HasPriority(IWowUnit unit) { diff --git a/AmeisenBotX.Core/Engines/Combat/Helpers/Targets/Validation/Basic/DisplayIdBlacklistTargetValidator.cs b/AmeisenBotX.Core/Engines/Combat/Helpers/Targets/Validation/Basic/DisplayIdBlacklistTargetValidator.cs index 93ebf07f..70adb486 100644 --- a/AmeisenBotX.Core/Engines/Combat/Helpers/Targets/Validation/Basic/DisplayIdBlacklistTargetValidator.cs +++ b/AmeisenBotX.Core/Engines/Combat/Helpers/Targets/Validation/Basic/DisplayIdBlacklistTargetValidator.cs @@ -4,14 +4,9 @@ namespace AmeisenBotX.Core.Engines.Combat.Helpers.Targets.Validation.Basic { - public class DisplayIdBlacklistTargetValidator : ITargetValidator + public class DisplayIdBlacklistTargetValidator(IEnumerable blacklistedGuids = null) : ITargetValidator { - public DisplayIdBlacklistTargetValidator(IEnumerable blacklistedGuids = null) - { - Blacklist = blacklistedGuids ?? new List(); - } - - public IEnumerable Blacklist { get; set; } + public IEnumerable Blacklist { get; set; } = blacklistedGuids ?? new List(); public bool IsValid(IWowUnit unit) { diff --git a/AmeisenBotX.Core/Engines/Combat/Helpers/Targets/Validation/Basic/IsAttackableTargetValidator.cs b/AmeisenBotX.Core/Engines/Combat/Helpers/Targets/Validation/Basic/IsAttackableTargetValidator.cs index 7697e7b1..6719beb3 100644 --- a/AmeisenBotX.Core/Engines/Combat/Helpers/Targets/Validation/Basic/IsAttackableTargetValidator.cs +++ b/AmeisenBotX.Core/Engines/Combat/Helpers/Targets/Validation/Basic/IsAttackableTargetValidator.cs @@ -3,14 +3,9 @@ namespace AmeisenBotX.Core.Engines.Combat.Helpers.Targets.Validation.Basic { - public class IsAttackableTargetValidator : ITargetValidator + public class IsAttackableTargetValidator(AmeisenBotInterfaces bot) : ITargetValidator { - public IsAttackableTargetValidator(AmeisenBotInterfaces bot) - { - Bot = bot; - } - - private AmeisenBotInterfaces Bot { get; } + private AmeisenBotInterfaces Bot { get; } = bot; public bool IsValid(IWowUnit unit) { diff --git a/AmeisenBotX.Core/Engines/Combat/Helpers/Targets/Validation/Basic/IsInCombatTargetValidator.cs b/AmeisenBotX.Core/Engines/Combat/Helpers/Targets/Validation/Basic/IsInCombatTargetValidator.cs index ab6e51ef..9b759ef5 100644 --- a/AmeisenBotX.Core/Engines/Combat/Helpers/Targets/Validation/Basic/IsInCombatTargetValidator.cs +++ b/AmeisenBotX.Core/Engines/Combat/Helpers/Targets/Validation/Basic/IsInCombatTargetValidator.cs @@ -3,14 +3,9 @@ namespace AmeisenBotX.Core.Engines.Combat.Helpers.Targets.Validation.Basic { - public class IsThreatTargetValidator : ITargetValidator + public class IsThreatTargetValidator(AmeisenBotInterfaces bot) : ITargetValidator { - public IsThreatTargetValidator(AmeisenBotInterfaces bot) - { - Bot = bot; - } - - private AmeisenBotInterfaces Bot { get; } + private AmeisenBotInterfaces Bot { get; } = bot; public bool IsValid(IWowUnit unit) { diff --git a/AmeisenBotX.Core/Engines/Combat/Helpers/Targets/Validation/Basic/IsReachableTargetValidator.cs b/AmeisenBotX.Core/Engines/Combat/Helpers/Targets/Validation/Basic/IsReachableTargetValidator.cs index f732c220..8bc58f0e 100644 --- a/AmeisenBotX.Core/Engines/Combat/Helpers/Targets/Validation/Basic/IsReachableTargetValidator.cs +++ b/AmeisenBotX.Core/Engines/Combat/Helpers/Targets/Validation/Basic/IsReachableTargetValidator.cs @@ -6,17 +6,11 @@ namespace AmeisenBotX.Core.Engines.Combat.Helpers.Targets.Validation.Basic { - public class IsReachableTargetValidator : ITargetValidator + public class IsReachableTargetValidator(AmeisenBotInterfaces bot, float maxDistance = 80.0f) : ITargetValidator { - public IsReachableTargetValidator(AmeisenBotInterfaces bot, float maxDistance = 80.0f) - { - Bot = bot; - MaxDistance = maxDistance; - } - - private AmeisenBotInterfaces Bot { get; } + private AmeisenBotInterfaces Bot { get; } = bot; - private float MaxDistance { get; } + private float MaxDistance { get; } = maxDistance; public bool IsValid(IWowUnit unit) { diff --git a/AmeisenBotX.Core/Engines/Dungeon/Objects/DungeonNode.cs b/AmeisenBotX.Core/Engines/Dungeon/Objects/DungeonNode.cs index de90de73..d36212a0 100644 --- a/AmeisenBotX.Core/Engines/Dungeon/Objects/DungeonNode.cs +++ b/AmeisenBotX.Core/Engines/Dungeon/Objects/DungeonNode.cs @@ -3,19 +3,12 @@ namespace AmeisenBotX.Core.Engines.Dungeon.Objects { - public class DungeonNode + public class DungeonNode(Vector3 position, DungeonNodeType type = DungeonNodeType.Normal, string extra = "") { - public DungeonNode(Vector3 position, DungeonNodeType type = DungeonNodeType.Normal, string extra = "") - { - Position = position; - Type = type; - Extra = extra; - } + public string Extra { get; } = extra; - public string Extra { get; } + public Vector3 Position { get; } = position; - public Vector3 Position { get; } - - public DungeonNodeType Type { get; } + public DungeonNodeType Type { get; } = type; } } \ No newline at end of file diff --git a/AmeisenBotX.Core/Engines/Movement/MovementEngine.cs b/AmeisenBotX.Core/Engines/Movement/MovementEngine.cs index 9746d9df..95b83afc 100644 --- a/AmeisenBotX.Core/Engines/Movement/MovementEngine.cs +++ b/AmeisenBotX.Core/Engines/Movement/MovementEngine.cs @@ -10,23 +10,8 @@ namespace AmeisenBotX.Core.Engines.Movement { - public class MovementEngine : IMovementEngine + public class MovementEngine(AmeisenBotInterfaces bot, AmeisenBotConfig config) : IMovementEngine { - public MovementEngine(AmeisenBotInterfaces bot, AmeisenBotConfig config) - { - Bot = bot; - Config = config; - - FindPathEvent = new(TimeSpan.FromMilliseconds(500)); - RefreshPathEvent = new(TimeSpan.FromMilliseconds(500)); - DistanceMovedCheckEvent = new(TimeSpan.FromMilliseconds(500)); - - PathQueue = new(); - PlacesToAvoidList = []; - - PlayerVehicle = new(bot); - } - public float CurrentSpeed { get; private set; } public bool IsAllowedToMove => DateTime.UtcNow > MovementBlockedUntil; @@ -47,27 +32,27 @@ public MovementEngine(AmeisenBotInterfaces bot, AmeisenBotConfig config) public Vector3 UnstuckTarget { get; private set; } - private AmeisenBotInterfaces Bot { get; } + private AmeisenBotInterfaces Bot { get; } = bot; - private AmeisenBotConfig Config { get; } + private AmeisenBotConfig Config { get; } = config; - private TimegatedEvent DistanceMovedCheckEvent { get; } + private TimegatedEvent DistanceMovedCheckEvent { get; } = new(TimeSpan.FromMilliseconds(500)); - private TimegatedEvent FindPathEvent { get; } + private TimegatedEvent FindPathEvent { get; } = new(TimeSpan.FromMilliseconds(500)); private Vector3 LastTargetPosition { get; set; } private DateTime MovementBlockedUntil { get; set; } - private Queue PathQueue { get; set; } + private Queue PathQueue { get; set; } = new(); - private List<(Vector3 position, float radius, DateTime until)> PlacesToAvoidList { get; set; } + private List<(Vector3 position, float radius, DateTime until)> PlacesToAvoidList { get; set; } = []; - private BasicVehicle PlayerVehicle { get; set; } + private BasicVehicle PlayerVehicle { get; set; } = new(bot); private PreventMovementType PreventMovementType { get; set; } - private TimegatedEvent RefreshPathEvent { get; } + private TimegatedEvent RefreshPathEvent { get; } = new(TimeSpan.FromMilliseconds(500)); private bool TriedToMountUp { get; set; } @@ -254,7 +239,7 @@ private bool AvoidAoeStuff(Vector3 position, out Vector3 newPosition) places.AddRange(aoeEffects.Select(e => (e.Position, e.Radius))); } - if (places.Any()) + if (places.Count != 0) { // build mean position and move away x meters from it x is the biggest distance // we have to move diff --git a/AmeisenBotX.Core/Engines/Movement/MovementManager.cs b/AmeisenBotX.Core/Engines/Movement/MovementManager.cs index bbb58432..4abeedf7 100644 --- a/AmeisenBotX.Core/Engines/Movement/MovementManager.cs +++ b/AmeisenBotX.Core/Engines/Movement/MovementManager.cs @@ -4,14 +4,9 @@ namespace AmeisenBotX.Core.Engines.Movement { - public class MovementManager + public class MovementManager(IEnumerable providers) { - public MovementManager(IEnumerable providers) - { - Providers = providers; - } - - public IEnumerable Providers { get; set; } + public IEnumerable Providers { get; set; } = providers; public Vector3 Target { get; private set; } diff --git a/AmeisenBotX.Core/Engines/Movement/Objects/BasicVehicle.cs b/AmeisenBotX.Core/Engines/Movement/Objects/BasicVehicle.cs index 646a2d2f..57c30aa9 100644 --- a/AmeisenBotX.Core/Engines/Movement/Objects/BasicVehicle.cs +++ b/AmeisenBotX.Core/Engines/Movement/Objects/BasicVehicle.cs @@ -7,20 +7,15 @@ namespace AmeisenBotX.Core.Engines.Movement.Objects { - public class BasicVehicle + public class BasicVehicle(AmeisenBotInterfaces bot) { - public BasicVehicle(AmeisenBotInterfaces bot) - { - Bot = bot; - } - public delegate void MoveCharacter(Vector3 positionToGoTo); public DateTime LastUpdate { get; private set; } public Vector3 Velocity { get; private set; } - private AmeisenBotInterfaces Bot { get; } + private AmeisenBotInterfaces Bot { get; } = bot; public Vector3 AvoidObstacles(float maxSteering, float maxVelocity, float multiplier) { diff --git a/AmeisenBotX.Core/Engines/Movement/Pathfinding/AmeisenNavigationHandler.cs b/AmeisenBotX.Core/Engines/Movement/Pathfinding/AmeisenNavigationHandler.cs index 8b6d4553..75c75918 100644 --- a/AmeisenBotX.Core/Engines/Movement/Pathfinding/AmeisenNavigationHandler.cs +++ b/AmeisenBotX.Core/Engines/Movement/Pathfinding/AmeisenNavigationHandler.cs @@ -26,7 +26,7 @@ public IEnumerable GetPath(int mapId, Vector3 origin, Vector3 target) { try { - return Client.IsConnected ? Client.Send((byte)EMessageType.PATH, (mapId, origin, target, 2)).AsArray() : Array.Empty(); + return Client.IsConnected ? Client.Send((byte)EMessageType.PATH, (mapId, origin, target, 2)).AsArray() : []; } catch { diff --git a/AmeisenBotX.Core/Engines/Movement/Pathfinding/Objects/SearchAreaEnsamble.cs b/AmeisenBotX.Core/Engines/Movement/Pathfinding/Objects/SearchAreaEnsamble.cs index ebcf5e78..f7dad052 100644 --- a/AmeisenBotX.Core/Engines/Movement/Pathfinding/Objects/SearchAreaEnsamble.cs +++ b/AmeisenBotX.Core/Engines/Movement/Pathfinding/Objects/SearchAreaEnsamble.cs @@ -8,6 +8,7 @@ internal class SearchAreaEnsamble public SearchAreaEnsamble(List> searchAreas) { CurrentSearchArea = 0; + foreach (List area in searchAreas) { Areas.Add(new(area)); diff --git a/AmeisenBotX.Core/Engines/Movement/Providers/Basic/FollowMovementProvider.cs b/AmeisenBotX.Core/Engines/Movement/Providers/Basic/FollowMovementProvider.cs index 45bc9abf..63cdec76 100644 --- a/AmeisenBotX.Core/Engines/Movement/Providers/Basic/FollowMovementProvider.cs +++ b/AmeisenBotX.Core/Engines/Movement/Providers/Basic/FollowMovementProvider.cs @@ -8,26 +8,17 @@ namespace AmeisenBotX.Core.Engines.Movement.Providers.Basic { - public class FollowMovementProvider : IMovementProvider + public class FollowMovementProvider(AmeisenBotInterfaces bot, AmeisenBotConfig config) : IMovementProvider { - public FollowMovementProvider(AmeisenBotInterfaces bot, AmeisenBotConfig config) - { - Bot = bot; - Config = config; - - Random = new(); - OffsetCheckEvent = new(TimeSpan.FromMilliseconds(30000)); - } + private AmeisenBotInterfaces Bot { get; } = bot; - private AmeisenBotInterfaces Bot { get; } - - private AmeisenBotConfig Config { get; } + private AmeisenBotConfig Config { get; } = config; private Vector3 FollowOffset { get; set; } - private TimegatedEvent OffsetCheckEvent { get; } + private TimegatedEvent OffsetCheckEvent { get; } = new(TimeSpan.FromMilliseconds(30000)); - private Random Random { get; } + private Random Random { get; } = new(); public bool Get(out Vector3 position, out MovementAction type) { @@ -74,11 +65,11 @@ private bool IsUnitToFollowThere(out IWowUnit playerToFollow, bool ignoreRange = if (wowPlayers.Any()) { IWowUnit[] playersToTry = - { + [ Config.FollowSpecificCharacter ? wowPlayers.FirstOrDefault(p => Bot.Db.GetUnitName(p, out string name) && name.Equals(Config.SpecificCharacterToFollow, StringComparison.OrdinalIgnoreCase)) : null, Config.FollowGroupLeader ? Bot.Objects.Partyleader : null, Config.FollowGroupMembers ? Bot.Objects.Partymembers.FirstOrDefault() : null - }; + ]; foreach (IWowUnit unit in playersToTry) { diff --git a/AmeisenBotX.Core/Engines/Movement/Providers/Basic/SimpleCombatMovementProvider.cs b/AmeisenBotX.Core/Engines/Movement/Providers/Basic/SimpleCombatMovementProvider.cs index 649f175a..49464ae6 100644 --- a/AmeisenBotX.Core/Engines/Movement/Providers/Basic/SimpleCombatMovementProvider.cs +++ b/AmeisenBotX.Core/Engines/Movement/Providers/Basic/SimpleCombatMovementProvider.cs @@ -5,14 +5,9 @@ namespace AmeisenBotX.Core.Engines.Movement.Providers.Basic { - public class SimpleCombatMovementProvider : IMovementProvider + public class SimpleCombatMovementProvider(AmeisenBotInterfaces bot) : IMovementProvider { - public SimpleCombatMovementProvider(AmeisenBotInterfaces bot) - { - Bot = bot; - } - - private AmeisenBotInterfaces Bot { get; } + private AmeisenBotInterfaces Bot { get; } = bot; public bool Get(out Vector3 position, out MovementAction type) { diff --git a/AmeisenBotX.Core/Engines/Movement/Providers/Basic/StayAroundMovementProvider.cs b/AmeisenBotX.Core/Engines/Movement/Providers/Basic/StayAroundMovementProvider.cs index 663e6cc5..b3ea608c 100644 --- a/AmeisenBotX.Core/Engines/Movement/Providers/Basic/StayAroundMovementProvider.cs +++ b/AmeisenBotX.Core/Engines/Movement/Providers/Basic/StayAroundMovementProvider.cs @@ -5,14 +5,9 @@ namespace AmeisenBotX.Core.Engines.Movement.Providers.Basic { - public class StayAroundMovementProvider : IMovementProvider + public class StayAroundMovementProvider(Func<(IWowUnit, float, float)> getUnit) : IMovementProvider { - public StayAroundMovementProvider(Func<(IWowUnit, float, float)> getUnit) - { - GetUnit = getUnit; - } - - public Func<(IWowUnit, float, float)> GetUnit { get; } + public Func<(IWowUnit, float, float)> GetUnit { get; } = getUnit; public bool Get(out Vector3 position, out MovementAction type) { diff --git a/AmeisenBotX.Core/Engines/PvP/DefaultPvpEngine.cs b/AmeisenBotX.Core/Engines/PvP/DefaultPvpEngine.cs index 37a46b49..0b558003 100644 --- a/AmeisenBotX.Core/Engines/PvP/DefaultPvpEngine.cs +++ b/AmeisenBotX.Core/Engines/PvP/DefaultPvpEngine.cs @@ -15,8 +15,6 @@ public DefaultPvpEngine(AmeisenBotInterfaces bot, AmeisenBotConfig config) ( new Leaf(() => BtStatus.Ongoing), (() => QueueStatus == 0, new Leaf(QueueForBattlegrounds)) - // (() => QueueStatus == 2, new Leaf(() => { Bot.Wow.AcceptBattlegroundInvite(); return - // BtStatus.Success; })) ); Bt = new(mainNode); diff --git a/AmeisenBotX.Core/Engines/Quest/DefaultQuestEngine.cs b/AmeisenBotX.Core/Engines/Quest/DefaultQuestEngine.cs index efa823e8..d6544259 100644 --- a/AmeisenBotX.Core/Engines/Quest/DefaultQuestEngine.cs +++ b/AmeisenBotX.Core/Engines/Quest/DefaultQuestEngine.cs @@ -7,27 +7,19 @@ namespace AmeisenBotX.Core.Engines.Quest { - public class DefaultQuestEngine : IQuestEngine + public class DefaultQuestEngine(AmeisenBotInterfaces bot) : IQuestEngine { - public DefaultQuestEngine(AmeisenBotInterfaces bot) - { - Bot = bot; - - CompletedQuests = []; - QueryCompletedQuestsEvent = new(TimeSpan.FromSeconds(2)); - } - - public List CompletedQuests { get; private set; } + public List CompletedQuests { get; private set; } = []; public IQuestProfile Profile { get; set; } public bool UpdatedCompletedQuests { get; set; } - private AmeisenBotInterfaces Bot { get; } + private AmeisenBotInterfaces Bot { get; } = bot; private DateTime LastAbandonQuestTime { get; set; } = DateTime.UtcNow; - private TimegatedEvent QueryCompletedQuestsEvent { get; } + private TimegatedEvent QueryCompletedQuestsEvent { get; } = new(TimeSpan.FromSeconds(2)); public void Enter() { diff --git a/AmeisenBotX.Core/Engines/Quest/Objects/AreaNode.cs b/AmeisenBotX.Core/Engines/Quest/Objects/AreaNode.cs index 0a40f589..01c55d02 100644 --- a/AmeisenBotX.Core/Engines/Quest/Objects/AreaNode.cs +++ b/AmeisenBotX.Core/Engines/Quest/Objects/AreaNode.cs @@ -2,16 +2,10 @@ namespace AmeisenBotX.Core.Engines.Quest.Objects { - public class AreaNode + public class AreaNode(Vector3 position, double radius) { - public AreaNode(Vector3 position, double radius) - { - Position = position; - Radius = radius; - } + public Vector3 Position { get; set; } = position; - public Vector3 Position { get; set; } - - public double Radius { get; set; } + public double Radius { get; set; } = radius; } } \ No newline at end of file diff --git a/AmeisenBotX.Core/Engines/Quest/Objects/Objectives/BotActionQuestObjective.cs b/AmeisenBotX.Core/Engines/Quest/Objects/Objectives/BotActionQuestObjective.cs index 295a2473..9cf8cdce 100644 --- a/AmeisenBotX.Core/Engines/Quest/Objects/Objectives/BotActionQuestObjective.cs +++ b/AmeisenBotX.Core/Engines/Quest/Objects/Objectives/BotActionQuestObjective.cs @@ -2,14 +2,9 @@ namespace AmeisenBotX.Core.Engines.Quest.Objects.Objectives { - public class BotActionQuestObjective : IQuestObjective + public class BotActionQuestObjective(Action action) : IQuestObjective { - public BotActionQuestObjective(Action action) - { - Action = action; - } - - public Action Action { get; } + public Action Action { get; } = action; public bool Finished => Progress == 100.0; diff --git a/AmeisenBotX.Core/Engines/Quest/Objects/Objectives/CastSpellQuestObjective.cs b/AmeisenBotX.Core/Engines/Quest/Objects/Objectives/CastSpellQuestObjective.cs index c12de527..795ddf7f 100644 --- a/AmeisenBotX.Core/Engines/Quest/Objects/Objectives/CastSpellQuestObjective.cs +++ b/AmeisenBotX.Core/Engines/Quest/Objects/Objectives/CastSpellQuestObjective.cs @@ -1,25 +1,18 @@ -namespace AmeisenBotX.Core.Engines.Quest.Objects.Objectives -{ - public delegate bool CastSpellQuestObjectiveCondition(); +using System; - public class CastSpellQuestObjective : IQuestObjective +namespace AmeisenBotX.Core.Engines.Quest.Objects.Objectives +{ + public class CastSpellQuestObjective(AmeisenBotInterfaces bot, int spellId, Func condition) : IQuestObjective { - public CastSpellQuestObjective(AmeisenBotInterfaces bot, int spellId, CastSpellQuestObjectiveCondition condition) - { - Bot = bot; - SpellId = spellId; - Condition = condition; - } - public bool Finished => Progress == 100.0; public double Progress => Condition() ? 100.0 : 0.0; - private AmeisenBotInterfaces Bot { get; } + private AmeisenBotInterfaces Bot { get; } = bot; - private CastSpellQuestObjectiveCondition Condition { get; } + private Func Condition { get; } = condition; - private int SpellId { get; } + private int SpellId { get; } = spellId; public void Execute() { diff --git a/AmeisenBotX.Core/Engines/Quest/Objects/Objectives/CastVehicleSpellQuestObjective.cs b/AmeisenBotX.Core/Engines/Quest/Objects/Objectives/CastVehicleSpellQuestObjective.cs index cae39681..2783723f 100644 --- a/AmeisenBotX.Core/Engines/Quest/Objects/Objectives/CastVehicleSpellQuestObjective.cs +++ b/AmeisenBotX.Core/Engines/Quest/Objects/Objectives/CastVehicleSpellQuestObjective.cs @@ -1,25 +1,18 @@ -namespace AmeisenBotX.Core.Engines.Quest.Objects.Objectives -{ - public delegate bool CastVehicleSpellQuestObjectiveCondition(); +using System; - public class CastVehicleSpellQuestObjective : IQuestObjective +namespace AmeisenBotX.Core.Engines.Quest.Objects.Objectives +{ + public class CastVehicleSpellQuestObjective(AmeisenBotInterfaces bot, int spellId, Func condition) : IQuestObjective { - public CastVehicleSpellQuestObjective(AmeisenBotInterfaces bot, int spellId, CastVehicleSpellQuestObjectiveCondition condition) - { - Bot = bot; - SpellId = spellId; - Condition = condition; - } - public bool Finished => Progress == 100.0; public double Progress => Condition() ? 100.0 : 0.0; - private AmeisenBotInterfaces Bot { get; } + private AmeisenBotInterfaces Bot { get; } = bot; - private CastVehicleSpellQuestObjectiveCondition Condition { get; } + private Func Condition { get; } = condition; - private int SpellId { get; } + private int SpellId { get; } = spellId; public void Execute() { diff --git a/AmeisenBotX.Core/Engines/Quest/Objects/Objectives/CollectQuestObjective.cs b/AmeisenBotX.Core/Engines/Quest/Objects/Objectives/CollectQuestObjective.cs index 231ea0e5..512f75ad 100644 --- a/AmeisenBotX.Core/Engines/Quest/Objects/Objectives/CollectQuestObjective.cs +++ b/AmeisenBotX.Core/Engines/Quest/Objects/Objectives/CollectQuestObjective.cs @@ -9,19 +9,9 @@ namespace AmeisenBotX.Core.Engines.Quest.Objects.Objectives { - public class CollectQuestObjective : IQuestObjective + public class CollectQuestObjective(AmeisenBotInterfaces bot, int itemId, int itemAmount, List gameObjectIds, List positions) : IQuestObjective { - public CollectQuestObjective(AmeisenBotInterfaces bot, int itemId, int itemAmount, List gameObjectIds, List positions) - { - Bot = bot; - ItemId = itemId; - WantedItemAmount = itemAmount; - GameObjectIds = gameObjectIds; - Area = positions.Select(pos => new AreaNode(pos, 10.0)).ToList(); - RightClickEvent = new(TimeSpan.FromMilliseconds(1500)); - } - - public List Area { get; set; } + public List Area { get; set; } = positions.Select(pos => new AreaNode(pos, 10.0)).ToList(); public bool Finished => Math.Abs(Progress - 100.0) < 0.0001; @@ -39,15 +29,15 @@ public double Progress } } - private AmeisenBotInterfaces Bot { get; } + private AmeisenBotInterfaces Bot { get; } = bot; - private List GameObjectIds { get; } + private List GameObjectIds { get; } = gameObjectIds; - private int ItemId { get; } + private int ItemId { get; } = itemId; - private TimegatedEvent RightClickEvent { get; } + private TimegatedEvent RightClickEvent { get; } = new(TimeSpan.FromMilliseconds(1500)); - private int WantedItemAmount { get; } + private int WantedItemAmount { get; } = itemAmount; public void Execute() { diff --git a/AmeisenBotX.Core/Engines/Quest/Objects/Objectives/CollectQuestObjectiveDEPRECATED.cs b/AmeisenBotX.Core/Engines/Quest/Objects/Objectives/CollectQuestObjectiveOld.cs similarity index 71% rename from AmeisenBotX.Core/Engines/Quest/Objects/Objectives/CollectQuestObjectiveDEPRECATED.cs rename to AmeisenBotX.Core/Engines/Quest/Objects/Objectives/CollectQuestObjectiveOld.cs index ac57de21..b0d03ccb 100644 --- a/AmeisenBotX.Core/Engines/Quest/Objects/Objectives/CollectQuestObjectiveDEPRECATED.cs +++ b/AmeisenBotX.Core/Engines/Quest/Objects/Objectives/CollectQuestObjectiveOld.cs @@ -7,36 +7,25 @@ namespace AmeisenBotX.Core.Engines.Quest.Objects.Objectives { - public class CollectQuestObjectiveDEPRECATED : IQuestObjective + public class CollectQuestObjectiveOld(AmeisenBotInterfaces bot, int itemId, int itemAmount, int objectDisplayId, List area) : IQuestObjective { - public CollectQuestObjectiveDEPRECATED(AmeisenBotInterfaces bot, int itemId, int itemAmount, int objectDisplayId, List area) - { - Bot = bot; - ItemId = itemId; - WantedItemAmount = itemAmount; - ObjectDisplayId = objectDisplayId; - Area = area; - - RightClickEvent = new(TimeSpan.FromSeconds(1)); - } - - public List Area { get; set; } + public List Area { get; set; } = area; public bool Finished => Progress == 100.0; public double Progress => Math.Round(CurrentItemAmount / (double)WantedItemAmount * 100.0, 1); - private AmeisenBotInterfaces Bot { get; } + private AmeisenBotInterfaces Bot { get; } = bot; private int CurrentItemAmount => Bot.Character.Inventory.Items.Count(e => e.Id == ItemId); - private int ItemId { get; } + private int ItemId { get; } = itemId; - private int ObjectDisplayId { get; } + private int ObjectDisplayId { get; } = objectDisplayId; - private TimegatedEvent RightClickEvent { get; } + private TimegatedEvent RightClickEvent { get; } = new(TimeSpan.FromSeconds(1)); - private int WantedItemAmount { get; } + private int WantedItemAmount { get; } = itemAmount; public void Execute() { diff --git a/AmeisenBotX.Core/Engines/Quest/Objects/Objectives/GrindingObjective.cs b/AmeisenBotX.Core/Engines/Quest/Objects/Objectives/GrindingObjective.cs index cc742b38..1cd9df16 100644 --- a/AmeisenBotX.Core/Engines/Quest/Objects/Objectives/GrindingObjective.cs +++ b/AmeisenBotX.Core/Engines/Quest/Objects/Objectives/GrindingObjective.cs @@ -8,32 +8,23 @@ namespace AmeisenBotX.Core.Engines.Quest.Objects.Objectives { - internal class GrindingObjective : IQuestObjective + internal class GrindingObjective(AmeisenBotInterfaces bot, int targetLevel, List> grindingAreas, List vendorsLocation = null) : IQuestObjective { - public GrindingObjective(AmeisenBotInterfaces bot, int targetLevel, - List> grindingAreas, List vendorsLocation = null) - { - Bot = bot; - WantedLevel = targetLevel; - SearchAreas = new SearchAreaEnsamble(grindingAreas); - VendorsLocation = vendorsLocation; - } - public bool Finished => Bot.Player.Level >= WantedLevel; public double Progress => 100.0 * (Bot.Player.Level + Bot.Player.XpPercentage / 100.0) / WantedLevel; - public List VendorsLocation { get; } + public List VendorsLocation { get; } = vendorsLocation; - private AmeisenBotInterfaces Bot { get; } + private AmeisenBotInterfaces Bot { get; } = bot; private Vector3 CurrentNode { get; set; } private IWowUnit IWowUnit { get; set; } - private SearchAreaEnsamble SearchAreas { get; } + private SearchAreaEnsamble SearchAreas { get; } = new SearchAreaEnsamble(grindingAreas); - private int WantedLevel { get; } + private int WantedLevel { get; } = targetLevel; public void Execute() { diff --git a/AmeisenBotX.Core/Engines/Quest/Objects/Objectives/KillUnitQuestObjective.cs b/AmeisenBotX.Core/Engines/Quest/Objects/Objectives/KillUnitQuestObjective.cs index 63b16d18..64ffe775 100644 --- a/AmeisenBotX.Core/Engines/Quest/Objects/Objectives/KillUnitQuestObjective.cs +++ b/AmeisenBotX.Core/Engines/Quest/Objects/Objectives/KillUnitQuestObjective.cs @@ -1,23 +1,22 @@ using AmeisenBotX.Core.Engines.Movement.Enums; using AmeisenBotX.Wow.Objects; using AmeisenBotX.Wow.Objects.Enums; +using System; using System.Collections.Generic; using System.Linq; namespace AmeisenBotX.Core.Engines.Quest.Objects.Objectives { - public delegate bool KillUnitQuestObjectiveCondition(); - public class KillUnitQuestObjective : IQuestObjective { - public KillUnitQuestObjective(AmeisenBotInterfaces bot, int objectDisplayId, KillUnitQuestObjectiveCondition condition) + public KillUnitQuestObjective(AmeisenBotInterfaces bot, int objectDisplayId, Func condition) { Bot = bot; ObjectDisplayIds = new Dictionary() { { 0, objectDisplayId } }; Condition = condition; } - public KillUnitQuestObjective(AmeisenBotInterfaces bot, Dictionary objectDisplayIds, KillUnitQuestObjectiveCondition condition) + public KillUnitQuestObjective(AmeisenBotInterfaces bot, Dictionary objectDisplayIds, Func condition) { Bot = bot; ObjectDisplayIds = objectDisplayIds; @@ -30,7 +29,7 @@ public KillUnitQuestObjective(AmeisenBotInterfaces bot, Dictionary obj private AmeisenBotInterfaces Bot { get; } - private KillUnitQuestObjectiveCondition Condition { get; } + private Func Condition { get; } private Dictionary ObjectDisplayIds { get; } @@ -53,7 +52,7 @@ public void Execute() Unit = Bot.Objects.All .OfType() - .Where(e => !e.IsDead && ObjectDisplayIds.Values.Contains(e.DisplayId)) + .Where(e => !e.IsDead && ObjectDisplayIds.ContainsValue(e.DisplayId)) .OrderBy(e => e.Position.GetDistance(Bot.Player.Position)) .OrderBy(e => ObjectDisplayIds.First(x => x.Value == e.DisplayId).Key) .FirstOrDefault(); diff --git a/AmeisenBotX.Core/Engines/Quest/Objects/Objectives/MoveToPositionQuestObjective.cs b/AmeisenBotX.Core/Engines/Quest/Objects/Objectives/MoveToPositionQuestObjective.cs index 042c39ee..74bfe731 100644 --- a/AmeisenBotX.Core/Engines/Quest/Objects/Objectives/MoveToPositionQuestObjective.cs +++ b/AmeisenBotX.Core/Engines/Quest/Objects/Objectives/MoveToPositionQuestObjective.cs @@ -3,27 +3,19 @@ namespace AmeisenBotX.Core.Engines.Quest.Objects.Objectives { - public class MoveToPositionQuestObjective : IQuestObjective + public class MoveToPositionQuestObjective(AmeisenBotInterfaces bot, Vector3 position, double distance, MovementAction movementAction = MovementAction.Move) : IQuestObjective { - public MoveToPositionQuestObjective(AmeisenBotInterfaces bot, Vector3 position, double distance, MovementAction movementAction = MovementAction.Move) - { - Bot = bot; - WantedPosition = position; - Distance = distance; - MovementAction = movementAction; - } - public bool Finished { get; set; } public double Progress => WantedPosition.GetDistance(Bot.Player.Position) < Distance ? 100.0 : 0.0; - private AmeisenBotInterfaces Bot { get; } + private AmeisenBotInterfaces Bot { get; } = bot; - private double Distance { get; } + private double Distance { get; } = distance; - private MovementAction MovementAction { get; } + private MovementAction MovementAction { get; } = movementAction; - private Vector3 WantedPosition { get; } + private Vector3 WantedPosition { get; } = position; public void Execute() { diff --git a/AmeisenBotX.Core/Engines/Quest/Objects/Objectives/MoveVehicleToPositionQuestObjective.cs b/AmeisenBotX.Core/Engines/Quest/Objects/Objectives/MoveVehicleToPositionQuestObjective.cs index d885b45c..63489837 100644 --- a/AmeisenBotX.Core/Engines/Quest/Objects/Objectives/MoveVehicleToPositionQuestObjective.cs +++ b/AmeisenBotX.Core/Engines/Quest/Objects/Objectives/MoveVehicleToPositionQuestObjective.cs @@ -3,27 +3,19 @@ namespace AmeisenBotX.Core.Engines.Quest.Objects.Objectives { - public class MoveVehicleToPositionQuestObjective : IQuestObjective + public class MoveVehicleToPositionQuestObjective(AmeisenBotInterfaces bot, Vector3 position, double distance, MovementAction movementAction = MovementAction.Move) : IQuestObjective { - public MoveVehicleToPositionQuestObjective(AmeisenBotInterfaces bot, Vector3 position, double distance, MovementAction movementAction = MovementAction.Move) - { - Bot = bot; - WantedPosition = position; - Distance = distance; - MovementAction = movementAction; - } - public bool Finished => Progress == 100.0; public double Progress => Bot.Objects.Vehicle != null && WantedPosition.GetDistance(Bot.Objects.Vehicle.Position) < Distance ? 100.0 : 0.0; - private AmeisenBotInterfaces Bot { get; } + private AmeisenBotInterfaces Bot { get; } = bot; - private double Distance { get; } + private double Distance { get; } = distance; - private MovementAction MovementAction { get; } + private MovementAction MovementAction { get; } = movementAction; - private Vector3 WantedPosition { get; } + private Vector3 WantedPosition { get; } = position; public void Execute() { diff --git a/AmeisenBotX.Core/Engines/Quest/Objects/Objectives/QuestObjectiveChain.cs b/AmeisenBotX.Core/Engines/Quest/Objects/Objectives/QuestObjectiveChain.cs index ac46d6d9..5fa7bf4e 100644 --- a/AmeisenBotX.Core/Engines/Quest/Objects/Objectives/QuestObjectiveChain.cs +++ b/AmeisenBotX.Core/Engines/Quest/Objects/Objectives/QuestObjectiveChain.cs @@ -3,18 +3,13 @@ namespace AmeisenBotX.Core.Engines.Quest.Objects.Objectives { - public class QuestObjectiveChain : IQuestObjective + public class QuestObjectiveChain(List questObjectives) : IQuestObjective { - public QuestObjectiveChain(List questObjectives) - { - QuestObjectives = questObjectives; - } - public bool Finished => Progress == 100.0; public double Progress => QuestObjectives.Count(e => QuestObjectives.IndexOf(e) <= AlreadyCompletedIndex || e.Finished) / (double)QuestObjectives.Count * 100.0; - public List QuestObjectives { get; } + public List QuestObjectives { get; } = questObjectives; private int AlreadyCompletedIndex { diff --git a/AmeisenBotX.Core/Engines/Quest/Objects/Objectives/RuneforgingQuestObjective.cs b/AmeisenBotX.Core/Engines/Quest/Objects/Objectives/RuneforgingQuestObjective.cs index c9174837..04680ad4 100644 --- a/AmeisenBotX.Core/Engines/Quest/Objects/Objectives/RuneforgingQuestObjective.cs +++ b/AmeisenBotX.Core/Engines/Quest/Objects/Objectives/RuneforgingQuestObjective.cs @@ -4,27 +4,17 @@ namespace AmeisenBotX.Core.Engines.Quest.Objects.Objectives { - public delegate bool EnchantItemQuestObjectiveCondition(); - - public class RuneforgingQuestObjective : IQuestObjective + public class RuneforgingQuestObjective(AmeisenBotInterfaces bot, Func condition) : IQuestObjective { - public RuneforgingQuestObjective(AmeisenBotInterfaces bot, EnchantItemQuestObjectiveCondition condition) - { - Bot = bot; - Condition = condition; - - EnchantEvent = new(TimeSpan.FromSeconds(1)); - } - public bool Finished => Progress == 100.0; public double Progress => Condition() ? 100.0 : 0.0; - private AmeisenBotInterfaces Bot { get; } + private AmeisenBotInterfaces Bot { get; } = bot; - private EnchantItemQuestObjectiveCondition Condition { get; } + private Func Condition { get; } = condition; - private TimegatedEvent EnchantEvent { get; } + private TimegatedEvent EnchantEvent { get; } = new(TimeSpan.FromSeconds(1)); public void Execute() { diff --git a/AmeisenBotX.Core/Engines/Quest/Objects/Objectives/TalkToUnitQuestObjective.cs b/AmeisenBotX.Core/Engines/Quest/Objects/Objectives/TalkToUnitQuestObjective.cs index f8489812..1aa917c8 100644 --- a/AmeisenBotX.Core/Engines/Quest/Objects/Objectives/TalkToUnitQuestObjective.cs +++ b/AmeisenBotX.Core/Engines/Quest/Objects/Objectives/TalkToUnitQuestObjective.cs @@ -7,11 +7,9 @@ namespace AmeisenBotX.Core.Engines.Quest.Objects.Objectives { - public delegate bool TalkToUnitQuestObjectiveCondition(); - public class TalkToUnitQuestObjective : IQuestObjective { - public TalkToUnitQuestObjective(AmeisenBotInterfaces bot, int displayId, List gossipIds, TalkToUnitQuestObjectiveCondition condition) + public TalkToUnitQuestObjective(AmeisenBotInterfaces bot, int displayId, List gossipIds, Func condition) { Bot = bot; DisplayIds = [displayId]; @@ -21,7 +19,7 @@ public TalkToUnitQuestObjective(AmeisenBotInterfaces bot, int displayId, List displayIds, List gossipIds, TalkToUnitQuestObjectiveCondition condition) + public TalkToUnitQuestObjective(AmeisenBotInterfaces bot, List displayIds, List gossipIds, Func condition) { Bot = bot; DisplayIds = displayIds; @@ -37,7 +35,7 @@ public TalkToUnitQuestObjective(AmeisenBotInterfaces bot, List displayIds, private AmeisenBotInterfaces Bot { get; } - private TalkToUnitQuestObjectiveCondition Condition { get; } + private Func Condition { get; } private int Counter { get; set; } diff --git a/AmeisenBotX.Core/Engines/Quest/Objects/Objectives/UseItemQuestObjective.cs b/AmeisenBotX.Core/Engines/Quest/Objects/Objectives/UseItemQuestObjective.cs index 533aa278..1470c2bf 100644 --- a/AmeisenBotX.Core/Engines/Quest/Objects/Objectives/UseItemQuestObjective.cs +++ b/AmeisenBotX.Core/Engines/Quest/Objects/Objectives/UseItemQuestObjective.cs @@ -1,28 +1,20 @@ using AmeisenBotX.Core.Managers.Character.Inventory.Objects; +using System; using System.Linq; namespace AmeisenBotX.Core.Engines.Quest.Objects.Objectives { - public delegate bool UseItemQuestObjectiveCondition(); - - public class UseItemQuestObjective : IQuestObjective + public class UseItemQuestObjective(AmeisenBotInterfaces bot, int itemId, Func condition) : IQuestObjective { - public UseItemQuestObjective(AmeisenBotInterfaces bot, int itemId, UseItemQuestObjectiveCondition condition) - { - Bot = bot; - ItemId = itemId; - Condition = condition; - } - public bool Finished => Progress == 100.0; public double Progress => Condition() ? 100.0 : 0.0; - private AmeisenBotInterfaces Bot { get; } + private AmeisenBotInterfaces Bot { get; } = bot; - private UseItemQuestObjectiveCondition Condition { get; } + private Func Condition { get; } = condition; - private int ItemId { get; } + private int ItemId { get; } = itemId; public void Execute() { diff --git a/AmeisenBotX.Core/Engines/Quest/Objects/Objectives/UseObjectQuestObjective.cs b/AmeisenBotX.Core/Engines/Quest/Objects/Objectives/UseObjectQuestObjective.cs index 24b38c09..ea6328fc 100644 --- a/AmeisenBotX.Core/Engines/Quest/Objects/Objectives/UseObjectQuestObjective.cs +++ b/AmeisenBotX.Core/Engines/Quest/Objects/Objectives/UseObjectQuestObjective.cs @@ -7,11 +7,9 @@ namespace AmeisenBotX.Core.Engines.Quest.Objects.Objectives { - public delegate bool UseObjectQuestObjectiveCondition(); - public class UseObjectQuestObjective : IQuestObjective { - public UseObjectQuestObjective(AmeisenBotInterfaces bot, int objectDisplayId, UseObjectQuestObjectiveCondition condition) + public UseObjectQuestObjective(AmeisenBotInterfaces bot, int objectDisplayId, Func condition) { Bot = bot; ObjectDisplayIds = [objectDisplayId]; @@ -20,7 +18,7 @@ public UseObjectQuestObjective(AmeisenBotInterfaces bot, int objectDisplayId, Us UseEvent = new(TimeSpan.FromSeconds(1)); } - public UseObjectQuestObjective(AmeisenBotInterfaces bot, List objectDisplayIds, UseObjectQuestObjectiveCondition condition) + public UseObjectQuestObjective(AmeisenBotInterfaces bot, List objectDisplayIds, Func condition) { Bot = bot; ObjectDisplayIds = objectDisplayIds; @@ -35,7 +33,7 @@ public UseObjectQuestObjective(AmeisenBotInterfaces bot, List objectDisplay private AmeisenBotInterfaces Bot { get; } - private UseObjectQuestObjectiveCondition Condition { get; } + private Func Condition { get; } private IWowGameobject IWowGameobject { get; set; } diff --git a/AmeisenBotX.Core/Engines/Quest/Objects/Objectives/UseUnitQuestObjective.cs b/AmeisenBotX.Core/Engines/Quest/Objects/Objectives/UseUnitQuestObjective.cs index 138ad831..020e4a8d 100644 --- a/AmeisenBotX.Core/Engines/Quest/Objects/Objectives/UseUnitQuestObjective.cs +++ b/AmeisenBotX.Core/Engines/Quest/Objects/Objectives/UseUnitQuestObjective.cs @@ -1,13 +1,12 @@ using AmeisenBotX.Wow.Objects; +using System; using System.Collections.Generic; namespace AmeisenBotX.Core.Engines.Quest.Objects.Objectives { - public delegate bool UseUnitQuestObjectiveCondition(); - public class UseUnitQuestObjective : IQuestObjective { - public UseUnitQuestObjective(AmeisenBotInterfaces bot, int objectDisplayId, bool questgiversOnly, UseUnitQuestObjectiveCondition condition) + public UseUnitQuestObjective(AmeisenBotInterfaces bot, int objectDisplayId, bool questgiversOnly, Func condition) { Bot = bot; ObjectDisplayIds = [objectDisplayId]; @@ -15,7 +14,7 @@ public UseUnitQuestObjective(AmeisenBotInterfaces bot, int objectDisplayId, bool QuestgiversOnly = questgiversOnly; } - public UseUnitQuestObjective(AmeisenBotInterfaces bot, List objectDisplayIds, bool questgiversOnly, UseUnitQuestObjectiveCondition condition) + public UseUnitQuestObjective(AmeisenBotInterfaces bot, List objectDisplayIds, bool questgiversOnly, Func condition) { Bot = bot; ObjectDisplayIds = objectDisplayIds; @@ -29,7 +28,7 @@ public UseUnitQuestObjective(AmeisenBotInterfaces bot, List objectDisplayId private AmeisenBotInterfaces Bot { get; } - private UseUnitQuestObjectiveCondition Condition { get; } + private Func Condition { get; } private List ObjectDisplayIds { get; } diff --git a/AmeisenBotX.Core/Engines/Quest/Objects/Objectives/WaitUntilQuestObjective.cs b/AmeisenBotX.Core/Engines/Quest/Objects/Objectives/WaitUntilQuestObjective.cs index 8e74d1a9..1e52efde 100644 --- a/AmeisenBotX.Core/Engines/Quest/Objects/Objectives/WaitUntilQuestObjective.cs +++ b/AmeisenBotX.Core/Engines/Quest/Objects/Objectives/WaitUntilQuestObjective.cs @@ -1,15 +1,10 @@ -namespace AmeisenBotX.Core.Engines.Quest.Objects.Objectives -{ - public delegate bool WaitUntilQuestObjectiveCondition(); +using System; - public class WaitUntilQuestObjective : IQuestObjective +namespace AmeisenBotX.Core.Engines.Quest.Objects.Objectives +{ + public class WaitUntilQuestObjective(Func condition) : IQuestObjective { - public WaitUntilQuestObjective(WaitUntilQuestObjectiveCondition condition) - { - Condition = condition; - } - - public WaitUntilQuestObjectiveCondition Condition { get; } + public Func Condition { get; } = condition; public bool Finished { get; set; } diff --git a/AmeisenBotX.Core/Engines/Quest/Objects/Quests/BotQuest.cs b/AmeisenBotX.Core/Engines/Quest/Objects/Quests/BotQuest.cs index 79b54a62..7c030e49 100644 --- a/AmeisenBotX.Core/Engines/Quest/Objects/Quests/BotQuest.cs +++ b/AmeisenBotX.Core/Engines/Quest/Objects/Quests/BotQuest.cs @@ -14,44 +14,29 @@ namespace AmeisenBotX.Core.Engines.Quest.Objects.Quests { public delegate (IWowObject, Vector3) BotQuestGetPosition(); - public class BotQuest : IBotQuest + public class BotQuest(AmeisenBotInterfaces bot, int id, string name, int level, int gossipId, BotQuestGetPosition start, BotQuestGetPosition end, List objectives) : IBotQuest { - public BotQuest(AmeisenBotInterfaces bot, int id, string name, int level, int gossipId, BotQuestGetPosition start, BotQuestGetPosition end, List objectives) - { - Bot = bot; - - Id = id; - Name = name; - Level = level; - GossipId = gossipId; - GetStartObject = start; - GetEndObject = end; - Objectives = objectives; - - ActionEvent = new(TimeSpan.FromMilliseconds(250)); - } - public bool Accepted { get; set; } - public TimegatedEvent ActionEvent { get; } + public TimegatedEvent ActionEvent { get; } = new(TimeSpan.FromMilliseconds(250)); public bool ActionToggle { get; set; } public bool Finished => (Objectives != null && Objectives.All(e => e.Finished)) || Progress == 100.0; - public BotQuestGetPosition GetEndObject { get; set; } + public BotQuestGetPosition GetEndObject { get; set; } = end; - public BotQuestGetPosition GetStartObject { get; set; } + public BotQuestGetPosition GetStartObject { get; set; } = start; - public int GossipId { get; set; } + public int GossipId { get; set; } = gossipId; - public int Id { get; set; } + public int Id { get; set; } = id; - public int Level { get; set; } + public int Level { get; set; } = level; - public string Name { get; set; } + public string Name { get; set; } = name; - public List Objectives { get; set; } + public List Objectives { get; set; } = objectives; public double Progress { @@ -67,7 +52,7 @@ public double Progress public bool Returned { get; set; } - private AmeisenBotInterfaces Bot { get; } + private AmeisenBotInterfaces Bot { get; } = bot; private bool CheckedIfAccepted { get; set; } = false; @@ -183,8 +168,8 @@ public bool CompleteQuest() // get the item id and try again itemJson = Bot.Wow.GetItemByNameOrLink ( - itemLink.Split(new string[] { "Hitem:" }, StringSplitOptions.RemoveEmptyEntries)[1] - .Split(new string[] { ":" }, StringSplitOptions.RemoveEmptyEntries)[0] + itemLink.Split("Hitem:", StringSplitOptions.RemoveEmptyEntries)[1] + .Split(":", StringSplitOptions.RemoveEmptyEntries)[0] ); item = ItemFactory.BuildSpecificItem(ItemFactory.ParseItem(itemJson)); diff --git a/AmeisenBotX.Core/Engines/Quest/Objects/Quests/GrindingBotQuest.cs b/AmeisenBotX.Core/Engines/Quest/Objects/Quests/GrindingBotQuest.cs index 40bd5e30..e5cb77ef 100644 --- a/AmeisenBotX.Core/Engines/Quest/Objects/Quests/GrindingBotQuest.cs +++ b/AmeisenBotX.Core/Engines/Quest/Objects/Quests/GrindingBotQuest.cs @@ -4,23 +4,17 @@ namespace AmeisenBotX.Core.Engines.Quest.Objects.Quests { - internal class GrindingBotQuest : IBotQuest + internal class GrindingBotQuest(string name, List objectives) : IBotQuest { - public GrindingBotQuest(string name, List objectives) - { - Name = name; - Objectives = objectives; - } - public bool Accepted => true; public bool Finished => Objectives != null && Objectives.All(e => e.Finished); public int Id => -1; - public string Name { get; } + public string Name { get; } = name; - public List Objectives { get; } + public List Objectives { get; } = objectives; public bool Returned => Finished; diff --git a/AmeisenBotX.Core/Engines/Quest/Profiles/StartAreas/DeathknightStartAreaQuestProfile.cs b/AmeisenBotX.Core/Engines/Quest/Profiles/StartAreas/DeathknightStartAreaQuestProfile.cs index 72ef6c0f..c9adbc7a 100644 --- a/AmeisenBotX.Core/Engines/Quest/Profiles/StartAreas/DeathknightStartAreaQuestProfile.cs +++ b/AmeisenBotX.Core/Engines/Quest/Profiles/StartAreas/DeathknightStartAreaQuestProfile.cs @@ -39,7 +39,7 @@ public DeathknightStartAreaQuestProfile(AmeisenBotInterfaces bot) [ new QuestObjectiveChain( [ - new CollectQuestObjectiveDEPRECATED(bot, 38607, 1, 7961, + new CollectQuestObjectiveOld(bot, 38607, 1, 7961, [ new AreaNode(new Vector3(2504, -5563, 421), 32.0) ]), diff --git a/AmeisenBotX.Core/Engines/Quest/Quests/Durotar/RazorHill/QAPeonBurden.cs b/AmeisenBotX.Core/Engines/Quest/Quests/Durotar/RazorHill/QAPeonBurden.cs index 0f9cebbb..1e735449 100644 --- a/AmeisenBotX.Core/Engines/Quest/Quests/Durotar/RazorHill/QAPeonBurden.cs +++ b/AmeisenBotX.Core/Engines/Quest/Quests/Durotar/RazorHill/QAPeonBurden.cs @@ -4,13 +4,10 @@ namespace AmeisenBotX.Core.Engines.Quest.Quests.Durotar.RazorHill { - internal class QAPeonBurden : BotQuest + internal class QAPeonBurden(AmeisenBotInterfaces bot) : BotQuest(bot, 2161, "A Peon's Burden", 1, 1, + () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 6786 }), new Vector3(-599.45f, -4715.32f, 35.23f)), + () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 6928 }), new Vector3(340.36f, -4686.29f, 16.54f)), + null) { - public QAPeonBurden(AmeisenBotInterfaces bot) - : base(bot, 2161, "A Peon's Burden", 1, 1, - () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 6786 }), new Vector3(-599.45f, -4715.32f, 35.23f)), - () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 6928 }), new Vector3(340.36f, -4686.29f, 16.54f)), - null) - { } } } \ No newline at end of file diff --git a/AmeisenBotX.Core/Engines/Quest/Quests/Durotar/RazorHill/QCarryYourWeight.cs b/AmeisenBotX.Core/Engines/Quest/Quests/Durotar/RazorHill/QCarryYourWeight.cs index 651c19f8..3242aaac 100644 --- a/AmeisenBotX.Core/Engines/Quest/Quests/Durotar/RazorHill/QCarryYourWeight.cs +++ b/AmeisenBotX.Core/Engines/Quest/Quests/Durotar/RazorHill/QCarryYourWeight.cs @@ -5,13 +5,10 @@ namespace AmeisenBotX.Core.Engines.Quest.Quests.Durotar.RazorHill { - internal class QCarryYourWeight : BotQuest - { - public QCarryYourWeight(AmeisenBotInterfaces bot) - : base(bot, 791, "Carry Your Weight", 4, 1, - () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3147 }), new Vector3(384.74f, -4600.13f, 76.17f)), - () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3147 }), new Vector3(384.74f, -4600.13f, 76.17f)), - [ + internal class QCarryYourWeight(AmeisenBotInterfaces bot) : BotQuest(bot, 791, "Carry Your Weight", 4, 1, + () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3147 }), new Vector3(384.74f, -4600.13f, 76.17f)), + () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3147 }), new Vector3(384.74f, -4600.13f, 76.17f)), + [ new QuestObjectiveChain( [ new KillAndLootQuestObjective(bot, [3119, 3120, 3128, 3129, 3192, 5808, 5809], 8, 4870, [ @@ -41,6 +38,6 @@ public QCarryYourWeight(AmeisenBotInterfaces bot) ]), ]) ]) - { } + { } } \ No newline at end of file diff --git a/AmeisenBotX.Core/Engines/Quest/Quests/Durotar/RazorHill/QConscriptOfTheHorde.cs b/AmeisenBotX.Core/Engines/Quest/Quests/Durotar/RazorHill/QConscriptOfTheHorde.cs index eb5ebc5c..3b5a9ea9 100644 --- a/AmeisenBotX.Core/Engines/Quest/Quests/Durotar/RazorHill/QConscriptOfTheHorde.cs +++ b/AmeisenBotX.Core/Engines/Quest/Quests/Durotar/RazorHill/QConscriptOfTheHorde.cs @@ -4,13 +4,10 @@ namespace AmeisenBotX.Core.Engines.Quest.Quests.Durotar.RazorHill { - internal class QConscriptOfTheHorde : BotQuest + internal class QConscriptOfTheHorde(AmeisenBotInterfaces bot) : BotQuest(bot, 840, "Conscript of the Horde", 10, 1, + () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3336 }), new Vector3(271.80f, -4650.83f, 11.79f)), + () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3337 }), new Vector3(303.43f, -3686.16f, 27.15f)), + null) { - public QConscriptOfTheHorde(AmeisenBotInterfaces bot) - : base(bot, 840, "Conscript of the Horde", 10, 1, - () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3336 }), new Vector3(271.80f, -4650.83f, 11.79f)), - () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3337 }), new Vector3(303.43f, -3686.16f, 27.15f)), - null) - { } } } \ No newline at end of file diff --git a/AmeisenBotX.Core/Engines/Quest/Quests/Durotar/RazorHill/QEncroachment.cs b/AmeisenBotX.Core/Engines/Quest/Quests/Durotar/RazorHill/QEncroachment.cs index 436f1640..d0991bcd 100644 --- a/AmeisenBotX.Core/Engines/Quest/Quests/Durotar/RazorHill/QEncroachment.cs +++ b/AmeisenBotX.Core/Engines/Quest/Quests/Durotar/RazorHill/QEncroachment.cs @@ -5,13 +5,10 @@ namespace AmeisenBotX.Core.Engines.Quest.Quests.Durotar.RazorHill { - internal class QEncroachment : BotQuest - { - public QEncroachment(AmeisenBotInterfaces bot) - : base(bot, 837, "Encroachment", 6, 1, - () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3139 }), new Vector3(274.99f, -4709.30f, 17.57f)), - () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3139 }), new Vector3(274.99f, -4709.30f, 17.57f)), - [ + internal class QEncroachment(AmeisenBotInterfaces bot) : BotQuest(bot, 837, "Encroachment", 6, 1, + () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3139 }), new Vector3(274.99f, -4709.30f, 17.57f)), + () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3139 }), new Vector3(274.99f, -4709.30f, 17.57f)), + [ new QuestObjectiveChain( [ new KillAndLootQuestObjective(bot, [3111], 4, 0, [ @@ -115,6 +112,6 @@ public QEncroachment(AmeisenBotInterfaces bot) ]), ]) ]) - { } + { } } \ No newline at end of file diff --git a/AmeisenBotX.Core/Engines/Quest/Quests/Durotar/RazorHill/QVanquishTheBetrayers.cs b/AmeisenBotX.Core/Engines/Quest/Quests/Durotar/RazorHill/QVanquishTheBetrayers.cs index 4d5f50de..234d2810 100644 --- a/AmeisenBotX.Core/Engines/Quest/Quests/Durotar/RazorHill/QVanquishTheBetrayers.cs +++ b/AmeisenBotX.Core/Engines/Quest/Quests/Durotar/RazorHill/QVanquishTheBetrayers.cs @@ -5,13 +5,10 @@ namespace AmeisenBotX.Core.Engines.Quest.Quests.Durotar.RazorHill { - internal class QVanquishTheBetrayers : BotQuest - { - public QVanquishTheBetrayers(AmeisenBotInterfaces bot) - : base(bot, 784, "Vanquish the Betrayers", 3, 1, - () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3139 }), new Vector3(274.99f, -4709.30f, 17.57f)), - () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3139 }), new Vector3(274.99f, -4709.30f, 17.57f)), - [ + internal class QVanquishTheBetrayers(AmeisenBotInterfaces bot) : BotQuest(bot, 784, "Vanquish the Betrayers", 3, 1, + () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3139 }), new Vector3(274.99f, -4709.30f, 17.57f)), + () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3139 }), new Vector3(274.99f, -4709.30f, 17.57f)), + [ new QuestObjectiveChain( [ new KillAndLootQuestObjective(bot, [3128], 10, 0, [ @@ -50,6 +47,6 @@ public QVanquishTheBetrayers(AmeisenBotInterfaces bot) ]), ]) ]) - { } + { } } \ No newline at end of file diff --git a/AmeisenBotX.Core/Engines/Quest/Quests/Durotar/ValleyOfStrength/QCuttingTeeth.cs b/AmeisenBotX.Core/Engines/Quest/Quests/Durotar/ValleyOfStrength/QCuttingTeeth.cs index eaf84b6c..a6920e83 100644 --- a/AmeisenBotX.Core/Engines/Quest/Quests/Durotar/ValleyOfStrength/QCuttingTeeth.cs +++ b/AmeisenBotX.Core/Engines/Quest/Quests/Durotar/ValleyOfStrength/QCuttingTeeth.cs @@ -5,13 +5,10 @@ namespace AmeisenBotX.Core.Engines.Quest.Quests.Durotar.ValleyOfStrength { - internal class QCuttingTeeth : BotQuest - { - public QCuttingTeeth(AmeisenBotInterfaces bot) - : base(bot, 788, "Cutting Teeth", 1, 1, - () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3143 }), new Vector3(-600.13f, -4186.19f, 41.27f)), - () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3143 }), new Vector3(-600.13f, -4186.19f, 41.27f)), - [ + internal class QCuttingTeeth(AmeisenBotInterfaces bot) : BotQuest(bot, 788, "Cutting Teeth", 1, 1, + () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3143 }), new Vector3(-600.13f, -4186.19f, 41.27f)), + () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3143 }), new Vector3(-600.13f, -4186.19f, 41.27f)), + [ new QuestObjectiveChain( [ new KillAndLootQuestObjective(bot, [3098], 8, 0, [ @@ -39,6 +36,6 @@ public QCuttingTeeth(AmeisenBotInterfaces bot) ]), ]) ]) - { } + { } } \ No newline at end of file diff --git a/AmeisenBotX.Core/Engines/Quest/Quests/Durotar/ValleyOfStrength/QGalgarCactusAppleSurprise.cs b/AmeisenBotX.Core/Engines/Quest/Quests/Durotar/ValleyOfStrength/QGalgarCactusAppleSurprise.cs index 3502b4c8..c3f4d257 100644 --- a/AmeisenBotX.Core/Engines/Quest/Quests/Durotar/ValleyOfStrength/QGalgarCactusAppleSurprise.cs +++ b/AmeisenBotX.Core/Engines/Quest/Quests/Durotar/ValleyOfStrength/QGalgarCactusAppleSurprise.cs @@ -5,13 +5,10 @@ namespace AmeisenBotX.Core.Engines.Quest.Quests.Durotar.ValleyOfStrength { - internal class QGalgarCactusAppleSurprise : BotQuest - { - public QGalgarCactusAppleSurprise(AmeisenBotInterfaces bot) - : base(bot, 4402, "Galgar's Cactus Apple Surprise", 1, 1, - () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 9796 }), new Vector3(-561.63f, -4221.80f, 41.67f)), - () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 9796 }), new Vector3(-561.63f, -4221.80f, 41.67f)), - [ + internal class QGalgarCactusAppleSurprise(AmeisenBotInterfaces bot) : BotQuest(bot, 4402, "Galgar's Cactus Apple Surprise", 1, 1, + () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 9796 }), new Vector3(-561.63f, -4221.80f, 41.67f)), + () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 9796 }), new Vector3(-561.63f, -4221.80f, 41.67f)), + [ new QuestObjectiveChain( [ new CollectQuestObjective(bot, 11583, 6, [171938], [ @@ -63,6 +60,6 @@ public QGalgarCactusAppleSurprise(AmeisenBotInterfaces bot) ]), ]) ]) - { } + { } } \ No newline at end of file diff --git a/AmeisenBotX.Core/Engines/Quest/Quests/Durotar/ValleyOfStrength/QSarkoth.cs b/AmeisenBotX.Core/Engines/Quest/Quests/Durotar/ValleyOfStrength/QSarkoth.cs index 2c3cbe19..30ffb54d 100644 --- a/AmeisenBotX.Core/Engines/Quest/Quests/Durotar/ValleyOfStrength/QSarkoth.cs +++ b/AmeisenBotX.Core/Engines/Quest/Quests/Durotar/ValleyOfStrength/QSarkoth.cs @@ -5,13 +5,10 @@ namespace AmeisenBotX.Core.Engines.Quest.Quests.Durotar.ValleyOfStrength { - internal class QSarkoth : BotQuest - { - public QSarkoth(AmeisenBotInterfaces bot) - : base(bot, 790, "Sarkoth", 1, 1, - () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3287 }), new Vector3(-397.76f, -4108.99f, 50.29f)), - () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3287 }), new Vector3(-397.76f, -4108.99f, 50.29f)), - [ + internal class QSarkoth(AmeisenBotInterfaces bot) : BotQuest(bot, 790, "Sarkoth", 1, 1, + () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3287 }), new Vector3(-397.76f, -4108.99f, 50.29f)), + () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3287 }), new Vector3(-397.76f, -4108.99f, 50.29f)), + [ new QuestObjectiveChain( [ new KillAndLootQuestObjective(bot, [3281], 1, 4905, [ @@ -22,6 +19,6 @@ public QSarkoth(AmeisenBotInterfaces bot) ]), ]) ]) - { } + { } } \ No newline at end of file diff --git a/AmeisenBotX.Core/Engines/Quest/Quests/Durotar/ValleyOfStrength/QSarkoth2.cs b/AmeisenBotX.Core/Engines/Quest/Quests/Durotar/ValleyOfStrength/QSarkoth2.cs index 20aa6bd7..80aaf7a2 100644 --- a/AmeisenBotX.Core/Engines/Quest/Quests/Durotar/ValleyOfStrength/QSarkoth2.cs +++ b/AmeisenBotX.Core/Engines/Quest/Quests/Durotar/ValleyOfStrength/QSarkoth2.cs @@ -4,13 +4,10 @@ namespace AmeisenBotX.Core.Engines.Quest.Quests.Durotar.ValleyOfStrength { - internal class QSarkoth2 : BotQuest + internal class QSarkoth2(AmeisenBotInterfaces bot) : BotQuest(bot, 804, "Sarkoth", 1, 1, + () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3287 }), new Vector3(-397.76f, -4108.99f, 50.29f)), + () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3143 }), new Vector3(-600.13f, -4186.19f, 41.27f)), + null) { - public QSarkoth2(AmeisenBotInterfaces bot) - : base(bot, 804, "Sarkoth", 1, 1, - () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3287 }), new Vector3(-397.76f, -4108.99f, 50.29f)), - () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3143 }), new Vector3(-600.13f, -4186.19f, 41.27f)), - null) - { } } } \ No newline at end of file diff --git a/AmeisenBotX.Core/Engines/Quest/Quests/Durotar/ValleyOfStrength/QStingOfTheScorpid.cs b/AmeisenBotX.Core/Engines/Quest/Quests/Durotar/ValleyOfStrength/QStingOfTheScorpid.cs index f780c2cc..201d2a21 100644 --- a/AmeisenBotX.Core/Engines/Quest/Quests/Durotar/ValleyOfStrength/QStingOfTheScorpid.cs +++ b/AmeisenBotX.Core/Engines/Quest/Quests/Durotar/ValleyOfStrength/QStingOfTheScorpid.cs @@ -5,13 +5,10 @@ namespace AmeisenBotX.Core.Engines.Quest.Quests.Durotar.ValleyOfStrength { - internal class QStingOfTheScorpid : BotQuest - { - public QStingOfTheScorpid(AmeisenBotInterfaces bot) - : base(bot, 789, "Sting of the Scorpid", 1, 1, - () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3143 }), new Vector3(-600.13f, -4186.19f, 41.27f)), - () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3143 }), new Vector3(-600.13f, -4186.19f, 41.27f)), - [ + internal class QStingOfTheScorpid(AmeisenBotInterfaces bot) : BotQuest(bot, 789, "Sting of the Scorpid", 1, 1, + () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3143 }), new Vector3(-600.13f, -4186.19f, 41.27f)), + () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3143 }), new Vector3(-600.13f, -4186.19f, 41.27f)), + [ new QuestObjectiveChain( [ new KillAndLootQuestObjective(bot, [3124, 3281], 8, 4862, [ @@ -54,6 +51,6 @@ public QStingOfTheScorpid(AmeisenBotInterfaces bot) ]), ]) ]) - { } + { } } \ No newline at end of file diff --git a/AmeisenBotX.Core/Engines/Quest/Quests/Durotar/ValleyOfStrength/QVileFamiliars.cs b/AmeisenBotX.Core/Engines/Quest/Quests/Durotar/ValleyOfStrength/QVileFamiliars.cs index 2ed7e776..ab5baa3c 100644 --- a/AmeisenBotX.Core/Engines/Quest/Quests/Durotar/ValleyOfStrength/QVileFamiliars.cs +++ b/AmeisenBotX.Core/Engines/Quest/Quests/Durotar/ValleyOfStrength/QVileFamiliars.cs @@ -5,13 +5,10 @@ namespace AmeisenBotX.Core.Engines.Quest.Quests.Durotar.ValleyOfStrength { - internal class QVileFamiliars : BotQuest - { - public QVileFamiliars(AmeisenBotInterfaces bot) - : base(bot, 792, "Vile Familiars", 2, 1, - () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3145 }), new Vector3(-629.05f, -4228.06f, 38.23f)), - () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3145 }), new Vector3(-629.05f, -4228.06f, 38.23f)), - [ + internal class QVileFamiliars(AmeisenBotInterfaces bot) : BotQuest(bot, 792, "Vile Familiars", 2, 1, + () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3145 }), new Vector3(-629.05f, -4228.06f, 38.23f)), + () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3145 }), new Vector3(-629.05f, -4228.06f, 38.23f)), + [ new QuestObjectiveChain( [ new KillAndLootQuestObjective(bot, [3101], 8, 0, [ @@ -30,6 +27,6 @@ public QVileFamiliars(AmeisenBotInterfaces bot) ]), ]) ]) - { } + { } } \ No newline at end of file diff --git a/AmeisenBotX.Core/Engines/Quest/Quests/Durotar/ValleyOfStrength/QYourPlaceInTheWorld.cs b/AmeisenBotX.Core/Engines/Quest/Quests/Durotar/ValleyOfStrength/QYourPlaceInTheWorld.cs index 8fbc8800..84cb9dce 100644 --- a/AmeisenBotX.Core/Engines/Quest/Quests/Durotar/ValleyOfStrength/QYourPlaceInTheWorld.cs +++ b/AmeisenBotX.Core/Engines/Quest/Quests/Durotar/ValleyOfStrength/QYourPlaceInTheWorld.cs @@ -4,13 +4,10 @@ namespace AmeisenBotX.Core.Engines.Quest.Quests.Durotar.ValleyOfStrength { - internal class QYourPlaceInTheWorld : BotQuest + internal class QYourPlaceInTheWorld(AmeisenBotInterfaces bot) : BotQuest(bot, 4641, "Your Place In The World", 1, 1, + () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 10176 }), new Vector3(-610.07f, -4253.52f, 39.04f)), + () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3143 }), new Vector3(-600.13f, -4186.19f, 41.27f)), + null) { - public QYourPlaceInTheWorld(AmeisenBotInterfaces bot) - : base(bot, 4641, "Your Place In The World", 1, 1, - () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 10176 }), new Vector3(-610.07f, -4253.52f, 39.04f)), - () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3143 }), new Vector3(-600.13f, -4186.19f, 41.27f)), - null) - { } } } \ No newline at end of file diff --git a/AmeisenBotX.Core/Engines/Quest/Quests/Grinder/QDesolaceGrindToLevel35.cs b/AmeisenBotX.Core/Engines/Quest/Quests/Grinder/QDesolaceGrindToLevel35.cs index 1a0572bd..82b137e5 100644 --- a/AmeisenBotX.Core/Engines/Quest/Quests/Grinder/QDesolaceGrindToLevel35.cs +++ b/AmeisenBotX.Core/Engines/Quest/Quests/Grinder/QDesolaceGrindToLevel35.cs @@ -4,11 +4,8 @@ namespace AmeisenBotX.Core.Engines.Quest.Quests.Grinder { - internal class QDesolaceGrindToLevel35 : GrindingBotQuest - { - public QDesolaceGrindToLevel35(AmeisenBotInterfaces bot) - : base("DesolaceGrindToLevel35", - [ + internal class QDesolaceGrindToLevel35(AmeisenBotInterfaces bot) : GrindingBotQuest("DesolaceGrindToLevel35", + [ new QuestObjectiveChain( [ new GrindingObjective(bot, 35, [ @@ -28,6 +25,6 @@ public QDesolaceGrindToLevel35(AmeisenBotInterfaces bot) ]), ]) ]) - { } + { } } \ No newline at end of file diff --git a/AmeisenBotX.Core/Engines/Quest/Quests/Grinder/QDesolaceGrindToLevel40.cs b/AmeisenBotX.Core/Engines/Quest/Quests/Grinder/QDesolaceGrindToLevel40.cs index 471f989c..616d1049 100644 --- a/AmeisenBotX.Core/Engines/Quest/Quests/Grinder/QDesolaceGrindToLevel40.cs +++ b/AmeisenBotX.Core/Engines/Quest/Quests/Grinder/QDesolaceGrindToLevel40.cs @@ -4,11 +4,8 @@ namespace AmeisenBotX.Core.Engines.Quest.Quests.Grinder { - internal class QDesolaceGrindToLevel40 : GrindingBotQuest - { - public QDesolaceGrindToLevel40(AmeisenBotInterfaces bot) - : base("DesolaceGrindToLevel40", - [ + internal class QDesolaceGrindToLevel40(AmeisenBotInterfaces bot) : GrindingBotQuest("DesolaceGrindToLevel40", + [ new QuestObjectiveChain( [ new GrindingObjective(bot, 40, [ @@ -29,6 +26,6 @@ public QDesolaceGrindToLevel40(AmeisenBotInterfaces bot) ]), ]) ]) - { } + { } } \ No newline at end of file diff --git a/AmeisenBotX.Core/Engines/Quest/Quests/Grinder/QDurotarGrindToLevel11.cs b/AmeisenBotX.Core/Engines/Quest/Quests/Grinder/QDurotarGrindToLevel11.cs index 1a77be72..b9e354e8 100644 --- a/AmeisenBotX.Core/Engines/Quest/Quests/Grinder/QDurotarGrindToLevel11.cs +++ b/AmeisenBotX.Core/Engines/Quest/Quests/Grinder/QDurotarGrindToLevel11.cs @@ -4,11 +4,8 @@ namespace AmeisenBotX.Core.Engines.Quest.Quests.Grinder { - internal class QDurotarGrindToLevel11 : GrindingBotQuest - { - public QDurotarGrindToLevel11(AmeisenBotInterfaces bot) - : base("DurotarGrindToLevel11", - [ + internal class QDurotarGrindToLevel11(AmeisenBotInterfaces bot) : GrindingBotQuest("DurotarGrindToLevel11", + [ new QuestObjectiveChain( [ new GrindingObjective(bot, 11, [ @@ -37,6 +34,6 @@ public QDurotarGrindToLevel11(AmeisenBotInterfaces bot) ]), ]) ]) - { } + { } } \ No newline at end of file diff --git a/AmeisenBotX.Core/Engines/Quest/Quests/Grinder/QDurotarGrindToLevel6.cs b/AmeisenBotX.Core/Engines/Quest/Quests/Grinder/QDurotarGrindToLevel6.cs index 17842f90..2512d45d 100644 --- a/AmeisenBotX.Core/Engines/Quest/Quests/Grinder/QDurotarGrindToLevel6.cs +++ b/AmeisenBotX.Core/Engines/Quest/Quests/Grinder/QDurotarGrindToLevel6.cs @@ -4,11 +4,8 @@ namespace AmeisenBotX.Core.Engines.Quest.Quests.Grinder { - internal class QDurotarGrindToLevel6 : GrindingBotQuest - { - public QDurotarGrindToLevel6(AmeisenBotInterfaces bot) - : base("DurotarGrindToLevel6", - [ + internal class QDurotarGrindToLevel6(AmeisenBotInterfaces bot) : GrindingBotQuest("DurotarGrindToLevel6", + [ new QuestObjectiveChain( [ new GrindingObjective(bot, 6, @@ -42,6 +39,6 @@ public QDurotarGrindToLevel6(AmeisenBotInterfaces bot) ]), ]) ]) - { } + { } } \ No newline at end of file diff --git a/AmeisenBotX.Core/Engines/Quest/Quests/Grinder/QDurotarGrindToLevel9.cs b/AmeisenBotX.Core/Engines/Quest/Quests/Grinder/QDurotarGrindToLevel9.cs index 7a896678..843dcd57 100644 --- a/AmeisenBotX.Core/Engines/Quest/Quests/Grinder/QDurotarGrindToLevel9.cs +++ b/AmeisenBotX.Core/Engines/Quest/Quests/Grinder/QDurotarGrindToLevel9.cs @@ -4,11 +4,8 @@ namespace AmeisenBotX.Core.Engines.Quest.Quests.Grinder { - internal class QDurotarGrindToLevel9 : GrindingBotQuest - { - public QDurotarGrindToLevel9(AmeisenBotInterfaces bot) - : base("DurotarGrindToLevel9", - [ + internal class QDurotarGrindToLevel9(AmeisenBotInterfaces bot) : GrindingBotQuest("DurotarGrindToLevel9", + [ new QuestObjectiveChain( [ new GrindingObjective(bot, 9, [ @@ -29,6 +26,6 @@ public QDurotarGrindToLevel9(AmeisenBotInterfaces bot) ]), ]) ]) - { } + { } } \ No newline at end of file diff --git a/AmeisenBotX.Core/Engines/Quest/Quests/Grinder/QSilithusGrindToLevel60.cs b/AmeisenBotX.Core/Engines/Quest/Quests/Grinder/QSilithusGrindToLevel60.cs index 145e45e1..b57bafc0 100644 --- a/AmeisenBotX.Core/Engines/Quest/Quests/Grinder/QSilithusGrindToLevel60.cs +++ b/AmeisenBotX.Core/Engines/Quest/Quests/Grinder/QSilithusGrindToLevel60.cs @@ -4,11 +4,8 @@ namespace AmeisenBotX.Core.Engines.Quest.Quests.Grinder { - internal class QSilithusGrindToLevel60 : GrindingBotQuest - { - public QSilithusGrindToLevel60(AmeisenBotInterfaces bot) - : base("SilithusGrindToLevel60", - [ + internal class QSilithusGrindToLevel60(AmeisenBotInterfaces bot) : GrindingBotQuest("SilithusGrindToLevel60", + [ new QuestObjectiveChain( [ new GrindingObjective(bot, 60, [ @@ -30,6 +27,6 @@ public QSilithusGrindToLevel60(AmeisenBotInterfaces bot) ]), ]) ]) - { } + { } } \ No newline at end of file diff --git a/AmeisenBotX.Core/Engines/Quest/Quests/Grinder/QStonetalonGrindToLevel23.cs b/AmeisenBotX.Core/Engines/Quest/Quests/Grinder/QStonetalonGrindToLevel23.cs index bd0001e0..dd06e062 100644 --- a/AmeisenBotX.Core/Engines/Quest/Quests/Grinder/QStonetalonGrindToLevel23.cs +++ b/AmeisenBotX.Core/Engines/Quest/Quests/Grinder/QStonetalonGrindToLevel23.cs @@ -4,16 +4,19 @@ namespace AmeisenBotX.Core.Engines.Quest.Quests.Grinder { - internal class QStonetalonGrindToLevel23 : GrindingBotQuest - { - public QStonetalonGrindToLevel23(AmeisenBotInterfaces bot) - : base("StonetalonGrindToLevel23", + internal class QStonetalonGrindToLevel23(AmeisenBotInterfaces bot) : GrindingBotQuest + ( + "StonetalonGrindToLevel23", + [ + new QuestObjectiveChain + ( [ - new QuestObjectiveChain( - [ - new GrindingObjective(bot, 23, [ - new() - { + new GrindingObjective + ( + bot, + 23, + [ + [ new Vector3(1414.59f, 164.04f, 18.81f), new Vector3(1215.00f, 343.34f, 32.46f), new Vector3(1128.53f, 283.56f, 16.99f), @@ -24,23 +27,24 @@ public QStonetalonGrindToLevel23(AmeisenBotInterfaces bot) new Vector3(1363.80f, -249.66f, -2.55f), new Vector3(1447.59f, -27.98f, 27.25f), new Vector3(1454.69f, 78.88f, 18.39f), - }, - new() - { + ], + [ new Vector3(993.42f, -382.99f, 8.45f), new Vector3(973.44f, -385.42f, 8.26f), new Vector3(988.42f, -421.82f, 7.94f), new Vector3(1006.76f, -394.96f, 7.06f), - }, - new() - { + ], + [ new Vector3(1481.77f, -222.40f, 23.03f), new Vector3(1481.04f, -249.44f, 23.85f), new Vector3(1510.72f, -251.47f, 30.71f), - }, - ]), - ]) - ]) - { } + ], + ] + ), + ] + ) + ] + ) + { } } \ No newline at end of file diff --git a/AmeisenBotX.Core/Engines/Quest/Quests/Grinder/QStonetalonGrindToLevel31.cs b/AmeisenBotX.Core/Engines/Quest/Quests/Grinder/QStonetalonGrindToLevel31.cs index b1b80337..45958a4c 100644 --- a/AmeisenBotX.Core/Engines/Quest/Quests/Grinder/QStonetalonGrindToLevel31.cs +++ b/AmeisenBotX.Core/Engines/Quest/Quests/Grinder/QStonetalonGrindToLevel31.cs @@ -4,11 +4,8 @@ namespace AmeisenBotX.Core.Engines.Quest.Quests.Grinder { - internal class QStonetalonGrindToLevel31 : GrindingBotQuest - { - public QStonetalonGrindToLevel31(AmeisenBotInterfaces bot) - : base("StonetalonGrindToLevel31", - [ + internal class QStonetalonGrindToLevel31(AmeisenBotInterfaces bot) : GrindingBotQuest("StonetalonGrindToLevel31", + [ new QuestObjectiveChain( [ new GrindingObjective(bot, 31, [ @@ -36,6 +33,6 @@ public QStonetalonGrindToLevel31(AmeisenBotInterfaces bot) ]), ]) ]) - { } + { } } \ No newline at end of file diff --git a/AmeisenBotX.Core/Engines/Quest/Quests/Grinder/QTanarisGrindToLevel44.cs b/AmeisenBotX.Core/Engines/Quest/Quests/Grinder/QTanarisGrindToLevel44.cs index 2fb57aa0..88da4824 100644 --- a/AmeisenBotX.Core/Engines/Quest/Quests/Grinder/QTanarisGrindToLevel44.cs +++ b/AmeisenBotX.Core/Engines/Quest/Quests/Grinder/QTanarisGrindToLevel44.cs @@ -4,11 +4,8 @@ namespace AmeisenBotX.Core.Engines.Quest.Quests.Grinder { - internal class QTanarisGrindToLevel44 : GrindingBotQuest - { - public QTanarisGrindToLevel44(AmeisenBotInterfaces bot) - : base("TanarisGrindToLevel44", - [ + internal class QTanarisGrindToLevel44(AmeisenBotInterfaces bot) : GrindingBotQuest("TanarisGrindToLevel44", + [ new QuestObjectiveChain( [ new GrindingObjective(bot, 44, [ @@ -68,6 +65,6 @@ public QTanarisGrindToLevel44(AmeisenBotInterfaces bot) ]), ]) ]) - { } + { } } \ No newline at end of file diff --git a/AmeisenBotX.Core/Engines/Quest/Quests/Grinder/QTanarisGrindToLevel49.cs b/AmeisenBotX.Core/Engines/Quest/Quests/Grinder/QTanarisGrindToLevel49.cs index 450aa8bf..3ebe7537 100644 --- a/AmeisenBotX.Core/Engines/Quest/Quests/Grinder/QTanarisGrindToLevel49.cs +++ b/AmeisenBotX.Core/Engines/Quest/Quests/Grinder/QTanarisGrindToLevel49.cs @@ -4,11 +4,8 @@ namespace AmeisenBotX.Core.Engines.Quest.Quests.Grinder { - internal class QTanarisGrindToLevel49 : GrindingBotQuest - { - public QTanarisGrindToLevel49(AmeisenBotInterfaces bot) - : base("TanarisGrindToLevel49", - [ + internal class QTanarisGrindToLevel49(AmeisenBotInterfaces bot) : GrindingBotQuest("TanarisGrindToLevel49", + [ new QuestObjectiveChain( [ new GrindingObjective(bot, 49, [ @@ -28,6 +25,6 @@ public QTanarisGrindToLevel49(AmeisenBotInterfaces bot) ]), ]) ]) - { } + { } } \ No newline at end of file diff --git a/AmeisenBotX.Core/Engines/Quest/Quests/Grinder/QTheBarrensGrindToLevel14.cs b/AmeisenBotX.Core/Engines/Quest/Quests/Grinder/QTheBarrensGrindToLevel14.cs index 0ab9eb27..dfd53dee 100644 --- a/AmeisenBotX.Core/Engines/Quest/Quests/Grinder/QTheBarrensGrindToLevel14.cs +++ b/AmeisenBotX.Core/Engines/Quest/Quests/Grinder/QTheBarrensGrindToLevel14.cs @@ -4,11 +4,8 @@ namespace AmeisenBotX.Core.Engines.Quest.Quests.Grinder { - internal class QTheBarrensGrindToLevel14 : GrindingBotQuest - { - public QTheBarrensGrindToLevel14(AmeisenBotInterfaces bot) - : base("TheBarrensGrindToLevel14", - [ + internal class QTheBarrensGrindToLevel14(AmeisenBotInterfaces bot) : GrindingBotQuest("TheBarrensGrindToLevel14", + [ new QuestObjectiveChain( [ new GrindingObjective(bot, 14, [ @@ -26,6 +23,6 @@ public QTheBarrensGrindToLevel14(AmeisenBotInterfaces bot) ]), ]) ]) - { } + { } } \ No newline at end of file diff --git a/AmeisenBotX.Core/Engines/Quest/Quests/Grinder/QTheBarrensGrindToLevel16.cs b/AmeisenBotX.Core/Engines/Quest/Quests/Grinder/QTheBarrensGrindToLevel16.cs index 089fb051..ea67d080 100644 --- a/AmeisenBotX.Core/Engines/Quest/Quests/Grinder/QTheBarrensGrindToLevel16.cs +++ b/AmeisenBotX.Core/Engines/Quest/Quests/Grinder/QTheBarrensGrindToLevel16.cs @@ -4,11 +4,8 @@ namespace AmeisenBotX.Core.Engines.Quest.Quests.Grinder { - internal class QTheBarrensGrindToLevel16 : GrindingBotQuest - { - public QTheBarrensGrindToLevel16(AmeisenBotInterfaces bot) - : base("TheBarrensGrindToLevel16", - [ + internal class QTheBarrensGrindToLevel16(AmeisenBotInterfaces bot) : GrindingBotQuest("TheBarrensGrindToLevel16", + [ new QuestObjectiveChain( [ new GrindingObjective(bot, 16, [ @@ -28,6 +25,6 @@ public QTheBarrensGrindToLevel16(AmeisenBotInterfaces bot) ]), ]) ]) - { } + { } } \ No newline at end of file diff --git a/AmeisenBotX.Core/Engines/Quest/Quests/Grinder/QTheBarrensGrindToLevel19.cs b/AmeisenBotX.Core/Engines/Quest/Quests/Grinder/QTheBarrensGrindToLevel19.cs index eedc644a..75f6657e 100644 --- a/AmeisenBotX.Core/Engines/Quest/Quests/Grinder/QTheBarrensGrindToLevel19.cs +++ b/AmeisenBotX.Core/Engines/Quest/Quests/Grinder/QTheBarrensGrindToLevel19.cs @@ -4,11 +4,8 @@ namespace AmeisenBotX.Core.Engines.Quest.Quests.Grinder { - internal class QTheBarrensGrindToLevel19 : GrindingBotQuest - { - public QTheBarrensGrindToLevel19(AmeisenBotInterfaces bot) - : base("TheBarrensGrindToLevel19", - [ + internal class QTheBarrensGrindToLevel19(AmeisenBotInterfaces bot) : GrindingBotQuest("TheBarrensGrindToLevel19", + [ new QuestObjectiveChain( [ new GrindingObjective(bot, 19, [ @@ -27,6 +24,6 @@ public QTheBarrensGrindToLevel19(AmeisenBotInterfaces bot) ]), ]) ]) - { } + { } } \ No newline at end of file diff --git a/AmeisenBotX.Core/Engines/Quest/Quests/Grinder/QUngoroGrindToLevel54.cs b/AmeisenBotX.Core/Engines/Quest/Quests/Grinder/QUngoroGrindToLevel54.cs index b41cdadf..e16cd7dc 100644 --- a/AmeisenBotX.Core/Engines/Quest/Quests/Grinder/QUngoroGrindToLevel54.cs +++ b/AmeisenBotX.Core/Engines/Quest/Quests/Grinder/QUngoroGrindToLevel54.cs @@ -4,11 +4,8 @@ namespace AmeisenBotX.Core.Engines.Quest.Quests.Grinder { - internal class QUngoroGrindToLevel54 : GrindingBotQuest - { - public QUngoroGrindToLevel54(AmeisenBotInterfaces bot) - : base("UngoroGrindToLevel54", - [ + internal class QUngoroGrindToLevel54(AmeisenBotInterfaces bot) : GrindingBotQuest("UngoroGrindToLevel54", + [ new QuestObjectiveChain( [ new GrindingObjective(bot, 54, [ @@ -31,6 +28,6 @@ public QUngoroGrindToLevel54(AmeisenBotInterfaces bot) ]), ]) ]) - { } + { } } \ No newline at end of file diff --git a/AmeisenBotX.Core/Engines/Quest/Quests/Test/GrindToLevel2.cs b/AmeisenBotX.Core/Engines/Quest/Quests/Test/GrindToLevel2.cs index 308bc1f7..c35c45af 100644 --- a/AmeisenBotX.Core/Engines/Quest/Quests/Test/GrindToLevel2.cs +++ b/AmeisenBotX.Core/Engines/Quest/Quests/Test/GrindToLevel2.cs @@ -4,11 +4,8 @@ namespace AmeisenBotX.Core.Engines.Quest.Quests.Test { - internal class GrindToLevel2 : GrindingBotQuest - { - public GrindToLevel2(AmeisenBotInterfaces bot) - : base("Test Grind Boars in Valley of Strength", - [ + internal class GrindToLevel2(AmeisenBotInterfaces bot) : GrindingBotQuest("Test Grind Boars in Valley of Strength", + [ new QuestObjectiveChain( [ new GrindingObjective(bot, 2, [ @@ -36,6 +33,6 @@ public GrindToLevel2(AmeisenBotInterfaces bot) ]), ]) ]) - { } + { } } \ No newline at end of file diff --git a/AmeisenBotX.Core/Engines/Quest/Quests/TheBarrens/Crossroads/QDisruptTheAttacks.cs b/AmeisenBotX.Core/Engines/Quest/Quests/TheBarrens/Crossroads/QDisruptTheAttacks.cs index cd5dbfb8..a832c69b 100644 --- a/AmeisenBotX.Core/Engines/Quest/Quests/TheBarrens/Crossroads/QDisruptTheAttacks.cs +++ b/AmeisenBotX.Core/Engines/Quest/Quests/TheBarrens/Crossroads/QDisruptTheAttacks.cs @@ -5,13 +5,10 @@ namespace AmeisenBotX.Core.Engines.Quest.Quests.TheBarrens.Crossroads { - internal class QDisruptTheAttacks : BotQuest - { - public QDisruptTheAttacks(AmeisenBotInterfaces bot) - : base(bot, 871, "Disrupt the Attacks", 9, 1, - () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3429 }), new Vector3(-473.20f, -2595.70f, 103.81f)), - () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3429 }), new Vector3(-473.20f, -2595.70f, 103.81f)), - [ + internal class QDisruptTheAttacks(AmeisenBotInterfaces bot) : BotQuest(bot, 871, "Disrupt the Attacks", 9, 1, + () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3429 }), new Vector3(-473.20f, -2595.70f, 103.81f)), + () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3429 }), new Vector3(-473.20f, -2595.70f, 103.81f)), + [ new QuestObjectiveChain( [ new KillAndLootQuestObjective(bot, [3267], 8, 0, [ @@ -102,6 +99,6 @@ public QDisruptTheAttacks(AmeisenBotInterfaces bot) ]), ]) ]) - { } + { } } \ No newline at end of file diff --git a/AmeisenBotX.Core/Engines/Quest/Quests/TheBarrens/Crossroads/QHarpyLieutenants.cs b/AmeisenBotX.Core/Engines/Quest/Quests/TheBarrens/Crossroads/QHarpyLieutenants.cs index bce5b5a2..4f670c3f 100644 --- a/AmeisenBotX.Core/Engines/Quest/Quests/TheBarrens/Crossroads/QHarpyLieutenants.cs +++ b/AmeisenBotX.Core/Engines/Quest/Quests/TheBarrens/Crossroads/QHarpyLieutenants.cs @@ -5,13 +5,10 @@ namespace AmeisenBotX.Core.Engines.Quest.Quests.TheBarrens.Crossroads { - internal class QHarpyLieutenants : BotQuest - { - public QHarpyLieutenants(AmeisenBotInterfaces bot) - : base(bot, 875, "Harpy Lieutenants", 12, 1, - () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3449 }), new Vector3(-474.89f, -2607.74f, 127.89f)), - () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3449 }), new Vector3(-474.89f, -2607.74f, 127.89f)), - [ + internal class QHarpyLieutenants(AmeisenBotInterfaces bot) : BotQuest(bot, 875, "Harpy Lieutenants", 12, 1, + () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3449 }), new Vector3(-474.89f, -2607.74f, 127.89f)), + () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3449 }), new Vector3(-474.89f, -2607.74f, 127.89f)), + [ new QuestObjectiveChain( [ new KillAndLootQuestObjective(bot, [3278], 6, 5065, [ @@ -32,6 +29,6 @@ public QHarpyLieutenants(AmeisenBotInterfaces bot) ]), ]) ]) - { } + { } } \ No newline at end of file diff --git a/AmeisenBotX.Core/Engines/Quest/Quests/TheBarrens/Crossroads/QHarpyRaiders.cs b/AmeisenBotX.Core/Engines/Quest/Quests/TheBarrens/Crossroads/QHarpyRaiders.cs index 45546a46..37e28ed6 100644 --- a/AmeisenBotX.Core/Engines/Quest/Quests/TheBarrens/Crossroads/QHarpyRaiders.cs +++ b/AmeisenBotX.Core/Engines/Quest/Quests/TheBarrens/Crossroads/QHarpyRaiders.cs @@ -5,13 +5,10 @@ namespace AmeisenBotX.Core.Engines.Quest.Quests.TheBarrens.Crossroads { - internal class QHarpyRaiders : BotQuest - { - public QHarpyRaiders(AmeisenBotInterfaces bot) - : base(bot, 867, "Harpy Raiders", 12, 1, - () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3449 }), new Vector3(-474.89f, -2607.74f, 127.89f)), - () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3449 }), new Vector3(-474.89f, -2607.74f, 127.89f)), - [ + internal class QHarpyRaiders(AmeisenBotInterfaces bot) : BotQuest(bot, 867, "Harpy Raiders", 12, 1, + () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3449 }), new Vector3(-474.89f, -2607.74f, 127.89f)), + () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3449 }), new Vector3(-474.89f, -2607.74f, 127.89f)), + [ new QuestObjectiveChain( [ new KillAndLootQuestObjective(bot, [3276, 3277, 3279, 3280, 3278, 3452], 8, 5064, [ @@ -32,6 +29,6 @@ public QHarpyRaiders(AmeisenBotInterfaces bot) ]), ]) ]) - { } + { } } \ No newline at end of file diff --git a/AmeisenBotX.Core/Engines/Quest/Quests/TheBarrens/Crossroads/QLetterToJinZil.cs b/AmeisenBotX.Core/Engines/Quest/Quests/TheBarrens/Crossroads/QLetterToJinZil.cs index 07a8259c..6ebe7809 100644 --- a/AmeisenBotX.Core/Engines/Quest/Quests/TheBarrens/Crossroads/QLetterToJinZil.cs +++ b/AmeisenBotX.Core/Engines/Quest/Quests/TheBarrens/Crossroads/QLetterToJinZil.cs @@ -4,13 +4,10 @@ namespace AmeisenBotX.Core.Engines.Quest.Quests.TheBarrens.Crossroads { - internal class QLetterToJinZil : BotQuest + internal class QLetterToJinZil(AmeisenBotInterfaces bot) : BotQuest(bot, 1060, "Letter to Jin'Zil", 15, 1, + () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3449 }), new Vector3(-474.89f, -2607.74f, 127.89f)), + () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3995 }), new Vector3(-272.48f, -394.08f, 17.21f)), + null) { - public QLetterToJinZil(AmeisenBotInterfaces bot) - : base(bot, 1060, "Letter to Jin'Zil", 15, 1, - () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3449 }), new Vector3(-474.89f, -2607.74f, 127.89f)), - () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3995 }), new Vector3(-272.48f, -394.08f, 17.21f)), - null) - { } } } \ No newline at end of file diff --git a/AmeisenBotX.Core/Engines/Quest/Quests/TheBarrens/Crossroads/QPlainstriderMenace.cs b/AmeisenBotX.Core/Engines/Quest/Quests/TheBarrens/Crossroads/QPlainstriderMenace.cs index 43345be0..ede55567 100644 --- a/AmeisenBotX.Core/Engines/Quest/Quests/TheBarrens/Crossroads/QPlainstriderMenace.cs +++ b/AmeisenBotX.Core/Engines/Quest/Quests/TheBarrens/Crossroads/QPlainstriderMenace.cs @@ -5,13 +5,10 @@ namespace AmeisenBotX.Core.Engines.Quest.Quests.TheBarrens.Crossroads { - internal class QPlainstriderMenace : BotQuest - { - public QPlainstriderMenace(AmeisenBotInterfaces bot) - : base(bot, 844, "Plainstrider Menace", 10, 1, - () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3338 }), new Vector3(-482.48f, -2670.19f, 97.52f)), - () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3338 }), new Vector3(-482.48f, -2670.19f, 97.52f)), - [ + internal class QPlainstriderMenace(AmeisenBotInterfaces bot) : BotQuest(bot, 844, "Plainstrider Menace", 10, 1, + () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3338 }), new Vector3(-482.48f, -2670.19f, 97.52f)), + () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3338 }), new Vector3(-482.48f, -2670.19f, 97.52f)), + [ new QuestObjectiveChain( [ new KillAndLootQuestObjective(bot, [3244, 3245, 3246], 7, 5087, [ @@ -35,6 +32,6 @@ public QPlainstriderMenace(AmeisenBotInterfaces bot) ]), ]) ]) - { } + { } } \ No newline at end of file diff --git a/AmeisenBotX.Core/Engines/Quest/Quests/TheBarrens/Crossroads/QProwlersOfTheBarrens.cs b/AmeisenBotX.Core/Engines/Quest/Quests/TheBarrens/Crossroads/QProwlersOfTheBarrens.cs index d470367a..d380f0c6 100644 --- a/AmeisenBotX.Core/Engines/Quest/Quests/TheBarrens/Crossroads/QProwlersOfTheBarrens.cs +++ b/AmeisenBotX.Core/Engines/Quest/Quests/TheBarrens/Crossroads/QProwlersOfTheBarrens.cs @@ -5,13 +5,10 @@ namespace AmeisenBotX.Core.Engines.Quest.Quests.TheBarrens.Crossroads { - internal class QProwlersOfTheBarrens : BotQuest - { - public QProwlersOfTheBarrens(AmeisenBotInterfaces bot) - : base(bot, 903, "Prowlers of the Barrens", 10, 1, - () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3338 }), new Vector3(-482.48f, -2670.19f, 97.52f)), - () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3338 }), new Vector3(-482.48f, -2670.19f, 97.52f)), - [ + internal class QProwlersOfTheBarrens(AmeisenBotInterfaces bot) : BotQuest(bot, 903, "Prowlers of the Barrens", 10, 1, + () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3338 }), new Vector3(-482.48f, -2670.19f, 97.52f)), + () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3338 }), new Vector3(-482.48f, -2670.19f, 97.52f)), + [ new QuestObjectiveChain( [ new KillAndLootQuestObjective(bot, [3425], 7, 5096, [ @@ -111,6 +108,6 @@ public QProwlersOfTheBarrens(AmeisenBotInterfaces bot) ]), ]) ]) - { } + { } } \ No newline at end of file diff --git a/AmeisenBotX.Core/Engines/Quest/Quests/TheBarrens/Crossroads/QRaptorThieves.cs b/AmeisenBotX.Core/Engines/Quest/Quests/TheBarrens/Crossroads/QRaptorThieves.cs index 7523dd87..40867455 100644 --- a/AmeisenBotX.Core/Engines/Quest/Quests/TheBarrens/Crossroads/QRaptorThieves.cs +++ b/AmeisenBotX.Core/Engines/Quest/Quests/TheBarrens/Crossroads/QRaptorThieves.cs @@ -5,13 +5,10 @@ namespace AmeisenBotX.Core.Engines.Quest.Quests.TheBarrens.Crossroads { - internal class QRaptorThieves : BotQuest - { - public QRaptorThieves(AmeisenBotInterfaces bot) - : base(bot, 869, "Raptor Thieves", 9, 1, - () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3464 }), new Vector3(-435.95f, -2639.21f, 96.36f)), - () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3464 }), new Vector3(-435.95f, -2639.21f, 96.36f)), - [ + internal class QRaptorThieves(AmeisenBotInterfaces bot) : BotQuest(bot, 869, "Raptor Thieves", 9, 1, + () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3464 }), new Vector3(-435.95f, -2639.21f, 96.36f)), + () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3464 }), new Vector3(-435.95f, -2639.21f, 96.36f)), + [ new QuestObjectiveChain( [ new KillAndLootQuestObjective(bot, [3254, 3255, 3256, 3257, 5842], 12, 5062, [ @@ -34,6 +31,6 @@ public QRaptorThieves(AmeisenBotInterfaces bot) ]), ]) ]) - { } + { } } \ No newline at end of file diff --git a/AmeisenBotX.Core/Engines/Quest/Quests/TheBarrens/Crossroads/QSerenaBloodfeather.cs b/AmeisenBotX.Core/Engines/Quest/Quests/TheBarrens/Crossroads/QSerenaBloodfeather.cs index fe1d71d2..461875a6 100644 --- a/AmeisenBotX.Core/Engines/Quest/Quests/TheBarrens/Crossroads/QSerenaBloodfeather.cs +++ b/AmeisenBotX.Core/Engines/Quest/Quests/TheBarrens/Crossroads/QSerenaBloodfeather.cs @@ -5,13 +5,10 @@ namespace AmeisenBotX.Core.Engines.Quest.Quests.TheBarrens.Crossroads { - internal class QSerenaBloodfeather : BotQuest - { - public QSerenaBloodfeather(AmeisenBotInterfaces bot) - : base(bot, 876, "Serena Bloodfeather", 12, 1, - () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3449 }), new Vector3(-474.89f, -2607.74f, 127.89f)), - () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3449 }), new Vector3(-474.89f, -2607.74f, 127.89f)), - [ + internal class QSerenaBloodfeather(AmeisenBotInterfaces bot) : BotQuest(bot, 876, "Serena Bloodfeather", 12, 1, + () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3449 }), new Vector3(-474.89f, -2607.74f, 127.89f)), + () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3449 }), new Vector3(-474.89f, -2607.74f, 127.89f)), + [ new QuestObjectiveChain( [ new KillAndLootQuestObjective(bot, [3452], 1, 5067, [ @@ -22,6 +19,6 @@ public QSerenaBloodfeather(AmeisenBotInterfaces bot) ]), ]) ]) - { } + { } } \ No newline at end of file diff --git a/AmeisenBotX.Core/Engines/Quest/Quests/TheBarrens/Crossroads/QSouthseaFreebooters.cs b/AmeisenBotX.Core/Engines/Quest/Quests/TheBarrens/Crossroads/QSouthseaFreebooters.cs index 50f9f751..a03f80d0 100644 --- a/AmeisenBotX.Core/Engines/Quest/Quests/TheBarrens/Crossroads/QSouthseaFreebooters.cs +++ b/AmeisenBotX.Core/Engines/Quest/Quests/TheBarrens/Crossroads/QSouthseaFreebooters.cs @@ -5,13 +5,10 @@ namespace AmeisenBotX.Core.Engines.Quest.Quests.TheBarrens.Crossroads { - internal class QSouthseaFreebooters : BotQuest - { - public QSouthseaFreebooters(AmeisenBotInterfaces bot) - : base(bot, 887, "Southsea Freebooters", 9, 1, - () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3391 }), new Vector3(-835.56f, -3728.66f, 26.37f)), - () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3391 }), new Vector3(-835.56f, -3728.66f, 26.37f)), - [ + internal class QSouthseaFreebooters(AmeisenBotInterfaces bot) : BotQuest(bot, 887, "Southsea Freebooters", 9, 1, + () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3391 }), new Vector3(-835.56f, -3728.66f, 26.37f)), + () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3391 }), new Vector3(-835.56f, -3728.66f, 26.37f)), + [ new QuestObjectiveChain( [ new KillAndLootQuestObjective(bot, [3381], 12, 0, [ @@ -40,6 +37,6 @@ public QSouthseaFreebooters(AmeisenBotInterfaces bot) ]), ]) ]) - { } + { } } \ No newline at end of file diff --git a/AmeisenBotX.Core/Engines/Quest/Quests/TheBarrens/Crossroads/QSuppliesForTheCrossroads.cs b/AmeisenBotX.Core/Engines/Quest/Quests/TheBarrens/Crossroads/QSuppliesForTheCrossroads.cs index 7139b277..6436b0c3 100644 --- a/AmeisenBotX.Core/Engines/Quest/Quests/TheBarrens/Crossroads/QSuppliesForTheCrossroads.cs +++ b/AmeisenBotX.Core/Engines/Quest/Quests/TheBarrens/Crossroads/QSuppliesForTheCrossroads.cs @@ -5,13 +5,10 @@ namespace AmeisenBotX.Core.Engines.Quest.Quests.TheBarrens.Crossroads { - internal class QSuppliesForTheCrossroads : BotQuest - { - public QSuppliesForTheCrossroads(AmeisenBotInterfaces bot) - : base(bot, 5041, "Supplies for the Crossroads", 9, 1, - () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3429 }), new Vector3(-473.20f, -2595.70f, 103.81f)), - () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3429 }), new Vector3(-473.20f, -2595.70f, 103.81f)), - [ + internal class QSuppliesForTheCrossroads(AmeisenBotInterfaces bot) : BotQuest(bot, 5041, "Supplies for the Crossroads", 9, 1, + () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3429 }), new Vector3(-473.20f, -2595.70f, 103.81f)), + () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3429 }), new Vector3(-473.20f, -2595.70f, 103.81f)), + [ new QuestObjectiveChain( [ new CollectQuestObjective(bot, 12708, 1, [175708], [ @@ -22,6 +19,6 @@ public QSuppliesForTheCrossroads(AmeisenBotInterfaces bot) ]), ]) ]) - { } + { } } \ No newline at end of file diff --git a/AmeisenBotX.Core/Engines/Quest/Quests/TheBarrens/Crossroads/QTheDisruptionEnds.cs b/AmeisenBotX.Core/Engines/Quest/Quests/TheBarrens/Crossroads/QTheDisruptionEnds.cs index 54430bbe..083bcd2d 100644 --- a/AmeisenBotX.Core/Engines/Quest/Quests/TheBarrens/Crossroads/QTheDisruptionEnds.cs +++ b/AmeisenBotX.Core/Engines/Quest/Quests/TheBarrens/Crossroads/QTheDisruptionEnds.cs @@ -5,13 +5,10 @@ namespace AmeisenBotX.Core.Engines.Quest.Quests.TheBarrens.Crossroads { - internal class QTheDisruptionEnds : BotQuest - { - public QTheDisruptionEnds(AmeisenBotInterfaces bot) - : base(bot, 872, "The Disruption Ends", 9, 1, - () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3429 }), new Vector3(-473.20f, -2595.70f, 103.81f)), - () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3429 }), new Vector3(-473.20f, -2595.70f, 103.81f)), - [ + internal class QTheDisruptionEnds(AmeisenBotInterfaces bot) : BotQuest(bot, 872, "The Disruption Ends", 9, 1, + () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3429 }), new Vector3(-473.20f, -2595.70f, 103.81f)), + () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3429 }), new Vector3(-473.20f, -2595.70f, 103.81f)), + [ new QuestObjectiveChain( [ new KillAndLootQuestObjective(bot, [3269], 8, 0, [ @@ -77,6 +74,6 @@ public QTheDisruptionEnds(AmeisenBotInterfaces bot) ]), ]) ]) - { } + { } } \ No newline at end of file diff --git a/AmeisenBotX.Core/Engines/Quest/Quests/TheBarrens/Crossroads/QTheZhevra.cs b/AmeisenBotX.Core/Engines/Quest/Quests/TheBarrens/Crossroads/QTheZhevra.cs index 4bf765a1..3cb42805 100644 --- a/AmeisenBotX.Core/Engines/Quest/Quests/TheBarrens/Crossroads/QTheZhevra.cs +++ b/AmeisenBotX.Core/Engines/Quest/Quests/TheBarrens/Crossroads/QTheZhevra.cs @@ -5,13 +5,10 @@ namespace AmeisenBotX.Core.Engines.Quest.Quests.TheBarrens.Crossroads { - internal class QTheZhevra : BotQuest - { - public QTheZhevra(AmeisenBotInterfaces bot) - : base(bot, 845, "The Zhevra", 10, 1, - () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3338 }), new Vector3(-482.48f, -2670.19f, 97.52f)), - () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3338 }), new Vector3(-482.48f, -2670.19f, 97.52f)), - [ + internal class QTheZhevra(AmeisenBotInterfaces bot) : BotQuest(bot, 845, "The Zhevra", 10, 1, + () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3338 }), new Vector3(-482.48f, -2670.19f, 97.52f)), + () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3338 }), new Vector3(-482.48f, -2670.19f, 97.52f)), + [ new QuestObjectiveChain( [ new KillAndLootQuestObjective(bot, [3242, 3426, 3466, 5831], 4, 5086, [ @@ -32,6 +29,6 @@ public QTheZhevra(AmeisenBotInterfaces bot) ]), ]) ]) - { } + { } } \ No newline at end of file diff --git a/AmeisenBotX.Core/Engines/Quest/Quests/TheBarrens/OutpostBridge/QCrossroadsConscription.cs b/AmeisenBotX.Core/Engines/Quest/Quests/TheBarrens/OutpostBridge/QCrossroadsConscription.cs index 7df55ec4..25ad2f3f 100644 --- a/AmeisenBotX.Core/Engines/Quest/Quests/TheBarrens/OutpostBridge/QCrossroadsConscription.cs +++ b/AmeisenBotX.Core/Engines/Quest/Quests/TheBarrens/OutpostBridge/QCrossroadsConscription.cs @@ -4,13 +4,10 @@ namespace AmeisenBotX.Core.Engines.Quest.Quests.TheBarrens.OutpostBridge { - internal class QCrossroadsConscription : BotQuest + internal class QCrossroadsConscription(AmeisenBotInterfaces bot) : BotQuest(bot, 842, "Crossroads Conscription", 10, 1, + () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3337 }), new Vector3(303.43f, -3686.16f, 27.15f)), + () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3338 }), new Vector3(-482.48f, -2670.19f, 97.52f)), + null) { - public QCrossroadsConscription(AmeisenBotInterfaces bot) - : base(bot, 842, "Crossroads Conscription", 10, 1, - () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3337 }), new Vector3(303.43f, -3686.16f, 27.15f)), - () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3338 }), new Vector3(-482.48f, -2670.19f, 97.52f)), - null) - { } } } \ No newline at end of file diff --git a/AmeisenBotX.Core/Engines/Quest/Quests/TheBarrens/OutpostStonetalon/QCentaurBracers.cs b/AmeisenBotX.Core/Engines/Quest/Quests/TheBarrens/OutpostStonetalon/QCentaurBracers.cs index 9cb0bb21..36bff731 100644 --- a/AmeisenBotX.Core/Engines/Quest/Quests/TheBarrens/OutpostStonetalon/QCentaurBracers.cs +++ b/AmeisenBotX.Core/Engines/Quest/Quests/TheBarrens/OutpostStonetalon/QCentaurBracers.cs @@ -5,13 +5,10 @@ namespace AmeisenBotX.Core.Engines.Quest.Quests.TheBarrens.OutpostStonetalon { - internal class QCentaurBracers : BotQuest - { - public QCentaurBracers(AmeisenBotInterfaces bot) - : base(bot, 855, "Centaur Bracers", 9, 1, - () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3389 }), new Vector3(-307.14f, -1971.95f, 96.48f)), - () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3389 }), new Vector3(-307.14f, -1971.95f, 96.48f)), - [ + internal class QCentaurBracers(AmeisenBotInterfaces bot) : BotQuest(bot, 855, "Centaur Bracers", 9, 1, + () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3389 }), new Vector3(-307.14f, -1971.95f, 96.48f)), + () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3389 }), new Vector3(-307.14f, -1971.95f, 96.48f)), + [ new QuestObjectiveChain( [ new KillAndLootQuestObjective(bot, [3272, 3273, 3274, 3275, 3397, 5837, 5838, 5841, 9523, 9524, 3394, 3395, 3396, 9456], 15, 5030, [ @@ -100,6 +97,6 @@ public QCentaurBracers(AmeisenBotInterfaces bot) ]), ]) ]) - { } + { } } \ No newline at end of file diff --git a/AmeisenBotX.Core/Engines/Quest/Quests/TheBarrens/OutpostStonetalon/QKolkarLeaders.cs b/AmeisenBotX.Core/Engines/Quest/Quests/TheBarrens/OutpostStonetalon/QKolkarLeaders.cs index 1a20475d..35f4adee 100644 --- a/AmeisenBotX.Core/Engines/Quest/Quests/TheBarrens/OutpostStonetalon/QKolkarLeaders.cs +++ b/AmeisenBotX.Core/Engines/Quest/Quests/TheBarrens/OutpostStonetalon/QKolkarLeaders.cs @@ -5,13 +5,10 @@ namespace AmeisenBotX.Core.Engines.Quest.Quests.TheBarrens.OutpostStonetalon { - internal class QKolkarLeaders : BotQuest - { - public QKolkarLeaders(AmeisenBotInterfaces bot) - : base(bot, 850, "Kolkar Leaders", 11, 1, - () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3389 }), new Vector3(-307.14f, -1971.95f, 96.48f)), - () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3389 }), new Vector3(-307.14f, -1971.95f, 96.48f)), - [ + internal class QKolkarLeaders(AmeisenBotInterfaces bot) : BotQuest(bot, 850, "Kolkar Leaders", 11, 1, + () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3389 }), new Vector3(-307.14f, -1971.95f, 96.48f)), + () => (bot.GetClosestQuestGiverByNpcId(bot.Player.Position, new List { 3389 }), new Vector3(-307.14f, -1971.95f, 96.48f)), + [ new QuestObjectiveChain( [ new KillAndLootQuestObjective(bot, [3394], 1, 5022, [ @@ -22,6 +19,6 @@ public QKolkarLeaders(AmeisenBotInterfaces bot) ]), ]) ]) - { } + { } } \ No newline at end of file diff --git a/AmeisenBotX.Core/Engines/Tactic/Bosses/Naxxramas10/AnubRekhan10Tactic.cs b/AmeisenBotX.Core/Engines/Tactic/Bosses/Naxxramas10/AnubRekhan10Tactic.cs index c4b647e5..6bf63703 100644 --- a/AmeisenBotX.Core/Engines/Tactic/Bosses/Naxxramas10/AnubRekhan10Tactic.cs +++ b/AmeisenBotX.Core/Engines/Tactic/Bosses/Naxxramas10/AnubRekhan10Tactic.cs @@ -81,6 +81,7 @@ public bool ExecuteTactic(WowRole role, bool isMelee, out bool handlesMovement, WowRole.Tank => DoTank(out handlesMovement, out allowAttacking), WowRole.Heal => DoDpsHeal(false, out handlesMovement, out allowAttacking), WowRole.Dps => DoDpsHeal(isMelee, out handlesMovement, out allowAttacking), + _ => throw new NotImplementedException(), }; } diff --git a/AmeisenBotX.Core/Logic/AmeisenBotLogic.cs b/AmeisenBotX.Core/Logic/AmeisenBotLogic.cs index fa71e996..25b4ba26 100644 --- a/AmeisenBotX.Core/Logic/AmeisenBotLogic.cs +++ b/AmeisenBotX.Core/Logic/AmeisenBotLogic.cs @@ -393,6 +393,7 @@ public static NpcSubType DecideClassTrainer(WowClass wowClass) WowClass.Mage => NpcSubType.MageTrainer, WowClass.Warlock => NpcSubType.WarlockTrainer, WowClass.Druid => NpcSubType.DruidTrainer, + _ => throw new NotImplementedException(), }; } @@ -478,7 +479,7 @@ private BtStatus ChangeRealmlist() if (File.Exists(configWtfPath)) { bool editedFile = false; - List content = File.ReadAllLines(configWtfPath).ToList(); + List content = [.. File.ReadAllLines(configWtfPath)]; if (!content.Any(e => e.Contains($"SET REALMLIST {Config.Realmlist}", StringComparison.OrdinalIgnoreCase))) { diff --git a/AmeisenBotX.Core/Logic/Idle/Actions/AuctionHouseIdleAction.cs b/AmeisenBotX.Core/Logic/Idle/Actions/AuctionHouseIdleAction.cs index 7275d2fc..edbbe826 100644 --- a/AmeisenBotX.Core/Logic/Idle/Actions/AuctionHouseIdleAction.cs +++ b/AmeisenBotX.Core/Logic/Idle/Actions/AuctionHouseIdleAction.cs @@ -8,14 +8,8 @@ namespace AmeisenBotX.Core.Logic.Idle.Actions { - public class AuctionHouseIdleAction : IIdleAction + public class AuctionHouseIdleAction(AmeisenBotInterfaces bot) : IIdleAction { - public AuctionHouseIdleAction(AmeisenBotInterfaces bot) - { - Bot = bot; - Rnd = new Random(); - } - public bool AutopilotOnly => true; public DateTime Cooldown { get; set; } @@ -30,7 +24,7 @@ public AuctionHouseIdleAction(AmeisenBotInterfaces bot) private DateTime AuctioneerTalkTime { get; set; } - private AmeisenBotInterfaces Bot { get; } + private AmeisenBotInterfaces Bot { get; } = bot; private Vector3 CurrentAuctioneer { get; set; } @@ -38,7 +32,7 @@ public AuctionHouseIdleAction(AmeisenBotInterfaces bot) private bool ReturnedToOrigin { get; set; } - private Random Rnd { get; } + private Random Rnd { get; } = new Random(); private bool TalkedToAuctioneer { get; set; } diff --git a/AmeisenBotX.Core/Logic/Idle/Actions/CheckMailsIdleAction.cs b/AmeisenBotX.Core/Logic/Idle/Actions/CheckMailsIdleAction.cs index 3e8946e8..6f1bd2cd 100644 --- a/AmeisenBotX.Core/Logic/Idle/Actions/CheckMailsIdleAction.cs +++ b/AmeisenBotX.Core/Logic/Idle/Actions/CheckMailsIdleAction.cs @@ -9,14 +9,8 @@ namespace AmeisenBotX.Core.Logic.Idle.Actions { - public class CheckMailsIdleAction : IIdleAction + public class CheckMailsIdleAction(AmeisenBotInterfaces bot) : IIdleAction { - public CheckMailsIdleAction(AmeisenBotInterfaces bot) - { - Bot = bot; - Rnd = new Random(); - } - public bool AutopilotOnly => true; public DateTime Cooldown { get; set; } @@ -29,7 +23,7 @@ public CheckMailsIdleAction(AmeisenBotInterfaces bot) public int MinDuration => 1 * 60 * 1000; - private AmeisenBotInterfaces Bot { get; } + private AmeisenBotInterfaces Bot { get; } = bot; private bool CheckedMails { get; set; } @@ -41,7 +35,7 @@ public CheckMailsIdleAction(AmeisenBotInterfaces bot) private bool ReturnedToOrigin { get; set; } - private Random Rnd { get; } + private Random Rnd { get; } = new Random(); public bool Enter() { diff --git a/AmeisenBotX.Core/Logic/Idle/Actions/FishingIdleAction.cs b/AmeisenBotX.Core/Logic/Idle/Actions/FishingIdleAction.cs index ad21946d..5a26958d 100644 --- a/AmeisenBotX.Core/Logic/Idle/Actions/FishingIdleAction.cs +++ b/AmeisenBotX.Core/Logic/Idle/Actions/FishingIdleAction.cs @@ -11,17 +11,11 @@ namespace AmeisenBotX.Core.Logic.Idle.Actions { - public class FishingIdleAction : IIdleAction + public class FishingIdleAction(AmeisenBotInterfaces bot) : IIdleAction { - public FishingIdleAction(AmeisenBotInterfaces bot) - { - Bot = bot; - Rnd = new Random(); - } - public bool AutopilotOnly => true; - public AmeisenBotInterfaces Bot { get; } + public AmeisenBotInterfaces Bot { get; } = bot; public DateTime Cooldown { get; set; } @@ -45,7 +39,7 @@ public FishingIdleAction(AmeisenBotInterfaces bot) public bool Started { get; set; } - private Random Rnd { get; } + private Random Rnd { get; } = new Random(); public bool Enter() { diff --git a/AmeisenBotX.Core/Logic/Idle/Actions/LookAroundIdleAction.cs b/AmeisenBotX.Core/Logic/Idle/Actions/LookAroundIdleAction.cs index dfc221eb..51a48e6b 100644 --- a/AmeisenBotX.Core/Logic/Idle/Actions/LookAroundIdleAction.cs +++ b/AmeisenBotX.Core/Logic/Idle/Actions/LookAroundIdleAction.cs @@ -2,17 +2,11 @@ namespace AmeisenBotX.Core.Logic.Idle.Actions { - public class LookAroundIdleAction : IIdleAction + public class LookAroundIdleAction(AmeisenBotInterfaces bot) : IIdleAction { - public LookAroundIdleAction(AmeisenBotInterfaces bot) - { - Bot = bot; - Rnd = new Random(); - } - public bool AutopilotOnly => false; - public AmeisenBotInterfaces Bot { get; } + public AmeisenBotInterfaces Bot { get; } = bot; public DateTime Cooldown { get; set; } @@ -24,7 +18,7 @@ public LookAroundIdleAction(AmeisenBotInterfaces bot) public int MinDuration => 0; - private Random Rnd { get; } + private Random Rnd { get; } = new Random(); public bool Enter() { diff --git a/AmeisenBotX.Core/Logic/Idle/Actions/LookAtGroupIdleAction.cs b/AmeisenBotX.Core/Logic/Idle/Actions/LookAtGroupIdleAction.cs index 862e279c..c5fb9f7b 100644 --- a/AmeisenBotX.Core/Logic/Idle/Actions/LookAtGroupIdleAction.cs +++ b/AmeisenBotX.Core/Logic/Idle/Actions/LookAtGroupIdleAction.cs @@ -6,17 +6,11 @@ namespace AmeisenBotX.Core.Logic.Idle.Actions { - public class LookAtGroupIdleAction : IIdleAction + public class LookAtGroupIdleAction(AmeisenBotInterfaces bot) : IIdleAction { - public LookAtGroupIdleAction(AmeisenBotInterfaces bot) - { - Bot = bot; - Rnd = new Random(); - } - public bool AutopilotOnly => false; - public AmeisenBotInterfaces Bot { get; } + public AmeisenBotInterfaces Bot { get; } = bot; public DateTime Cooldown { get; set; } @@ -28,9 +22,7 @@ public LookAtGroupIdleAction(AmeisenBotInterfaces bot) public int MinDuration => 0; - private IEnumerable NearPartymembers { get; set; } - - private Random Rnd { get; } + private Random Rnd { get; } = new Random(); public bool Enter() { diff --git a/AmeisenBotX.Core/Logic/Idle/Actions/LookAtGroupmemberIdleAction.cs b/AmeisenBotX.Core/Logic/Idle/Actions/LookAtGroupmemberIdleAction.cs index 2fe46d35..11358f68 100644 --- a/AmeisenBotX.Core/Logic/Idle/Actions/LookAtGroupmemberIdleAction.cs +++ b/AmeisenBotX.Core/Logic/Idle/Actions/LookAtGroupmemberIdleAction.cs @@ -6,17 +6,11 @@ namespace AmeisenBotX.Core.Logic.Idle.Actions { - public class LookAtGroupmemberIdleAction : IIdleAction + public class LookAtGroupmemberIdleAction(AmeisenBotInterfaces bot) : IIdleAction { - public LookAtGroupmemberIdleAction(AmeisenBotInterfaces bot) - { - Bot = bot; - Rnd = new Random(); - } - public bool AutopilotOnly => false; - public AmeisenBotInterfaces Bot { get; } + public AmeisenBotInterfaces Bot { get; } = bot; public DateTime Cooldown { get; set; } @@ -30,7 +24,7 @@ public LookAtGroupmemberIdleAction(AmeisenBotInterfaces bot) private IEnumerable NearPartymembersFacingMe { get; set; } - private Random Rnd { get; } + private Random Rnd { get; } = new Random(); public bool Enter() { diff --git a/AmeisenBotX.Core/Logic/Idle/Actions/LookAtNpcsIdleAction.cs b/AmeisenBotX.Core/Logic/Idle/Actions/LookAtNpcsIdleAction.cs index 77595137..cff8549e 100644 --- a/AmeisenBotX.Core/Logic/Idle/Actions/LookAtNpcsIdleAction.cs +++ b/AmeisenBotX.Core/Logic/Idle/Actions/LookAtNpcsIdleAction.cs @@ -6,17 +6,11 @@ namespace AmeisenBotX.Core.Logic.Idle.Actions { - public class LookAtNpcsIdleAction : IIdleAction + public class LookAtNpcsIdleAction(AmeisenBotInterfaces bot) : IIdleAction { - public LookAtNpcsIdleAction(AmeisenBotInterfaces bot) - { - Bot = bot; - Rnd = new Random(); - } - public bool AutopilotOnly => false; - public AmeisenBotInterfaces Bot { get; } + public AmeisenBotInterfaces Bot { get; } = bot; public DateTime Cooldown { get; set; } @@ -30,7 +24,7 @@ public LookAtNpcsIdleAction(AmeisenBotInterfaces bot) private IEnumerable NpcsNearMe { get; set; } - private Random Rnd { get; } + private Random Rnd { get; } = new Random(); public bool Enter() { diff --git a/AmeisenBotX.Core/Logic/Idle/Actions/LookAtTargetIdleAction.cs b/AmeisenBotX.Core/Logic/Idle/Actions/LookAtTargetIdleAction.cs index d6b706a9..5131f69c 100644 --- a/AmeisenBotX.Core/Logic/Idle/Actions/LookAtTargetIdleAction.cs +++ b/AmeisenBotX.Core/Logic/Idle/Actions/LookAtTargetIdleAction.cs @@ -3,17 +3,11 @@ namespace AmeisenBotX.Core.Logic.Idle.Actions { - public class LookAtTargetIdleAction : IIdleAction + public class LookAtTargetIdleAction(AmeisenBotInterfaces bot) : IIdleAction { - public LookAtTargetIdleAction(AmeisenBotInterfaces bot) - { - Bot = bot; - Rnd = new Random(); - } - public bool AutopilotOnly => false; - public AmeisenBotInterfaces Bot { get; } + public AmeisenBotInterfaces Bot { get; } = bot; public DateTime Cooldown { get; set; } @@ -25,7 +19,7 @@ public LookAtTargetIdleAction(AmeisenBotInterfaces bot) public int MinDuration => 0; - private Random Rnd { get; } + private Random Rnd { get; } = new Random(); public bool Enter() { diff --git a/AmeisenBotX.Core/Logic/Idle/Actions/OpenMapIdleAction.cs b/AmeisenBotX.Core/Logic/Idle/Actions/OpenMapIdleAction.cs index b6ac4161..0af5b4df 100644 --- a/AmeisenBotX.Core/Logic/Idle/Actions/OpenMapIdleAction.cs +++ b/AmeisenBotX.Core/Logic/Idle/Actions/OpenMapIdleAction.cs @@ -2,16 +2,11 @@ namespace AmeisenBotX.Core.Logic.Idle.Actions { - public class OpenMapIdleAction : IIdleAction + public class OpenMapIdleAction(AmeisenBotInterfaces bot) : IIdleAction { - public OpenMapIdleAction(AmeisenBotInterfaces bot) - { - Bot = bot; - } - public bool AutopilotOnly => false; - public AmeisenBotInterfaces Bot { get; } + public AmeisenBotInterfaces Bot { get; } = bot; public DateTime Cooldown { get; set; } diff --git a/AmeisenBotX.Core/Logic/Idle/Actions/RandomEmoteIdleAction.cs b/AmeisenBotX.Core/Logic/Idle/Actions/RandomEmoteIdleAction.cs index 91c8c2c6..bacb351e 100644 --- a/AmeisenBotX.Core/Logic/Idle/Actions/RandomEmoteIdleAction.cs +++ b/AmeisenBotX.Core/Logic/Idle/Actions/RandomEmoteIdleAction.cs @@ -5,13 +5,15 @@ namespace AmeisenBotX.Core.Logic.Idle.Actions { - public class RandomEmoteIdleAction : IIdleAction + public class RandomEmoteIdleAction(AmeisenBotInterfaces bot) : IIdleAction { - public RandomEmoteIdleAction(AmeisenBotInterfaces bot) - { - Bot = bot; + public bool AutopilotOnly => false; - Emotes = + public AmeisenBotInterfaces Bot { get; } = bot; + + public DateTime Cooldown { get; set; } + + public List Emotes { get; } = [ "flex", "train", @@ -22,7 +24,7 @@ public RandomEmoteIdleAction(AmeisenBotInterfaces bot) "sleep", ]; - EmotesWithInteraction = + public List EmotesWithInteraction { get; } = [ "hi", "wink", @@ -36,19 +38,6 @@ public RandomEmoteIdleAction(AmeisenBotInterfaces bot) "shy", ]; - Rnd = new Random(); - } - - public bool AutopilotOnly => false; - - public AmeisenBotInterfaces Bot { get; } - - public DateTime Cooldown { get; set; } - - public List Emotes { get; } - - public List EmotesWithInteraction { get; } - public int MaxCooldown => 168 * 1000; public int MaxDuration => 0; @@ -57,7 +46,7 @@ public RandomEmoteIdleAction(AmeisenBotInterfaces bot) public int MinDuration => 0; - private Random Rnd { get; } + private Random Rnd { get; } = new Random(); public bool Enter() { diff --git a/AmeisenBotX.Core/Logic/Idle/Actions/SheathWeaponIdleAction.cs b/AmeisenBotX.Core/Logic/Idle/Actions/SheathWeaponIdleAction.cs index d407224a..62cb3864 100644 --- a/AmeisenBotX.Core/Logic/Idle/Actions/SheathWeaponIdleAction.cs +++ b/AmeisenBotX.Core/Logic/Idle/Actions/SheathWeaponIdleAction.cs @@ -2,16 +2,11 @@ namespace AmeisenBotX.Core.Logic.Idle.Actions { - public class SheathWeaponIdleAction : IIdleAction + public class SheathWeaponIdleAction(AmeisenBotInterfaces bot) : IIdleAction { - public SheathWeaponIdleAction(AmeisenBotInterfaces bot) - { - Bot = bot; - } - public bool AutopilotOnly => false; - public AmeisenBotInterfaces Bot { get; } + public AmeisenBotInterfaces Bot { get; } = bot; public DateTime Cooldown { get; set; } diff --git a/AmeisenBotX.Core/Logic/Idle/Actions/SitByCampfireIdleAction.cs b/AmeisenBotX.Core/Logic/Idle/Actions/SitByCampfireIdleAction.cs index d68369c3..2968cfc5 100644 --- a/AmeisenBotX.Core/Logic/Idle/Actions/SitByCampfireIdleAction.cs +++ b/AmeisenBotX.Core/Logic/Idle/Actions/SitByCampfireIdleAction.cs @@ -5,17 +5,11 @@ namespace AmeisenBotX.Core.Logic.Idle.Actions { - public class SitByCampfireIdleAction : IIdleAction + public class SitByCampfireIdleAction(AmeisenBotInterfaces bot) : IIdleAction { - public SitByCampfireIdleAction(AmeisenBotInterfaces bot) - { - Bot = bot; - Rnd = new Random(); - } - public bool AutopilotOnly => false; - public AmeisenBotInterfaces Bot { get; } + public AmeisenBotInterfaces Bot { get; } = bot; public DateTime Cooldown { get; set; } @@ -29,7 +23,7 @@ public SitByCampfireIdleAction(AmeisenBotInterfaces bot) private bool PlacedCampfire { get; set; } - private Random Rnd { get; } + private Random Rnd { get; } = new Random(); private bool SatDown { get; set; } diff --git a/AmeisenBotX.Core/Logic/Idle/Actions/SitToChairIdleAction.cs b/AmeisenBotX.Core/Logic/Idle/Actions/SitToChairIdleAction.cs index 5b464290..0ee41021 100644 --- a/AmeisenBotX.Core/Logic/Idle/Actions/SitToChairIdleAction.cs +++ b/AmeisenBotX.Core/Logic/Idle/Actions/SitToChairIdleAction.cs @@ -7,17 +7,11 @@ namespace AmeisenBotX.Core.Logic.Idle.Actions { - public class SitToChairIdleAction : IIdleAction + public class SitToChairIdleAction(AmeisenBotInterfaces bot, double maxDistance) : IIdleAction { - public SitToChairIdleAction(AmeisenBotInterfaces bot, double maxDistance) - { - Bot = bot; - MaxDistance = maxDistance; - } - public bool AutopilotOnly => false; - public AmeisenBotInterfaces Bot { get; } + public AmeisenBotInterfaces Bot { get; } = bot; public DateTime Cooldown { get; set; } @@ -31,7 +25,7 @@ public SitToChairIdleAction(AmeisenBotInterfaces bot, double maxDistance) private IWowGameobject CurrentSeat { get; set; } - private double MaxDistance { get; } + private double MaxDistance { get; } = maxDistance; private bool SatDown { get; set; } diff --git a/AmeisenBotX.Core/Logic/Idle/Actions/Utils/BasicIdleAction.cs b/AmeisenBotX.Core/Logic/Idle/Actions/Utils/BasicIdleAction.cs index 1a42aa82..ca118744 100644 --- a/AmeisenBotX.Core/Logic/Idle/Actions/Utils/BasicIdleAction.cs +++ b/AmeisenBotX.Core/Logic/Idle/Actions/Utils/BasicIdleAction.cs @@ -35,10 +35,7 @@ public BasicIdleAction(List actions, string name = "") public virtual void Execute() { - if (SelectedAction != null) - { - SelectedAction.Execute(); - } + SelectedAction?.Execute(); } public override string ToString() diff --git a/AmeisenBotX.Core/Logic/Idle/IdleActionManager.cs b/AmeisenBotX.Core/Logic/Idle/IdleActionManager.cs index 6f32eca0..4e596c98 100644 --- a/AmeisenBotX.Core/Logic/Idle/IdleActionManager.cs +++ b/AmeisenBotX.Core/Logic/Idle/IdleActionManager.cs @@ -5,28 +5,19 @@ namespace AmeisenBotX.Core.Logic.Idle { - public class IdleActionManager + public class IdleActionManager(AmeisenBotConfig config, IEnumerable idleActions) { - public IdleActionManager(AmeisenBotConfig config, IEnumerable idleActions) - { - Config = config; - IdleActions = idleActions; - - Rnd = new(); - LastActions = []; - } - public TimeSpan Cooldown { get; private set; } public DateTime ExecuteUntil { get; private set; } - public IEnumerable IdleActions { get; set; } + public IEnumerable IdleActions { get; set; } = idleActions; public DateTime LastActionExecuted { get; private set; } - public List> LastActions { get; private set; } + public List> LastActions { get; private set; } = []; - private AmeisenBotConfig Config { get; } + private AmeisenBotConfig Config { get; } = config; private IIdleAction CurrentAction { get; set; } @@ -34,7 +25,7 @@ public IdleActionManager(AmeisenBotConfig config, IEnumerable idleA private int MinActionCooldown { get; } = 12 * 1000; - private Random Rnd { get; } + private Random Rnd { get; } = new(); public void Reset() { diff --git a/AmeisenBotX.Core/Logic/Leafs/MoveToLeaf.cs b/AmeisenBotX.Core/Logic/Leafs/MoveToLeaf.cs index bca3d81a..b780cfb4 100644 --- a/AmeisenBotX.Core/Logic/Leafs/MoveToLeaf.cs +++ b/AmeisenBotX.Core/Logic/Leafs/MoveToLeaf.cs @@ -6,23 +6,15 @@ namespace AmeisenBotX.Core.Logic.Leafs { - public class MoveToLeaf : INode + public class MoveToLeaf(AmeisenBotInterfaces bot, Func getUnit, INode child = null, float maxDistance = 3.2f) : INode { - public MoveToLeaf(AmeisenBotInterfaces bot, Func getUnit, INode child = null, float maxDistance = 3.2f) - { - Bot = bot; - GetUnit = getUnit; - Child = child; - MaxDistance = maxDistance; - } - - protected AmeisenBotInterfaces Bot { get; } + protected AmeisenBotInterfaces Bot { get; } = bot; - protected INode Child { get; set; } + protected INode Child { get; set; } = child; - protected Func GetUnit { get; } + protected Func GetUnit { get; } = getUnit; - protected float MaxDistance { get; } + protected float MaxDistance { get; } = maxDistance; protected bool NeedToStopMoving { get; set; } diff --git a/AmeisenBotX.Core/Logic/Leafs/SuccessLeaf.cs b/AmeisenBotX.Core/Logic/Leafs/SuccessLeaf.cs index bc040162..16a74007 100644 --- a/AmeisenBotX.Core/Logic/Leafs/SuccessLeaf.cs +++ b/AmeisenBotX.Core/Logic/Leafs/SuccessLeaf.cs @@ -4,14 +4,9 @@ namespace AmeisenBotX.Core.Logic.Leafs { - public class SuccessLeaf : INode + public class SuccessLeaf(Action action = null) : INode { - public SuccessLeaf(Action action = null) - { - Action = action; - } - - private Action Action { get; } + private Action Action { get; } = action; public BtStatus Execute() { diff --git a/AmeisenBotX.Core/Managers/Character/Comparators/ArmsItemComparator.cs b/AmeisenBotX.Core/Managers/Character/Comparators/ArmsItemComparator.cs index dbdc3aa0..a82a8f09 100644 --- a/AmeisenBotX.Core/Managers/Character/Comparators/ArmsItemComparator.cs +++ b/AmeisenBotX.Core/Managers/Character/Comparators/ArmsItemComparator.cs @@ -4,14 +4,9 @@ namespace AmeisenBotX.Core.Managers.Character.Comparators { - public class ArmsItemComparator : IItemComparator + public class ArmsItemComparator(AmeisenBotInterfaces bot) : IItemComparator { - private readonly AmeisenBotInterfaces Bot; - - public ArmsItemComparator(AmeisenBotInterfaces bot) - { - Bot = bot; - } + private readonly AmeisenBotInterfaces Bot = bot; public bool IsBetter(IWowInventoryItem current, IWowInventoryItem item) { diff --git a/AmeisenBotX.Core/Managers/Character/Comparators/FuryItemComparator.cs b/AmeisenBotX.Core/Managers/Character/Comparators/FuryItemComparator.cs index ccb36981..84364074 100644 --- a/AmeisenBotX.Core/Managers/Character/Comparators/FuryItemComparator.cs +++ b/AmeisenBotX.Core/Managers/Character/Comparators/FuryItemComparator.cs @@ -4,14 +4,9 @@ namespace AmeisenBotX.Core.Managers.Character.Comparators { - public class FuryItemComparator : IItemComparator + public class FuryItemComparator(AmeisenBotInterfaces bot) : IItemComparator { - public FuryItemComparator(AmeisenBotInterfaces bot) - { - Bot = bot; - } - - private AmeisenBotInterfaces Bot { get; } + private AmeisenBotInterfaces Bot { get; } = bot; public bool IsBetter(IWowInventoryItem current, IWowInventoryItem item) { diff --git a/AmeisenBotX.Core/Managers/Character/Comparators/Objects/GearscoreFactory.cs b/AmeisenBotX.Core/Managers/Character/Comparators/Objects/GearscoreFactory.cs index 55eff64d..809161a4 100644 --- a/AmeisenBotX.Core/Managers/Character/Comparators/Objects/GearscoreFactory.cs +++ b/AmeisenBotX.Core/Managers/Character/Comparators/Objects/GearscoreFactory.cs @@ -5,14 +5,9 @@ namespace AmeisenBotX.Core.Managers.Character.Comparators.Objects { - public class GearscoreFactory + public class GearscoreFactory(Dictionary statMultiplicators) { - public GearscoreFactory(Dictionary statMultiplicators) - { - StatMultiplicators = statMultiplicators; - } - - private Dictionary StatMultiplicators { get; } + private Dictionary StatMultiplicators { get; } = statMultiplicators; public double Calculate(IWowInventoryItem item) { diff --git a/AmeisenBotX.Core/Managers/Character/Comparators/SimpleItemComparator.cs b/AmeisenBotX.Core/Managers/Character/Comparators/SimpleItemComparator.cs index dfb0696f..57e97aff 100644 --- a/AmeisenBotX.Core/Managers/Character/Comparators/SimpleItemComparator.cs +++ b/AmeisenBotX.Core/Managers/Character/Comparators/SimpleItemComparator.cs @@ -4,18 +4,11 @@ namespace AmeisenBotX.Core.Managers.Character.Comparators { - public class SimpleItemComparator : IItemComparator + public class SimpleItemComparator(DefaultCharacterManager characterManager, Dictionary statPriorities) : IItemComparator { - public SimpleItemComparator(DefaultCharacterManager characterManager, Dictionary statPriorities) - { - // This introduces a cyclic dependency. Are we fine with that? - CharacterManager = characterManager; - GearscoreFactory = new(statPriorities); - } - - protected GearscoreFactory GearscoreFactory { get; set; } + protected GearscoreFactory GearscoreFactory { get; set; } = new(statPriorities); - private DefaultCharacterManager CharacterManager { get; } + private DefaultCharacterManager CharacterManager { get; } = characterManager; public bool IsBetter(IWowInventoryItem current, IWowInventoryItem item) { diff --git a/AmeisenBotX.Core/Managers/Character/Inventory/Objects/WowArmor.cs b/AmeisenBotX.Core/Managers/Character/Inventory/Objects/WowArmor.cs index bd5a35c6..d2788686 100644 --- a/AmeisenBotX.Core/Managers/Character/Inventory/Objects/WowArmor.cs +++ b/AmeisenBotX.Core/Managers/Character/Inventory/Objects/WowArmor.cs @@ -7,7 +7,7 @@ public class WowArmor : WowBasicItem { public WowArmor(IWowInventoryItem wowBasicItem) : base(wowBasicItem) { - if (Subtype.ToLowerInvariant().EndsWith("s")) + if (Subtype.ToLowerInvariant().EndsWith('s')) { Subtype = Subtype.Remove(Subtype.Length - 1); } diff --git a/AmeisenBotX.Core/Managers/Character/Inventory/Objects/WowConsumable.cs b/AmeisenBotX.Core/Managers/Character/Inventory/Objects/WowConsumable.cs index afc372e6..bdc4c052 100644 --- a/AmeisenBotX.Core/Managers/Character/Inventory/Objects/WowConsumable.cs +++ b/AmeisenBotX.Core/Managers/Character/Inventory/Objects/WowConsumable.cs @@ -1,9 +1,6 @@ namespace AmeisenBotX.Core.Managers.Character.Inventory.Objects { - public class WowConsumable : WowBasicItem + public class WowConsumable(IWowInventoryItem wowBasicItem) : WowBasicItem(wowBasicItem) { - public WowConsumable(IWowInventoryItem wowBasicItem) : base(wowBasicItem) - { - } } } \ No newline at end of file diff --git a/AmeisenBotX.Core/Managers/Character/Inventory/Objects/WowContainer.cs b/AmeisenBotX.Core/Managers/Character/Inventory/Objects/WowContainer.cs index cfef2bd8..0e04033a 100644 --- a/AmeisenBotX.Core/Managers/Character/Inventory/Objects/WowContainer.cs +++ b/AmeisenBotX.Core/Managers/Character/Inventory/Objects/WowContainer.cs @@ -1,9 +1,6 @@ namespace AmeisenBotX.Core.Managers.Character.Inventory.Objects { - public class WowContainer : WowBasicItem + public class WowContainer(IWowInventoryItem wowBasicItem) : WowBasicItem(wowBasicItem) { - public WowContainer(IWowInventoryItem wowBasicItem) : base(wowBasicItem) - { - } } } \ No newline at end of file diff --git a/AmeisenBotX.Core/Managers/Character/Inventory/Objects/WowGem.cs b/AmeisenBotX.Core/Managers/Character/Inventory/Objects/WowGem.cs index 531bd5b5..638d3f0b 100644 --- a/AmeisenBotX.Core/Managers/Character/Inventory/Objects/WowGem.cs +++ b/AmeisenBotX.Core/Managers/Character/Inventory/Objects/WowGem.cs @@ -1,9 +1,6 @@ namespace AmeisenBotX.Core.Managers.Character.Inventory.Objects { - public class WowGem : WowBasicItem + public class WowGem(IWowInventoryItem wowBasicItem) : WowBasicItem(wowBasicItem) { - public WowGem(IWowInventoryItem wowBasicItem) : base(wowBasicItem) - { - } } } \ No newline at end of file diff --git a/AmeisenBotX.Core/Managers/Character/Inventory/Objects/WowKey.cs b/AmeisenBotX.Core/Managers/Character/Inventory/Objects/WowKey.cs index 778a5bac..c1880fb5 100644 --- a/AmeisenBotX.Core/Managers/Character/Inventory/Objects/WowKey.cs +++ b/AmeisenBotX.Core/Managers/Character/Inventory/Objects/WowKey.cs @@ -1,9 +1,6 @@ namespace AmeisenBotX.Core.Managers.Character.Inventory.Objects { - public class WowKey : WowBasicItem + public class WowKey(IWowInventoryItem wowBasicItem) : WowBasicItem(wowBasicItem) { - public WowKey(IWowInventoryItem wowBasicItem) : base(wowBasicItem) - { - } } } \ No newline at end of file diff --git a/AmeisenBotX.Core/Managers/Character/Inventory/Objects/WowMiscellaneousItem.cs b/AmeisenBotX.Core/Managers/Character/Inventory/Objects/WowMiscellaneousItem.cs index d50a8673..4d233c44 100644 --- a/AmeisenBotX.Core/Managers/Character/Inventory/Objects/WowMiscellaneousItem.cs +++ b/AmeisenBotX.Core/Managers/Character/Inventory/Objects/WowMiscellaneousItem.cs @@ -1,9 +1,6 @@ namespace AmeisenBotX.Core.Managers.Character.Inventory.Objects { - public class WowMiscellaneousItem : WowBasicItem + public class WowMiscellaneousItem(IWowInventoryItem wowBasicItem) : WowBasicItem(wowBasicItem) { - public WowMiscellaneousItem(IWowInventoryItem wowBasicItem) : base(wowBasicItem) - { - } } } \ No newline at end of file diff --git a/AmeisenBotX.Core/Managers/Character/Inventory/Objects/WowMoneyItem.cs b/AmeisenBotX.Core/Managers/Character/Inventory/Objects/WowMoneyItem.cs index 3f976c18..001d28a0 100644 --- a/AmeisenBotX.Core/Managers/Character/Inventory/Objects/WowMoneyItem.cs +++ b/AmeisenBotX.Core/Managers/Character/Inventory/Objects/WowMoneyItem.cs @@ -1,9 +1,6 @@ namespace AmeisenBotX.Core.Managers.Character.Inventory.Objects { - public class WowMoneyItem : WowBasicItem + public class WowMoneyItem(IWowInventoryItem wowBasicItem) : WowBasicItem(wowBasicItem) { - public WowMoneyItem(IWowInventoryItem wowBasicItem) : base(wowBasicItem) - { - } } } \ No newline at end of file diff --git a/AmeisenBotX.Core/Managers/Character/Inventory/Objects/WowProjectile.cs b/AmeisenBotX.Core/Managers/Character/Inventory/Objects/WowProjectile.cs index 685ddad3..6d37a76a 100644 --- a/AmeisenBotX.Core/Managers/Character/Inventory/Objects/WowProjectile.cs +++ b/AmeisenBotX.Core/Managers/Character/Inventory/Objects/WowProjectile.cs @@ -1,9 +1,6 @@ namespace AmeisenBotX.Core.Managers.Character.Inventory.Objects { - public class WowProjectile : WowBasicItem + public class WowProjectile(IWowInventoryItem wowBasicItem) : WowBasicItem(wowBasicItem) { - public WowProjectile(IWowInventoryItem wowBasicItem) : base(wowBasicItem) - { - } } } \ No newline at end of file diff --git a/AmeisenBotX.Core/Managers/Character/Inventory/Objects/WowQuestItem.cs b/AmeisenBotX.Core/Managers/Character/Inventory/Objects/WowQuestItem.cs index f76f195e..8ab1135c 100644 --- a/AmeisenBotX.Core/Managers/Character/Inventory/Objects/WowQuestItem.cs +++ b/AmeisenBotX.Core/Managers/Character/Inventory/Objects/WowQuestItem.cs @@ -1,9 +1,6 @@ namespace AmeisenBotX.Core.Managers.Character.Inventory.Objects { - public class WowQuestItem : WowBasicItem + public class WowQuestItem(IWowInventoryItem wowBasicItem) : WowBasicItem(wowBasicItem) { - public WowQuestItem(IWowInventoryItem wowBasicItem) : base(wowBasicItem) - { - } } } \ No newline at end of file diff --git a/AmeisenBotX.Core/Managers/Character/Inventory/Objects/WowQuiver.cs b/AmeisenBotX.Core/Managers/Character/Inventory/Objects/WowQuiver.cs index 94270f1d..2ff28cd0 100644 --- a/AmeisenBotX.Core/Managers/Character/Inventory/Objects/WowQuiver.cs +++ b/AmeisenBotX.Core/Managers/Character/Inventory/Objects/WowQuiver.cs @@ -1,9 +1,6 @@ namespace AmeisenBotX.Core.Managers.Character.Inventory.Objects { - public class WowQuiver : WowBasicItem + public class WowQuiver(IWowInventoryItem wowBasicItem) : WowBasicItem(wowBasicItem) { - public WowQuiver(IWowInventoryItem wowBasicItem) : base(wowBasicItem) - { - } } } \ No newline at end of file diff --git a/AmeisenBotX.Core/Managers/Character/Inventory/Objects/WowReagent.cs b/AmeisenBotX.Core/Managers/Character/Inventory/Objects/WowReagent.cs index e1126eff..7d8bbfda 100644 --- a/AmeisenBotX.Core/Managers/Character/Inventory/Objects/WowReagent.cs +++ b/AmeisenBotX.Core/Managers/Character/Inventory/Objects/WowReagent.cs @@ -1,9 +1,6 @@ namespace AmeisenBotX.Core.Managers.Character.Inventory.Objects { - public class WowReagent : WowBasicItem + public class WowReagent(IWowInventoryItem wowBasicItem) : WowBasicItem(wowBasicItem) { - public WowReagent(IWowInventoryItem wowBasicItem) : base(wowBasicItem) - { - } } } \ No newline at end of file diff --git a/AmeisenBotX.Core/Managers/Character/Inventory/Objects/WowRecipe.cs b/AmeisenBotX.Core/Managers/Character/Inventory/Objects/WowRecipe.cs index 379b5d39..33a4e304 100644 --- a/AmeisenBotX.Core/Managers/Character/Inventory/Objects/WowRecipe.cs +++ b/AmeisenBotX.Core/Managers/Character/Inventory/Objects/WowRecipe.cs @@ -1,9 +1,6 @@ namespace AmeisenBotX.Core.Managers.Character.Inventory.Objects { - public class WowRecipe : WowBasicItem + public class WowRecipe(IWowInventoryItem wowBasicItem) : WowBasicItem(wowBasicItem) { - public WowRecipe(IWowInventoryItem wowBasicItem) : base(wowBasicItem) - { - } } } \ No newline at end of file diff --git a/AmeisenBotX.Core/Managers/Character/Inventory/Objects/WowTradeGoods.cs b/AmeisenBotX.Core/Managers/Character/Inventory/Objects/WowTradeGoods.cs index 461c6fa8..1035a68f 100644 --- a/AmeisenBotX.Core/Managers/Character/Inventory/Objects/WowTradeGoods.cs +++ b/AmeisenBotX.Core/Managers/Character/Inventory/Objects/WowTradeGoods.cs @@ -1,9 +1,6 @@ namespace AmeisenBotX.Core.Managers.Character.Inventory.Objects { - public class WowTradeGoods : WowBasicItem + public class WowTradeGoods(IWowInventoryItem wowBasicItem) : WowBasicItem(wowBasicItem) { - public WowTradeGoods(IWowInventoryItem wowBasicItem) : base(wowBasicItem) - { - } } } \ No newline at end of file diff --git a/AmeisenBotX.Core/Managers/Character/Spells/SpellBook.cs b/AmeisenBotX.Core/Managers/Character/Spells/SpellBook.cs index 4faff408..148f0336 100644 --- a/AmeisenBotX.Core/Managers/Character/Spells/SpellBook.cs +++ b/AmeisenBotX.Core/Managers/Character/Spells/SpellBook.cs @@ -10,12 +10,13 @@ namespace AmeisenBotX.Core.Managers.Character.Spells { - public class SpellBook + public class SpellBook(IWowInterface wowInterface) { - public SpellBook(IWowInterface wowInterface) + private static readonly JsonSerializerOptions Options = new() { - Wow = wowInterface; - } + AllowTrailingCommas = true, + NumberHandling = JsonNumberHandling.AllowReadingFromString + }; public delegate void SpellBookUpdate(); @@ -23,7 +24,7 @@ public SpellBook(IWowInterface wowInterface) public IEnumerable Spells { get; private set; } - private IWowInterface Wow { get; } + private IWowInterface Wow { get; } = wowInterface; public Spell GetSpellByName(string spellname) { @@ -40,14 +41,13 @@ public bool TryGetSpellByName(string spellname, out Spell spell) spell = GetSpellByName(spellname); return spell != null; } - public void Update() { string rawSpells = Wow.GetSpells(); try { - Spells = JsonSerializer.Deserialize>(rawSpells, new JsonSerializerOptions() { AllowTrailingCommas = true, NumberHandling = JsonNumberHandling.AllowReadingFromString }) + Spells = JsonSerializer.Deserialize>(rawSpells, Options) .OrderBy(e => e.Name) .ThenByDescending(e => e.Rank); diff --git a/AmeisenBotX.Core/Managers/Character/Talents/TalentManager.cs b/AmeisenBotX.Core/Managers/Character/Talents/TalentManager.cs index 8b7fce7f..31aa14aa 100644 --- a/AmeisenBotX.Core/Managers/Character/Talents/TalentManager.cs +++ b/AmeisenBotX.Core/Managers/Character/Talents/TalentManager.cs @@ -7,16 +7,11 @@ namespace AmeisenBotX.Core.Managers.Character.Talents { - public class TalentManager + public class TalentManager(IWowInterface wowInterface) { - public TalentManager(IWowInterface wowInterface) - { - Wow = wowInterface; - } - public TalentTree TalentTree { get; set; } - private IWowInterface Wow { get; } + private IWowInterface Wow { get; } = wowInterface; public void SelectTalents(TalentTree wantedTalents, int talentPoints) { @@ -34,7 +29,7 @@ public void SelectTalents(TalentTree wantedTalents, int talentPoints) } } - if (talentsToSpend.Any()) + if (talentsToSpend.Count != 0) { SpendTalents(talentsToSpend); } @@ -56,7 +51,7 @@ private static bool CheckTalentTree(ref int talentPoints, int treeId, Dictionary bool result = false; - Talent[] wantedTreeValues = wantedTree.Values.ToArray(); + Talent[] wantedTreeValues = [.. wantedTree.Values]; foreach (Talent talent in wantedTreeValues) { @@ -64,13 +59,13 @@ private static bool CheckTalentTree(ref int talentPoints, int treeId, Dictionary Talent wantedTalent = talent; - if (tree.ContainsKey(wantedTalent.Num)) + if (tree.TryGetValue(wantedTalent.Num, out Talent value)) { - int wantedRank = Math.Min(wantedTalent.Rank, tree[wantedTalent.Num].MaxRank); + int wantedRank = Math.Min(wantedTalent.Rank, value.MaxRank); - if (tree[wantedTalent.Num].Rank < wantedRank) + if (value.Rank < wantedRank) { - int amount = Math.Min(talentPoints, wantedRank - tree[wantedTalent.Num].Rank); + int amount = Math.Min(talentPoints, wantedRank - value.Rank); talentsToSpend.Add((treeId, wantedTalent.Num, amount)); diff --git a/AmeisenBotX.Core/Managers/Chat/DefaultChatManager.cs b/AmeisenBotX.Core/Managers/Chat/DefaultChatManager.cs index f4bf0124..9921c2e7 100644 --- a/AmeisenBotX.Core/Managers/Chat/DefaultChatManager.cs +++ b/AmeisenBotX.Core/Managers/Chat/DefaultChatManager.cs @@ -7,22 +7,15 @@ namespace AmeisenBotX.Core.Managers.Chat { - public class DefaultChatManager : IChatManager + public class DefaultChatManager(AmeisenBotConfig config, string dataPath) : IChatManager { - public DefaultChatManager(AmeisenBotConfig config, string dataPath) - { - Config = config; - DataPath = dataPath; - ChatMessages = []; - } - public event Action OnNewChatMessage; - public List ChatMessages { get; } + public List ChatMessages { get; } = []; - private AmeisenBotConfig Config { get; } + private AmeisenBotConfig Config { get; } = config; - private string DataPath { get; } + private string DataPath { get; } = dataPath; public string ProtocolName(string type) { diff --git a/AmeisenBotX.Core/Managers/Threat/ThreatManager.cs b/AmeisenBotX.Core/Managers/Threat/ThreatManager.cs index 7e5f6d3b..037c8c0b 100644 --- a/AmeisenBotX.Core/Managers/Threat/ThreatManager.cs +++ b/AmeisenBotX.Core/Managers/Threat/ThreatManager.cs @@ -10,17 +10,11 @@ namespace AmeisenBotX.Core.Managers.Threat /// /// Manager to observe environmental threats (not threat of mobs) /// - public class ThreatManager + public class ThreatManager(AmeisenBotInterfaces bot, AmeisenBotConfig config) { - public ThreatManager(AmeisenBotInterfaces bot, AmeisenBotConfig config) - { - Bot = bot; - Config = config; - } - - private AmeisenBotInterfaces Bot { get; } + private AmeisenBotInterfaces Bot { get; } = bot; - private AmeisenBotConfig Config { get; } + private AmeisenBotConfig Config { get; } = config; /// /// This method tries to calculate how dangerous a position is for us. @@ -48,7 +42,7 @@ public float Get(Vector3 position) if (hostilePlayers.Any()) { - foreach (IWowPlayer player in hostilePlayers) + foreach (IWowPlayer player in hostilePlayers.Cast()) { float leveldiffMult = MathF.Max(0.0f, MathF.Tanh(player.Level - Bot.Player.Level)); diff --git a/AmeisenBotX.Core/Objects/InteractableObject.cs b/AmeisenBotX.Core/Objects/InteractableObject.cs index 3399c56a..cf66be77 100644 --- a/AmeisenBotX.Core/Objects/InteractableObject.cs +++ b/AmeisenBotX.Core/Objects/InteractableObject.cs @@ -4,24 +4,13 @@ namespace AmeisenBotX.Core.Objects { - public class InteractableObject + public class InteractableObject(int entryId, WowMapId mapId, WowZoneId zoneId, Vector3 position, InteractableObjectType objectType, MailboxFactionType factionType = MailboxFactionType.None) { - public readonly MailboxFactionType FactionType; - public readonly InteractableObjectType ObjectType; - public int EntryId; - public WowMapId MapId; - public Vector3 Position; - public WowZoneId ZoneId; - - public InteractableObject(int entryId, WowMapId mapId, WowZoneId zoneId, Vector3 position, - InteractableObjectType objectType, MailboxFactionType factionType = MailboxFactionType.None) - { - EntryId = entryId; - MapId = mapId; - ZoneId = zoneId; - Position = position; - ObjectType = objectType; - FactionType = factionType; - } + public readonly MailboxFactionType FactionType = factionType; + public readonly InteractableObjectType ObjectType = objectType; + public int EntryId = entryId; + public WowMapId MapId = mapId; + public Vector3 Position = position; + public WowZoneId ZoneId = zoneId; } } \ No newline at end of file diff --git a/AmeisenBotX.Core/Objects/Npc.cs b/AmeisenBotX.Core/Objects/Npc.cs index 944b5b44..6d9deb3c 100644 --- a/AmeisenBotX.Core/Objects/Npc.cs +++ b/AmeisenBotX.Core/Objects/Npc.cs @@ -4,26 +4,14 @@ namespace AmeisenBotX.Core.Objects { - public class Npc + public class Npc(string name, int entryId, WowMapId mapId, WowZoneId zoneId, Vector3 position, NpcType type, NpcSubType subType = NpcSubType.None) { - public readonly int EntryId; - public readonly NpcSubType SubType; - public readonly NpcType Type; - public WowMapId MapId; - public string Name; - public Vector3 Position; - public WowZoneId ZoneId; - - public Npc(string name, int entryId, WowMapId mapId, WowZoneId zoneId, Vector3 position, - NpcType type, NpcSubType subType = NpcSubType.None) - { - Name = name; - EntryId = entryId; - MapId = mapId; - ZoneId = zoneId; - Position = position; - Type = type; - SubType = subType; - } + public readonly int EntryId = entryId; + public readonly NpcSubType SubType = subType; + public readonly NpcType Type = type; + public WowMapId MapId = mapId; + public string Name = name; + public Vector3 Position = position; + public WowZoneId ZoneId = zoneId; } } \ No newline at end of file diff --git a/AmeisenBotX.Logging/AmeisenLogger.cs b/AmeisenBotX.Logging/AmeisenLogger.cs index fb58a60d..d5b43e0b 100644 --- a/AmeisenBotX.Logging/AmeisenLogger.cs +++ b/AmeisenBotX.Logging/AmeisenLogger.cs @@ -117,8 +117,8 @@ public void Stop() { if (Enabled) { - Enabled = false; LogFileWriterTick(); + Enabled = false; } } diff --git a/AmeisenBotX.Memory/Structs/AllocationPool.cs b/AmeisenBotX.Memory/Structs/AllocationPool.cs index 9cdf5ac2..fc431f9c 100644 --- a/AmeisenBotX.Memory/Structs/AllocationPool.cs +++ b/AmeisenBotX.Memory/Structs/AllocationPool.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; namespace AmeisenBotX.Memory.Structs diff --git a/AmeisenBotX.Memory/Structs/FasmStateOk.cs b/AmeisenBotX.Memory/Structs/FasmStateOk.cs index 0b70a071..b5ba4236 100644 --- a/AmeisenBotX.Memory/Structs/FasmStateOk.cs +++ b/AmeisenBotX.Memory/Structs/FasmStateOk.cs @@ -1,5 +1,4 @@ -using System; -using System.Runtime.InteropServices; +using System.Runtime.InteropServices; namespace AmeisenBotX.Memory.Structs { diff --git a/AmeisenBotX.Memory/Win32/Margins.cs b/AmeisenBotX.Memory/Win32/Margins.cs index d3767fc5..ae4d413c 100644 --- a/AmeisenBotX.Memory/Win32/Margins.cs +++ b/AmeisenBotX.Memory/Win32/Margins.cs @@ -13,7 +13,7 @@ public struct Margins public int Bottom { get; set; } - public override bool Equals(object obj) + public override readonly bool Equals(object obj) { return obj != null && obj.GetType() == typeof(Margins) @@ -23,7 +23,7 @@ public override bool Equals(object obj) && ((Margins)obj).Bottom == Bottom; } - public override int GetHashCode() + public override readonly int GetHashCode() { unchecked { diff --git a/AmeisenBotX.Memory/Win32/Rect.cs b/AmeisenBotX.Memory/Win32/Rect.cs index 00aee7a9..cb13e5d0 100644 --- a/AmeisenBotX.Memory/Win32/Rect.cs +++ b/AmeisenBotX.Memory/Win32/Rect.cs @@ -23,16 +23,16 @@ public struct Rect return left.Equals(right); } - public override bool Equals(object obj) + public override readonly bool Equals(object obj) { return obj.GetType() == typeof(Rect) - && ((Rect)obj).Left == Left - && ((Rect)obj).Top == Top - && ((Rect)obj).Right == Right - && ((Rect)obj).Bottom == Bottom; + && ((Rect)obj).Left == Left + && ((Rect)obj).Top == Top + && ((Rect)obj).Right == Right + && ((Rect)obj).Bottom == Bottom; } - public override int GetHashCode() + public override readonly int GetHashCode() { unchecked { @@ -40,7 +40,7 @@ public override int GetHashCode() } } - public override string ToString() + public override readonly string ToString() { return $"Left: {Left} Top: {Top} Right: {Right} Bottom: {Bottom}"; } diff --git a/AmeisenBotX.Memory/Win32/Win32Imports.cs b/AmeisenBotX.Memory/Win32/Win32Imports.cs index bb4cd582..30e9d5ed 100644 --- a/AmeisenBotX.Memory/Win32/Win32Imports.cs +++ b/AmeisenBotX.Memory/Win32/Win32Imports.cs @@ -121,7 +121,9 @@ public enum WindowStyle : uint WS_SIZEBOX = WS_THICKFRAME, WS_TILEDWINDOW = WS_OVERLAPPEDWINDOW, +#pragma warning disable CA1069 WS_OVERLAPPEDWINDOW = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX, +#pragma warning restore CA1069 WS_POPUPWINDOW = WS_POPUP | WS_BORDER | WS_SYSMENU, WS_CHILDWINDOW = WS_CHILD, @@ -136,7 +138,7 @@ public enum WindowStyle : uint [return: MarshalAs(UnmanagedType.Bool)] public static partial bool GetWindowRect(nint windowHandle, ref Rect rectangle); - [LibraryImport("ntdll", SetLastError = true)] + [LibraryImport("ntdll")] public static partial int NtOpenProcess ( out nint ProcessHandle, @@ -272,6 +274,7 @@ public struct ObjectAttributes public nint SecurityDescriptor; public nint SecurityQualityOfService; } + [StructLayout(LayoutKind.Sequential)] public struct ProcessInformation { diff --git a/AmeisenBotX.Memory/XMemory.cs b/AmeisenBotX.Memory/XMemory.cs index e31dc6ea..81804d2f 100644 --- a/AmeisenBotX.Memory/XMemory.cs +++ b/AmeisenBotX.Memory/XMemory.cs @@ -13,7 +13,7 @@ namespace AmeisenBotX.Memory { - public unsafe class XMemory : IMemoryApi + public unsafe partial class XMemory : IMemoryApi { // FASM configuration, if you encounter fasm error, try to increase the values private const int FASM_MEMORY_SIZE = 8192; @@ -123,8 +123,8 @@ public bool AllocateMemory(uint size, out nint address) public void Dispose() { GC.SuppressFinalize(this); - NtClose(MainThreadHandle); - NtClose(ProcessHandle); + _ = NtClose(MainThreadHandle); + _ = NtClose(ProcessHandle); FreeAllMemory(); } @@ -229,6 +229,7 @@ public Rect GetWindowPosition() return rect; } + /// public virtual bool Init(Process process, nint processHandle, nint mainThreadHandle) { @@ -344,6 +345,7 @@ public bool ProtectMemory(nint address, uint size, MemoryProtectionFlag memoryPr nint s = new(size); return NtProtectVirtualMemory(ProcessHandle, ref address, ref s, memoryProtection, out oldMemoryProtection) == 0; } + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool Read(nint address, out T value) where T : unmanaged @@ -471,7 +473,7 @@ public void SetupAutoPosition(nint mainWindowHandle, int offsetX, int offsetY, i int style = GetWindowLong(Process.MainWindowHandle, GWL_STYLE); style &= ~(int)WindowStyle.WS_CAPTION & ~(int)WindowStyle.WS_THICKFRAME & ~(int)WindowStyle.WS_BORDER; - SetWindowLong(Process.MainWindowHandle, GWL_STYLE, style); + _ = SetWindowLong(Process.MainWindowHandle, GWL_STYLE, style); ResizeParentWindow(offsetX, offsetY, width, height); } @@ -572,15 +574,17 @@ public bool ZeroMemory(nint address, int size) /// FASM pass limit /// FASM display pipe /// FASM status struct pointer - [DllImport("FASM.dll", EntryPoint = "fasm_Assemble", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] - private static extern int FasmAssemble(string szSource, byte* lpMemory, int nSize, int nPassesLimit, nint hDisplayPipe); + [LibraryImport("FASM.dll", EntryPoint = "fasm_Assemble", StringMarshalling = StringMarshalling.Utf8)] + [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvStdcall) })] + private static partial int FasmAssemble(string szSource, byte* lpMemory, int nSize, int nPassesLimit, nint hDisplayPipe); /// /// Get FASM assembler version. /// /// Version - [DllImport("FASM.dll", EntryPoint = "fasm_GetVersion", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)] - private static extern int FasmGetVersion(); + [LibraryImport("FASM.dll", EntryPoint = "fasm_GetVersion")] + [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvStdcall) })] + private static partial int FasmGetVersion(); /// /// Gateway function to monitor ReadProcessMemory calls. diff --git a/AmeisenBotX.RconClient/AmeisenBotRconClient.cs b/AmeisenBotX.RconClient/AmeisenBotRconClient.cs index 4f9e48bb..c7566d7e 100644 --- a/AmeisenBotX.RconClient/AmeisenBotRconClient.cs +++ b/AmeisenBotX.RconClient/AmeisenBotRconClient.cs @@ -11,6 +11,12 @@ namespace AmeisenBotX.RconClient { public class AmeisenBotRconClient { + public static readonly JsonSerializerOptions Options = new() + { + AllowTrailingCommas = true, + NumberHandling = JsonNumberHandling.AllowReadingFromString + }; + public AmeisenBotRconClient(string endpoint, string name, string wowRace, string wowGender, string wowClass, string wowRole, string image = "", string guid = "", bool validateCertificate = false) { Endpoint = endpoint; @@ -94,7 +100,7 @@ public bool PullPendingActions() if (dataResponse.IsSuccessStatusCode) { - PendingActions = JsonSerializer.Deserialize>(dataResponse.Content.ReadAsStringAsync().Result, new JsonSerializerOptions() { AllowTrailingCommas = true, NumberHandling = JsonNumberHandling.AllowReadingFromString }); + PendingActions = JsonSerializer.Deserialize>(dataResponse.Content.ReadAsStringAsync().Result, Options); return true; } else diff --git a/AmeisenBotX.Test/BotUtilsTests.cs b/AmeisenBotX.Test/BotUtilsTests.cs index 93f57fc2..479fe79d 100644 --- a/AmeisenBotX.Test/BotUtilsTests.cs +++ b/AmeisenBotX.Test/BotUtilsTests.cs @@ -26,7 +26,7 @@ public void BigValueToStringTest() [TestMethod] public void ByteArrayToStringTest() { - byte[] bytes = new byte[] { 0x0, 0x35, 0xff }; + byte[] bytes = [0x0, 0x35, 0xff]; string s = BotUtils.ByteArrayToString(bytes); Assert.AreEqual("00 35 FF", s); } diff --git a/AmeisenBotX.Test/Vector3Tests.cs b/AmeisenBotX.Test/Vector3Tests.cs index 9e2caec6..464755c3 100644 --- a/AmeisenBotX.Test/Vector3Tests.cs +++ b/AmeisenBotX.Test/Vector3Tests.cs @@ -178,14 +178,14 @@ public void Vector3MiscTest() Assert.Fail(); } - float[] x = new float[] { 2f, 1f, 2000f }; + float[] x = [2f, 1f, 2000f]; float[] y = a.ToArray(); Assert.AreEqual(x[0], y[0]); Assert.AreEqual(x[1], y[1]); Assert.AreEqual(x[2], y[2]); - Assert.AreEqual(a, Vector3.FromArray(y)); + Assert.AreEqual(a, new(y)); Vector3 c = new(a); diff --git a/AmeisenBotX.Wow/Combatlog/Objects/BasicCombatLogEntry.cs b/AmeisenBotX.Wow/Combatlog/Objects/BasicCombatLogEntry.cs index 278b0f9f..9589ea41 100644 --- a/AmeisenBotX.Wow/Combatlog/Objects/BasicCombatLogEntry.cs +++ b/AmeisenBotX.Wow/Combatlog/Objects/BasicCombatLogEntry.cs @@ -51,7 +51,7 @@ public static bool TryParse(ICombatlogFields fields, List eventArgs, out string[] splitted = eventArgs[fields.Type] .Replace("SPELL_BUILDING", "SPELLBUILDING") .Replace("SPELL_PERIODIC", "SPELLPERIODIC") - .Split(new char[] { '_' }, 2); + .Split(['_'], 2); if (splitted.Length < 2) { diff --git a/AmeisenBotX.Wow/Hook/GenericEndSceneHook.cs b/AmeisenBotX.Wow/Hook/GenericEndSceneHook.cs index 1ed563ee..791236f5 100644 --- a/AmeisenBotX.Wow/Hook/GenericEndSceneHook.cs +++ b/AmeisenBotX.Wow/Hook/GenericEndSceneHook.cs @@ -13,7 +13,7 @@ namespace AmeisenBotX.Wow.Hook { - public class GenericEndSceneHook + public class GenericEndSceneHook(WowMemoryApi memory) { private const int MEM_ALLOC_EXECUTION_SIZE = 4096; private const int MEM_ALLOC_GATEWAY_SIZE = 24; @@ -22,11 +22,6 @@ public class GenericEndSceneHook private int hookCalls; - public GenericEndSceneHook(WowMemoryApi memory) - { - Memory = memory; - } - public event Action OnGameInfoPush; public int HookCallCount @@ -44,7 +39,7 @@ public int HookCallCount public bool IsWoWHooked => WowEndSceneAddress != nint.Zero && Memory.Read(WowEndSceneAddress, out byte c) && c == 0xE9; - protected WowMemoryApi Memory { get; } + protected WowMemoryApi Memory { get; } = memory; /// /// Codecave that hold the code, the bot want's to execute. @@ -225,7 +220,7 @@ public bool Hook(int hookSize, List hookModules) { if (!module.Inject()) { - AmeisenLogger.I.Log("HookManager", $"Failed to inject {nameof(module)} module", LogLevel.Error); + AmeisenLogger.I.Log("HookManager", $"Failed to inject {module.GetType().FullName}", LogLevel.Error); return false; } } diff --git a/AmeisenBotX.Wow/Hook/Modules/RunAsmHookModule.cs b/AmeisenBotX.Wow/Hook/Modules/RunAsmHookModule.cs index af88fb48..7013da45 100644 --- a/AmeisenBotX.Wow/Hook/Modules/RunAsmHookModule.cs +++ b/AmeisenBotX.Wow/Hook/Modules/RunAsmHookModule.cs @@ -3,16 +3,8 @@ namespace AmeisenBotX.Wow.Hook.Modules { - public abstract class RunAsmHookModule : IHookModule + public abstract class RunAsmHookModule(Action onUpdate, Action tick, WowMemoryApi memory, uint allocSize) : IHookModule { - public RunAsmHookModule(Action onUpdate, Action tick, WowMemoryApi memory, uint allocSize) - { - Memory = memory; - AllocSize = allocSize; - OnDataUpdate = onUpdate; - Tick = tick; - } - ~RunAsmHookModule() { if (AsmAddress != nint.Zero) { Memory.FreeMemory(AsmAddress); } @@ -20,13 +12,13 @@ public RunAsmHookModule(Action onUpdate, Action tick, WowMemo public nint AsmAddress { get; set; } - public Action OnDataUpdate { get; set; } + public Action OnDataUpdate { get; set; } = onUpdate; - public Action Tick { get; set; } + public Action Tick { get; set; } = tick; - protected uint AllocSize { get; } + protected uint AllocSize { get; } = allocSize; - protected WowMemoryApi Memory { get; } + protected WowMemoryApi Memory { get; } = memory; public abstract nint GetDataPointer(); @@ -38,10 +30,8 @@ public virtual bool Inject() AsmAddress = address; return Memory.InjectAssembly(assembly, address); } - else - { - return false; - } + + return false; } protected abstract bool PrepareAsm(out IEnumerable assembly); diff --git a/AmeisenBotX.Wow/Hook/Modules/RunLuaHookModule.cs b/AmeisenBotX.Wow/Hook/Modules/RunLuaHookModule.cs index b3f74cdc..9b35b9d2 100644 --- a/AmeisenBotX.Wow/Hook/Modules/RunLuaHookModule.cs +++ b/AmeisenBotX.Wow/Hook/Modules/RunLuaHookModule.cs @@ -4,14 +4,8 @@ namespace AmeisenBotX.Wow.Hook.Modules { - public class RunLuaHookModule : RunAsmHookModule + public class RunLuaHookModule(Action onUpdate, Action tick, WowMemoryApi memory, string lua, string varName, uint allocSize = 128) : RunAsmHookModule(onUpdate, tick, memory, allocSize) { - public RunLuaHookModule(Action onUpdate, Action tick, WowMemoryApi memory, string lua, string varName, uint allocSize = 128) : base(onUpdate, tick, memory, allocSize) - { - Lua = lua; - VarName = varName; - } - ~RunLuaHookModule() { if (ReturnAddress != nint.Zero) { Memory.FreeMemory(ReturnAddress); } @@ -23,9 +17,9 @@ public RunLuaHookModule(Action onUpdate, Action tick, WowMemo public nint VarAddress { get; private set; } - private string Lua { get; } + private string Lua { get; } = lua; - private string VarName { get; } + private string VarName { get; } = varName; public override nint GetDataPointer() { @@ -48,8 +42,8 @@ protected override bool PrepareAsm(out IEnumerable assembly) Memory.WriteBytes(CommandAddress, luaBytes); Memory.WriteBytes(VarAddress, luaVarBytes); - assembly = new List() - { + assembly = + [ "X:", "PUSH 0", $"PUSH {CommandAddress}", @@ -63,12 +57,12 @@ protected override bool PrepareAsm(out IEnumerable assembly) $"CALL {Memory.Offsets.FunctionGetLocalizedText}", $"MOV DWORD [{ReturnAddress}], EAX", $"RET" - }; + ]; return true; } - assembly = Array.Empty(); + assembly = []; return false; } } diff --git a/AmeisenBotX.Wow/Hook/Modules/TracelineJumpHookModule.cs b/AmeisenBotX.Wow/Hook/Modules/TracelineJumpHookModule.cs index 06817b49..c9b62a50 100644 --- a/AmeisenBotX.Wow/Hook/Modules/TracelineJumpHookModule.cs +++ b/AmeisenBotX.Wow/Hook/Modules/TracelineJumpHookModule.cs @@ -4,12 +4,8 @@ namespace AmeisenBotX.Wow.Hook.Modules { - public class TracelineJumpHookModule : RunAsmHookModule + public class TracelineJumpHookModule(Action onUpdate, Action tick, WowMemoryApi memory) : RunAsmHookModule(onUpdate, tick, memory, 256) { - public TracelineJumpHookModule(Action onUpdate, Action tick, WowMemoryApi memory) : base(onUpdate, tick, memory, 256) - { - } - ~TracelineJumpHookModule() { if (ExecuteAddress != nint.Zero) { Memory.FreeMemory(ExecuteAddress); } diff --git a/AmeisenBotX.Wow/Objects/ObjectManager.cs b/AmeisenBotX.Wow/Objects/ObjectManager.cs index 63e305d5..84958a69 100644 --- a/AmeisenBotX.Wow/Objects/ObjectManager.cs +++ b/AmeisenBotX.Wow/Objects/ObjectManager.cs @@ -11,7 +11,7 @@ namespace AmeisenBotX.Wow.Objects { - public abstract class ObjectManager : IObjectProvider + public abstract class ObjectManager(WowMemoryApi memory) : IObjectProvider where TObject : IWowObject, new() where TUnit : IWowUnit, new() where TPlayer : IWowPlayer, new() @@ -26,21 +26,8 @@ public abstract class ObjectManager(); - PartyPetGuids = new List(); - Partymembers = new List(); - PartyPets = new List(); - } + protected readonly nint[] wowObjectPointers = new nint[MAX_OBJECT_COUNT]; + protected readonly IWowObject[] wowObjects = new IWowObject[MAX_OBJECT_COUNT]; /// public event Action> OnObjectUpdateComplete; @@ -82,16 +69,16 @@ public ObjectManager(WowMemoryApi memory) public ulong PartyleaderGuid { get; protected set; } /// - public IEnumerable PartymemberGuids { get; protected set; } + public IEnumerable PartymemberGuids { get; protected set; } = new List(); /// - public IEnumerable Partymembers { get; protected set; } + public IEnumerable Partymembers { get; protected set; } = new List(); /// - public IEnumerable PartyPetGuids { get; protected set; } + public IEnumerable PartyPetGuids { get; protected set; } = new List(); /// - public IEnumerable PartyPets { get; protected set; } + public IEnumerable PartyPets { get; protected set; } = new List(); /// public IWowUnit Pet { get; protected set; } @@ -126,7 +113,7 @@ public ObjectManager(WowMemoryApi memory) /// public string ZoneSubName { get; protected set; } - protected WowMemoryApi Memory { get; } + protected WowMemoryApi Memory { get; } = memory; protected bool PlayerGuidIsVehicle { get; set; } diff --git a/AmeisenBotX.Wow/WowMemoryApi.cs b/AmeisenBotX.Wow/WowMemoryApi.cs index d4257f30..ee7f1531 100644 --- a/AmeisenBotX.Wow/WowMemoryApi.cs +++ b/AmeisenBotX.Wow/WowMemoryApi.cs @@ -3,14 +3,8 @@ namespace AmeisenBotX.Wow { - public class WowMemoryApi : XMemory + public class WowMemoryApi(IOffsetList offsets) : XMemory() { - public WowMemoryApi(IOffsetList offsets) - : base() - { - Offsets = offsets; - } - - public IOffsetList Offsets { get; } + public IOffsetList Offsets { get; } = offsets; } } \ No newline at end of file diff --git a/AmeisenBotX.Wow335a/Hook/EndSceneHook335a.cs b/AmeisenBotX.Wow335a/Hook/EndSceneHook335a.cs index fcf5f043..5f54d252 100644 --- a/AmeisenBotX.Wow335a/Hook/EndSceneHook335a.cs +++ b/AmeisenBotX.Wow335a/Hook/EndSceneHook335a.cs @@ -13,14 +13,8 @@ namespace AmeisenBotX.Wow335a.Hook { - public class EndSceneHook335a : GenericEndSceneHook + public class EndSceneHook335a(WowMemoryApi memory) : GenericEndSceneHook(memory) { - public EndSceneHook335a(WowMemoryApi memory) - : base(memory) - { - OriginalFunctionBytes = []; - } - /// /// Used to save the old render flags of wow. /// @@ -29,7 +23,7 @@ public EndSceneHook335a(WowMemoryApi memory) /// /// Used to save the original instruction when a function get disabled. /// - private Dictionary OriginalFunctionBytes { get; } + private Dictionary OriginalFunctionBytes { get; } = []; [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool CallObjectFunction(nint objectBaseAddress, nint functionAddress, List args = null) @@ -212,8 +206,8 @@ public bool TraceLine(Vector3 start, Vector3 end, uint flags) if (Memory.Write(distancePointer, tracelineCombo)) { - string[] asm = new string[] - { + string[] asm = + [ "PUSH 0", $"PUSH {flags}", $"PUSH {distancePointer}", @@ -223,7 +217,7 @@ public bool TraceLine(Vector3 start, Vector3 end, uint flags) $"CALL {Memory.Offsets.FunctionTraceline}", "ADD ESP, 0x18", "RET", - }; + ]; if (InjectAndExecute(asm, true, out nint returnAddress)) { @@ -316,8 +310,8 @@ public bool ExecuteLuaAndRead(string command, string variable, out string result Memory.WriteBytes(memAllocCmdVar, bytesToWrite); - string[] asm = new string[] - { + string[] asm = + [ "PUSH 0", $"PUSH {memAllocCmdVar}", $"PUSH {memAllocCmdVar}", @@ -329,7 +323,7 @@ public bool ExecuteLuaAndRead(string command, string variable, out string result $"PUSH {memAllocCmdVar + commandBytes.Length}", $"CALL {Memory.Offsets.FunctionGetLocalizedText}", "RET", - }; + ]; if (InjectAndExecute(asm, true, out nint returnAddress) && Memory.ReadString(returnAddress, Encoding.UTF8, out result)) @@ -368,15 +362,15 @@ public bool GetLocalizedText(string variable, out string result) { Memory.WriteBytes(memAlloc, variableBytes); - string[] asm = new string[] - { + string[] asm = + [ $"CALL {Memory.Offsets.FunctionGetActivePlayerObject}", "MOV ECX, EAX", "PUSH -1", $"PUSH {memAlloc}", $"CALL {Memory.Offsets.FunctionGetLocalizedText}", "RET", - }; + ]; if (InjectAndExecute(asm, true, out nint returnAddress) && Memory.ReadString(returnAddress, Encoding.UTF8, out result)) @@ -420,11 +414,11 @@ private void DisableFunction(nint address) private void EnableFunction(nint address) { // check for RET opcode to be present before restoring original function - if (OriginalFunctionBytes.ContainsKey(address) + if (OriginalFunctionBytes.TryGetValue(address, out byte value) && Memory.Read(address, out byte opcode) && opcode == 0xC3) { - Memory.PatchMemory(address, OriginalFunctionBytes[address]); + Memory.PatchMemory(address, value); } } @@ -432,11 +426,7 @@ private void SaveOriginalFunctionBytes(nint address) { if (Memory.Read(address, out byte opcode)) { - if (!OriginalFunctionBytes.ContainsKey(address)) - { - OriginalFunctionBytes.Add(address, opcode); - } - else + if (!OriginalFunctionBytes.TryAdd(address, opcode)) { OriginalFunctionBytes[address] = opcode; } diff --git a/AmeisenBotX.Wow335a/Objects/ObjectManager335a.cs b/AmeisenBotX.Wow335a/Objects/ObjectManager335a.cs index 30d6c429..226f765c 100644 --- a/AmeisenBotX.Wow335a/Objects/ObjectManager335a.cs +++ b/AmeisenBotX.Wow335a/Objects/ObjectManager335a.cs @@ -8,13 +8,8 @@ namespace AmeisenBotX.Wow335a.Objects { - public class ObjectManager335a : ObjectManager + public class ObjectManager335a(WowMemoryApi memory) : ObjectManager(memory) { - public ObjectManager335a(WowMemoryApi memory) - : base(memory) - { - } - protected override void ReadParty() { PartyleaderGuid = ReadLeaderGuid(); diff --git a/AmeisenBotX.Wow335a/Objects/Raw/RawPartyGuids.cs b/AmeisenBotX.Wow335a/Objects/Raw/RawPartyGuids.cs index dbbfe05a..499689e8 100644 --- a/AmeisenBotX.Wow335a/Objects/Raw/RawPartyGuids.cs +++ b/AmeisenBotX.Wow335a/Objects/Raw/RawPartyGuids.cs @@ -13,15 +13,15 @@ public struct RawPartyGuids public ulong PartymemberGuid4 { get; set; } - public ulong[] AsArray() + public readonly ulong[] AsArray() { - return new ulong[] - { + return + [ PartymemberGuid1, PartymemberGuid2, PartymemberGuid3, PartymemberGuid4, - }; + ]; } } } \ No newline at end of file diff --git a/AmeisenBotX.Wow335a/Objects/Raw/RawRaidStruct.cs b/AmeisenBotX.Wow335a/Objects/Raw/RawRaidStruct.cs index 97763273..89c67d63 100644 --- a/AmeisenBotX.Wow335a/Objects/Raw/RawRaidStruct.cs +++ b/AmeisenBotX.Wow335a/Objects/Raw/RawRaidStruct.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Runtime.InteropServices; namespace AmeisenBotX.Wow335a.Objects.Raw @@ -87,10 +86,10 @@ public struct RawRaidStruct public nint RaidPlayer9 { get; set; } - public IEnumerable GetPointers() + public readonly IEnumerable GetPointers() { - return new List() - { + return + [ RaidPlayer1, RaidPlayer2, RaidPlayer3, @@ -131,7 +130,7 @@ public IEnumerable GetPointers() RaidPlayer38, RaidPlayer39, RaidPlayer40 - }; + ]; } } } \ No newline at end of file diff --git a/AmeisenBotX.Wow335a/Objects/Raw/WowAura335a.cs b/AmeisenBotX.Wow335a/Objects/Raw/WowAura335a.cs index 68bb1087..08ec3af0 100644 --- a/AmeisenBotX.Wow335a/Objects/Raw/WowAura335a.cs +++ b/AmeisenBotX.Wow335a/Objects/Raw/WowAura335a.cs @@ -23,13 +23,13 @@ public struct WowAura335a : IWowAura public uint EndTime { get; set; } - public bool IsActive => ((WowAuraFlag)Flags).HasFlag(WowAuraFlag.Active); + public readonly bool IsActive => ((WowAuraFlag)Flags).HasFlag(WowAuraFlag.Active); - public bool IsHarmful => ((WowAuraFlag)Flags).HasFlag(WowAuraFlag.Harmful); + public readonly bool IsHarmful => ((WowAuraFlag)Flags).HasFlag(WowAuraFlag.Harmful); - public bool IsPassive => ((WowAuraFlag)Flags).HasFlag(WowAuraFlag.Passive); + public readonly bool IsPassive => ((WowAuraFlag)Flags).HasFlag(WowAuraFlag.Passive); - public override string ToString() + public override readonly string ToString() { return $"{SpellId} (lvl. {Level}) x{StackCount} [CG: {Creator}], Harmful: {IsHarmful}, Passive: {IsPassive}"; } diff --git a/AmeisenBotX.Wow335a/Objects/WowPlayer335a.cs b/AmeisenBotX.Wow335a/Objects/WowPlayer335a.cs index 605db1ad..b3bfbbf9 100644 --- a/AmeisenBotX.Wow335a/Objects/WowPlayer335a.cs +++ b/AmeisenBotX.Wow335a/Objects/WowPlayer335a.cs @@ -111,8 +111,8 @@ public override void Update() { RawWowPlayer = obj; - questlogEntries = new QuestlogEntry[] - { + questlogEntries = + [ obj.QuestlogEntry1, obj.QuestlogEntry2, obj.QuestlogEntry3, @@ -138,10 +138,10 @@ public override void Update() obj.QuestlogEntry23, obj.QuestlogEntry24, obj.QuestlogEntry25, - }; + ]; - itemEnchantments = new VisibleItemEnchantment[] - { + itemEnchantments = + [ obj.VisibleItemEnchantment1, obj.VisibleItemEnchantment2, obj.VisibleItemEnchantment3, @@ -161,7 +161,7 @@ public override void Update() obj.VisibleItemEnchantment17, obj.VisibleItemEnchantment18, obj.VisibleItemEnchantment19, - }; + ]; } if (Memory.Read(nint.Add(BaseAddress, 0xA30), out uint swimFlags)) diff --git a/AmeisenBotX.Wow335a/WowInterface335a.cs b/AmeisenBotX.Wow335a/WowInterface335a.cs index 23045ee1..a902b558 100644 --- a/AmeisenBotX.Wow335a/WowInterface335a.cs +++ b/AmeisenBotX.Wow335a/WowInterface335a.cs @@ -26,6 +26,12 @@ namespace AmeisenBotX.Wow335a /// public class WowInterface335a : IWowInterface { + private static readonly JsonSerializerOptions Options = new() + { + AllowTrailingCommas = true, + NumberHandling = JsonNumberHandling.AllowReadingFromString + }; + public WowInterface335a(WowMemoryApi memory) { Memory = memory; @@ -334,7 +340,7 @@ public IEnumerable GetCompletedQuests() { if (result != null && result.Length > 0) { - return result.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries) + return result.Split(';', StringSplitOptions.RemoveEmptyEntries) .Select(e => int.TryParse(e, out int n) ? n : (int?)null) .Where(e => e.HasValue) .Select(e => e.Value); @@ -368,7 +374,7 @@ public string[] GetGossipTypes() // ignored } - return Array.Empty(); + return []; } public string GetInventoryItems() @@ -397,14 +403,14 @@ public IEnumerable GetMounts() try { - return JsonSerializer.Deserialize>(mountJson, new JsonSerializerOptions() { AllowTrailingCommas = true, NumberHandling = JsonNumberHandling.AllowReadingFromString }); + return JsonSerializer.Deserialize>(mountJson, Options); } catch (Exception e) { AmeisenLogger.I.Log("CharacterManager", $"Failed to parse Mounts JSON:\n{mountJson}\n{e}", LogLevel.Error); } - return Array.Empty(); + return []; } public bool GetNumQuestLogChoices(out int numChoices) @@ -865,12 +871,12 @@ public void SetFacing(nint playerBase, float angle, bool smooth = false) public void SetLfgRole(WowRole combatClassRole) { - int[] roleBools = new int[3] - { - combatClassRole == WowRole.Tank ? 1:0, - combatClassRole == WowRole.Heal ? 1:0, - combatClassRole == WowRole.Dps ? 1:0 - }; + int[] roleBools = + [ + combatClassRole == WowRole.Tank ? 1 : 0, + combatClassRole == WowRole.Heal ? 1 : 0, + combatClassRole == WowRole.Dps ? 1 : 0 + ]; LuaDoString($"SetLFGRoles(0, {roleBools[0]}, {roleBools[1]}, {roleBools[2]});LFDRoleCheckPopupAcceptButton:Click()"); } diff --git a/AmeisenBotX.Wow548/Hook/EndSceneHook548.cs b/AmeisenBotX.Wow548/Hook/EndSceneHook548.cs index 1c47b068..f7abd395 100644 --- a/AmeisenBotX.Wow548/Hook/EndSceneHook548.cs +++ b/AmeisenBotX.Wow548/Hook/EndSceneHook548.cs @@ -11,14 +11,8 @@ namespace AmeisenBotX.Wow548.Hook { - public class EndSceneHook548 : GenericEndSceneHook + public class EndSceneHook548(WowMemoryApi memory) : GenericEndSceneHook(memory) { - public EndSceneHook548(WowMemoryApi memory) - : base(memory) - { - OriginalFunctionBytes = []; - } - /// /// Used to save the old render flags of wow. /// @@ -27,7 +21,7 @@ public EndSceneHook548(WowMemoryApi memory) /// /// Used to save the original instruction when a function get disabled. /// - private Dictionary OriginalFunctionBytes { get; } + private Dictionary OriginalFunctionBytes { get; } = []; [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool CallObjectFunction(nint objectBaseAddress, nint functionAddress, List? args = null) @@ -209,8 +203,8 @@ public bool TraceLine(Vector3 start, Vector3 end, uint flags) if (Memory.Write(distancePointer, tracelineCombo)) { - string[] asm = new string[] - { + string[] asm = + [ "PUSH 0", $"PUSH {flags}", $"PUSH {distancePointer}", @@ -220,7 +214,7 @@ public bool TraceLine(Vector3 start, Vector3 end, uint flags) $"CALL {Memory.Offsets.FunctionTraceline}", "ADD ESP, 0x18", "RET", - }; + ]; if (InjectAndExecute(asm, true, out nint returnAddress)) { @@ -322,8 +316,8 @@ public bool ExecuteLuaAndRead(string command, string variable, out string result Memory.WriteBytes(memAllocCmdVar, bytesToWrite); - string[] asm = new string[] - { + string[] asm = + [ "PUSH 0", $"PUSH {memAllocCmdVar}", $"PUSH {memAllocCmdVar}", @@ -335,7 +329,7 @@ public bool ExecuteLuaAndRead(string command, string variable, out string result $"PUSH {memAllocCmdVar + commandBytes.Length}", $"CALL {Memory.Offsets.FunctionGetLocalizedText}", "RET", - }; + ]; if (InjectAndExecute(asm, true, out nint returnAddress) && Memory.ReadString(returnAddress, Encoding.UTF8, out result)) @@ -374,15 +368,15 @@ public bool GetLocalizedText(string variable, out string result) { Memory.WriteBytes(memAlloc, variableBytes); - string[] asm = new string[] - { + string[] asm = + [ $"CALL {Memory.Offsets.FunctionGetActivePlayerObject}", "MOV ECX, EAX", "PUSH -1", $"PUSH {memAlloc}", $"CALL {Memory.Offsets.FunctionGetLocalizedText}", "RET", - }; + ]; if (InjectAndExecute(asm, true, out nint returnAddress) && Memory.ReadString(returnAddress, Encoding.UTF8, out result)) @@ -426,11 +420,11 @@ private void DisableFunction(nint address) private void EnableFunction(nint address) { // check for RET opcode to be present before restoring original function - if (OriginalFunctionBytes.ContainsKey(address) + if (OriginalFunctionBytes.TryGetValue(address, out byte value) && Memory.Read(address, out byte opcode) && opcode == 0xC3) { - Memory.PatchMemory(address, OriginalFunctionBytes[address]); + Memory.PatchMemory(address, value); } } @@ -438,11 +432,7 @@ private void SaveOriginalFunctionBytes(nint address) { if (Memory.Read(address, out byte opcode)) { - if (!OriginalFunctionBytes.ContainsKey(address)) - { - OriginalFunctionBytes.Add(address, opcode); - } - else + if (!OriginalFunctionBytes.TryAdd(address, opcode)) { OriginalFunctionBytes[address] = opcode; } diff --git a/AmeisenBotX.Wow548/Objects/ObjectManager548.cs b/AmeisenBotX.Wow548/Objects/ObjectManager548.cs index 2ef1403f..222ae774 100644 --- a/AmeisenBotX.Wow548/Objects/ObjectManager548.cs +++ b/AmeisenBotX.Wow548/Objects/ObjectManager548.cs @@ -4,13 +4,8 @@ namespace AmeisenBotX.Wow548.Objects { - public class ObjectManager548 : ObjectManager + public class ObjectManager548(WowMemoryApi memory) : ObjectManager(memory) { - public ObjectManager548(WowMemoryApi memory) - : base(memory) - { - } - protected override void ReadParty() { if (ReadPartyPointer(out nint party) diff --git a/AmeisenBotX.Wow548/Objects/Raw/WowAura548.cs b/AmeisenBotX.Wow548/Objects/Raw/WowAura548.cs index eed77476..29527baf 100644 --- a/AmeisenBotX.Wow548/Objects/Raw/WowAura548.cs +++ b/AmeisenBotX.Wow548/Objects/Raw/WowAura548.cs @@ -23,13 +23,13 @@ public unsafe struct WowAura548 : IWowAura public fixed int Pad1[5]; - public bool IsActive => ((WowAuraFlag)Flags).HasFlag(WowAuraFlag.Active); + public readonly bool IsActive => ((WowAuraFlag)Flags).HasFlag(WowAuraFlag.Active); - public bool IsHarmful => ((WowAuraFlag)Flags).HasFlag(WowAuraFlag.Harmful); + public readonly bool IsHarmful => ((WowAuraFlag)Flags).HasFlag(WowAuraFlag.Harmful); - public bool IsPassive => ((WowAuraFlag)Flags).HasFlag(WowAuraFlag.Passive); + public readonly bool IsPassive => ((WowAuraFlag)Flags).HasFlag(WowAuraFlag.Passive); - public override string ToString() + public override readonly string ToString() { return $"{SpellId} (lvl. {Level}) x{StackCount} [CG: {Creator}], Harmful: {IsHarmful}, Passive: {IsPassive}"; } diff --git a/AmeisenBotX.Wow548/Objects/WowPlayer548.cs b/AmeisenBotX.Wow548/Objects/WowPlayer548.cs index 418e1df2..0042e584 100644 --- a/AmeisenBotX.Wow548/Objects/WowPlayer548.cs +++ b/AmeisenBotX.Wow548/Objects/WowPlayer548.cs @@ -12,9 +12,9 @@ public unsafe class WowPlayer548 : WowUnit548, IWowPlayer { protected WowPlayerDescriptor548? PlayerDescriptor; - private IEnumerable itemEnchantments; + private readonly IEnumerable? itemEnchantments; - private IEnumerable questlogEntries; + private readonly IEnumerable? questlogEntries; public int ComboPoints => Memory.Read(Memory.Offsets.ComboPoints, out byte comboPoints) ? comboPoints : 0; @@ -24,11 +24,11 @@ public unsafe class WowPlayer548 : WowUnit548, IWowPlayer public bool IsUnderwater { get; set; } - public IEnumerable ItemEnchantments => itemEnchantments; + public IEnumerable? ItemEnchantments => itemEnchantments; public int NextLevelXp => GetPlayerDescriptor().NextLevelXp; - public IEnumerable QuestlogEntries => questlogEntries; + public IEnumerable? QuestlogEntries => questlogEntries; public int Xp => GetPlayerDescriptor().Xp; diff --git a/AmeisenBotX.Wow548/WowInterface548.cs b/AmeisenBotX.Wow548/WowInterface548.cs index 94ac793d..77c0d978 100644 --- a/AmeisenBotX.Wow548/WowInterface548.cs +++ b/AmeisenBotX.Wow548/WowInterface548.cs @@ -23,6 +23,12 @@ namespace AmeisenBotX.Wow548 /// public class WowInterface548 : IWowInterface { + private static readonly JsonSerializerOptions Options = new() + { + AllowTrailingCommas = true, + NumberHandling = JsonNumberHandling.AllowReadingFromString + }; + public WowInterface548(WowMemoryApi memory) { Memory = memory; @@ -331,14 +337,14 @@ public IEnumerable GetCompletedQuests() { if (result != null && result.Length > 0) { - return result.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries) + return result.Split(';', StringSplitOptions.RemoveEmptyEntries) .Select(e => int.TryParse(e, out int n) ? n : (int?)null) .Where(e => e.HasValue) .Select(e => e.Value); } } - return Array.Empty(); + return []; } public string GetEquipmentItems() @@ -365,7 +371,7 @@ public string[] GetGossipTypes() // ignored } - return Array.Empty(); + return []; } public string GetInventoryItems() @@ -388,13 +394,13 @@ public int GetMoney() return ExecuteLuaAndRead(BotUtils.ObfuscateLua("{v:0}=GetMoney();"), out string s) ? int.TryParse(s, out int v) ? v : 0 : 0; } - public IEnumerable GetMounts() + public IEnumerable? GetMounts() { string mountJson = ExecuteLuaAndRead(BotUtils.ObfuscateLua($"{{v:0}}=\"[\"{{v:1}}=GetNumCompanions(\"MOUNT\")if {{v:1}}>0 then for b=1,{{v:1}} do {{v:4}},{{v:2}},{{v:3}}=GetCompanionInfo(\"mount\",b){{v:0}}={{v:0}}..\"{{\\\"name\\\":\\\"\"..{{v:2}}..\"\\\",\"..\"\\\"index\\\":\"..b..\",\"..\"\\\"spellId\\\":\"..{{v:3}}..\",\"..\"\\\"mountId\\\":\"..{{v:4}}..\",\"..\"}}\"if b<{{v:1}} then {{v:0}}={{v:0}}..\",\"end end end;{{v:0}}={{v:0}}..\"]\""), out string result) ? result : string.Empty; try { - return JsonSerializer.Deserialize>(mountJson, new JsonSerializerOptions() { AllowTrailingCommas = true, NumberHandling = JsonNumberHandling.AllowReadingFromString }); + return JsonSerializer.Deserialize>(mountJson, Options); } catch (Exception e) { @@ -1003,12 +1009,12 @@ public void SetFacing(nint playerBase, float angle, bool smooth = false) public void SetLfgRole(WowRole combatClassRole) { - int[] roleBools = new int[3] - { - combatClassRole == WowRole.Tank ? 1:0, - combatClassRole == WowRole.Heal ? 1:0, - combatClassRole == WowRole.Dps ? 1:0 - }; + int[] roleBools = + [ + combatClassRole == WowRole.Tank ? 1 : 0, + combatClassRole == WowRole.Heal ? 1 : 0, + combatClassRole == WowRole.Dps ? 1 : 0 + ]; LuaDoString($"SetLFGRoles(0, {roleBools[0]}, {roleBools[1]}, {roleBools[2]});LFDRoleCheckPopupAcceptButton:Click()"); } diff --git a/AmeisenBotX/DevToolsWindow.xaml.cs b/AmeisenBotX/DevToolsWindow.xaml.cs index f69b6403..46b75940 100644 --- a/AmeisenBotX/DevToolsWindow.xaml.cs +++ b/AmeisenBotX/DevToolsWindow.xaml.cs @@ -82,7 +82,7 @@ private static void CopyDataOfNearestObject(ItemsControl listView) string[] splitByBrace = splitByPos[1].Split("]", 2); string[] posComponents = splitByBrace[0].Split(", "); - string[] cleanComponents = { "", "", "" }; + string[] cleanComponents = ["", "", ""]; for (int i = 0; i < posComponents.Length; i++) { diff --git a/AmeisenBotX/InfoWindow.xaml.cs b/AmeisenBotX/InfoWindow.xaml.cs index 6ab5f72e..dcad3912 100644 --- a/AmeisenBotX/InfoWindow.xaml.cs +++ b/AmeisenBotX/InfoWindow.xaml.cs @@ -70,7 +70,7 @@ private void DisplayStuff() buttonInventory.BorderBrush = new SolidColorBrush((Color)Application.Current.Resources["DarkBorder"]); buttonSpells.BorderBrush = new SolidColorBrush((Color)Application.Current.Resources["DarkBorder"]); - IWowInventoryItem[] equipmentItems = AmeisenBot.Bot.Character.Equipment.Items.Values.ToArray(); + IWowInventoryItem[] equipmentItems = [.. AmeisenBot.Bot.Character.Equipment.Items.Values]; foreach (IWowInventoryItem invItem in equipmentItems) { @@ -84,7 +84,7 @@ private void DisplayStuff() buttonInventory.BorderBrush = new SolidColorBrush((Color)Application.Current.Resources["DarkAccent1"]); buttonSpells.BorderBrush = new SolidColorBrush((Color)Application.Current.Resources["DarkBorder"]); - IWowInventoryItem[] inventoryItems = AmeisenBot.Bot.Character.Inventory.Items.ToArray(); + IWowInventoryItem[] inventoryItems = [.. AmeisenBot.Bot.Character.Inventory.Items]; foreach (IWowInventoryItem invItem in inventoryItems) { diff --git a/AmeisenBotX/MainWindow.xaml.cs b/AmeisenBotX/MainWindow.xaml.cs index bf7d0bc8..158da1bb 100644 --- a/AmeisenBotX/MainWindow.xaml.cs +++ b/AmeisenBotX/MainWindow.xaml.cs @@ -30,6 +30,19 @@ namespace AmeisenBotX { public partial class MainWindow : Window { + private static readonly JsonSerializerOptions Options = new() + { + AllowTrailingCommas = true, + NumberHandling = JsonNumberHandling.AllowReadingFromString, + WriteIndented = true, + }; + + private static readonly JsonSerializerOptions OptionsFields = new() + { + WriteIndented = true, + IncludeFields = true + }; + public MainWindow(string dataPath, string configPath) { if (!Directory.Exists(dataPath)) { throw new FileNotFoundException(dataPath); } @@ -157,13 +170,12 @@ protected override Size MeasureOverride(Size availableSize) return size; } - private static bool TryLoadConfig(string configPath, out AmeisenBotConfig config) { if (!string.IsNullOrWhiteSpace(configPath)) { config = File.Exists(configPath) - ? JsonSerializer.Deserialize(File.ReadAllText(configPath), new JsonSerializerOptions() { AllowTrailingCommas = true, NumberHandling = JsonNumberHandling.AllowReadingFromString }) + ? JsonSerializer.Deserialize(File.ReadAllText(configPath), Options) : new(); config.Path = configPath; @@ -187,7 +199,7 @@ private void ButtonConfig_Click(object sender, RoutedEventArgs e) if (configWindow.SaveConfig) { AmeisenBot.ReloadConfig(configWindow.Config); - File.WriteAllText(AmeisenBot.Config.Path, JsonSerializer.Serialize(configWindow.Config, new JsonSerializerOptions() { WriteIndented = true })); + File.WriteAllText(AmeisenBot.Config.Path, JsonSerializer.Serialize(configWindow.Config, Options)); KeyboardHook.Clear(); LoadHotkeys(); @@ -446,7 +458,6 @@ private void SaveBotWindowPosition() } } } - private void SaveConfig() { if (AmeisenBot != null @@ -454,7 +465,7 @@ private void SaveConfig() && !string.IsNullOrWhiteSpace(AmeisenBot.Config.Path) && Directory.Exists(Path.GetDirectoryName(AmeisenBot.Config.Path))) { - File.WriteAllText(AmeisenBot.Config.Path, JsonSerializer.Serialize(AmeisenBot.Config, new JsonSerializerOptions() { WriteIndented = true, IncludeFields = true })); + File.WriteAllText(AmeisenBot.Config.Path, JsonSerializer.Serialize(AmeisenBot.Config, OptionsFields)); } } diff --git a/AmeisenBotX/MapWindow.xaml.cs b/AmeisenBotX/MapWindow.xaml.cs index 2ea8c7b4..cec5b0e6 100644 --- a/AmeisenBotX/MapWindow.xaml.cs +++ b/AmeisenBotX/MapWindow.xaml.cs @@ -520,15 +520,8 @@ private void RenderUnits(int halfWidth, int halfHeight, Graphics graphics, float private void SetupGraphics() { - if (Graphics != null) - { - Graphics.Dispose(); - } - - if (Bitmap != null) - { - Bitmap.Dispose(); - } + Graphics?.Dispose(); + Bitmap?.Dispose(); int width = (int)mapCanvasBackground.ActualWidth; int height = (int)mapCanvasBackground.ActualHeight;