- using System;
- using System.Collections.Generic;
- namespace WowMoPObjMgrTest
- {
- class ObjectManager : IEnumerable<WowObject>
- {
- private IntPtr BaseAddress;
- private const int s_curMgr = 0x00BE1D2C;
- private const int FirstObjectOfs = 0xC;
- private const int NextObjectOfs = 0x4;
- //const int FirstObjectOfs = 0xCC;
- //const int NextObjectOfs = 0xC4;
- private const int LocalGuidOfs = 0xD0;
- public ObjectManager()
- {
- IntPtr objMgrPtr = Memory.BaseAddress + s_curMgr;
- BaseAddress = Memory.Read<IntPtr>(objMgrPtr);
- }
- public ulong LocalGuid
- {
- get { return Memory.Read<ulong>(BaseAddress + LocalGuidOfs); }
- }
- public IntPtr FirstObject()
- {
- return Memory.Read<IntPtr>(BaseAddress + FirstObjectOfs);
- }
- public IntPtr NextObject(IntPtr current)
- {
- return Memory.Read<IntPtr>(current + Memory.Read<int>(BaseAddress + NextObjectOfs) + 4);
- }
- System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
- {
- return GetEnumerator();
- }
- public IEnumerator<WowObject> GetEnumerator()
- {
- IntPtr first = FirstObject();
- while (((first.ToInt64() & 1) == 0) && first != IntPtr.Zero)
- {
- yield return new WowObject(first);
- first = NextObject(first);
- }
- }
- }
- }