public void RevivePossibleBags() { int reviveCount = 0; FarmHouse house = Game1.getLocationFromName("FarmHouse") as FarmHouse; foreach (BagDumpInfo bagInfo in this.DumpedBags) { Vector2 position = new Vector2(bagInfo.posX, bagInfo.posY); if (!house.objects.TryGetValue(position, out StardewValley.Object obj) && !(obj is Chest)) { this.Monitor.Log($"Bag at position ${position} can't be revived!", LogLevel.Warn); continue; } Chest chest = obj as Chest; DumpedBag bag = new DumpedBag(chest.items.ToList(), position, 0) { GivenFrom = bagInfo.source, Message = bagInfo.message }; house.objects[position] = bag; reviveCount++; this.Monitor.Log($"Revive dumpedBag on position ${bag.TileLocation} (Items count: {bag.items.Count})"); } this.Monitor.Log($"Revived {reviveCount} dumped bags!", LogLevel.Info); }
public void DumpBagInFarmHouse() { FarmHouse farm = (FarmHouse)Game1.getLocationFromName("FarmHouse"); Vector2 place = Utility.PointToVector2(farm.getRandomOpenPointInHouse(Game1.random)); DumpedBag dumpedBag = new DumpedBag(this.Bag.items.ToList(), place); dumpedBag.GivenFrom = this.Name; dumpedBag.Message = this.ContentLoader.LoadString("Strings/Strings:bagItemsSentLetter", this.CompanionManager.Farmer.Name, this.Companion.displayName); farm.objects.Add(place, dumpedBag); this.Bag = new Chest(true); this.Monitor.Log($"{this.Companion} delivered bag contents into farm house at position {place}"); }