public override void DayUpdate(int dayOfMonth) { for (int i = itemsToStartSellingTomorrow.Count - 1; i >= 0; i--) { Item tomorrowItem = itemsToStartSellingTomorrow[i]; if (itemsFromPlayerToSell.Count < 11) { bool stacked = false; foreach (Item item in itemsFromPlayerToSell) { if (item.Name.Equals(tomorrowItem.Name) && (item as Object).quality == (tomorrowItem as Object).quality) { item.Stack += tomorrowItem.Stack; stacked = true; break; } } itemsToStartSellingTomorrow.RemoveAt(i); if (!stacked) { itemsFromPlayerToSell.Add(tomorrowItem); } } } base.DayUpdate(dayOfMonth); }
public virtual void ClearNulls() { for (int index = Items.Count - 1; index >= 0; --index) { if (Items[index] == null) { Items.RemoveAt(index); } } }
public virtual void ClearNulls() { for (int i = heldItems.Count - 1; i >= 0; i--) { if (heldItems[i] == null) { heldItems.RemoveAt(i); } } }
public Item TryExtractItem(ContainerNode input, NetObjectList <Item> itemList, int index, int flux) { //Exception for multiple thread collisions Item source = itemList[index]; Item tosend = null; if (source is SObject) { SObject obj = (SObject)source; SObject tosendObject = (SObject)tosend; if (input.CanRecieveItem(source) && !IsEmpty()) { if (obj.Stack <= flux) { tosendObject = obj; itemList.RemoveAt(index); } else { obj.stack.Value -= flux; tosendObject = (SObject)obj.getOne(); tosendObject.stack.Value = flux; } Chest.clearNulls(); return(tosendObject); } } else if (source is Tool) { Tool tool = (Tool)source; Tool tosendTool = (Tool)tosend; if (input.CanRecieveItem(tool)) { tosendTool = tool; itemList.RemoveAt(index); } Chest.clearNulls(); return(tosendTool); } return(null); }
public override bool performToolAction(Tool t, int tileX, int tileY) { if (t is Axe) { Point p = new Point(tileX * 64 + 32, tileY * 64 + 32); for (int i = stumps.Count - 1; i >= 0; i--) { if (stumps[i].getBoundingBox(stumps[i].tile).Contains(p)) { if (stumps[i].performToolAction(t, 1, stumps[i].tile, this)) { stumps.RemoveAt(i); } return(true); } } } return(false); }
public void dumpContents(GameLocation location) { Random r = new Random((int)tileLocation.X + (int)tileLocation.Y + (int)Game1.uniqueIDForThisGame + Game1.CurrentMineLevel); if ((int)coins <= 0 && items.Count <= 0) { if (tileLocation.X % 7f == 0f) { chestType.Value = "Monster"; } else { addContents(r.Next(4, Math.Max(8, Game1.CurrentMineLevel / 10 - 5)), Utility.getUncommonItemForThisMineLevel(Game1.CurrentMineLevel, new Point((int)tileLocation.X, (int)tileLocation.Y))); } } if (items.Count > 0 && !chestType.Equals("Monster") && items.Count >= 1 && (mutex.IsLockHeld() || !playerChest)) { bool isStardrop = items[0] is Object && !(items[0] as Object).bigCraftable && (int)items[0].parentSheetIndex == 434; if (location is FarmHouse) { if ((location as FarmHouse).owner.UniqueMultiplayerID != Game1.player.UniqueMultiplayerID) { Game1.drawObjectDialogue(Game1.content.LoadString("Strings\\Objects:ParsnipSeedPackage_SomeoneElse")); return; } if (!isStardrop) { Game1.player.addQuest(6); Game1.screenOverlayTempSprites.Add(new TemporaryAnimatedSprite("LooseSprites\\Cursors", new Rectangle(128, 208, 16, 16), 200f, 2, 30, new Vector2(Game1.dayTimeMoneyBox.questButton.bounds.Left - 16, Game1.dayTimeMoneyBox.questButton.bounds.Bottom + 8), flicker: false, flipped: false, 1f, 0f, Color.White, 4f, 0f, 0f, 0f, local: true)); } } if (isStardrop) { string stardropName = (location is FarmHouse) ? "CF_Spouse" : "CF_Mines"; if (!Game1.player.mailReceived.Contains(stardropName)) { Game1.player.eatObject(items[0] as Object, overrideFullness: true); Game1.player.mailReceived.Add(stardropName); } items.Clear(); } else { Item item = items[0]; items[0] = null; items.RemoveAt(0); Game1.player.addItemByMenuIfNecessaryElseHoldUp(item); ItemGrabMenu grab_menu; if ((grab_menu = (Game1.activeClickableMenu as ItemGrabMenu)) != null) { ItemGrabMenu itemGrabMenu = grab_menu; itemGrabMenu.behaviorBeforeCleanup = (Action <IClickableMenu>)Delegate.Combine(itemGrabMenu.behaviorBeforeCleanup, (Action <IClickableMenu>) delegate { grab_menu.DropRemainingItems(); }); } } if (Game1.mine != null) { Game1.mine.chestConsumed(); } } if (chestType.Equals("Monster")) { Monster monster = Game1.mine.getMonsterForThisLevel(Game1.CurrentMineLevel, (int)tileLocation.X, (int)tileLocation.Y); Vector2 v = Utility.getVelocityTowardPlayer(new Point((int)tileLocation.X, (int)tileLocation.Y), 8f, Game1.player); monster.xVelocity = v.X; monster.yVelocity = v.Y; location.characters.Add(monster); location.playSound("explosion"); Game1.multiplayer.broadcastSprites(location, new TemporaryAnimatedSprite(362, Game1.random.Next(30, 90), 6, 1, new Vector2(tileLocation.X * 64f, tileLocation.Y * 64f), flicker: false, (Game1.random.NextDouble() < 0.5) ? true : false)); location.objects.Remove(tileLocation); Game1.addHUDMessage(new HUDMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:Chest.cs.12531"), Color.Red, 3500f)); } else { Game1.player.gainExperience(5, 25 + Game1.CurrentMineLevel); } if ((bool)giftbox) { TemporaryAnimatedSprite sprite = new TemporaryAnimatedSprite("LooseSprites\\Giftbox", new Rectangle(0, (int)giftboxIndex * 32, 16, 32), 80f, 11, 1, tileLocation.Value * 64f - new Vector2(0f, 52f), flicker: false, flipped: false, tileLocation.Y / 10000f, 0f, Color.White, 4f, 0f, 0f, 0f) { destroyable = false, holdLastFrame = true }; if (location.netObjects.ContainsKey(tileLocation) && location.netObjects[tileLocation] == this) { Game1.multiplayer.broadcastSprites(location, sprite); location.removeObject(tileLocation, showDestroyedObject: false); } else { location.temporarySprites.Add(sprite); } } }