mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +01:00
IObjectTable Helpful Enumerables (#2328)
* Add ObjectTable Enumerables * Put kind check on the correct function
This commit is contained in:
parent
58fbff7c56
commit
bf5fcaaf00
2 changed files with 72 additions and 0 deletions
|
|
@ -66,6 +66,24 @@ internal sealed partial class ObjectTable : IServiceType, IObjectTable
|
|||
/// <inheritdoc/>
|
||||
public int Length => objectTableLength;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public IEnumerable<IBattleChara> PlayerObjects => this.GetPlayerObjects();
|
||||
|
||||
/// <inheritdoc/>
|
||||
public IEnumerable<IGameObject> CharacterManagerObjects => this.GetObjectsInRange(..199);
|
||||
|
||||
/// <inheritdoc/>
|
||||
public IEnumerable<IGameObject> ClientObjects => this.GetObjectsInRange(200..448);
|
||||
|
||||
/// <inheritdoc/>
|
||||
public IEnumerable<IGameObject> EventObjects => this.GetObjectsInRange(449..488);
|
||||
|
||||
/// <inheritdoc/>
|
||||
public IEnumerable<IGameObject> StandObjects => this.GetObjectsInRange(489..628);
|
||||
|
||||
/// <inheritdoc/>
|
||||
public IEnumerable<IGameObject> ReactionEventObjects => this.GetObjectsInRange(629..728);
|
||||
|
||||
/// <inheritdoc/>
|
||||
public IGameObject? this[int index]
|
||||
{
|
||||
|
|
@ -146,6 +164,28 @@ internal sealed partial class ObjectTable : IServiceType, IObjectTable
|
|||
};
|
||||
}
|
||||
|
||||
private IEnumerable<IBattleChara> GetPlayerObjects()
|
||||
{
|
||||
for (var index = 0; index < 200; index += 2)
|
||||
{
|
||||
if (this[index] is IBattleChara { ObjectKind: ObjectKind.Player } gameObject)
|
||||
{
|
||||
yield return gameObject;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerable<IGameObject> GetObjectsInRange(Range range)
|
||||
{
|
||||
for (var index = range.Start.Value; index <= range.End.Value; index++)
|
||||
{
|
||||
if (this[index] is { } gameObject)
|
||||
{
|
||||
yield return gameObject;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Stores an object table entry, with preallocated concrete types.</summary>
|
||||
/// <remarks>Initializes a new instance of the <see cref="CachedEntry"/> struct.</remarks>
|
||||
/// <param name="gameObjectPtr">A pointer to the object table entry this entry should be pointing to.</param>
|
||||
|
|
|
|||
|
|
@ -19,6 +19,38 @@ public interface IObjectTable : IEnumerable<IGameObject>
|
|||
/// </summary>
|
||||
public int Length { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets an enumerator for accessing player objects. This will only contain BattleChara objects.
|
||||
/// Does not contain any mounts, minions, or accessories.
|
||||
/// </summary>
|
||||
public IEnumerable<IBattleChara> PlayerObjects { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets an enumerator for accessing character manager objects. Contains all objects in indexes [0, 199].
|
||||
/// Includes mounts, minions, accessories, and players.
|
||||
/// </summary>
|
||||
public IEnumerable<IGameObject> CharacterManagerObjects { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets an enumerator for accessing client objects. Contains all objects in indexes [200, 448].
|
||||
/// </summary>
|
||||
public IEnumerable<IGameObject> ClientObjects { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets an enumerator for accessing event objects. Contains all objects in indexes [449, 488].
|
||||
/// </summary>
|
||||
public IEnumerable<IGameObject> EventObjects { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets an enumerator for accessing stand objects. Contains all objects in indexes [489, 628].
|
||||
/// </summary>
|
||||
public IEnumerable<IGameObject> StandObjects { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets an enumerator for accessing reaction event objects. Contains all objects in indexes [629, 728].
|
||||
/// </summary>
|
||||
public IEnumerable<IGameObject> ReactionEventObjects { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Get an object at the specified spawn index.
|
||||
/// </summary>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue