diff --git a/GeneralMods/CustomNPCFramework/Class1.cs b/GeneralMods/CustomNPCFramework/Class1.cs index 83bccc2a..8407027f 100644 --- a/GeneralMods/CustomNPCFramework/Class1.cs +++ b/GeneralMods/CustomNPCFramework/Class1.cs @@ -108,7 +108,11 @@ namespace CustomNPCFramework private void SaveEvents_LoadChar(object sender, EventArgs e) { ExtendedNPC myNpc3 = assetPool.generateNPC(Genders.female, 0, 1); - npcTracker.addNewNPCToLocation(Game1.getLocationFromName("BusStop", false), myNpc3); + MerchantNPC merch = new MerchantNPC(new List() + { + new StardewValley.Object(475,999) + }, myNpc3); + npcTracker.addNewNPCToLocation(Game1.getLocationFromName("BusStop", false), merch); } public void initializeExamples() diff --git a/GeneralMods/CustomNPCFramework/CustomNPCFramework.csproj b/GeneralMods/CustomNPCFramework/CustomNPCFramework.csproj index 254d76b4..5562b56b 100644 --- a/GeneralMods/CustomNPCFramework/CustomNPCFramework.csproj +++ b/GeneralMods/CustomNPCFramework/CustomNPCFramework.csproj @@ -65,6 +65,7 @@ + diff --git a/GeneralMods/CustomNPCFramework/Framework/NPCS/ExtendedNPC.cs b/GeneralMods/CustomNPCFramework/Framework/NPCS/ExtendedNPC.cs index dc249bf2..9289d832 100644 --- a/GeneralMods/CustomNPCFramework/Framework/NPCS/ExtendedNPC.cs +++ b/GeneralMods/CustomNPCFramework/Framework/NPCS/ExtendedNPC.cs @@ -49,7 +49,10 @@ namespace CustomNPCFramework.Framework.NPCS this.Portrait = (Texture2D)null; this.portraitInformation = null; this.spriteInformation = sprite; - this.spriteInformation.setCharacterSpriteFromThis(this); + if (this.spriteInformation != null) + { + this.spriteInformation.setCharacterSpriteFromThis(this); + } this.swimming = false; } @@ -57,7 +60,10 @@ namespace CustomNPCFramework.Framework.NPCS { this.characterRenderer = null; this.portraitInformation = portrait; - this.portraitInformation.setCharacterPortraitFromThis(this); + if (this.portraitInformation != null) + { + this.portraitInformation.setCharacterPortraitFromThis(this); + } this.spriteInformation = sprite; this.spriteInformation.setCharacterSpriteFromThis(this); this.swimming = false; diff --git a/GeneralMods/CustomNPCFramework/Framework/NPCS/MerchantNPC.cs b/GeneralMods/CustomNPCFramework/Framework/NPCS/MerchantNPC.cs new file mode 100644 index 00000000..3570d378 --- /dev/null +++ b/GeneralMods/CustomNPCFramework/Framework/NPCS/MerchantNPC.cs @@ -0,0 +1,39 @@ +using CustomNPCFramework.Framework.ModularNPCS; +using CustomNPCFramework.Framework.ModularNPCS.ModularRenderers; +using Microsoft.Xna.Framework; +using StardewValley; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CustomNPCFramework.Framework.NPCS +{ + class MerchantNPC: ExtendedNPC + { + public List stock; + public MerchantNPC(List Stock, Sprite sprite, BasicRenderer renderer,Vector2 position,int facingDirection,string name): base(sprite,renderer,position,facingDirection,name) + { + this.stock = Stock; + } + + public MerchantNPC(List Stock, ExtendedNPC npcBase): base(npcBase.spriteInformation, npcBase.portraitInformation, npcBase.position, npcBase.facingDirection, npcBase.name) + { + this.stock = Stock; + } + + public override bool checkAction(StardewValley.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); + } + } + } +}