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

Commit

Permalink
fix: clean code.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Jul 21, 2023
1 parent b596d54 commit 69dd6ea
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 88 deletions.
1 change: 0 additions & 1 deletion RotationSolver.Basic/Actions/BaseAction_ActionInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ public unsafe virtual bool CanUse(out IAction act, CanUseOption option = CanUseO
Target = player;

if (!option.HasFlag(CanUseOption.SkipDisable) && !IsEnabled) return false;


if (DataCenter.DisabledAction != null && DataCenter.DisabledAction.Contains(ID)) return false;

Expand Down
87 changes: 1 addition & 86 deletions RotationSolver/UI/PainterManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,78 +9,6 @@ namespace RotationSolver.UI;

internal static class PainterManager
{
class PositionalDrawing : Drawing3DPoly
{
Drawing3DCircularSectorO _noneCir, _flankCir, _rearCir;

public EnemyPositional Positional { get; set; }

public GameObject Target { get; set; }

public PositionalDrawing()
{
var right = ImGui.ColorConvertFloat4ToU32(new Vector4(1, 1, 1, 0.15f));
var wrong = ImGui.ColorConvertFloat4ToU32(new Vector4(0.3f, 0.8f, 0.2f, 0.15f));

_noneCir = new Drawing3DCircularSectorO(null, 3, wrong, 2);

_flankCir = new Drawing3DCircularSectorO(null, 3, wrong, 2, XIVPainter.Enum.RadiusInclude.IncludeBoth,
new Vector2(MathF.PI * 0.25f, MathF.PI / 2), new Vector2(MathF.PI * 1.25f, MathF.PI / 2));
_rearCir = new Drawing3DCircularSectorO(null, 3, wrong, 2, XIVPainter.Enum.RadiusInclude.IncludeBoth,
new Vector2(MathF.PI * 0.75f, MathF.PI / 2));

_noneCir.InsideColor = _flankCir.InsideColor = _rearCir.InsideColor = right;

SubItems = new IDrawing3D[] { _noneCir, _flankCir, _rearCir };
}

public override void UpdateOnFrame(XIVPainter.XIVPainter painter)
{
if (Target == null || !Target.IsNPCEnemy())
{
_flankCir.Target = null;
_rearCir.Target = null;
_noneCir.Target = null;
}
else
{
var pos = Positional;
if (!Target.HasPositional() || Player.Available && Player.Object.HasStatus(true, CustomRotation.TrueNorth.StatusProvide))
{
pos = EnemyPositional.None;
}
switch (pos)
{
case EnemyPositional.Flank when Service.Config.DrawPositional:
_flankCir.Target = Target;
_rearCir.Target = null;
_noneCir.Target = null;
break;

case EnemyPositional.Rear when Service.Config.DrawPositional:
_flankCir.Target = null;
_rearCir.Target = Target;
_noneCir.Target = null;
break;

case EnemyPositional.None when Service.Config.DrawMeleeRange:
_flankCir.Target = null;
_rearCir.Target = null;
_noneCir.Target = Target;
break;

default:
_flankCir.Target = null;
_rearCir.Target = null;
_noneCir.Target = null;
break;
}
}

base.UpdateOnFrame(painter);
}
}

class TargetDrawing : Drawing3DPoly
{
Drawing3DCircularSector _target;
Expand Down Expand Up @@ -194,7 +122,6 @@ public override void UpdateOnFrame(XIVPainter.XIVPainter painter)
}

internal static XIVPainter.XIVPainter _painter;
static PositionalDrawing _positional = new();
static DrawingHighlightHotbar _highLight = new();

public static HashSet<uint> ActionIds => _highLight.ActionIds;
Expand All @@ -209,7 +136,6 @@ public static void Init()
{
_painter = XIVPainter.XIVPainter.Create(Svc.PluginInterface, "RotationSolverOverlay");

_positional = new();
_highLight = new();

_painter.DrawingHeight = Service.Config.DrawingHeight;
Expand Down Expand Up @@ -253,7 +179,7 @@ public static void Init()
movingTarget.To = tar.Value;
};

_painter.AddDrawings(_positional, _highLight, annulus, movingTarget, new TargetDrawing(), new TargetText());
_painter.AddDrawings(_highLight, annulus, movingTarget, new TargetDrawing(), new TargetText());

#if DEBUG
//try
Expand Down Expand Up @@ -289,17 +215,6 @@ public static void Init()
#endif
}

public static void UpdatePositional(EnemyPositional positional, GameObject target)
{
_positional.Target = target;
_positional.Positional = positional;
}

public static void ClearPositional()
{
_positional.Target = null;
}

public static void Dispose()
{
_painter?.Dispose();
Expand Down
7 changes: 6 additions & 1 deletion RotationSolver/Updaters/ActionUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ internal static class ActionUpdater
internal static IAction WrongAction { get; set; }
static Random _wrongRandom = new();

internal static void Dispose()
{
SetAction(0);
}

internal static void UpdateNextAction()
{
PlayerCharacter localPlayer = Player.Object;
Expand Down Expand Up @@ -66,10 +71,10 @@ internal static void UpdateNextAction()
}

WrongAction = NextAction = NextGCDAction = null;
PainterManager.ClearPositional();
}

private static void SetAction(uint id) => Svc.PluginInterface.GetOrCreateData("Avarice.ActionOverride", () => new List<uint>() { id })[0] = id;

internal unsafe static void UpdateActionInfo()
{
SetAction(NextGCDAction?.AdjustedID ?? 0);
Expand Down
1 change: 1 addition & 0 deletions RotationSolver/Updaters/MajorUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -175,5 +175,6 @@ public static void Dispose()
PreviewUpdater.Dispose();
ActionSequencerUpdater.SaveFiles();
SocialUpdater.Disable();
ActionUpdater.Dispose();
}
}

0 comments on commit 69dd6ea

Please sign in to comment.