diff --git a/ArabicaCliento/Patches/ClientHeavyAttackPatch.cs b/ArabicaCliento/Patches/ClientHeavyAttackPatch.cs index 4107a4b..cb1d36d 100644 --- a/ArabicaCliento/Patches/ClientHeavyAttackPatch.cs +++ b/ArabicaCliento/Patches/ClientHeavyAttackPatch.cs @@ -3,25 +3,31 @@ using Robust.Shared.Map; using ArabicaCliento.Systems; using Content.Client.Weapons.Melee; +using Robust.Client.GameObjects; namespace ArabicaCliento.Patches; [HarmonyPatch(typeof(MeleeWeaponSystem), "ClientHeavyAttack")] public class ClientHeavyAttackPatch { + private static IEntityManager? _entMan; + private static TransformSystem? _transform; + private static ArabicaAimSystem? _aim; + + [HarmonyPrefix] private static void Prefix(ref EntityUid user, ref EntityCoordinates coordinates, ref EntityUid meleeUid, ref MeleeWeaponComponent component) { - var entity = IoCManager.Resolve(); - var xform = entity.System(); - var aim = entity.System(); - - var output = aim.GetClosestToEntInRange(user, component.Range, [user]); - if (output == null || !ArabicaConfig.MeleeAimbotEnabled) return; + if (!ArabicaConfig.MeleeAimbotEnabled) return; + _entMan ??= IoCManager.Resolve(); + _transform ??= _entMan.System(); + _aim ??= _entMan.System(); - coordinates = EntityCoordinates.FromMap(coordinates.EntityId, output.Value.Position, xform, entity); + var output = _aim.GetClosestToEntInRange(user, component.Range, [user]); + if (output == null) return; + coordinates = _transform.ToCoordinates(coordinates.EntityId, output.Value.Position); } } \ No newline at end of file diff --git a/ArabicaCliento/Patches/EntityMenuElementPatch.cs b/ArabicaCliento/Patches/EntityMenuElementPatch.cs index 1317b68..62eae4f 100644 --- a/ArabicaCliento/Patches/EntityMenuElementPatch.cs +++ b/ArabicaCliento/Patches/EntityMenuElementPatch.cs @@ -1,3 +1,4 @@ +using System.Reflection; using Content.Client.ContextMenu.UI; using HarmonyLib; @@ -7,11 +8,12 @@ namespace ArabicaCliento.Patches; [HarmonyPatch("GetEntityDescription")] internal class EntityMenuElementPatch { + private static MethodInfo? _methodCache; [HarmonyPrefix] private static bool Prefix(EntityUid entity, EntityMenuElement __instance, ref string __result) { - __result = AccessTools.Method(typeof(EntityMenuElement), "GetEntityDescriptionAdmin") - .Invoke(__instance, [entity]) as string ?? throw new InvalidOperationException(); + _methodCache ??= AccessTools.Method(typeof(EntityMenuElement), "GetEntityDescriptionAdmin"); + __result = _methodCache.Invoke(__instance, [entity]) as string ?? throw new InvalidOperationException(); return false; } } \ No newline at end of file diff --git a/ArabicaCliento/Systems/ArabicaIcons.cs b/ArabicaCliento/Systems/ArabicaIcons.cs index 0b71941..6ffa6c2 100644 --- a/ArabicaCliento/Systems/ArabicaIcons.cs +++ b/ArabicaCliento/Systems/ArabicaIcons.cs @@ -6,5 +6,4 @@ namespace ArabicaCliento.Systems; public class ArabicaJobIconsSystem : LocalPlayerAddCompSystem; public class ArabicaCriminalRecordIcons : LocalPlayerAddCompSystem; public class ArabicaMindShieldIcons : LocalPlayerAddCompSystem; - public class ArabicaSyndicateIcons : LocalPlayerAddCompSystem; \ No newline at end of file diff --git a/ArabicaCliento/UI/Controls/ArabicaWindow.xaml.cs b/ArabicaCliento/UI/Controls/ArabicaWindow.xaml.cs index 8bd89f6..6e4db1b 100644 --- a/ArabicaCliento/UI/Controls/ArabicaWindow.xaml.cs +++ b/ArabicaCliento/UI/Controls/ArabicaWindow.xaml.cs @@ -1,46 +1,51 @@ using System.Numerics; using Robust.Client.AutoGenerated; +using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.CustomControls; using Robust.Client.UserInterface.XAML; -using Robust.Shared.Prototypes; -namespace ArabicaCliento.UI.Controls +namespace ArabicaCliento.UI.Controls; + +[GenerateTypedNameReferences] +[Virtual] +public partial class ArabicaWindow : BaseWindow { - [GenerateTypedNameReferences] - [Virtual] - public partial class ArabicaWindow : BaseWindow + private const int DRAG_MARGIN_SIZE = 7; + + public ArabicaWindow() { - private const int DRAG_MARGIN_SIZE = 7; + RobustXamlLoader.Load(this); + CloseButton.OnPressed += CloseButtonPressed; + } - public ArabicaWindow() + private void CloseButtonPressed(BaseButton.ButtonEventArgs buttonEventArgs) + { + Close(); + } + + protected override DragMode GetDragModeFor(Vector2 relativeMousePos) + { + var mode = DragMode.Move; + + if (!Resizable) return mode; + if (relativeMousePos.Y < DRAG_MARGIN_SIZE) + { + mode = DragMode.Top; + } + else if (relativeMousePos.Y > Size.Y - DRAG_MARGIN_SIZE) { - RobustXamlLoader.Load(this); + mode = DragMode.Bottom; } - protected override DragMode GetDragModeFor(Vector2 relativeMousePos) + if (relativeMousePos.X < DRAG_MARGIN_SIZE) { - var mode = DragMode.Move; - - if (!Resizable) return mode; - if (relativeMousePos.Y < DRAG_MARGIN_SIZE) - { - mode = DragMode.Top; - } - else if (relativeMousePos.Y > Size.Y - DRAG_MARGIN_SIZE) - { - mode = DragMode.Bottom; - } - - if (relativeMousePos.X < DRAG_MARGIN_SIZE) - { - mode |= DragMode.Left; - } - else if (relativeMousePos.X > Size.X - DRAG_MARGIN_SIZE) - { - mode |= DragMode.Right; - } - - return mode; + mode |= DragMode.Left; } + else if (relativeMousePos.X > Size.X - DRAG_MARGIN_SIZE) + { + mode |= DragMode.Right; + } + + return mode; } -} +} \ No newline at end of file