1. using System;
  2. namespace WowMoPObjMgrTest
  3. {
  4. class WowObject
  5. {
  6. private IntPtr BaseAddress;
  7. private const int DescriptorsOfs = 0x8;
  8. private const int ObjTypeOfs = 0x10;
  9. private const int ObjGuidOfs = 0x30;
  10. public WowObject(IntPtr address)
  11. {
  12. BaseAddress = address;
  13. }
  14. public IntPtr Pointer
  15. {
  16. get { return BaseAddress; }
  17. }
  18. public WowObjectType Type
  19. {
  20. get { return (WowObjectType)Memory.Read<int>(BaseAddress + ObjTypeOfs); }
  21. }
  22. public ulong Guid
  23. {
  24. get { return Memory.Read<ulong>(BaseAddress + ObjGuidOfs); }
  25. }
  26. public ulong VisibleGuid
  27. {
  28. get { return GetDescriptor<ulong>(ObjectFields.Guid); }
  29. }
  30. public int Entry
  31. {
  32. get { return GetDescriptor<int>(ObjectFields.Entry); }
  33. }
  34. public float Scale
  35. {
  36. get { return GetDescriptor<float>(ObjectFields.Scale); }
  37. }
  38. public T GetDescriptor<T>(Enum index) where T : struct
  39. {
  40. return Memory.Read<T>(Memory.Read<IntPtr>(BaseAddress + DescriptorsOfs) + Convert.ToInt32(index) * 4);
  41. }
  42. public bool IsA(WowObjectTypeFlags flags)
  43. {
  44. return (GetDescriptor<int>(ObjectFields.Type) & (int)flags) != 0;
  45. }
  46. }
  47. }