/// <summary>Get whether to prevent stacking the given item.</summary> /// <param name="item">The item to check.</param> private static bool ShouldPreventStacking(ISalable item) { return (ChestHelper.IsSupported(item) && item is Chest chest && chest.items.Count != 0); }
/********* ** Private methods *********/ /// <summary>The method to call before <see cref="SObject.getDescription"/>.</summary> private static void After_GetDescription(SObject __instance, ref string __result) { if (ChestHelper.IsSupported(__instance)) { var chest = __instance as Chest; __result += "\n" + $"Contains {chest?.items?.Count ?? 0} items."; } }
/// <summary>Raised after the player presses a button on the keyboard, controller, or mouse.</summary> /// <param name="sender">The event sender.</param> /// <param name="e">The event arguments.</param> private void OnButtonPressed(object sender, ButtonPressedEventArgs e) { if (!Context.IsPlayerFree) { return; } // pick up clicked chest if (e.Button == SButton.MouseLeft && Game1.player.CurrentItem == null) { GameLocation location = Game1.currentLocation; Vector2 tile = e.Cursor.Tile; if (location.objects.TryGetValue(tile, out SObject obj) && ChestHelper.IsSupported(obj) && Game1.player.addItemToInventoryBool(obj, true)) { location.objects.Remove(tile); this.Helper.Input.Suppress(e.Button); } } }