mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-02-19 22:37:43 +01:00
Merge pull request #120 from Caraxi/fix-actortable-enumerator
This commit is contained in:
commit
ca1ed75cf3
2 changed files with 10 additions and 55 deletions
|
|
@ -85,34 +85,12 @@ namespace Dalamud.Game.ClientState.Actors {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ActorTableEnumerator : IEnumerator<Actor> {
|
|
||||||
private readonly ActorTable table;
|
|
||||||
|
|
||||||
private int currentIndex;
|
|
||||||
|
|
||||||
public ActorTableEnumerator(ActorTable table) {
|
|
||||||
this.table = table;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool MoveNext() {
|
|
||||||
this.currentIndex++;
|
|
||||||
return this.currentIndex != this.table.Length;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Reset() {
|
|
||||||
this.currentIndex = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Actor Current => this.table[this.currentIndex];
|
|
||||||
|
|
||||||
object IEnumerator.Current => Current;
|
|
||||||
|
|
||||||
// Required by IEnumerator<T> even though we have nothing we want to dispose here.
|
|
||||||
public void Dispose() {}
|
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerator<Actor> GetEnumerator() {
|
public IEnumerator<Actor> GetEnumerator() {
|
||||||
return new ActorTableEnumerator(this);
|
for (int i=0;i<Length;i++){
|
||||||
|
if (this[i] != null) {
|
||||||
|
yield return this[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IEnumerator IEnumerable.GetEnumerator() {
|
IEnumerator IEnumerable.GetEnumerator() {
|
||||||
|
|
|
||||||
|
|
@ -73,37 +73,14 @@ namespace Dalamud.Game.ClientState
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class PartyListEnumerator : IEnumerator<PartyMember>
|
public IEnumerator<PartyMember> GetEnumerator() {
|
||||||
{
|
for (var i = 0; i < Length; i++) {
|
||||||
private readonly PartyList party;
|
if (this[i] != null) {
|
||||||
private int currentIndex;
|
yield return this[i];
|
||||||
|
}
|
||||||
public PartyListEnumerator(PartyList list)
|
|
||||||
{
|
|
||||||
this.party = list;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool MoveNext()
|
|
||||||
{
|
|
||||||
this.currentIndex++;
|
|
||||||
return this.currentIndex != this.party.Length;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Reset()
|
|
||||||
{
|
|
||||||
this.currentIndex = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PartyMember Current => this.party[this.currentIndex];
|
|
||||||
|
|
||||||
object IEnumerator.Current => Current;
|
|
||||||
|
|
||||||
// Required by IEnumerator<T> even though we have nothing we want to dispose here.
|
|
||||||
public void Dispose() {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerator<PartyMember> GetEnumerator() => new PartyListEnumerator(this);
|
|
||||||
|
|
||||||
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
||||||
|
|
||||||
public int Length => !this.isReady ? 0 : Marshal.ReadByte(partyListBegin + 0xF0);
|
public int Length => !this.isReady ? 0 : Marshal.ReadByte(partyListBegin + 0xF0);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue