Skip to content

Commit

Permalink
merge fix
Browse files Browse the repository at this point in the history
  • Loading branch information
CarnifexOptimus committed Nov 21, 2024
1 parent c1dcbb7 commit f7cb18e
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 63 deletions.
17 changes: 7 additions & 10 deletions BossMod/Debug/DebugTeleport.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
using Dalamud.Game.ClientState.Keys;
using Dalamud.Plugin.Services;
using FFXIVClientStructs.FFXIV.Client.System.Framework;
using BossMod.Util;
using ImGuiNET;
using FFXIVClientStructs.FFXIV.Client.System.Framework;

namespace BossMod;

class DebugTeleport
{
private bool EnableNoClip = false;
private bool ncActive;
private float NoClipSpeed = 0.05f;

private bool EnableNoClip;
private float NoClipSpeed = 0.001f;
private Vector3 inputCoordinates = new(0, 0, 0);
private Vector3 playerCoordinates = new Vector3(PlayerEx.Position.X, PlayerEx.Position.Y, PlayerEx.Position.Z);

public unsafe void Draw()
{
Expand All @@ -24,7 +21,7 @@ public unsafe void Draw()
Enable();
ImGui.SameLine();
ImGui.SetNextItemWidth(150);
ImGui.InputFloat("No Clip Speed", ref NoClipSpeed, 0.05f);
ImGui.InputFloat("No Clip Speed", ref NoClipSpeed, 0.001f);
}
else
{
Expand All @@ -46,11 +43,11 @@ public unsafe void Draw()
SetPlayerPosition(inputCoordinates);
}
ImGui.SetNextItemWidth(150);
ImGui.InputFloat("X Coordinate", ref inputCoordinates.X, 1.0f);
ImGui.InputFloat("X Coordinate", ref inputCoordinates.X, 1f);
ImGui.SetNextItemWidth(150);
ImGui.InputFloat("Y Coordinate", ref inputCoordinates.Y, 1.0f);
ImGui.InputFloat("Y Coordinate", ref inputCoordinates.Y, 1f);
ImGui.SetNextItemWidth(150);
ImGui.InputFloat("Z Coordinate", ref inputCoordinates.Z, 1.0f);
ImGui.InputFloat("Z Coordinate", ref inputCoordinates.Z, 1f);
ImGui.EndGroup();
}

Expand Down
6 changes: 3 additions & 3 deletions BossMod/Framework/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -318,12 +318,12 @@ private void ParseAutorotationCommands(string[] cmd)
if (cmd.Length <= 2)
Service.Log("Specify an autorotation preset name.");
else
ParseAutorotationSetCommand(cmd.Skip(1).ToArray(), false);
ParseAutorotationSetCommand([.. cmd.Skip(1)], false);
break;
case "TOGGLE":
ParseAutorotationSetCommand(cmd.Length > 2 ? cmd.Skip(1).ToArray() : [""], true);
ParseAutorotationSetCommand(cmd.Length > 2 ? [.. cmd.Skip(1)] : [""], true);
break;
case "ui":
case "UI":
_wndRotation.SetVisible(!_wndRotation.IsOpen);
break;
}
Expand Down
30 changes: 16 additions & 14 deletions BossMod/Framework/Utils.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using BossModReborn.Util;
using Dalamud.Game.ClientState.Objects.Types;
using Dalamud.Game.ClientState.Objects.Types;
using PInvoke;
using System.Globalization;
using System.Reflection;
Expand Down Expand Up @@ -301,24 +300,24 @@ public static string StringToIdentifier(string v)
/// <summary>
/// Sets whether <see cref="User32.GetKeyState"/> or <see cref="User32.GetAsyncKeyState"/> will be used when calling <see cref="IsKeyPressed(Keys)"/> or <see cref="IsKeyPressed(LimitedKeys)"/>
/// </summary>
private static bool UseAsyncKeyCheck;
#pragma warning restore
public static bool UseAsyncKeyCheck = false;

/// <summary>
/// Checks if a key is pressed via winapi.
/// </summary>
/// <param name="key">Key</param>
/// <returns>Whether the key is currently pressed</returns>
public static bool IsKeyPressed(int key)
{
if (key == 0) return false;
if (key == 0)
return false;
if (UseAsyncKeyCheck)
{
return Bitmask.IsBitSet(User32.GetKeyState(key), 15);
return Bitmasks.IsBitSet(User32.GetKeyState(key), 15);
}
else
{
return Bitmask.IsBitSet(User32.GetAsyncKeyState(key), 15);
return Bitmasks.IsBitSet(User32.GetAsyncKeyState(key), 15);
}
}

Expand All @@ -327,15 +326,16 @@ public static bool IsKeyPressed(int key)
/// </summary>
/// <param name="key">Key</param>
/// <returns>Whether the key is currently pressed</returns>
public static bool IsKeyPressed(LimitedKeys key) => IsKeyPressed((int)key);
public static bool IsKeyPressed(Util.LimitedKeys key) => IsKeyPressed((int)key);

public static bool IsAnyKeyPressed(IEnumerable<LimitedKeys> keys) => keys.Any(IsKeyPressed);
public static bool IsAnyKeyPressed(IEnumerable<Util.LimitedKeys> keys) => keys.Any(IsKeyPressed);

public static bool IsKeyPressed(IEnumerable<LimitedKeys> keys)
public static bool IsKeyPressed(IEnumerable<Util.LimitedKeys> keys)
{
foreach (var x in keys)
{
if (IsKeyPressed(x)) return true;
if (IsKeyPressed(x))
return true;
}
return false;
}
Expand All @@ -344,14 +344,16 @@ public static bool IsKeyPressed(IEnumerable<int> keys)
{
foreach (var x in keys)
{
if (IsKeyPressed(x)) return true;
if (IsKeyPressed(x))
return true;
}
return false;
}

public static Vector3 RotatePoint(float cx, float cy, float angle, Vector3 p)
{
if (angle == 0f) return p;
if (angle == 0f)
return p;
var s = (float)Math.Sin(angle);
var c = (float)Math.Cos(angle);

Expand All @@ -370,7 +372,7 @@ public static Vector3 RotatePoint(float cx, float cy, float angle, Vector3 p)
}
}

public static class Bitmask
public static class Bitmasks
{
public static bool IsBitSet(ulong b, int pos)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@ public override void AddAIHints(int slot, Actor actor, PartyRolesConfig.Assignme
case D092OverseerKanilokkaConfig.NecrohazardMechanic.TankInvuln:
if (actor.Role != Role.Tank)
return;
var isDelayDeltaLow = (Module.CastFinishAt(Casters[0].CastInfo) - WorldState.CurrentTime).TotalSeconds < 5;
if (isDelayDeltaLow)
if ((Module.CastFinishAt(Casters[0].CastInfo) - WorldState.CurrentTime).TotalSeconds < 5)
{
switch (actor.Class)
{
Expand All @@ -132,7 +131,6 @@ public override void AddAIHints(int slot, Actor actor, PartyRolesConfig.Assignme
}
}
break;

case D092OverseerKanilokkaConfig.NecrohazardMechanic.TeleportHackAlways:
Teleport();
break;
Expand Down
10 changes: 3 additions & 7 deletions BossMod/Util/CameraEx.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.InteropServices;

namespace BossMod.Util;

namespace BossModReborn.Util;
[StructLayout(LayoutKind.Explicit, Size = 0x2B0)]
public unsafe struct CameraEx
{
Expand Down
27 changes: 11 additions & 16 deletions BossMod/Util/LimitedKeys.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BossMod.Util;

namespace BossModReborn.Util;
public enum LimitedKeys
{
//
Expand Down Expand Up @@ -169,43 +164,43 @@ public enum LimitedKeys
//
// Summary:
// The 0 key.
Digit_0 = 48,
Digit0 = 48,
//
// Summary:
// The 1 key.
Digit_1 = 49,
Digit1 = 49,
//
// Summary:
// The 2 key.
Digit_2 = 50,
Digit2 = 50,
//
// Summary:
// The 3 key.
Digit_3 = 51,
Digit3 = 51,
//
// Summary:
// The 4 key.
Digit_4 = 52,
Digit4 = 52,
//
// Summary:
// The 5 key.
Digit_5 = 53,
Digit5 = 53,
//
// Summary:
// The 6 key.
Digit_6 = 54,
Digit6 = 54,
//
// Summary:
// The 7 key.
Digit_7 = 55,
Digit7 = 55,
//
// Summary:
// The 8 key.
Digit_8 = 56,
Digit8 = 56,
//
// Summary:
// The 9 key.
Digit_9 = 57,
Digit9 = 57,
//
// Summary:
// The A key.
Expand Down
12 changes: 2 additions & 10 deletions BossMod/Util/PlayerEx.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
using Dalamud.Game.ClientState.Objects.SubKinds;
using FFXIVClientStructs.FFXIV.Client.Game;
using FFXIVClientStructs.FFXIV.Client.Game.Control;
using FFXIVClientStructs.FFXIV.Client.Game.Object;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CSGameObject = FFXIVClientStructs.FFXIV.Client.Game.Object.GameObject;
using FFXIVClientStructs.FFXIV.Client.Game.Control;

namespace BossMod.Util;
public static unsafe class PlayerEx
{
public static IPlayerCharacter Object => Service.ClientState.LocalPlayer;
public static IPlayerCharacter Object => Service.ClientState.LocalPlayer ?? throw new InvalidOperationException("LocalPlayer is null");
public static unsafe FFXIVClientStructs.FFXIV.Client.Game.Camera* Camera => CameraManager.Instance()->GetActiveCamera();
public static unsafe CameraEx* CameraEx => (CameraEx*)CameraManager.Instance()->GetActiveCamera();

Expand Down Expand Up @@ -70,5 +63,4 @@ public static void SetPlayerPosition(Vector3 position)
Service.Log("Error in SetPlayerPosition" + ex);
}
}

}

0 comments on commit f7cb18e

Please sign in to comment.