From 8aac4499fc16fbbc6208825082511fc8962f9489 Mon Sep 17 00:00:00 2001 From: Mohammad Shoaib Khan Date: Sat, 29 Oct 2022 14:41:41 +0530 Subject: [PATCH] Added dropped item detection --- stardew-access/Features/TileInfo.cs | 22 ++++++++++++++++++++++ stardew-access/Features/Utils.cs | 3 +++ 2 files changed, 25 insertions(+) diff --git a/stardew-access/Features/TileInfo.cs b/stardew-access/Features/TileInfo.cs index 0194b8f..b1833a0 100644 --- a/stardew-access/Features/TileInfo.cs +++ b/stardew-access/Features/TileInfo.cs @@ -1,4 +1,5 @@ using Microsoft.Xna.Framework; +using Netcode; using StardewValley; using StardewValley.Buildings; using StardewValley.Locations; @@ -148,6 +149,27 @@ namespace stardew_access.Features category = CATEGORY.JunimoBundle; } + #region Track dropped items + NetCollection droppedItems = Game1.currentLocation.debris; + if (droppedItems.Count() > 0) + { + foreach (var item in droppedItems) + { + int xPos = ((int)item.Chunks[0].position.Value.X / Game1.tileSize) + 1; + int yPos = ((int)item.Chunks[0].position.Value.Y / Game1.tileSize) + 1; + if (xPos != x || yPos != y) continue; + + string name = item.item.DisplayName; + int count = item.item.Stack; + + if (toReturn == "") + return ($"Dropped Item: {count} {name}", CATEGORY.DroppedItems); + else + toReturn = $"{toReturn}, Dropped Item: {count} {name}"; + } + } + #endregion + if (toReturn == "") return (null, category); diff --git a/stardew-access/Features/Utils.cs b/stardew-access/Features/Utils.cs index f8d6945..51a222a 100644 --- a/stardew-access/Features/Utils.cs +++ b/stardew-access/Features/Utils.cs @@ -59,6 +59,8 @@ namespace stardew_access.Features return CATEGORY.Machines; else if (name == "bridge") return CATEGORY.Bridges; + else if (name == "dropped item") + return CATEGORY.DroppedItems; else if (name == "other") return CATEGORY.Others; @@ -85,6 +87,7 @@ namespace stardew_access.Features public static CATEGORY Decor = new CATEGORY("decoration"); public static CATEGORY Machines = new CATEGORY("machine"); public static CATEGORY Bridges = new CATEGORY("bridge"); + public static CATEGORY DroppedItems = new CATEGORY("dropped item"); public static CATEGORY Others = new CATEGORY("other"); }