Skip to content

Commit

Permalink
Merge pull request #459 from FFXIV-CombatReborn/markerfix
Browse files Browse the repository at this point in the history
Refactor target access methods for consistency
  • Loading branch information
LTS-FFXIV authored Dec 3, 2024
2 parents e46ac3d + 1be07b3 commit b4208b5
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 48 deletions.
2 changes: 1 addition & 1 deletion RotationSolver.Basic/Actions/ActionTargetInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ public bool GeneralCheck(IBattleChara gameObject, bool skipStatusProvideCheck)
return false;
}

if (MarkingHelper.StopTargets.Contains((long)gameObject.GameObjectId) && Service.Config.FilterStopMark)
if (MarkingHelper.GetStopTargets().Contains((long)gameObject.GameObjectId) && Service.Config.FilterStopMark)
{
return false;
}
Expand Down
64 changes: 18 additions & 46 deletions RotationSolver.Basic/Helpers/MarkingHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,64 +48,36 @@ internal unsafe static long GetMarker(HeadMarker index)
/// <summary>
/// Gets a value indicating whether there are any attack characters.
/// </summary>
internal static bool HaveAttackChara => AttackSignTargets.Any(id => id != 0);
internal static bool HaveAttackChara => GetAttackSignTargets().Any(id => id != 0);

private static long[]? _attackSignTargets;
/// <summary>
/// Gets the attack sign targets.
/// </summary>
internal static long[] AttackSignTargets
internal static long[] GetAttackSignTargets()
{
get
return new long[]
{
if (_attackSignTargets == null)
{
lock (_lock)
{
if (_attackSignTargets == null)
{
_attackSignTargets = new long[]
{
GetMarker(HeadMarker.Attack1),
GetMarker(HeadMarker.Attack2),
GetMarker(HeadMarker.Attack3),
GetMarker(HeadMarker.Attack4),
GetMarker(HeadMarker.Attack5),
GetMarker(HeadMarker.Attack6),
GetMarker(HeadMarker.Attack7),
GetMarker(HeadMarker.Attack8),
};
}
}
}
return _attackSignTargets;
}
GetMarker(HeadMarker.Attack1),
GetMarker(HeadMarker.Attack2),
GetMarker(HeadMarker.Attack3),
GetMarker(HeadMarker.Attack4),
GetMarker(HeadMarker.Attack5),
GetMarker(HeadMarker.Attack6),
GetMarker(HeadMarker.Attack7),
GetMarker(HeadMarker.Attack8),
};
}

private static long[]? _stopTargets;
/// <summary>
/// Gets the stop targets.
/// </summary>
internal static long[] StopTargets
internal static long[] GetStopTargets()
{
get
return new long[]
{
if (_stopTargets == null)
{
lock (_lock)
{
if (_stopTargets == null)
{
_stopTargets = new long[]
{
GetMarker(HeadMarker.Stop1),
GetMarker(HeadMarker.Stop2),
};
}
}
}
return _stopTargets;
}
GetMarker(HeadMarker.Stop1),
GetMarker(HeadMarker.Stop2),
};
}

/// <summary>
Expand All @@ -115,7 +87,7 @@ internal static long[] StopTargets
/// <returns>The filtered characters.</returns>
internal unsafe static IEnumerable<IBattleChara> FilterStopCharacters(IEnumerable<IBattleChara> charas)
{
var ids = new HashSet<long>(StopTargets.Where(id => id != 0));
var ids = new HashSet<long>(GetStopTargets().Where(id => id != 0));
return charas.Where(b => !ids.Contains((long)b.GameObjectId));
}
}
Expand Down
2 changes: 1 addition & 1 deletion RotationSolver.Basic/Helpers/ObjectHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ internal static bool IsTopPriorityHostile(this IGameObject obj)
if (b.StatusList != null && b.StatusList.Any(StatusHelper.IsPriority)) return true;
}

if (Service.Config.ChooseAttackMark && MarkingHelper.AttackSignTargets.FirstOrDefault(id => id != 0) == (long)obj.GameObjectId) return true;
if (Service.Config.ChooseAttackMark && MarkingHelper.GetAttackSignTargets().FirstOrDefault(id => id != 0) == (long)obj.GameObjectId) return true;

// Fate
if (Service.Config.TargetFatePriority && fateId != 0 && obj.FateId() == fateId) return true;
Expand Down

0 comments on commit b4208b5

Please sign in to comment.