Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
fix: fixed some ui bugs.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Apr 5, 2023
1 parent f0829e1 commit 1c06b15
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 19 deletions.
8 changes: 2 additions & 6 deletions RotationSolver.Basic/Actions/BaseAction_Target.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,12 @@ public partial class BaseAction
{
public byte AOECount { private get; set; } = 3;

/// <summary>
/// Shortcut for Target.IsDying();
/// </summary>
public bool IsTargetDying => Target?.IsDying() ?? false;

/// <summary>
/// Shortcut for Target.IsBoss();
/// </summary>
public bool IsTargetBoss => Target?.IsBoss() ?? false;

public bool IsSingleTarget => _action.CastType == 1;

/// <summary>
/// The action's target.
/// </summary>
Expand Down
5 changes: 5 additions & 0 deletions RotationSolver.Basic/Actions/IBaseAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,11 @@ public interface IBaseAction : IAction
/// If this is an aoe action, how many hostile target would want to attack on, when you use this action.
/// </summary>
byte AOECount { set; }

/// <summary>
/// Is this action's target type is target only one.
/// </summary>
bool IsSingleTarget { get; }
#endregion
}
}
53 changes: 40 additions & 13 deletions RotationSolver/UI/OverlayWindow.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using RotationSolver.Updaters;
using Dalamud.Interface;
using RotationSolver.Updaters;

namespace RotationSolver.UI;

Expand Down Expand Up @@ -121,15 +122,24 @@ private static void DrawTarget(BattleChara tar, uint color, float radius, out Ve
const int COUNT = 20;
private static void DrawPositional()
{
if (ActionUpdater.NextGCDAction == null || 
!Service.Player.IsJobCategory(JobRole.Tank)
&& !Service.Player.IsJobCategory(JobRole.Melee)) return;
if (!Service.Player.IsJobCategory(JobRole.Tank)
&& !Service.Player.IsJobCategory(JobRole.Melee) ) return;

Vector3 pPosition = ActionUpdater.NextGCDAction.Target.Position;
if (!(ActionUpdater.NextGCDAction?.IsSingleTarget ?? false)) return;

var target = ActionUpdater.NextGCDAction?.Target?.IsNPCEnemy() ?? false
? ActionUpdater.NextGCDAction.Target
: Service.TargetManager.Target?.IsNPCEnemy() ?? false
? Service.TargetManager.Target
: null;

if(target == null) return;

Vector3 pPosition = target.Position;
Service.WorldToScreen(pPosition, out var scrPos);

float radius = ActionUpdater.NextGCDAction.Target.HitboxRadius + Service.Player.HitboxRadius + 3;
float rotation = ActionUpdater.NextGCDAction.Target.Rotation;
float radius = target.HitboxRadius + Service.Player.HitboxRadius + 3;
float rotation = target.Rotation;

if (Service.Config.DrawMeleeOffset)
{
Expand All @@ -139,16 +149,17 @@ private static void DrawPositional()

List<Vector2> pts2 = new List<Vector2>(4 * COUNT);
SectorPlots(ref pts2, pPosition, radius + Service.Config.MeleeRangeOffset, 0, 4 * COUNT, 2 * Math.PI);
pts2.Reverse();

DrawFill(pts1.Union(pts2), offsetColor);
DrawBoundary(pts1 , offsetColor);
DrawFill(pts1.ToArray(), pts2.ToArray(), offsetColor);

DrawBoundary(pts1, offsetColor);
DrawBoundary(pts2, offsetColor);
}

if (ActionUpdater.NextGCDAction == null || !ActionUpdater.NextGCDAction.Target.IsNPCEnemy()) return;

List<Vector2> pts = new List<Vector2>(4 * COUNT);
bool wrong = ActionUpdater.NextGCDAction.Target.DistanceToPlayer() > 3;
bool wrong = target.DistanceToPlayer() > 3;
if (Service.Config.DrawPositional && !Service.Player.HasStatus(true, StatusID.TrueNorth))
{
var shouldPos = ActionUpdater.NextGCDAction.EnemyPositional;
Expand All @@ -170,7 +181,7 @@ private static void DrawPositional()
}
if (!wrong && pts.Count > 0)
{
wrong = shouldPos != ActionUpdater.NextGCDAction.Target.FindEnemyPositional();
wrong = shouldPos != target.FindEnemyPositional();
}
}
if (pts.Count == 0 && Service.Config.DrawMeleeRange)
Expand All @@ -181,6 +192,22 @@ private static void DrawPositional()
if (pts.Count > 0) DrawRange(pts, wrong);
}

static void DrawFill(Vector2[] pts1, Vector2[] pts2, Vector3 color)
{
if (pts1 == null || pts2 == null) return;
if (pts1.Length != pts2.Length) return;
var length = pts1.Length;
for (int i = 0; i < length; i++)
{
var p1 = pts1[i];
var p2 = pts2[i];
var p3 = pts2[(i + 1) % length];
var p4 = pts1[(i + 1) % length];

DrawFill(new Vector2[] { p1, p2, p3, p4}, color);
}
}

static void DrawRange(IEnumerable<Vector2> pts, bool wrong)
{
var color = wrong ? new Vector3(0.3f, 0.8f, 0.2f) : new Vector3(1, 1, 1);
Expand Down

0 comments on commit 1c06b15

Please sign in to comment.