IObjectTable Helpful Enumerables (#2328)

* Add ObjectTable Enumerables

* Put kind check on the correct function
This commit is contained in:
MidoriKami 2025-08-04 15:47:39 -07:00 committed by GitHub
parent 58fbff7c56
commit bf5fcaaf00
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 72 additions and 0 deletions

View file

@ -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>