public void Update(MemoryContext ctx)
        {
            if (ctx == null)
            {
                throw new ArgumentNullException(nameof(ctx));
            }
            ctx.Memory.Reader.ResetCounters();
            try
            {
                if (!IsLocalActorValid(ctx))
                {
                    return;
                }

                if (!IsObjectManagerOnNewFrame(ctx))
                {
                    return;
                }

                var itemsToAdd    = new List <IMapMarker>();
                var itemsToRemove = new List <IMapMarker>();

                _acdsObserver = _acdsObserver ?? new ContainerCache <ACD>(ctx.DataSegment.ObjectManager.ACDManager.ActorCommonData);
                _acdsObserver.Update();

                // Must have a local ACD to base coords on.
                if (_playerAcd == null)
                {
                    var playerAcdId = ctx.DataSegment.ObjectManager.PlayerDataManager[
                        ctx.DataSegment.ObjectManager.Player.LocalPlayerIndex].ACDID;

                    _playerAcd = _acdsObserver.Items[(short)playerAcdId];
                }

                foreach (var acd in _acdsObserver.OldItems)
                {
                    var marker = default(IMapMarker);
                    if (_minimapItemsDic.TryGetValue(acd.Address, out marker))
                    {
                        Trace.WriteLine("Removing " + acd.Name);
                        itemsToRemove.Add(marker);
                    }
                }

                foreach (var acd in _acdsObserver.NewItems)
                {
                    var actorSnoId = acd.ActorSNO;
                    if (_ignoredSnoIds.Contains(actorSnoId))
                    {
                        continue;
                    }

                    if (!_minimapItemsDic.ContainsKey(acd.Address))
                    {
                        bool ignore;
                        var  minimapItem = MapMarkerFactory.Create(acd, out ignore);
                        if (ignore)
                        {
                            _ignoredSnoIds.Add(actorSnoId);
                        }
                        else if (minimapItem != null)
                        {
                            _minimapItemsDic.Add(acd.Address, minimapItem);
                            itemsToAdd.Add(minimapItem);
                        }
                    }
                }

                UpdateUI(itemsToAdd, itemsToRemove);
            }
            catch (Exception exception)
            {
                OnUpdateException(exception);
            }
        }
示例#2
0
        public void Update(MemoryContext ctx)
        {
            if (ctx == null)
            {
                throw new ArgumentNullException(nameof(ctx));
            }
            ctx.Memory.Reader.ResetCounters();
            try
            {
                if (!IsLocalActorValid(ctx))
                {
                    return;
                }

                if (!IsObjectManagerOnNewFrame(ctx))
                {
                    return;
                }

                var itemsToAdd    = new List <IMapMarker>();
                var itemsToRemove = new List <IMapMarker>();

                _acdsObserver = _acdsObserver ?? new ContainerCache <ACD>(ctx.DataSegment.ObjectManager.ACDManager.ActorCommonData);
                _acdsObserver.Update();

                // Must have a local ACD to base coords on.
                if (_playerAcd == null)
                {
                    var playerAcdId = ctx.DataSegment.ObjectManager.PlayerDataManager[
                        ctx.DataSegment.ObjectManager.Player.LocalPlayerIndex].ACDID;

                    _playerAcd = _acdsObserver.Items[(short)playerAcdId];
                }


                foreach (var acd in ctx.DataSegment.ObjectManager.ACDManager.ActorCommonData)
                {
                    Console.WriteLine(acd.Name);

                    if (!((acd.MonsterQuality == MonsterQuality.Champion) || (acd.MonsterQuality == MonsterQuality.Rare) || (acd.MonsterQuality == MonsterQuality.Boss)))
                    {
                        continue;
                    }



                    if (WindowsInput.InputSimulator.IsKeyDown(VirtualKeyCode.TAB))
                    {
                        System.Drawing.Point MouseCords = D3ToScreen.FromD3toScreenCoords(acd.Position, _playerAcd.Position);
                        if ((MouseCords.X > 0 && MouseCords.Y > 0) && (MouseCords.X < System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width && MouseCords.Y < System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height))
                        {
                            SetCursorPos(MouseCords.X, MouseCords.Y);
                            Thread.Sleep(600);
                        }
                        //System.Windows.MessageBox.Show("X " + MouseCords.X);
                    }
                }
            }
            catch (Exception exception)
            {
                OnUpdateException(exception);
            }
        }