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

Commit

Permalink
fix: add a lot of ui for raidboss drawing.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Mar 6, 2024
1 parent a2db516 commit 673dd83
Show file tree
Hide file tree
Showing 10 changed files with 213 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ internal class DrawingTimeline : BaseTimelineItem
{
public float Duration { get; set; } = 5;

public ITimelineCondition Condition { get; set; } = new TrueTimelineCondition();
public TimelineConditionSet Condition { get; set; } = new()
{
Conditions = [new TrueTimelineCondition()],
};
public List<IDrawingGetter> DrawingGetters { get; set; } = [];

private IDisposable[] _drawings = [];
Expand All @@ -26,7 +29,7 @@ public override bool InPeriod(TimelineItem item)
if (time < Time - Duration) return false;
if (time > Time) return false;

if (!Condition.IsTrue()) return false;
if (!Condition.IsTrue(item)) return false;

return true;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
namespace RotationSolver.Basic.Configuration.Timeline.TimelineCondition;
public interface ITimelineCondition
internal interface ITimelineCondition
{
bool IsTrue();
bool IsTrue(TimelineItem item);
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
using Newtonsoft.Json.Linq;
using RotationSolver.Basic.Configuration.Conditions;
using RotationSolver.Basic.Configuration.Timeline.TimelineDrawing;

namespace RotationSolver.Basic.Configuration.Timeline.TimelineCondition;
internal class ITimelineConditionConverter : JsonCreationConverter<ITimelineCondition>
{
protected override ITimelineCondition? Create(JObject jObject)
{
if (FieldExists(nameof(ActionDrawingGetter.ActionID), jObject))
if (FieldExists(nameof(TimelineConditionSet.Conditions), jObject))
{
//return new ActionDrawingGetter();
return new TimelineConditionSet();
}
else if (FieldExists(nameof(TimelineConditionAction.ActionID), jObject))
{
return new TimelineConditionAction();
}
else if (FieldExists(nameof(TimelineConditionTargetCount.Getter), jObject))
{
return new TimelineConditionTargetCount();
}

return new TrueTimelineCondition();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
using Dalamud.Game.ClientState.Objects.SubKinds;
using System.Text.RegularExpressions;

namespace RotationSolver.Basic.Configuration.Timeline.TimelineCondition;

internal class ObjectGetter
{
public bool IsPlayer { get; set; } = false;
public uint DataID { get; set; } = 0;
public string DataID { get; set; } = "";
public JobRole Role { get; set; } = JobRole.None;
public bool CanGet(GameObject obj)
{
if (IsPlayer && obj is not PlayerCharacter) return false;

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

if (Role != JobRole.None && !obj.IsJobCategory(Role)) return false;
return true;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace RotationSolver.Basic.Configuration.Timeline.TimelineCondition;
internal class TimelineConditionAction : ITimelineCondition
{
public uint ActionID { get; set; }
public bool IsTrue(TimelineItem item)
{
if (ActionID == 0) return true;
return ActionID == item.LastActionID;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using RotationSolver.Basic.Configuration.Conditions;

namespace RotationSolver.Basic.Configuration.Timeline.TimelineCondition;

internal class TimelineConditionSet : ITimelineCondition
{
public List<ITimelineCondition> Conditions { get; set; } = [];

public LogicalType Type;
public bool IsTrue(TimelineItem item)
{
if (Conditions.Count == 0) return false;

return Type switch
{
LogicalType.And => Conditions.All(c => c.IsTrue(item)),
LogicalType.Or => Conditions.Any(c => c.IsTrue(item)),
_ => false,
};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using ECommons.DalamudServices;

namespace RotationSolver.Basic.Configuration.Timeline.TimelineCondition;
internal class TimelineConditionTargetCount : ITimelineCondition
{
public int Count { get; set; }
public ObjectGetter Getter { get; set; } = new();
public bool IsTrue(TimelineItem item)
{
return Svc.Objects.Count(Getter.CanGet) >= Count;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace RotationSolver.Basic.Configuration.Timeline.TimelineCondition;

public class TrueTimelineCondition : ITimelineCondition
internal class TrueTimelineCondition : ITimelineCondition
{
public bool IsTrue() => true;
public bool IsTrue(TimelineItem item) => true;
}
32 changes: 16 additions & 16 deletions RotationSolver.Basic/Data/TimelineItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ internal enum TimelineType : byte
AddedCombatant,
}

internal struct TimelineItem(float time, string name, TimelineType type, JObject? obj, RaidLangs langs, float? jumpTime, float windowMin, float windowMax)
internal class TimelineItem(float time, string name, TimelineType type, JObject? obj, RaidLangs langs, float? jumpTime, float windowMin, float windowMax)
{
private uint[]? ids = null;

public uint LastActionID { get; set; }
public uint[] ActionIDs => ids ??= GetActionIds();
private readonly uint[] GetActionIds()
private uint[] GetActionIds()
{
if (Type is not TimelineType.Ability and not TimelineType.StartsUsing) return [];
var idsRaw = this["id"];
Expand Down Expand Up @@ -61,7 +61,7 @@ private readonly uint[] GetActionIds()
return [.. reuslt];
}

private readonly RaidLangs.Lang Lang
private RaidLangs.Lang Lang
{
get
{
Expand All @@ -79,15 +79,15 @@ private readonly RaidLangs.Lang Lang
return new RaidLangs.Lang();
}
}
public readonly TimelineType Type => type;
public TimelineType Type => type;

public readonly float Time => time;
public float Time => time;

public readonly float WindowMin => windowMin;
public readonly float WindowMax => windowMax;
public readonly JObject? Object => obj;
public float WindowMin => windowMin;
public float WindowMax => windowMax;
public JObject? Object => obj;

public readonly string Name
public string Name
{
get
{
Expand All @@ -96,14 +96,14 @@ public readonly string Name
}
}

public readonly bool IsInWindow => DataCenter.RaidTimeRaw >= Time - WindowMin && DataCenter.RaidTimeRaw <= Time + WindowMax;
public bool IsInWindow => DataCenter.RaidTimeRaw >= Time - WindowMin && DataCenter.RaidTimeRaw <= Time + WindowMax;

public readonly bool IsShown => Name is not "--Reset--" and not "--sync--";
public bool IsShown => Name is not "--Reset--" and not "--sync--";

public readonly bool this[string propertyName, uint matchValue]
public bool this[string propertyName, uint matchValue]
=> this[propertyName, matchValue.ToString("X")];

public readonly bool this[string propertyName, string matchString]
public bool this[string propertyName, string matchString]
{
get
{
Expand All @@ -124,7 +124,7 @@ public readonly string Name
}
}

public readonly string[] this[string propertyName]
public string[] this[string propertyName]
{
get
{
Expand Down Expand Up @@ -203,7 +203,7 @@ private static TimelineType GetTypeFromName(string type)
}
}

public readonly void UpdateRaidTimeOffset()
public void UpdateRaidTimeOffset()
{
if (Name == "--Reset--")
{
Expand All @@ -222,7 +222,7 @@ public readonly void UpdateRaidTimeOffset()
}
}

public readonly override string ToString()
public override string ToString()
{
return $"""
IsShown: {IsShown},
Expand Down
Loading

0 comments on commit 673dd83

Please sign in to comment.