public ScavengerTabViewModel()
 {
     ScavengerManager manager = ScavengerManager.GetInstance();
     manager.Items = Items;
     manager.CheckArea = () => Task.Run( CheckArea );
     _ignoreList = new List<int>();
 }
Beispiel #2
0
        public void WillScavengerEnabled()
        {
            ScavengerTabViewModel vm = new ScavengerTabViewModel {
                Enabled = true
            };
            ScavengerManager manager = ScavengerManager.GetInstance();

            if (!Directory.Exists(@"C:\Program Files (x86)\Electronic Arts\Ultima Online Classic"))
            {
                return;
            }

            TileData.Initialize(@"C:\Program Files (x86)\Electronic Arts\Ultima Online Classic");
            Engine.Player = new PlayerMobile(0x0)
            {
                WeightMax = 500
            };
            Engine.Player.SetLayer(Layer.Backpack, 0x40000001);
            manager.Items.Add(new ScavengerEntry {
                Enabled = true, Graphic = 0xff, Hue = -1, Name = "Test"
            });

            Engine.Items.Add(new Item(0x40000001)
            {
                Container = new ItemCollection(0x4000001)
            });
            Engine.Items.Add(new Item(0x40000000)
            {
                ID = 0xff
            });

            AutoResetEvent are = new AutoResetEvent(false);

            void OnInternalPacketSentEvent(byte[] data, int length)
            {
                if (data[0] == 0x07)
                {
                    are.Set();
                }
            }

            Engine.InternalPacketSentEvent += OnInternalPacketSentEvent;

            vm.CheckArea();

            bool result = are.WaitOne(5000);

            if (!result)
            {
                Assert.Fail();
            }

            Engine.InternalPacketSentEvent -= OnInternalPacketSentEvent;
            Engine.Player = null;
            Engine.Items.Clear();
            manager.Items.Clear();
        }
Beispiel #3
0
        private static void OnPlayerPositionChanged(int x, int y, int z)
        {
            if (Player != null)
            {
                Player.X = x;
                Player.Y = y;
                Player.Z = z;
            }

            Items.RemoveByDistance(MAX_DISTANCE, x, y);
            Mobiles.RemoveByDistance(MAX_DISTANCE, x, y);
            ScavengerManager.GetInstance().CheckArea?.Invoke();
        }
        public void WontScavengerEntryDisabled()
        {
            ScavengerTabViewModel vm = new ScavengerTabViewModel {
                Enabled = true
            };
            ScavengerManager manager = ScavengerManager.GetInstance();

            Engine.Player = new PlayerMobile(0x0)
            {
                WeightMax = 500
            };
            Engine.Player.SetLayer(Layer.Backpack, 0x40000001);
            manager.Items.Add(new ScavengerEntry {
                Enabled = false, Graphic = 0xff, Hue = -1, Name = "Test"
            });

            Engine.Items.Add(new Item(0x40000001)
            {
                Container = new ItemCollection(0x4000001)
            });
            Engine.Items.Add(new Item(0x40000000)
            {
                ID = 0xff
            });

            AutoResetEvent are = new AutoResetEvent(false);

            void OnInternalPacketSentEvent(byte[] data, int length)
            {
                if (data[0] == 0x07)
                {
                    Assert.Fail();
                }
            }

            Engine.InternalPacketSentEvent += OnInternalPacketSentEvent;

            vm.CheckArea();

            bool result = are.WaitOne(500);

            Engine.InternalPacketSentEvent -= OnInternalPacketSentEvent;
            Engine.Player = null;
            Engine.Items.Clear();
            manager.Items.Clear();
        }
        public void WillScavengerPriority()
        {
            ScavengerTabViewModel vm = new ScavengerTabViewModel {
                Enabled = true
            };
            ScavengerManager manager = ScavengerManager.GetInstance();

            Engine.Player = new PlayerMobile(0x0)
            {
                WeightMax = 500
            };
            Engine.Player.SetLayer(Layer.Backpack, 0x40000001);
            manager.Items.Add(new ScavengerEntry
            {
                Enabled  = true,
                Graphic  = 0xee,
                Hue      = -1,
                Name     = "Test",
                Priority = ScavengerPriority.Normal
            });
            manager.Items.Add(new ScavengerEntry
            {
                Enabled  = true,
                Graphic  = 0xff,
                Hue      = -1,
                Name     = "Test",
                Priority = ScavengerPriority.High
            });

            Engine.Items.Add(new Item(0x40000001)
            {
                Container = new ItemCollection(0x4000001)
            });
            Engine.Items.Add(new Item(0x40000000)
            {
                ID = 0xee
            });
            Engine.Items.Add(new Item(0x40000002)
            {
                ID = 0xff
            });

            AutoResetEvent are = new AutoResetEvent(false);

            bool found = false;

            void OnInternalPacketSentEvent(byte[] data, int length)
            {
                if (data[0] != 0x07)
                {
                    return;
                }

                int serial = (data[1] << 24) | (data[2] << 16) | (data[3] << 8) | data[4];

                if (serial != 0x40000002 && !found)
                {
                    Assert.Fail();
                }
                else
                {
                    found = true;
                }

                are.Set();
            }

            Engine.InternalPacketSentEvent += OnInternalPacketSentEvent;

            vm.CheckArea();

            bool result = are.WaitOne(5000);

            if (!result)
            {
                Assert.Fail();
            }

            Engine.InternalPacketSentEvent -= OnInternalPacketSentEvent;
            Engine.Player = null;
            Engine.Items.Clear();
            manager.Items.Clear();
        }