public bool destroyStructure(Vector2 tile)
        {
            Building building = getBuildingAt(tile);

            if (building != null)
            {
                building.performActionOnDemolition(this);
                buildings.Remove(building);
                return(true);
            }
            return(false);
        }
示例#2
0
 public bool OnDonatedItemWithdrawn(ISalable salable, Farmer who, int amount)
 {
     if (salable is Item && (salable.Stack <= 0 || salable.maximumStackSize() <= 1))
     {
         returnedDonations.Remove(salable as Item);
     }
     return(false);
 }
示例#3
0
        private void ClearAndSaveTempObelisks(List <DesertObelisk> saveData)
        {
            saveData.Clear();

            NetCollection <Building> buildings = Game1.getFarm().buildings;
            List <DesertObelisk>     copied    = new List <DesertObelisk>();

            copied.AddRange(buildings.Where(item => item is DesertObelisk).OfType <DesertObelisk>());
            saveData.AddRange(copied);

            foreach (DesertObelisk obelisk in copied)
            {
                buildings.Remove(obelisk);
            }
        }
        public Item TryExtractItem(ContainerNode input, NetCollection <Item> itemList)
        {
            //Exception for multiple thread collisions
            Item source = itemList.Last();
            Item tosend = null;

            if (source is SObject)
            {
                SObject obj          = (SObject)source;
                SObject tosendObject = (SObject)tosend;
                if (input.CanRecieveItem(source))
                {
                    tosendObject = obj;
                    itemList.Remove(itemList.Last());
                    Farm.lastItemShipped = itemList.Last();
                    if (itemList.Count == 1)
                    {
                        Farm.lastItemShipped = null;
                    }
                    else
                    {
                        Farm.lastItemShipped = itemList.Last();
                    }
                    return(tosendObject);
                }
            }
            else if (source is Tool)
            {
                /*
                 * Tool tool = (Tool)source;
                 * Tool tosendTool = (Tool)tosend;
                 * if (input.CanRecieveItems())
                 * {
                 *  tosendTool = tool;
                 *  itemList.RemoveAt(index);
                 * }
                 * Chest.clearNulls();
                 */
                return(null);
            }
            return(null);
        }
示例#5
0
        protected virtual void removeQueuedFurniture(Guid guid)
        {
            Farmer who = Game1.player;

            if (!furniture.ContainsGuid(guid))
            {
                return;
            }
            Furniture furnitureItem = furniture[guid];

            if (!who.couldInventoryAcceptThisItem(furnitureItem))
            {
                return;
            }
            furnitureItem.performRemoveAction(furnitureItem.tileLocation, this);
            furniture.Remove(guid);
            bool foundInToolbar = false;

            for (int i = 0; i < 12; i++)
            {
                if (who.items[i] == null)
                {
                    who.items[i]         = furnitureItem;
                    who.CurrentToolIndex = i;
                    foundInToolbar       = true;
                    break;
                }
            }
            if (!foundInToolbar)
            {
                Item item = who.addItemToInventory(furnitureItem, 11);
                who.addItemToInventory(item);
                who.CurrentToolIndex = 11;
            }
            localSound("coin");
        }