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

Commit

Permalink
fix: timeline drawing fixed.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Mar 7, 2024
1 parent 2654937 commit 5a24eff
Show file tree
Hide file tree
Showing 9 changed files with 235 additions and 162 deletions.
41 changes: 1 addition & 40 deletions RotationSolver.Basic/Configuration/Conditions/TargetCondition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ internal class TargetCondition : DelayCondition
public TargetType TargetType;
public TargetConditionType TargetConditionType;

public float DistanceOrTime, TimeEnd;
public float DistanceOrTime;
public int GCD, Param2;

public string CastingActionName = string.Empty;
Expand Down Expand Up @@ -197,39 +197,6 @@ protected override bool IsTrueInside(ICustomRotation rotation)
}
result = tar.Name.TextValue == CastingActionName;
break;

case TargetConditionType.ObjectEffect:
foreach (var effect in DataCenter.ObjectEffects.Reverse())
{
var time = effect.TimeDuration.TotalSeconds;
if (time > DistanceOrTime && time < TimeEnd
&& effect.Param1 == GCD
&& effect.Param2 == Param2)
{
if (!FromSelf || effect.ObjectId == tar.ObjectId)
{
result = true;
break;
}
}
}
break;

case TargetConditionType.Vfx:
foreach (var effect in DataCenter.VfxNewData.Reverse())
{
var time = effect.TimeDuration.TotalSeconds;
if (time > DistanceOrTime && time < TimeEnd
&& effect.Path == CastingActionName)
{
if (!FromSelf || effect.ObjectId == tar.ObjectId)
{
result = true;
break;
}
}
}
break;
}

return result;
Expand Down Expand Up @@ -297,10 +264,4 @@ internal enum TargetConditionType : byte

[Description("Target Name")]
TargetName,

[Description("Object Effect")]
ObjectEffect,

[Description("Vfx")]
Vfx,
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,16 @@ internal class TerritoryCondition : DelayCondition
{
public TerritoryConditionType TerritoryConditionType = TerritoryConditionType.TerritoryContentType;

public int Position = 0;
public int Param1 = 0, Param2 = 0;
public int TerritoryId = 0;
public string Name = "Not Chosen";
public float TimeStart, TimeEnd;

protected override bool IsTrueInside(ICustomRotation rotation)
{
bool result = false;
switch (TerritoryConditionType)
{
case TerritoryConditionType.TerritoryContentType:
result = (int)DataCenter.TerritoryContentType == Param1;
result = (int)DataCenter.TerritoryContentType == TerritoryId;
break;

case TerritoryConditionType.DutyName:
Expand All @@ -26,22 +24,6 @@ protected override bool IsTrueInside(ICustomRotation rotation)
case TerritoryConditionType.TerritoryName:
result = Name == DataCenter.TerritoryName;
break;

case TerritoryConditionType.MapEffect:
foreach (var effect in DataCenter.MapEffects.Reverse())
{
var time = effect.TimeDuration.TotalSeconds;
if (time > TimeStart && time < TimeEnd
&& effect.Position == Position
&& effect.Param1 == Param1
&& effect.Param2 == Param2)
{
result = true;
break;
}
}

break;
}
return result;
}
Expand All @@ -57,7 +39,4 @@ internal enum TerritoryConditionType : byte

[Description("Duty Name")]
DutyName,

[Description("Map Effect")]
MapEffect,
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ internal class ITimelineConditionConverter : JsonCreationConverter<ITimelineCond
{
return new TimelineConditionTargetCount();
}
else if (FieldExists(nameof(TimelineConditionMapEffect.Position), jObject))
{
return new TimelineConditionMapEffect();
}

return new TrueTimelineCondition();
return null;
}
}
Original file line number Diff line number Diff line change
@@ -1,20 +1,91 @@
using Dalamud.Game.ClientState.Objects.SubKinds;
using ECommons.GameHelpers;
using System.Text.RegularExpressions;

namespace RotationSolver.Basic.Configuration.Timeline.TimelineCondition;

internal class ObjectGetter
{
public bool IsPlayer { get; set; } = false;
public ObjectType Type { get; set; }
public string DataID { get; set; } = "";
public JobRole Role { get; set; } = JobRole.None;
public uint Status { get; set; }
public float StatusTime { get; set; } = 5;
public Vector2 TimeDuration { get; set; } = new(0, 2);
public string VfxPath { get; set; } = string.Empty;
public ushort ObjectEffect1 { get; set; } = 0;
public ushort ObjectEffect2 { get; set; } = 0;
public bool CanGet(GameObject obj)
{
if (IsPlayer && obj is not PlayerCharacter) return false;
switch (Type)
{
case ObjectType.BattleCharactor:
if(obj is not BattleChara) return false;
break;

case ObjectType.PlayerCharactor:
if (obj is not PlayerCharacter) return false;
break;

case ObjectType.Myself:
return obj == Player.Object;
}

if (!string.IsNullOrEmpty(DataID) && !new Regex(DataID).IsMatch(obj.DataId.ToString("X"))) return false;

if (Role != JobRole.None && !obj.IsJobCategory(Role)) return false;

if (Status != 0)
{
if (obj is not BattleChara b) return false;
var status = b.StatusList.FirstOrDefault(s => s.StatusId == Status);
if (status == null) return false;
if (status.RemainingTime > StatusTime) return false;
}

if (!string.IsNullOrEmpty(VfxPath))
{
if (!DataCenter.VfxNewData.Reverse().Any(effect =>
{
if (effect.ObjectId != obj.ObjectId) return false;

var time = effect.TimeDuration.TotalSeconds;

if (time < TimeDuration.X) return false;
if (time > TimeDuration.Y) return false;

if (effect.Path != VfxPath) return false;

return true;
})) return false;
}

if (ObjectEffect1 != 0 || ObjectEffect2 != 0)
{
if (!DataCenter.ObjectEffects.Reverse().Any(effect =>
{
if (effect.ObjectId != obj.ObjectId) return false;

var time = effect.TimeDuration.TotalSeconds;

if (time < TimeDuration.X) return false;
if (time > TimeDuration.Y) return false;

if (effect.Param1 != ObjectEffect1) return false;
if (effect.Param2 != ObjectEffect2) return false;

return true;
})) return false;
}

return true;
}
}

public enum ObjectType : byte
{
GameObject,
BattleCharactor,
PlayerCharactor,
Myself,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
namespace RotationSolver.Basic.Configuration.Timeline.TimelineCondition;

[Description("Map Effect")]
internal class TimelineConditionMapEffect : ITimelineCondition
{
public Vector2 TimeDuration { get; set; } = new(0, 2);
public int Position { get; set; }
public int Param1 { get; set; }
public int Param2 { get; set; }
public bool IsTrue(TimelineItem item)
{
return DataCenter.MapEffects.Reverse().Any(effect =>
{
var time = effect.TimeDuration.TotalSeconds;

if (time < TimeDuration.X) return false;
if (time > TimeDuration.Y) return false;

if (effect.Position != Position) return false;
if (effect.Param1 != Param1) return false;
if (effect.Param2 != Param2) return false;

return true;
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ internal class TimelineConditionSet : ITimelineCondition
public LogicalType Type;
public bool IsTrue(TimelineItem item)
{
if (Conditions.Count == 0) return false;
if (Conditions.Count == 0) return true;

return Type switch
{
Expand Down

This file was deleted.

75 changes: 3 additions & 72 deletions RotationSolver/UI/ConditionDrawer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -836,75 +836,6 @@ void DrawStatusIcon()
ImGuiHelper.SetNextWidthWithName(targetCondition.CastingActionName);
ImGui.InputText($"Name##TargetName{targetCondition.GetHashCode()}", ref targetCondition.CastingActionName, 128);
break;

case TargetConditionType.ObjectEffect:
ImGui.SameLine();

ImGui.Text("P1:");
DrawDragInt($"##Param1{targetCondition.GetHashCode()}", ref targetCondition.GCD);

ImGui.SameLine();

ImGui.Text("P2:");
DrawDragInt($"##Param2{targetCondition.GetHashCode()}", ref targetCondition.Param2);

ImGui.SameLine();

ImGui.Text("Time Offset:");
ImGui.SameLine();
const float MIN = 0, MAX = 60;

ImGui.SetNextItemWidth(80 * ImGuiHelpers.GlobalScale);
if (ImGui.DragFloatRange2($"##TimeOffset {targetCondition.GetHashCode()}", ref targetCondition.DistanceOrTime, ref targetCondition.TimeEnd, 0.1f, MIN, MAX))
{
targetCondition.DistanceOrTime = Math.Max(Math.Min(targetCondition.DistanceOrTime, targetCondition.TimeEnd), MIN);
targetCondition.TimeEnd = Math.Min(Math.Max(targetCondition.DistanceOrTime, targetCondition.TimeEnd), MAX);
}

ImGui.SameLine();
check = targetCondition.FromSelf ? 1 : 0;
if (ImGuiHelper.SelectableCombo($"From Self {targetCondition.GetHashCode()}",
[
UiString.ActionSequencer_StatusAll.Local(),
UiString.ActionSequencer_StatusSelf.Local(),
], ref check))
{
targetCondition.FromSelf = check != 0;
}
break;

case TargetConditionType.Vfx:
ImGui.SameLine();

ImGui.Text("Vfx Path:");
ImGui.SameLine();

ImGuiHelper.SetNextWidthWithName(targetCondition.CastingActionName);
ImGui.InputText($"Name##TargetName{targetCondition.GetHashCode()}", ref targetCondition.CastingActionName, 128);

ImGui.SameLine();

ImGui.Text("Time Offset:");
ImGui.SameLine();

ImGui.SetNextItemWidth(80 * ImGuiHelpers.GlobalScale);
if (ImGui.DragFloatRange2($"##TimeOffset {targetCondition.GetHashCode()}", ref targetCondition.DistanceOrTime, ref targetCondition.TimeEnd, 0.1f, MIN, MAX))
{
targetCondition.DistanceOrTime = Math.Max(Math.Min(targetCondition.DistanceOrTime, targetCondition.TimeEnd), MIN);
targetCondition.TimeEnd = Math.Min(Math.Max(targetCondition.DistanceOrTime, targetCondition.TimeEnd), MAX);
}

ImGui.SameLine();
check = targetCondition.FromSelf ? 1 : 0;
if (ImGuiHelper.SelectableCombo($"From Self {targetCondition.GetHashCode()}",
[
UiString.ActionSequencer_StatusAll.Local(),
UiString.ActionSequencer_StatusSelf.Local(),
], ref check))
{
targetCondition.FromSelf = check != 0;
}
break;
}

if (targetCondition._action == null && targetCondition.TargetType == TargetType.Target)
Expand Down Expand Up @@ -932,9 +863,9 @@ private static void DrawAfter(this TerritoryCondition territoryCondition, ICusto
case TerritoryConditionType.TerritoryContentType:
ImGui.SameLine();

var type = (TerritoryContentType)territoryCondition.Param1;
var type = (TerritoryContentType)territoryCondition.TerritoryId;
DrawByteEnum($"##TerritoryContentType{territoryCondition.GetHashCode()}", ref type);
territoryCondition.Param1 = (int)type;
territoryCondition.TerritoryId = (int)type;
break;

case TerritoryConditionType.TerritoryName:
Expand Down Expand Up @@ -966,7 +897,7 @@ private static void DrawAfter(this TerritoryCondition territoryCondition, ICusto
ImGui.SameLine();

ImGui.Text("P1:");
DrawDragInt($"##Param1{territoryCondition.GetHashCode()}", ref territoryCondition.Param1);
DrawDragInt($"##Param1{territoryCondition.GetHashCode()}", ref territoryCondition.TerritoryId);

ImGui.SameLine();

Expand Down
Loading

0 comments on commit 5a24eff

Please sign in to comment.