Simplify Resolvers, move to ClientState.Resolvers namespace

This commit is contained in:
Raymond 2021-07-15 14:28:06 -04:00
parent c3dfe0eb31
commit 53e52dbae3
8 changed files with 110 additions and 84 deletions

View file

@ -1,22 +0,0 @@
namespace Dalamud.Game.ClientState.Actors.Resolvers
{
/// <summary>
/// Base object resolver.
/// </summary>
public abstract class BaseResolver
{
/// <summary>
/// Initializes a new instance of the <see cref="BaseResolver"/> class.
/// </summary>
/// <param name="dalamud">The Dalamud instance.</param>
internal BaseResolver(Dalamud dalamud)
{
this.Dalamud = dalamud;
}
/// <summary>
/// Gets the Dalamud instance.
/// </summary>
private protected Dalamud Dalamud { get; }
}
}

View file

@ -1,31 +0,0 @@
namespace Dalamud.Game.ClientState.Actors.Resolvers
{
/// <summary>
/// This object represents a class or job.
/// </summary>
public class ClassJob : BaseResolver
{
/// <summary>
/// Initializes a new instance of the <see cref="ClassJob"/> class.
/// Set up the ClassJob resolver with the provided ID.
/// </summary>
/// <param name="id">The ID of the classJob.</param>
/// <param name="dalamud">The Dalamud instance.</param>
internal ClassJob(byte id, Dalamud dalamud)
: base(dalamud)
{
this.Id = id;
}
/// <summary>
/// Gets the ID of the ClassJob.
/// </summary>
public uint Id { get; }
/// <summary>
/// Gets GameData linked to this ClassJob.
/// </summary>
public Lumina.Excel.GeneratedSheets.ClassJob GameData =>
this.Dalamud.Data.GetExcelSheet<Lumina.Excel.GeneratedSheets.ClassJob>().GetRow(this.Id);
}
}

View file

@ -1,31 +0,0 @@
namespace Dalamud.Game.ClientState.Actors.Resolvers
{
/// <summary>
/// This object represents a world a character can reside on.
/// </summary>
public class World : BaseResolver
{
/// <summary>
/// Initializes a new instance of the <see cref="World"/> class.
/// Set up the world resolver with the provided ID.
/// </summary>
/// <param name="id">The ID of the world.</param>
/// <param name="dalamud">The Dalamud instance.</param>
internal World(ushort id, Dalamud dalamud)
: base(dalamud)
{
this.Id = id;
}
/// <summary>
/// Gets the ID of the world.
/// </summary>
public uint Id { get; }
/// <summary>
/// Gets GameData linked to this world.
/// </summary>
public Lumina.Excel.GeneratedSheets.World GameData =>
this.Dalamud.Data.GetExcelSheet<Lumina.Excel.GeneratedSheets.World>().GetRow(this.Id);
}
}

View file

@ -0,0 +1,34 @@
using Lumina.Excel;
namespace Dalamud.Game.ClientState.Resolvers
{
/// <summary>
/// This object represents a class or job.
/// </summary>
/// <typeparam name="T">The type of Lumina sheet to resolve.</typeparam>
public class BaseResolver<T> where T : ExcelRow
{
private readonly Dalamud dalamud;
/// <summary>
/// Initializes a new instance of the <see cref="BaseResolver{T}"/> class.
/// </summary>
/// <param name="id">The ID of the classJob.</param>
/// <param name="dalamud">The Dalamud instance.</param>
internal BaseResolver(uint id, Dalamud dalamud)
{
this.dalamud = dalamud;
this.Id = id;
}
/// <summary>
/// Gets the ID to be resolved.
/// </summary>
public uint Id { get; }
/// <summary>
/// Gets GameData linked to this excel row.
/// </summary>
public T GameData => this.dalamud.Data.GetExcelSheet<T>().GetRow(this.Id);
}
}

View file

@ -0,0 +1,19 @@
namespace Dalamud.Game.ClientState.Resolvers
{
/// <summary>
/// This object represents a class or job.
/// </summary>
public class ClassJobResolver : BaseResolver<Lumina.Excel.GeneratedSheets.ClassJob>
{
/// <summary>
/// Initializes a new instance of the <see cref="ClassJobResolver"/> class.
/// Set up the ClassJob resolver with the provided ID.
/// </summary>
/// <param name="id">The ID of the classJob.</param>
/// <param name="dalamud">The Dalamud instance.</param>
internal ClassJobResolver(ushort id, Dalamud dalamud)
: base(id, dalamud)
{
}
}
}

View file

@ -0,0 +1,19 @@
namespace Dalamud.Game.ClientState.Resolvers
{
/// <summary>
/// This object represents a Fate a character can participate in.
/// </summary>
public class FateResolver : BaseResolver<Lumina.Excel.GeneratedSheets.Fate>
{
/// <summary>
/// Initializes a new instance of the <see cref="FateResolver"/> class.
/// Set up the Fate resolver with the provided ID.
/// </summary>
/// <param name="id">The ID of the Fate.</param>
/// <param name="dalamud">The Dalamud instance.</param>
internal FateResolver(ushort id, Dalamud dalamud)
: base(id, dalamud)
{
}
}
}

View file

@ -0,0 +1,19 @@
namespace Dalamud.Game.ClientState.Resolvers
{
/// <summary>
/// This object represents a territory a character can be in.
/// </summary>
public class TerritoryTypeResolver : BaseResolver<Lumina.Excel.GeneratedSheets.TerritoryType>
{
/// <summary>
/// Initializes a new instance of the <see cref="TerritoryTypeResolver"/> class.
/// Set up the territory type resolver with the provided ID.
/// </summary>
/// <param name="id">The ID of the territory type.</param>
/// <param name="dalamud">The Dalamud instance.</param>
internal TerritoryTypeResolver(ushort id, Dalamud dalamud)
: base(id, dalamud)
{
}
}
}

View file

@ -0,0 +1,19 @@
namespace Dalamud.Game.ClientState.Resolvers
{
/// <summary>
/// This object represents a world a character can reside on.
/// </summary>
public class WorldResolver : BaseResolver<Lumina.Excel.GeneratedSheets.World>
{
/// <summary>
/// Initializes a new instance of the <see cref="WorldResolver"/> class.
/// Set up the world resolver with the provided ID.
/// </summary>
/// <param name="id">The ID of the world.</param>
/// <param name="dalamud">The Dalamud instance.</param>
internal WorldResolver(ushort id, Dalamud dalamud)
: base(id, dalamud)
{
}
}
}