using System.Collections.Generic; using CustomNPCFramework.Framework.ModularNpcs; using CustomNPCFramework.Framework.ModularNpcs.ModularRenderers; using Microsoft.Xna.Framework; using StardewValley; namespace CustomNPCFramework.Framework.NPCS { /// Extended merchant npc from ExtendedNPC. class MerchantNpc : ExtendedNpc { /// The list of items this npc has for sale. public List stock; /// Construct an instance. /// The list of items this npc will sell. /// The sprite for the npc to use. /// The renderer for the npc to use. /// The position for the npc to use. /// The facing direction for the player to face. /// The name for the npc. public MerchantNpc(List Stock, Sprite sprite, BasicRenderer renderer, Vector2 position, int facingDirection, string name) : base(sprite, renderer, position, facingDirection, name) { this.stock = Stock; } /// Construct an instance. /// The list of items for the npc to sell. /// The npc base for the character to be expanded upon. public MerchantNpc(List Stock, ExtendedNpc npcBase) : base(npcBase.spriteInformation, npcBase.characterRenderer, npcBase.portraitInformation, npcBase.position, npcBase.facingDirection, npcBase.Name) { this.stock = Stock; } /// Used to interact with the npc. When interacting pulls up a shop menu for the npc with their current stock. public override bool checkAction(Farmer who, GameLocation l) { if (Game1.activeClickableMenu == null) { Game1.activeClickableMenu = new StardewValley.Menus.ShopMenu(this.stock); return true; } else { return base.checkAction(Game1.player, Game1.player.currentLocation); } } } }