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

Commit

Permalink
fix: default target.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Mar 21, 2024
1 parent 3f0d7e7 commit 4f6824e
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 24 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<TargetFramework>net8.0-windows</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Authors>ArchiTed</Authors>
<Version>4.2.1.1</Version>
<Version>4.2.1.2</Version>
<PlatformTarget>x64</PlatformTarget>
<Platforms>AnyCPU</Platforms>
<LangVersion>latest</LangVersion>
Expand Down
2 changes: 1 addition & 1 deletion Resources/RotationSolverRecord.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"ClickingCount": 107756,
"ClickingCount": 107940,
"SayingHelloCount": 176,
"SaidUsers": []
}
8 changes: 3 additions & 5 deletions RotationSolver.Basic/Actions/BaseAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace RotationSolver.Basic.Actions;
public class BaseAction : IBaseAction
{
/// <inheritdoc/>
public TargetResult? Target { get; set; } = null;
public TargetResult Target { get; set; } = new(Player.Object, [], null);

/// <inheritdoc/>
public TargetResult? PreviewTarget { get; private set; } = null;
Expand Down Expand Up @@ -152,7 +152,7 @@ public bool CanUse(out IAction act, bool skipStatusProvideCheck = false, bool sk
if (PreviewTarget == null) return false;
if (!IBaseAction.ActionPreview)
{
Target = PreviewTarget;
Target = PreviewTarget.Value;
}

return true;
Expand All @@ -175,9 +175,7 @@ public bool CanUse(out IAction act, CanUseOption option, byte gcdCountForAbility
/// <inheritdoc/>
public unsafe bool Use()
{
if (!Target.HasValue) return false;

var target = Target.Value;
var target = Target;

var adjustId = AdjustedID;
if (TargetInfo.IsTargetArea)
Expand Down
2 changes: 1 addition & 1 deletion RotationSolver.Basic/Actions/IBaseAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public interface IBaseAction : IAction
/// <summary>
/// The target to use on.
/// </summary>
TargetResult? Target { get; set; }
TargetResult Target { get; set; }

/// <summary>
/// The target for preview.
Expand Down
2 changes: 1 addition & 1 deletion RotationSolver.Basic/Rotations/CustomRotation_GCD.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ partial class CustomRotation
if (DataCenter.MergedStatus.HasFlag(AutoStatus.MoveForward)
&& MoveForwardGCD(out act))
{
if (act is IBaseAction b && ObjectHelper.DistanceToPlayer(b.Target?.Target) > 5) return act;
if (act is IBaseAction b && ObjectHelper.DistanceToPlayer(b.Target.Target) > 5) return act;
}

IBaseAction.TargetOverride = TargetType.Heal;
Expand Down
11 changes: 8 additions & 3 deletions RotationSolver/Commands/RSCommands_Actions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public static void DoAction()

if (nextAction is BaseAction act1 && act1.Info.IsPvP && !act1.Setting.IsFriendly
&& act1.TargetInfo.IsSingleTarget
&& act1.Target?.Target is PlayerCharacter p && p != Player.Object)
&& act1.Target.Target is PlayerCharacter p && p != Player.Object)
{
var hash = p.EncryptString();

Expand Down Expand Up @@ -109,8 +109,8 @@ public static void DoAction()
//}
#endif
//Change Target
var tar = (act.Target == null || act.Target?.Target == Player.Object)
? act.Target?.AffectedTargets.FirstOrDefault() : act.Target?.Target;
var tar = act.Target.Target == Player.Object
? act.Target.AffectedTargets.FirstOrDefault() : act.Target.Target;

if (tar != null && tar != Player.Object && tar.IsEnemy())
{
Expand All @@ -123,6 +123,11 @@ public static void DoAction()
}
}
}

}
else
{
Svc.Log.Error($"Failed to use the action {nextAction} ({nextAction.AdjustedID})");
}
}

Expand Down
6 changes: 2 additions & 4 deletions RotationSolver/UI/PainterManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,15 +193,13 @@ private static void UpdateTarget()

if (ActionUpdater.NextAction is not BaseAction act) return;

if (act.Target == null) return;

var d = DateTime.Now.Millisecond / 1000f;
var ratio = (float)DrawingExtensions.EaseFuncRemap(EaseFuncType.None, EaseFuncType.Cubic)(d);

if (Service.Config.TargetIconSize > 0)
{
_targetImage.Enable = true;
_targetImage.Position = act.Target?.Position ?? Player.Object.Position;
_targetImage.Position = act.Target.Position ?? Player.Object.Position;
if (act.GetTexture(out var texture, true))
{
_targetImage.Image = texture;
Expand All @@ -212,7 +210,7 @@ private static void UpdateTarget()
{
_target.Enable = true;
_target.Color = ImGui.GetColorU32(Service.Config.TargetColor);
_target.Center = act.Target?.Position ?? Player.Object.Position;
_target.Center = act.Target.Position ?? Player.Object.Position;
_target.Radius = targetRadius * ratio;
}
}
Expand Down
5 changes: 1 addition & 4 deletions RotationSolver/UI/RotationConfigWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1550,10 +1550,7 @@ static void DrawActionDebug()

ImGui.Text($"Can Use: {action.CanUse(out _, skipClippingCheck: true)} ");
ImGui.Text("IgnoreCastCheck:" + action.CanUse(out _, skipClippingCheck: true, skipCastingCheck: true).ToString());
if (action.Target != null)
{
ImGui.Text("Target Name: " + action.Target.Value.Target?.Name ?? string.Empty);
}
ImGui.Text("Target Name: " + action.Target.Target?.Name ?? string.Empty);
}
catch
{
Expand Down
2 changes: 1 addition & 1 deletion RotationSolver/Updaters/ActionUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ internal static IBaseAction? NextGCDAction
circle.Owner = sector.Owner = rectangle.Owner = player;

if (value == null) return;
var target = value.Target?.Target ?? player;
var target = value.Target.Target ?? player;

var range = value.Action.EffectRange;
var size = new Vector3(range, gcdHeight, range);
Expand Down
2 changes: 1 addition & 1 deletion RotationSolver/Updaters/MajorUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ private unsafe static void FrameworkUpdate(IFramework framework)
{
SocialUpdater.UpdateSocial();
PreviewUpdater.UpdatePreview();
TargetUpdater.UpdateTarget();

if (Service.Config.TeachingMode && ActionUpdater.NextAction != null)
{
Expand Down Expand Up @@ -171,7 +172,6 @@ private static void UpdateWork()

try
{
TargetUpdater.UpdateTarget();
StateUpdater.UpdateState();

if (Service.Config.AutoLoadCustomRotations)
Expand Down
4 changes: 2 additions & 2 deletions RotationSolver/Updaters/StateUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ private static AutoStatus StatusFromAutomatic()
{
var id = ActionUpdater.NextGCDAction.ID;
if (ConfigurationHelper.ActionPositional.TryGetValue((ActionID)id, out var positional)
&& positional != ActionUpdater.NextGCDAction.Target?.Target?.FindEnemyPositional()
&& (ActionUpdater.NextGCDAction.Target?.Target?.HasPositional() ?? false))
&& positional != ActionUpdater.NextGCDAction.Target.Target?.FindEnemyPositional()
&& (ActionUpdater.NextGCDAction.Target.Target?.HasPositional() ?? false))
{
status |= AutoStatus.Positional;
}
Expand Down

0 comments on commit 4f6824e

Please sign in to comment.