private void DestroyObject(Vector2 key) { StardewValley.Object @object = Game1.currentLocation.objects[key]; @object.performRemoveAction((Vector2)(NetFieldBase <Vector2, NetVector2>)@object.tileLocation, Game1.currentLocation); @object.dropItem(Game1.currentLocation, new Vector2(key.X * 64f, key.Y * 64f), new Vector2(key.X * 64f, key.Y * 64f)); Game1.currentLocation.Objects.Remove(key); }
public DonateFishMenuAndroid(IModHelper helper, IMonitor monitor) : base(new Dictionary <ISalable, int[]>()) { //look android forced me to do this terrible thing don't judge me just pretend they're not static Donated = AchievementUnlock = PufferchickDonated = false; /* * why do i have a whole custom class for something that gets immediately replaced by a vanilla one by smapi? bc screw u * ( initial concept was to keep harmony targeting and menu detection clean without using an NPC name but like, idk anymore lmao ) * I'll come back and readdress this someday probably, when I have more sanity to spend. I'm all out atm */ List <int> fishes = Utils.GetUndonatedFishInInventory().Distinct().ToList(); if (fishes.Count == 0) { return; } foreach (int fish in fishes) { Object display = new StardewValley.Object(fish, 1); donations.Add(display, new int[] { 0, 1, fish, 1 }); } setItemPriceAndStock(donations); }
public static void Desert_getDesertMerchantTradeStock_Postfix(Farmer who, ref Dictionary <ISalable, int[]> __result) { try { if (who != null && who.getFriendshipHeartLevelForNPC("Krobus") >= 10 && !who.friendshipData["Krobus"].RoommateMarriage && who.HouseUpgradeLevel >= 1 && (who.isMarried() || who.isEngaged()) && !who.hasItemInInventory(808, 1, 0)) { ISalable i = new StardewValley.Object(808, 1, false, -1, 0); __result.Add(i, new int[] { 0, 1, 769, 200 }); } } catch (Exception ex) { Monitor.Log($"Failed in {nameof(Desert_getDesertMerchantTradeStock_Postfix)}:\n{ex}", LogLevel.Error); } }
public ConsumedItem(StardewValley.Object theItem) { item = theItem; amt = item.Stack; }
/// <summary>Raised after objects are added or removed in a location.</summary> /// <param name="sender">The event sender.</param> /// <param name="e">The event data.</param> private void OnObjectListChanged(object sender, ObjectListChangedEventArgs e) { if (!this._config.DoHarvestTruffles) { return; } if (!e.Location.Name.Equals("Farm", StringComparison.InvariantCultureIgnoreCase)) { return; } var truffles = e.Added.Where(x => x.Value.Name.Equals("Truffle", StringComparison.InvariantCultureIgnoreCase)).ToList(); if (truffles.Count == 0) { return; } StardewValley.Object grabber = null; // Try to find global grabber var globalForageMap = Game1.getLocationFromName(_config.GlobalForageMap); globalForageMap?.Objects.TryGetValue(new Vector2(_config.GlobalForageTileX, _config.GlobalForageTileY), out grabber); // No global grabber if (grabber == null || !grabber.Name.Contains("Grabber")) { grabber = e.Location.Objects.Values.FirstOrDefault(x => x.Name.Contains("Grabber")); if (grabber == null) { return; } } grabber.showNextIndex.Value = true; if (!(grabber.heldObject.Value is Chest chest)) { return; } // Pick up truffles foreach (var truffle in truffles) { if (chest.items.Count >= 36) { Monitor.Log($"Can't grab truffle: Auto-grabber inventory full."); break; } if (Game1.player.professions.Contains(16)) { truffle.Value.Quality = 4; } else if (Game1.random.NextDouble() < (double)Game1.player.ForagingLevel / 30.0) { truffle.Value.Quality = 2; } else if (Game1.random.NextDouble() < (double)Game1.player.ForagingLevel / 15.0) { truffle.Value.Quality = 1; } if (truffle.Value.Stack == 0) { truffle.Value.Stack = 1; } if (Game1.player.professions.Contains(13)) { while (Game1.random.NextDouble() < 0.2) { truffle.Value.Stack += 1; } } base.Monitor.Log($"Grabbing truffle: {truffle.Value.Stack}x{this._qualityStrings[truffle.Value.Quality]}", LogLevel.Trace); chest.addItem(truffle.Value); e.Location.Objects.Remove(truffle.Key); if (this._config.DoGainExperience) { this.gainExperience(Farmer.foragingSkill, 7); } } }