mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +01:00
Merge pull request #93 from karashiiro/minor-tweaks
Implement IReadOnlyCollection on PartyList, see #92
This commit is contained in:
commit
b1202d4be7
1 changed files with 16 additions and 7 deletions
|
|
@ -10,9 +10,8 @@ using System.Text;
|
|||
using System.Threading.Tasks;
|
||||
|
||||
namespace Dalamud.Game.ClientState
|
||||
|
||||
{
|
||||
public class PartyList : ICollection, IDisposable
|
||||
public class PartyList : IReadOnlyCollection<PartyMember>, ICollection, IDisposable
|
||||
{
|
||||
private ClientStateAddressResolver Address { get; }
|
||||
private Dalamud dalamud;
|
||||
|
|
@ -73,7 +72,7 @@ namespace Dalamud.Game.ClientState
|
|||
}
|
||||
}
|
||||
|
||||
private class PartyListEnumerator : IEnumerator
|
||||
private class PartyListEnumerator : IEnumerator<PartyMember>
|
||||
{
|
||||
private readonly PartyList party;
|
||||
private int currentIndex;
|
||||
|
|
@ -83,8 +82,6 @@ namespace Dalamud.Game.ClientState
|
|||
party = list;
|
||||
}
|
||||
|
||||
public object Current => party[currentIndex];
|
||||
|
||||
public bool MoveNext()
|
||||
{
|
||||
currentIndex++;
|
||||
|
|
@ -95,15 +92,27 @@ namespace Dalamud.Game.ClientState
|
|||
{
|
||||
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 GetEnumerator()
|
||||
{
|
||||
public IEnumerator<PartyMember> GetEnumerator() {
|
||||
return new PartyListEnumerator(this);
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator() {
|
||||
return GetEnumerator();
|
||||
}
|
||||
|
||||
public int Length => !this.isReady ? 0 : Marshal.ReadByte(partyListBegin + 0xF0);
|
||||
|
||||
int IReadOnlyCollection<PartyMember>.Count => Length;
|
||||
|
||||
public int Count => Length;
|
||||
|
||||
public object SyncRoot => this;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue