public override void HandleMetadata(int x, int y, string metadata)
        {
            string[] data = metadata.Split(' ');
            level = SecurityLevel.GetSecurityLevelByName(data[0]);
            string[] types = data[1].Substring(1, data[1].IndexOf('}')-1).Split(',');
            //Select a type in this chest
            int itemInChest = rng.Next(types.Length);

            string type = types[itemInChest];
            Console.WriteLine("Selected Item " + itemInChest + " it's " + type + " " + types.Length);

            itemInside = ItemEntity.CreateItem(type);
        }
 public override void OnInteract(Entity e)
 {
     if (e is PlayerEntity)
     {
         if (!opened)
         {
             PlayerEntity p = e as PlayerEntity;
             if (this.level <= p.GetSecurityLevel())
             {
                 opened = true;
                 UserInterface.Message("Inside is a " + itemInside.Name + " (Interact again to take)", Color.SkyBlue);
             }
             else
             {
                 UserInterface.Message("You need to be atleast " + level.name + " to use this chest", Color.Red);
             }
         }
         else
         {
             if (itemInside != null)
             {
                 PlayerEntity p = e as PlayerEntity;
                 bool success = p.PickUpItem(itemInside);
                 if (success)
                 {
                     UserInterface.Message("Took " + itemInside.Name, Color.SkyBlue);
                     itemInside = null;
                 }
             }
             else UserInterface.Message("The chest is Empty!", Color.Red);
         }
     }
 }
 public bool PickUpItem(ItemEntity item)
 {
     for (int i = 0; i < 10; i++)
     {
         if (inventory[i] == null)
         {
             inventory[i] = item;
             return true;
         }
     }
     if (this is PlayerEntity) UserInterface.Message("Inventory is full! Drop something");
     return false;
 }