From 67c110f282ed44258577080215e03f178e3c121a Mon Sep 17 00:00:00 2001 From: Date: Tue, 20 Mar 2018 03:10:02 -0700 Subject: [PATCH] attempted rough implementation of farmers market. Needs a lot more work before rough prototype would be complete. --- GeneralMods/CustomNPCFramework/Class1.cs | 5 ++ GeneralMods/FarmersMarketStall/Class1.cs | 55 ++++++++++++++++ .../FarmersMarketStall.csproj | 65 +++++++++++++++++++ .../MapEvents/ShopInteractionEvent.cs | 48 ++++++++++++++ .../Framework/MarketStall.cs | 39 +++++++++++ .../Framework/Menus/MarketStallMenu.cs | 25 +++++++ .../Properties/AssemblyInfo.cs | 36 ++++++++++ GeneralMods/FarmersMarketStall/manifest.json | 16 +++++ .../FarmersMarketStall/packages.config | 4 ++ GeneralMods/StardewMods.sln | 10 +++ 10 files changed, 303 insertions(+) create mode 100644 GeneralMods/FarmersMarketStall/Class1.cs create mode 100644 GeneralMods/FarmersMarketStall/FarmersMarketStall.csproj create mode 100644 GeneralMods/FarmersMarketStall/Framework/MapEvents/ShopInteractionEvent.cs create mode 100644 GeneralMods/FarmersMarketStall/Framework/MarketStall.cs create mode 100644 GeneralMods/FarmersMarketStall/Framework/Menus/MarketStallMenu.cs create mode 100644 GeneralMods/FarmersMarketStall/Properties/AssemblyInfo.cs create mode 100644 GeneralMods/FarmersMarketStall/manifest.json create mode 100644 GeneralMods/FarmersMarketStall/packages.config diff --git a/GeneralMods/CustomNPCFramework/Class1.cs b/GeneralMods/CustomNPCFramework/Class1.cs index 4a96a29d..5d57d1e0 100644 --- a/GeneralMods/CustomNPCFramework/Class1.cs +++ b/GeneralMods/CustomNPCFramework/Class1.cs @@ -19,7 +19,10 @@ using System.Threading.Tasks; namespace CustomNPCFramework { /// + /// BETA VERSION 0.1.0: Lots of ways this can be improved upon. /// TODO: + /// + /// /// List all asset managers in use. /// Have all asset managers list what assets they are using. /// @@ -39,6 +42,8 @@ namespace CustomNPCFramework /// -Collect a bunch of assets together to test this thing. /// /// Find way to make sideways shirts render correctly. + /// + ///Get suggestions from modding community on requests and ways to improve the mod. /// diff --git a/GeneralMods/FarmersMarketStall/Class1.cs b/GeneralMods/FarmersMarketStall/Class1.cs new file mode 100644 index 00000000..036a74a5 --- /dev/null +++ b/GeneralMods/FarmersMarketStall/Class1.cs @@ -0,0 +1,55 @@ +using EventSystem.Framework.FunctionEvents; +using FarmersMarketStall.Framework.MapEvents; +using Microsoft.Xna.Framework; +using StardewModdingAPI; +using StardewValley; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FarmersMarketStall +{ + + /// + /// TODO: + /// Make a farmers market menu + /// MAke a way to store items to sell in a sort of inventory + /// Make a map event to call the farmers market stall menu + /// Make way to sell market items at a higher value + /// Make a selling menu + /// Make a minigame event for bonus money to earn. + /// + /// + + public class Class1 :Mod + { + + public static IModHelper ModHelper; + public static IMonitor ModMonitor; + public static FarmersMarketStall.Framework.MarketStall marketStall; + public override void Entry(IModHelper helper) + { + ModHelper = Helper; + ModMonitor = Monitor; + + StardewModdingAPI.Events.SaveEvents.BeforeSave += SaveEvents_BeforeSave; + StardewModdingAPI.Events.SaveEvents.AfterLoad += SaveEvents_AfterLoad; + marketStall = new Framework.MarketStall(); + } + + private void SaveEvents_AfterLoad(object sender, EventArgs e) + { + EventSystem.EventSystem.eventManager.addEvent(Game1.getLocationFromName("BusStop"), new ShopInteractionEvent("FarmersMarketStall", Game1.getLocationFromName("BusStop"), new Vector2(6, 11), new MouseButtonEvents(null, true), new MouseEntryLeaveEvent(null, null))); + } + + private void SaveEvents_BeforeSave(object sender, EventArgs e) + { + if (marketStall.stock.Count > 0) { + // Game1.endOfNightMenus.Push(new StardewValley.Menus.ShippingMenu(marketStall.stock)); + marketStall.sellAllItems(); + } + } + } +} diff --git a/GeneralMods/FarmersMarketStall/FarmersMarketStall.csproj b/GeneralMods/FarmersMarketStall/FarmersMarketStall.csproj new file mode 100644 index 00000000..6f34f346 --- /dev/null +++ b/GeneralMods/FarmersMarketStall/FarmersMarketStall.csproj @@ -0,0 +1,65 @@ + + + + + Debug + AnyCPU + {0E37BE57-6B3C-4C79-A134-D16283D5306D} + Library + Properties + FarmersMarketStall + FarmersMarketStall + v4.6.1 + 512 + + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\MapEvents\bin\Release\EventSystem.dll + + + + + + + + + + + + + + + + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + \ No newline at end of file diff --git a/GeneralMods/FarmersMarketStall/Framework/MapEvents/ShopInteractionEvent.cs b/GeneralMods/FarmersMarketStall/Framework/MapEvents/ShopInteractionEvent.cs new file mode 100644 index 00000000..25fbd4b1 --- /dev/null +++ b/GeneralMods/FarmersMarketStall/Framework/MapEvents/ShopInteractionEvent.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using EventSystem; +using EventSystem.Framework.FunctionEvents; +using Microsoft.Xna.Framework; +using StardewValley; + +namespace FarmersMarketStall.Framework.MapEvents +{ + public class ShopInteractionEvent :EventSystem.Framework.MapEvent + { + public ShopInteractionEvent(string Name, GameLocation Location, Vector2 Position, MouseButtonEvents MouseEvents, MouseEntryLeaveEvent EntryLeave) : base(Name, Location, Position) + { + this.name = Name; + this.location = Location; + this.tilePosition = Position; + this.mouseButtonEvents = MouseEvents; + + this.doesInteractionNeedToRun = true; + + this.mouseEntryLeaveEvents = EntryLeave; + } + + + public override bool OnLeftClick() + { + if (base.OnLeftClick() == false) return false; + if (this.location.isObjectAt((int)this.tilePosition.X * Game1.tileSize, (int)this.tilePosition.Y * Game1.tileSize)) return false; + Game1.activeClickableMenu = Menus.MarketStallMenu.openMenu(Class1.marketStall); + return true; + } + + /// + /// Used to update the event and check for interaction. + /// + public override void update() + { + this.clickEvent(); + //Needed for updating. + this.OnMouseEnter(); + this.OnMouseLeave(); + } + + } +} diff --git a/GeneralMods/FarmersMarketStall/Framework/MarketStall.cs b/GeneralMods/FarmersMarketStall/Framework/MarketStall.cs new file mode 100644 index 00000000..c043bcf6 --- /dev/null +++ b/GeneralMods/FarmersMarketStall/Framework/MarketStall.cs @@ -0,0 +1,39 @@ +using StardewValley; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FarmersMarketStall.Framework +{ + public class MarketStall + { + public List stock; + + public MarketStall() + { + + } + + public void addItemToSell(Item item) + { + this.stock.Add(item); + } + + public void removeItemFromStock(Item item) + { + this.stock.Remove(item); + } + + public void sellAllItems() + { + foreach(var item in stock) + { + Game1.player.money+=(int)(item.salePrice() * 1.10f); //Replace the multiplier with some sort of level. + } + this.stock.Clear(); + } + + } +} diff --git a/GeneralMods/FarmersMarketStall/Framework/Menus/MarketStallMenu.cs b/GeneralMods/FarmersMarketStall/Framework/Menus/MarketStallMenu.cs new file mode 100644 index 00000000..104bd0de --- /dev/null +++ b/GeneralMods/FarmersMarketStall/Framework/Menus/MarketStallMenu.cs @@ -0,0 +1,25 @@ +using StardewValley; +using StardewValley.Menus; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FarmersMarketStall.Framework.Menus +{ + class MarketStallMenu + { + public MarketStallMenu(MarketStall marketStall) + { + openMenu(marketStall); + } + + public static IClickableMenu openMenu(MarketStall marketStall) + { + return null; + //return new StardewValley.Menus.InventoryMenu((int)(Game1.viewport.Width*.25f),(int)(Game1.viewport.Height*.25f),true,marketStall.stock); + } + + } +} diff --git a/GeneralMods/FarmersMarketStall/Properties/AssemblyInfo.cs b/GeneralMods/FarmersMarketStall/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..63738cde --- /dev/null +++ b/GeneralMods/FarmersMarketStall/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("FarmersMarketStall")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("FarmersMarketStall")] +[assembly: AssemblyCopyright("Copyright © 2018")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("0e37be57-6b3c-4c79-a134-d16283d5306d")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/GeneralMods/FarmersMarketStall/manifest.json b/GeneralMods/FarmersMarketStall/manifest.json new file mode 100644 index 00000000..c6ed000c --- /dev/null +++ b/GeneralMods/FarmersMarketStall/manifest.json @@ -0,0 +1,16 @@ +{ + "Name": "FarmersMarketStall", + "Author": "Alpha_Omegasis", + "Version": "0.1.0", + "Description": "A system to add a farmers market stall to Sundrop.", + "UniqueID": "SunDrop.SunDropMapEvents.FarmersMarketStall", + "EntryDll": "FarmersMarketStall.dll", + "MinimumApiVersion": "2.0", + "UpdateKeys": [ ], + "Dependencies": [ + { + "UniqueID": "Omegasis.EventSystem", + "IsRequired": true + } +] +} diff --git a/GeneralMods/FarmersMarketStall/packages.config b/GeneralMods/FarmersMarketStall/packages.config new file mode 100644 index 00000000..33db9a9b --- /dev/null +++ b/GeneralMods/FarmersMarketStall/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/GeneralMods/StardewMods.sln b/GeneralMods/StardewMods.sln index 62058292..9183f418 100644 --- a/GeneralMods/StardewMods.sln +++ b/GeneralMods/StardewMods.sln @@ -79,6 +79,11 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SundropMapEvents", "Sundrop EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CustomNPCFramework", "CustomNPCFramework\CustomNPCFramework.csproj", "{89C7DF45-8AE5-49AC-ADA9-6312E9590829}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FarmersMarketStall", "FarmersMarketStall\FarmersMarketStall.csproj", "{0E37BE57-6B3C-4C79-A134-D16283D5306D}" + ProjectSection(ProjectDependencies) = postProject + {BB737337-2D82-4245-AA46-F3B82FC6F228} = {BB737337-2D82-4245-AA46-F3B82FC6F228} + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -185,6 +190,10 @@ Global {89C7DF45-8AE5-49AC-ADA9-6312E9590829}.Debug|Any CPU.Build.0 = Debug|Any CPU {89C7DF45-8AE5-49AC-ADA9-6312E9590829}.Release|Any CPU.ActiveCfg = Release|Any CPU {89C7DF45-8AE5-49AC-ADA9-6312E9590829}.Release|Any CPU.Build.0 = Release|Any CPU + {0E37BE57-6B3C-4C79-A134-D16283D5306D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0E37BE57-6B3C-4C79-A134-D16283D5306D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0E37BE57-6B3C-4C79-A134-D16283D5306D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0E37BE57-6B3C-4C79-A134-D16283D5306D}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -195,6 +204,7 @@ Global {BAAC8F21-C12F-42B0-A51C-0C5F33B52575} = {3EE26DA0-0337-4991-8B02-BCB8D408008C} {29A68F94-B23C-442B-8867-8B8F3502E64F} = {BAAC8F21-C12F-42B0-A51C-0C5F33B52575} {89C7DF45-8AE5-49AC-ADA9-6312E9590829} = {3EE26DA0-0337-4991-8B02-BCB8D408008C} + {0E37BE57-6B3C-4C79-A134-D16283D5306D} = {3EE26DA0-0337-4991-8B02-BCB8D408008C} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {4135247C-1326-43F4-A762-3916E50635EF}