public void RegisterSession(NetworkClient clientSession)
 {
     Session = (ClientSession)clientSession;
 }
Example #2
0
        public MapItem PutItem(PocketType type, short slot, short amount, ref ItemInstance inv, ClientSession session)
        {
            Guid           random2       = Guid.NewGuid();
            MapItem        droppedItem   = null;
            List <MapCell> possibilities = new List <MapCell>();

            for (short x = -2; x < 3; x++)
            {
                for (short y = -2; y < 3; y++)
                {
                    possibilities.Add(new MapCell {
                        X = x, Y = y
                    });
                }
            }

            short mapX     = 0;
            short mapY     = 0;
            var   niceSpot = false;

            foreach (MapCell possibility in possibilities.OrderBy(s => ServerManager.Instance.RandomNumber()))
            {
                mapX = (short)(session.Character.PositionX + possibility.X);
                mapY = (short)(session.Character.PositionY + possibility.Y);
                if (!Map.IsWalkable(Map[mapX, mapY]))
                {
                    continue;
                }
                niceSpot = true;
                break;
            }

            if (!niceSpot)
            {
                return(null);
            }
            if (amount <= 0 || amount > inv.Amount)
            {
                return(null);
            }
            var newItemInstance = inv.Clone();

            newItemInstance.Id     = random2;
            newItemInstance.Amount = amount;
            droppedItem            = new MapItem {
                MapInstance = this, VNum = newItemInstance.ItemVNum, PositionX = mapX, PositionY = mapY, Amount = amount
            };
            DroppedList[droppedItem.VisualId] = droppedItem;
            inv.Amount -= amount;
            return(droppedItem);
        }
Example #3
0
 internal void RegisterSession(ClientSession clientSession)
 {
     Sessions.Add(clientSession);
 }