public StockpileStep(Path path, Carryable toDropOff, Building stockpile, FullTask parentList) : base(path, parentList, TaskType.PUT_DOWN) { this.ToDropOff = toDropOff; this.WhereToPlace = stockpile; this.endPoint = path.End; if (Path.Start != StartPoint) throw new ArgumentException("Path doesn't start where we picked up the item!"); }
public PickupStep(Path path, FullTask parentList, Carryable item) : base(path, parentList, TaskType.PICK_UP) { this.ToPickUp = item; if (path != null) { this.startPoint = path.Start; if (path.End != EndPoint) throw new ArgumentException("The path doesn't end at the item we're picking up!"); } else { this.startPoint = item.SquareCoordinate; } }
/// <summary> /// Gets an object, and does with it as appropriate based on the state of the building /// and the specific square. /// </summary> /// <param name="worldX"></param> /// <param name="worldY"></param> /// <param name="worldObject"></param> public void ReceiveObject(int worldX, int worldY, Carryable worldObject, FullTask marker) { if (!this.ContainsSquare(worldX, worldY)) throw new ArgumentOutOfRangeException("This building does not contain the specified cell!"); int localX = worldX - XMin; int localY = worldY - YMin; if (squareAvailabilityModes[localX, localY] != BuildingAvailabilityType.MARKED) throw new NotImplementedException("Can't send an object without marking the square first."); switch (squareActionModes[localX, localY]) { case BuildingInteractionType.STORAGE: if (!IsSquareMarkedByAndFor(worldX, worldY, marker, BuildingInteractionType.STORAGE)) throw new InvalidOperationException("Cell is not marked for storage by this marker, so cannot be used for storage by this marker!"); if (!IsSquareMarkedByAndFor(worldX, worldY, marker, BuildingInteractionType.STORAGE)) throw new InvalidOperationException("Can't occupy without marking!"); SetSquareState(worldX, worldY, BuildingInteractionType.STORAGE, BuildingAvailabilityType.IN_USE); occupants[localX, localY] = worldObject; worldObject.GetPutInStockpile(this); break; case BuildingInteractionType.LOAD_BUILDING_MATERIALS: if (!IsSquareMarkedByAndFor(worldX, worldY, marker, BuildingInteractionType.LOAD_BUILDING_MATERIALS)) throw new InvalidOperationException("Wrong marker or coordinate."); materials[localX, localY, materialIndices[localX, localY]] = worldObject; materialIndices[localX, localY]++; worldObject.GetUsedAsMaterial(); if (materialIndices[localX, localY] == NumberOfMaterialsPerSquare) this.SetSquareState(worldX, worldY, BuildingInteractionType.BUILD, BuildingAvailabilityType.AVAILABLE); else this.SetSquareState(worldX, worldY, BuildingInteractionType.LOAD_BUILDING_MATERIALS, BuildingAvailabilityType.AVAILABLE); break; default: throw new NotImplementedException("Unclear how to receive an object in state " + squareActionModes[localX, localY]); } }