예제 #1
0
        public void UpdateObject(WowObjectType wowObjectType, IntPtr baseAddress)
        {
            WowObjects.RemoveAll(e => e.BaseAddress == baseAddress);
            switch (wowObjectType)
            {
            case WowObjectType.Gameobject:
                WowObjects.Add(ReadWowGameobject(baseAddress, wowObjectType));
                break;

            case WowObjectType.Dynobject:
                WowObjects.Add(ReadWowDynobject(baseAddress, wowObjectType));
                break;

            case WowObjectType.Unit:
                WowObjects.Add(ReadWowUnit(baseAddress, wowObjectType));
                break;

            case WowObjectType.Player:
                WowObjects.Add(ReadWowPlayer(baseAddress, wowObjectType));
                break;

            default:
                WowObjects.Add(ReadWowObject(baseAddress, wowObjectType));
                break;
            }
        }
예제 #2
0
        public void UpdateWowObjects()
        {
            IsWorldLoaded = UpdateGlobalVar <int>(WowInterface.OffsetList.IsWorldLoaded) == 1;

            if (!IsWorldLoaded)
            {
                return;
            }

            PlayerGuid     = UpdateGlobalVar <ulong>(WowInterface.OffsetList.PlayerGuid);
            TargetGuid     = UpdateGlobalVar <ulong>(WowInterface.OffsetList.TargetGuid);
            LastTargetGuid = UpdateGlobalVar <ulong>(WowInterface.OffsetList.LastTargetGuid);
            PetGuid        = UpdateGlobalVar <ulong>(WowInterface.OffsetList.PetGuid);

            PlayerBase = UpdateGlobalVar <IntPtr>(WowInterface.OffsetList.PlayerBase);

            MapId = UpdateGlobalVar <MapId>(WowInterface.OffsetList.MapId);

            ZoneId = UpdateGlobalVar <int>(WowInterface.OffsetList.ZoneId);

            if (WowInterface.XMemory.Read(WowInterface.OffsetList.ZoneText, out IntPtr zoneNamePointer))
            {
                ZoneName = UpdateGlobalVarString(zoneNamePointer);
            }

            if (WowInterface.XMemory.Read(WowInterface.OffsetList.ZoneSubText, out IntPtr zoneSubNamePointer))
            {
                ZoneSubName = UpdateGlobalVarString(zoneSubNamePointer);
            }

            GameState = UpdateGlobalVarString(WowInterface.OffsetList.GameState);

            WowObjects.Clear();

            // get the current objectmanager
            // TODO: maybe cache it
            WowInterface.XMemory.Read(WowInterface.OffsetList.ClientConnection, out IntPtr clientConnection);
            WowInterface.XMemory.Read(IntPtr.Add(clientConnection, WowInterface.OffsetList.CurrentObjectManager.ToInt32()), out IntPtr currentObjectManager);

            // read the first object
            WowInterface.XMemory.Read(IntPtr.Add(currentObjectManager, WowInterface.OffsetList.FirstObject.ToInt32()), out IntPtr activeObjectBaseAddress);
            WowInterface.XMemory.Read(IntPtr.Add(activeObjectBaseAddress, WowInterface.OffsetList.WowObjectType.ToInt32()), out int activeObjectType);

            while (IsWorldLoaded && (activeObjectType <= 7 && activeObjectType > 0))
            {
                WowObjectType wowObjectType = (WowObjectType)activeObjectType;
                WowObject     obj           = wowObjectType switch
                {
                    WowObjectType.Container => ReadWowContainer(activeObjectBaseAddress, wowObjectType),
                    WowObjectType.Corpse => ReadWowCorpse(activeObjectBaseAddress, wowObjectType),
                    WowObjectType.Item => ReadWowItem(activeObjectBaseAddress, wowObjectType),
                    WowObjectType.Dynobject => ReadWowDynobject(activeObjectBaseAddress, wowObjectType),
                    WowObjectType.Gameobject => ReadWowGameobject(activeObjectBaseAddress, wowObjectType),
                    WowObjectType.Player => ReadWowPlayer(activeObjectBaseAddress, wowObjectType),
                    WowObjectType.Unit => ReadWowUnit(activeObjectBaseAddress, wowObjectType),
                    _ => ReadWowObject(activeObjectBaseAddress, wowObjectType),
                };

                if (obj != null)
                {
                    WowObjects.Add(obj);

                    // set the global unit properties if a guid matches it
                    if (obj.Guid == TargetGuid)
                    {
                        Target = (WowUnit)obj;
                    }
                    if (obj.Guid == PetGuid)
                    {
                        Pet = (WowUnit)obj;
                    }
                    if (obj.Guid == LastTargetGuid)
                    {
                        LastTarget = (WowUnit)obj;
                    }
                }

                WowInterface.XMemory.Read(IntPtr.Add(activeObjectBaseAddress, WowInterface.OffsetList.NextObject.ToInt32()), out activeObjectBaseAddress);
                WowInterface.XMemory.Read(IntPtr.Add(activeObjectBaseAddress, WowInterface.OffsetList.WowObjectType.ToInt32()), out activeObjectType);
            }

            // read the party/raid leaders guid and if there is one, the group too
            PartyleaderGuid = ReadPartyLeaderGuid();
            if (PartyleaderGuid > 0)
            {
                PartymemberGuids = ReadPartymemberGuids();
            }

            OnObjectUpdateComplete?.Invoke(WowObjects);
        }