public void MoveItemsIntoNearbyWarehouse(ItemType[] items)
 {
     foreach (var i in items)
     {
         var warehouse = handle.Get4Connected().FirstOrDefault(v => v.Data.Type is WarehouseType && v.Data.Inventory.AvailableSlots > 0);
         if (warehouse == null)
         {
             return;
         }
         warehouse.Data.Inventory.AddNewItems(i, 1);
     }
 }
Example #2
0
 /// <summary>
 /// Returns true when given voxel borders to the town (so not in the town)
 /// </summary>
 public bool IsAtBorder(IVoxel voxel)
 {
     if (townVoxels.Contains(voxel))
     {
         return(false);
     }
     if (!townVoxels.Overlaps(voxel.Get4Connected()))
     {
         return(false);
     }
     return(true);
 }
 public static IEnumerable <IVoxel> GetRoads(IVoxel voxel)
 {
     return(voxel.Get4Connected().Where(v => v.Data.Type is RoadType));
 }
Example #4
0
 public static IEnumerable <IVoxel> GetConnectedWarehouses(IVoxel voxel)
 {
     return(voxel.Get4Connected().Where(v => v.Data.Type is WarehouseType));
 }
        public override void OnCreated(IVoxel handle)
        {
            var minHeight = handle.Get4Connected().Min(e => e.Data.Height);

            handle.Data.Height = minHeight;
        }
 /// <summary>
 /// Return order: (1,0) (0,1) (-1,0) (0,-1)
 /// </summary>
 /// <returns></returns>
 public IEnumerable <IVoxelHandle> Get4Connected()
 {
     return(currentVoxel.Get4Connected().Cast <IVoxelHandle>());
 }