Exemplo n.º 1
0
        public void AddItem(int x, int y, ItemObject itemObject)
        {
            GameLog.DebugFormat("{0}, {1}, {2} qty {3} id {4}",
                                x, y, itemObject.Name, itemObject.Count, itemObject.Id);
            if (itemObject.Id == 0)
            {
                World.Insert(itemObject);
            }

            if (itemObject == null)
            {
                GameLog.DebugFormat("ItemObject is null, aborting");
                return;
            }
            // Add the ItemObject to the world at the given location.
            itemObject.X   = (byte)x;
            itemObject.Y   = (byte)y;
            itemObject.Map = this;
            lock (_lock)
            {
                EntityTree.Add(itemObject);
                Objects.Add(itemObject);
            }
            NotifyNearbyAoiEntry(itemObject);
        }
Exemplo n.º 2
0
        public void Insert(VisibleObject obj, byte x, byte y, bool updateClient = true)
        {
            lock (_lock)
            {
                if (Objects.Add(obj))
                {
                    obj.Map = this;
                    obj.X   = x;
                    obj.Y   = y;

                    EntityTree.Add(obj);

                    var user = obj as User;
                    if (user != null)
                    {
                        if (updateClient)
                        {
                            obj.SendMapInfo();
                            obj.SendLocation();
                        }
                        Users.Add(user.Name, user);
                    }

                    var affectedObjects = EntityTree.GetObjects(obj.GetViewport());

                    foreach (var target in affectedObjects)
                    {
                        target.AoiEntry(obj);
                        obj.AoiEntry(target);
                    }
                }
            }
        }
Exemplo n.º 3
0
 public void AddItem(int x, int y, Item item)
 {
     Logger.DebugFormat("{0}, {1}, {2} qty {3} id {4}",
                        x, y, item.Name, item.Count, item.Id);
     if (item == null)
     {
         Logger.DebugFormat("Item is null, aborting");
         return;
     }
     // Add the item to the world at the given location.
     item.X   = (byte)x;
     item.Y   = (byte)y;
     item.Map = this;
     EntityTree.Add(item);
     Objects.Add(item);
     NotifyNearbyAoiEntry(item);
 }
Exemplo n.º 4
0
 public void AddGold(int x, int y, Gold gold)
 {
     Logger.DebugFormat("{0}, {1}, {2} qty {3} id {4}",
                        x, y, gold.Name, gold.Amount, gold.Id);
     if (gold == null)
     {
         Logger.DebugFormat("Item is null, aborting");
         return;
     }
     // Add the gold to the world at the given location.
     gold.X   = (byte)x;
     gold.Y   = (byte)y;
     gold.Map = this;
     EntityTree.Add(gold);
     Objects.Add(gold);
     NotifyNearbyAoiEntry(gold);
 }