From 11fca7dd6a1c7b5950f089bed7990d9af33d7999 Mon Sep 17 00:00:00 2001 From: Joshua Navarro Date: Thu, 20 Dec 2018 13:34:08 -0800 Subject: [PATCH 01/72] Started work on Revitalize, the final mod compilation. --- .../CustomFurnitureFramework/Class1.cs | 19 +++ .../CustomFurnitureFramework.csproj | 62 ++++++++ .../Properties/AssemblyInfo.cs | 36 +++++ .../CustomFurnitureFramework/packages.config | 4 + GeneralMods/CustomObjectFramework/App.config | 6 + .../CustomObjectFramework.csproj | 52 +++++++ GeneralMods/CustomObjectFramework/Program.cs | 15 ++ .../Properties/AssemblyInfo.cs | 36 +++++ .../Framework/Graphics/Texture2DExtended.cs | 81 ++++++++++ .../Framework/Objects/BasicItemInformation.cs | 63 ++++++++ .../Framework/Objects/CustomObject.cs | 146 ++++++++++++++++++ GeneralMods/Revitalize/ModCore.cs | 47 ++++++ .../Revitalize/Properties/AssemblyInfo.cs | 36 +++++ GeneralMods/Revitalize/Revitalize.csproj | 69 +++++++++ GeneralMods/Revitalize/manifest.json | 10 ++ GeneralMods/Revitalize/packages.config | 4 + GeneralMods/StardewMods.sln | 14 ++ 17 files changed, 700 insertions(+) create mode 100644 GeneralMods/CustomFurnitureFramework/Class1.cs create mode 100644 GeneralMods/CustomFurnitureFramework/CustomFurnitureFramework.csproj create mode 100644 GeneralMods/CustomFurnitureFramework/Properties/AssemblyInfo.cs create mode 100644 GeneralMods/CustomFurnitureFramework/packages.config create mode 100644 GeneralMods/CustomObjectFramework/App.config create mode 100644 GeneralMods/CustomObjectFramework/CustomObjectFramework.csproj create mode 100644 GeneralMods/CustomObjectFramework/Program.cs create mode 100644 GeneralMods/CustomObjectFramework/Properties/AssemblyInfo.cs create mode 100644 GeneralMods/Revitalize/Framework/Graphics/Texture2DExtended.cs create mode 100644 GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs create mode 100644 GeneralMods/Revitalize/Framework/Objects/CustomObject.cs create mode 100644 GeneralMods/Revitalize/ModCore.cs create mode 100644 GeneralMods/Revitalize/Properties/AssemblyInfo.cs create mode 100644 GeneralMods/Revitalize/Revitalize.csproj create mode 100644 GeneralMods/Revitalize/manifest.json create mode 100644 GeneralMods/Revitalize/packages.config diff --git a/GeneralMods/CustomFurnitureFramework/Class1.cs b/GeneralMods/CustomFurnitureFramework/Class1.cs new file mode 100644 index 00000000..b81717cd --- /dev/null +++ b/GeneralMods/CustomFurnitureFramework/Class1.cs @@ -0,0 +1,19 @@ +using StardewModdingAPI; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using PyTK; +using PyTK.CustomElementHandler; + +namespace CustomFurnitureFramework +{ + public class Class1 : Mod + { + public override void Entry(IModHelper helper) + { + + } + } +} diff --git a/GeneralMods/CustomFurnitureFramework/CustomFurnitureFramework.csproj b/GeneralMods/CustomFurnitureFramework/CustomFurnitureFramework.csproj new file mode 100644 index 00000000..9fb3791b --- /dev/null +++ b/GeneralMods/CustomFurnitureFramework/CustomFurnitureFramework.csproj @@ -0,0 +1,62 @@ + + + + + Debug + AnyCPU + {2FA81A17-D9A1-46D9-A5F7-A76AF9C70526} + Library + Properties + CustomFurnitureFramework + CustomFurnitureFramework + v4.6.1 + 512 + + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + + + + + + 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/CustomFurnitureFramework/Properties/AssemblyInfo.cs b/GeneralMods/CustomFurnitureFramework/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..4b409a25 --- /dev/null +++ b/GeneralMods/CustomFurnitureFramework/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("CustomFurnitureFramework")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("CustomFurnitureFramework")] +[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("2fa81a17-d9a1-46d9-a5f7-a76af9c70526")] + +// 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/CustomFurnitureFramework/packages.config b/GeneralMods/CustomFurnitureFramework/packages.config new file mode 100644 index 00000000..84563214 --- /dev/null +++ b/GeneralMods/CustomFurnitureFramework/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/GeneralMods/CustomObjectFramework/App.config b/GeneralMods/CustomObjectFramework/App.config new file mode 100644 index 00000000..731f6de6 --- /dev/null +++ b/GeneralMods/CustomObjectFramework/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/GeneralMods/CustomObjectFramework/CustomObjectFramework.csproj b/GeneralMods/CustomObjectFramework/CustomObjectFramework.csproj new file mode 100644 index 00000000..9f4e4e1d --- /dev/null +++ b/GeneralMods/CustomObjectFramework/CustomObjectFramework.csproj @@ -0,0 +1,52 @@ + + + + + Debug + AnyCPU + {901B46C9-38B6-469F-BB2F-E1BE2B770FC0} + Exe + CustomObjectFramework + CustomObjectFramework + v4.6.1 + 512 + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/GeneralMods/CustomObjectFramework/Program.cs b/GeneralMods/CustomObjectFramework/Program.cs new file mode 100644 index 00000000..2691193e --- /dev/null +++ b/GeneralMods/CustomObjectFramework/Program.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CustomObjectFramework +{ + class Program + { + static void Main(string[] args) + { + } + } +} diff --git a/GeneralMods/CustomObjectFramework/Properties/AssemblyInfo.cs b/GeneralMods/CustomObjectFramework/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..30da100b --- /dev/null +++ b/GeneralMods/CustomObjectFramework/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("CustomObjectFramework")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("CustomObjectFramework")] +[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("901b46c9-38b6-469f-bb2f-e1be2b770fc0")] + +// 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/Revitalize/Framework/Graphics/Texture2DExtended.cs b/GeneralMods/Revitalize/Framework/Graphics/Texture2DExtended.cs new file mode 100644 index 00000000..af6d4499 --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Graphics/Texture2DExtended.cs @@ -0,0 +1,81 @@ +using Microsoft.Xna.Framework.Graphics; +using StardewModdingAPI; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Revitalize.Framework.Graphics +{ + public class Texture2DExtended + { + public string Name; + public Texture2D texture; + public string path; + IModHelper helper; + public string modID; + public ContentSource source; + + /// + /// Empty/null constructor. + /// + public Texture2DExtended() + { + this.Name = ""; + this.texture = null; + this.path = ""; + this.helper = null; + this.modID = ""; + } + + /// + /// Constructor. + /// + /// The relative path to file on disk. See StardustCore.Utilities.getRelativePath(modname,path); + public Texture2DExtended(IModHelper helper, IManifest manifest, string path, ContentSource contentSource = ContentSource.ModFolder) + { + this.Name = Path.GetFileNameWithoutExtension(path); + this.path = path; + this.texture = helper.Content.Load(path, contentSource); + this.helper = helper; + this.modID = manifest.UniqueID; + this.source = contentSource; + } + + public Texture2DExtended(IModHelper helper, string modID, string path, ContentSource contentSource = ContentSource.ModFolder) + { + this.Name = Path.GetFileNameWithoutExtension(path); + this.path = path; + this.texture = helper.Content.Load(path, contentSource); + this.helper = helper; + this.modID = modID; + this.source = contentSource; + } + + public Texture2DExtended Copy() + { + return new Texture2DExtended(this.helper, this.modID, this.path); + } + + public IModHelper getHelper() + { + return this.helper; + } + + /// + /// Returns the actual 2D texture held by this wrapper class. + /// + /// + public Texture2D getTexture() + { + return this.texture; + } + + public void setTexure(Texture2D text) + { + this.texture = text; + } + } +} diff --git a/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs b/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs new file mode 100644 index 00000000..7c32791c --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs @@ -0,0 +1,63 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using PyTK.CustomElementHandler; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Revitalize.Framework.Objects +{ + public class BasicItemInformation: CustomObjectData + { + public string name; + public string description; + public string categoryName; + public Color categoryColor; + public int price; + public Vector2 TileLocation; + public int edibility; + public int fragility; + public bool canBeSetIndoors; + public bool canBeSetOutdoors; + public bool isLamp; + + public BasicItemInformation() : base() + { + name = ""; + description = ""; + categoryName = ""; + categoryColor = new Color(0, 0, 0); + price = 0; + TileLocation = Vector2.Zero; + this.edibility = -300; + this.canBeSetIndoors = false; + this.canBeSetOutdoors = false; + } + + public BasicItemInformation(string name, string description, string categoryName, Color categoryColor,int edibility,int fragility,bool isLamp,int price, Vector2 TileLocation,bool canBeSetOutdoors,bool canBeSetIndoors,string id, string data, Texture2D texture, Color color,int tileIndex, bool bigCraftable, Type type, CraftingData craftingData ):base(id,data,texture,color,tileIndex,bigCraftable,type,craftingData) + { + this.name = name; + this.description = description; + this.categoryName = categoryName; + this.categoryColor = categoryColor; + this.price = price; + this.TileLocation = TileLocation; + this.edibility = edibility; + + this.canBeSetOutdoors = canBeSetOutdoors; + this.canBeSetIndoors = canBeSetIndoors; + this.fragility = fragility; + this.isLamp = isLamp; + + recreateDataString(); + } + + public void recreateDataString() + { + this.data=this.name+"/"+this.price+"/"+this.edibility+"/"+"Crafting -9"+"/"+this.description+"/"+this.canBeSetOutdoors+"/"+this.canBeSetIndoors+"/"+this.fragility+"/"+this.isLamp+"/"+this.name; + } + + } +} diff --git a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs new file mode 100644 index 00000000..04d7f84a --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs @@ -0,0 +1,146 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using PyTK.CustomElementHandler; +using Revitalize.Framework.Graphics; +using StardewValley; +using StardewValley.Objects; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Revitalize.Framework.Objects +{ + /// + /// Change draw functions. + /// + public class CustomObject : PySObject + { + + public string id; + public Texture2DExtended texture; + public BasicItemInformation info; + public Texture2D displayTexture + { + get + { + return texture.texture; + } + } + + + public CustomObject() + { + + } + + public CustomObject(BasicItemInformation info):base(info,Vector2.Zero) + { + this.info = info; + this.initializeBasics(); + } + + public CustomObject(BasicItemInformation info,Vector2 TileLocation) : base(info, TileLocation) + { + this.info = info; + this.initializeBasics(); + } + + public virtual void initializeBasics() + { + this.name = info.name; + this.displayName = getDisplayNameFromStringsFile(this.id); + this.Edibility = info.edibility; + this.Category = -9; //For crafting. + this.displayName = info.name; + this.setOutdoors.Value = true; + this.setIndoors.Value = true; + this.isLamp.Value = false; + this.fragility.Value = 0; + } + + public override bool checkForAction(Farmer who, bool justCheckingForActivity = false) + { + if (justCheckingForActivity) + return true; + Revitalize.ModCore.ModMonitor.Log("Interact with core object!"); + return true; + } + + public override ICustomObject recreate(Dictionary additionalSaveData, object replacement) + { + BasicItemInformation data =(BasicItemInformation) CustomObjectData.collection[additionalSaveData["id"]]; + return new CustomObject((BasicItemInformation) CustomObjectData.collection[additionalSaveData["id"]], (replacement as Chest).TileLocation); + } + + + public override Color getCategoryColor() + { + return info.categoryColor; + //return data.categoryColor; + } + + public override string getCategoryName() + { + return info.categoryName; + } + + public override string getDescription() + { + string text = info.description; + SpriteFont smallFont = Game1.smallFont; + int width = Game1.tileSize * 4 + Game1.tileSize / 4; + return Game1.parseText(text, smallFont, width); + } + + public override Item getOne() + { + return new CustomObject((BasicItemInformation)this.data); + } + + public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1) + { + base.draw(spriteBatch, x, y, alpha); + } + + public override void draw(SpriteBatch spriteBatch, int xNonTile, int yNonTile, float layerDepth, float alpha = 1) + { + base.draw(spriteBatch, xNonTile, yNonTile, layerDepth, alpha); + } + + public override void drawAsProp(SpriteBatch b) + { + base.drawAsProp(b); + } + + public override void drawAttachments(SpriteBatch b, int x, int y) + { + base.drawAttachments(b, x, y); + } + + public override void drawInMenu(SpriteBatch spriteBatch, Vector2 location, float scaleSize, float transparency, float layerDepth, bool drawStackNumber, Color color, bool drawShadow) + { + base.drawInMenu(spriteBatch, location, scaleSize, transparency, layerDepth, drawStackNumber, color, drawShadow); + } + + public override void drawPlacementBounds(SpriteBatch spriteBatch, GameLocation location) + { + base.drawPlacementBounds(spriteBatch, location); + } + + public override void drawWhenHeld(SpriteBatch spriteBatch, Vector2 objectPosition, Farmer f) + { + base.drawWhenHeld(spriteBatch, objectPosition, f); + } + + + public string getDisplayNameFromStringsFile(string objectID) + { + //Load in a file that has all object names referenced here or something. + return info.name; + } + + } +} diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs new file mode 100644 index 00000000..5d37151b --- /dev/null +++ b/GeneralMods/Revitalize/ModCore.cs @@ -0,0 +1,47 @@ +using Microsoft.Xna.Framework; +using PyTK.Types; +using PyTK.Extensions; +using Revitalize.Framework.Objects; +using StardewModdingAPI; +using StardewValley; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Revitalize +{ + public class ModCore : Mod + { + public static IModHelper ModHelper; + public static IMonitor ModMonitor; + + public static Dictionary customObjects; + + + public override void Entry(IModHelper helper) + { + ModHelper = helper; + ModMonitor = Monitor; + + ModHelper.Events.GameLoop.SaveLoaded += GameLoop_SaveLoaded; + } + + private void GameLoop_SaveLoaded(object sender, StardewModdingAPI.Events.SaveLoadedEventArgs e) + { + CustomObject obj = new CustomObject(new BasicItemInformation("CoreObjectTest","YAY FUN!","Omegasis.Revitalize.CoreObject",Color.Violet,-300,1,false,100,Vector2.Zero,true,true,"Omegasis.bleh", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", Game1.objectSpriteSheet,Color.White,0,true,typeof(CustomObject),null)); + + + new InventoryItem(obj, 100,1).addToNPCShop("Gus"); + Game1.player.addItemToInventory(obj); + + } + + public static void log(object message) + { + + ModMonitor.Log(message.ToString()); + } + } +} diff --git a/GeneralMods/Revitalize/Properties/AssemblyInfo.cs b/GeneralMods/Revitalize/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..9463f7af --- /dev/null +++ b/GeneralMods/Revitalize/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("Revitalize")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Revitalize")] +[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("44ef6cec-fbf1-4b45-8135-81d4ebe84ddd")] + +// 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/Revitalize/Revitalize.csproj b/GeneralMods/Revitalize/Revitalize.csproj new file mode 100644 index 00000000..e07b12ca --- /dev/null +++ b/GeneralMods/Revitalize/Revitalize.csproj @@ -0,0 +1,69 @@ + + + + + Debug + AnyCPU + {44EF6CEC-FBF1-4B45-8135-81D4EBE84DDD} + Library + Properties + Revitalize + Revitalize + v4.6.1 + 512 + + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\..\..\..\..\..\..\Desktop\New folder (2)\PyTK.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/Revitalize/manifest.json b/GeneralMods/Revitalize/manifest.json new file mode 100644 index 00000000..9674ce58 --- /dev/null +++ b/GeneralMods/Revitalize/manifest.json @@ -0,0 +1,10 @@ +{ + "Name": "Revitalize", + "Author": "Alpha_Omegasis", + "Version": "0.0.1", + "Description": "A mod that attempts to add in a variety of new things to Stardew.", + "UniqueID": "Omegasis.Revitalize", + "EntryDll": "Revitalize.dll", + "MinimumApiVersion": "2.3", + "UpdateKeys": [] +} diff --git a/GeneralMods/Revitalize/packages.config b/GeneralMods/Revitalize/packages.config new file mode 100644 index 00000000..84563214 --- /dev/null +++ b/GeneralMods/Revitalize/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/GeneralMods/StardewMods.sln b/GeneralMods/StardewMods.sln index 4e379438..6c9f6d9a 100644 --- a/GeneralMods/StardewMods.sln +++ b/GeneralMods/StardewMods.sln @@ -81,6 +81,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Vocalization", "Vocalizatio EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AUnifiedSaveCore", "UnifiedSaveCore\AUnifiedSaveCore.csproj", "{ACAF0BAE-6495-4F1B-8B1F-E34BF7CCF51A}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Revitalize", "Revitalize\Revitalize.csproj", "{44EF6CEC-FBF1-4B45-8135-81D4EBE84DDD}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -415,6 +417,18 @@ Global {ACAF0BAE-6495-4F1B-8B1F-E34BF7CCF51A}.x86|Any CPU.Build.0 = Release|Any CPU {ACAF0BAE-6495-4F1B-8B1F-E34BF7CCF51A}.x86|x86.ActiveCfg = Release|Any CPU {ACAF0BAE-6495-4F1B-8B1F-E34BF7CCF51A}.x86|x86.Build.0 = Release|Any CPU + {44EF6CEC-FBF1-4B45-8135-81D4EBE84DDD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {44EF6CEC-FBF1-4B45-8135-81D4EBE84DDD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {44EF6CEC-FBF1-4B45-8135-81D4EBE84DDD}.Debug|x86.ActiveCfg = Debug|Any CPU + {44EF6CEC-FBF1-4B45-8135-81D4EBE84DDD}.Debug|x86.Build.0 = Debug|Any CPU + {44EF6CEC-FBF1-4B45-8135-81D4EBE84DDD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {44EF6CEC-FBF1-4B45-8135-81D4EBE84DDD}.Release|Any CPU.Build.0 = Release|Any CPU + {44EF6CEC-FBF1-4B45-8135-81D4EBE84DDD}.Release|x86.ActiveCfg = Release|Any CPU + {44EF6CEC-FBF1-4B45-8135-81D4EBE84DDD}.Release|x86.Build.0 = Release|Any CPU + {44EF6CEC-FBF1-4B45-8135-81D4EBE84DDD}.x86|Any CPU.ActiveCfg = Release|Any CPU + {44EF6CEC-FBF1-4B45-8135-81D4EBE84DDD}.x86|Any CPU.Build.0 = Release|Any CPU + {44EF6CEC-FBF1-4B45-8135-81D4EBE84DDD}.x86|x86.ActiveCfg = Release|Any CPU + {44EF6CEC-FBF1-4B45-8135-81D4EBE84DDD}.x86|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE From 23d964d86184c0a28e68aaa812340b4ef50106e6 Mon Sep 17 00:00:00 2001 From: Joshua Navarro Date: Thu, 20 Dec 2018 13:54:00 -0800 Subject: [PATCH 02/72] Implemented right click and shift right click functionality for custom objects. --- .../Framework/Objects/CustomObject.cs | 50 ++++++++++++++++++- GeneralMods/Revitalize/Revitalize.csproj | 3 ++ 2 files changed, 51 insertions(+), 2 deletions(-) diff --git a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs index 04d7f84a..3654203c 100644 --- a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs +++ b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs @@ -1,5 +1,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework.Input; using PyTK.CustomElementHandler; using Revitalize.Framework.Graphics; using StardewValley; @@ -63,10 +64,25 @@ namespace Revitalize.Framework.Objects public override bool checkForAction(Farmer who, bool justCheckingForActivity = false) { + var mState = Microsoft.Xna.Framework.Input.Mouse.GetState(); + var keyboardState = Game1.GetKeyboardState(); + + if (mState.RightButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed && (keyboardState.IsKeyDown(Keys.LeftShift) || keyboardState.IsKeyDown(Keys.RightShift))==false) + { + Revitalize.ModCore.log("Right clicked!"); + return rightClicked(who); + } + else if(mState.RightButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed && (keyboardState.IsKeyDown(Keys.LeftShift) || keyboardState.IsKeyDown(Keys.RightShift))) + { + return shiftRightClicked(who); + } + if (justCheckingForActivity) + { return true; - Revitalize.ModCore.ModMonitor.Log("Interact with core object!"); - return true; + } + Revitalize.ModCore.log("Left clicked!"); + return this.clicked(who); } public override ICustomObject recreate(Dictionary additionalSaveData, object replacement) @@ -76,6 +92,36 @@ namespace Revitalize.Framework.Objects } + public virtual bool rightClicked(Farmer who) + { + // Game1.showRedMessage("YOOO"); + //do some stuff when the right button is down + // rotate(); + if (this.heldObject.Value != null) + { + // Game1.player.addItemByMenuIfNecessary(this.heldObject); + // this.heldObject = null; + } + else + { + // this.heldObject = Game1.player.ActiveObject; + // Game1.player.removeItemFromInventory(heldObject); + } + return true; + } + + public virtual bool shiftRightClicked(Farmer who) + { + Revitalize.ModCore.log("Shift right clicked!"); + return true; + } + + public override bool clicked(Farmer who) + { + Revitalize.ModCore.log("Clicky click!"); + return base.clicked(who); + } + public override Color getCategoryColor() { return info.categoryColor; diff --git a/GeneralMods/Revitalize/Revitalize.csproj b/GeneralMods/Revitalize/Revitalize.csproj index e07b12ca..b2e8891d 100644 --- a/GeneralMods/Revitalize/Revitalize.csproj +++ b/GeneralMods/Revitalize/Revitalize.csproj @@ -58,6 +58,9 @@ + + + From e1abeac68b19cdba5ee206e6ce44c607a580978f Mon Sep 17 00:00:00 2001 From: Joshua Navarro Date: Fri, 21 Dec 2018 15:28:52 -0800 Subject: [PATCH 03/72] Revitalize: Implemented Animation Manager. Need to fix when held and display in menu. --- GeneralMods/AdvancedSaveBackup/manifest.json | 2 +- GeneralMods/AutoSpeed/manifest.json | 2 +- GeneralMods/BillboardAnywhere/manifest.json | 2 +- GeneralMods/BuildEndurance/manifest.json | 2 +- GeneralMods/BuildHealth/manifest.json | 2 +- GeneralMods/BuyBackCollectables/manifest.json | 2 +- GeneralMods/CustomNPCFramework/Class1.cs | 3 + .../Framework/Graphics/DirectionalTexture.cs | 10 +- GeneralMods/DailyQuestAnywhere/manifest.json | 2 +- GeneralMods/Fall28SnowDay/manifest.json | 2 +- GeneralMods/HappyBirthday/BirthdayMessages.cs | 4 +- GeneralMods/HappyBirthday/Changelog.txt | 25 +- GeneralMods/HappyBirthday/GiftManager.cs | 3 + GeneralMods/HappyBirthday/HappyBirthday.cs | 4 +- GeneralMods/HappyBirthday/manifest.json | 9 +- GeneralMods/MoreRain/manifest.json | 2 +- GeneralMods/MuseumRearranger/manifest.json | 2 +- GeneralMods/NightOwl/manifest.json | 2 +- GeneralMods/NoMorePets/manifest.json | 2 +- .../Graphics/Animations/Animation.cs | 80 +++++ .../Graphics/Animations/AnimationManager.cs | 290 ++++++++++++++++++ .../Framework/Objects/BasicItemInformation.cs | 24 +- .../Framework/Objects/CustomObject.cs | 129 +++++++- GeneralMods/Revitalize/ModCore.cs | 2 +- GeneralMods/Revitalize/Revitalize.csproj | 2 + GeneralMods/SaveAnywhere/manifest.json | 2 +- GeneralMods/SimpleSoundManager/manifest.json | 2 +- GeneralMods/StardewMods.sln | 42 --- .../StardewSymphonyRemastered/manifest.json | 2 +- GeneralMods/StardustCore/manifest.json | 2 +- GeneralMods/TimeFreeze/manifest.json | 2 +- 31 files changed, 563 insertions(+), 98 deletions(-) create mode 100644 GeneralMods/Revitalize/Framework/Graphics/Animations/Animation.cs create mode 100644 GeneralMods/Revitalize/Framework/Graphics/Animations/AnimationManager.cs diff --git a/GeneralMods/AdvancedSaveBackup/manifest.json b/GeneralMods/AdvancedSaveBackup/manifest.json index f4afb5a4..8db3680c 100644 --- a/GeneralMods/AdvancedSaveBackup/manifest.json +++ b/GeneralMods/AdvancedSaveBackup/manifest.json @@ -1,7 +1,7 @@ { "Name": "Advanced Save Backup", "Author": "Alpha_Omegasis", - "Version": "1.5.0", + "Version": "1.6.0", "Description": "Backs up your save files when loading SMAPI and every in game night when saving.", "UniqueID": "Omegasis.AdvancedSaveBackup", "EntryDll": "AdvancedSaveBackup.dll", diff --git a/GeneralMods/AutoSpeed/manifest.json b/GeneralMods/AutoSpeed/manifest.json index 5dd4808f..39a0695d 100644 --- a/GeneralMods/AutoSpeed/manifest.json +++ b/GeneralMods/AutoSpeed/manifest.json @@ -1,7 +1,7 @@ { "Name": "Auto Speed", "Author": "Alpha_Omegasis", - "Version": "1.6.0", + "Version": "1.7.0", "Description": "Got to go fast!", "UniqueID": "Omegasis.AutoSpeed", "EntryDll": "AutoSpeed.dll", diff --git a/GeneralMods/BillboardAnywhere/manifest.json b/GeneralMods/BillboardAnywhere/manifest.json index d8d45b95..c35ec23e 100644 --- a/GeneralMods/BillboardAnywhere/manifest.json +++ b/GeneralMods/BillboardAnywhere/manifest.json @@ -1,7 +1,7 @@ { "Name": "Billboard Anywhere", "Author": "Alpha_Omegasis", - "Version": "1.6.0", + "Version": "1.7.0", "Description": "Lets you view the billboard from anywhere.", "UniqueID": "Omegasis.BillboardAnywhere", "EntryDll": "BillboardAnywhere.dll", diff --git a/GeneralMods/BuildEndurance/manifest.json b/GeneralMods/BuildEndurance/manifest.json index 6829e663..3b75abd3 100644 --- a/GeneralMods/BuildEndurance/manifest.json +++ b/GeneralMods/BuildEndurance/manifest.json @@ -1,7 +1,7 @@ { "Name": "Build Endurance", "Author": "Alpha_Omegasis", - "Version": "1.6.0", + "Version": "1.7.0", "Description": "Increase your health as you play.", "UniqueID": "Omegasis.BuildEndurance", "EntryDll": "BuildEndurance.dll", diff --git a/GeneralMods/BuildHealth/manifest.json b/GeneralMods/BuildHealth/manifest.json index dff2d592..808dd39d 100644 --- a/GeneralMods/BuildHealth/manifest.json +++ b/GeneralMods/BuildHealth/manifest.json @@ -1,7 +1,7 @@ { "Name": "Build Health", "Author": "Alpha_Omegasis", - "Version": "1.6.0", + "Version": "1.7.0", "Description": "Increase your health as you play.", "UniqueID": "Omegasis.BuildHealth", "EntryDll": "BuildHealth.dll", diff --git a/GeneralMods/BuyBackCollectables/manifest.json b/GeneralMods/BuyBackCollectables/manifest.json index e700b1b2..a420d9ca 100644 --- a/GeneralMods/BuyBackCollectables/manifest.json +++ b/GeneralMods/BuyBackCollectables/manifest.json @@ -1,7 +1,7 @@ { "Name": "Buy Back Collectables", "Author": "Alpha_Omegasis", - "Version": "1.5.0", + "Version": "1.6.0", "Description": "Lets you buy back any obtained collectable.", "UniqueID": "Omegasis.BuyBackCollectables", "EntryDll": "BuyBackCollectables.dll", diff --git a/GeneralMods/CustomNPCFramework/Class1.cs b/GeneralMods/CustomNPCFramework/Class1.cs index 03bac289..117b59eb 100644 --- a/GeneralMods/CustomNPCFramework/Class1.cs +++ b/GeneralMods/CustomNPCFramework/Class1.cs @@ -66,6 +66,8 @@ namespace CustomNPCFramework /// Keeps track of all of the asets/textures added in by the framework. Also manages all of the asset managers that are the ones actually managing the textures. /// public static AssetPool assetPool; + + public static IManifest Manifest; /// /// Ran when loading the SMAPI. Used to initialize data. @@ -75,6 +77,7 @@ namespace CustomNPCFramework { ModHelper = this.Helper; ModMonitor = this.Monitor; + Manifest = ModManifest; StardewModdingAPI.Events.SaveEvents.AfterLoad += SaveEvents_LoadChar; diff --git a/GeneralMods/CustomNPCFramework/Framework/Graphics/DirectionalTexture.cs b/GeneralMods/CustomNPCFramework/Framework/Graphics/DirectionalTexture.cs index d5a3aca5..4303cf5a 100644 --- a/GeneralMods/CustomNPCFramework/Framework/Graphics/DirectionalTexture.cs +++ b/GeneralMods/CustomNPCFramework/Framework/Graphics/DirectionalTexture.cs @@ -66,7 +66,7 @@ namespace CustomNPCFramework.Framework.Graphics public DirectionalTexture(IModHelper helper ,NamePairings info, string path, Direction direction = Direction.down) { - new Texture2DExtended(helper, path); + new Texture2DExtended(helper, Class1.Manifest, path); string leftString= Class1.getShortenedDirectory(Path.Combine(path, info.leftString + ".png")).Remove(0, 1); string rightString = Class1.getShortenedDirectory(Path.Combine(path, info.rightString + ".png")).Remove(0, 1); @@ -74,10 +74,10 @@ namespace CustomNPCFramework.Framework.Graphics string downString = Class1.getShortenedDirectory(Path.Combine(path, info.downString + ".png")).Remove(0, 1); - this.leftTexture = new Texture2DExtended(helper, leftString); - this.rightTexture = new Texture2DExtended(helper, rightString); - this.upTexture = new Texture2DExtended(helper, upString); - this.downTexture = new Texture2DExtended(helper, downString); + this.leftTexture = new Texture2DExtended(helper, Class1.Manifest, leftString); + this.rightTexture = new Texture2DExtended(helper, Class1.Manifest, rightString); + this.upTexture = new Texture2DExtended(helper, Class1.Manifest, upString); + this.downTexture = new Texture2DExtended(helper, Class1.Manifest, downString); if (direction == Direction.left) this.currentTexture = leftTexture; if (direction == Direction.right) this.currentTexture = rightTexture; diff --git a/GeneralMods/DailyQuestAnywhere/manifest.json b/GeneralMods/DailyQuestAnywhere/manifest.json index 1bc9f1fb..319acf00 100644 --- a/GeneralMods/DailyQuestAnywhere/manifest.json +++ b/GeneralMods/DailyQuestAnywhere/manifest.json @@ -1,7 +1,7 @@ { "Name": "Daily Quest Anywhere", "Author": "Alpha_Omegasis", - "Version": "1.5.0", + "Version": "1.6.0", "Description": "Open the daily quest board from anywhere in the game.", "UniqueID": "Omegasis.DailyQuestAnywhere", "EntryDll": "DailyQuestAnywhere.dll", diff --git a/GeneralMods/Fall28SnowDay/manifest.json b/GeneralMods/Fall28SnowDay/manifest.json index be64d502..5681c600 100644 --- a/GeneralMods/Fall28SnowDay/manifest.json +++ b/GeneralMods/Fall28SnowDay/manifest.json @@ -1,7 +1,7 @@ { "Name": "Fall 28 Snow Day", "Author": "Alpha_Omegasis", - "Version": "1.5.0", + "Version": "1.6.0", "Description": "Makes it snow on Fall 28, which makes a good explanation for all the snow on the next day.", "UniqueID": "Omegasis.Fall28SnowDay", "EntryDll": "Fall28SnowDay.dll", diff --git a/GeneralMods/HappyBirthday/BirthdayMessages.cs b/GeneralMods/HappyBirthday/BirthdayMessages.cs index 67dfe5ba..49c33786 100644 --- a/GeneralMods/HappyBirthday/BirthdayMessages.cs +++ b/GeneralMods/HappyBirthday/BirthdayMessages.cs @@ -95,7 +95,7 @@ namespace Omegasis.HappyBirthday //Handle normal birthday wishes. if (!File.Exists(Path.Combine(HappyBirthday.ModHelper.DirectoryPath,path))) { - + HappyBirthday.ModMonitor.Log("Creating Villager Birthday Messages", StardewModdingAPI.LogLevel.Alert); HappyBirthday.ModHelper.Data.WriteJsonFile>(path, defaultBirthdayWishes); this.birthdayWishes = defaultBirthdayWishes; } @@ -156,7 +156,7 @@ namespace Omegasis.HappyBirthday } else { - tempBirthdayDict = HappyBirthday.ModHelper.Data.ReadJsonFile>(tempSpouseBirthdayFile); + tempSpouseBirthdayDict = HappyBirthday.ModHelper.Data.ReadJsonFile>(tempSpouseBirthdayFile); } //Set translated birthday info. diff --git a/GeneralMods/HappyBirthday/Changelog.txt b/GeneralMods/HappyBirthday/Changelog.txt index 0ce95022..e4b23240 100644 --- a/GeneralMods/HappyBirthday/Changelog.txt +++ b/GeneralMods/HappyBirthday/Changelog.txt @@ -1,26 +1,27 @@ Happy Birthday Change Log ~~~~~~~~~~~~~~~~ -1.8.0 Changelog +Manifest 1.8.0 Changelog ~~~~~~~~~~~~~~~~ -General Changes +General Changes + -NPCs now wish you a happy birthday if you have 2+ hearts with them. (Configurable in config file) + -A language can be set for birthday messages in the Config.json file. -Added support for birthday messages to be in .json files for easier editing. -Added support for birthday messages to be in multiple supported languages - -English - -Spanish - -German - -Chinese - -Japanese - -Brazillian Portuguese - -Added in spouse specific birthday dialogue messages which can be selected by the players. - -Added in multiple langages for spouse birthday messages. + -English + -Spanish + -German + -Chinese + -Japanese + -Brazilian Portuguese + -Added in spouse specific birthday dialogue messages which can be created by the players. + -Added in multiple languages for spouse birthday messages. -Added in birthday gifts to be in .json files. -Added in a new pool of spouse specific gifts that can be set by the player located in SpouseBirthdayGifts.json -Added in support for loading legacy birthday gift.xnb info from StardewValley/Content/Data/PossibleBirthdayGifts.xnb -Added in support for loading legacy birthday messages from StardewValley/Content/Data/BirthdayMessages.xnb -Added in player portraits to be shown on the callendar. - Multiplayer changes: - -Added in multiplayer portraits to be shown on the callendar. + -Added in multiplayer farmhand portraits to be shown on the callendar. -Added in a hud message that displays when another player has a birthday. \ No newline at end of file diff --git a/GeneralMods/HappyBirthday/GiftManager.cs b/GeneralMods/HappyBirthday/GiftManager.cs index eb313029..18972ab3 100644 --- a/GeneralMods/HappyBirthday/GiftManager.cs +++ b/GeneralMods/HappyBirthday/GiftManager.cs @@ -117,6 +117,9 @@ namespace Omegasis.HappyBirthday if (File.Exists(Path.Combine(Game1.content.RootDirectory, "Data", "PossibleBirthdayGifts.xnb"))){ HappyBirthday.ModMonitor.Log("Legacy loading detected. Attempting to load from StardewValley/Content/Data/PossibleBirthdayGifts.xnb"); this.defaultBirthdayGifts = Game1.content.Load>(Path.Combine("Data", "PossibleBirthdayGifts")); + + string villagerGifts = Path.Combine("Content", "Gifts", "BirthdayGifts.json"); + HappyBirthday.ModHelper.Data.WriteJsonFile>(villagerGifts, this.defaultBirthdayGifts); } else { diff --git a/GeneralMods/HappyBirthday/HappyBirthday.cs b/GeneralMods/HappyBirthday/HappyBirthday.cs index f41f8a82..86742385 100644 --- a/GeneralMods/HappyBirthday/HappyBirthday.cs +++ b/GeneralMods/HappyBirthday/HappyBirthday.cs @@ -127,6 +127,7 @@ namespace Omegasis.HappyBirthday messages = new BirthdayMessages(); giftManager = new GiftManager(); + messages.createBirthdayGreetings(); isDailyQuestBoard = false; ModHelper.Events.Multiplayer.ModMessageReceived += Multiplayer_ModMessageReceived; @@ -368,7 +369,7 @@ namespace Omegasis.HappyBirthday this.MigrateLegacyData(); this.PlayerData = this.Helper.Data.ReadJsonFile(this.DataFilePath) ?? new PlayerData(); - messages.createBirthdayGreetings(); + ; if (PlayerBirthdayData != null) { @@ -495,6 +496,7 @@ namespace Omegasis.HappyBirthday if (Game1.currentSpeaker != null) { string name = Game1.currentSpeaker.Name; + if (Game1.player.getFriendshipHeartLevelForNPC(name) <= Config.minNeutralFriendshipGiftLevel) return; if (this.IsBirthday() && this.VillagerQueue.Contains(name)) { try diff --git a/GeneralMods/HappyBirthday/manifest.json b/GeneralMods/HappyBirthday/manifest.json index 6b5cc92c..8a984cae 100644 --- a/GeneralMods/HappyBirthday/manifest.json +++ b/GeneralMods/HappyBirthday/manifest.json @@ -1,16 +1,11 @@ { "Name": "Happy Birthday", "Author": "Alpha_Omegasis", - "Version": { - "MajorVersion": 1, - "MinorVersion": 8, - "PatchVersion": 0, - "Build": null - }, + "Version": "1.8.0", "MinimumApiVersion": "1.15", "Description": "Adds the farmer's birthday to the game.", "UniqueID": "Omegasis.HappyBirthday", "EntryDll": "HappyBirthday.dll", - "MinimumApiVersion": "2.0", + "MinimumApiVersion": "2.9", "UpdateKeys": [ "Nexus:520" ] } diff --git a/GeneralMods/MoreRain/manifest.json b/GeneralMods/MoreRain/manifest.json index 481fc266..2923d02b 100644 --- a/GeneralMods/MoreRain/manifest.json +++ b/GeneralMods/MoreRain/manifest.json @@ -1,7 +1,7 @@ { "Name": "More Rain", "Author": "Alpha_Omegasis", - "Version": "1.6.1", + "Version": "1.7.0", "Description": "Change how much it rains in the game.", "UniqueID": "Omegasis.MoreRain", "EntryDll": "MoreRain.dll", diff --git a/GeneralMods/MuseumRearranger/manifest.json b/GeneralMods/MuseumRearranger/manifest.json index 4f390cda..8f28f6fe 100644 --- a/GeneralMods/MuseumRearranger/manifest.json +++ b/GeneralMods/MuseumRearranger/manifest.json @@ -1,7 +1,7 @@ { "Name": "Museum Rearranger", "Author": "Alpha_Omegasis", - "Version": "1.6.0", + "Version": "1.7.0", "Description": "Lets you rearrange the museum without needing to donate something.", "UniqueID": "Omegasis.MuseumRearranger", "EntryDll": "MuseumRearranger.dll", diff --git a/GeneralMods/NightOwl/manifest.json b/GeneralMods/NightOwl/manifest.json index d937a0fe..070c5081 100644 --- a/GeneralMods/NightOwl/manifest.json +++ b/GeneralMods/NightOwl/manifest.json @@ -1,7 +1,7 @@ { "Name": "Night Owl", "Author": "Alpha_Omegasis", - "Version": "1.7.1", + "Version": "1.8.0", "Description": "Lets you stay up all night.", "UniqueID": "Omegasis.NightOwl", "EntryDll": "NightOwl.dll", diff --git a/GeneralMods/NoMorePets/manifest.json b/GeneralMods/NoMorePets/manifest.json index 64ca1569..4f44bd43 100644 --- a/GeneralMods/NoMorePets/manifest.json +++ b/GeneralMods/NoMorePets/manifest.json @@ -1,7 +1,7 @@ { "Name": "No More Pets", "Author": "Alpha_Omegasis", - "Version": "1.5.0", + "Version": "1.6.0", "Description": "Removes all pets from the game.", "UniqueID": "Omegasis.NoMorePets", "EntryDll": "NoMorePets.dll", diff --git a/GeneralMods/Revitalize/Framework/Graphics/Animations/Animation.cs b/GeneralMods/Revitalize/Framework/Graphics/Animations/Animation.cs new file mode 100644 index 00000000..70c86246 --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Graphics/Animations/Animation.cs @@ -0,0 +1,80 @@ +using Microsoft.Xna.Framework; +using Netcode; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Serialization; + +namespace Revitalize.Framework.Graphics.Animations +{ + /// + /// A custom class used to deal with custom animations/ + /// + public class Animation + { + /// + /// The source rectangle on the texture to display. + /// + public Rectangle sourceRectangle; + /// + /// The duration of the frame in length. + /// + public int frameDuration; + /// + /// The duration until the next frame. + /// + public int frameCountUntilNextAnimation; + + [XmlIgnore] + public NetFields NetFields { get; } = new NetFields(); + + public Animation() + { + this.sourceRectangle = new Rectangle(0,0,16,16); + this.frameCountUntilNextAnimation = -1; + this.frameDuration = -1; + } + + /// + /// Constructor that causes the animation frame count to be set to -1; This forces it to never change. + /// + /// The draw source for this animation. + public Animation(Rectangle SourceRectangle) + { + sourceRectangle = SourceRectangle; + this.frameCountUntilNextAnimation = -1; + frameDuration = -1; + } + + /// + /// Constructor. + /// + /// The draw source for this animation. + /// How many on screen frames this animation stays for. Every draw frame decrements an active animation by 1 frame. Set this to -1 to have it be on the screen infinitely. + public Animation(Rectangle SourceRectangle,int existForXFrames) + { + sourceRectangle = SourceRectangle; + frameDuration = existForXFrames; + } + + /// + /// Decrements the amount of frames this animation is on the screen for by 1. + /// + public void tickAnimationFrame() + { + frameCountUntilNextAnimation--; + } + + /// + /// This sets the animation frame count to be the max duration. I.E restart the timer. + /// + public void startAnimation() + { + frameCountUntilNextAnimation = frameDuration; + } + + + } +} diff --git a/GeneralMods/Revitalize/Framework/Graphics/Animations/AnimationManager.cs b/GeneralMods/Revitalize/Framework/Graphics/Animations/AnimationManager.cs new file mode 100644 index 00000000..4611ceba --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Graphics/Animations/AnimationManager.cs @@ -0,0 +1,290 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using StardewModdingAPI; +using StardewValley; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Revitalize.Framework.Graphics.Animations +{ + /// + /// Used to play animations for Stardust.CoreObject type objects and all objects that extend from it. In draw code of object make sure to use this info instead. + /// + public class AnimationManager + { + public Dictionary> animations = new SerializableDictionary>(); + public string currentAnimationName; + public int currentAnimationListIndex; + public List currentAnimationList = new List(); + private Texture2DExtended objectTexture; ///Might not be necessary if I use the CoreObject texture sheet. + public Animation defaultDrawFrame; + public Animation currentAnimation; + public bool enabled; + + + public string animationDataString; + + + public bool IsNull + { + get + { + if (this.defaultDrawFrame == null && this.objectTexture == null) return true; + else return false; + } + } + /// + /// Empty constructor. + /// + public AnimationManager() + { + + } + + + /// + /// Constructor for Animation Manager class. + /// + /// The texture that will be used for the animation. This is typically the same as the object this class is attached to. + /// This is used if no animations will be available to the animation manager. + /// Whether or not animations play by default. Default value is true. + public AnimationManager (Texture2DExtended ObjectTexture,Animation DefaultFrame, bool EnabledByDefault=true) + { + currentAnimationListIndex = 0; + this.objectTexture = ObjectTexture; + this.defaultDrawFrame = DefaultFrame; + this.enabled = EnabledByDefault; + currentAnimation = this.defaultDrawFrame; + this.currentAnimationName = ""; + this.animationDataString = ""; + } + + public AnimationManager(Texture2DExtended ObjectTexture,Animation DefaultFrame ,string animationString, string startingAnimationKey, int startingAnimationFrame=0,bool EnabledByDefault=true) + { + currentAnimationListIndex = 0; + this.objectTexture = ObjectTexture; + this.defaultDrawFrame = DefaultFrame; + this.enabled = EnabledByDefault; + + this.animationDataString = animationString; + this.animations = parseAnimationsFromXNB(animationString); + bool f = animations.TryGetValue(startingAnimationKey, out currentAnimationList); + if (f == true) + { + setAnimation(startingAnimationKey, startingAnimationFrame); + } + else + { + currentAnimation = this.defaultDrawFrame; + this.currentAnimationName = ""; + } + } + + public AnimationManager(Texture2DExtended ObjectTexture, Animation DefaultFrame, Dictionary> animationString, string startingAnimationKey, int startingAnimationFrame = 0, bool EnabledByDefault = true) + { + currentAnimationListIndex = 0; + this.objectTexture = ObjectTexture; + this.defaultDrawFrame = DefaultFrame; + this.enabled = EnabledByDefault; + + this.animations = animationString; + bool f = animations.TryGetValue(startingAnimationKey, out currentAnimationList); + if (f == true) + { + setAnimation(startingAnimationKey, startingAnimationFrame); + } + else + { + currentAnimation = this.defaultDrawFrame; + this.currentAnimationName = ""; + } + } + + /// + /// Update the animation frame once after drawing the object. + /// + public void tickAnimation() + { + try + { + if (this.currentAnimation.frameDuration == -1 || this.enabled == false || this.currentAnimation == this.defaultDrawFrame) return; //This is if this is a default animation or the animation stops here. + if (this.currentAnimation.frameCountUntilNextAnimation == 0) getNextAnimation(); + this.currentAnimation.tickAnimationFrame(); + } + catch(Exception err) + { + ModCore.ModMonitor.Log("An internal error occured when trying to tick the animation."); + ModCore.ModMonitor.Log(err.ToString(), StardewModdingAPI.LogLevel.Error); + } + } + + /// + /// Get the next animation in the list of animations. + /// + public void getNextAnimation() + { + currentAnimationListIndex++; + if(currentAnimationListIndex==currentAnimationList.Count) //If the animation frame I'm tryting to get is 1 outside my list length, reset the list. + { + currentAnimationListIndex = 0; + } + + //Get the next animation from the list and reset it's counter to the starting frame value. + this.currentAnimation = currentAnimationList[currentAnimationListIndex]; + this.currentAnimation.startAnimation(); + } + + /// + /// Gets the animation from the dictionary of all animations available. + /// + /// + /// + /// + public bool setAnimation(string AnimationName, int StartingFrame=0) + { + List dummyList = new List(); + bool f = animations.TryGetValue(AnimationName, out dummyList); + if (f == true) + { + if (dummyList.Count != 0 || StartingFrame>=dummyList.Count) + { + currentAnimationList = dummyList; + currentAnimation = currentAnimationList[StartingFrame]; + currentAnimationName = AnimationName; + return true; + } + else + { + if(dummyList.Count==0) ModCore.ModMonitor.Log("Error: Current animation " + AnimationName+ " has no animation frames associated with it."); + if (dummyList.Count > dummyList.Count) ModCore.ModMonitor.Log("Error: Animation frame "+ StartingFrame+ " is outside the range of provided animations. Which has a maximum count of "+ dummyList.Count); + return false; + } + } + else + { + ModCore.ModMonitor.Log("Error setting animation: " + AnimationName + " animation does not exist in list of available animations. Did you make sure to add it in?"); + return false; + } + } + + /// + /// Sets the animation manager to an on state, meaning that this animation will update on the draw frame. + /// + public void enableAnimation() + { + this.enabled = true; + } + + /// + /// Sets the animation manager to an off state, meaning that this animation will no longer update on the draw frame. + /// + public void disableAnimation() + { + this.enabled = false; + } + + public static Dictionary> parseAnimationsFromXNB(string s) + { + string[] array = s.Split('*'); + Dictionary> parsedDic = new Dictionary>(); + foreach(var v in array) + { + // Log.AsyncC(v); + string[] AnimationArray = v.Split(' '); + if (parsedDic.ContainsKey(AnimationArray[0])) + { + List aniList = new List(); + aniList = parseAnimationFromString(v); + foreach(var ani in aniList) { + parsedDic[AnimationArray[0]].Add(ani); + } + + } + else + { + parsedDic.Add(AnimationArray[0], new List()); + List aniList = new List(); + aniList = parseAnimationFromString(v); + foreach (var ani in aniList) + { + parsedDic[AnimationArray[0]].Add(ani); + } + } + } + return parsedDic; + } + + public static List parseAnimationFromString(string s) + { + List ok = new List(); + string[] array2 = s.Split('>'); + foreach(var q in array2) { + string[] array = q.Split(' '); + try + { + Animation ani = new Animation(new Rectangle(Convert.ToInt32(array[1]), Convert.ToInt32(array[2]), Convert.ToInt32(array[3]), Convert.ToInt32(array[4])), Convert.ToInt32(array[5])); + // ModCore.ModMonitor.Log(ani.sourceRectangle.ToString()); + ok.Add(ani); + } + catch(Exception err) + { + err.ToString(); + continue; + } + + } + return ok; + } + /// + /// Used to handle general drawing functionality using the animation manager. + /// + /// We need a spritebatch to draw. + /// The texture to draw. + /// The onscreen position to draw to. + /// The source rectangle on the texture to draw. + /// The color to draw the thing passed in. + /// The rotation of the animation texture being drawn. + /// The origin of the texture. + /// The scale of the texture. + /// Effects that get applied to the sprite. + /// The dept at which to draw the texture. + public void draw(SpriteBatch spriteBatch,Texture2D texture, Vector2 Position, Rectangle? sourceRectangle,Color drawColor, float rotation, Vector2 origin, float scale,SpriteEffects spriteEffects, float LayerDepth) + { + //Log.AsyncC("Animation Manager is working!"); + spriteBatch.Draw(texture, Position, sourceRectangle, drawColor, rotation, origin, scale, spriteEffects, LayerDepth); + try + { + this.tickAnimation(); + // Log.AsyncC("Tick animation"); + } + catch (Exception err) + { + ModCore.ModMonitor.Log(err.ToString()); + } + } + + public Texture2DExtended getExtendedTexture() + { + return this.objectTexture; + } + + public void setExtendedTexture(Texture2DExtended texture) + { + this.objectTexture = texture; + } + + public void setEnabled(bool enabled) + { + this.enabled = enabled; + } + + public Texture2D getTexture() + { + return this.objectTexture.getTexture(); + } + + } +} diff --git a/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs b/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs index 7c32791c..3f29e0f4 100644 --- a/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs +++ b/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs @@ -1,6 +1,7 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using PyTK.CustomElementHandler; +using Revitalize.Framework.Graphics.Animations; using System; using System.Collections.Generic; using System.Linq; @@ -23,6 +24,9 @@ namespace Revitalize.Framework.Objects public bool canBeSetOutdoors; public bool isLamp; + public AnimationManager animationManager; + public Vector2 drawPosition; + public BasicItemInformation() : base() { name = ""; @@ -34,9 +38,12 @@ namespace Revitalize.Framework.Objects this.edibility = -300; this.canBeSetIndoors = false; this.canBeSetOutdoors = false; + + this.animationManager = null; + this.drawPosition = Vector2.Zero; } - public BasicItemInformation(string name, string description, string categoryName, Color categoryColor,int edibility,int fragility,bool isLamp,int price, Vector2 TileLocation,bool canBeSetOutdoors,bool canBeSetIndoors,string id, string data, Texture2D texture, Color color,int tileIndex, bool bigCraftable, Type type, CraftingData craftingData ):base(id,data,texture,color,tileIndex,bigCraftable,type,craftingData) + public BasicItemInformation(string name, string description, string categoryName, Color categoryColor,int edibility,int fragility,bool isLamp,int price, Vector2 TileLocation,bool canBeSetOutdoors,bool canBeSetIndoors,string id, string data, Texture2D texture, Color color,int tileIndex, bool bigCraftable, Type type, CraftingData craftingData, AnimationManager animationManager):base(id,data,texture,color,tileIndex,bigCraftable,type,craftingData) { this.name = name; this.description = description; @@ -51,6 +58,19 @@ namespace Revitalize.Framework.Objects this.fragility = fragility; this.isLamp = isLamp; + this.animationManager = animationManager; + if (this.animationManager.IsNull) + { + this.animationManager = new AnimationManager(new Graphics.Texture2DExtended(), new Animation(new Rectangle(0, 0, 16, 16)), false); + this.animationManager.getExtendedTexture().texture = this.texture; + } + else + { + this.texture = this.animationManager.getTexture(); + } + + this.drawPosition = Vector2.Zero; + recreateDataString(); } @@ -59,5 +79,7 @@ namespace Revitalize.Framework.Objects this.data=this.name+"/"+this.price+"/"+this.edibility+"/"+"Crafting -9"+"/"+this.description+"/"+this.canBeSetOutdoors+"/"+this.canBeSetIndoors+"/"+this.fragility+"/"+this.isLamp+"/"+this.name; } + + } } diff --git a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs index 3654203c..b569f9cb 100644 --- a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs +++ b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs @@ -3,6 +3,7 @@ using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; using PyTK.CustomElementHandler; using Revitalize.Framework.Graphics; +using Revitalize.Framework.Graphics.Animations; using StardewValley; using StardewValley.Objects; using System; @@ -21,13 +22,23 @@ namespace Revitalize.Framework.Objects { public string id; - public Texture2DExtended texture; public BasicItemInformation info; + + + public AnimationManager animationManager + { + get + { + return info.animationManager; + } + } + + public Texture2D displayTexture { get { - return texture.texture; + return animationManager.getTexture(); } } @@ -60,6 +71,10 @@ namespace Revitalize.Framework.Objects this.setIndoors.Value = true; this.isLamp.Value = false; this.fragility.Value = 0; + + this.updateDrawPosition(); + + } public override bool checkForAction(Farmer who, bool justCheckingForActivity = false) @@ -141,21 +156,88 @@ namespace Revitalize.Framework.Objects return Game1.parseText(text, smallFont, width); } + public override bool placementAction(GameLocation location, int x, int y, Farmer who = null) + { + this.updateDrawPosition(); + return base.placementAction(location, x, y, who); + } + + public virtual void updateDrawPosition() + { + this.info.drawPosition = new Vector2((float)this.boundingBox.X, (float)(this.boundingBox.Y - (this.animationManager.currentAnimation.sourceRectangle.Height * Game1.pixelZoom - this.boundingBox.Height))); + } + public override Item getOne() { return new CustomObject((BasicItemInformation)this.data); } - public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1) + public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1f) { - base.draw(spriteBatch, x, y, alpha); + if (x == -1) + { + spriteBatch.Draw(this.info.animationManager.getTexture(), Game1.GlobalToLocal(Game1.viewport, this.info.drawPosition), new Rectangle?(this.animationManager.currentAnimation.sourceRectangle), Color.White * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0); + } + else + { + //The actual planter box being drawn. + if (animationManager == null) + { + if (this.animationManager.getExtendedTexture() == null) + { + ModCore.ModMonitor.Log("Tex Extended is null???"); + + } + + spriteBatch.Draw(this.displayTexture, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(x * Game1.tileSize), y * Game1.tileSize)), new Rectangle?(this.animationManager.currentAnimation.sourceRectangle), Color.White * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0); + // Log.AsyncG("ANIMATION IS NULL?!?!?!?!"); + } + + else + { + //Log.AsyncC("Animation Manager is working!"); + this.animationManager.draw(spriteBatch, this.displayTexture, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(x * Game1.tileSize), y * Game1.tileSize)), new Rectangle?(this.animationManager.currentAnimation.sourceRectangle), Color.White * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0); + try + { + this.animationManager.tickAnimation(); + // Log.AsyncC("Tick animation"); + } + catch (Exception err) + { + ModCore.ModMonitor.Log(err.ToString()); + } + } + + // spriteBatch.Draw(Game1.mouseCursors, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)((double)tileLocation.X * (double)Game1.tileSize + (((double)tileLocation.X * 11.0 + (double)tileLocation.Y * 7.0) % 10.0 - 5.0)) + (float)(Game1.tileSize / 2), (float)((double)tileLocation.Y * (double)Game1.tileSize + (((double)tileLocation.Y * 11.0 + (double)tileLocation.X * 7.0) % 10.0 - 5.0)) + (float)(Game1.tileSize / 2))), new Rectangle?(new Rectangle((int)((double)tileLocation.X * 51.0 + (double)tileLocation.Y * 77.0) % 3 * 16, 128 + this.whichForageCrop * 16, 16, 16)), Color.White, 0.0f, new Vector2(8f, 8f), (float)Game1.pixelZoom, SpriteEffects.None, (float)(((double)tileLocation.Y * (double)Game1.tileSize + (double)(Game1.tileSize / 2) + (((double)tileLocation.Y * 11.0 + (double)tileLocation.X * 7.0) % 10.0 - 5.0)) / 10000.0)); + + + + } } - public override void draw(SpriteBatch spriteBatch, int xNonTile, int yNonTile, float layerDepth, float alpha = 1) + public override void draw(SpriteBatch spriteBatch, int xNonTile, int yNonTile, float layerDepth, float alpha = 1f) { - base.draw(spriteBatch, xNonTile, yNonTile, layerDepth, alpha); + + if (Game1.eventUp && Game1.CurrentEvent.isTileWalkedOn(xNonTile / 64, yNonTile / 64)) + return; + if ((int)(this.ParentSheetIndex) != 590 && (int)(this.Fragility) != 2) + spriteBatch.Draw(Game1.shadowTexture, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(xNonTile + 32), (float)(yNonTile + 51 + 4))), new Microsoft.Xna.Framework.Rectangle?(Game1.shadowTexture.Bounds), Color.White * alpha, 0.0f, new Vector2((float)Game1.shadowTexture.Bounds.Center.X, (float)Game1.shadowTexture.Bounds.Center.Y), 4f, SpriteEffects.None, layerDepth - 1E-06f); + SpriteBatch spriteBatch1 = spriteBatch; + Texture2D objectSpriteSheet = Game1.objectSpriteSheet; + Vector2 local = Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(xNonTile + 32 + (this.shakeTimer > 0 ? Game1.random.Next(-1, 2) : 0)), (float)(yNonTile + 32 + (this.shakeTimer > 0 ? Game1.random.Next(-1, 2) : 0)))); + Microsoft.Xna.Framework.Rectangle? sourceRectangle = new Microsoft.Xna.Framework.Rectangle?(GameLocation.getSourceRectForObject(this.ParentSheetIndex)); + Color color = Color.White * alpha; + double num1 = 0.0; + Vector2 origin = new Vector2(8f, 8f); + Vector2 scale = this.scale; + double num2 = (double)this.scale.Y > 1.0 ? (double)this.getScale().Y : 4.0; + int num3 = (bool)(this.flipped) ? 1 : 0; + double num4 = (double)layerDepth; + spriteBatch1.Draw(this.displayTexture, local, sourceRectangle, color, (float)num1, origin, (float)num2, (SpriteEffects)num3, (float)num4); + } + public override void drawAsProp(SpriteBatch b) { base.drawAsProp(b); @@ -166,9 +248,16 @@ namespace Revitalize.Framework.Objects base.drawAttachments(b, x, y); } - public override void drawInMenu(SpriteBatch spriteBatch, Vector2 location, float scaleSize, float transparency, float layerDepth, bool drawStackNumber, Color color, bool drawShadow) + public override void drawInMenu(SpriteBatch spriteBatch, Vector2 location, float scaleSize, float transparency, float layerDepth, bool drawStackNumber, Color c, bool drawShadow) { - base.drawInMenu(spriteBatch, location, scaleSize, transparency, layerDepth, drawStackNumber, color, drawShadow); + if (drawStackNumber && this.maximumStackSize() > 1 && ((double)scaleSize > 0.3 && this.Stack != int.MaxValue) && this.Stack > 1) + Utility.drawTinyDigits(this.Stack, spriteBatch, location + new Vector2((float)(Game1.tileSize - Utility.getWidthOfTinyDigitString(this.Stack, 3f * scaleSize)) + 3f * scaleSize, (float)((double)Game1.tileSize - 18.0 * (double)scaleSize + 2.0)), 3f * scaleSize, 1f, Color.White); + if (drawStackNumber && this.Quality > 0) + { + float num = this.Quality < 4 ? 0.0f : (float)((Math.Cos((double)Game1.currentGameTime.TotalGameTime.Milliseconds * Math.PI / 512.0) + 1.0) * 0.0500000007450581); + spriteBatch.Draw(Game1.mouseCursors, location + new Vector2(12f, (float)(Game1.tileSize - 12) + num), new Microsoft.Xna.Framework.Rectangle?(this.Quality < 4 ? new Microsoft.Xna.Framework.Rectangle(338 + (this.Quality - 1) * 8, 400, 8, 8) : new Microsoft.Xna.Framework.Rectangle(346, 392, 8, 8)), Color.White * transparency, 0.0f, new Vector2(4f, 4f), (float)(3.0 * (double)scaleSize * (1.0 + (double)num)), SpriteEffects.None, layerDepth); + } + spriteBatch.Draw(this.displayTexture, location + new Vector2((float)(Game1.tileSize), (float)(Game1.tileSize)), new Rectangle?(this.animationManager.currentAnimation.sourceRectangle), Color.White * transparency, 0f, new Vector2((float)(this.animationManager.currentAnimation.sourceRectangle.Width / 2), (float)(this.animationManager.currentAnimation.sourceRectangle.Height)), 1f * 1 * scaleSize * .5f, SpriteEffects.None, layerDepth); } public override void drawPlacementBounds(SpriteBatch spriteBatch, GameLocation location) @@ -176,9 +265,29 @@ namespace Revitalize.Framework.Objects base.drawPlacementBounds(spriteBatch, location); } - public override void drawWhenHeld(SpriteBatch spriteBatch, Vector2 objectPosition, Farmer f) + public override void drawWhenHeld(SpriteBatch spriteBatch, Vector2 objectPosition, StardewValley.Farmer f) { - base.drawWhenHeld(spriteBatch, objectPosition, f); + if (f.ActiveObject.bigCraftable.Value) + { + spriteBatch.Draw(this.displayTexture, objectPosition, this.animationManager.currentAnimation.sourceRectangle, Color.White, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, Math.Max(0f, (float)(f.getStandingY() + 2) / 10000f)); + return; + } + + spriteBatch.Draw(this.displayTexture, objectPosition, this.animationManager.currentAnimation.sourceRectangle, Color.White, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, Math.Max(0f, (float)(f.getStandingY() + 2) / 10000f)); + if (f.ActiveObject != null && f.ActiveObject.Name.Contains("=")) + { + spriteBatch.Draw(this.displayTexture, objectPosition + new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize / 2)), this.animationManager.currentAnimation.sourceRectangle, Color.White, 0f, new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize / 2)), (float)Game1.pixelZoom + Math.Abs(Game1.starCropShimmerPause) / 8f, SpriteEffects.None, Math.Max(0f, (float)(f.getStandingY() + 2) / 10000f)); + if (Math.Abs(Game1.starCropShimmerPause) <= 0.05f && Game1.random.NextDouble() < 0.97) + { + return; + } + Game1.starCropShimmerPause += 0.04f; + if (Game1.starCropShimmerPause >= 0.8f) + { + Game1.starCropShimmerPause = -0.8f; + } + } + //base.drawWhenHeld(spriteBatch, objectPosition, f); } diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index 5d37151b..a98f6f94 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -30,7 +30,7 @@ namespace Revitalize private void GameLoop_SaveLoaded(object sender, StardewModdingAPI.Events.SaveLoadedEventArgs e) { - CustomObject obj = new CustomObject(new BasicItemInformation("CoreObjectTest","YAY FUN!","Omegasis.Revitalize.CoreObject",Color.Violet,-300,1,false,100,Vector2.Zero,true,true,"Omegasis.bleh", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", Game1.objectSpriteSheet,Color.White,0,true,typeof(CustomObject),null)); + CustomObject obj = new CustomObject(new BasicItemInformation("CoreObjectTest","YAY FUN!","Omegasis.Revitalize.CoreObject",Color.Violet,-300,1,false,100,Vector2.Zero,true,true,"Omegasis.bleh", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", Game1.objectSpriteSheet,Color.White,0,true,typeof(CustomObject),null,new Framework.Graphics.Animations.AnimationManager())); new InventoryItem(obj, 100,1).addToNPCShop("Gus"); diff --git a/GeneralMods/Revitalize/Revitalize.csproj b/GeneralMods/Revitalize/Revitalize.csproj index b2e8891d..b74de180 100644 --- a/GeneralMods/Revitalize/Revitalize.csproj +++ b/GeneralMods/Revitalize/Revitalize.csproj @@ -45,6 +45,8 @@ + + diff --git a/GeneralMods/SaveAnywhere/manifest.json b/GeneralMods/SaveAnywhere/manifest.json index f2a0325d..bfaa6bb2 100644 --- a/GeneralMods/SaveAnywhere/manifest.json +++ b/GeneralMods/SaveAnywhere/manifest.json @@ -1,7 +1,7 @@ { "Name": "Save Anywhere", "Author": "Alpha_Omegasis", - "Version": "3.0.0", + "Version": "2.10.0", "Description": "Lets you save almost anywhere.", "UniqueID": "Omegasis.SaveAnywhere", "EntryDll": "SaveAnywhere.dll", diff --git a/GeneralMods/SimpleSoundManager/manifest.json b/GeneralMods/SimpleSoundManager/manifest.json index e5e92fab..a63ef698 100644 --- a/GeneralMods/SimpleSoundManager/manifest.json +++ b/GeneralMods/SimpleSoundManager/manifest.json @@ -1,7 +1,7 @@ { "Name": "Simple Sound Manager", "Author": "Alpha_Omegasis", - "Version": "2.0.1", + "Version": "2.1.0", "Description": "A simple framework to play sounds from wave banks and wav files.", "UniqueID": "Omegasis.SimpleSoundManager", "EntryDll": "SimpleSoundManager.dll", diff --git a/GeneralMods/StardewMods.sln b/GeneralMods/StardewMods.sln index 6c9f6d9a..47b5fc95 100644 --- a/GeneralMods/StardewMods.sln +++ b/GeneralMods/StardewMods.sln @@ -13,8 +13,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BuildHealth", "BuildHealth\ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BuyBackCollectables", "BuyBackCollectables\BuyBackCollectables.csproj", "{A19025C4-E194-4CAD-B156-4AC00BDD2AA3}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CustomShopsRedux", "CustomShopsRedux\CustomShopsRedux.csproj", "{29F7DE68-4C76-471E-86FB-873794802ADC}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DailyQuestAnywhere", "DailyQuestAnywhere\DailyQuestAnywhere.csproj", "{AC4B84F5-31E4-4A55-B13F-A5189C552343}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Fall28SnowDay", "Fall28SnowDay\Fall28SnowDay.csproj", "{1DBB583D-4A4F-4A46-8CC5-42017C93D292}" @@ -68,8 +66,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FarmersMarketStall", "Farme {BB737337-2D82-4245-AA46-F3B82FC6F228} = {BB737337-2D82-4245-AA46-F3B82FC6F228} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DebugSandBoxAndReferences", "DebugSandBoxAndReferences\DebugSandBoxAndReferences.csproj", "{B196EB60-5042-46B9-BEAA-3020E539CB9F}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AdditionalCropsFramework", "AdditionalCropsFramework\AdditionalCropsFramework.csproj", "{C5F88D48-EA20-40CD-91E2-C8725DC11795}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AdvancedSaveBackup", "AdvancedSaveBackup\AdvancedSaveBackup.csproj", "{12984468-2B79-4B3B-B045-EE917301DEE0}" @@ -79,8 +75,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Vocalization", "Vocalizatio {7B1E9A54-ED9E-47AA-BBAA-98A6E7CB527A} = {7B1E9A54-ED9E-47AA-BBAA-98A6E7CB527A} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AUnifiedSaveCore", "UnifiedSaveCore\AUnifiedSaveCore.csproj", "{ACAF0BAE-6495-4F1B-8B1F-E34BF7CCF51A}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Revitalize", "Revitalize\Revitalize.csproj", "{44EF6CEC-FBF1-4B45-8135-81D4EBE84DDD}" EndProject Global @@ -153,18 +147,6 @@ Global {A19025C4-E194-4CAD-B156-4AC00BDD2AA3}.x86|Any CPU.Build.0 = x86|Any CPU {A19025C4-E194-4CAD-B156-4AC00BDD2AA3}.x86|x86.ActiveCfg = x86|x86 {A19025C4-E194-4CAD-B156-4AC00BDD2AA3}.x86|x86.Build.0 = x86|x86 - {29F7DE68-4C76-471E-86FB-873794802ADC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {29F7DE68-4C76-471E-86FB-873794802ADC}.Debug|Any CPU.Build.0 = Debug|Any CPU - {29F7DE68-4C76-471E-86FB-873794802ADC}.Debug|x86.ActiveCfg = Debug|x86 - {29F7DE68-4C76-471E-86FB-873794802ADC}.Debug|x86.Build.0 = Debug|x86 - {29F7DE68-4C76-471E-86FB-873794802ADC}.Release|Any CPU.ActiveCfg = Release|Any CPU - {29F7DE68-4C76-471E-86FB-873794802ADC}.Release|Any CPU.Build.0 = Release|Any CPU - {29F7DE68-4C76-471E-86FB-873794802ADC}.Release|x86.ActiveCfg = Release|x86 - {29F7DE68-4C76-471E-86FB-873794802ADC}.Release|x86.Build.0 = Release|x86 - {29F7DE68-4C76-471E-86FB-873794802ADC}.x86|Any CPU.ActiveCfg = x86|Any CPU - {29F7DE68-4C76-471E-86FB-873794802ADC}.x86|Any CPU.Build.0 = x86|Any CPU - {29F7DE68-4C76-471E-86FB-873794802ADC}.x86|x86.ActiveCfg = x86|x86 - {29F7DE68-4C76-471E-86FB-873794802ADC}.x86|x86.Build.0 = x86|x86 {AC4B84F5-31E4-4A55-B13F-A5189C552343}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {AC4B84F5-31E4-4A55-B13F-A5189C552343}.Debug|Any CPU.Build.0 = Debug|Any CPU {AC4B84F5-31E4-4A55-B13F-A5189C552343}.Debug|x86.ActiveCfg = Debug|x86 @@ -357,18 +339,6 @@ Global {0E37BE57-6B3C-4C79-A134-D16283D5306D}.x86|Any CPU.Build.0 = x86|Any CPU {0E37BE57-6B3C-4C79-A134-D16283D5306D}.x86|x86.ActiveCfg = x86|x86 {0E37BE57-6B3C-4C79-A134-D16283D5306D}.x86|x86.Build.0 = x86|x86 - {B196EB60-5042-46B9-BEAA-3020E539CB9F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B196EB60-5042-46B9-BEAA-3020E539CB9F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B196EB60-5042-46B9-BEAA-3020E539CB9F}.Debug|x86.ActiveCfg = Debug|x86 - {B196EB60-5042-46B9-BEAA-3020E539CB9F}.Debug|x86.Build.0 = Debug|x86 - {B196EB60-5042-46B9-BEAA-3020E539CB9F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B196EB60-5042-46B9-BEAA-3020E539CB9F}.Release|Any CPU.Build.0 = Release|Any CPU - {B196EB60-5042-46B9-BEAA-3020E539CB9F}.Release|x86.ActiveCfg = Release|x86 - {B196EB60-5042-46B9-BEAA-3020E539CB9F}.Release|x86.Build.0 = Release|x86 - {B196EB60-5042-46B9-BEAA-3020E539CB9F}.x86|Any CPU.ActiveCfg = x86|Any CPU - {B196EB60-5042-46B9-BEAA-3020E539CB9F}.x86|Any CPU.Build.0 = x86|Any CPU - {B196EB60-5042-46B9-BEAA-3020E539CB9F}.x86|x86.ActiveCfg = x86|x86 - {B196EB60-5042-46B9-BEAA-3020E539CB9F}.x86|x86.Build.0 = x86|x86 {C5F88D48-EA20-40CD-91E2-C8725DC11795}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {C5F88D48-EA20-40CD-91E2-C8725DC11795}.Debug|Any CPU.Build.0 = Debug|Any CPU {C5F88D48-EA20-40CD-91E2-C8725DC11795}.Debug|x86.ActiveCfg = Debug|x86 @@ -405,18 +375,6 @@ Global {1651701C-DB36-43C7-B66D-2700171DD9A9}.x86|Any CPU.Build.0 = Release|Any CPU {1651701C-DB36-43C7-B66D-2700171DD9A9}.x86|x86.ActiveCfg = Release|Any CPU {1651701C-DB36-43C7-B66D-2700171DD9A9}.x86|x86.Build.0 = Release|Any CPU - {ACAF0BAE-6495-4F1B-8B1F-E34BF7CCF51A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {ACAF0BAE-6495-4F1B-8B1F-E34BF7CCF51A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {ACAF0BAE-6495-4F1B-8B1F-E34BF7CCF51A}.Debug|x86.ActiveCfg = Debug|Any CPU - {ACAF0BAE-6495-4F1B-8B1F-E34BF7CCF51A}.Debug|x86.Build.0 = Debug|Any CPU - {ACAF0BAE-6495-4F1B-8B1F-E34BF7CCF51A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {ACAF0BAE-6495-4F1B-8B1F-E34BF7CCF51A}.Release|Any CPU.Build.0 = Release|Any CPU - {ACAF0BAE-6495-4F1B-8B1F-E34BF7CCF51A}.Release|x86.ActiveCfg = Release|Any CPU - {ACAF0BAE-6495-4F1B-8B1F-E34BF7CCF51A}.Release|x86.Build.0 = Release|Any CPU - {ACAF0BAE-6495-4F1B-8B1F-E34BF7CCF51A}.x86|Any CPU.ActiveCfg = Release|Any CPU - {ACAF0BAE-6495-4F1B-8B1F-E34BF7CCF51A}.x86|Any CPU.Build.0 = Release|Any CPU - {ACAF0BAE-6495-4F1B-8B1F-E34BF7CCF51A}.x86|x86.ActiveCfg = Release|Any CPU - {ACAF0BAE-6495-4F1B-8B1F-E34BF7CCF51A}.x86|x86.Build.0 = Release|Any CPU {44EF6CEC-FBF1-4B45-8135-81D4EBE84DDD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {44EF6CEC-FBF1-4B45-8135-81D4EBE84DDD}.Debug|Any CPU.Build.0 = Debug|Any CPU {44EF6CEC-FBF1-4B45-8135-81D4EBE84DDD}.Debug|x86.ActiveCfg = Debug|Any CPU diff --git a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/manifest.json b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/manifest.json index 8a0c53a7..7e6a067f 100644 --- a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/manifest.json +++ b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/manifest.json @@ -1,7 +1,7 @@ { "Name": "Stardew Symphony Remastered", "Author": "Alpha_Omegasis", - "Version": "2.1.7", + "Version": "2.2.0", "Description": "Adding more music to the game one beep at a time. Now with streaming!", "UniqueID": "Omegasis.StardewSymphonyRemastered", "EntryDll": "StardewSymphonyRemastered.dll", diff --git a/GeneralMods/StardustCore/manifest.json b/GeneralMods/StardustCore/manifest.json index 033a06b3..48a12f4b 100644 --- a/GeneralMods/StardustCore/manifest.json +++ b/GeneralMods/StardustCore/manifest.json @@ -1,7 +1,7 @@ { "Name": "StardustCore", "Author": "Alpha_Omegasis", - "Version": "2.0.5", + "Version": "2.1.0", "Description": "A core mod that allows for other mods of mine to be run.", "UniqueID": "Omegasis.StardustCore", "EntryDll": "StardustCore.dll", diff --git a/GeneralMods/TimeFreeze/manifest.json b/GeneralMods/TimeFreeze/manifest.json index 24129c43..f96a7755 100644 --- a/GeneralMods/TimeFreeze/manifest.json +++ b/GeneralMods/TimeFreeze/manifest.json @@ -1,7 +1,7 @@ { "Name": "Time Freeze", "Author": "Alpha_Omegasis", - "Version": "1.5.1", + "Version": "1.6.0", "Description": "Emulates old Harvest Moon-style games where time is frozen inside.", "UniqueID": "Omegasis.TimeFreeze", "EntryDll": "TimeFreeze.dll", From 6328bfe5b39c9aa45f4e4499cd90506783b26319 Mon Sep 17 00:00:00 2001 From: Joshua Navarro Date: Fri, 21 Dec 2018 16:00:44 -0800 Subject: [PATCH 04/72] Properly remove objects from world by picking up and with destorying them with tools. --- .../Framework/Objects/CustomObject.cs | 37 +++++++++++++++++-- GeneralMods/Revitalize/ModCore.cs | 2 +- 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs index b569f9cb..13e0c012 100644 --- a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs +++ b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs @@ -74,6 +74,7 @@ namespace Revitalize.Framework.Objects this.updateDrawPosition(); + this.bigCraftable.Value = false; } @@ -134,7 +135,35 @@ namespace Revitalize.Framework.Objects public override bool clicked(Farmer who) { Revitalize.ModCore.log("Clicky click!"); - return base.clicked(who); + + return removeAndAddToPlayersInventory(); + //return base.clicked(who); + } + + public override bool performToolAction(Tool t, GameLocation location) + { + + if(t.GetType()== typeof(StardewValley.Tools.Axe) || t.GetType()== typeof(StardewValley.Tools.Pickaxe)) + { + Game1.createItemDebris(this, Game1.player.getStandingPosition(), Game1.player.getDirection()); + Game1.player.currentLocation.removeObject(this.TileLocation, false); + return false; + } + + return false; + //return base.performToolAction(t, location); + } + + public virtual bool removeAndAddToPlayersInventory() + { + if (Game1.player.isInventoryFull()) + { + Game1.showRedMessage("Inventory full."); + return false; + } + Game1.player.currentLocation.removeObject(this.TileLocation, false); + Game1.player.addItemToInventory(this); + return true; } public override Color getCategoryColor() @@ -233,10 +262,12 @@ namespace Revitalize.Framework.Objects double num2 = (double)this.scale.Y > 1.0 ? (double)this.getScale().Y : 4.0; int num3 = (bool)(this.flipped) ? 1 : 0; double num4 = (double)layerDepth; - spriteBatch1.Draw(this.displayTexture, local, sourceRectangle, color, (float)num1, origin, (float)num2, (SpriteEffects)num3, (float)num4); + + spriteBatch1.Draw(this.displayTexture, local, this.animationManager.defaultDrawFrame.sourceRectangle, color, (float)num1, origin, (float)num2, (SpriteEffects)num3, (float)num4); } + public override void drawAsProp(SpriteBatch b) { @@ -257,7 +288,7 @@ namespace Revitalize.Framework.Objects float num = this.Quality < 4 ? 0.0f : (float)((Math.Cos((double)Game1.currentGameTime.TotalGameTime.Milliseconds * Math.PI / 512.0) + 1.0) * 0.0500000007450581); spriteBatch.Draw(Game1.mouseCursors, location + new Vector2(12f, (float)(Game1.tileSize - 12) + num), new Microsoft.Xna.Framework.Rectangle?(this.Quality < 4 ? new Microsoft.Xna.Framework.Rectangle(338 + (this.Quality - 1) * 8, 400, 8, 8) : new Microsoft.Xna.Framework.Rectangle(346, 392, 8, 8)), Color.White * transparency, 0.0f, new Vector2(4f, 4f), (float)(3.0 * (double)scaleSize * (1.0 + (double)num)), SpriteEffects.None, layerDepth); } - spriteBatch.Draw(this.displayTexture, location + new Vector2((float)(Game1.tileSize), (float)(Game1.tileSize)), new Rectangle?(this.animationManager.currentAnimation.sourceRectangle), Color.White * transparency, 0f, new Vector2((float)(this.animationManager.currentAnimation.sourceRectangle.Width / 2), (float)(this.animationManager.currentAnimation.sourceRectangle.Height)), 1f * 1 * scaleSize * .5f, SpriteEffects.None, layerDepth); + spriteBatch.Draw(this.displayTexture, location + new Vector2((float)(Game1.tileSize), (float)(Game1.tileSize)), new Rectangle?(this.animationManager.currentAnimation.sourceRectangle), Color.White * transparency, 0f, new Vector2((float)(this.animationManager.currentAnimation.sourceRectangle.Width / 2), (float)(this.animationManager.currentAnimation.sourceRectangle.Height)), scaleSize, SpriteEffects.None, layerDepth); } public override void drawPlacementBounds(SpriteBatch spriteBatch, GameLocation location) diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index a98f6f94..46f62943 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -30,7 +30,7 @@ namespace Revitalize private void GameLoop_SaveLoaded(object sender, StardewModdingAPI.Events.SaveLoadedEventArgs e) { - CustomObject obj = new CustomObject(new BasicItemInformation("CoreObjectTest","YAY FUN!","Omegasis.Revitalize.CoreObject",Color.Violet,-300,1,false,100,Vector2.Zero,true,true,"Omegasis.bleh", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", Game1.objectSpriteSheet,Color.White,0,true,typeof(CustomObject),null,new Framework.Graphics.Animations.AnimationManager())); + CustomObject obj = new CustomObject(new BasicItemInformation("CoreObjectTest","YAY FUN!","Omegasis.Revitalize.CoreObject",Color.Violet,-300,0,false,100,Vector2.Zero,true,true,"Omegasis.bleh", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", Game1.objectSpriteSheet,Color.White,0,true,typeof(CustomObject),null,new Framework.Graphics.Animations.AnimationManager())); new InventoryItem(obj, 100,1).addToNPCShop("Gus"); From 8fb7a9062c84601a5f6463694d883006482f4538 Mon Sep 17 00:00:00 2001 From: Joshua Navarro Date: Sat, 22 Dec 2018 22:34:53 -0800 Subject: [PATCH 05/72] Got draw in menu working. Next: Draw at non-tile spot. --- GeneralMods/Revitalize/Framework/Objects/CustomObject.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs index 13e0c012..90ae8a6f 100644 --- a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs +++ b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs @@ -288,7 +288,7 @@ namespace Revitalize.Framework.Objects float num = this.Quality < 4 ? 0.0f : (float)((Math.Cos((double)Game1.currentGameTime.TotalGameTime.Milliseconds * Math.PI / 512.0) + 1.0) * 0.0500000007450581); spriteBatch.Draw(Game1.mouseCursors, location + new Vector2(12f, (float)(Game1.tileSize - 12) + num), new Microsoft.Xna.Framework.Rectangle?(this.Quality < 4 ? new Microsoft.Xna.Framework.Rectangle(338 + (this.Quality - 1) * 8, 400, 8, 8) : new Microsoft.Xna.Framework.Rectangle(346, 392, 8, 8)), Color.White * transparency, 0.0f, new Vector2(4f, 4f), (float)(3.0 * (double)scaleSize * (1.0 + (double)num)), SpriteEffects.None, layerDepth); } - spriteBatch.Draw(this.displayTexture, location + new Vector2((float)(Game1.tileSize), (float)(Game1.tileSize)), new Rectangle?(this.animationManager.currentAnimation.sourceRectangle), Color.White * transparency, 0f, new Vector2((float)(this.animationManager.currentAnimation.sourceRectangle.Width / 2), (float)(this.animationManager.currentAnimation.sourceRectangle.Height)), scaleSize, SpriteEffects.None, layerDepth); + spriteBatch.Draw(this.displayTexture, location + new Vector2((float)(Game1.tileSize/2), (float)(Game1.tileSize*.75)), new Rectangle?(this.animationManager.currentAnimation.sourceRectangle), Color.White * transparency, 0f, new Vector2((float)(this.animationManager.currentAnimation.sourceRectangle.Width / 2), (float)(this.animationManager.currentAnimation.sourceRectangle.Height)), 3f, SpriteEffects.None, layerDepth); } public override void drawPlacementBounds(SpriteBatch spriteBatch, GameLocation location) From 65ab0812b755a4c2531be9573193baaf5742b9df Mon Sep 17 00:00:00 2001 From: Joshua Navarro Date: Sat, 22 Dec 2018 22:40:31 -0800 Subject: [PATCH 06/72] Got drawing at non tile spot working. --- GeneralMods/Revitalize/Framework/Objects/CustomObject.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs index 90ae8a6f..95a0707c 100644 --- a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs +++ b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs @@ -263,7 +263,7 @@ namespace Revitalize.Framework.Objects int num3 = (bool)(this.flipped) ? 1 : 0; double num4 = (double)layerDepth; - spriteBatch1.Draw(this.displayTexture, local, this.animationManager.defaultDrawFrame.sourceRectangle, color, (float)num1, origin, (float)num2, (SpriteEffects)num3, (float)num4); + spriteBatch1.Draw(this.displayTexture, local, this.animationManager.defaultDrawFrame.sourceRectangle, color, (float)num1, origin, (float)4f, (SpriteEffects)num3, (float)num4); } From 591a6f4a9698d190e5e004727afb88001790ee4c Mon Sep 17 00:00:00 2001 From: Joshua Navarro Date: Sat, 22 Dec 2018 22:55:03 -0800 Subject: [PATCH 07/72] Got customizable draw colors working. --- .../Framework/Objects/BasicItemInformation.cs | 15 +- .../Framework/Objects/CustomObject.cs | 132 ++++++++++++++++-- GeneralMods/Revitalize/ModCore.cs | 2 +- 3 files changed, 135 insertions(+), 14 deletions(-) diff --git a/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs b/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs index 3f29e0f4..2a277a07 100644 --- a/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs +++ b/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs @@ -27,6 +27,8 @@ namespace Revitalize.Framework.Objects public AnimationManager animationManager; public Vector2 drawPosition; + public Color drawColor; + public BasicItemInformation() : base() { name = ""; @@ -41,9 +43,10 @@ namespace Revitalize.Framework.Objects this.animationManager = null; this.drawPosition = Vector2.Zero; + this.drawColor = Color.White; } - public BasicItemInformation(string name, string description, string categoryName, Color categoryColor,int edibility,int fragility,bool isLamp,int price, Vector2 TileLocation,bool canBeSetOutdoors,bool canBeSetIndoors,string id, string data, Texture2D texture, Color color,int tileIndex, bool bigCraftable, Type type, CraftingData craftingData, AnimationManager animationManager):base(id,data,texture,color,tileIndex,bigCraftable,type,craftingData) + public BasicItemInformation(string name, string description, string categoryName, Color categoryColor,int edibility,int fragility,bool isLamp,int price, Vector2 TileLocation,bool canBeSetOutdoors,bool canBeSetIndoors,string id, string data, Texture2D texture, Color color,int tileIndex, bool bigCraftable, Type type, CraftingData craftingData, AnimationManager animationManager,Color DrawColor):base(id,data,texture,color,tileIndex,bigCraftable,type,craftingData) { this.name = name; this.description = description; @@ -71,6 +74,16 @@ namespace Revitalize.Framework.Objects this.drawPosition = Vector2.Zero; + if (DrawColor == null) + { + this.drawColor = Color.White; + } + else + { + this.drawColor = DrawColor; + } + + recreateDataString(); } diff --git a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs index 95a0707c..9e208fe1 100644 --- a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs +++ b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs @@ -16,7 +16,7 @@ using System.Threading.Tasks; namespace Revitalize.Framework.Objects { /// - /// Change draw functions. + /// A custom object template. /// public class CustomObject : PySObject { @@ -24,7 +24,9 @@ namespace Revitalize.Framework.Objects public string id; public BasicItemInformation info; - + /// + /// The animation manager. + /// public AnimationManager animationManager { get @@ -33,7 +35,9 @@ namespace Revitalize.Framework.Objects } } - + /// + /// The display texture for this object. + /// public Texture2D displayTexture { get @@ -42,24 +46,38 @@ namespace Revitalize.Framework.Objects } } - + /// + /// Empty constructor. + /// public CustomObject() { } + /// + /// Constructor. + /// + /// public CustomObject(BasicItemInformation info):base(info,Vector2.Zero) { this.info = info; this.initializeBasics(); } + /// + /// Constructor. + /// + /// + /// public CustomObject(BasicItemInformation info,Vector2 TileLocation) : base(info, TileLocation) { this.info = info; this.initializeBasics(); } + /// + /// Sets some basic information up. + /// public virtual void initializeBasics() { this.name = info.name; @@ -78,6 +96,12 @@ namespace Revitalize.Framework.Objects } + /// + /// Checks for interaction with the object. + /// + /// + /// + /// public override bool checkForAction(Farmer who, bool justCheckingForActivity = false) { var mState = Microsoft.Xna.Framework.Input.Mouse.GetState(); @@ -107,7 +131,11 @@ namespace Revitalize.Framework.Objects return new CustomObject((BasicItemInformation) CustomObjectData.collection[additionalSaveData["id"]], (replacement as Chest).TileLocation); } - + /// + /// What happens when the player right clicks the object. + /// + /// + /// public virtual bool rightClicked(Farmer who) { // Game1.showRedMessage("YOOO"); @@ -126,12 +154,22 @@ namespace Revitalize.Framework.Objects return true; } + /// + /// What happens when the player shift-right clicks this object. + /// + /// + /// public virtual bool shiftRightClicked(Farmer who) { Revitalize.ModCore.log("Shift right clicked!"); return true; } + /// + /// What happens when the player left clicks the object. + /// + /// + /// public override bool clicked(Farmer who) { Revitalize.ModCore.log("Clicky click!"); @@ -140,6 +178,12 @@ namespace Revitalize.Framework.Objects //return base.clicked(who); } + /// + /// What happens when a player uses a tool on this object. + /// + /// + /// + /// public override bool performToolAction(Tool t, GameLocation location) { @@ -154,6 +198,10 @@ namespace Revitalize.Framework.Objects //return base.performToolAction(t, location); } + /// + /// Remove the object from the world and add it to the player's inventory if possible. + /// + /// public virtual bool removeAndAddToPlayersInventory() { if (Game1.player.isInventoryFull()) @@ -166,17 +214,29 @@ namespace Revitalize.Framework.Objects return true; } + /// + /// Gets the category color for the object. + /// + /// public override Color getCategoryColor() { return info.categoryColor; //return data.categoryColor; } + /// + /// Gets the category name for the object. + /// + /// public override string getCategoryName() { return info.categoryName; } + /// + /// Gets the description for the object. + /// + /// public override string getDescription() { string text = info.description; @@ -185,27 +245,49 @@ namespace Revitalize.Framework.Objects return Game1.parseText(text, smallFont, width); } + /// + /// Places an object down. + /// + /// + /// + /// + /// + /// public override bool placementAction(GameLocation location, int x, int y, Farmer who = null) { this.updateDrawPosition(); return base.placementAction(location, x, y, who); } + /// + /// Updates a visual draw position. + /// public virtual void updateDrawPosition() { this.info.drawPosition = new Vector2((float)this.boundingBox.X, (float)(this.boundingBox.Y - (this.animationManager.currentAnimation.sourceRectangle.Height * Game1.pixelZoom - this.boundingBox.Height))); } + /// + /// Gets a clone of the game object. + /// + /// public override Item getOne() { return new CustomObject((BasicItemInformation)this.data); } + /// + /// What happens when the object is drawn at a tile location. + /// + /// + /// + /// + /// public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1f) { if (x == -1) { - spriteBatch.Draw(this.info.animationManager.getTexture(), Game1.GlobalToLocal(Game1.viewport, this.info.drawPosition), new Rectangle?(this.animationManager.currentAnimation.sourceRectangle), Color.White * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0); + spriteBatch.Draw(this.info.animationManager.getTexture(), Game1.GlobalToLocal(Game1.viewport, this.info.drawPosition), new Rectangle?(this.animationManager.currentAnimation.sourceRectangle), info.drawColor * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0); } else { @@ -218,14 +300,14 @@ namespace Revitalize.Framework.Objects } - spriteBatch.Draw(this.displayTexture, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(x * Game1.tileSize), y * Game1.tileSize)), new Rectangle?(this.animationManager.currentAnimation.sourceRectangle), Color.White * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0); + spriteBatch.Draw(this.displayTexture, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(x * Game1.tileSize), y * Game1.tileSize)), new Rectangle?(this.animationManager.currentAnimation.sourceRectangle), info.drawColor * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0); // Log.AsyncG("ANIMATION IS NULL?!?!?!?!"); } else { //Log.AsyncC("Animation Manager is working!"); - this.animationManager.draw(spriteBatch, this.displayTexture, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(x * Game1.tileSize), y * Game1.tileSize)), new Rectangle?(this.animationManager.currentAnimation.sourceRectangle), Color.White * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0); + this.animationManager.draw(spriteBatch, this.displayTexture, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(x * Game1.tileSize), y * Game1.tileSize)), new Rectangle?(this.animationManager.currentAnimation.sourceRectangle), info.drawColor * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0); try { this.animationManager.tickAnimation(); @@ -244,6 +326,14 @@ namespace Revitalize.Framework.Objects } } + /// + /// Draw the game object at a non-tile spot. Aka like debris. + /// + /// + /// + /// + /// + /// public override void draw(SpriteBatch spriteBatch, int xNonTile, int yNonTile, float layerDepth, float alpha = 1f) { @@ -263,7 +353,7 @@ namespace Revitalize.Framework.Objects int num3 = (bool)(this.flipped) ? 1 : 0; double num4 = (double)layerDepth; - spriteBatch1.Draw(this.displayTexture, local, this.animationManager.defaultDrawFrame.sourceRectangle, color, (float)num1, origin, (float)4f, (SpriteEffects)num3, (float)num4); + spriteBatch1.Draw(this.displayTexture, local, this.animationManager.defaultDrawFrame.sourceRectangle, info.drawColor*alpha, (float)num1, origin, (float)4f, (SpriteEffects)num3, (float)num4); } @@ -279,6 +369,17 @@ namespace Revitalize.Framework.Objects base.drawAttachments(b, x, y); } + /// + /// What happens when the object is drawn in a menu. + /// + /// + /// + /// + /// + /// + /// + /// + /// public override void drawInMenu(SpriteBatch spriteBatch, Vector2 location, float scaleSize, float transparency, float layerDepth, bool drawStackNumber, Color c, bool drawShadow) { if (drawStackNumber && this.maximumStackSize() > 1 && ((double)scaleSize > 0.3 && this.Stack != int.MaxValue) && this.Stack > 1) @@ -288,7 +389,7 @@ namespace Revitalize.Framework.Objects float num = this.Quality < 4 ? 0.0f : (float)((Math.Cos((double)Game1.currentGameTime.TotalGameTime.Milliseconds * Math.PI / 512.0) + 1.0) * 0.0500000007450581); spriteBatch.Draw(Game1.mouseCursors, location + new Vector2(12f, (float)(Game1.tileSize - 12) + num), new Microsoft.Xna.Framework.Rectangle?(this.Quality < 4 ? new Microsoft.Xna.Framework.Rectangle(338 + (this.Quality - 1) * 8, 400, 8, 8) : new Microsoft.Xna.Framework.Rectangle(346, 392, 8, 8)), Color.White * transparency, 0.0f, new Vector2(4f, 4f), (float)(3.0 * (double)scaleSize * (1.0 + (double)num)), SpriteEffects.None, layerDepth); } - spriteBatch.Draw(this.displayTexture, location + new Vector2((float)(Game1.tileSize/2), (float)(Game1.tileSize*.75)), new Rectangle?(this.animationManager.currentAnimation.sourceRectangle), Color.White * transparency, 0f, new Vector2((float)(this.animationManager.currentAnimation.sourceRectangle.Width / 2), (float)(this.animationManager.currentAnimation.sourceRectangle.Height)), 3f, SpriteEffects.None, layerDepth); + spriteBatch.Draw(this.displayTexture, location + new Vector2((float)(Game1.tileSize/2), (float)(Game1.tileSize*.75)), new Rectangle?(this.animationManager.currentAnimation.sourceRectangle), info.drawColor*transparency, 0f, new Vector2((float)(this.animationManager.currentAnimation.sourceRectangle.Width / 2), (float)(this.animationManager.currentAnimation.sourceRectangle.Height)), 3f, SpriteEffects.None, layerDepth); } public override void drawPlacementBounds(SpriteBatch spriteBatch, GameLocation location) @@ -296,15 +397,22 @@ namespace Revitalize.Framework.Objects base.drawPlacementBounds(spriteBatch, location); } + + /// + /// What happens when the object is drawn when held by a player. + /// + /// + /// + /// public override void drawWhenHeld(SpriteBatch spriteBatch, Vector2 objectPosition, StardewValley.Farmer f) { if (f.ActiveObject.bigCraftable.Value) { - spriteBatch.Draw(this.displayTexture, objectPosition, this.animationManager.currentAnimation.sourceRectangle, Color.White, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, Math.Max(0f, (float)(f.getStandingY() + 2) / 10000f)); + spriteBatch.Draw(this.displayTexture, objectPosition, this.animationManager.currentAnimation.sourceRectangle, info.drawColor, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, Math.Max(0f, (float)(f.getStandingY() + 2) / 10000f)); return; } - spriteBatch.Draw(this.displayTexture, objectPosition, this.animationManager.currentAnimation.sourceRectangle, Color.White, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, Math.Max(0f, (float)(f.getStandingY() + 2) / 10000f)); + spriteBatch.Draw(this.displayTexture, objectPosition, this.animationManager.currentAnimation.sourceRectangle, info.drawColor, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, Math.Max(0f, (float)(f.getStandingY() + 2) / 10000f)); if (f.ActiveObject != null && f.ActiveObject.Name.Contains("=")) { spriteBatch.Draw(this.displayTexture, objectPosition + new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize / 2)), this.animationManager.currentAnimation.sourceRectangle, Color.White, 0f, new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize / 2)), (float)Game1.pixelZoom + Math.Abs(Game1.starCropShimmerPause) / 8f, SpriteEffects.None, Math.Max(0f, (float)(f.getStandingY() + 2) / 10000f)); diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index 46f62943..924875d8 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -30,7 +30,7 @@ namespace Revitalize private void GameLoop_SaveLoaded(object sender, StardewModdingAPI.Events.SaveLoadedEventArgs e) { - CustomObject obj = new CustomObject(new BasicItemInformation("CoreObjectTest","YAY FUN!","Omegasis.Revitalize.CoreObject",Color.Violet,-300,0,false,100,Vector2.Zero,true,true,"Omegasis.bleh", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", Game1.objectSpriteSheet,Color.White,0,true,typeof(CustomObject),null,new Framework.Graphics.Animations.AnimationManager())); + CustomObject obj = new CustomObject(new BasicItemInformation("CoreObjectTest","YAY FUN!","Omegasis.Revitalize.CoreObject",Color.Violet,-300,0,false,100,Vector2.Zero,true,true,"Omegasis.bleh", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", Game1.objectSpriteSheet,Color.White,0,true,typeof(CustomObject),null,new Framework.Graphics.Animations.AnimationManager(),Color.Red)); new InventoryItem(obj, 100,1).addToNPCShop("Gus"); From f46379f9e6cdbf6602f16faa03758b706a78b748 Mon Sep 17 00:00:00 2001 From: Joshua Navarro Date: Sun, 23 Dec 2018 00:53:43 -0800 Subject: [PATCH 08/72] Got multi-tiled objects and components working at a surprising speed actually. --- .../Framework/Graphics/Texture2DExtended.cs | 9 + .../Framework/Objects/CustomObject.cs | 7 + .../Framework/Objects/MultiTiledComponent.cs | 110 +++++++++ .../Framework/Objects/MultiTiledObject.cs | 216 ++++++++++++++++++ GeneralMods/Revitalize/ModCore.cs | 15 +- GeneralMods/Revitalize/Revitalize.csproj | 2 + 6 files changed, 356 insertions(+), 3 deletions(-) create mode 100644 GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs create mode 100644 GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs diff --git a/GeneralMods/Revitalize/Framework/Graphics/Texture2DExtended.cs b/GeneralMods/Revitalize/Framework/Graphics/Texture2DExtended.cs index af6d4499..3d316a96 100644 --- a/GeneralMods/Revitalize/Framework/Graphics/Texture2DExtended.cs +++ b/GeneralMods/Revitalize/Framework/Graphics/Texture2DExtended.cs @@ -30,6 +30,15 @@ namespace Revitalize.Framework.Graphics this.modID = ""; } + public Texture2DExtended(Texture2D Texture) + { + this.Name = ""; + this.texture = Texture; + this.path = ""; + this.helper = null; + this.modID = ""; + } + /// /// Constructor. /// diff --git a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs index 9e208fe1..e9c7d6ce 100644 --- a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs +++ b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs @@ -24,6 +24,8 @@ namespace Revitalize.Framework.Objects public string id; public BasicItemInformation info; + public GameLocation location; + /// /// The animation manager. /// @@ -174,6 +176,8 @@ namespace Revitalize.Framework.Objects { Revitalize.ModCore.log("Clicky click!"); + Revitalize.ModCore.log(System.Environment.StackTrace); + return removeAndAddToPlayersInventory(); //return base.clicked(who); } @@ -190,6 +194,7 @@ namespace Revitalize.Framework.Objects if(t.GetType()== typeof(StardewValley.Tools.Axe) || t.GetType()== typeof(StardewValley.Tools.Pickaxe)) { Game1.createItemDebris(this, Game1.player.getStandingPosition(), Game1.player.getDirection()); + this.location = null; Game1.player.currentLocation.removeObject(this.TileLocation, false); return false; } @@ -209,6 +214,7 @@ namespace Revitalize.Framework.Objects Game1.showRedMessage("Inventory full."); return false; } + this.location = null; Game1.player.currentLocation.removeObject(this.TileLocation, false); Game1.player.addItemToInventory(this); return true; @@ -256,6 +262,7 @@ namespace Revitalize.Framework.Objects public override bool placementAction(GameLocation location, int x, int y, Farmer who = null) { this.updateDrawPosition(); + this.location = location; return base.placementAction(location, x, y, who); } diff --git a/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs b/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs new file mode 100644 index 00000000..b0c366d4 --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs @@ -0,0 +1,110 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using PyTK.CustomElementHandler; +using StardewValley; +using StardewValley.Objects; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Revitalize.Framework.Objects +{ + public class MultiTiledComponent:CustomObject + { + + public MultiTiledObject containerObject; + + public MultiTiledComponent():base() + { + + } + + public MultiTiledComponent(BasicItemInformation info):base(info) + { + + } + + public MultiTiledComponent(BasicItemInformation info, Vector2 TileLocation): base(info, TileLocation) + { + + } + + public override bool checkForAction(Farmer who, bool justCheckingForActivity = false) + { + //Revitalize.ModCore.log("Checking for a clicky click???"); + return base.checkForAction(who, justCheckingForActivity); + } + + public override bool clicked(Farmer who) + { + + Revitalize.ModCore.log("Clicked a multiTiledComponent!"); + this.containerObject.pickUp(); + return true; + //return base.clicked(who); + } + + + + public override void performRemoveAction(Vector2 tileLocation, GameLocation environment) + { + base.performRemoveAction(this.TileLocation, environment); + } + + public virtual void removeFromLocation(GameLocation location,Vector2 offset) + { + location.removeObject(this.TileLocation,false); + //this.performRemoveAction(this.TileLocation,location); + } + + /// + /// Places an object down. + /// + /// + /// + /// + /// + /// + public override bool placementAction(GameLocation location, int x, int y, Farmer who = null) + { + Revitalize.ModCore.ModMonitor.Log("SCREAMING!!!!"); + this.updateDrawPosition(); + this.location = location; + + this.TileLocation = new Vector2((int)(x / Game1.tileSize), (int)(y / Game1.tileSize)); + + return base.placementAction(location, x, y, who); + } + + public override void drawInMenu(SpriteBatch spriteBatch, Vector2 location, float scaleSize, float transparency, float layerDepth, bool drawStackNumber, Color c, bool drawShadow) + { + if (drawStackNumber && this.maximumStackSize() > 1 && ((double)scaleSize > 0.3 && this.Stack != int.MaxValue) && this.Stack > 1) + Utility.drawTinyDigits(this.Stack, spriteBatch, location + new Vector2((float)(Game1.tileSize - Utility.getWidthOfTinyDigitString(this.Stack, 3f * scaleSize)) + 3f * scaleSize, (float)((double)Game1.tileSize - 18.0 * (double)scaleSize + 2.0)), 3f * scaleSize, 1f, Color.White); + if (drawStackNumber && this.Quality > 0) + { + float num = this.Quality < 4 ? 0.0f : (float)((Math.Cos((double)Game1.currentGameTime.TotalGameTime.Milliseconds * Math.PI / 512.0) + 1.0) * 0.0500000007450581); + spriteBatch.Draw(Game1.mouseCursors, location + new Vector2(12f, (float)(Game1.tileSize - 12) + num), new Microsoft.Xna.Framework.Rectangle?(this.Quality < 4 ? new Microsoft.Xna.Framework.Rectangle(338 + (this.Quality - 1) * 8, 400, 8, 8) : new Microsoft.Xna.Framework.Rectangle(346, 392, 8, 8)), Color.White * transparency, 0.0f, new Vector2(4f, 4f), (float)(3.0 * (double)scaleSize * (1.0 + (double)num)), SpriteEffects.None, layerDepth); + } + spriteBatch.Draw(this.displayTexture, location + new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize * .75)), new Rectangle?(this.animationManager.currentAnimation.sourceRectangle), info.drawColor * transparency, 0f, new Vector2((float)(this.animationManager.currentAnimation.sourceRectangle.Width / 2), (float)(this.animationManager.currentAnimation.sourceRectangle.Height)), scaleSize, SpriteEffects.None, layerDepth); + } + + public override Item getOne() + { + MultiTiledComponent component=new MultiTiledComponent(this.info, this.TileLocation); + component.containerObject = this.containerObject; + return component; + + } + + public override ICustomObject recreate(Dictionary additionalSaveData, object replacement) + { + BasicItemInformation data = (BasicItemInformation)CustomObjectData.collection[additionalSaveData["id"]]; + MultiTiledComponent component= new MultiTiledComponent((BasicItemInformation)CustomObjectData.collection[additionalSaveData["id"]], (replacement as Chest).TileLocation); + component.containerObject = this.containerObject; + return containerObject; + } + + } +} diff --git a/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs b/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs new file mode 100644 index 00000000..bc30ba63 --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs @@ -0,0 +1,216 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using PyTK.CustomElementHandler; +using StardewValley; +using StardewValley.Objects; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Revitalize.Framework.Objects +{ + public class MultiTiledObject:CustomObject + { + public Dictionary objects; + + public MultiTiledObject() : base() + { + + this.objects = new Dictionary(); + } + + public MultiTiledObject(BasicItemInformation info) : base(info) + { + this.objects = new Dictionary(); + } + + public MultiTiledObject(BasicItemInformation info, Vector2 TileLocation) : base(info, TileLocation) + { + this.objects = new Dictionary(); + } + + public MultiTiledObject(BasicItemInformation info, Vector2 TileLocation, Dictionary ObjectsList) : base(info, TileLocation) + { + this.objects = new Dictionary(); + foreach(var v in ObjectsList) + { + MultiTiledComponent component =(MultiTiledComponent)v.Value.getOne(); + this.addComponent(v.Key, component); + } + } + + public bool addComponent(Vector2 key, MultiTiledComponent obj) + { + if (this.objects.ContainsKey(key)) + { + return false; + } + else + { + this.objects.Add(key, obj); + obj.containerObject = this; + return true; + } + } + + public bool removeComponent(Vector2 key) + { + if (!this.objects.ContainsKey(key)) + { + return false; + } + else + { + this.objects.Remove(key); + return true; + } + } + + public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1) + { + foreach (KeyValuePair pair in this.objects) + { + pair.Value.draw(spriteBatch, x + (int)pair.Key.X * Game1.tileSize, y + (int)pair.Key.Y * Game1.tileSize, alpha); + } + } + + public override void draw(SpriteBatch spriteBatch, int xNonTile, int yNonTile, float layerDepth, float alpha = 1) + { + foreach (KeyValuePair pair in this.objects) + { + pair.Value.draw(spriteBatch, xNonTile + (int)pair.Key.X * Game1.tileSize, yNonTile+ (int)pair.Key.Y * Game1.tileSize, layerDepth, alpha); + } + + //base.draw(spriteBatch, xNonTile, yNonTile, layerDepth, alpha); + } + + public override void drawAsProp(SpriteBatch b) + { + base.drawAsProp(b); + } + + public override void drawAttachments(SpriteBatch b, int x, int y) + { + base.drawAttachments(b, x, y); + } + + public override void drawInMenu(SpriteBatch spriteBatch, Vector2 location, float scaleSize, float transparency, float layerDepth, bool drawStackNumber, Color c, bool drawShadow) + { + foreach (KeyValuePair pair in this.objects) + { + pair.Value.drawInMenu(spriteBatch, location + (pair.Key*16), 1.0f, transparency, layerDepth, drawStackNumber, c, drawShadow); + } + //base.drawInMenu(spriteBatch, location, scaleSize, transparency, layerDepth, drawStackNumber, c, drawShadow); + } + + public override void drawPlacementBounds(SpriteBatch spriteBatch, GameLocation location) + { + base.drawPlacementBounds(spriteBatch, location); + } + + public override void drawWhenHeld(SpriteBatch spriteBatch, Vector2 objectPosition, Farmer f) + { + + foreach(KeyValuePair pair in this.objects) + { + pair.Value.drawWhenHeld(spriteBatch, objectPosition + (pair.Key * Game1.tileSize), f); + } + //base.drawWhenHeld(spriteBatch, objectPosition, f); + } + + + + //IMPLEMENT THESE! + + + public virtual void pickUp() + { + bool canPickUp= this.removeAndAddToPlayersInventory(); + if (canPickUp) + { + foreach (KeyValuePair pair in this.objects) + { + pair.Value.removeFromLocation(pair.Value.location,pair.Key); + } + this.location = null; + } + else + { + Game1.showRedMessage("NOOOOOOOO"); + } + } + + public override bool removeAndAddToPlayersInventory() + { + if (Game1.player.isInventoryFull()) + { + Game1.showRedMessage("Inventory full."); + return false; + } + Game1.player.addItemToInventory(this); + return true; + } + + public override bool placementAction(GameLocation location, int x, int y, Farmer who = null) + { + + foreach(KeyValuePair pair in this.objects) + { + pair.Value.placementAction(location, x + (int)pair.Key.X*Game1.tileSize, y + (int)pair.Key.Y*Game1.tileSize, who); + Revitalize.ModCore.log(pair.Value.TileLocation); + } + this.location = location; + return true; + //return base.placementAction(location, x, y, who); + } + + public override bool canBePlacedHere(GameLocation l, Vector2 tile) + { + foreach(KeyValuePair pair in this.objects) + { + if (pair.Value.canBePlacedHere(l, tile + pair.Key) == false) return false; + } + return true; + + } + public override bool clicked(Farmer who) + { + Revitalize.ModCore.log("WTF IS HAPPENING???"); + bool cleanUp=clicked(who); + if (cleanUp) + { + pickUp(); + } + return cleanUp; + } + + public override bool rightClicked(Farmer who) + { + return base.rightClicked(who); + } + + public override bool shiftRightClicked(Farmer who) + { + return base.shiftRightClicked(who); + } + + public override bool checkForAction(Farmer who, bool justCheckingForActivity = false) + { + + return base.checkForAction(who, justCheckingForActivity); + } + + public override Item getOne() + { + return new MultiTiledObject(this.info, this.TileLocation,this.objects); + } + + public override ICustomObject recreate(Dictionary additionalSaveData, object replacement) + { + BasicItemInformation data = (BasicItemInformation)CustomObjectData.collection[additionalSaveData["id"]]; + return new MultiTiledObject((BasicItemInformation)CustomObjectData.collection[additionalSaveData["id"]], (replacement as Chest).TileLocation,this.objects); + } + } +} diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index 924875d8..427e08e9 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -9,6 +9,8 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Revitalize.Framework.Graphics; +using Revitalize.Framework.Graphics.Animations; namespace Revitalize { @@ -30,11 +32,18 @@ namespace Revitalize private void GameLoop_SaveLoaded(object sender, StardewModdingAPI.Events.SaveLoadedEventArgs e) { - CustomObject obj = new CustomObject(new BasicItemInformation("CoreObjectTest","YAY FUN!","Omegasis.Revitalize.CoreObject",Color.Violet,-300,0,false,100,Vector2.Zero,true,true,"Omegasis.bleh", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", Game1.objectSpriteSheet,Color.White,0,true,typeof(CustomObject),null,new Framework.Graphics.Animations.AnimationManager(),Color.Red)); + MultiTiledComponent obj = new MultiTiledComponent(new BasicItemInformation("CoreObjectTest","YAY FUN!","Omegasis.Revitalize.MultiTiledComponent",Color.White,-300,0,false,100,Vector2.Zero,true,true,"Omegasis.TEST1", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", Game1.objectSpriteSheet,Color.White,0,true,typeof(MultiTiledComponent),null,new AnimationManager(new Texture2DExtended(Game1.objectSpriteSheet),new Animation(new Rectangle(0,0,16,16))),Color.Red)); + MultiTiledComponent obj2 = new MultiTiledComponent(new BasicItemInformation("CoreObjectTest2", "SomeFun", "Omegasis.Revitalize.MultiTiledComponent", Color.White, -300, 0, false, 100, Vector2.Zero, true, true, "Omegasis.TEST1", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", Game1.objectSpriteSheet, Color.White, 0, true, typeof(MultiTiledComponent), null, new AnimationManager(new Texture2DExtended(Game1.objectSpriteSheet), new Animation(new Rectangle(0, 16, 16, 16))), Color.Red)); + MultiTiledComponent obj3 = new MultiTiledComponent(new BasicItemInformation("CoreObjectTest3", "NoFun", "Omegasis.Revitalize.MultiTiledComponent", Color.White, -300, 0, false, 100, Vector2.Zero, true, true, "Omegasis.TEST1", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", Game1.objectSpriteSheet, Color.White, 0, true, typeof(MultiTiledComponent), null, new AnimationManager(new Texture2DExtended(Game1.objectSpriteSheet), new Animation(new Rectangle(0, 32, 16, 16))), Color.Red)); + + MultiTiledObject bigObject= new MultiTiledObject(new BasicItemInformation("MultiTest", "A really big object", "Omegasis.Revitalize.MultiTiledObject", Color.Blue, -300, 0, false, 100, Vector2.Zero, true, true, "Omegasis.BigTiledTest", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", Game1.objectSpriteSheet, Color.White, 0, true, typeof(MultiTiledObject), null, new AnimationManager(), Color.White)); + bigObject.addComponent(new Vector2(0, 0), obj); + bigObject.addComponent(new Vector2(1, 0), obj2); + bigObject.addComponent(new Vector2(2, 0), obj3); - new InventoryItem(obj, 100,1).addToNPCShop("Gus"); - Game1.player.addItemToInventory(obj); + new InventoryItem(bigObject, 100,1).addToNPCShop("Gus"); + Game1.player.addItemToInventory(bigObject); } diff --git a/GeneralMods/Revitalize/Revitalize.csproj b/GeneralMods/Revitalize/Revitalize.csproj index b74de180..dd1f7f2a 100644 --- a/GeneralMods/Revitalize/Revitalize.csproj +++ b/GeneralMods/Revitalize/Revitalize.csproj @@ -50,6 +50,8 @@ + + From 5c78f88e6af42fc31b09197601db89b8b2724410 Mon Sep 17 00:00:00 2001 From: Joshua Navarro Date: Mon, 24 Dec 2018 10:58:20 -0800 Subject: [PATCH 09/72] Got "transparent" boudning boxes working for objects that can be passed through. --- .../Framework/Objects/BasicItemInformation.cs | 7 +++- .../Framework/Objects/CustomObject.cs | 39 ++++++++++++++----- .../Framework/Objects/MultiTiledComponent.cs | 4 +- GeneralMods/Revitalize/ModCore.cs | 8 ++-- 4 files changed, 41 insertions(+), 17 deletions(-) diff --git a/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs b/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs index 2a277a07..094af3cb 100644 --- a/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs +++ b/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs @@ -29,6 +29,8 @@ namespace Revitalize.Framework.Objects public Color drawColor; + public bool ignoreBoundingBox; + public BasicItemInformation() : base() { name = ""; @@ -46,7 +48,7 @@ namespace Revitalize.Framework.Objects this.drawColor = Color.White; } - public BasicItemInformation(string name, string description, string categoryName, Color categoryColor,int edibility,int fragility,bool isLamp,int price, Vector2 TileLocation,bool canBeSetOutdoors,bool canBeSetIndoors,string id, string data, Texture2D texture, Color color,int tileIndex, bool bigCraftable, Type type, CraftingData craftingData, AnimationManager animationManager,Color DrawColor):base(id,data,texture,color,tileIndex,bigCraftable,type,craftingData) + public BasicItemInformation(string name, string description, string categoryName, Color categoryColor,int edibility,int fragility,bool isLamp,int price, Vector2 TileLocation,bool canBeSetOutdoors,bool canBeSetIndoors,string id, string data, Texture2D texture, Color color,int tileIndex, bool bigCraftable, Type type, CraftingData craftingData, AnimationManager animationManager,Color DrawColor,bool ignoreBoundingBox):base(id,data,texture,color,tileIndex,bigCraftable,type,craftingData) { this.name = name; this.description = description; @@ -82,7 +84,8 @@ namespace Revitalize.Framework.Objects { this.drawColor = DrawColor; } - + + this.ignoreBoundingBox = ignoreBoundingBox; recreateDataString(); } diff --git a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs index e9c7d6ce..67b2edb0 100644 --- a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs +++ b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs @@ -92,10 +92,27 @@ namespace Revitalize.Framework.Objects this.isLamp.Value = false; this.fragility.Value = 0; - this.updateDrawPosition(); + this.updateDrawPosition(0,0); this.bigCraftable.Value = false; - + + + if (this.info.ignoreBoundingBox) + { + this.boundingBox.Value = new Rectangle(Int32.MinValue, Int32.MinValue, 0, 0); + } + } + + public override Rectangle getBoundingBox(Vector2 tileLocation) + { + if (this.info.ignoreBoundingBox) + { + return new Rectangle(Int32.MinValue, Int32.MinValue, 0, 0); + } + else + { + return base.getBoundingBox(tileLocation); + } } /// @@ -195,7 +212,9 @@ namespace Revitalize.Framework.Objects { Game1.createItemDebris(this, Game1.player.getStandingPosition(), Game1.player.getDirection()); this.location = null; + this.updateDrawPosition(0, 0); Game1.player.currentLocation.removeObject(this.TileLocation, false); + this.updateDrawPosition(0, 0); return false; } @@ -217,6 +236,7 @@ namespace Revitalize.Framework.Objects this.location = null; Game1.player.currentLocation.removeObject(this.TileLocation, false); Game1.player.addItemToInventory(this); + this.updateDrawPosition(0, 0); return true; } @@ -261,7 +281,7 @@ namespace Revitalize.Framework.Objects /// public override bool placementAction(GameLocation location, int x, int y, Farmer who = null) { - this.updateDrawPosition(); + this.updateDrawPosition(x,y); this.location = location; return base.placementAction(location, x, y, who); } @@ -269,9 +289,10 @@ namespace Revitalize.Framework.Objects /// /// Updates a visual draw position. /// - public virtual void updateDrawPosition() + public virtual void updateDrawPosition(int x, int y) { - this.info.drawPosition = new Vector2((float)this.boundingBox.X, (float)(this.boundingBox.Y - (this.animationManager.currentAnimation.sourceRectangle.Height * Game1.pixelZoom - this.boundingBox.Height))); + this.info.drawPosition = new Vector2((int)(x / Game1.tileSize), (int)(y / Game1.tileSize)); + //this.info.drawPosition = new Vector2((float)this.boundingBox.X, (float)(this.boundingBox.Y - (this.animationManager.currentAnimation.sourceRectangle.Height * Game1.pixelZoom - this.boundingBox.Height))); } /// @@ -292,9 +313,9 @@ namespace Revitalize.Framework.Objects /// public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1f) { - if (x == -1) + if (x <= -1) { - spriteBatch.Draw(this.info.animationManager.getTexture(), Game1.GlobalToLocal(Game1.viewport, this.info.drawPosition), new Rectangle?(this.animationManager.currentAnimation.sourceRectangle), info.drawColor * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0); + spriteBatch.Draw(this.info.animationManager.getTexture(), Game1.GlobalToLocal(Game1.viewport, this.info.drawPosition), new Rectangle?(this.animationManager.currentAnimation.sourceRectangle), info.drawColor * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, Math.Max(0f, (float)(this.TileLocation.Y*Game1.tileSize) / 10000f)); } else { @@ -307,14 +328,14 @@ namespace Revitalize.Framework.Objects } - spriteBatch.Draw(this.displayTexture, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(x * Game1.tileSize), y * Game1.tileSize)), new Rectangle?(this.animationManager.currentAnimation.sourceRectangle), info.drawColor * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0); + spriteBatch.Draw(this.displayTexture, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(x * Game1.tileSize), y * Game1.tileSize)), new Rectangle?(this.animationManager.currentAnimation.sourceRectangle), info.drawColor * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, Math.Max(0f, (float)(this.TileLocation.Y*Game1.tileSize) / 10000f)); // Log.AsyncG("ANIMATION IS NULL?!?!?!?!"); } else { //Log.AsyncC("Animation Manager is working!"); - this.animationManager.draw(spriteBatch, this.displayTexture, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(x * Game1.tileSize), y * Game1.tileSize)), new Rectangle?(this.animationManager.currentAnimation.sourceRectangle), info.drawColor * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0); + this.animationManager.draw(spriteBatch, this.displayTexture, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(x * Game1.tileSize), y * Game1.tileSize)), new Rectangle?(this.animationManager.currentAnimation.sourceRectangle), info.drawColor * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, Math.Max(0f, (float)(this.TileLocation.Y*Game1.tileSize) / 10000f)); try { this.animationManager.tickAnimation(); diff --git a/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs b/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs index b0c366d4..1502278c 100644 --- a/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs +++ b/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs @@ -70,7 +70,7 @@ namespace Revitalize.Framework.Objects public override bool placementAction(GameLocation location, int x, int y, Farmer who = null) { Revitalize.ModCore.ModMonitor.Log("SCREAMING!!!!"); - this.updateDrawPosition(); + this.updateDrawPosition(x,y); this.location = location; this.TileLocation = new Vector2((int)(x / Game1.tileSize), (int)(y / Game1.tileSize)); @@ -87,7 +87,7 @@ namespace Revitalize.Framework.Objects float num = this.Quality < 4 ? 0.0f : (float)((Math.Cos((double)Game1.currentGameTime.TotalGameTime.Milliseconds * Math.PI / 512.0) + 1.0) * 0.0500000007450581); spriteBatch.Draw(Game1.mouseCursors, location + new Vector2(12f, (float)(Game1.tileSize - 12) + num), new Microsoft.Xna.Framework.Rectangle?(this.Quality < 4 ? new Microsoft.Xna.Framework.Rectangle(338 + (this.Quality - 1) * 8, 400, 8, 8) : new Microsoft.Xna.Framework.Rectangle(346, 392, 8, 8)), Color.White * transparency, 0.0f, new Vector2(4f, 4f), (float)(3.0 * (double)scaleSize * (1.0 + (double)num)), SpriteEffects.None, layerDepth); } - spriteBatch.Draw(this.displayTexture, location + new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize * .75)), new Rectangle?(this.animationManager.currentAnimation.sourceRectangle), info.drawColor * transparency, 0f, new Vector2((float)(this.animationManager.currentAnimation.sourceRectangle.Width / 2), (float)(this.animationManager.currentAnimation.sourceRectangle.Height)), scaleSize, SpriteEffects.None, layerDepth); + spriteBatch.Draw(this.displayTexture, location + new Vector2((float)(Game1.tileSize / 4), (float)(Game1.tileSize * .75)), new Rectangle?(this.animationManager.currentAnimation.sourceRectangle), info.drawColor * transparency, 0f, new Vector2((float)(this.animationManager.currentAnimation.sourceRectangle.Width / 2), (float)(this.animationManager.currentAnimation.sourceRectangle.Height)), scaleSize, SpriteEffects.None, layerDepth); } public override Item getOne() diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index 427e08e9..4c183826 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -32,11 +32,11 @@ namespace Revitalize private void GameLoop_SaveLoaded(object sender, StardewModdingAPI.Events.SaveLoadedEventArgs e) { - MultiTiledComponent obj = new MultiTiledComponent(new BasicItemInformation("CoreObjectTest","YAY FUN!","Omegasis.Revitalize.MultiTiledComponent",Color.White,-300,0,false,100,Vector2.Zero,true,true,"Omegasis.TEST1", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", Game1.objectSpriteSheet,Color.White,0,true,typeof(MultiTiledComponent),null,new AnimationManager(new Texture2DExtended(Game1.objectSpriteSheet),new Animation(new Rectangle(0,0,16,16))),Color.Red)); - MultiTiledComponent obj2 = new MultiTiledComponent(new BasicItemInformation("CoreObjectTest2", "SomeFun", "Omegasis.Revitalize.MultiTiledComponent", Color.White, -300, 0, false, 100, Vector2.Zero, true, true, "Omegasis.TEST1", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", Game1.objectSpriteSheet, Color.White, 0, true, typeof(MultiTiledComponent), null, new AnimationManager(new Texture2DExtended(Game1.objectSpriteSheet), new Animation(new Rectangle(0, 16, 16, 16))), Color.Red)); - MultiTiledComponent obj3 = new MultiTiledComponent(new BasicItemInformation("CoreObjectTest3", "NoFun", "Omegasis.Revitalize.MultiTiledComponent", Color.White, -300, 0, false, 100, Vector2.Zero, true, true, "Omegasis.TEST1", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", Game1.objectSpriteSheet, Color.White, 0, true, typeof(MultiTiledComponent), null, new AnimationManager(new Texture2DExtended(Game1.objectSpriteSheet), new Animation(new Rectangle(0, 32, 16, 16))), Color.Red)); + MultiTiledComponent obj = new MultiTiledComponent(new BasicItemInformation("CoreObjectTest","YAY FUN!","Omegasis.Revitalize.MultiTiledComponent",Color.White,-300,0,false,100,Vector2.Zero,true,true,"Omegasis.TEST1", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", Game1.objectSpriteSheet,Color.White,0,true,typeof(MultiTiledComponent),null,new AnimationManager(new Texture2DExtended(Game1.objectSpriteSheet),new Animation(new Rectangle(0,0,16,16))),Color.Red,true)); + MultiTiledComponent obj2 = new MultiTiledComponent(new BasicItemInformation("CoreObjectTest2", "SomeFun", "Omegasis.Revitalize.MultiTiledComponent", Color.White, -300, 0, false, 100, Vector2.Zero, true, true, "Omegasis.TEST1", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", Game1.objectSpriteSheet, Color.White, 0, true, typeof(MultiTiledComponent), null, new AnimationManager(new Texture2DExtended(Game1.objectSpriteSheet), new Animation(new Rectangle(0, 16, 16, 16))), Color.Red,false)); + MultiTiledComponent obj3 = new MultiTiledComponent(new BasicItemInformation("CoreObjectTest3", "NoFun", "Omegasis.Revitalize.MultiTiledComponent", Color.White, -300, 0, false, 100, Vector2.Zero, true, true, "Omegasis.TEST1", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", Game1.objectSpriteSheet, Color.White, 0, true, typeof(MultiTiledComponent), null, new AnimationManager(new Texture2DExtended(Game1.objectSpriteSheet), new Animation(new Rectangle(0, 32, 16, 16))), Color.Red,false)); - MultiTiledObject bigObject= new MultiTiledObject(new BasicItemInformation("MultiTest", "A really big object", "Omegasis.Revitalize.MultiTiledObject", Color.Blue, -300, 0, false, 100, Vector2.Zero, true, true, "Omegasis.BigTiledTest", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", Game1.objectSpriteSheet, Color.White, 0, true, typeof(MultiTiledObject), null, new AnimationManager(), Color.White)); + MultiTiledObject bigObject= new MultiTiledObject(new BasicItemInformation("MultiTest", "A really big object", "Omegasis.Revitalize.MultiTiledObject", Color.Blue, -300, 0, false, 100, Vector2.Zero, true, true, "Omegasis.BigTiledTest", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", Game1.objectSpriteSheet, Color.White, 0, true, typeof(MultiTiledObject), null, new AnimationManager(), Color.White,false)); bigObject.addComponent(new Vector2(0, 0), obj); bigObject.addComponent(new Vector2(1, 0), obj2); bigObject.addComponent(new Vector2(2, 0), obj3); From 15455416a87eeaf7af2f5bd95adae31174363fdb Mon Sep 17 00:00:00 2001 From: Joshua Navarro Date: Mon, 24 Dec 2018 12:00:58 -0800 Subject: [PATCH 10/72] Got darker night working somewhat. Needs a lot of tweaking. --- .../Framework/Environment/DarkerNight.cs | 49 +++++++++++++++++++ .../Environment/DarkerNightConfig.cs | 21 ++++++++ .../Framework/Illuminate/ColorExtensions.cs | 19 +++++++ .../Framework/Objects/CustomObject.cs | 7 ++- GeneralMods/Revitalize/ModCore.cs | 24 +++++++++ GeneralMods/Revitalize/Revitalize.csproj | 3 ++ 6 files changed, 121 insertions(+), 2 deletions(-) create mode 100644 GeneralMods/Revitalize/Framework/Environment/DarkerNight.cs create mode 100644 GeneralMods/Revitalize/Framework/Environment/DarkerNightConfig.cs create mode 100644 GeneralMods/Revitalize/Framework/Illuminate/ColorExtensions.cs diff --git a/GeneralMods/Revitalize/Framework/Environment/DarkerNight.cs b/GeneralMods/Revitalize/Framework/Environment/DarkerNight.cs new file mode 100644 index 00000000..fa4c5d6a --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Environment/DarkerNight.cs @@ -0,0 +1,49 @@ +using StardewValley; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Revitalize.Framework.Illuminate; +using System.IO; + +namespace Revitalize.Framework.Environment +{ + public class DarkerNight + { + + public static float IncrediblyDark = 0.9f; + public static float VeryDark = 0.75f; + public static float SomewhatDark = 0.50f; + + public static DarkerNightConfig Config; + + public static void InitializeConfig() + { + if (File.Exists(Path.Combine(Revitalize.ModCore.ModHelper.DirectoryPath, "Configs", "DarkerNightConfig.json"))) + { + Config = Revitalize.ModCore.ModHelper.Data.ReadJsonFile(Path.Combine("Configs", "DarkerNightConfig.json")); + } + else + { + Config = new DarkerNightConfig(); + Revitalize.ModCore.ModHelper.Data.WriteJsonFile(Path.Combine("Configs", "DarkerNightConfig.json"),Config); + } + } + + public static void setDarkerNightColor() + { + if (Game1.player == null) return; + if (Game1.player.currentLocation.IsOutdoors && Game1.timeOfDay>= Game1.getTrulyDarkTime()) + { + //Game1.ambientLight = Game1.ambientLight.GreyScaleAverage(); + Game1.outdoorLight = Game1.ambientLight*Config.DarknessIntensity; + + Revitalize.ModCore.log("OUT: " + Game1.outdoorLight); + Revitalize.ModCore.log("Ambient"+Game1.ambientLight); + } + } + + + } +} diff --git a/GeneralMods/Revitalize/Framework/Environment/DarkerNightConfig.cs b/GeneralMods/Revitalize/Framework/Environment/DarkerNightConfig.cs new file mode 100644 index 00000000..f4da30bb --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Environment/DarkerNightConfig.cs @@ -0,0 +1,21 @@ +using Microsoft.Xna.Framework; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Revitalize.Framework.Environment +{ + public class DarkerNightConfig + { + public float DarknessIntensity; + + + public DarkerNightConfig() + { + this.DarknessIntensity = .9f; + } + + } +} diff --git a/GeneralMods/Revitalize/Framework/Illuminate/ColorExtensions.cs b/GeneralMods/Revitalize/Framework/Illuminate/ColorExtensions.cs new file mode 100644 index 00000000..1cc17128 --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Illuminate/ColorExtensions.cs @@ -0,0 +1,19 @@ +using Microsoft.Xna.Framework; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Revitalize.Framework.Illuminate +{ + public static class ColorExtensions + { + public static Color GreyScaleAverage(this Color color) + { + int value = (color.R + color.G + color.B) / 3; + return new Color(new Vector3(value)); + } + + } +} diff --git a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs index 67b2edb0..cd6f2ab0 100644 --- a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs +++ b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs @@ -17,13 +17,16 @@ namespace Revitalize.Framework.Objects { /// /// A custom object template. + /// + /// Todo: + /// -Multiple Lights + /// -Events when walking over? + /// -Inventories /// public class CustomObject : PySObject { - public string id; public BasicItemInformation info; - public GameLocation location; /// diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index 4c183826..2026cf8b 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -11,6 +11,8 @@ using System.Text; using System.Threading.Tasks; using Revitalize.Framework.Graphics; using Revitalize.Framework.Graphics.Animations; +using Revitalize.Framework.Environment; +using System.IO; namespace Revitalize { @@ -27,7 +29,29 @@ namespace Revitalize ModHelper = helper; ModMonitor = Monitor; + createDirectories(); + initailizeComponents(); + + ModHelper.Events.GameLoop.SaveLoaded += GameLoop_SaveLoaded; + ModHelper.Events.GameLoop.TimeChanged += GameLoop_TimeChanged; + } + + + private void createDirectories() + { + Directory.CreateDirectory(Path.Combine(this.Helper.DirectoryPath, "Configs")); + } + + private void initailizeComponents() + { + DarkerNight.InitializeConfig(); + } + + + private void GameLoop_TimeChanged(object sender, StardewModdingAPI.Events.TimeChangedEventArgs e) + { + DarkerNight.setDarkerNightColor(); } private void GameLoop_SaveLoaded(object sender, StardewModdingAPI.Events.SaveLoadedEventArgs e) diff --git a/GeneralMods/Revitalize/Revitalize.csproj b/GeneralMods/Revitalize/Revitalize.csproj index dd1f7f2a..7c729339 100644 --- a/GeneralMods/Revitalize/Revitalize.csproj +++ b/GeneralMods/Revitalize/Revitalize.csproj @@ -45,9 +45,12 @@ + + + From 1ec8cd8613900530413d8a9bda260d037430feb9 Mon Sep 17 00:00:00 2001 From: Joshua Navarro Date: Mon, 24 Dec 2018 12:02:59 -0800 Subject: [PATCH 11/72] Need to work on how fast darker night occurs. --- .../Revitalize/Framework/Environment/DarkerNightConfig.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/GeneralMods/Revitalize/Framework/Environment/DarkerNightConfig.cs b/GeneralMods/Revitalize/Framework/Environment/DarkerNightConfig.cs index f4da30bb..4724f88c 100644 --- a/GeneralMods/Revitalize/Framework/Environment/DarkerNightConfig.cs +++ b/GeneralMods/Revitalize/Framework/Environment/DarkerNightConfig.cs @@ -10,8 +10,6 @@ namespace Revitalize.Framework.Environment public class DarkerNightConfig { public float DarknessIntensity; - - public DarkerNightConfig() { this.DarknessIntensity = .9f; From b0b7a8f5dca0cede88229cea91f66c50be8fcdb3 Mon Sep 17 00:00:00 2001 From: Joshua Navarro Date: Mon, 24 Dec 2018 12:36:03 -0800 Subject: [PATCH 12/72] Finished darker night. --- .../Framework/Environment/DarkerNight.cs | 37 +++++++++++++++++-- GeneralMods/Revitalize/ModCore.cs | 8 +++- 2 files changed, 40 insertions(+), 5 deletions(-) diff --git a/GeneralMods/Revitalize/Framework/Environment/DarkerNight.cs b/GeneralMods/Revitalize/Framework/Environment/DarkerNight.cs index fa4c5d6a..c2e86615 100644 --- a/GeneralMods/Revitalize/Framework/Environment/DarkerNight.cs +++ b/GeneralMods/Revitalize/Framework/Environment/DarkerNight.cs @@ -6,6 +6,7 @@ using System.Text; using System.Threading.Tasks; using Revitalize.Framework.Illuminate; using System.IO; +using Microsoft.Xna.Framework; namespace Revitalize.Framework.Environment { @@ -18,6 +19,8 @@ namespace Revitalize.Framework.Environment public static DarkerNightConfig Config; + private static Color CalculatedColor; + public static void InitializeConfig() { if (File.Exists(Path.Combine(Revitalize.ModCore.ModHelper.DirectoryPath, "Configs", "DarkerNightConfig.json"))) @@ -31,15 +34,41 @@ namespace Revitalize.Framework.Environment } } - public static void setDarkerNightColor() + public static void SetDarkerColor() + { + if (Game1.player.currentLocation.IsOutdoors && Game1.timeOfDay >= Game1.getStartingToGetDarkTime()) + { + Game1.outdoorLight = CalculatedColor; + } + } + + + public static void CalculateDarkerNightColor() { if (Game1.player == null) return; - if (Game1.player.currentLocation.IsOutdoors && Game1.timeOfDay>= Game1.getTrulyDarkTime()) + + //Calculate original lighting. + if (Game1.timeOfDay >= Game1.getTrulyDarkTime()) + { + float num = Math.Min(0.93f, (float)(0.75 + ((double)((int)((double)(Game1.timeOfDay - Game1.timeOfDay % 100) + (double)(Game1.timeOfDay % 100 / 10) * 16.6599998474121) - Game1.getTrulyDarkTime()) + (double)Game1.gameTimeInterval / 7000.0 * 16.6000003814697) * 0.000624999986030161)); + Game1.outdoorLight = (Game1.isRaining ? Game1.ambientLight : Game1.eveningColor) * num; + } + else if (Game1.timeOfDay >= Game1.getStartingToGetDarkTime()) + { + float num = Math.Min(0.93f, (float)(0.300000011920929 + ((double)((int)((double)(Game1.timeOfDay - Game1.timeOfDay % 100) + (double)(Game1.timeOfDay % 100 / 10) * 16.6599998474121) - Game1.getStartingToGetDarkTime()) + (double)Game1.gameTimeInterval / 7000.0 * 16.6000003814697) * 0.00224999990314245)); + Game1.outdoorLight = (Game1.isRaining ? Game1.ambientLight : Game1.eveningColor) * num; + } + + Revitalize.ModCore.log("OUT: " + Game1.outdoorLight); + + int red = Game1.outdoorLight.R; + + if (Game1.player.currentLocation.IsOutdoors && Game1.timeOfDay>= Game1.getStartingToGetDarkTime()) { //Game1.ambientLight = Game1.ambientLight.GreyScaleAverage(); - Game1.outdoorLight = Game1.ambientLight*Config.DarknessIntensity; + CalculatedColor = Game1.ambientLight* ( (red+30) / 255f) * Config.DarknessIntensity; - Revitalize.ModCore.log("OUT: " + Game1.outdoorLight); + Revitalize.ModCore.log("OUT: " + CalculatedColor); Revitalize.ModCore.log("Ambient"+Game1.ambientLight); } } diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index 2026cf8b..c8e6f9c4 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -35,6 +35,7 @@ namespace Revitalize ModHelper.Events.GameLoop.SaveLoaded += GameLoop_SaveLoaded; ModHelper.Events.GameLoop.TimeChanged += GameLoop_TimeChanged; + ModHelper.Events.GameLoop.UpdateTicked += GameLoop_UpdateTicked; } @@ -49,9 +50,14 @@ namespace Revitalize } + private void GameLoop_UpdateTicked(object sender, StardewModdingAPI.Events.UpdateTickedEventArgs e) + { + DarkerNight.SetDarkerColor(); + } + private void GameLoop_TimeChanged(object sender, StardewModdingAPI.Events.TimeChangedEventArgs e) { - DarkerNight.setDarkerNightColor(); + DarkerNight.CalculateDarkerNightColor(); } private void GameLoop_SaveLoaded(object sender, StardewModdingAPI.Events.SaveLoadedEventArgs e) From ccdc99ab8e5414fbcae117aae0aabe191f212597 Mon Sep 17 00:00:00 2001 From: Joshua Navarro Date: Mon, 24 Dec 2018 13:00:33 -0800 Subject: [PATCH 13/72] Added some comments and a way to disable DarkerNight. --- .../Framework/Environment/DarkerNight.cs | 30 ++++++++++++++++++- .../Environment/DarkerNightConfig.cs | 2 ++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/GeneralMods/Revitalize/Framework/Environment/DarkerNight.cs b/GeneralMods/Revitalize/Framework/Environment/DarkerNight.cs index c2e86615..ea5739e2 100644 --- a/GeneralMods/Revitalize/Framework/Environment/DarkerNight.cs +++ b/GeneralMods/Revitalize/Framework/Environment/DarkerNight.cs @@ -10,17 +10,38 @@ using Microsoft.Xna.Framework; namespace Revitalize.Framework.Environment { + /// + /// Deals with making night time darker in Stardew. + /// public class DarkerNight { + /// + /// Darkness intensity. + /// public static float IncrediblyDark = 0.9f; + /// + /// Darkness intensity. + /// public static float VeryDark = 0.75f; + /// + /// Darkness intensity. + /// public static float SomewhatDark = 0.50f; + /// + /// The config file. + /// public static DarkerNightConfig Config; + /// + /// The calculated night color. + /// private static Color CalculatedColor; + /// + /// Initializes the config for DarkerNight. + /// public static void InitializeConfig() { if (File.Exists(Path.Combine(Revitalize.ModCore.ModHelper.DirectoryPath, "Configs", "DarkerNightConfig.json"))) @@ -34,17 +55,24 @@ namespace Revitalize.Framework.Environment } } + /// + /// Sets the color of darkness at night. + /// public static void SetDarkerColor() { + if (Config.Enabled == false) return; if (Game1.player.currentLocation.IsOutdoors && Game1.timeOfDay >= Game1.getStartingToGetDarkTime()) { Game1.outdoorLight = CalculatedColor; } } - + /// + /// Calculates how dark it should be a night. + /// public static void CalculateDarkerNightColor() { + if (Config.Enabled == false) return; if (Game1.player == null) return; //Calculate original lighting. diff --git a/GeneralMods/Revitalize/Framework/Environment/DarkerNightConfig.cs b/GeneralMods/Revitalize/Framework/Environment/DarkerNightConfig.cs index 4724f88c..6d2c4b93 100644 --- a/GeneralMods/Revitalize/Framework/Environment/DarkerNightConfig.cs +++ b/GeneralMods/Revitalize/Framework/Environment/DarkerNightConfig.cs @@ -9,9 +9,11 @@ namespace Revitalize.Framework.Environment { public class DarkerNightConfig { + public bool Enabled; public float DarknessIntensity; public DarkerNightConfig() { + this.Enabled = true; this.DarknessIntensity = .9f; } From 3fd37231176331747a67b6c8b3cc1e25103248c9 Mon Sep 17 00:00:00 2001 From: Joshua Navarro Date: Mon, 24 Dec 2018 15:04:18 -0800 Subject: [PATCH 14/72] Created inventory management for having core objects deal with inventories. --- .../Framework/Objects/BasicItemInformation.cs | 14 +- .../Framework/Utilities/InventoryManager.cs | 210 ++++++++++++++++++ GeneralMods/Revitalize/ModCore.cs | 8 +- GeneralMods/Revitalize/Revitalize.csproj | 1 + 4 files changed, 228 insertions(+), 5 deletions(-) create mode 100644 GeneralMods/Revitalize/Framework/Utilities/InventoryManager.cs diff --git a/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs b/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs index 094af3cb..207feb90 100644 --- a/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs +++ b/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs @@ -2,6 +2,7 @@ using Microsoft.Xna.Framework.Graphics; using PyTK.CustomElementHandler; using Revitalize.Framework.Graphics.Animations; +using Revitalize.Framework.Utilities; using System; using System.Collections.Generic; using System.Linq; @@ -31,6 +32,8 @@ namespace Revitalize.Framework.Objects public bool ignoreBoundingBox; + public InventoryManager inventory; + public BasicItemInformation() : base() { name = ""; @@ -46,9 +49,10 @@ namespace Revitalize.Framework.Objects this.animationManager = null; this.drawPosition = Vector2.Zero; this.drawColor = Color.White; + this.inventory = new InventoryManager(); } - public BasicItemInformation(string name, string description, string categoryName, Color categoryColor,int edibility,int fragility,bool isLamp,int price, Vector2 TileLocation,bool canBeSetOutdoors,bool canBeSetIndoors,string id, string data, Texture2D texture, Color color,int tileIndex, bool bigCraftable, Type type, CraftingData craftingData, AnimationManager animationManager,Color DrawColor,bool ignoreBoundingBox):base(id,data,texture,color,tileIndex,bigCraftable,type,craftingData) + public BasicItemInformation(string name, string description, string categoryName, Color categoryColor,int edibility,int fragility,bool isLamp,int price, Vector2 TileLocation,bool canBeSetOutdoors,bool canBeSetIndoors,string id, string data, Texture2D texture, Color color,int tileIndex, bool bigCraftable, Type type, CraftingData craftingData, AnimationManager animationManager,Color DrawColor,bool ignoreBoundingBox, InventoryManager Inventory):base(id,data,texture,color,tileIndex,bigCraftable,type,craftingData) { this.name = name; this.description = description; @@ -88,6 +92,14 @@ namespace Revitalize.Framework.Objects this.ignoreBoundingBox = ignoreBoundingBox; recreateDataString(); + if (Inventory == null) + { + this.inventory = new InventoryManager(); + } + else + { + this.inventory = Inventory; + } } public void recreateDataString() diff --git a/GeneralMods/Revitalize/Framework/Utilities/InventoryManager.cs b/GeneralMods/Revitalize/Framework/Utilities/InventoryManager.cs new file mode 100644 index 00000000..93fd67af --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Utilities/InventoryManager.cs @@ -0,0 +1,210 @@ +using StardewValley; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Revitalize.Framework.Utilities +{ + /// + /// Handles dealing with objects. + /// + public class InventoryManager + { + /// + /// How many items the inventory can hold. + /// + public int capacity; + + /// + /// The hard uper limit in case of upgrading or resizing. + /// + private int maxCapacity; + + /// + /// The hard uper limit for # of items to be held in case of upgrading or resizing. + /// + public int MaxCapacity + { + get + { + return maxCapacity; + } + } + + /// + /// How many items are currently stored in the inventory. + /// + public int ItemCount + { + get + { + return this.items.Count; + } + } + + /// + /// The actual contents of the inventory. + /// + public List items; + + /// + /// Checks if the inventory is full or not. + /// + public bool IsFull + { + get + { + return this.ItemCount >= this.capacity; + } + } + + public InventoryManager() + { + this.capacity = 0; + setMaxLimit(0); + this.items = new List(); + } + + /// + /// Constructor. + /// + /// + public InventoryManager(List items) + { + this.capacity = Int32.MaxValue; + this.setMaxLimit(Int32.MaxValue); + this.items = items; + } + + /// + /// Constructor. + /// + /// + public InventoryManager(int capacity) + { + this.capacity = capacity; + this.maxCapacity = Int32.MaxValue; + this.items = new List(); + } + + /// + /// Constructor. + /// + /// + /// + public InventoryManager(int capacity, int MaxCapacity) + { + this.capacity = capacity; + setMaxLimit(MaxCapacity); + this.items = new List(); + } + + /// + /// Add the item to the inventory. + /// + /// + /// + public bool addItem(Item I) + { + if (IsFull) + { + return false; + } + else + { + foreach(Item self in this.items) + { + if (self.canStackWith(I)) + { + self.addToStack(I.Stack); + return true; + } + } + this.items.Add(I); + return true; + } + } + + /// + /// Gets a reference to the object IF it exists in the inventory. + /// + /// + /// + public Item getItem(Item I) + { + foreach(Item i in this.items) + { + if (I == i) return I; + } + return null; + } + + /// + /// Get the item at the specific index. + /// + /// + /// + public Item getItemAtIndex(int Index) + { + return items[Index]; + } + + /// + /// Gets only one item from the stack. + /// + /// + /// + public Item getSingleItemFromStack(Item I) + { + if (I.Stack == 1) + { + return I; + } + else + { + I.Stack = I.Stack - 1; + return I.getOne(); + } + } + + /// + /// Empty the inventory. + /// + public void clear() + { + this.items.Clear(); + } + + /// + /// Empty the inventory. + /// + public void empty() + { + this.clear(); + } + + /// + /// Resize how many items can be held by this object. + /// + /// + public void resizeCapacity(int Amount) + { + if (this.capacity + Amount < this.maxCapacity) + { + this.capacity += Amount; + } + } + + /// + /// Sets the upper limity of the capacity size for the inventory. + /// + /// + public void setMaxLimit(int amount) + { + this.maxCapacity = amount; + } + + } +} diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index c8e6f9c4..78455f90 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -62,11 +62,11 @@ namespace Revitalize private void GameLoop_SaveLoaded(object sender, StardewModdingAPI.Events.SaveLoadedEventArgs e) { - MultiTiledComponent obj = new MultiTiledComponent(new BasicItemInformation("CoreObjectTest","YAY FUN!","Omegasis.Revitalize.MultiTiledComponent",Color.White,-300,0,false,100,Vector2.Zero,true,true,"Omegasis.TEST1", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", Game1.objectSpriteSheet,Color.White,0,true,typeof(MultiTiledComponent),null,new AnimationManager(new Texture2DExtended(Game1.objectSpriteSheet),new Animation(new Rectangle(0,0,16,16))),Color.Red,true)); - MultiTiledComponent obj2 = new MultiTiledComponent(new BasicItemInformation("CoreObjectTest2", "SomeFun", "Omegasis.Revitalize.MultiTiledComponent", Color.White, -300, 0, false, 100, Vector2.Zero, true, true, "Omegasis.TEST1", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", Game1.objectSpriteSheet, Color.White, 0, true, typeof(MultiTiledComponent), null, new AnimationManager(new Texture2DExtended(Game1.objectSpriteSheet), new Animation(new Rectangle(0, 16, 16, 16))), Color.Red,false)); - MultiTiledComponent obj3 = new MultiTiledComponent(new BasicItemInformation("CoreObjectTest3", "NoFun", "Omegasis.Revitalize.MultiTiledComponent", Color.White, -300, 0, false, 100, Vector2.Zero, true, true, "Omegasis.TEST1", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", Game1.objectSpriteSheet, Color.White, 0, true, typeof(MultiTiledComponent), null, new AnimationManager(new Texture2DExtended(Game1.objectSpriteSheet), new Animation(new Rectangle(0, 32, 16, 16))), Color.Red,false)); + MultiTiledComponent obj = new MultiTiledComponent(new BasicItemInformation("CoreObjectTest","YAY FUN!","Omegasis.Revitalize.MultiTiledComponent",Color.White,-300,0,false,100,Vector2.Zero,true,true,"Omegasis.TEST1", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", Game1.objectSpriteSheet,Color.White,0,true,typeof(MultiTiledComponent),null,new AnimationManager(new Texture2DExtended(Game1.objectSpriteSheet),new Animation(new Rectangle(0,0,16,16))),Color.Red,true,null)); + MultiTiledComponent obj2 = new MultiTiledComponent(new BasicItemInformation("CoreObjectTest2", "SomeFun", "Omegasis.Revitalize.MultiTiledComponent", Color.White, -300, 0, false, 100, Vector2.Zero, true, true, "Omegasis.TEST1", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", Game1.objectSpriteSheet, Color.White, 0, true, typeof(MultiTiledComponent), null, new AnimationManager(new Texture2DExtended(Game1.objectSpriteSheet), new Animation(new Rectangle(0, 16, 16, 16))), Color.Red,false,null)); + MultiTiledComponent obj3 = new MultiTiledComponent(new BasicItemInformation("CoreObjectTest3", "NoFun", "Omegasis.Revitalize.MultiTiledComponent", Color.White, -300, 0, false, 100, Vector2.Zero, true, true, "Omegasis.TEST1", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", Game1.objectSpriteSheet, Color.White, 0, true, typeof(MultiTiledComponent), null, new AnimationManager(new Texture2DExtended(Game1.objectSpriteSheet), new Animation(new Rectangle(0, 32, 16, 16))), Color.Red,false,null)); - MultiTiledObject bigObject= new MultiTiledObject(new BasicItemInformation("MultiTest", "A really big object", "Omegasis.Revitalize.MultiTiledObject", Color.Blue, -300, 0, false, 100, Vector2.Zero, true, true, "Omegasis.BigTiledTest", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", Game1.objectSpriteSheet, Color.White, 0, true, typeof(MultiTiledObject), null, new AnimationManager(), Color.White,false)); + MultiTiledObject bigObject= new MultiTiledObject(new BasicItemInformation("MultiTest", "A really big object", "Omegasis.Revitalize.MultiTiledObject", Color.Blue, -300, 0, false, 100, Vector2.Zero, true, true, "Omegasis.BigTiledTest", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", Game1.objectSpriteSheet, Color.White, 0, true, typeof(MultiTiledObject), null, new AnimationManager(), Color.White,false,null)); bigObject.addComponent(new Vector2(0, 0), obj); bigObject.addComponent(new Vector2(1, 0), obj2); bigObject.addComponent(new Vector2(2, 0), obj3); diff --git a/GeneralMods/Revitalize/Revitalize.csproj b/GeneralMods/Revitalize/Revitalize.csproj index 7c729339..018c0418 100644 --- a/GeneralMods/Revitalize/Revitalize.csproj +++ b/GeneralMods/Revitalize/Revitalize.csproj @@ -55,6 +55,7 @@ + From e83e031568a73f0fd532a0312cb4b046b3286616 Mon Sep 17 00:00:00 2001 From: Joshua Navarro Date: Mon, 24 Dec 2018 15:06:42 -0800 Subject: [PATCH 15/72] Hotfix to check if certain objects have inventories or not. --- .../Framework/Utilities/InventoryManager.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/GeneralMods/Revitalize/Framework/Utilities/InventoryManager.cs b/GeneralMods/Revitalize/Framework/Utilities/InventoryManager.cs index 93fd67af..e127fa7a 100644 --- a/GeneralMods/Revitalize/Framework/Utilities/InventoryManager.cs +++ b/GeneralMods/Revitalize/Framework/Utilities/InventoryManager.cs @@ -60,6 +60,18 @@ namespace Revitalize.Framework.Utilities } } + /// + /// Checks to see if this core object actually has a valid inventory. + /// + public bool HasInventory + { + get + { + if (this.capacity <= 0) return false; + return true; + } + } + public InventoryManager() { this.capacity = 0; From 8bcc399723229edad12dce2258e6f2e6c4188818 Mon Sep 17 00:00:00 2001 From: Joshua Navarro Date: Mon, 24 Dec 2018 15:07:51 -0800 Subject: [PATCH 16/72] Hotfix for errors on DarkerNight component --- GeneralMods/Revitalize/Framework/Environment/DarkerNight.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/GeneralMods/Revitalize/Framework/Environment/DarkerNight.cs b/GeneralMods/Revitalize/Framework/Environment/DarkerNight.cs index ea5739e2..f2075411 100644 --- a/GeneralMods/Revitalize/Framework/Environment/DarkerNight.cs +++ b/GeneralMods/Revitalize/Framework/Environment/DarkerNight.cs @@ -61,6 +61,8 @@ namespace Revitalize.Framework.Environment public static void SetDarkerColor() { if (Config.Enabled == false) return; + if (Game1.player == null) return; + if (Game1.player.currentLocation == null) return; if (Game1.player.currentLocation.IsOutdoors && Game1.timeOfDay >= Game1.getStartingToGetDarkTime()) { Game1.outdoorLight = CalculatedColor; @@ -74,7 +76,7 @@ namespace Revitalize.Framework.Environment { if (Config.Enabled == false) return; if (Game1.player == null) return; - + if (Game1.player.currentLocation == null) return; //Calculate original lighting. if (Game1.timeOfDay >= Game1.getTrulyDarkTime()) { From c638ba2c809f1c63dd9767076211248ce0b2052c Mon Sep 17 00:00:00 2001 From: Joshua Navarro Date: Mon, 24 Dec 2018 22:02:25 -0800 Subject: [PATCH 17/72] Just got crafting recipes working with Inventory Managers! --- .../Revitalize/Framework/Crafting/Recipe.cs | 208 ++++++++++++++++++ .../Framework/Utilities/InventoryManager.cs | 1 + GeneralMods/Revitalize/ModCore.cs | 12 + GeneralMods/Revitalize/Revitalize.csproj | 1 + 4 files changed, 222 insertions(+) create mode 100644 GeneralMods/Revitalize/Framework/Crafting/Recipe.cs diff --git a/GeneralMods/Revitalize/Framework/Crafting/Recipe.cs b/GeneralMods/Revitalize/Framework/Crafting/Recipe.cs new file mode 100644 index 00000000..4640696e --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Crafting/Recipe.cs @@ -0,0 +1,208 @@ +using Revitalize.Framework.Utilities; +using StardewValley; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Revitalize.Framework.Crafting +{ + public class Recipe + { + public Dictionary ingredients; + public Dictionary outputs; + + private Item displayItem; + + public Item DisplayItem + { + get + { + if (this.displayItem == null) return outputs.ElementAt(0).Key; + else + { + return displayItem; + } + } + set + { + this.displayItem = value; + } + } + + public string outputDescription; + public string outputName; + + + public Recipe() + { + + } + + /// + /// Constructor for single item output. + /// + /// All the ingredients required to make the output. + /// The item given as output with how many + public Recipe(Dictionary inputs,KeyValuePair output) + { + this.ingredients = inputs; + this.DisplayItem = output.Key; + this.outputDescription = output.Key.getDescription(); + this.outputName = output.Key.DisplayName; + this.outputs = new Dictionary(); + this.outputs.Add(output.Key, output.Value); + } + + public Recipe(Dictionary inputs,Dictionary outputs,string OutputName, string OutputDescription,Item DisplayItem=null) + { + this.ingredients = inputs; + this.outputs = outputs; + this.outputName = OutputName; + this.outputDescription = OutputDescription; + this.DisplayItem = DisplayItem; + } + + + /// + /// Checks if a player contains all recipe ingredients. + /// + /// + public bool PlayerContainsAllIngredients() + { + return InventoryContainsAllIngredient(Game1.player.Items.ToList()); + } + + /// + /// Checks if a player contains a recipe ingredient. + /// + /// + /// + public bool PlayerContainsIngredient(KeyValuePair pair) + { + return InventoryContainsIngredient(Game1.player.Items.ToList(), pair); + } + + + /// + /// Checks if an inventory contains all items. + /// + /// + /// + public bool InventoryContainsAllIngredient(List items) + { + foreach (KeyValuePair pair in this.ingredients) + { + if (InventoryContainsIngredient(items,pair) == false) return false; + } + return true; + } + + /// + /// Checks if an inventory contains an ingredient. + /// + /// + /// + /// + public bool InventoryContainsIngredient(List items,KeyValuePair pair) + { + foreach (Item i in items) + { + if (i == null) continue; + if (ItemEqualsOther(i, pair.Key) && pair.Value == i.Stack) + { + return true; + } + } + return false; + } + + + /// + /// Checks roughly if two items equal each other. + /// + /// + /// + /// + public bool ItemEqualsOther(Item self, Item other) + { + if (self.Name == other.Name && self.getCategoryName() == other.getCategoryName() && self.GetType() == other.GetType()) return true; + return false; + } + + public void consume(ref List from) + { + if (!InventoryContainsAllIngredient(from)) return; + InventoryManager manager = new InventoryManager(from); + + List removalList = new List(); + + foreach (KeyValuePair pair in this.ingredients) + { + foreach(Item InventoryItem in manager.items) + { + if (InventoryItem == null) continue; + if (ItemEqualsOther(InventoryItem, pair.Key)) + { + if (InventoryItem.Stack == pair.Value) + { + removalList.Add(InventoryItem); //remove the item + } + else + { + InventoryItem.Stack -= pair.Value; //or reduce the stack size. + } + } + } + } + + foreach (var v in removalList) + { + manager.items.Remove(v); + } + removalList.Clear(); + from = manager.items; + } + + public void produce(ref List to,bool dropToGround=false) + { + InventoryManager manager = new InventoryManager(to); + foreach(KeyValuePair pair in this.outputs) + { + Item I = pair.Key.getOne(); + I.addToStack(pair.Value - 1); + bool added=manager.addItem(I); + if (added == false && dropToGround==true) + { + Game1.createItemDebris(I, Game1.player.getStandingPosition(), Game1.player.getDirection()); + } + } + to = manager.items; + } + + public void craft(ref List from,ref List to,bool dropToGround=false) + { + consume(ref from); + produce(ref to); + } + + public void craft() + { + List playerItems = Game1.player.Items.ToList(); + craft(ref playerItems,ref playerItems, true); + Game1.player.Items = playerItems; + } + + public bool PlayerCanCraft() + { + return PlayerContainsAllIngredients(); + } + + public bool CanCraft(List items) + { + return InventoryContainsAllIngredient(items); + } + + } +} diff --git a/GeneralMods/Revitalize/Framework/Utilities/InventoryManager.cs b/GeneralMods/Revitalize/Framework/Utilities/InventoryManager.cs index e127fa7a..2816519c 100644 --- a/GeneralMods/Revitalize/Framework/Utilities/InventoryManager.cs +++ b/GeneralMods/Revitalize/Framework/Utilities/InventoryManager.cs @@ -128,6 +128,7 @@ namespace Revitalize.Framework.Utilities { foreach(Item self in this.items) { + if (self == null) continue; if (self.canStackWith(I)) { self.addToStack(I.Stack); diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index 78455f90..94589898 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -13,6 +13,8 @@ using Revitalize.Framework.Graphics; using Revitalize.Framework.Graphics.Animations; using Revitalize.Framework.Environment; using System.IO; +using Revitalize.Framework.Crafting; +using StardewValley.Objects; namespace Revitalize { @@ -71,9 +73,19 @@ namespace Revitalize bigObject.addComponent(new Vector2(1, 0), obj2); bigObject.addComponent(new Vector2(2, 0), obj3); + Recipe pie = new Recipe(new Dictionary() + { + [bigObject] = 1 + },new KeyValuePair(new Furniture(3,Vector2.Zero),1)); + new InventoryItem(bigObject, 100,1).addToNPCShop("Gus"); Game1.player.addItemToInventory(bigObject); + + if (pie.PlayerCanCraft()) + { + pie.craft(); + } } diff --git a/GeneralMods/Revitalize/Revitalize.csproj b/GeneralMods/Revitalize/Revitalize.csproj index 018c0418..64b1d86a 100644 --- a/GeneralMods/Revitalize/Revitalize.csproj +++ b/GeneralMods/Revitalize/Revitalize.csproj @@ -45,6 +45,7 @@ + From 36fc2c1fa95cc13b0f5b17ad0ea08c640c1b5b53 Mon Sep 17 00:00:00 2001 From: Joshua Navarro Date: Mon, 24 Dec 2018 22:23:25 -0800 Subject: [PATCH 18/72] Got crafting working to inventories! --- .../Revitalize/Framework/Crafting/Recipe.cs | 32 +++++++++++++++---- 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/GeneralMods/Revitalize/Framework/Crafting/Recipe.cs b/GeneralMods/Revitalize/Framework/Crafting/Recipe.cs index 4640696e..0a9d8589 100644 --- a/GeneralMods/Revitalize/Framework/Crafting/Recipe.cs +++ b/GeneralMods/Revitalize/Framework/Crafting/Recipe.cs @@ -165,9 +165,17 @@ namespace Revitalize.Framework.Crafting from = manager.items; } - public void produce(ref List to,bool dropToGround=false) + public void produce(ref List to,bool dropToGround=false,bool isPlayerInventory=false) { - InventoryManager manager = new InventoryManager(to); + InventoryManager manager; + if (isPlayerInventory == true) + { + manager = new InventoryManager(new List()); + } + else + { + manager = new InventoryManager(to); + } foreach(KeyValuePair pair in this.outputs) { Item I = pair.Key.getOne(); @@ -181,17 +189,29 @@ namespace Revitalize.Framework.Crafting to = manager.items; } - public void craft(ref List from,ref List to,bool dropToGround=false) + public void craft(ref List from,ref List to,bool dropToGround=false,bool isPlayerInventory=false) { + InventoryManager manager = new InventoryManager(to); + if (manager.ItemCount + this.outputs.Count >= manager.capacity) + { + if (isPlayerInventory) Game1.showRedMessage("Inventory Full"); + else return; + } consume(ref from); - produce(ref to); + produce(ref to,dropToGround,isPlayerInventory); } public void craft() { List playerItems = Game1.player.Items.ToList(); - craft(ref playerItems,ref playerItems, true); - Game1.player.Items = playerItems; + List outPutItems = new List(); + craft(ref playerItems,ref outPutItems, true,true); + + Game1.player.Items = playerItems; //Set the items to be post consumption. + foreach(Item I in outPutItems) + { + Game1.player.addItemToInventory(I); //Add all items produced. + } } public bool PlayerCanCraft() From a8e457a5ff00afe30579c8687b648ff12b0226ac Mon Sep 17 00:00:00 2001 From: Joshua Navarro Date: Mon, 24 Dec 2018 23:34:38 -0800 Subject: [PATCH 19/72] Left an overly ambitious ToDo/Wishlist in the main file. --- GeneralMods/Revitalize/ModCore.cs | 61 +++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index 94589898..ad634fe0 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -18,6 +18,67 @@ using StardewValley.Objects; namespace Revitalize { + + /* + * Todo: + * -Multiple Lights On Object + * -Illumination Colors + * Furniture: + * -rugs + * -tables + * -lamps + * -chairs + * -dressers/other storage containers + * -fun interactables + * -More crafting tables + * -Machines + * !=Energy + * -Furnace + * -Seed Maker + * -Stone Quarry + * -Materials + * -Tin/Bronze/Alluminum/Silver?Platinum/Etc + * -Crafting Menu + * -Item Grab Menu (Extendable) + * -Gift Boxes + * Magic! + * -Alchemy Bags + * -Transmutation + * -Effect Crystals + * -Spell books + * -Potions! + * -Magic Meter + * Festivals + * -Firework festival? + * Stargazing??? + * -Moon Phases+DarkerNight + * Bigger/Better Museum? + * More Crops? + * More Food? + * + * Equippables! + * -accessories that provide buffs/regen/friendship + * + * Music??? + * -IDK maybe add in instruments??? + * + * More buildings???? + * + * More Animals??? + * + * Readable Books? + * + * Custom NPCs for shops??? + * + * Frisbee Minigame? + * + * HorseRace Minigame/Betting? + * + * Locations: + * -Small Island Home? + * + */ + public class ModCore : Mod { public static IModHelper ModHelper; From 1efe48b4d61363574782cfef870e5d6625cee45f Mon Sep 17 00:00:00 2001 From: Joshua Navarro Date: Tue, 25 Dec 2018 19:48:45 -0800 Subject: [PATCH 20/72] Got light manager working for adding light sources to custom objects. --- .../Framework/Illuminate/ColorExtensions.cs | 8 + .../Framework/Illuminate/LightManager.cs | 167 ++++++++++++++++++ .../Framework/Objects/BasicItemInformation.cs | 15 +- .../Framework/Objects/MultiTiledComponent.cs | 15 +- GeneralMods/Revitalize/ModCore.cs | 17 +- GeneralMods/Revitalize/Revitalize.csproj | 1 + .../StardustCore/Objects/CoreObject.cs | 3 +- 7 files changed, 217 insertions(+), 9 deletions(-) create mode 100644 GeneralMods/Revitalize/Framework/Illuminate/LightManager.cs diff --git a/GeneralMods/Revitalize/Framework/Illuminate/ColorExtensions.cs b/GeneralMods/Revitalize/Framework/Illuminate/ColorExtensions.cs index 1cc17128..c3a03831 100644 --- a/GeneralMods/Revitalize/Framework/Illuminate/ColorExtensions.cs +++ b/GeneralMods/Revitalize/Framework/Illuminate/ColorExtensions.cs @@ -15,5 +15,13 @@ namespace Revitalize.Framework.Illuminate return new Color(new Vector3(value)); } + public static Color Invert(this Color color) + { + int r = Math.Abs(255 - color.R); + int g = Math.Abs(255 - color.G); + int b = Math.Abs(255 - color.B); + return new Color(r, g, b); + } + } } diff --git a/GeneralMods/Revitalize/Framework/Illuminate/LightManager.cs b/GeneralMods/Revitalize/Framework/Illuminate/LightManager.cs new file mode 100644 index 00000000..0dbb3efe --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Illuminate/LightManager.cs @@ -0,0 +1,167 @@ +using Microsoft.Xna.Framework; +using StardewValley; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Revitalize.Framework.Illuminate +{ + public class LightManager + { + public Dictionary lights; + public bool lightsOn; + + public LightManager() + { + this.lights = new Dictionary(); + lightsOn = false; + } + + /// + /// Add a light to the list of tracked lights. + /// + /// + /// + /// + /// + public bool addLight(Vector2 IdKey,LightSource light,StardewValley.Object gameObject) + { + Vector2 initialPosition = gameObject.TileLocation*Game1.tileSize; + initialPosition += IdKey; + + if (this.lights.ContainsKey(IdKey)) + { + return false; + } + else + { + light.position.Value = initialPosition; + this.lights.Add(IdKey, light); + return true; + } + } + + /// + /// Turn off a single light. + /// + /// + /// + /// + public bool turnOffLight(Vector2 IdKey, GameLocation location) + { + if (!lights.ContainsKey(IdKey)) + { + return false; + } + else + { + LightSource light = new LightSource(); + this.lights.TryGetValue(IdKey, out light); + Game1.currentLightSources.Remove(light); + location.sharedLights.Remove(light); + return true; + } + } + + /// + /// Turn on a single light. + /// + /// + /// + /// + public bool turnOnLight(Vector2 IdKey, GameLocation location,StardewValley.Object gameObject) + { + if (!lights.ContainsKey(IdKey)) + { + return false; + } + else + { + LightSource light = new LightSource(); + this.lights.TryGetValue(IdKey, out light); + if (light == null) + { + throw new Exception("Light is null????"); + } + Game1.currentLightSources.Add(light); + if (location == null) + { + throw new Exception("WHY IS LOC NULL???"); + } + if (location.sharedLights == null) + { + throw new Exception("Locational lights is null!"); + + } + Game1.showRedMessage("TURN ON!"); + Game1.currentLightSources.Add(light); + location.sharedLights.Add(light); + repositionLight(light,IdKey,gameObject); + return true; + } + } + + + + + /// + /// Add a light source to this location. + /// + /// The game location to add the light source in. + /// The color of the light to be added + public virtual void turnOnLights(GameLocation environment,StardewValley.Object gameObject) + { + foreach(KeyValuePair pair in this.lights) + { + turnOnLight(pair.Key, environment,gameObject); + } + repositionLights(gameObject); + } + + /// + /// Removes a lightsource from the game location. + /// + /// The game location to remove the light source from. + public void turnOffLights(GameLocation environment) + { + foreach (KeyValuePair pair in this.lights) + { + turnOffLight(pair.Key, environment); + } + + } + + public void repositionLights(StardewValley.Object gameObject) + { + foreach (KeyValuePair pair in this.lights) + { + repositionLight(pair.Value, pair.Key, gameObject); + } + } + + public void repositionLight(LightSource light,Vector2 offset,StardewValley.Object gameObject) + { + Vector2 initialPosition = gameObject.TileLocation * Game1.tileSize; + light.position.Value = initialPosition + offset; + } + + public virtual void toggleLights(GameLocation location,StardewValley.Object gameObject) + { + + if (lightsOn == false) + { + this.turnOnLights(location,gameObject); + lightsOn = true; + } + else if (lightsOn == true) + { + + this.turnOffLights(Game1.player.currentLocation); + lightsOn = false; + } + } + + } +} diff --git a/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs b/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs index 207feb90..bccfe455 100644 --- a/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs +++ b/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs @@ -2,6 +2,7 @@ using Microsoft.Xna.Framework.Graphics; using PyTK.CustomElementHandler; using Revitalize.Framework.Graphics.Animations; +using Revitalize.Framework.Illuminate; using Revitalize.Framework.Utilities; using System; using System.Collections.Generic; @@ -34,6 +35,8 @@ namespace Revitalize.Framework.Objects public InventoryManager inventory; + public LightManager lightManager; + public BasicItemInformation() : base() { name = ""; @@ -50,9 +53,10 @@ namespace Revitalize.Framework.Objects this.drawPosition = Vector2.Zero; this.drawColor = Color.White; this.inventory = new InventoryManager(); + this.lightManager = new LightManager(); } - public BasicItemInformation(string name, string description, string categoryName, Color categoryColor,int edibility,int fragility,bool isLamp,int price, Vector2 TileLocation,bool canBeSetOutdoors,bool canBeSetIndoors,string id, string data, Texture2D texture, Color color,int tileIndex, bool bigCraftable, Type type, CraftingData craftingData, AnimationManager animationManager,Color DrawColor,bool ignoreBoundingBox, InventoryManager Inventory):base(id,data,texture,color,tileIndex,bigCraftable,type,craftingData) + public BasicItemInformation(string name, string description, string categoryName, Color categoryColor,int edibility,int fragility,bool isLamp,int price, Vector2 TileLocation,bool canBeSetOutdoors,bool canBeSetIndoors,string id, string data, Texture2D texture, Color color,int tileIndex, bool bigCraftable, Type type, CraftingData craftingData, AnimationManager animationManager,Color DrawColor,bool ignoreBoundingBox, InventoryManager Inventory,LightManager Lights):base(id,data,texture,color,tileIndex,bigCraftable,type,craftingData) { this.name = name; this.description = description; @@ -100,6 +104,15 @@ namespace Revitalize.Framework.Objects { this.inventory = Inventory; } + + if (Lights == null) + { + this.lightManager = new LightManager(); + } + else + { + this.lightManager = Lights; + } } public void recreateDataString() diff --git a/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs b/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs index 1502278c..9ac9a47e 100644 --- a/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs +++ b/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs @@ -46,16 +46,28 @@ namespace Revitalize.Framework.Objects //return base.clicked(who); } - + public override bool rightClicked(Farmer who) + { + if (this.location == null) + { + this.location = Game1.player.currentLocation; + } + this.info.lightManager.toggleLights(this.location, this); + return true; + } + + public override void performRemoveAction(Vector2 tileLocation, GameLocation environment) { + this.location = null; base.performRemoveAction(this.TileLocation, environment); } public virtual void removeFromLocation(GameLocation location,Vector2 offset) { location.removeObject(this.TileLocation,false); + this.location = null; //this.performRemoveAction(this.TileLocation,location); } @@ -73,6 +85,7 @@ namespace Revitalize.Framework.Objects this.updateDrawPosition(x,y); this.location = location; + if (this.location == null) this.location = Game1.player.currentLocation; this.TileLocation = new Vector2((int)(x / Game1.tileSize), (int)(y / Game1.tileSize)); return base.placementAction(location, x, y, who); diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index ad634fe0..8c59dd2d 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -15,6 +15,7 @@ using Revitalize.Framework.Environment; using System.IO; using Revitalize.Framework.Crafting; using StardewValley.Objects; +using Revitalize.Framework.Illuminate; namespace Revitalize { @@ -77,6 +78,7 @@ namespace Revitalize * Locations: * -Small Island Home? * + * More crops */ public class ModCore : Mod @@ -125,11 +127,14 @@ namespace Revitalize private void GameLoop_SaveLoaded(object sender, StardewModdingAPI.Events.SaveLoadedEventArgs e) { - MultiTiledComponent obj = new MultiTiledComponent(new BasicItemInformation("CoreObjectTest","YAY FUN!","Omegasis.Revitalize.MultiTiledComponent",Color.White,-300,0,false,100,Vector2.Zero,true,true,"Omegasis.TEST1", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", Game1.objectSpriteSheet,Color.White,0,true,typeof(MultiTiledComponent),null,new AnimationManager(new Texture2DExtended(Game1.objectSpriteSheet),new Animation(new Rectangle(0,0,16,16))),Color.Red,true,null)); - MultiTiledComponent obj2 = new MultiTiledComponent(new BasicItemInformation("CoreObjectTest2", "SomeFun", "Omegasis.Revitalize.MultiTiledComponent", Color.White, -300, 0, false, 100, Vector2.Zero, true, true, "Omegasis.TEST1", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", Game1.objectSpriteSheet, Color.White, 0, true, typeof(MultiTiledComponent), null, new AnimationManager(new Texture2DExtended(Game1.objectSpriteSheet), new Animation(new Rectangle(0, 16, 16, 16))), Color.Red,false,null)); - MultiTiledComponent obj3 = new MultiTiledComponent(new BasicItemInformation("CoreObjectTest3", "NoFun", "Omegasis.Revitalize.MultiTiledComponent", Color.White, -300, 0, false, 100, Vector2.Zero, true, true, "Omegasis.TEST1", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", Game1.objectSpriteSheet, Color.White, 0, true, typeof(MultiTiledComponent), null, new AnimationManager(new Texture2DExtended(Game1.objectSpriteSheet), new Animation(new Rectangle(0, 32, 16, 16))), Color.Red,false,null)); + MultiTiledComponent obj = new MultiTiledComponent(new BasicItemInformation("CoreObjectTest","YAY FUN!","Omegasis.Revitalize.MultiTiledComponent",Color.White,-300,0,false,100,Vector2.Zero,true,true,"Omegasis.TEST1", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", Game1.objectSpriteSheet,Color.White,0,true,typeof(MultiTiledComponent),null,new AnimationManager(new Texture2DExtended(Game1.objectSpriteSheet),new Animation(new Rectangle(0,0,16,16))),Color.Red,true,null,null)); + MultiTiledComponent obj2 = new MultiTiledComponent(new BasicItemInformation("CoreObjectTest2", "SomeFun", "Omegasis.Revitalize.MultiTiledComponent", Color.White, -300, 0, false, 100, Vector2.Zero, true, true, "Omegasis.TEST1", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", Game1.objectSpriteSheet, Color.White, 0, true, typeof(MultiTiledComponent), null, new AnimationManager(new Texture2DExtended(Game1.objectSpriteSheet), new Animation(new Rectangle(0, 16, 16, 16))), Color.Red,false,null,null)); + MultiTiledComponent obj3 = new MultiTiledComponent(new BasicItemInformation("CoreObjectTest3", "NoFun", "Omegasis.Revitalize.MultiTiledComponent", Color.White, -300, 0, false, 100, Vector2.Zero, true, true, "Omegasis.TEST1", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", Game1.objectSpriteSheet, Color.White, 0, true, typeof(MultiTiledComponent), null, new AnimationManager(new Texture2DExtended(Game1.objectSpriteSheet), new Animation(new Rectangle(0, 32, 16, 16))), Color.Red,false,null,null)); - MultiTiledObject bigObject= new MultiTiledObject(new BasicItemInformation("MultiTest", "A really big object", "Omegasis.Revitalize.MultiTiledObject", Color.Blue, -300, 0, false, 100, Vector2.Zero, true, true, "Omegasis.BigTiledTest", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", Game1.objectSpriteSheet, Color.White, 0, true, typeof(MultiTiledObject), null, new AnimationManager(), Color.White,false,null)); + + obj.info.lightManager.addLight(new Vector2(Game1.tileSize), new LightSource(4, new Vector2(0, 0), 2.5f, Color.Orange.Invert()), obj); + + MultiTiledObject bigObject= new MultiTiledObject(new BasicItemInformation("MultiTest", "A really big object", "Omegasis.Revitalize.MultiTiledObject", Color.Blue, -300, 0, false, 100, Vector2.Zero, true, true, "Omegasis.BigTiledTest", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", Game1.objectSpriteSheet, Color.White, 0, true, typeof(MultiTiledObject), null, new AnimationManager(), Color.White,false,null,null)); bigObject.addComponent(new Vector2(0, 0), obj); bigObject.addComponent(new Vector2(1, 0), obj2); bigObject.addComponent(new Vector2(2, 0), obj3); @@ -142,10 +147,10 @@ namespace Revitalize new InventoryItem(bigObject, 100,1).addToNPCShop("Gus"); Game1.player.addItemToInventory(bigObject); - + if (pie.PlayerCanCraft()) { - pie.craft(); + //pie.craft(); } } diff --git a/GeneralMods/Revitalize/Revitalize.csproj b/GeneralMods/Revitalize/Revitalize.csproj index 64b1d86a..b08233ee 100644 --- a/GeneralMods/Revitalize/Revitalize.csproj +++ b/GeneralMods/Revitalize/Revitalize.csproj @@ -52,6 +52,7 @@ + diff --git a/GeneralMods/StardustCore/Objects/CoreObject.cs b/GeneralMods/StardustCore/Objects/CoreObject.cs index 913fcfde..73d76bf5 100644 --- a/GeneralMods/StardustCore/Objects/CoreObject.cs +++ b/GeneralMods/StardustCore/Objects/CoreObject.cs @@ -894,7 +894,8 @@ namespace StardustCore num2 = 2; goto IL_94; } - num = 1; + + num = 1; num2 = 1; IL_94: return new Rectangle((int)this.TileLocation.X * Game1.tileSize, (int)this.TileLocation.Y * Game1.tileSize, num * Game1.tileSize, num2 * Game1.tileSize); From 3369c11cb9b8e0a4e84e8c7a205b4b3affed5380 Mon Sep 17 00:00:00 2001 From: Joshua Navarro Date: Fri, 28 Dec 2018 22:23:16 -0800 Subject: [PATCH 21/72] Fixed issues with objects being destroyed underfoot. --- .../Revitalize/Framework/Objects/CustomObject.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs index cd6f2ab0..8949ce30 100644 --- a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs +++ b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs @@ -99,11 +99,18 @@ namespace Revitalize.Framework.Objects this.bigCraftable.Value = false; - + if (this.info.ignoreBoundingBox) { - this.boundingBox.Value = new Rectangle(Int32.MinValue, Int32.MinValue, 0, 0); + //this.boundingBox.Value = new Rectangle(Int32.MinValue, Int32.MinValue, 0, 0); } + + + } + + public override bool isPassable() + { + return this.info.ignoreBoundingBox; } public override Rectangle getBoundingBox(Vector2 tileLocation) From 8530a9ea03d9aaf5389b269e88954d9db2f2008f Mon Sep 17 00:00:00 2001 From: Joshua Navarro Date: Fri, 28 Dec 2018 23:28:21 -0800 Subject: [PATCH 22/72] Got sitting working as a test! Next: Make some chairs! --- GeneralMods/HappyBirthday/manifest.json | 2 +- .../Framework/Objects/MultiTiledComponent.cs | 3 + .../Framework/Player/Managers/SittingInfo.cs | 128 ++++++++++++++++++ .../Revitalize/Framework/Player/PlayerInfo.cs | 27 ++++ GeneralMods/Revitalize/ModCore.cs | 4 + GeneralMods/Revitalize/Revitalize.csproj | 2 + 6 files changed, 165 insertions(+), 1 deletion(-) create mode 100644 GeneralMods/Revitalize/Framework/Player/Managers/SittingInfo.cs create mode 100644 GeneralMods/Revitalize/Framework/Player/PlayerInfo.cs diff --git a/GeneralMods/HappyBirthday/manifest.json b/GeneralMods/HappyBirthday/manifest.json index 8a984cae..54b399eb 100644 --- a/GeneralMods/HappyBirthday/manifest.json +++ b/GeneralMods/HappyBirthday/manifest.json @@ -1,7 +1,7 @@ { "Name": "Happy Birthday", "Author": "Alpha_Omegasis", - "Version": "1.8.0", + "Version": "1.8.2", "MinimumApiVersion": "1.15", "Description": "Adds the farmer's birthday to the game.", "UniqueID": "Omegasis.HappyBirthday", diff --git a/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs b/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs index 9ac9a47e..a59ee09a 100644 --- a/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs +++ b/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs @@ -53,6 +53,9 @@ namespace Revitalize.Framework.Objects this.location = Game1.player.currentLocation; } this.info.lightManager.toggleLights(this.location, this); + + Revitalize.ModCore.playerInfo.sittingInfo.sit(this, Vector2.Zero); + return true; } diff --git a/GeneralMods/Revitalize/Framework/Player/Managers/SittingInfo.cs b/GeneralMods/Revitalize/Framework/Player/Managers/SittingInfo.cs new file mode 100644 index 00000000..ef668982 --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Player/Managers/SittingInfo.cs @@ -0,0 +1,128 @@ +using Microsoft.Xna.Framework; +using StardewValley; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Revitalize.Framework.Player.Managers +{ + /// + /// TODO: + /// Make chair + /// animate player better + /// have it where when player is sitting on chair it is passable so it can't be destoryed underneath + /// + public class SittingInfo + { + /// + /// If the player is currently sitting. + /// + public bool isSitting; + + /// + /// How long a Farmer has sat (in milliseconds) + /// + private int elapsedTime; + + /// + /// Gets how long the farmer has sat (in milliseconds). + /// + public int ElapsedTime + { + get + { + return elapsedTime; + } + } + + /// + /// Keeps trck of time elapsed. + /// + GameTime timer; + + + /// + /// The default amount of time a player has to sit to recover some energy/health + /// + private int _sittingSpan; + /// + /// A modified version of how long a player has to sit to recover energy/health; + /// + public int SittingSpan + { + get + { + return _sittingSpan; + } + } + + + + /// + /// Constructor. + /// + public SittingInfo() + { + timer = Game1.currentGameTime; + this._sittingSpan = 10000; + } + + /// + /// Update the sitting info. + /// + public void update() + { + if (Game1.activeClickableMenu != null) return; + + if (Game1.player.isMoving()) + { + isSitting = false; + elapsedTime = 0; + } + if (isSitting && Game1.player.CanMove) + { + showSitting(); + if (timer == null) timer = Game1.currentGameTime; + elapsedTime += timer.ElapsedGameTime.Milliseconds; + } + + if (elapsedTime >= SittingSpan) + { + elapsedTime %= SittingSpan; + Game1.player.health++; + Game1.player.Stamina++; + } + Revitalize.ModCore.log(elapsedTime); + + } + + public void showSitting() + { + switch (Game1.player.FacingDirection) + { + case 0: + Game1.player.FarmerSprite.setCurrentSingleFrame(113, (short)32000, false, false); + break; + case 1: + Game1.player.FarmerSprite.setCurrentSingleFrame(106, (short)32000, false, false); + break; + case 2: + Game1.player.FarmerSprite.setCurrentSingleFrame(107, (short)32000, false, false); + break; + case 3: + Game1.player.FarmerSprite.setCurrentSingleFrame(106, (short)32000, false, true); + break; + } + } + + public void sit(StardewValley.Object obj,Vector2 offset) + { + this.isSitting = true; + Game1.player.Position = (obj.TileLocation * Game1.tileSize + offset); + Game1.player.position.Y += Game1.tileSize/2; + } + + } +} diff --git a/GeneralMods/Revitalize/Framework/Player/PlayerInfo.cs b/GeneralMods/Revitalize/Framework/Player/PlayerInfo.cs new file mode 100644 index 00000000..efde5463 --- /dev/null +++ b/GeneralMods/Revitalize/Framework/Player/PlayerInfo.cs @@ -0,0 +1,27 @@ +using Microsoft.Xna.Framework; +using Revitalize.Framework.Player.Managers; +using StardewValley; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Revitalize.Framework.Player +{ + public class PlayerInfo + { + public SittingInfo sittingInfo; + + public PlayerInfo() + { + sittingInfo = new SittingInfo(); + } + + + public void update() + { + sittingInfo.update(); + } + } +} diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index 8c59dd2d..c1858c8b 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -16,6 +16,7 @@ using System.IO; using Revitalize.Framework.Crafting; using StardewValley.Objects; using Revitalize.Framework.Illuminate; +using Revitalize.Framework.Player; namespace Revitalize { @@ -88,6 +89,7 @@ namespace Revitalize public static Dictionary customObjects; + public static PlayerInfo playerInfo; public override void Entry(IModHelper helper) { @@ -101,6 +103,7 @@ namespace Revitalize ModHelper.Events.GameLoop.SaveLoaded += GameLoop_SaveLoaded; ModHelper.Events.GameLoop.TimeChanged += GameLoop_TimeChanged; ModHelper.Events.GameLoop.UpdateTicked += GameLoop_UpdateTicked; + playerInfo = new PlayerInfo(); } @@ -118,6 +121,7 @@ namespace Revitalize private void GameLoop_UpdateTicked(object sender, StardewModdingAPI.Events.UpdateTickedEventArgs e) { DarkerNight.SetDarkerColor(); + playerInfo.update(); } private void GameLoop_TimeChanged(object sender, StardewModdingAPI.Events.TimeChangedEventArgs e) diff --git a/GeneralMods/Revitalize/Revitalize.csproj b/GeneralMods/Revitalize/Revitalize.csproj index b08233ee..c117d27d 100644 --- a/GeneralMods/Revitalize/Revitalize.csproj +++ b/GeneralMods/Revitalize/Revitalize.csproj @@ -57,6 +57,8 @@ + + From 22af3b7af754f1cb4a866a9d3c9ab328040ee79f Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sat, 29 Dec 2018 22:21:19 -0500 Subject: [PATCH 23/72] migrate to the new package reference format --- .../AdvancedSaveBackup.csproj | 18 +++-------- .../AdvancedSaveBackup/packages.config | 4 --- GeneralMods/AutoSpeed/AutoSpeed.csproj | 18 +++-------- GeneralMods/AutoSpeed/packages.config | 4 --- .../BillboardAnywhere.csproj | 18 +++-------- GeneralMods/BillboardAnywhere/packages.config | 4 --- .../BuildEndurance/BuildEndurance.csproj | 18 +++-------- GeneralMods/BuildEndurance/packages.config | 4 --- GeneralMods/BuildHealth/BuildHealth.csproj | 18 +++-------- GeneralMods/BuildHealth/packages.config | 4 --- .../BuyBackCollectables.csproj | 18 +++-------- .../BuyBackCollectables/packages.config | 4 --- .../CustomNPCFramework.csproj | 28 +++-------------- .../CustomNPCFramework/packages.config | 4 --- .../DailyQuestAnywhere.csproj | 18 +++-------- .../DailyQuestAnywhere/packages.config | 4 --- .../Fall28SnowDay/Fall28SnowDay.csproj | 18 +++-------- GeneralMods/Fall28SnowDay/packages.config | 4 --- .../FarmersMarketStall.csproj | 18 ++--------- .../FarmersMarketStall/packages.config | 4 --- .../HappyBirthday/HappyBirthday.csproj | 22 +++---------- GeneralMods/HappyBirthday/packages.config | 5 --- GeneralMods/MapEvents/EventSystem.csproj | 27 +++------------- GeneralMods/MapEvents/packages.config | 4 --- GeneralMods/MoreRain/MoreRain.csproj | 18 +++-------- GeneralMods/MoreRain/packages.config | 4 --- .../MuseumRearranger/MuseumRearranger.csproj | 18 +++-------- GeneralMods/MuseumRearranger/packages.config | 4 --- GeneralMods/NightOwl/NightOwl.csproj | 18 +++-------- GeneralMods/NightOwl/packages.config | 4 --- GeneralMods/NoMorePets/NoMorePets.csproj | 18 +++-------- GeneralMods/NoMorePets/packages.config | 4 --- GeneralMods/Revitalize/Revitalize.csproj | 19 ++---------- GeneralMods/Revitalize/packages.config | 4 --- GeneralMods/SaveAnywhere/SaveAnywhere.csproj | 18 +++-------- GeneralMods/SaveAnywhere/packages.config | 4 --- .../SimpleSoundManager.csproj | 18 +++-------- .../SimpleSoundManager/packages.config | 4 --- .../StardewSymphonyRemastered.csproj | 27 +++------------- .../StardewSymphonyRemastered/packages.config | 4 --- GeneralMods/StardustCore/StardustCore.csproj | 23 +++----------- GeneralMods/StardustCore/packages.config | 5 --- .../SundropMapEvents/SundropMapEvents.csproj | 31 +++---------------- GeneralMods/SundropMapEvents/packages.config | 5 --- GeneralMods/TimeFreeze/TimeFreeze.csproj | 18 +++-------- GeneralMods/TimeFreeze/packages.config | 4 --- .../Vocalization/Vocalization.csproj | 18 ++--------- .../Vocalization/Vocalization/packages.config | 4 --- 48 files changed, 96 insertions(+), 486 deletions(-) delete mode 100644 GeneralMods/AdvancedSaveBackup/packages.config delete mode 100644 GeneralMods/AutoSpeed/packages.config delete mode 100644 GeneralMods/BillboardAnywhere/packages.config delete mode 100644 GeneralMods/BuildEndurance/packages.config delete mode 100644 GeneralMods/BuildHealth/packages.config delete mode 100644 GeneralMods/BuyBackCollectables/packages.config delete mode 100644 GeneralMods/CustomNPCFramework/packages.config delete mode 100644 GeneralMods/DailyQuestAnywhere/packages.config delete mode 100644 GeneralMods/Fall28SnowDay/packages.config delete mode 100644 GeneralMods/FarmersMarketStall/packages.config delete mode 100644 GeneralMods/HappyBirthday/packages.config delete mode 100644 GeneralMods/MapEvents/packages.config delete mode 100644 GeneralMods/MoreRain/packages.config delete mode 100644 GeneralMods/MuseumRearranger/packages.config delete mode 100644 GeneralMods/NightOwl/packages.config delete mode 100644 GeneralMods/NoMorePets/packages.config delete mode 100644 GeneralMods/Revitalize/packages.config delete mode 100644 GeneralMods/SaveAnywhere/packages.config delete mode 100644 GeneralMods/SimpleSoundManager/packages.config delete mode 100644 GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/packages.config delete mode 100644 GeneralMods/StardustCore/packages.config delete mode 100644 GeneralMods/SundropMapEvents/packages.config delete mode 100644 GeneralMods/TimeFreeze/packages.config delete mode 100644 GeneralMods/Vocalization/Vocalization/packages.config diff --git a/GeneralMods/AdvancedSaveBackup/AdvancedSaveBackup.csproj b/GeneralMods/AdvancedSaveBackup/AdvancedSaveBackup.csproj index eeae3c37..46bf2a7a 100644 --- a/GeneralMods/AdvancedSaveBackup/AdvancedSaveBackup.csproj +++ b/GeneralMods/AdvancedSaveBackup/AdvancedSaveBackup.csproj @@ -1,5 +1,5 @@  - + Debug @@ -11,8 +11,6 @@ AdvancedSaveBackup v4.5 512 - - true @@ -67,6 +65,9 @@ prompt MinimumRecommendedRules.ruleset + + + @@ -83,19 +84,8 @@ - - - - - - - - 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/AdvancedSaveBackup/packages.config b/GeneralMods/AdvancedSaveBackup/packages.config deleted file mode 100644 index af793ad3..00000000 --- a/GeneralMods/AdvancedSaveBackup/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/GeneralMods/AutoSpeed/AutoSpeed.csproj b/GeneralMods/AutoSpeed/AutoSpeed.csproj index 23545179..50269de6 100644 --- a/GeneralMods/AutoSpeed/AutoSpeed.csproj +++ b/GeneralMods/AutoSpeed/AutoSpeed.csproj @@ -1,5 +1,5 @@  - + Debug @@ -11,8 +11,6 @@ AutoSpeed v4.5 512 - - true @@ -67,6 +65,9 @@ prompt MinimumRecommendedRules.ruleset + + + @@ -81,19 +82,8 @@ - - - - - - - - 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/AutoSpeed/packages.config b/GeneralMods/AutoSpeed/packages.config deleted file mode 100644 index af793ad3..00000000 --- a/GeneralMods/AutoSpeed/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/GeneralMods/BillboardAnywhere/BillboardAnywhere.csproj b/GeneralMods/BillboardAnywhere/BillboardAnywhere.csproj index a3638df8..d98ba599 100644 --- a/GeneralMods/BillboardAnywhere/BillboardAnywhere.csproj +++ b/GeneralMods/BillboardAnywhere/BillboardAnywhere.csproj @@ -1,5 +1,5 @@  - + Debug @@ -11,8 +11,6 @@ BillboardAnywhere v4.5 512 - - true @@ -67,6 +65,9 @@ prompt MinimumRecommendedRules.ruleset + + + @@ -83,19 +84,8 @@ - - - - - - - - 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/BillboardAnywhere/packages.config b/GeneralMods/BillboardAnywhere/packages.config deleted file mode 100644 index af793ad3..00000000 --- a/GeneralMods/BillboardAnywhere/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/GeneralMods/BuildEndurance/BuildEndurance.csproj b/GeneralMods/BuildEndurance/BuildEndurance.csproj index 0fd10fa4..83e9f2df 100644 --- a/GeneralMods/BuildEndurance/BuildEndurance.csproj +++ b/GeneralMods/BuildEndurance/BuildEndurance.csproj @@ -1,5 +1,5 @@  - + Debug @@ -11,8 +11,6 @@ BuildEndurance v4.5 512 - - true @@ -67,6 +65,9 @@ prompt MinimumRecommendedRules.ruleset + + + @@ -82,19 +83,8 @@ - - - - - - - - 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/BuildEndurance/packages.config b/GeneralMods/BuildEndurance/packages.config deleted file mode 100644 index af793ad3..00000000 --- a/GeneralMods/BuildEndurance/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/GeneralMods/BuildHealth/BuildHealth.csproj b/GeneralMods/BuildHealth/BuildHealth.csproj index d1627a93..f1846f3b 100644 --- a/GeneralMods/BuildHealth/BuildHealth.csproj +++ b/GeneralMods/BuildHealth/BuildHealth.csproj @@ -1,5 +1,5 @@  - + Debug @@ -11,8 +11,6 @@ BuildHealth v4.5 512 - - true @@ -67,6 +65,9 @@ prompt MinimumRecommendedRules.ruleset + + + @@ -82,19 +83,8 @@ - - - - - - - - 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/BuildHealth/packages.config b/GeneralMods/BuildHealth/packages.config deleted file mode 100644 index af793ad3..00000000 --- a/GeneralMods/BuildHealth/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/GeneralMods/BuyBackCollectables/BuyBackCollectables.csproj b/GeneralMods/BuyBackCollectables/BuyBackCollectables.csproj index 488853fb..dcba9f4e 100644 --- a/GeneralMods/BuyBackCollectables/BuyBackCollectables.csproj +++ b/GeneralMods/BuyBackCollectables/BuyBackCollectables.csproj @@ -1,5 +1,5 @@  - + Debug @@ -11,8 +11,6 @@ BuyBackCollectables v4.5 512 - - true @@ -67,6 +65,9 @@ prompt MinimumRecommendedRules.ruleset + + + @@ -84,19 +85,8 @@ - - - - - - - - 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/BuyBackCollectables/packages.config b/GeneralMods/BuyBackCollectables/packages.config deleted file mode 100644 index af793ad3..00000000 --- a/GeneralMods/BuyBackCollectables/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/GeneralMods/CustomNPCFramework/CustomNPCFramework.csproj b/GeneralMods/CustomNPCFramework/CustomNPCFramework.csproj index 20071e85..5d0e36ed 100644 --- a/GeneralMods/CustomNPCFramework/CustomNPCFramework.csproj +++ b/GeneralMods/CustomNPCFramework/CustomNPCFramework.csproj @@ -1,5 +1,5 @@  - + Debug @@ -11,9 +11,6 @@ CustomNPCFramework v4.5 512 - - - true @@ -70,6 +67,9 @@ prompt MinimumRecommendedRules.ruleset + + + @@ -115,25 +115,5 @@ StardustCore - - - - - - - - - - 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/CustomNPCFramework/packages.config b/GeneralMods/CustomNPCFramework/packages.config deleted file mode 100644 index af793ad3..00000000 --- a/GeneralMods/CustomNPCFramework/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/GeneralMods/DailyQuestAnywhere/DailyQuestAnywhere.csproj b/GeneralMods/DailyQuestAnywhere/DailyQuestAnywhere.csproj index 2d0790fc..13cf5c50 100644 --- a/GeneralMods/DailyQuestAnywhere/DailyQuestAnywhere.csproj +++ b/GeneralMods/DailyQuestAnywhere/DailyQuestAnywhere.csproj @@ -1,5 +1,5 @@  - + Debug @@ -11,8 +11,6 @@ DailyQuestAnywhere v4.5 512 - - true @@ -67,6 +65,9 @@ prompt MinimumRecommendedRules.ruleset + + + @@ -83,19 +84,8 @@ - - - - - - - - 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/DailyQuestAnywhere/packages.config b/GeneralMods/DailyQuestAnywhere/packages.config deleted file mode 100644 index af793ad3..00000000 --- a/GeneralMods/DailyQuestAnywhere/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/GeneralMods/Fall28SnowDay/Fall28SnowDay.csproj b/GeneralMods/Fall28SnowDay/Fall28SnowDay.csproj index e0b9c753..23b5bc04 100644 --- a/GeneralMods/Fall28SnowDay/Fall28SnowDay.csproj +++ b/GeneralMods/Fall28SnowDay/Fall28SnowDay.csproj @@ -1,5 +1,5 @@  - + Debug @@ -11,8 +11,6 @@ Fall28SnowDay v4.5 512 - - true @@ -67,6 +65,9 @@ prompt MinimumRecommendedRules.ruleset + + + @@ -82,19 +83,8 @@ - - - - - - - - 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/Fall28SnowDay/packages.config b/GeneralMods/Fall28SnowDay/packages.config deleted file mode 100644 index af793ad3..00000000 --- a/GeneralMods/Fall28SnowDay/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/GeneralMods/FarmersMarketStall/FarmersMarketStall.csproj b/GeneralMods/FarmersMarketStall/FarmersMarketStall.csproj index c2b0dbbc..74b88d6b 100644 --- a/GeneralMods/FarmersMarketStall/FarmersMarketStall.csproj +++ b/GeneralMods/FarmersMarketStall/FarmersMarketStall.csproj @@ -11,8 +11,6 @@ FarmersMarketStall v4.6.1 512 - - true @@ -67,6 +65,9 @@ prompt MinimumRecommendedRules.ruleset + + + ..\MapEvents\bin\Release\EventSystem.dll @@ -87,18 +88,5 @@ - - - - - - - - - - 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/packages.config b/GeneralMods/FarmersMarketStall/packages.config deleted file mode 100644 index 84563214..00000000 --- a/GeneralMods/FarmersMarketStall/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/GeneralMods/HappyBirthday/HappyBirthday.csproj b/GeneralMods/HappyBirthday/HappyBirthday.csproj index 6d571ee8..15023a81 100644 --- a/GeneralMods/HappyBirthday/HappyBirthday.csproj +++ b/GeneralMods/HappyBirthday/HappyBirthday.csproj @@ -1,5 +1,5 @@  - + Debug @@ -11,8 +11,6 @@ HappyBirthday v4.5 512 - - true @@ -71,9 +69,10 @@ MinimumRecommendedRules.ruleset - - ..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll - + + + + @@ -98,22 +97,11 @@ - - - - - - - - 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/HappyBirthday/packages.config b/GeneralMods/HappyBirthday/packages.config deleted file mode 100644 index b8b15c8e..00000000 --- a/GeneralMods/HappyBirthday/packages.config +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/GeneralMods/MapEvents/EventSystem.csproj b/GeneralMods/MapEvents/EventSystem.csproj index 8dd8ec3a..dbf9baee 100644 --- a/GeneralMods/MapEvents/EventSystem.csproj +++ b/GeneralMods/MapEvents/EventSystem.csproj @@ -1,5 +1,5 @@  - + Debug @@ -11,8 +11,6 @@ EventSystem v4.5 512 - - true @@ -67,6 +65,9 @@ prompt MinimumRecommendedRules.ruleset + + + @@ -91,25 +92,5 @@ - - - - - - - - - - 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/MapEvents/packages.config b/GeneralMods/MapEvents/packages.config deleted file mode 100644 index af793ad3..00000000 --- a/GeneralMods/MapEvents/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/GeneralMods/MoreRain/MoreRain.csproj b/GeneralMods/MoreRain/MoreRain.csproj index 3b5337c8..1517a05e 100644 --- a/GeneralMods/MoreRain/MoreRain.csproj +++ b/GeneralMods/MoreRain/MoreRain.csproj @@ -1,5 +1,5 @@  - + Debug @@ -11,8 +11,6 @@ MoreRain v4.5 512 - - true @@ -67,6 +65,9 @@ prompt MinimumRecommendedRules.ruleset + + + @@ -81,19 +82,8 @@ - - - - - - - - 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/MoreRain/packages.config b/GeneralMods/MoreRain/packages.config deleted file mode 100644 index af793ad3..00000000 --- a/GeneralMods/MoreRain/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/GeneralMods/MuseumRearranger/MuseumRearranger.csproj b/GeneralMods/MuseumRearranger/MuseumRearranger.csproj index 07ec6f76..7f1ced70 100644 --- a/GeneralMods/MuseumRearranger/MuseumRearranger.csproj +++ b/GeneralMods/MuseumRearranger/MuseumRearranger.csproj @@ -1,5 +1,5 @@  - + Debug @@ -11,8 +11,6 @@ MuseumRearranger v4.5 512 - - true @@ -69,6 +67,9 @@ prompt MinimumRecommendedRules.ruleset + + + @@ -84,19 +85,8 @@ - - - - - - - - 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/MuseumRearranger/packages.config b/GeneralMods/MuseumRearranger/packages.config deleted file mode 100644 index af793ad3..00000000 --- a/GeneralMods/MuseumRearranger/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/GeneralMods/NightOwl/NightOwl.csproj b/GeneralMods/NightOwl/NightOwl.csproj index a744fce1..7c0f46b8 100644 --- a/GeneralMods/NightOwl/NightOwl.csproj +++ b/GeneralMods/NightOwl/NightOwl.csproj @@ -1,5 +1,5 @@  - + Debug @@ -11,8 +11,6 @@ NightOwl v4.5 512 - - true @@ -67,6 +65,9 @@ prompt MinimumRecommendedRules.ruleset + + + @@ -87,19 +88,8 @@ - - - - - - - - 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/NightOwl/packages.config b/GeneralMods/NightOwl/packages.config deleted file mode 100644 index af793ad3..00000000 --- a/GeneralMods/NightOwl/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/GeneralMods/NoMorePets/NoMorePets.csproj b/GeneralMods/NoMorePets/NoMorePets.csproj index 9b5cef2a..d6478fbb 100644 --- a/GeneralMods/NoMorePets/NoMorePets.csproj +++ b/GeneralMods/NoMorePets/NoMorePets.csproj @@ -1,5 +1,5 @@  - + Debug @@ -11,8 +11,6 @@ NoMorePets v4.5 512 - - true @@ -67,6 +65,9 @@ prompt MinimumRecommendedRules.ruleset + + + @@ -82,19 +83,8 @@ - - - - - - - - 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/NoMorePets/packages.config b/GeneralMods/NoMorePets/packages.config deleted file mode 100644 index af793ad3..00000000 --- a/GeneralMods/NoMorePets/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/GeneralMods/Revitalize/Revitalize.csproj b/GeneralMods/Revitalize/Revitalize.csproj index c117d27d..846ea608 100644 --- a/GeneralMods/Revitalize/Revitalize.csproj +++ b/GeneralMods/Revitalize/Revitalize.csproj @@ -11,8 +11,6 @@ Revitalize v4.6.1 512 - - true @@ -31,6 +29,9 @@ prompt 4 + + + ..\..\..\..\..\..\..\Desktop\New folder (2)\PyTK.dll @@ -65,20 +66,6 @@ - - - - - - - - - - - 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/Revitalize/packages.config b/GeneralMods/Revitalize/packages.config deleted file mode 100644 index 84563214..00000000 --- a/GeneralMods/Revitalize/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/GeneralMods/SaveAnywhere/SaveAnywhere.csproj b/GeneralMods/SaveAnywhere/SaveAnywhere.csproj index a059c773..2fb9a4ca 100644 --- a/GeneralMods/SaveAnywhere/SaveAnywhere.csproj +++ b/GeneralMods/SaveAnywhere/SaveAnywhere.csproj @@ -1,5 +1,5 @@  - + Debug @@ -11,8 +11,6 @@ SaveAnywhere v4.5.2 512 - - true @@ -67,6 +65,9 @@ prompt MinimumRecommendedRules.ruleset + + + @@ -92,19 +93,8 @@ - - - - - - - - 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/SaveAnywhere/packages.config b/GeneralMods/SaveAnywhere/packages.config deleted file mode 100644 index 30506716..00000000 --- a/GeneralMods/SaveAnywhere/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/GeneralMods/SimpleSoundManager/SimpleSoundManager.csproj b/GeneralMods/SimpleSoundManager/SimpleSoundManager.csproj index b5eb855e..4e840a0a 100644 --- a/GeneralMods/SimpleSoundManager/SimpleSoundManager.csproj +++ b/GeneralMods/SimpleSoundManager/SimpleSoundManager.csproj @@ -1,5 +1,5 @@  - + Debug @@ -11,8 +11,6 @@ SimpleSoundManager v4.5 512 - - true @@ -67,6 +65,9 @@ prompt MinimumRecommendedRules.ruleset + + + @@ -82,19 +83,8 @@ - - - - - - - - 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/SimpleSoundManager/packages.config b/GeneralMods/SimpleSoundManager/packages.config deleted file mode 100644 index af793ad3..00000000 --- a/GeneralMods/SimpleSoundManager/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/StardewSymphonyRemastered.csproj b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/StardewSymphonyRemastered.csproj index 9c4c3c98..8cfa1ac1 100644 --- a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/StardewSymphonyRemastered.csproj +++ b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/StardewSymphonyRemastered.csproj @@ -1,5 +1,5 @@  - + Debug @@ -11,8 +11,6 @@ StardewSymphonyRemastered v4.5 512 - - true @@ -67,6 +65,9 @@ prompt MinimumRecommendedRules.ruleset + + + ..\..\..\..\..\..\..\..\Desktop\NAudio.dll @@ -218,7 +219,6 @@ Always - @@ -238,25 +238,6 @@ - - - - - - - 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/StardewSymphonyRemastered/StardewSymphonyRemastered/packages.config b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/packages.config deleted file mode 100644 index af793ad3..00000000 --- a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/GeneralMods/StardustCore/StardustCore.csproj b/GeneralMods/StardustCore/StardustCore.csproj index 2c739c1d..12bbe40b 100644 --- a/GeneralMods/StardustCore/StardustCore.csproj +++ b/GeneralMods/StardustCore/StardustCore.csproj @@ -1,5 +1,5 @@  - + Debug @@ -11,9 +11,6 @@ StardustCore v4.5 512 - - - true @@ -70,14 +67,15 @@ prompt MinimumRecommendedRules.ruleset + + + + False ..\..\..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Stardew Valley\Lidgren.Network.dll - - ..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll - @@ -147,7 +145,6 @@ - @@ -453,16 +450,6 @@ PreserveNewest - - - - - - - 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/StardustCore/packages.config b/GeneralMods/StardustCore/packages.config deleted file mode 100644 index b8b15c8e..00000000 --- a/GeneralMods/StardustCore/packages.config +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/GeneralMods/SundropMapEvents/SundropMapEvents.csproj b/GeneralMods/SundropMapEvents/SundropMapEvents.csproj index b5c6c929..84e1bd96 100644 --- a/GeneralMods/SundropMapEvents/SundropMapEvents.csproj +++ b/GeneralMods/SundropMapEvents/SundropMapEvents.csproj @@ -1,5 +1,5 @@  - + Debug @@ -11,8 +11,6 @@ SundropMapEvents v4.5 512 - - true @@ -67,13 +65,14 @@ prompt MinimumRecommendedRules.ruleset + + + + ..\MapEvents\bin\Release\EventSystem.dll - - ..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll - @@ -87,25 +86,5 @@ - - - - - - - - - - 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/SundropMapEvents/packages.config b/GeneralMods/SundropMapEvents/packages.config deleted file mode 100644 index b8b15c8e..00000000 --- a/GeneralMods/SundropMapEvents/packages.config +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/GeneralMods/TimeFreeze/TimeFreeze.csproj b/GeneralMods/TimeFreeze/TimeFreeze.csproj index 2e39ee10..b91c66e6 100644 --- a/GeneralMods/TimeFreeze/TimeFreeze.csproj +++ b/GeneralMods/TimeFreeze/TimeFreeze.csproj @@ -1,5 +1,5 @@  - + Debug @@ -11,8 +11,6 @@ TimeFreeze v4.5 512 - - true @@ -67,6 +65,9 @@ prompt MinimumRecommendedRules.ruleset + + + @@ -83,19 +84,8 @@ - - - - - - - - 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/TimeFreeze/packages.config b/GeneralMods/TimeFreeze/packages.config deleted file mode 100644 index af793ad3..00000000 --- a/GeneralMods/TimeFreeze/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/GeneralMods/Vocalization/Vocalization/Vocalization.csproj b/GeneralMods/Vocalization/Vocalization/Vocalization.csproj index 7b2dee44..5cfcc5a3 100644 --- a/GeneralMods/Vocalization/Vocalization/Vocalization.csproj +++ b/GeneralMods/Vocalization/Vocalization/Vocalization.csproj @@ -11,8 +11,6 @@ Vocalization v4.6.1 512 - - true @@ -31,6 +29,9 @@ prompt 4 + + + ..\..\..\..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Stardew Valley\Netcode.dll @@ -61,7 +62,6 @@ - @@ -83,17 +83,5 @@ Always - - - - - - - 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/Vocalization/Vocalization/packages.config b/GeneralMods/Vocalization/Vocalization/packages.config deleted file mode 100644 index 84563214..00000000 --- a/GeneralMods/Vocalization/Vocalization/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file From 713f7d0381c9ac40e39a098db34f6ffb3049aff3 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sat, 29 Dec 2018 22:25:25 -0500 Subject: [PATCH 24/72] fix hardcoded assembly paths --- GeneralMods/FarmersMarketStall/FarmersMarketStall.csproj | 9 ++++++--- GeneralMods/Revitalize/Revitalize.csproj | 2 +- .../StardewSymphonyRemastered.csproj | 9 ++++++--- GeneralMods/StardustCore/StardustCore.csproj | 2 +- GeneralMods/SundropMapEvents/SundropMapEvents.csproj | 9 ++++++--- .../Vocalization/Vocalization/Vocalization.csproj | 9 +++++---- 6 files changed, 25 insertions(+), 15 deletions(-) diff --git a/GeneralMods/FarmersMarketStall/FarmersMarketStall.csproj b/GeneralMods/FarmersMarketStall/FarmersMarketStall.csproj index 74b88d6b..84e57097 100644 --- a/GeneralMods/FarmersMarketStall/FarmersMarketStall.csproj +++ b/GeneralMods/FarmersMarketStall/FarmersMarketStall.csproj @@ -69,9 +69,6 @@ - - ..\MapEvents\bin\Release\EventSystem.dll - @@ -88,5 +85,11 @@ + + + {bb737337-2d82-4245-aa46-f3b82fc6f228} + EventSystem + + \ No newline at end of file diff --git a/GeneralMods/Revitalize/Revitalize.csproj b/GeneralMods/Revitalize/Revitalize.csproj index 846ea608..8fa04685 100644 --- a/GeneralMods/Revitalize/Revitalize.csproj +++ b/GeneralMods/Revitalize/Revitalize.csproj @@ -34,7 +34,7 @@ - ..\..\..\..\..\..\..\Desktop\New folder (2)\PyTK.dll + $(GamePath)\Mods\PyTK\PyTK.dll diff --git a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/StardewSymphonyRemastered.csproj b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/StardewSymphonyRemastered.csproj index 8cfa1ac1..defd3816 100644 --- a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/StardewSymphonyRemastered.csproj +++ b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/StardewSymphonyRemastered.csproj @@ -72,9 +72,6 @@ ..\..\..\..\..\..\..\..\Desktop\NAudio.dll - - ..\..\StardustCore\bin\Release\StardustCore.dll - @@ -238,6 +235,12 @@ + + + {0756d36a-95c8-480d-8ea6-4584c03010c6} + StardustCore + + \ No newline at end of file diff --git a/GeneralMods/StardustCore/StardustCore.csproj b/GeneralMods/StardustCore/StardustCore.csproj index 12bbe40b..5a69ed44 100644 --- a/GeneralMods/StardustCore/StardustCore.csproj +++ b/GeneralMods/StardustCore/StardustCore.csproj @@ -74,7 +74,7 @@ False - ..\..\..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Stardew Valley\Lidgren.Network.dll + $(GamePath)\Lidgren.Network.dll diff --git a/GeneralMods/SundropMapEvents/SundropMapEvents.csproj b/GeneralMods/SundropMapEvents/SundropMapEvents.csproj index 84e1bd96..b4d5cb95 100644 --- a/GeneralMods/SundropMapEvents/SundropMapEvents.csproj +++ b/GeneralMods/SundropMapEvents/SundropMapEvents.csproj @@ -70,9 +70,6 @@ - - ..\MapEvents\bin\Release\EventSystem.dll - @@ -86,5 +83,11 @@ + + + {bb737337-2d82-4245-aa46-f3b82fc6f228} + EventSystem + + \ No newline at end of file diff --git a/GeneralMods/Vocalization/Vocalization/Vocalization.csproj b/GeneralMods/Vocalization/Vocalization/Vocalization.csproj index 5cfcc5a3..e5c520a0 100644 --- a/GeneralMods/Vocalization/Vocalization/Vocalization.csproj +++ b/GeneralMods/Vocalization/Vocalization/Vocalization.csproj @@ -34,10 +34,7 @@ - ..\..\..\..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Stardew Valley\Netcode.dll - - - ..\..\SimpleSoundManager\bin\Release\SimpleSoundManager.dll + $(GamePath)\Netcode.dll @@ -64,6 +61,10 @@ + + {7b1e9a54-ed9e-47aa-bbaa-98a6e7cb527a} + SimpleSoundManager + {0756D36A-95C8-480D-8EA6-4584C03010C6} StardustCore From 90203315aa238e8b49f3624a733346fe81805103 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sun, 30 Dec 2018 00:01:20 -0500 Subject: [PATCH 25/72] remove unused serialisation & networking code per discussion --- GeneralMods/SaveAnywhere/SaveAnywhere.cs | 6 - .../StardustCore/Interfaces/ISerializeable.cs | 27 - .../Interfaces/IToolSerializer.cs | 15 - GeneralMods/StardustCore/ModCore.cs | 388 +---- GeneralMods/StardustCore/ModInfo/Metadata.cs | 270 ---- .../NetCode/Graphics/NetAnimation.cs | 65 - .../NetCode/Graphics/NetAnimationManager.cs | 143 -- .../NetCode/MultiplayerSupport.cs | 15 - .../NetCode/NetBufferReadStream.cs | 99 -- .../NetCode/NetBufferWriteStream.cs | 97 -- .../StardustCore/NetCode/NetKeyValuePair.cs | 30 - .../NetPairs/NetVector2MultiTilePair.cs | 36 - .../NetCode/NetTexure2DExtended.cs | 84 - .../NetCode/Objects/NetCoreObject.cs | 160 -- .../NetCode/Objects/NetMultiTileComponent.cs | 116 -- .../NetCode/Objects/NetMultiTileObject.cs | 81 - .../StardustCore/Objects/CoreObject.cs | 1354 ----------------- .../Objects/MultiTileComponent.cs | 244 --- .../StardustCore/Objects/MultiTileObject.cs | 247 --- .../Objects/Tools/BasicToolInfo.cs | 40 - .../StardustCore/Objects/Tools/ExtendedAxe.cs | 142 -- .../StardustCore/Objects/Tools/ExtendedHoe.cs | 142 -- .../Objects/Tools/ExtendedPickaxe.cs | 142 -- .../Objects/Tools/ExtendedWateringCan.cs | 156 -- .../Serialization_ExtendedAxe.cs | 43 - .../Serialization_ExtendedHoe.cs | 43 - .../Serialization_ExtendedPickaxe.cs | 42 - .../Serialization_ExtendedWateringCan.cs | 46 - .../SerializedObjectBase.cs | 29 - .../Serialization/Serialization.cs | 971 ------------ .../Serialization/SerializerDataNode.cs | 73 - GeneralMods/StardustCore/StardustCore.csproj | 30 - GeneralMods/StardustCore/Utilities.cs | 673 -------- 33 files changed, 9 insertions(+), 6040 deletions(-) delete mode 100644 GeneralMods/StardustCore/Interfaces/ISerializeable.cs delete mode 100644 GeneralMods/StardustCore/Interfaces/IToolSerializer.cs delete mode 100644 GeneralMods/StardustCore/ModInfo/Metadata.cs delete mode 100644 GeneralMods/StardustCore/NetCode/Graphics/NetAnimation.cs delete mode 100644 GeneralMods/StardustCore/NetCode/Graphics/NetAnimationManager.cs delete mode 100644 GeneralMods/StardustCore/NetCode/MultiplayerSupport.cs delete mode 100644 GeneralMods/StardustCore/NetCode/NetBufferReadStream.cs delete mode 100644 GeneralMods/StardustCore/NetCode/NetBufferWriteStream.cs delete mode 100644 GeneralMods/StardustCore/NetCode/NetKeyValuePair.cs delete mode 100644 GeneralMods/StardustCore/NetCode/NetPairs/NetVector2MultiTilePair.cs delete mode 100644 GeneralMods/StardustCore/NetCode/NetTexure2DExtended.cs delete mode 100644 GeneralMods/StardustCore/NetCode/Objects/NetCoreObject.cs delete mode 100644 GeneralMods/StardustCore/NetCode/Objects/NetMultiTileComponent.cs delete mode 100644 GeneralMods/StardustCore/NetCode/Objects/NetMultiTileObject.cs delete mode 100644 GeneralMods/StardustCore/Objects/CoreObject.cs delete mode 100644 GeneralMods/StardustCore/Objects/MultiTileComponent.cs delete mode 100644 GeneralMods/StardustCore/Objects/MultiTileObject.cs delete mode 100644 GeneralMods/StardustCore/Objects/Tools/BasicToolInfo.cs delete mode 100644 GeneralMods/StardustCore/Objects/Tools/ExtendedAxe.cs delete mode 100644 GeneralMods/StardustCore/Objects/Tools/ExtendedHoe.cs delete mode 100644 GeneralMods/StardustCore/Objects/Tools/ExtendedPickaxe.cs delete mode 100644 GeneralMods/StardustCore/Objects/Tools/ExtendedWateringCan.cs delete mode 100644 GeneralMods/StardustCore/Objects/Tools/SerializationInformation/Serialization_ExtendedAxe.cs delete mode 100644 GeneralMods/StardustCore/Objects/Tools/SerializationInformation/Serialization_ExtendedHoe.cs delete mode 100644 GeneralMods/StardustCore/Objects/Tools/SerializationInformation/Serialization_ExtendedPickaxe.cs delete mode 100644 GeneralMods/StardustCore/Objects/Tools/SerializationInformation/Serialization_ExtendedWateringCan.cs delete mode 100644 GeneralMods/StardustCore/Objects/Tools/SerializationInformation/SerializedObjectBase.cs delete mode 100644 GeneralMods/StardustCore/Serialization/Serialization.cs delete mode 100644 GeneralMods/StardustCore/Serialization/SerializerDataNode.cs delete mode 100644 GeneralMods/StardustCore/Utilities.cs diff --git a/GeneralMods/SaveAnywhere/SaveAnywhere.cs b/GeneralMods/SaveAnywhere/SaveAnywhere.cs index ee824935..698ffdcb 100644 --- a/GeneralMods/SaveAnywhere/SaveAnywhere.cs +++ b/GeneralMods/SaveAnywhere/SaveAnywhere.cs @@ -67,12 +67,6 @@ namespace Omegasis.SaveAnywhere customMenuOpen = false; } - /*Notes. Mods that want to support save anywhere will get the api for Save anywhere and then add their clean up code to the events that happen for Before/After Save and Loading. - Example with pseudo code. - SaveAnywhere.api.BeforeSave+=StardustCore.Objects.CleanUpBeforeSave; - We then can use function wrapping (is that what it's called?) to just handle calling the actual function that deals with clean-up code. - - */ /********* ** Private methods *********/ diff --git a/GeneralMods/StardustCore/Interfaces/ISerializeable.cs b/GeneralMods/StardustCore/Interfaces/ISerializeable.cs deleted file mode 100644 index 35c7292e..00000000 --- a/GeneralMods/StardustCore/Interfaces/ISerializeable.cs +++ /dev/null @@ -1,27 +0,0 @@ -using StardewValley; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace StardustCore.Interfaces -{ - /// - /// Used to extend custom serialization to a variety of items. - /// - public interface IItemSerializeable - { - /// - /// Gets the type of object I am trying to parse. - /// - /// - Type getCustomType(); - - /// - /// Returns the serialization name of the object I am serializing. - /// - /// - string GetSerializationName(); - } -} diff --git a/GeneralMods/StardustCore/Interfaces/IToolSerializer.cs b/GeneralMods/StardustCore/Interfaces/IToolSerializer.cs deleted file mode 100644 index c633679e..00000000 --- a/GeneralMods/StardustCore/Interfaces/IToolSerializer.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace StardustCore.Interfaces -{ - /// - /// Used to mark items that are valid tools so we can do things like if(Item is IToolSerializer) - /// - interface IToolSerializer - { - } -} diff --git a/GeneralMods/StardustCore/ModCore.cs b/GeneralMods/StardustCore/ModCore.cs index 0ae51a73..165ccd1b 100644 --- a/GeneralMods/StardustCore/ModCore.cs +++ b/GeneralMods/StardustCore/ModCore.cs @@ -1,78 +1,28 @@ -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Input; +using System.Collections.Generic; +using System.IO; using StardewModdingAPI; -using StardewValley; -using StardewValley.Menus; -using StardewValley.Network; -using StardustCore.Menus; -using StardustCore.ModInfo; -using StardustCore.NetCode; -using StardustCore.Objects; -using StardustCore.Objects.Tools; -using StardustCore.Serialization; using StardustCore.UIUtilities; using StardustCore.UIUtilities.SpriteFonts; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; -using System.Xml; -using System.Xml.Serialization; namespace StardustCore { - /* - *Known issues: - * Clients have a error on Serialization that says they run across unknown XML elements such as core objects. However, inventories for farmhands and modded objects still get serialized properly. - * Inventories get wiped after being returned home from a festival. - */ - - public class ModCore : Mod { public static IModHelper ModHelper; public static IMonitor ModMonitor; public static IManifest Manifest; - public static Serialization.SerializationManager SerializationManager; - public static UIUtilities.TextureManager TextureManager; + public static TextureManager TextureManager; public static Dictionary TextureManagers; - private Type lastMenuType; - public ModConfig config; - public bool playerJustDisconnected; - - public bool justWarped; - public static string ContentDirectory; public override void Entry(IModHelper helper) { - ModHelper = Helper; - ModMonitor = Monitor; - Manifest = ModManifest; - //Unused MetaData information. Works in player inventory but not in chests. Besides who really care where an object is from anyways. Also doesn't work 100% like I intended since it only gets base mod object that this runs from, not extensions? - - // StardewModdingAPI.Events.GraphicsEvents.OnPostRenderGuiEvent += Metadata.GameEvents_UpdateTick; - //StardewModdingAPI.Events.ControlEvents.MouseChanged += ControlEvents_MouseChanged; - - - StardewModdingAPI.Events.SaveEvents.AfterSave += SaveEvents_AfterSave; - StardewModdingAPI.Events.SaveEvents.BeforeSave += SaveEvents_BeforeSave; - StardewModdingAPI.Events.SaveEvents.AfterLoad += SaveEvents_AfterLoad; - StardewModdingAPI.Events.MenuEvents.MenuChanged += MenuEvents_MenuChanged; - StardewModdingAPI.Events.MenuEvents.MenuClosed += MenuEvents_MenuClosed; - - ModHelper.Events.Multiplayer.PeerContextReceived += Multiplayer_PeerContextReceived; - ModHelper.Events.Multiplayer.ModMessageReceived += Multiplayer_ModMessageReceived; - ModHelper.Events.Multiplayer.PeerDisconnected += Multiplayer_PeerDisconnected; - - - playerJustDisconnected = false; + ModHelper = this.Helper; + ModMonitor = this.Monitor; + Manifest = this.ModManifest; IlluminateFramework.Colors.initializeColors(); ContentDirectory = "Content"; @@ -82,332 +32,12 @@ namespace StardustCore TextureManagers = new Dictionary(); TextureManager = new TextureManager(); - TextureManager.addTexture("Test1", new Texture2DExtended(ModCore.ModHelper, Manifest,Path.Combine("Content", "Graphics", "MultiTest", "Test1.png"))); + TextureManager.addTexture("Test1", new Texture2DExtended(ModCore.ModHelper, Manifest, Path.Combine("Content", "Graphics", "MultiTest", "Test1.png"))); TextureManager.addTexture("Test2", new Texture2DExtended(ModCore.ModHelper, Manifest, Path.Combine("Content", "Graphics", "MultiTest", "Test2.png"))); TextureManager.addTexture("Test3", new Texture2DExtended(ModCore.ModHelper, Manifest, Path.Combine("Content", "Graphics", "MultiTest", "Test3.png"))); - TextureManagers.Add(ModManifest.UniqueID, TextureManager); - StardewModdingAPI.Events.ControlEvents.KeyPressed += ControlEvents_KeyPressed; + TextureManagers.Add(this.ModManifest.UniqueID, TextureManager); - ModHelper.Events.World.ObjectListChanged += World_ObjectListChanged; - - config = ModHelper.ReadConfig(); - - StardewModdingAPI.Events.GameEvents.UpdateTick += GameEvents_UpdateTick; - - Helper.Events.Player.Warped += Player_Warped; - - ModHelper.Events.GameLoop.ReturnedToTitle += GameLoop_ReturnedToTitle; - - } - - private void World_ObjectListChanged(object sender, StardewModdingAPI.Events.ObjectListChangedEventArgs e) - { - if (e.Added != null) - { - - } - else if (e.Removed != null) - { - - } - } - - private void Player_Warped(object sender, StardewModdingAPI.Events.WarpedEventArgs e) - { - if (justWarped) return; - SerializationManager.cleanUpInventory(); - //SerializationManager.cleanUpWorld(); - //SerializationManager.cleanUpStorageContainers(); - justWarped = true; - } - - - private void GameLoop_ReturnedToTitle(object sender, StardewModdingAPI.Events.ReturnedToTitleEventArgs e) - { - if (Game1.player != null) - { - SerializationManager.cleanUpInventory(); - //SerializationManager.cleanUpWorld(); - //SerializationManager.cleanUpStorageContainers(); - //Monitor.Log("Saved the player data after returning to title!"); - } - } - - private void Multiplayer_PeerDisconnected(object sender, StardewModdingAPI.Events.PeerDisconnectedEventArgs e) - { - this.playerJustDisconnected = true; - - //ModMonitor.Log("Peer disconnected! Serializing custom objects"); - - SerializationManager.cleanUpInventory(); - //SerializationManager.cleanUpWorld(); - //SerializationManager.cleanUpStorageContainers(); - - } - - private void Multiplayer_ModMessageReceived(object sender, StardewModdingAPI.Events.ModMessageReceivedEventArgs e) - { - //ModMonitor.Log("Get messages from"+e.FromModID); - //ModMonitor.Log("Message type: " + e.Type); - - if (e.FromModID == this.ModManifest.UniqueID) - { - if (e.Type == MultiplayerSupport.CleanUpModObjects) - { - SerializationManager.cleanUpInventory(); - SerializationManager.cleanUpWorld(); - SerializationManager.cleanUpStorageContainers(); - } - else if (e.Type == MultiplayerSupport.RestoreModObjects) - { - if (Game1.eventUp) return; //Prevent item duplication. - //ModMonitor.Log("Restoring custom objects."); - SerializationManager.restoreAllModObjects(SerializationManager.trackedObjectList); - } - } - } - - private void Multiplayer_PeerContextReceived(object sender, StardewModdingAPI.Events.PeerContextReceivedEventArgs e) - { - - if (SerializationManager == null) return; - - - if (Game1.eventUp) - { - SerializationManager.restoreAllModObjects(SerializationManager.trackedObjectList); //Force a restore and then a serialize save to prevent deletions. - } - //ModMonitor.Log("Got peer context. Serialize/remove all custom objects really quick to prevent loading errors."); - - - SerializationManager.cleanUpInventory(); - //SerializationManager.cleanUpWorld(); - //SerializationManager.cleanUpStorageContainers(); - - - } - - private void MenuEvents_MenuClosed(object sender, StardewModdingAPI.Events.EventArgsClickableMenuClosed e) - { - if (this.lastMenuType == null) - { - return; - } - else - { - /* - if (lastMenuType == typeof(StardewValley.Menus.SaveGameMenu) ||lastMenuType==typeof(StardewValley.Menus.ShippingMenu)) - { - SerializationManager.restoreAllModObjects(SerializationManager.trackedObjectList); - - List playerIds = new List(); - foreach (Farmer f in Game1.getAllFarmers()) - { - if (f == Game1.player) continue; - playerIds.Add(f.uniqueMultiplayerID); - - } - ModHelper.Multiplayer.SendMessage(MultiplayerSupport.RestoreModObjects, MultiplayerSupport.RestoreModObjects, new string[] { ModManifest.UniqueID }, playerIds.ToArray()); - } - */ - //Only fires in multiplayer since ReadyCheckDialogue only appears in multiplayer - if (lastMenuType == typeof(StardewValley.Menus.ReadyCheckDialog) && Game1.player.canMove==false && Game1.player.isInBed) - { - //ModMonitor.Log("Time to sleep/serialize all objects!"); - SerializationManager.cleanUpInventory(); - SerializationManager.cleanUpWorld(); - SerializationManager.cleanUpStorageContainers(); - - /* - List playerIds = new List(); - foreach (Farmer f in Game1.getAllFarmers()) - { - if (f == null) continue; - if (f == Game1.player) continue; - playerIds.Add(f.uniqueMultiplayerID); - - } - */ - //ModHelper.Multiplayer.SendMessage(MultiplayerSupport.CleanUpModObjects, MultiplayerSupport.CleanUpModObjects, new string[] { ModManifest.UniqueID }, playerIds.ToArray()); - - } - } - } - - private void MenuEvents_MenuChanged(object sender, StardewModdingAPI.Events.EventArgsClickableMenuChanged e) - { - lastMenuType = Game1.activeClickableMenu.GetType(); - } - - /// - /// Returns the value of the data snagged by reflection. - /// - /// - /// - /// - /// - public static object GetInstanceField(Type type, object instance, string fieldName) - { - BindingFlags bindFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static; - FieldInfo field = type.GetField(fieldName, bindFlags); - /* - FieldInfo[] meh = type.GetFields(bindFlags); - foreach(var v in meh) - { - if (v.Name == null) - { - continue; - } - Monitor.Log(v.Name); - } - */ - return field.GetValue(instance); - } - - public static void SetInstanceField(Type type, object instance, object value, string fieldName) - { - BindingFlags bindFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic - | BindingFlags.Static; - FieldInfo field = type.GetField(fieldName, bindFlags); - field.SetValue(instance, value); - return; - } - - private void GameEvents_UpdateTick(object sender, EventArgs e) - { - if (playerJustDisconnected) - { - playerJustDisconnected = false; - if (Game1.activeClickableMenu != null) - { - if (Game1.activeClickableMenu.GetType() == typeof(StardewValley.Menus.TitleMenu)) return; - } - //ModMonitor.Log("Restore objects after peer disconnect!"); - SerializationManager.restoreAllModObjects(SerializationManager.trackedObjectList); - } - else if (justWarped && Game1.eventUp==false && Game1.activeClickableMenu==null) - { - justWarped = false; - //ModMonitor.Log("Restore objects after player warping!"); - SerializationManager.restoreAllModObjects(SerializationManager.trackedObjectList,true); - } - } - - private void ControlEvents_KeyPressed(object sender, StardewModdingAPI.Events.EventArgsKeyPressed e) - { - if(e.KeyPressed.ToString()== config.modularMenuKey && Game1.activeClickableMenu==null) - { - //Game1.activeClickableMenu = new ModularGameMenu(0); - } - } - - private void SaveEvents_AfterLoad(object sender, EventArgs e) - { - Game1.game1.Disposed += Game1_Disposed; - - string basePath=Path.Combine( ModCore.ModHelper.DirectoryPath, "PlayerData", Game1.player.Name + "_" + Game1.player.uniqueMultiplayerID); - - string invPath = Path.Combine(basePath,"PlayerInventory"); - string worldPath = Path.Combine(basePath, "ObjectsInWorld"); - string trashPath = Path.Combine(basePath,"ModTrashFolder"); - string chestPath = Path.Combine(basePath, "StorageContainers"); - SerializationManager = new SerializationManager(invPath, trashPath, worldPath, chestPath); - SerializationManager.initializeDefaultSuportedTypes(); - - SerializationManager.restoreAllModObjects(SerializationManager.trackedObjectList); - - List playerIds = new List(); - foreach (Farmer f in Game1.getOnlineFarmers()) - { - if (f.uniqueMultiplayerID == Game1.player.uniqueMultiplayerID) continue; - playerIds.Add(f.uniqueMultiplayerID); - ModMonitor.Log("Sending Message to peer ID: "+f.uniqueMultiplayerID.ToString()); - } - //ModMonitor.Log("Send message to restore mod objects after load!"); - ModHelper.Multiplayer.SendMessage(MultiplayerSupport.RestoreModObjects, MultiplayerSupport.RestoreModObjects, new string[] { ModManifest.UniqueID },playerIds.ToArray()); - /* - List> objs = new List>(); - - MultiTileComponent tile1 = new MultiTileComponent(0,"Tileobj1","A basic tile obj",new Texture2DExtended(ModCore.ModHelper,ModCore.Manifest ,Path.Combine("Content", "Graphics", "MultiTest", "Test1.png"))); - MultiTileComponent tile2 = new MultiTileComponent(0,"Tileobj2", "A basic tile obj", new Texture2DExtended(ModCore.ModHelper, ModCore.Manifest, Path.Combine("Content", "Graphics", "MultiTest", "Test2.png"))); - MultiTileComponent tile3 = new MultiTileComponent(0,"Tileobj3", "A basic tile obj", new Texture2DExtended(ModCore.ModHelper, ModCore.Manifest, Path.Combine("Content", "Graphics", "MultiTest", "Test3.png"))); - objs.Add(new KeyValuePair(new Vector2(0, 0), tile1)); - objs.Add(new KeyValuePair(new Vector2(1, 0), tile2)); - objs.Add(new KeyValuePair(new Vector2(2, 0), tile3)); - - MultiTileObject collection= new MultiTileObject("MultiTest", "Trying to get multi object testing working", Vector2.Zero, new Texture2DExtended(ModCore.ModHelper, ModCore.Manifest, Path.Combine("Content", "Graphics", "MultiTest", "Test3.png")), objs, StardustCore.IlluminateFramework.Colors.invertColor(StardustCore.IlluminateFramework.LightColorsList.Purple), "MultiTest"); - - - Game1.player.addItemToInventory(collection); - */ - - /* - CoreObject testTile = new CoreObject(new Texture2DExtended(ModCore.ModHelper,ModCore.Manifest, Path.Combine("Content", "Graphics", "MultiTest", "Test3.png")),3, Vector2.Zero,9); - - testTile.description = "Hello"; - testTile.Name = "test"; - testTile.displayName = "test"; - Game1.player.addItemToInventory(testTile); - */ - - } - - private void Game1_Disposed(object sender, EventArgs e) - { - if (Game1.player != null && lastMenuType!= typeof(StardewValley.Menus.TitleMenu)) - { - //ModMonitor.Log("Serialize all objects on disposing!"); - SerializationManager.cleanUpInventory(); - //SerializationManager.cleanUpWorld(); - //SerializationManager.cleanUpStorageContainers(); - } - } - - private void SaveEvents_AfterSave(object sender, EventArgs e) - { - - SerializationManager.restoreAllModObjects(SerializationManager.trackedObjectList); - - } - - private void SaveEvents_BeforeSave(object sender, EventArgs e) - { - //Call the serialization if alone since the ReadyCheckDialogue menu never shows with just 1 player online. - if (Game1.IsMultiplayer == false || (Game1.IsMultiplayer && Game1.getOnlineFarmers().Count==1)) - { - //ModMonitor.Log("Serialize all objects before save when only 1 farmer present!"); - SerializationManager.cleanUpInventory(); - SerializationManager.cleanUpWorld(); - SerializationManager.cleanUpStorageContainers(); - } - - - } - - private void ControlEvents_MouseChanged(object sender, StardewModdingAPI.Events.EventArgsMouseStateChanged e) - { - //??? - return; - if (Game1.activeClickableMenu == null) return; - var MouseState = Mouse.GetState(); - if (Game1.activeClickableMenu is StardewValley.Menus.ItemGrabMenu && MouseState.LeftButton == ButtonState.Released) - { - (Game1.activeClickableMenu as StardewValley.Menus.ItemGrabMenu).ItemsToGrabMenu.populateClickableComponentList(); - for (int index = 0; index < (Game1.activeClickableMenu as StardewValley.Menus.ItemGrabMenu).ItemsToGrabMenu.inventory.Count; ++index) - { - if ((Game1.activeClickableMenu as StardewValley.Menus.ItemGrabMenu).ItemsToGrabMenu.inventory[index] != null) - { - (Game1.activeClickableMenu as StardewValley.Menus.ItemGrabMenu).ItemsToGrabMenu.inventory[index].myID += 53910; - (Game1.activeClickableMenu as StardewValley.Menus.ItemGrabMenu).ItemsToGrabMenu.inventory[index].upNeighborID += 53910; - (Game1.activeClickableMenu as StardewValley.Menus.ItemGrabMenu).ItemsToGrabMenu.inventory[index].rightNeighborID += 53910; - (Game1.activeClickableMenu as StardewValley.Menus.ItemGrabMenu).ItemsToGrabMenu.inventory[index].downNeighborID = -7777; - (Game1.activeClickableMenu as StardewValley.Menus.ItemGrabMenu).ItemsToGrabMenu.inventory[index].leftNeighborID += 53910; - (Game1.activeClickableMenu as StardewValley.Menus.ItemGrabMenu).ItemsToGrabMenu.inventory[index].fullyImmutable = true; - } - } - // (Game1.activeClickableMenu as ItemGrabMenu).inventory.playerInventory = false; - // Game1.activeClickableMenu =Game1.activeClickableMenu;//new ItemGrabMenu((Game1.activeClickableMenu as ItemGrabMenu).ItemsToGrabMenu.actualInventory,true,true,null,null,null,null,false,false,true,true,true,1,null,-1,null); - } + this.config = ModHelper.ReadConfig(); } } } diff --git a/GeneralMods/StardustCore/ModInfo/Metadata.cs b/GeneralMods/StardustCore/ModInfo/Metadata.cs deleted file mode 100644 index 9f1ccbf5..00000000 --- a/GeneralMods/StardustCore/ModInfo/Metadata.cs +++ /dev/null @@ -1,270 +0,0 @@ -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using StardewModdingAPI; -using StardewValley; -using StardewValley.Menus; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; - -namespace StardustCore.ModInfo -{ - /// - /// Handles things like displaying object class types. - /// - public class Metadata - { - Color ModInfoColor; - string ModName; - - - /// - /// - /// - /// - /// - private Metadata(Color ? modColor,string modName="") - { - if (modColor == null) ModInfoColor = Color.Black; - else ModInfoColor =(Color) modColor; - ModName = modName; - } - - /// - /// Parse the name of the mod that this object is from from the Namespace type. - /// - /// - /// - public static string parseModNameFromType(Type t) - { - string s = t.ToString(); - string[] array = s.Split('.'); - return array[0]; - } - - /// - /// Parse the class inside of the mod's namespace that this object is from. - /// - /// - /// - public static string parseClassNameFromType(Type t) - { - string s = t.ToString(); - string[] array = s.Split('.'); - return array[array.Length-1]; - } - - /// - /// TODO: Add the ModClass item check to chest inventory. See if I can grab activeclickable menu and instead hook the inventory component from it. - /// - /// - /// - public static void GameEvents_UpdateTick(object sender, EventArgs e) - { - if (Game1.activeClickableMenu != null) - { - // if (Game1.activeClickableMenu.allClickableComponents == null) return; - try { - List pages = ModCore.ModHelper.Reflection.GetField>(Game1.activeClickableMenu, "pages").GetValue(); - if (Game1.activeClickableMenu is GameMenu) - { - StardewValley.Menus.IClickableMenu s = pages[(Game1.activeClickableMenu as GameMenu).currentTab]; - - - - foreach (var v in s.allClickableComponents) - { - if (v.containsPoint(Game1.getMouseX(), Game1.getMouseY())) - { - - if (v == null) continue; - string fire = v.name; - - - bool num = true; - foreach (var v2 in fire) - { - if (v2 != '0' && v2 != '1' && v2 != '2' && v2 != '3' && v2 != '4' && v2 != '5' && v2 != '6' && v2 != '7' && v2 != '8' && v2 != '9') - { - num = false; - break; - } - else continue; - } - if (num == true) - { - int inv = Convert.ToInt32(v.name); - Item I = (s as StardewValley.Menus.InventoryPage).inventory.actualInventory[inv]; - - string s1 = parseModNameFromType(I.GetType()); - string s2 = parseClassNameFromType(I.GetType()); - string s3 = Assembly.GetAssembly(I.GetType()).Location; - s3 = Path.GetFileName(s3); - - - //DRAW THE INFO BOX!!! - try - { - SpriteBatch b = new SpriteBatch(Game1.graphics.GraphicsDevice); - b.Begin(); - float boxX =Game1.getMouseX()- (Game1.viewport.Width * .25f); - float boxY =Game1.getMouseY() - (Game1.viewport.Height * .05f); - float boxWidth= (Game1.viewport.Width * .25f); - float boxHeight = (Game1.viewport.Height*.35f); - Game1.drawDialogueBox((int)boxX,(int) boxY,(int)boxWidth, (int)boxHeight, false, true, null,false); - - float xText1XPos = boxX + (Game1.viewport.Width * .08f); - float xText2XPos = boxX + (Game1.viewport.Width * .08f); - if (s1.Length > 12) - { - s1 = "\n" + s1; - xText1XPos = boxX + (Game1.viewport.Width * .025f); - } - - if (s2.Length > 12) - { - s2 = "\n" + s2; - xText2XPos = boxX + (Game1.viewport.Width * .025f); - } - if (s3.Length > 12) - { - s3 = "\n" + s3; - xText1XPos = boxX + (Game1.viewport.Width * .025f); - } - - Utility.drawTextWithShadow(Game1.spriteBatch, "Mod: ", Game1.smallFont, new Vector2(boxX + (Game1.viewport.Width * .025f), Game1.getMouseY() + (int)(Game1.viewport.Height * .1f)), Color.Black, 1, -1); - Utility.drawTextWithShadow(Game1.spriteBatch, s3, Game1.smallFont, new Vector2(xText1XPos, Game1.getMouseY()+(int)(Game1.viewport.Height*.1f)), Color.Black, 1, -1); - - Utility.drawTextWithShadow(Game1.spriteBatch, "Class: ", Game1.smallFont, new Vector2(boxX + (Game1.viewport.Width * .025f), Game1.getMouseY() + (int)(Game1.viewport.Height * .2f)), Color.Black, 1, -1); - Utility.drawTextWithShadow(Game1.spriteBatch, s2, Game1.smallFont, new Vector2(xText2XPos, Game1.getMouseY() + (int)(Game1.viewport.Height * .2f)), I.getCategoryColor(), 1, -1); - b.End(); - } - catch(Exception errr) - { - errr.ToString(); - } - - } - } - // if (v == null) continue; - // Log.AsyncC(v.name); - // Log.AsyncM(v.item.Name); - // (s as StardewValley.Menus.InventoryPage). - } - } - } - catch(Exception err) //Try to parse a menu that isn't the default GameMenu - { - err.ToString(); - try - { - List inventory = (List)Game1.activeClickableMenu.GetType().GetProperty("inventory").GetValue(Game1.activeClickableMenu, null); - } - catch(Exception errr) - { - errr.ToString(); - try - { - - IClickableMenu s = (Game1.activeClickableMenu as ItemGrabMenu).ItemsToGrabMenu; - if (s == null) return; - int i = 0; - foreach (var v in s.allClickableComponents) - { - i++; - if (v.containsPoint(Game1.getMouseX(), Game1.getMouseY())) - { - - if (v == null || v.name=="") continue; - string fire = v.name; - - bool num = true; - foreach (var v2 in fire) - { - if (v2 != '0' && v2 != '1' && v2 != '2' && v2 != '3' && v2 != '4' && v2 != '5' && v2 != '6' && v2 != '7' && v2 != '8' && v2 != '9') - { - num = false; - break; - } - else continue; - } - - ///NUM ISN't TRUE!?!?!?!? - if (num == true) - { - int inv = Convert.ToInt32(v.name); - Item I = (s as InventoryMenu).actualInventory[inv]; //Inventory Menu is the actual menu under ItemGrabMenu - // Item I = (s as StardewValley.Menus.ItemGrabMenu).inventory.actualInventory[inv]; ///I isn't being grabbed??? - - string s1 = parseModNameFromType(I.GetType()); - string s2 = parseClassNameFromType(I.GetType()); - string s3 = Assembly.GetAssembly(I.GetType()).Location; - s3 = Path.GetFileName(s3); - - //Draw the info Box! - try - { - - float boxX = Game1.getMouseX() - (Game1.viewport.Width * .25f); - float boxY = Game1.getMouseY() - (Game1.viewport.Height * .05f); - float boxWidth = (Game1.viewport.Width * .25f); - float boxHeight = (Game1.viewport.Height * .35f); - Game1.drawDialogueBox((int)boxX, (int)boxY, (int)boxWidth, (int)boxHeight, false, true, null, false); - - float xText1XPos = boxX + (Game1.viewport.Width * .08f); - float xText2XPos = boxX + (Game1.viewport.Width * .08f); - if (s1.Length > 12) - { - s1 = "\n" + s1; - xText1XPos = boxX + (Game1.viewport.Width * .025f); - } - - if (s2.Length > 12) - { - s2 = "\n" + s2; - xText2XPos = boxX + (Game1.viewport.Width * .025f); - } - if (s3.Length > 12) - { - s3 = "\n" + s3; - xText1XPos = boxX + (Game1.viewport.Width * .025f); - } - - Utility.drawTextWithShadow(Game1.spriteBatch, "Mod: ", Game1.smallFont, new Vector2(boxX + (Game1.viewport.Width * .025f), Game1.getMouseY() + (int)(Game1.viewport.Height * .1f)), Color.Black, 1, -1); - Utility.drawTextWithShadow(Game1.spriteBatch, s3, Game1.smallFont, new Vector2(xText1XPos, Game1.getMouseY() + (int)(Game1.viewport.Height * .1f)), Color.Black, 1, -1); - - Utility.drawTextWithShadow(Game1.spriteBatch, "Class: ", Game1.smallFont, new Vector2(boxX + (Game1.viewport.Width * .025f), Game1.getMouseY() + (int)(Game1.viewport.Height * .2f)), Color.Black, 1, -1); - Utility.drawTextWithShadow(Game1.spriteBatch, s2, Game1.smallFont, new Vector2(xText2XPos, Game1.getMouseY() + (int)(Game1.viewport.Height * .2f)), I.getCategoryColor(), 1, -1); - - } - catch (Exception errrr) - { - errrr.ToString(); - } - - } - } - // if (v == null) continue; - // Log.AsyncC(v.name); - // Log.AsyncM(v.item.Name); - // (s as StardewValley.Menus.InventoryPage). - - - } - } - catch(Exception errrr) - { - errrr.ToString(); - } - } - } - } - - } - - } -} diff --git a/GeneralMods/StardustCore/NetCode/Graphics/NetAnimation.cs b/GeneralMods/StardustCore/NetCode/Graphics/NetAnimation.cs deleted file mode 100644 index 52eb687f..00000000 --- a/GeneralMods/StardustCore/NetCode/Graphics/NetAnimation.cs +++ /dev/null @@ -1,65 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Netcode; -using StardustCore.Animations; - -namespace StardustCore.NetCode.Graphics -{ - public class NetAnimation : Netcode.NetField - { - - public NetRectangle sourceRect; - public NetInt frameDuration; - public NetInt frameDurationUntilNextAnimation; - - public NetAnimation() - { - - } - public NetAnimation(Animations.Animation animation) : base(animation) - { - this.Set(animation); - } - - public override void Set(Animation newValue) - { - this.value = newValue; - } - - protected override void ReadDelta(BinaryReader reader, NetVersion version) - { - sourceRect = new NetRectangle(); - if (sourceRect == null) throw new Exception("WTF??? Why is netfield null"); - if (reader == null) throw new Exception("reader null"); - if (value == null) this.Set(new Animation()); - sourceRect.Read(reader, version); - Value.sourceRectangle = sourceRect.Value; - - frameDuration = new NetInt(); - frameDuration.Read(reader, version); - Value.frameDuration = frameDuration.Value; - - frameDurationUntilNextAnimation = new NetInt(); - frameDurationUntilNextAnimation.Read(reader, version); - Value.frameCountUntilNextAnimation = frameDurationUntilNextAnimation.Value; - } - - protected override void WriteDelta(BinaryWriter writer) - { - - - sourceRect = new NetRectangle(Value.sourceRectangle); - sourceRect.Write(writer); - - frameDuration = new NetInt(Value.frameDuration); - frameDuration.Write(writer); - - frameDurationUntilNextAnimation = new NetInt(Value.frameCountUntilNextAnimation); - frameDurationUntilNextAnimation.Write(writer); - } - } -} diff --git a/GeneralMods/StardustCore/NetCode/Graphics/NetAnimationManager.cs b/GeneralMods/StardustCore/NetCode/Graphics/NetAnimationManager.cs deleted file mode 100644 index 964fa446..00000000 --- a/GeneralMods/StardustCore/NetCode/Graphics/NetAnimationManager.cs +++ /dev/null @@ -1,143 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Netcode; -using StardewValley; -using StardewValley.Network; -using StardustCore.Animations; - -namespace StardustCore.NetCode.Graphics -{ - public class NetAnimationManager : Netcode.NetField - { - - public NetAnimationManager() - { - - } - - public NetAnimationManager(Animations.AnimationManager manager) : base(manager) - { - this.Set(manager); - } - - public NetString currentAnimationName; - public NetInt currentAnimationListIndex; - public NetTexture2DExtended objectTexture; - public NetAnimation defaultDrawFrame; - public NetBool enabled; - public NetString animationDataString; - - protected override void ReadDelta(BinaryReader reader, NetVersion version) - { - //Checks to see if the current animation is nothing, aka null. - NetBool isNull = new NetBool(); - isNull.Read(reader, version); - bool valueIsNull = isNull.Value; - if (isNull) - { - NetTexture2DExtended nullTexture = new NetTexture2DExtended(); - nullTexture.Read(reader, version); - - NetAnimation nullAnimation = new NetAnimation(); - nullAnimation.Read(reader, version); - - Value.setExtendedTexture(nullTexture.Value); - Value.defaultDrawFrame = nullAnimation.Value; - return; - } - - - NetString currentAnimationName = new NetString(); - currentAnimationName.Read(reader, version); - - NetInt currentIndex = new NetInt(); - currentIndex.Read(reader, version); - - NetTexture2DExtended text = new NetTexture2DExtended(); - text.Read(reader, version); - - NetAnimation defaultAnimation = new NetAnimation(); - defaultAnimation.Read(reader, version); - - NetBool enabled = new NetBool(); - enabled.Read(reader, version); - - NetString data = new NetString(); - data.Read(reader, version); - - Value.setExtendedTexture(text.Value); - Value.defaultDrawFrame = defaultAnimation.Value; - Value.enabled = enabled.Value; - //Try and prevent unnecessary parsing. - if (Value.animations == null && !String.IsNullOrEmpty(Value.animationDataString)) - { - Value.animations = Animations.AnimationManager.parseAnimationsFromXNB(data.Value); - } - if (!String.IsNullOrEmpty(data.Value)) - { - Value.setAnimation(currentAnimationName.Value, currentIndex.Value); - } - else - { - Value.currentAnimation = defaultDrawFrame.Value; - } - } - - protected override void WriteDelta(BinaryWriter writer) - { - - - if (String.IsNullOrEmpty(Value.currentAnimationName)) - { - NetBool isNull = new NetBool(true); - writer.Write(isNull); - - - - NetTexture2DExtended defaultTexture = new NetTexture2DExtended(Value.getExtendedTexture()); - defaultTexture.Write(writer); - - //do read/write null values here!!! - if (Value == null) throw new Exception("DONT WRITE A NULL VALUE!!!!"); - NetAnimation drawFrame = new NetAnimation(Value.defaultDrawFrame); - drawFrame.Write(writer); - return; - //throw new Exception("Null string value for currentAnimationName!"); - } - else - { - NetBool isNull = new NetBool(false); - writer.Write(isNull); - } - NetString curentAnimationName = new NetString(!String.IsNullOrEmpty(Value.currentAnimationName) ? Value.currentAnimationName : ""); - currentAnimationName.Write(writer); - - - NetInt currentAnimationListIndex = new NetInt(Value.currentAnimationListIndex); - currentAnimationListIndex.Write(writer); - - NetTexture2DExtended texture = new NetTexture2DExtended(Value.getExtendedTexture()); - texture.Write(writer); - - //do read/write null values here!!! - NetAnimation defaultDrawFrame = new NetAnimation(Value.defaultDrawFrame); - defaultDrawFrame.Write(writer); - - NetBool enabled = new NetBool(Value.enabled); - enabled.Write(writer); - - NetString animationData = new NetString(Value.animationDataString); - animationData.Write(writer); - - } - - public override void Set(AnimationManager newValue) - { - this.value = newValue; - } - } -} diff --git a/GeneralMods/StardustCore/NetCode/MultiplayerSupport.cs b/GeneralMods/StardustCore/NetCode/MultiplayerSupport.cs deleted file mode 100644 index d6c1c464..00000000 --- a/GeneralMods/StardustCore/NetCode/MultiplayerSupport.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace StardustCore.NetCode -{ - public class MultiplayerSupport - { - public static string CleanUpModObjects = "Omegasis.StardustCore.MultiplayerSupport.CleanUpModObjects"; - public static string RestoreModObjects = "Omegasis.StardustCore.MultiplayerSupport.RestoreModObjects"; - - } -} diff --git a/GeneralMods/StardustCore/NetCode/NetBufferReadStream.cs b/GeneralMods/StardustCore/NetCode/NetBufferReadStream.cs deleted file mode 100644 index 0b24e59a..00000000 --- a/GeneralMods/StardustCore/NetCode/NetBufferReadStream.cs +++ /dev/null @@ -1,99 +0,0 @@ -using System; -using System.IO; -using Lidgren.Network; - -namespace StardustCore.NetCode -{ - public class NetBufferReadStream : Stream - { - private long offset; - public NetBuffer Buffer; - - public NetBufferReadStream(NetBuffer buffer) - { - this.Buffer = buffer; - this.offset = buffer.Position; - } - - public override bool CanRead - { - get - { - return true; - } - } - - public override bool CanSeek - { - get - { - return true; - } - } - - public override bool CanWrite - { - get - { - return false; - } - } - - public override long Length - { - get - { - return ((long)this.Buffer.LengthBits - this.offset) / 8L; - } - } - - public override long Position - { - get - { - return (this.Buffer.Position - this.offset) / 8L; - } - set - { - this.Buffer.Position = this.offset + value * 8L; - } - } - - public override void Flush() - { - } - - public override int Read(byte[] buffer, int offset, int count) - { - this.Buffer.ReadBytes(buffer, offset, count); - return count; - } - - public override long Seek(long offset, SeekOrigin origin) - { - switch (origin) - { - case SeekOrigin.Begin: - this.Position = offset; - break; - case SeekOrigin.Current: - this.Position += offset; - break; - case SeekOrigin.End: - this.Position = this.Length + offset; - break; - } - return this.Position; - } - - public override void SetLength(long value) - { - throw new NotSupportedException(); - } - - public override void Write(byte[] buffer, int offset, int count) - { - throw new NotSupportedException(); - } - } -} diff --git a/GeneralMods/StardustCore/NetCode/NetBufferWriteStream.cs b/GeneralMods/StardustCore/NetCode/NetBufferWriteStream.cs deleted file mode 100644 index e3b62d41..00000000 --- a/GeneralMods/StardustCore/NetCode/NetBufferWriteStream.cs +++ /dev/null @@ -1,97 +0,0 @@ -using System; -using System.IO; -using Lidgren.Network; - -namespace StardustCore.NetCode -{ - public class NetBufferWriteStream : Stream - { - private int offset; - public NetBuffer Buffer; - - public NetBufferWriteStream(NetBuffer buffer) - { - this.Buffer = buffer; - this.offset = buffer.LengthBits; - } - - public override bool CanRead - { - get - { - return false; - } - } - - public override bool CanSeek - { - get - { - return true; - } - } - - public override bool CanWrite - { - get - { - return true; - } - } - - public override long Length - { - get - { - throw new NotSupportedException(); - } - } - - public override long Position - { - get - { - return (long)((this.Buffer.LengthBits - this.offset) / 8); - } - set - { - this.Buffer.LengthBits = (int)((long)this.offset + value * 8L); - } - } - - public override void Flush() - { - } - - public override int Read(byte[] buffer, int offset, int count) - { - throw new NotSupportedException(); - } - - public override long Seek(long offset, SeekOrigin origin) - { - switch (origin) - { - case SeekOrigin.Begin: - this.Position = offset; - break; - case SeekOrigin.Current: - this.Position += offset; - break; - case SeekOrigin.End: - throw new NotSupportedException(); - } - return this.Position; - } - - public override void SetLength(long value) - { - throw new NotSupportedException(); - } - - public override void Write(byte[] buffer, int offset, int count) - { - this.Buffer.Write(buffer, offset, count); - } - } -} diff --git a/GeneralMods/StardustCore/NetCode/NetKeyValuePair.cs b/GeneralMods/StardustCore/NetCode/NetKeyValuePair.cs deleted file mode 100644 index afeb5082..00000000 --- a/GeneralMods/StardustCore/NetCode/NetKeyValuePair.cs +++ /dev/null @@ -1,30 +0,0 @@ -using Netcode; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace StardustCore.NetCode -{ - public class NetKeyValuePair : NetField, NetKeyValuePair> where KField : NetField, new() where VField : NetField, new() - { - public override void Set(KeyValuePair newValue) - { - this.value = newValue; - } - - protected override void ReadDelta(BinaryReader reader, NetVersion version) - { - throw new NotImplementedException(); - } - - protected override void WriteDelta(BinaryWriter writer) - { - throw new NotImplementedException(); - } - - - } -} diff --git a/GeneralMods/StardustCore/NetCode/NetPairs/NetVector2MultiTilePair.cs b/GeneralMods/StardustCore/NetCode/NetPairs/NetVector2MultiTilePair.cs deleted file mode 100644 index f719de5e..00000000 --- a/GeneralMods/StardustCore/NetCode/NetPairs/NetVector2MultiTilePair.cs +++ /dev/null @@ -1,36 +0,0 @@ -using Microsoft.Xna.Framework; -using Netcode; -using StardustCore.Objects; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace StardustCore.NetCode.NetPairs -{ - public class NetVector2MultiTilePair: NetKeyValuePair - { - - public NetVector2MultiTilePair() - { - - } - - public NetVector2MultiTilePair(KeyValuePair hello) - { - this.Set(Value); - } - - public override void Read(BinaryReader reader, NetVersion version) - { - base.Read(reader, version); - } - - public override void Write(BinaryWriter writer) - { - base.Write(writer); - } - } -} diff --git a/GeneralMods/StardustCore/NetCode/NetTexure2DExtended.cs b/GeneralMods/StardustCore/NetCode/NetTexure2DExtended.cs deleted file mode 100644 index 25cbcbeb..00000000 --- a/GeneralMods/StardustCore/NetCode/NetTexure2DExtended.cs +++ /dev/null @@ -1,84 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Netcode; -using StardewValley; -using StardustCore.UIUtilities; - -namespace StardustCore.NetCode -{ - public class NetTexture2DExtended : Netcode.NetField - { - - - - public NetTexture2DExtended() - { - - } - - public NetTexture2DExtended(Texture2DExtended value) : base(value) - { - this.Set(value); - } - - public void ReadData(BinaryReader reader, NetVersion version) - { - ReadDelta(reader, version); - } - - public override void Set(Texture2DExtended newValue) - { - this.value = newValue; - } - - public void WriteData(BinaryWriter writer) - { - WriteDelta(writer); - } - - protected override void ReadDelta(BinaryReader reader, NetVersion version) - { - NetString name = new NetString(); - name.Read(reader, version); - - NetString iD = new NetString(); - iD.Read(reader, version); - - - StardustCore.ModCore.ModMonitor.Log("Name: "+name); - StardustCore.ModCore.ModMonitor.Log("Mod ID:"+iD); - - - //Texture2D texture = new Texture2D(Game1.graphics.GraphicsDevice,width,height); - if (String.IsNullOrEmpty(iD.Value) || String.IsNullOrEmpty(name.Value)) - { - ModCore.ModMonitor.Log("FOR SOME REASON THE TEXTURE INFO IS NULL????"); - return; - } - - - Texture2DExtended texture = ModCore.TextureManagers[iD.Value].getTexture(name.Value); - if (texture == null) throw new Exception("FOR SOME REASON NULL IS BEING READ???"); - this.Value = texture; - - } - - protected override void WriteDelta(BinaryWriter writer) - { - NetString name = new NetString(Value.Name); - name.Write(writer); - - NetString iD = new NetString(Value.modID); - iD.Write(writer); - - } - - - } -} diff --git a/GeneralMods/StardustCore/NetCode/Objects/NetCoreObject.cs b/GeneralMods/StardustCore/NetCode/Objects/NetCoreObject.cs deleted file mode 100644 index 7b195950..00000000 --- a/GeneralMods/StardustCore/NetCode/Objects/NetCoreObject.cs +++ /dev/null @@ -1,160 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Runtime.Serialization.Formatters.Binary; -using System.Text; -using System.Threading.Tasks; -using Netcode; -using StardewValley; -using StardustCore.NetCode.Graphics; -using StardustCore.UIUtilities; - -namespace StardustCore.NetCode -{ - /* - * Need to send default source rect and width - * - */ - - - public class NetCoreObject : Netcode.NetField - { - - - public NetInt which; - public NetVector2 tilePos; - - - public NetRectangle boundingBox; - - - - public NetVector2 position; - public NetInt Decoration_type; - public NetInt rotations; - public NetInt currentRotation; - public NetInt sourceIndexOffset; - public NetVector2 drawPosition; - public NetRectangle sourceRect; - public NetRectangle defaultSourceRect; - public NetRectangle defaultBoundingBox; - public NetString description; - public NetTexture2DExtended texture; - public NetBool flipped; - public NetBool flaggedForPickup; - public NetBool lightGlowAdded; - public NetObjectList inventory; - public NetInt InventoryMaxSize; - public NetBool itemReadyForHarvest; - public NetBool lightsOn; - public NetString locationName; - public NetColor lightColor; - public NetBool removable; - public NetColor drawColor; - public NetBool useXML; - public NetString serializationName; - - - //Animation Manager..... - public NetAnimationManager animationManager; - - - - - public NetCoreObject() - { - - } - - public NetCoreObject(CoreObject value) : base(value) - { - Set(value); - } - - public override void Set(CoreObject newValue) - { - this.value = newValue; - } - - protected override void ReadDelta(BinaryReader reader, NetVersion version) - { - texture = new NetTexture2DExtended(); - texture.Read(reader, version); - - Value.setExtendedTexture(texture.Value); - - which = new NetInt(); - which.Read(reader, version); - Value.ParentSheetIndex = which.Value; - - tilePos = new NetVector2(); - tilePos.Read(reader, version); - Value.TileLocation = tilePos.Value; - - InventoryMaxSize = new NetInt(); - InventoryMaxSize.Read(reader, version); - Value.inventoryMaxSize = InventoryMaxSize.Value; - - sourceRect = new NetRectangle(); - sourceRect.Read(reader, version); - Value.sourceRect = sourceRect.Value; - - boundingBox = new NetRectangle(); - boundingBox.Read(reader, version); - Value.boundingBox.Value = boundingBox.Value; - - drawPosition = new NetVector2(); - drawPosition.Read(reader, version); - Value.drawPosition = drawPosition.Value; - - locationName = new NetString(); - locationName.Read(reader, version); - Value.locationsName = locationName.Value; - Value.thisLocation = Game1.getLocationFromName(locationName.Value); - - /* - animationManager = new NetAnimationManager(); - animationManager.Read(reader, version); - Value.animationManager = animationManager.Value; - */ - - } - - protected override void WriteDelta(BinaryWriter writer) - { - texture = new NetTexture2DExtended(Value.getExtendedTexture()); - texture.Write(writer); - - which = new NetInt(Value.ParentSheetIndex); - which.Write(writer); - - tilePos = new NetVector2(Value.TileLocation); - tilePos.Write(writer); - - InventoryMaxSize = new NetInt(Value.inventoryMaxSize); - InventoryMaxSize.Write(writer); - - sourceRect = new NetRectangle(Value.sourceRect); - sourceRect.Write(writer); - - boundingBox = new NetRectangle(Value.boundingBox.Value); - sourceRect.Write(writer); - - drawPosition = new NetVector2(Value.drawPosition); - drawPosition.Write(writer); - - locationName = new NetString(Value.locationsName); - locationName.Write(writer); - - /* - if (Value.animationManager == null) - { - throw new Exception("WTF, why is the animation manager null???????????"); - } - animationManager = new NetAnimationManager(Value.animationManager); - animationManager.Write(writer); - */ - } - } -} \ No newline at end of file diff --git a/GeneralMods/StardustCore/NetCode/Objects/NetMultiTileComponent.cs b/GeneralMods/StardustCore/NetCode/Objects/NetMultiTileComponent.cs deleted file mode 100644 index 62bfed63..00000000 --- a/GeneralMods/StardustCore/NetCode/Objects/NetMultiTileComponent.cs +++ /dev/null @@ -1,116 +0,0 @@ -using Netcode; -using StardustCore.NetCode.Graphics; -using StardustCore.Objects; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace StardustCore.NetCode.Objects -{ - public class NetMultiTileComponent : Netcode.NetField - { - private NetTexture2DExtended texture; - private NetInt which; - private NetVector2 tilePos; - private NetRectangle sourceRect; - private NetRectangle boundingBox; - private NetVector2 drawPosition; - private NetAnimationManager animationManager; - - public NetMultiTileComponent() - { - - } - - public NetMultiTileComponent(MultiTileComponent obj): base(obj) - { - Set(obj); - } - - public NetInt InventoryMaxSize { get; private set; } - - public override void Set(MultiTileComponent newValue) - { - this.value = newValue; - } - - protected override void ReadDelta(BinaryReader reader, NetVersion version) - { - - texture = new NetTexture2DExtended(); - texture.Read(reader, version); - - which = new NetInt(); - which.Read(reader, version); - Value.ParentSheetIndex = which.Value; - - tilePos = new NetVector2(); - tilePos.Read(reader, version); - Value.TileLocation = tilePos.Value; - - InventoryMaxSize = new NetInt(); - InventoryMaxSize.Read(reader, version); - Value.inventoryMaxSize = InventoryMaxSize.Value; - - sourceRect = new NetRectangle(); - sourceRect.Read(reader, version); - Value.sourceRect = sourceRect.Value; - - boundingBox = new NetRectangle(); - boundingBox.Read(reader, version); - Value.boundingBox.Value = boundingBox.Value; - - drawPosition = new NetVector2(); - drawPosition.Read(reader, version); - Value.drawPosition = drawPosition.Value; - - animationManager = new NetAnimationManager(); - animationManager.Read(reader, version); - Value.animationManager = animationManager.Value; - //NetCoreObject obj = new NetCoreObject(); - //obj.ReadData(reader, version); - - /* - NetMultiTileObject hmm = new NetMultiTileObject(); - hmm.Read(reader,version); - Value.containerObject = hmm.Value; - */ - } - - protected override void WriteDelta(BinaryWriter writer) - { - //NetCoreObject obj = new NetCoreObject(Value); - //obj.WriteData(writer); - - texture = new NetTexture2DExtended(Value.getExtendedTexture()); - texture.Write(writer); - - which = new NetInt(Value.ParentSheetIndex); - which.Write(writer); - - tilePos = new NetVector2(Value.TileLocation); - tilePos.Write(writer); - - InventoryMaxSize = new NetInt(Value.inventoryMaxSize); - InventoryMaxSize.Write(writer); - - sourceRect = new NetRectangle(Value.sourceRect); - sourceRect.Write(writer); - - boundingBox = new NetRectangle(Value.boundingBox.Value); - sourceRect.Write(writer); - - drawPosition = new NetVector2(Value.drawPosition); - drawPosition.Write(writer); - - animationManager = new NetAnimationManager(Value.animationManager); - animationManager.Write(writer); - - //NetMultiTileObject hmm = new NetMultiTileObject(Value.containerObject); - //hmm.Write(writer); - } - } -} diff --git a/GeneralMods/StardustCore/NetCode/Objects/NetMultiTileObject.cs b/GeneralMods/StardustCore/NetCode/Objects/NetMultiTileObject.cs deleted file mode 100644 index 0653a03e..00000000 --- a/GeneralMods/StardustCore/NetCode/Objects/NetMultiTileObject.cs +++ /dev/null @@ -1,81 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Microsoft.Xna.Framework; -using Netcode; -using StardustCore.Objects; - -namespace StardustCore.NetCode.Objects -{ - public class NetMultiTileObject : Netcode.NetField - { - public NetMultiTileObject() - { - - } - - public NetMultiTileObject(MultiTileObject obj): base(obj) - { - - } - - public override void Set(MultiTileObject newValue) - { - this.value = newValue; - } - - protected override void ReadDelta(BinaryReader reader, NetVersion version) - { - NetCoreObject obj = new NetCoreObject(); - obj.Read(reader, version); - //Values already taken care of in NetCoreObject - - NetList, NetKeyValuePair> netList = new NetList, NetKeyValuePair>(); - netList.Read(reader, version); - if (netList.ToList() == null) throw new Exception("WTF WHY IS NETLIST NULL?!?!?!?!"); - - foreach(var v in netList.ToList()) - { - StardustCore.ModCore.ModMonitor.Log(v.Value.name, StardewModdingAPI.LogLevel.Alert); - } - - Value.objects = netList.ToList(); - //this.value.objects=netList.ToArray().ToList(); - - - - NetColor col = new NetColor(); - col.Read(reader, version); - Value.categoryColor = col.Value; - - NetString name = new NetString(); - name.Read(reader, version); - Value.categoryName = name.Value; - } - - protected override void WriteDelta(BinaryWriter writer) - { - NetCoreObject obj = new NetCoreObject(Value); - obj.Write(writer); - - NetList, NetKeyValuePair> netList = new NetList, NetKeyValuePair>(); - - if (Value.objects == null) throw new Exception("Trying to write null object list!"); - foreach (var v in Value.objects) - { - StardustCore.ModCore.ModMonitor.Log(v.Value.name); - netList.Add(v); - } - netList.Write(writer); - - NetColor col = new NetColor(Value.categoryColor); - col.Write(writer); - - NetString catName = new NetString(Value.categoryName); - catName.Write(writer); - } - } -} diff --git a/GeneralMods/StardustCore/Objects/CoreObject.cs b/GeneralMods/StardustCore/Objects/CoreObject.cs deleted file mode 100644 index 73d76bf5..00000000 --- a/GeneralMods/StardustCore/Objects/CoreObject.cs +++ /dev/null @@ -1,1354 +0,0 @@ -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Netcode; -using Newtonsoft.Json; -using StardewModdingAPI; -using StardewValley; -using StardewValley.Locations; -using StardewValley.Menus; -using StardewValley.Objects; -using StardustCore.Animations; -using StardustCore.Interfaces; -using StardustCore.UIUtilities; -using System; -using System.Collections.Generic; -using System.IO; -using System.Xml.Serialization; - -namespace StardustCore -{ - /// - /// Extends StardewValley.Object. Might be broken and just mainly uses a ton of junk code. Just extend off of this. - /// - /// - - public class CoreObject : StardewValley.Object, IItemSerializeable - { - public Vector2 position; - - public int Decoration_type; - - public int rotations; - - public int currentRotation; - - public int sourceIndexOffset; - - public Vector2 drawPosition; - - public Rectangle sourceRect; - - public Rectangle defaultSourceRect; - - public Rectangle defaultBoundingBox; - - public string description; - - - protected Texture2DExtended TextureSheet; - - public new bool flipped; - - [XmlIgnore] - public bool flaggedForPickUp; - - public bool lightGlowAdded; - - public List inventory; - - public int inventoryMaxSize; - - public bool itemReadyForHarvest; - - public bool lightsOn; - - public GameLocation thisLocation; - - public Color lightColor; - - public bool removable; - - public string locationsName; - - public Color drawColor; - - public bool useXML; - - public AnimationManager animationManager; - - public string serializationName; - - public string textureName; - - public override string Name - { - get - { - return this.name; - } - - } - - /// - /// Initialize some basic custom logic such as inventory for CoreObjects. - /// - /// The max size of this object's internal inventory. - /// The location for this object to be positioned. - public virtual void InitializeBasics(int InvMaxSize, Vector2 tile) - { - this.inventory = new List(); - this.inventoryMaxSize = InvMaxSize; - this.TileLocation = tile; - lightsOn = false; - - lightColor = Color.Black; - - base.initNetFields(); - this.NetFields.AddField(new NetCode.NetCoreObject(this)); - this.NetFields.AddFields(new INetSerializable[] { new NetString(this.Name), new NetRectangle(this.defaultSourceRect), new NetString(this.description) }); - - - } - - public CoreObject() - { - base.initNetFields(); - this.updateDrawPosition(); - this.NetFields.AddField(new NetCode.NetCoreObject(this)); - - } - - public CoreObject(bool f) - { - base.initNetFields(); - //does nothng - this.NetFields.AddField(new NetCode.NetCoreObject(this)); - - } - - public CoreObject(Texture2DExtended texture,int which, Vector2 Tile, int InventoryMaxSize):base() - { - var ok=Game1.getAllFarmers(); - this.Type = "Not Sure"; - this.CanBeSetDown = true; - this.CanBeGrabbed = true; - this.IsSpawnedObject = false; - this.questItem.Value = false; - this.questId.Value =0; - this.IsOn = false; - this.heldObject.Value = null; - this.Stack = 1; - - - InitializeBasics(InventoryMaxSize, Tile); - if (TextureSheet == null) - { - TextureSheet = texture; - } - Dictionary dictionary = Game1.content.Load>("Data\\Furniture"); - string[] array = dictionary[which].Split(new char[] - { - '/' - }); - this.name = array[0]; - - this.Decoration_type = this.getTypeNumberFromName(array[1]); - this.description = "Can be placed inside your house."; - this.defaultSourceRect = new Rectangle(which * 16 % TextureSheet.getTexture().Width, which * 16 / TextureSheet.getTexture().Width * 16, 1, 1); - if (array[2].Equals("-1")) - { - this.sourceRect = new Rectangle(0, 0, 16, 16); - this.defaultSourceRect = this.sourceRect; - } - else - { - this.defaultSourceRect.Width = 16; - this.defaultSourceRect.Height = 16; - this.sourceRect = new Rectangle((which * 16) % TextureSheet.getTexture().Width, (which * 16) / TextureSheet.getTexture().Width * 16, this.defaultSourceRect.Width, this.defaultSourceRect.Height); - this.defaultSourceRect = this.sourceRect; - } - this.defaultBoundingBox = new Rectangle((int)this.TileLocation.X, (int)this.TileLocation.Y, 1, 1); - if (array[3].Equals("-1")) - { - this.boundingBox.Value = this.getDefaultBoundingBoxForType(this.Decoration_type); - this.defaultBoundingBox = this.boundingBox.Value; - } - else - { - this.defaultBoundingBox.Width = Convert.ToInt32(array[3].Split(new char[] - { - ' ' - })[0]); - this.defaultBoundingBox.Height = Convert.ToInt32(array[3].Split(new char[] - { - ' ' - })[1]); - this.boundingBox.Value = new Rectangle((int)this.TileLocation.X * Game1.tileSize, (int)this.TileLocation.Y * Game1.tileSize, 1 * Game1.tileSize, 1 * Game1.tileSize); - this.defaultBoundingBox = this.boundingBox.Value; - } - - this.boundingBox.Value = new Rectangle(0, 0, Game1.tileSize, Game1.tileSize); - this.updateDrawPosition(); - this.rotations = Convert.ToInt32(array[4]); - this.Price = Convert.ToInt32(array[5]); - this.ParentSheetIndex = which; - this.serializationName=this.GetType().ToString(); - - - this.drawPosition = Vector2.Zero; - this.TileLocation = tileLocation; - this.locationsName = ""; - this.position = this.TileLocation * (Game1.tileSize); - this.thisLocation = null; - - this.textureName = this.TextureSheet.Name; - - this.animationManager = new AnimationManager(this.TextureSheet, new Animation(this.sourceRect), false); - } - - public override string getDescription() - { - return this.description; - } - - /// - /// A "placement" action that doesn't put the object in the world, but set it's position accordingly. - /// - /// The GameLocation that this object will be placed at. - /// The x tile location to "place". - /// The y tile location to "place". - /// If true then the Serialization manager will keep track of this object. - public virtual void fakePlacementAction(GameLocation location, int tileX, int tileY,bool trackSerialization=true) - { - this.thisLocation = location; - this.TileLocation = new Vector2(tileX, tileY); - this.position = this.TileLocation*(Game1.tileSize); - if (trackSerialization) - { - if (ModCore.SerializationManager.trackedObjectList.Contains(this)) return; - ModCore.SerializationManager.trackedObjectList.Add(this); - } - } - - public override bool performDropDownAction(StardewValley.Farmer who) - { - this.resetOnPlayerEntry((who == null) ? Game1.currentLocation : who.currentLocation); - return false; - } - - public override void hoverAction() - { - base.hoverAction(); - if (!Game1.player.isInventoryFull()) - { - Game1.mouseCursor = 2; - } - } - - public override bool checkForAction(StardewValley.Farmer who, bool justCheckingForActivity = false) - { - var mState = Microsoft.Xna.Framework.Input.Mouse.GetState(); - if (mState.RightButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed) - { - // Game1.showRedMessage("YOOO"); - //do some stuff when the right button is down - // rotate(); - if (this.heldObject.Value != null) - { - // Game1.player.addItemByMenuIfNecessary(this.heldObject); - // this.heldObject = null; - } - else - { - // this.heldObject = Game1.player.ActiveObject; - // Game1.player.removeItemFromInventory(heldObject); - } - //this.minutesUntilReady = 30; - // Log.AsyncC("placed item!"); - } - else - { - //Game1.showRedMessage("CRY"); - } - - if (justCheckingForActivity) - { - return true; - } - return this.clicked(who); - } - - public override bool clicked(Farmer who) - { - performRemoveAction(this.TileLocation, this.thisLocation); - who.addItemToInventory(this); - - return true; - } - - public virtual bool RightClicked(StardewValley.Farmer who) - { - // StardewModdingAPI.Log.AsyncC(lightColor); - // Game1.activeClickableMenu = new Revitalize.Menus.LightCustomizer(this); - - // Game1.showRedMessage("THIS IS CLICKED!!!"); - //var mState = Microsoft.Xna.Framework.Input.Mouse.GetState(); - /* - - Game1.haltAfterCheck = false; - if (this.Decoration_type == 11 && who.ActiveObject != null && who.ActiveObject != null && this.heldObject == null) - { - // Game1.showRedMessage("Why1?"); - return false; - } - if (this.heldObject == null && (who.ActiveObject == null || !(who.ActiveObject is Light))) - { - if (Game1.player.currentLocation is FarmHouse) - { - // - Game1.player.addItemByMenuIfNecessary(this); - removeLights(this.thisLocation); - this.lightsOn = false; - Game1.playSound("coin"); - // this.flaggedForPickUp = true; - return true; - } - else - { - // return true; - // this.heldObject = new Light(parentSheetIndex, Vector2.Zero, this.lightColor, this.inventoryMaxSize); - Game1.player.addItemByMenuIfNecessary(this); - removeLights(this.thisLocation); - this.lightsOn = false; - Game1.playSound("coin"); - return true; - - } - } - if (this.heldObject != null && who.addItemToInventoryBool(this.heldObject, false)) - { - // Game1.showRedMessage("Why3?"); - // if(this.heldObject!=null) Game1.player.addItemByMenuIfNecessary((Item)this.heldObject); - Util.addItemToInventoryElseDrop(this); - this.heldObject.performRemoveAction(this.tileLocation, who.currentLocation); - this.heldObject = null; - Game1.playSound("coin"); - removeLights(this.thisLocation); - this.lightsOn = false; - return true; - } - - */ - - return false; - } - - public override void DayUpdate(GameLocation location) - { - base.DayUpdate(location); - this.lightGlowAdded = false; - if (!Game1.isDarkOut() || (Game1.newDay && !Game1.isRaining)) - { - this.removeLights(location); - return; - } - this.addLights(location); - } - - public virtual void resetOnPlayerEntry(GameLocation environment) - { - this.removeLights(environment); - if (Game1.isDarkOut()) - { - this.addLights(environment); - } - } - - /// - /// Drops in an item into this object. I.E putting an egg in a mayo maker. - /// - /// - /// - /// - /// - public override bool performObjectDropInAction(Item dropIn, bool probe, StardewValley.Farmer who) - { - // Log.AsyncG("HEY!"); - if (this.heldObject.Value == null && (dropIn is Item)) //Basically who cares accept whatever. - { - try { - this.heldObject.Value = (StardewValley.Object)dropIn.getOne(); - this.heldObject.Value.TileLocation = this.TileLocation; - this.heldObject.Value.boundingBox.X = this.boundingBox.X; - this.heldObject.Value.boundingBox.Y = this.boundingBox.Y; - // Log.AsyncO(getDefaultBoundingBoxForType((dropIn as CoreObject).Decoration_type)); - this.heldObject.Value.performDropDownAction(who); - if (!probe) - { - Game1.playSound("woodyStep"); - // Log.AsyncC("HUH?"); - if (who != null) - { - who.reduceActiveItemByOne(); - } - } - return true; - } - catch(Exception err) - { - ModCore.ModMonitor.Log(err.ToString(),LogLevel.Error); - return false; - } - } - return false; - } - - public virtual void addLights(GameLocation environment) - { - if (this.Decoration_type == 7) - { - if (this.sourceIndexOffset == 0) - { - this.sourceRect = this.defaultSourceRect; - this.sourceRect.X = this.sourceRect.X + this.sourceRect.Width; - } - this.sourceIndexOffset = 1; - if (this.lightSource == null) - { - Utility.removeLightSource((int)(this.TileLocation.X * 2000f + this.TileLocation.Y)); - this.lightSource = new LightSource(4, new Vector2((float)(this.boundingBox.X + Game1.tileSize / 2), (float)(this.boundingBox.Y - Game1.tileSize)), 2f, lightColor, (int)(this.TileLocation.X * 2000f + this.TileLocation.Y)); - Game1.currentLightSources.Add(this.lightSource); - // Log.AsyncG("LIGHT SOURCE ADDED FFFFFFF"); - return; - } - } - else if (this.Decoration_type == 13) - { - if (this.sourceIndexOffset == 0) - { - this.sourceRect = this.defaultSourceRect; - this.sourceRect.X = this.sourceRect.X + this.sourceRect.Width; - } - this.sourceIndexOffset = 1; - if (this.lightGlowAdded) - { - environment.lightGlows.Remove(new Vector2((float)(this.boundingBox.X + Game1.tileSize / 2), (float)(this.boundingBox.Y + Game1.tileSize))); - this.lightGlowAdded = false; - } - } - else - { - - if (this.sourceIndexOffset == 0) - { - this.sourceRect = this.defaultSourceRect; - this.sourceRect.X = this.sourceRect.X + this.sourceRect.Width; - } - this.sourceIndexOffset = 1; - if (this.lightSource == null) - { - Utility.removeLightSource((int)(this.TileLocation.X * 2000f + this.TileLocation.Y)); - this.lightSource = new LightSource(4, new Vector2((float)(this.boundingBox.X + Game1.tileSize / 2), (float)(this.boundingBox.Y - Game1.tileSize)), 2f, lightColor, (int)(this.TileLocation.X * 2000f + this.TileLocation.Y)); - Game1.currentLightSources.Add(this.lightSource); - return; - } - - } - } - - - /// - /// Add a light source to this location. - /// - /// The game location to add the light source in. - /// The color of the light to be added - public virtual void addLights(GameLocation environment, Color c) - { - if (this.sourceIndexOffset == 0) - { - this.sourceRect = this.defaultSourceRect; - this.sourceRect.X = this.sourceRect.X + this.sourceRect.Width; - } - this.sourceIndexOffset = 1; - if (this.lightSource == null) - { - Utility.removeLightSource((int)(this.TileLocation.X * 2000f + this.TileLocation.Y)); - this.lightSource = new LightSource(4, new Vector2((float)(this.boundingBox.X + Game1.tileSize / 2), (float)(this.boundingBox.Y - Game1.tileSize)), 2f, c, (int)(this.TileLocation.X * 2000f + this.TileLocation.Y)); - Game1.currentLightSources.Add(this.lightSource); - return; - } - } - - /// - /// Removes a lightsource from the game location. - /// - /// The game location to remove the light source from. - public void removeLights(GameLocation environment) - { - if (this.Decoration_type == 7) - { - if (this.sourceIndexOffset == 1) - { - this.sourceRect = this.defaultSourceRect; - } - this.sourceIndexOffset = 0; - Utility.removeLightSource((int)(this.TileLocation.X * 2000f + this.TileLocation.Y)); - this.lightSource = null; - return; - } - if (this.Decoration_type == 13) - { - if (this.sourceIndexOffset == 1) - { - this.sourceRect = this.defaultSourceRect; - } - this.sourceIndexOffset = 0; - if (Game1.isRaining) - { - this.sourceRect = this.defaultSourceRect; - this.sourceRect.X = this.sourceRect.X + this.sourceRect.Width; - this.sourceIndexOffset = 1; - return; - } - if (!this.lightGlowAdded && !environment.lightGlows.Contains(new Vector2((float)(this.boundingBox.X + Game1.tileSize / 2), (float)(this.boundingBox.Y + Game1.tileSize)))) - { - environment.lightGlows.Add(new Vector2((float)(this.boundingBox.X + Game1.tileSize / 2), (float)(this.boundingBox.Y + Game1.tileSize))); - } - this.lightGlowAdded = true; - } - - if (this.sourceIndexOffset == 1) - { - this.sourceRect = this.defaultSourceRect; - } - this.sourceIndexOffset = 0; - Utility.removeLightSource((int)(this.TileLocation.X * 2000f + this.TileLocation.Y)); - this.lightSource = null; - return; - } - - - - - public override bool minutesElapsed(int minutes, GameLocation environment) - { - // Log.Info("minutes passed in"+minutes); - // Log.Info("minues remaining" + this.minutesUntilReady); - this.MinutesUntilReady = (this.MinutesUntilReady - minutes); - if (Game1.isDarkOut()) - { - // this.addLights(environment,this.lightColor); - this.addLights(environment); - } - else - { - this.removeLights(environment); - } - - if (minutesUntilReady == 0) - { - // Log.AsyncC(this.name + "Is ready!"); - // Log.AsyncC(Game1.player.getStandingPosition()); - // Vector2 v2 = new Vector2(this.tileLocation.X * Game1.tileSize, this.tileLocation.Y * Game1.tileSize); - //Game1.createItemDebris((Item)this.heldObject, v2, Game1.player.getDirection()); - // minutesUntilReady = 30; - } - - return false; - } - - public override void performRemoveAction(Vector2 tileLocation, GameLocation environment) - { - this.removeLights(environment); - if (this.Decoration_type == 13 && this.lightGlowAdded) - { - environment.lightGlows.Remove(new Vector2((float)(this.boundingBox.X + Game1.tileSize / 2), (float)(this.boundingBox.Y + Game1.tileSize))); - this.lightGlowAdded = false; - } - try - { - this.spillInventoryEverywhere(); - } - catch(Exception err) - { - - } - - - StardustCore.ModCore.SerializationManager.trackedObjectList.Remove(this); - this.thisLocation.removeObject(this.TileLocation, false); - this.thisLocation = null; - this.locationsName = ""; - - base.performRemoveAction(tileLocation, environment); - } - - public virtual void rotate() - { - if (this.rotations < 2) - { - return; - } - int num = (this.rotations == 4) ? 1 : 2; - this.currentRotation += num; - this.currentRotation %= 4; - this.flipped = false; - Point point = default(Point); - int num2 = this.Decoration_type; - switch (num2) - { - case 2: - point.Y = 1; - point.X = -1; - break; - case 3: - point.X = -1; - point.Y = 1; - break; - case 4: - break; - case 5: - point.Y = 0; - point.X = -1; - break; - default: - if (num2 == 12) - { - point.X = 0; - point.Y = 0; - } - break; - } - bool flag = this.Decoration_type == 5 || this.Decoration_type == 12 || this.ParentSheetIndex == 724 || this.ParentSheetIndex == 727; - bool flag2 = this.defaultBoundingBox.Width != this.defaultBoundingBox.Height; - if (flag && this.currentRotation == 2) - { - this.currentRotation = 1; - } - if (flag2) - { - int height = this.boundingBox.Height; - switch (this.currentRotation) - { - case 0: - case 2: - this.boundingBox.Height = this.defaultBoundingBox.Height; - this.boundingBox.Width = this.defaultBoundingBox.Width; - break; - case 1: - case 3: - this.boundingBox.Height = this.boundingBox.Width + point.X * Game1.tileSize; - this.boundingBox.Width = height + point.Y * Game1.tileSize; - break; - } - } - Point point2 = default(Point); - int num3 = this.Decoration_type; - if (num3 == 12) - { - point2.X = 1; - point2.Y = -1; - } - if (flag2) - { - switch (this.currentRotation) - { - case 0: - this.sourceRect = this.defaultSourceRect; - break; - case 1: - this.sourceRect = new Rectangle(this.defaultSourceRect.X + this.defaultSourceRect.Width, this.defaultSourceRect.Y, this.defaultSourceRect.Height - 16 + point.Y * 16 + point2.X * 16, this.defaultSourceRect.Width + 16 + point.X * 16 + point2.Y * 16); - break; - case 2: - this.sourceRect = new Rectangle(this.defaultSourceRect.X + this.defaultSourceRect.Width + this.defaultSourceRect.Height - 16 + point.Y * 16 + point2.X * 16, this.defaultSourceRect.Y, this.defaultSourceRect.Width, this.defaultSourceRect.Height); - break; - case 3: - this.sourceRect = new Rectangle(this.defaultSourceRect.X + this.defaultSourceRect.Width, this.defaultSourceRect.Y, this.defaultSourceRect.Height - 16 + point.Y * 16 + point2.X * 16, this.defaultSourceRect.Width + 16 + point.X * 16 + point2.Y * 16); - this.flipped = true; - break; - } - } - else - { - this.flipped = (this.currentRotation == 3); - if (this.rotations == 2) - { - this.sourceRect = new Rectangle(this.defaultSourceRect.X + ((this.currentRotation == 2) ? 1 : 0) * this.defaultSourceRect.Width, this.defaultSourceRect.Y, this.defaultSourceRect.Width, this.defaultSourceRect.Height); - } - else - { - this.sourceRect = new Rectangle(this.defaultSourceRect.X + ((this.currentRotation == 3) ? 1 : this.currentRotation) * this.defaultSourceRect.Width, this.defaultSourceRect.Y, this.defaultSourceRect.Width, this.defaultSourceRect.Height); - } - } - if (flag && this.currentRotation == 1) - { - this.currentRotation = 2; - } - this.updateDrawPosition(); - } - - public virtual bool isGroundFurniture() - { - return this.Decoration_type != 13 && this.Decoration_type != 6 && this.Decoration_type != 13; - } - - /// - /// Determines whether or not this item can be given as a gift. Default is always false. - /// - /// - public override bool canBeGivenAsGift() - { - return false; - } - - - public virtual void updateDrawPosition() - { - this.drawPosition = new Vector2((float)this.boundingBox.X, (float)(this.boundingBox.Y - (this.sourceRect.Height * Game1.pixelZoom - this.boundingBox.Height))); - } - - public virtual int getTilesWide() - { - return this.boundingBox.Width / Game1.tileSize; - } - - public virtual int getTilesHigh() - { - return this.boundingBox.Height / Game1.tileSize; - } - - public override bool canStackWith(Item other) - { - if (other.Name == this.name && (other as CoreObject).textureName == this.textureName) return true; - else return false; - } - - public override bool placementAction(GameLocation location, int x, int y, StardewValley.Farmer who = null) - { - - StardustCore.ModCore.ModMonitor.Log("X Value:" + x); - Point point = new Point(x, y); - - - this.TileLocation = new Vector2((float)point.X/Game1.tileSize, (float)point.Y/Game1.tileSize); - - this.boundingBox.Value = new Rectangle((int)tileLocation.X, (int)tileLocation.Y, Game1.tileSize, Game1.tileSize); - - foreach (Farmer farmer in Game1.getAllFarmers()) - { - if (location == farmer.currentLocation) - { - if (farmer.GetBoundingBox().Intersects(this.boundingBox.Value)) - { - Game1.showRedMessage("Can't place on top of a person."); - bool result = false; - return result; - } - } - } - - this.updateDrawPosition(); - - bool f = Utilities.placementAction(this, location, x, y, StardustCore.ModCore.SerializationManager,who); - this.thisLocation = Game1.player.currentLocation; - return f; - // Game1.showRedMessage("Can only be placed in House"); - // return false; - - - - - } - - public override bool isPlaceable() - { - return true; - } - - public override Rectangle getBoundingBox(Vector2 tileLocation) - { - return this.boundingBox.Value; - } - - private Rectangle getDefaultSourceRectForType(int tileIndex, int type) - { - int num; - int num2; - switch (type) - { - case 0: - num = 1; - num2 = 2; - goto IL_94; - case 1: - num = 2; - num2 = 2; - goto IL_94; - case 2: - num = 3; - num2 = 2; - goto IL_94; - case 3: - num = 2; - num2 = 2; - goto IL_94; - case 4: - num = 2; - num2 = 2; - goto IL_94; - case 5: - num = 5; - num2 = 3; - goto IL_94; - case 6: - num = 2; - num2 = 2; - goto IL_94; - case 7: - num = 1; - num2 = 3; - goto IL_94; - case 8: - num = 1; - num2 = 2; - goto IL_94; - case 10: - num = 2; - num2 = 3; - goto IL_94; - case 11: - num = 2; - num2 = 3; - goto IL_94; - case 12: - num = 3; - num2 = 2; - goto IL_94; - case 13: - num = 1; - num2 = 2; - goto IL_94; - } - num = 1; - num2 = 2; - IL_94: - return new Rectangle(tileIndex * 16 % TextureSheet.getTexture().Width, tileIndex * 16 / TextureSheet.getTexture().Width * 16, num * 16, num2 * 16); - } - - private Rectangle getDefaultBoundingBoxForType(int type) - { - int num; - int num2; - switch (type) - { - case 0: - num = 1; - num2 = 1; - goto IL_94; - case 1: - num = 2; - num2 = 1; - goto IL_94; - case 2: - num = 3; - num2 = 1; - goto IL_94; - case 3: - num = 2; - num2 = 1; - goto IL_94; - case 4: - num = 2; - num2 = 1; - goto IL_94; - case 5: - num = 5; - num2 = 2; - goto IL_94; - case 6: - num = 2; - num2 = 2; - goto IL_94; - case 7: - num = 1; - num2 = 1; - goto IL_94; - case 8: - num = 1; - num2 = 1; - goto IL_94; - case 10: - num = 2; - num2 = 1; - goto IL_94; - case 11: - num = 2; - num2 = 2; - goto IL_94; - case 12: - num = 3; - num2 = 2; - goto IL_94; - case 13: - num = 1; - num2 = 2; - goto IL_94; - } - - num = 1; - num2 = 1; - IL_94: - return new Rectangle((int)this.TileLocation.X * Game1.tileSize, (int)this.TileLocation.Y * Game1.tileSize, num * Game1.tileSize, num2 * Game1.tileSize); - } - - private int getTypeNumberFromName(string typeName) - { - string key; - switch (key = typeName.ToLower()) - { - case "chair": - return 0; - case "bench": - return 1; - case "couch": - return 2; - case "armchair": - return 3; - case "dresser": - return 4; - case "long table": - return 5; - case "painting": - return 6; - case "lamp": - return 7; - case "decor": - return 8; - case "bookcase": - return 10; - case "table": - return 11; - case "rug": - return 12; - case "window": - return 13; - } - return 9; - } - - public override int salePrice() - { - return this.Price; - } - - public override int maximumStackSize() - { - return 999; - } - - public override int getStack() - { - return this.Stack; - } - - - private float getScaleSize() - { - int num = this.sourceRect.Width / 16; - int num2 = this.sourceRect.Height / 16; - if (num >= 5) - { - return 0.75f; - } - if (num2 >= 3) - { - return 1f; - } - if (num <= 2) - { - return 2f; - } - if (num <= 4) - { - return 1f; - } - return 0.1f; - } - - public override void drawWhenHeld(SpriteBatch spriteBatch, Vector2 objectPosition, StardewValley.Farmer f) - { - if (f.ActiveObject.bigCraftable.Value) - { - spriteBatch.Draw(Game1.bigCraftableSpriteSheet, objectPosition, new Microsoft.Xna.Framework.Rectangle?(StardewValley.Object.getSourceRectForBigCraftable(f.ActiveObject.ParentSheetIndex)), Color.White, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, Math.Max(0f, (float)(f.getStandingY() + 2) / 10000f)); - return; - } - - spriteBatch.Draw(Game1.objectSpriteSheet, objectPosition, new Microsoft.Xna.Framework.Rectangle?(GameLocation.getSourceRectForObject(f.ActiveObject.ParentSheetIndex)), Color.White, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, Math.Max(0f, (float)(f.getStandingY() + 2) / 10000f)); - if (f.ActiveObject != null && f.ActiveObject.Name.Contains("=")) - { - spriteBatch.Draw(Game1.objectSpriteSheet, objectPosition + new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize / 2)), new Microsoft.Xna.Framework.Rectangle?(GameLocation.getSourceRectForObject(f.ActiveObject.ParentSheetIndex)), Color.White, 0f, new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize / 2)), (float)Game1.pixelZoom + Math.Abs(Game1.starCropShimmerPause) / 8f, SpriteEffects.None, Math.Max(0f, (float)(f.getStandingY() + 2) / 10000f)); - if (Math.Abs(Game1.starCropShimmerPause) <= 0.05f && Game1.random.NextDouble() < 0.97) - { - return; - } - Game1.starCropShimmerPause += 0.04f; - if (Game1.starCropShimmerPause >= 0.8f) - { - Game1.starCropShimmerPause = -0.8f; - } - } - //base.drawWhenHeld(spriteBatch, objectPosition, f); - } - - /// - /// Draws the item's icon in the menu. - /// - /// - /// - /// - /// - /// - /// - /// - /// - public override void drawInMenu(SpriteBatch spriteBatch, Vector2 location, float scaleSize, float transparency, float layerDepth, bool drawStackNumber, Color c, bool drawShadow) - { - if (drawStackNumber && this.maximumStackSize() > 1 && ((double)scaleSize > 0.3 && this.Stack != int.MaxValue) && this.Stack > 1) - Utility.drawTinyDigits(this.Stack, spriteBatch, location + new Vector2((float)(Game1.tileSize - Utility.getWidthOfTinyDigitString(this.Stack, 3f * scaleSize)) + 3f * scaleSize, (float)((double)Game1.tileSize - 18.0 * (double)scaleSize + 2.0)), 3f * scaleSize, 1f, Color.White); - if (drawStackNumber && this.Quality > 0) - { - float num = this.Quality < 4 ? 0.0f : (float)((Math.Cos((double)Game1.currentGameTime.TotalGameTime.Milliseconds * Math.PI / 512.0) + 1.0) * 0.0500000007450581); - spriteBatch.Draw(Game1.mouseCursors, location + new Vector2(12f, (float)(Game1.tileSize - 12) + num), new Microsoft.Xna.Framework.Rectangle?(this.Quality < 4 ? new Microsoft.Xna.Framework.Rectangle(338 + (this.Quality - 1) * 8, 400, 8, 8) : new Microsoft.Xna.Framework.Rectangle(346, 392, 8, 8)), Color.White * transparency, 0.0f, new Vector2(4f, 4f), (float)(3.0 * (double)scaleSize * (1.0 + (double)num)), SpriteEffects.None, layerDepth); - } - spriteBatch.Draw(TextureSheet.getTexture(), location + new Vector2((float)(Game1.tileSize), (float)(Game1.tileSize)), new Rectangle?(this.defaultSourceRect), Color.White * transparency, 0f, new Vector2((float)(this.defaultSourceRect.Width / 2), (float)(this.defaultSourceRect.Height)), 1f * this.getScaleSize() * scaleSize * .5f, SpriteEffects.None, layerDepth); - } - - /// - /// Draws the object to the screen. - /// - /// - /// - /// - /// - public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1f) - { - if (TextureSheet == null) - { - ModCore.ModMonitor.Log("WTF? Why is texture sheet null???"); - } - if (x == -1) - { - spriteBatch.Draw(TextureSheet.getTexture(), Game1.GlobalToLocal(Game1.viewport, this.drawPosition), new Rectangle?(this.sourceRect), Color.White * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0f); - } - else - { - spriteBatch.Draw(TextureSheet.getTexture(), Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(x * Game1.tileSize), (float)(y * Game1.tileSize))), new Rectangle?(this.sourceRect), Color.White * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0f); - } - if (this.heldObject.Value != null) - { - if (this.heldObject.Value is CoreObject) - { - (this.heldObject.Value as CoreObject).drawAtNonTileSpot(spriteBatch, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(this.boundingBox.Center.X - Game1.tileSize / 2), (float)(this.boundingBox.Center.Y - (this.heldObject.Value as CoreObject).sourceRect.Height * Game1.pixelZoom - Game1.tileSize / 4))), (float)(this.boundingBox.Bottom - 7) / 10000f, alpha); - return; - } - spriteBatch.Draw(Game1.shadowTexture, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(this.boundingBox.Center.X - Game1.tileSize / 2), (float)(this.boundingBox.Center.Y - Game1.tileSize * 4 / 3))) + new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize * 5 / 6)), new Rectangle?(Game1.shadowTexture.Bounds), Color.White * alpha, 0f, new Vector2((float)Game1.shadowTexture.Bounds.Center.X, (float)Game1.shadowTexture.Bounds.Center.Y), 4f, SpriteEffects.None, (float)this.boundingBox.Bottom / 10000f); - spriteBatch.Draw(Game1.objectSpriteSheet, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(this.boundingBox.Center.X - Game1.tileSize / 2), (float)(this.boundingBox.Center.Y - Game1.tileSize * 4 / 3))), new Rectangle?(GameLocation.getSourceRectForObject(this.heldObject.Value.ParentSheetIndex)), Color.White * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, (float)(this.boundingBox.Bottom + 1) / 10000f); - } - } - - public override void draw(SpriteBatch spriteBatch, int xNonTile, int yNonTile, float layerDepth, float alpha = 1) - { - this.draw(spriteBatch, xNonTile, yNonTile, alpha); - } - - - - public virtual void drawAtNonTileSpot(SpriteBatch spriteBatch, Vector2 location, float layerDepth, float alpha = 1f) - { - spriteBatch.Draw(TextureSheet.getTexture(), location, new Rectangle?(this.sourceRect), Color.White * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, layerDepth); - } - - public override Item getOne() - { - CoreObject CoreObject = new CoreObject(this.TextureSheet,this.ParentSheetIndex, this.TileLocation, this.inventoryMaxSize); - - CoreObject.drawPosition = this.drawPosition; - CoreObject.defaultBoundingBox = this.defaultBoundingBox; - CoreObject.boundingBox.Value = this.boundingBox.Value; - CoreObject.currentRotation = this.currentRotation - 1; - CoreObject.rotations = this.rotations; - //rotate(); - - return CoreObject; - } - - - /// - /// Used in vertain cases where the mod needs to get an object relative to a content pack's directory. - /// - /// - /// - public virtual Item getOne(IModHelper helper) - { - Texture2DExtended texture = new Texture2DExtended(helper, this.TextureSheet.modID,this.TextureSheet.path); - CoreObject CoreObject = new CoreObject(texture,this.ParentSheetIndex, this.TileLocation, this.inventoryMaxSize); - - CoreObject.drawPosition = this.drawPosition; - CoreObject.defaultBoundingBox = this.defaultBoundingBox; - CoreObject.boundingBox.Value = this.boundingBox.Value; - CoreObject.currentRotation = this.currentRotation - 1; - CoreObject.rotations = this.rotations; - //rotate(); - - return CoreObject; - } - - public virtual bool isInventoryFull() - { - // Log.AsyncC("Count" + inventory.Count); - // Log.AsyncC("size" + inventoryMaxSize); - if (inventory.Count >= inventoryMaxSize) - { - - return true; - } - else - { - return false; - } - - } - - public virtual bool addItemToInventory(Item I) - { - if (isInventoryFull() == false) - { - inventory.Add(I.getOne()); - return true; - } - else return false; - } - - public virtual void getInventoryMenu() - { - Game1.activeClickableMenu = new StorageContainer(this.inventory, 3, 3); - this.itemReadyForHarvest = false; - /* - - */ - } - - public virtual void spillInventoryEverywhere() - { - - Random random = new Random(inventory.Count); - int i = random.Next(); - i = i % 4; - Vector2 v2 = new Vector2(this.TileLocation.X * Game1.tileSize, this.TileLocation.Y * Game1.tileSize); - foreach (var I in inventory) - { - Game1.createItemDebris(I, v2, i); - } - inventory.Clear(); - } - - /// - /// Adds an item to this item's internal inventory if it can. Otherwise drop it on the ground as item debris. - /// - /// - /// - public virtual bool addItemToInventoryElseDrop(Item I) - { - - if (isInventoryFull() == false) - { - foreach (Item C in inventory) - { - if (C == null) continue; - if (I.canStackWith(C) == true) - { - C.addToStack(I.Stack); - return true; - } - else - { - inventory.Add(I.getOne()); - return true; - } - } - inventory.Add(I.getOne()); - return true; - } - else - { - Random random = new Random(inventory.Count); - int i = random.Next(); - i = i % 4; - Vector2 v2 = new Vector2(this.TileLocation.X * Game1.tileSize, this.TileLocation.Y * Game1.tileSize); - Game1.createItemDebris(I.getOne(), v2, i); - return false; - } - } - - public virtual void toggleLights() - { - - if (lightsOn == false) - { - - // Log.AsyncG("ADD LIGHTS"); - this.Decoration_type = 7; - this.Type = "Lamp"; - - // this.lightSource.lightTexture = Game1.content.Load("LooseSprites\\Lighting\\Lantern"); - // this.lightSource.position = tileLocation; - - // this.addLights(thisLocation, lightColor); - this.addLights(thisLocation, lightColor); - lightsOn = true; - } - if (lightsOn == true) - { - this.removeLights(Game1.player.currentLocation); - lightsOn = false; - } - - } - - public virtual void resetTexture(IModHelper helper) - { - TextureSheet = new Texture2DExtended(helper, this.TextureSheet.modID,TextureSheet.path); - } - - public virtual void resetTexture() - { - TextureSheet = new Texture2DExtended(TextureSheet.getHelper(),TextureSheet.modID, TextureSheet.path); - } - - public override string getCategoryName() - { - return "Core Mod Object"; - // return base.getCategoryName(); - } - - public override Color getCategoryColor() - { - return Color.Black; - } - - public virtual Type getCustomType() - { - return this.GetType(); - } - - public virtual string GetSerializationName() - { - return this.GetType().ToString(); - } - - - public virtual Texture2DExtended getExtendedTexture() - { - return this.TextureSheet; - } - - public virtual void setExtendedTexture(Texture2DExtended texture) - { - this.TextureSheet = texture; - } - - - /// - /// Serializes the said item properly. - /// - /// - public static void Serialize(Item I) - { - - if((I as CoreObject).thisLocation != null) - { - SerializeToWorldPath(I); - return; - } - - String savePath = ModCore.SerializationManager.playerInventoryPath; - String fileName = I.Name + ".json"; - String resultPath = Path.Combine(savePath, fileName); - int count = 0; - while (File.Exists(resultPath)) - { - resultPath = Serialization.SerializationManager.getValidSavePathIfDuplicatesExist(I, savePath, count); - count++; - } - JsonSerializerSettings settings = new JsonSerializerSettings(); - settings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; - (I as CoreObject).textureName = (I as CoreObject).TextureSheet.Name; - string json = JsonConvert.SerializeObject(I, Formatting.Indented,settings); - System.IO.File.WriteAllText(resultPath, json); - //StardustCore.ModCore.ModHelper.WriteJsonFile(resultPath, (CoreObject)I); - } - - public static void SerializeToWorldPath(Item I) - { - String savePath = ModCore.SerializationManager.objectsInWorldPath; - String fileName = I.Name + ".json"; - String resultPath = Path.Combine(savePath, fileName); - int count = 0; - while (File.Exists(resultPath)) - { - resultPath = Serialization.SerializationManager.getValidSavePathIfDuplicatesExist(I, savePath, count); - count++; - } - JsonSerializerSettings settings = new JsonSerializerSettings(); - settings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; - (I as CoreObject).textureName = (I as CoreObject).TextureSheet.Name; - string json = JsonConvert.SerializeObject(I, Formatting.Indented, settings); - System.IO.File.WriteAllText(resultPath, json); - } - - - - /// - /// Serializes the said item to a chest. - /// - /// - /// - public static void SerializeToContainer(Item I, string s) - { - String savePath = s; - String fileName = I.Name + ".json"; - String resultPath = Path.Combine(savePath, fileName); - int count = 0; - while (File.Exists(resultPath)) - { - resultPath = Serialization.SerializationManager.getValidSavePathIfDuplicatesExist(I, savePath, count); - count++; - } - JsonSerializerSettings settings = new JsonSerializerSettings(); - settings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; - (I as CoreObject).textureName = (I as CoreObject).TextureSheet.Name; - string json = JsonConvert.SerializeObject(I, Formatting.Indented, settings); - System.IO.File.WriteAllText(resultPath, json); - //StardustCore.ModCore.ModHelper.WriteJsonFile(resultPath, (CoreObject)I); - } - - /// - /// Deserializes the object from a .json. - /// - /// - /// - public static CoreObject Deserialize(string data) - { - CoreObject obj = ModCore.ModHelper.ReadJsonFile(data); - obj.TextureSheet = ModCore.TextureManager.getTexture(obj.textureName); - return obj; - } - - public override void updateWhenCurrentLocation(GameTime time, GameLocation environment) - { - //Do nothing. - this.updateDrawPosition(); - } - } -} - diff --git a/GeneralMods/StardustCore/Objects/MultiTileComponent.cs b/GeneralMods/StardustCore/Objects/MultiTileComponent.cs deleted file mode 100644 index dfe76e57..00000000 --- a/GeneralMods/StardustCore/Objects/MultiTileComponent.cs +++ /dev/null @@ -1,244 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using StardewValley; -using StardustCore.UIUtilities; - -namespace StardustCore.Objects -{ - public class MultiTileComponent : CoreObject - { - //Pass in different function pointers that return bool to check if this default code will run. If not - public MultiTileObject containerObject; - - public MultiTileComponent() - { - //this.TextureSheet = new Texture2DExtended(); - this.NetFields.AddField(new NetCode.NetTexture2DExtended(this.getExtendedTexture())); - } - - public MultiTileComponent(CoreObject part) - { - this.name = part.name; - this.description = part.description; - this.TextureSheet = part.getExtendedTexture(); - if (part.animationManager != null) - { - this.animationManager = part.animationManager; - } - this.defaultBoundingBox = new Rectangle(0, 0, 16, 16); - this.boundingBox.Value = new Rectangle((int)0 * Game1.tileSize, (int)0* Game1.tileSize, 1 * Game1.tileSize, 1 * Game1.tileSize); - - - this.NetFields.AddField(new NetCode.NetTexture2DExtended(this.getExtendedTexture())); - - this.InitializeBasics(0, Vector2.Zero); - } - - public MultiTileComponent(int which,String name, String description, Texture2DExtended texture) - { - this.name = name; - this.displayName = name; - this.description = description; - this.TextureSheet = texture; - this.defaultBoundingBox = new Rectangle(0, 0, 16, 16); - this.boundingBox.Value = new Rectangle((int)0 * Game1.tileSize, (int)0 * Game1.tileSize, 1 * Game1.tileSize, 1 * Game1.tileSize); - this.defaultSourceRect.Width = 16; - this.defaultSourceRect.Height = 16; - this.sourceRect = new Rectangle((which * 16) % TextureSheet.getTexture().Width, (which * 16) / TextureSheet.getTexture().Width * 16, this.defaultSourceRect.Width * 1, this.defaultSourceRect.Height * 1); - this.defaultSourceRect = this.sourceRect; - this.serializationName = this.GetType().ToString(); - this.ParentSheetIndex = which; - - this.animationManager = new Animations.AnimationManager(texture, new Animations.Animation(this.defaultSourceRect), false); - - this.NetFields.AddField(new NetCode.NetTexture2DExtended(this.getExtendedTexture())); - - this.InitializeBasics(0, Vector2.Zero); - } - - public MultiTileComponent(int which,String name, String description, Animations.AnimationManager animationManager) - { - this.name = name; - this.displayName = name; - this.description = description; - this.animationManager = animationManager; - this.TextureSheet = animationManager.getExtendedTexture(); - this.defaultBoundingBox = new Rectangle(0, 0, 16, 16); - this.boundingBox.Value = new Rectangle((int)0 * Game1.tileSize, (int)0 * Game1.tileSize, 1 * Game1.tileSize, 1 * Game1.tileSize); - this.defaultSourceRect.Width = 16; - this.defaultSourceRect.Height = 16; - this.sourceRect = new Rectangle(which * 16 % TextureSheet.getTexture().Width, which * 16 / TextureSheet.getTexture().Width * 16, this.defaultSourceRect.Width * 16, this.defaultSourceRect.Height * 16); - this.defaultSourceRect = this.sourceRect; - this.serializationName = this.GetType().ToString(); - this.ParentSheetIndex = which; - - this.NetFields.AddField(new NetCode.NetTexture2DExtended(this.getExtendedTexture())); - - this.InitializeBasics(0,Vector2.Zero); - } - - public override void InitializeBasics(int InvMaxSize, Vector2 tile) - { - this.inventory = new List(); - this.inventoryMaxSize = InvMaxSize; - this.TileLocation = tile; - lightsOn = false; - - lightColor = Color.Black; - - base.initNetFields(); - this.NetFields.AddField(new NetCode.Objects.NetMultiTileComponent(this)); - } - - public override bool clicked(Farmer who) - { - //Check if shift click to interact with object. - containerObject.RemoveAllObjects(); - return true; - } - - public override Item getOne() - { - if (this.animationManager != null) - { - var obj = new MultiTileComponent(this.ParentSheetIndex,this.name, this.description, this.animationManager); - obj.containerObject = this.containerObject; - return obj; - } - else - { - var obj = new MultiTileComponent(this.ParentSheetIndex,this.name, this.description, this.TextureSheet); - obj.containerObject = this.containerObject; - return obj; - } - } - - public override bool RightClicked(Farmer who) - { - return true; - } - - public override bool placementAction(GameLocation location, int x, int y, Farmer who = null) - { - Point point = new Point(x / Game1.tileSize, y / Game1.tileSize); - this.position = new Vector2(point.X, point.Y); - this.TileLocation = new Vector2((float)point.X, (float)point.Y); - this.boundingBox.Value = new Rectangle((int)TileLocation.X * Game1.tileSize, (int)TileLocation.Y * Game1.tileSize, 1 * Game1.tileSize, 1 * Game1.tileSize); - - foreach(Farmer farmer in Game1.getAllFarmers()) - { - if (location == farmer.currentLocation) - { - if (farmer.GetBoundingBox().Intersects(this.boundingBox.Value)) - { - Game1.showRedMessage("Can't place on top of a person."); - bool result = false; - return result; - } - } - } - - - this.updateDrawPosition(); - - bool f = Utilities.placementAction(this, location, x, y,StardustCore.ModCore.SerializationManager ,who); - this.thisLocation = Game1.player.currentLocation; - return f; - // Game1.showRedMessage("Can only be placed in House"); - // return false; - } - - public override void performRemoveAction(Vector2 tileLocation, GameLocation environment) - { - // Game1.showRedMessage("Why3?"); - try - { - this.heldObject.Value.performRemoveAction(this.TileLocation, this.thisLocation); - this.heldObject.Value = null; - } - catch(Exception err) - { - - } - StardustCore.ModCore.SerializationManager.trackedObjectList.Remove(this); - this.thisLocation.removeObject(this.tileLocation, false); - //this.thisLocation.objects.Remove(this.TileLocation); - this.thisLocation = null; - this.locationsName = ""; - base.performRemoveAction(tileLocation, environment); - } - - public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1f) - { - if (x == -1) - { - spriteBatch.Draw(this.TextureSheet.getTexture(), Game1.GlobalToLocal(Game1.viewport, this.drawPosition), new Rectangle?(this.sourceRect), Color.White * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, (this.Decoration_type == 12) ? 0f : ((float)(this.boundingBox.Bottom - 8) / 10000f)); - } - else - { - //The actual planter box being drawn. - if (animationManager == null) - { - if (this.TextureSheet == null) - { - ModCore.ModMonitor.Log("Tex Extended is null???"); - - } - - spriteBatch.Draw(this.TextureSheet.getTexture(), Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(x * Game1.tileSize), y * Game1.tileSize)), new Rectangle?(this.sourceRect), Color.White * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0); - // Log.AsyncG("ANIMATION IS NULL?!?!?!?!"); - } - - else - { - //Log.AsyncC("Animation Manager is working!"); - this.animationManager.draw(spriteBatch, this.animationManager.getTexture(), Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(x * Game1.tileSize), y * Game1.tileSize)), new Rectangle?(this.animationManager.currentAnimation.sourceRectangle), Color.White * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0); - try - { - this.animationManager.tickAnimation(); - // Log.AsyncC("Tick animation"); - } - catch (Exception err) - { - ModCore.ModMonitor.Log(err.ToString()); - } - } - - // spriteBatch.Draw(Game1.mouseCursors, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)((double)tileLocation.X * (double)Game1.tileSize + (((double)tileLocation.X * 11.0 + (double)tileLocation.Y * 7.0) % 10.0 - 5.0)) + (float)(Game1.tileSize / 2), (float)((double)tileLocation.Y * (double)Game1.tileSize + (((double)tileLocation.Y * 11.0 + (double)tileLocation.X * 7.0) % 10.0 - 5.0)) + (float)(Game1.tileSize / 2))), new Rectangle?(new Rectangle((int)((double)tileLocation.X * 51.0 + (double)tileLocation.Y * 77.0) % 3 * 16, 128 + this.whichForageCrop * 16, 16, 16)), Color.White, 0.0f, new Vector2(8f, 8f), (float)Game1.pixelZoom, SpriteEffects.None, (float)(((double)tileLocation.Y * (double)Game1.tileSize + (double)(Game1.tileSize / 2) + (((double)tileLocation.Y * 11.0 + (double)tileLocation.X * 7.0) % 10.0 - 5.0)) / 10000.0)); - - - - } - } - - public override void draw(SpriteBatch spriteBatch, int xNonTile, int yNonTile, float layerDepth, float alpha = 1f) - { - - if (Game1.eventUp && Game1.CurrentEvent.isTileWalkedOn(xNonTile / 64, yNonTile / 64)) - return; - if ((int)(this.ParentSheetIndex) != 590 && (int)(this.Fragility) != 2) - spriteBatch.Draw(Game1.shadowTexture, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(xNonTile + 32), (float)(yNonTile + 51 + 4))), new Microsoft.Xna.Framework.Rectangle?(Game1.shadowTexture.Bounds), Color.White * alpha, 0.0f, new Vector2((float)Game1.shadowTexture.Bounds.Center.X, (float)Game1.shadowTexture.Bounds.Center.Y), 4f, SpriteEffects.None, layerDepth - 1E-06f); - SpriteBatch spriteBatch1 = spriteBatch; - Texture2D objectSpriteSheet = Game1.objectSpriteSheet; - Vector2 local = Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(xNonTile + 32 + (this.shakeTimer > 0 ? Game1.random.Next(-1, 2) : 0)), (float)(yNonTile + 32 + (this.shakeTimer > 0 ? Game1.random.Next(-1, 2) : 0)))); - Microsoft.Xna.Framework.Rectangle? sourceRectangle = new Microsoft.Xna.Framework.Rectangle?(GameLocation.getSourceRectForObject(this.ParentSheetIndex)); - Color color = Color.White * alpha; - double num1 = 0.0; - Vector2 origin = new Vector2(8f, 8f); - Vector2 scale = this.scale; - double num2 = (double)this.scale.Y > 1.0 ? (double)this.getScale().Y : 4.0; - int num3 = (bool)(this.flipped) ? 1 : 0; - double num4 = (double)layerDepth; - spriteBatch1.Draw(TextureSheet.getTexture(), local, sourceRectangle, color, (float)num1, origin, (float)num2, (SpriteEffects)num3, (float)num4); - - } - - - - } -} diff --git a/GeneralMods/StardustCore/Objects/MultiTileObject.cs b/GeneralMods/StardustCore/Objects/MultiTileObject.cs deleted file mode 100644 index 045b8413..00000000 --- a/GeneralMods/StardustCore/Objects/MultiTileObject.cs +++ /dev/null @@ -1,247 +0,0 @@ -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using StardewValley; -using StardustCore.UIUtilities; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Runtime.Serialization.Formatters.Binary; -using System.Text; -using System.Threading.Tasks; - -namespace StardustCore.Objects -{ - public class MultiTileObject : CoreObject - { - public List> objects; - public Color categoryColor; - public String categoryName; - - public MultiTileObject() - { - - } - - public MultiTileObject(String Name, String Description,Vector2 tile, Texture2DExtended texture, List> Objects, Color CategoryColor, String CategoryName) :base(texture,0,tile,0) - { - this.objects = Objects; - this.TextureSheet = texture; - this.categoryColor = CategoryColor; - this.categoryName = CategoryName; - this.name = Name; - this.displayName = Name; - this.description = Description; - this.animationManager = new Animations.AnimationManager(this.TextureSheet, new Animations.Animation(), false); - foreach(var v in this.objects) - { - v.Value.containerObject = this; - } - - InitializeBasics(0, tile); - this.serializationName = this.GetType().ToString(); - - this.defaultSourceRect = new Rectangle(0, 0, 16, 16); - this.sourceRect = defaultSourceRect; - } - - public MultiTileObject(String Name, String Description, Vector2 tile, Animations.AnimationManager animationManager, List> Objects, Color CategoryColor, String CategoryName) - { - this.animationManager = animationManager; - this.objects = Objects; - this.TextureSheet =animationManager.getExtendedTexture(); - this.name = Name; - this.displayName = Name; - this.description = Description; - InitializeBasics(0, tile); - this.serializationName = this.GetType().ToString(); - } - - public void RemoveAllObjects() - { - if (Game1.player.isInventoryFull() == false){ - foreach (var v in this.objects) - { - v.Value.performRemoveAction(v.Value.TileLocation, v.Value.thisLocation); - } - Game1.player.addItemToInventory(this); - } - return; - } - - public override Type getCustomType() - { - return this.GetType(); - } - - public override string GetSerializationName() - { - return typeof(MultiTileObject).ToString(); - } - - public override void InitializeBasics(int InvMaxSize, Vector2 tile) - { - this.inventory = new List(); - this.inventoryMaxSize = InvMaxSize; - this.TileLocation = tile; - lightsOn = false; - - lightColor = Color.Black; - - base.initNetFields(); - this.NetFields.AddField(new NetCode.Objects.NetMultiTileObject(this)); - } - public override bool placementAction(GameLocation location, int x, int y, Farmer who = null) - { - if (canBePlacedHere(location,new Vector2(x/Game1.tileSize,y/Game1.tileSize))) - { - foreach (var pair in this.objects) - { - - pair.Value.placementAction(location, x + (int)(pair.Key.X * Game1.tileSize), y + (int)(pair.Key.Y * Game1.tileSize), who); - } - return true; - } - return false; - } - - public override bool canBePlacedHere(GameLocation l, Vector2 tile) - { - bool canBePlaced = true; - foreach (var v in this.objects) - { - canBePlaced=v.Value.canBePlacedHere(l, tile+v.Key); - if (canBePlaced == false) return false; - } - return true; - } - - public override bool clicked(Farmer who) - { - foreach (var pair in this.objects) - { - pair.Value.clicked(who); - } - return true; - } - - public override bool RightClicked(Farmer who) - { - foreach (var pair in this.objects) - { - pair.Value.RightClicked(who); - } - return true; - } - - /// - /// Need to fix this for sure!!! - /// - /// - public override Item getOne() - { - List> items = new List>(); - foreach (var pair in this.objects) - { - items.Add(new KeyValuePair(pair.Key, (pair.Value.getOne()) as MultiTileComponent)); - } - if (this.animationManager != null) - { - return new MultiTileObject(this.name, this.description, this.TileLocation, this.animationManager, items, this.categoryColor, this.categoryName); - //throw new NotImplementedException(); - } - else - { - return new MultiTileObject(this.name, this.description, this.TileLocation, this.TextureSheet, items, this.categoryColor, this.categoryName); - } - return null; - } - - public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1) - { - - foreach(var v in this.objects) - { - v.Value.draw(spriteBatch, (int)x+(int)(v.Key.X), (int)y+(int)(v.Key.Y), alpha); - } - - //base.draw(spriteBatch, x, y, alpha); - } - - public override void draw(SpriteBatch spriteBatch, int xNonTile, int yNonTile, float layerDepth, float alpha = 1) - { - foreach (var v in this.objects) - { - v.Value.draw(spriteBatch, (int)xNonTile+(int)(v.Key.X*Game1.tileSize), (int)yNonTile+ (int)(v.Key.Y * Game1.tileSize), layerDepth, alpha); - } - } - - public override void drawWhenHeld(SpriteBatch spriteBatch, Vector2 objectPosition, StardewValley.Farmer f) - { - if (animationManager == null) - { - if (this.objects == null) return; - if (this.sourceRect == null) throw new Exception("Source rect null???"); - foreach (var v in this.objects) - { - - if (v.Value.getExtendedTexture() == null) throw new Exception("Extended texture is null!"); - if (v.Value.getExtendedTexture().getTexture() == null) throw new Exception("Texture is null!"); - spriteBatch.Draw(v.Value.getExtendedTexture().getTexture(), objectPosition + new Vector2(v.Key.X * Game1.tileSize, v.Key.Y * Game1.tileSize), this.sourceRect, Color.White, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, Math.Max(0f, (float)(f.getStandingY() + 2) / 10000f)); - } - } - else - { - - foreach (var v in this.objects) - { - if(v.Value.getExtendedTexture() == null) throw new Exception("Extended texture is null!"); - if (v.Value.getExtendedTexture().getTexture() == null) throw new Exception("Texture is null!"); - spriteBatch.Draw(v.Value.animationManager.getTexture(), objectPosition + new Vector2(v.Key.X * Game1.tileSize, v.Key.Y * Game1.tileSize), this.sourceRect, Color.White, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, Math.Max(0f, (float)(f.getStandingY() + 2) / 10000f)); - } - } - - //base.drawWhenHeld(spriteBatch, objectPosition, f); - } - - public override void drawAtNonTileSpot(SpriteBatch spriteBatch, Vector2 location, float layerDepth, float alpha = 1) - { - foreach (var v in this.objects) - { - v.Value.drawAtNonTileSpot(spriteBatch, location+new Vector2(v.Key.X * Game1.tileSize, v.Key.Y * Game1.tileSize), layerDepth, alpha); - } - } - - public override void drawInMenu(SpriteBatch spriteBatch, Vector2 location, float scaleSize, float transparency, float layerDepth, bool drawStackNumber, Color c, bool drawShadows) - { - foreach (var v in this.objects) - { - if (animationManager == null) - { - //FIX SCALE SIZE AND POSITION APPROPRIATELY DEPENDING ON # OF OBJECTS!!! - //fsfsd - spriteBatch.Draw(v.Value.getExtendedTexture().getTexture(), location+new Vector2(v.Key.X*16,v.Key.Y*16), this.defaultSourceRect, Color.White * transparency, 0f, new Vector2(0, 0), 1, SpriteEffects.None, layerDepth); - } - else - { - spriteBatch.Draw(v.Value.animationManager.getTexture(), location + new Vector2(v.Key.X*8, v.Key.Y*8), v.Value.animationManager.currentAnimation.sourceRectangle, Color.White * transparency, 0f, new Vector2(0, 0), scaleSize, SpriteEffects.None, layerDepth); - //this.modularCrop.drawInMenu(spriteBatch, location + new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize / 2)), Color.White, 0f,true); - if (Game1.player.CurrentItem != this) animationManager.tickAnimation(); - } - } - } - - - public override Color getCategoryColor() - { - return this.categoryColor; - } - - public override string getCategoryName() - { - return this.name; - } - - - } -} diff --git a/GeneralMods/StardustCore/Objects/Tools/BasicToolInfo.cs b/GeneralMods/StardustCore/Objects/Tools/BasicToolInfo.cs deleted file mode 100644 index eb2866be..00000000 --- a/GeneralMods/StardustCore/Objects/Tools/BasicToolInfo.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace StardustCore.Objects.Tools -{ - public class BasicToolInfo - { - /// - /// The name of the tool. - /// - public string name; - - /// - /// The upgrade level of the tool. - /// - public int level; - - /// - /// The description of the tool. - /// - public string description; - - /// - /// Constructor used to hold generic info shared across all tools. - /// - /// - /// - /// - public BasicToolInfo(String Name, int Level, string Description) - { - this.name = Name; - this.level = Level; - this.description = Description; - } - - } -} diff --git a/GeneralMods/StardustCore/Objects/Tools/ExtendedAxe.cs b/GeneralMods/StardustCore/Objects/Tools/ExtendedAxe.cs deleted file mode 100644 index 95b6f9fd..00000000 --- a/GeneralMods/StardustCore/Objects/Tools/ExtendedAxe.cs +++ /dev/null @@ -1,142 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using StardewModdingAPI; -using StardewValley; -using StardustCore.Interfaces; -using StardustCore.Objects.Tools.SerializationInformation; -using StardustCore.UIUtilities; - -namespace StardustCore.Objects.Tools -{ - public class ExtendedAxe : StardewValley.Tools.Axe, IItemSerializeable, IToolSerializer - { - public Texture2DExtended texture; - - public override string DisplayName { get => this.displayName; set => this.displayName = value; } - public override string Name { get => this.displayName; set => this.displayName = value; } - - /// - /// Generates a default axe. Doens't really do much. - /// - public ExtendedAxe() : base() - { - this.texture = new Texture2DExtended(StardustCore.ModCore.ModHelper, ModCore.Manifest,Path.Combine("Content","Graphics","Tools","CustomAxe.png")); - } - - public ExtendedAxe(BasicToolInfo info, Texture2DExtended texture) - { - this.texture = texture; - this.displayName = info.name; - this.description = info.description; - this.UpgradeLevel = info.level; - } - - public ExtendedAxe(SerializedObjectBase dataBase) : base() - { - StardustCore.ModCore.ModMonitor.Log("WTF EVEN " + dataBase.GetType().ToString()); - StardustCore.ModCore.ModMonitor.Log((dataBase as Serialization_ExtendedAxe).Name); - this.displayName = "Hello"; - this.description = (dataBase as Serialization_ExtendedAxe).Description; - this.texture = StardustCore.ModCore.TextureManager.getTexture((dataBase as Serialization_ExtendedAxe).TextureInformation.Name); //new Texture2DExtended(StardustCore.ModCore.ModHelper, Path.Combine("Content", "Graphics", "Tools", "CustomAxe.png")); - this.UpgradeLevel = (dataBase as Serialization_ExtendedAxe).UpgradeLevel; - } - - public override void draw(SpriteBatch b) - { - base.draw(b); - } - - public override void drawInMenu(SpriteBatch spriteBatch, Vector2 location, float scaleSize, float transparency, float layerDepth, bool drawStackNumber, Color color, bool drawShadow) - { - spriteBatch.Draw(texture.getTexture(), location + new Vector2(32f, 32f), new Rectangle(0, 0, 16 , 16), color * transparency, 0.0f, new Vector2(8f, 8f), 4f * scaleSize, SpriteEffects.None, layerDepth); - } - - public Type getCustomType() - { - return this.GetType(); - } - - public string GetSerializationName() - { - return this.GetType().ToString(); - } - - public override int maximumStackSize() - { - return 1; - } - - public override bool canBeDropped() - { - return true; - } - - public override bool canBeTrashed() - { - return true; - } - - public override void setNewTileIndexForUpgradeLevel() - { - //Do nothing. - } - - /// - /// Serializes the said item properly. - /// - /// - public static void Serialize(Item I) - { - SerializationInformation.Serialization_ExtendedAxe sAxe = new SerializationInformation.Serialization_ExtendedAxe((I as ExtendedAxe)); - String savePath = ModCore.SerializationManager.playerInventoryPath; - String fileName = I.Name + ".json"; - String resultPath = Path.Combine(savePath, fileName); - int count = 0; - while (File.Exists(resultPath)) - { - resultPath=Serialization.SerializationManager.getValidSavePathIfDuplicatesExist(I, savePath,count); - count++; - } - StardustCore.ModCore.ModHelper.WriteJsonFile(resultPath, sAxe); - } - - /// - /// Serializes the said item to a chest. - /// - /// - /// - public static void SerializeToContainer(Item I, string s) - { - SerializationInformation.Serialization_ExtendedAxe sAxe = new SerializationInformation.Serialization_ExtendedAxe((I as ExtendedAxe)); - String savePath = s; - String fileName = I.Name + ".json"; - String resultPath = Path.Combine(savePath, fileName); - int count = 0; - while (File.Exists(resultPath)) - { - resultPath = Serialization.SerializationManager.getValidSavePathIfDuplicatesExist(I, savePath, count); - count++; - } - StardustCore.ModCore.ModHelper.WriteJsonFile(resultPath, sAxe); - } - - /// - /// Deserializes the object from a .json. - /// - /// - /// - public static ExtendedAxe Deserialize(string data) - { - Serialization_ExtendedAxe axeData= ModCore.ModHelper.ReadJsonFile(data); - return new ExtendedAxe(axeData); - } - - - } -} diff --git a/GeneralMods/StardustCore/Objects/Tools/ExtendedHoe.cs b/GeneralMods/StardustCore/Objects/Tools/ExtendedHoe.cs deleted file mode 100644 index 67edd662..00000000 --- a/GeneralMods/StardustCore/Objects/Tools/ExtendedHoe.cs +++ /dev/null @@ -1,142 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using StardewModdingAPI; -using StardewValley; -using StardustCore.Interfaces; -using StardustCore.Objects.Tools.SerializationInformation; -using StardustCore.UIUtilities; - -namespace StardustCore.Objects.Tools -{ - public class ExtendedHoe : StardewValley.Tools.Hoe, IItemSerializeable, IToolSerializer - { - public Texture2DExtended texture; - - public override string DisplayName { get => this.displayName; set => this.displayName = value; } - public override string Name { get => this.displayName; set => this.displayName = value; } - - /// - /// Generates a default axe. Doens't really do much. - /// - public ExtendedHoe() : base() - { - this.texture = new Texture2DExtended(StardustCore.ModCore.ModHelper,ModCore.Manifest ,Path.Combine("Content", "Graphics", "Tools", "CustomAxe.png")); - } - - public ExtendedHoe(BasicToolInfo info, Texture2DExtended texture) - { - this.texture = texture; - this.displayName = info.name; - this.description = info.description; - this.UpgradeLevel = info.level; - } - - public ExtendedHoe(SerializedObjectBase dataBase) : base() - { - StardustCore.ModCore.ModMonitor.Log("WTF EVEN " + dataBase.GetType().ToString()); - StardustCore.ModCore.ModMonitor.Log((dataBase as Serialization_ExtendedHoe).Name); - this.displayName = "Hello"; - this.description = (dataBase as Serialization_ExtendedHoe).Description; - this.texture = StardustCore.ModCore.TextureManager.getTexture((dataBase as Serialization_ExtendedHoe).TextureInformation.Name); - this.UpgradeLevel = (dataBase as Serialization_ExtendedHoe).UpgradeLevel; - } - - public override bool canBeDropped() - { - return true; - } - - public override bool canBeTrashed() - { - return true; - } - - public override void draw(SpriteBatch b) - { - base.draw(b); - } - - public override void drawInMenu(SpriteBatch spriteBatch, Vector2 location, float scaleSize, float transparency, float layerDepth, bool drawStackNumber, Color color, bool drawShadow) - { - spriteBatch.Draw(texture.getTexture(), location + new Vector2(32f, 32f), new Rectangle(0, 0, 16, 16), color * transparency, 0.0f, new Vector2(8f, 8f), 4f * scaleSize, SpriteEffects.None, layerDepth); - } - - public Type getCustomType() - { - return this.GetType(); - } - - public string GetSerializationName() - { - return this.GetType().ToString(); - } - - public override int maximumStackSize() - { - return 1; - } - - public override void setNewTileIndexForUpgradeLevel() - { - //Do nothing. - } - - /// - /// Serializes the said item properly. - /// - /// - public static void Serialize(Item I) - { - SerializationInformation.Serialization_ExtendedHoe sAxe = new SerializationInformation.Serialization_ExtendedHoe((I as ExtendedHoe)); - String savePath = ModCore.SerializationManager.playerInventoryPath; - String fileName = I.Name + ".json"; - String resultPath = Path.Combine(savePath, fileName); - int count = 0; - while (File.Exists(resultPath)) - { - resultPath = Serialization.SerializationManager.getValidSavePathIfDuplicatesExist(I, savePath, count); - count++; - } - StardustCore.ModCore.ModHelper.WriteJsonFile(resultPath, sAxe); - } - - /// - /// Serializes the said item to a chest. - /// - /// - /// - public static void SerializeToContainer(Item I, string s) - { - SerializationInformation.Serialization_ExtendedHoe sAxe = new SerializationInformation.Serialization_ExtendedHoe((I as ExtendedHoe)); - String savePath = s; - String fileName = I.Name + ".json"; - String resultPath = Path.Combine(savePath, fileName); - int count = 0; - while (File.Exists(resultPath)) - { - resultPath = Serialization.SerializationManager.getValidSavePathIfDuplicatesExist(I, savePath, count); - count++; - } - StardustCore.ModCore.ModHelper.WriteJsonFile(resultPath, sAxe); - } - - /// - /// Deserializes the object from a .json. - /// - /// - /// - public static ExtendedHoe Deserialize(string data) - { - Serialization_ExtendedHoe axeData = ModCore.ModHelper.ReadJsonFile(data); - return new ExtendedHoe(axeData); - } - - - } -} diff --git a/GeneralMods/StardustCore/Objects/Tools/ExtendedPickaxe.cs b/GeneralMods/StardustCore/Objects/Tools/ExtendedPickaxe.cs deleted file mode 100644 index c03720f2..00000000 --- a/GeneralMods/StardustCore/Objects/Tools/ExtendedPickaxe.cs +++ /dev/null @@ -1,142 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using StardewModdingAPI; -using StardewValley; -using StardustCore.Interfaces; -using StardustCore.Objects.Tools.SerializationInformation; -using StardustCore.UIUtilities; - -namespace StardustCore.Objects.Tools -{ - public class ExtendedPickaxe : StardewValley.Tools.Pickaxe, IItemSerializeable, IToolSerializer - { - public Texture2DExtended texture; - - public override string DisplayName { get => this.displayName; set => this.displayName = value; } - public override string Name { get => this.displayName; set => this.displayName = value; } - - /// - /// Generates a default axe. Doens't really do much. - /// - public ExtendedPickaxe() : base() - { - this.texture = new Texture2DExtended(StardustCore.ModCore.ModHelper, ModCore.Manifest,Path.Combine("Content", "Graphics", "Tools", "CustomAxe.png")); - } - - public ExtendedPickaxe(BasicToolInfo info, Texture2DExtended texture) - { - this.texture = texture; - this.displayName = info.name; - this.description = info.description; - this.UpgradeLevel = info.level; - } - - public ExtendedPickaxe(SerializedObjectBase dataBase) : base() - { - StardustCore.ModCore.ModMonitor.Log("WTF EVEN " + dataBase.GetType().ToString()); - StardustCore.ModCore.ModMonitor.Log((dataBase as Serialization_ExtendedPickaxe).Name); - this.displayName = "Hello"; - this.description = (dataBase as Serialization_ExtendedPickaxe).Description; - this.texture = this.texture = StardustCore.ModCore.TextureManager.getTexture((dataBase as Serialization_ExtendedPickaxe).TextureInformation.Name); - this.UpgradeLevel = (dataBase as Serialization_ExtendedPickaxe).UpgradeLevel; - } - - public override bool canBeDropped() - { - return true; - } - - public override bool canBeTrashed() - { - return true; - } - - public override void draw(SpriteBatch b) - { - base.draw(b); - } - - public override void drawInMenu(SpriteBatch spriteBatch, Vector2 location, float scaleSize, float transparency, float layerDepth, bool drawStackNumber, Color color, bool drawShadow) - { - spriteBatch.Draw(texture.getTexture(), location + new Vector2(32f, 32f), new Rectangle(0, 0, 16, 16), color * transparency, 0.0f, new Vector2(8f, 8f), 4f * scaleSize, SpriteEffects.None, layerDepth); - } - - public Type getCustomType() - { - return this.GetType(); - } - - public string GetSerializationName() - { - return this.GetType().ToString(); - } - - public override int maximumStackSize() - { - return 1; - } - - public override void setNewTileIndexForUpgradeLevel() - { - //Do nothing. - } - - /// - /// Serializes the said item properly. - /// - /// - public static void Serialize(Item I) - { - SerializationInformation.Serialization_ExtendedPickaxe sAxe = new SerializationInformation.Serialization_ExtendedPickaxe((I as ExtendedPickaxe)); - String savePath = ModCore.SerializationManager.playerInventoryPath; - String fileName = I.Name + ".json"; - String resultPath = Path.Combine(savePath, fileName); - int count = 0; - while (File.Exists(resultPath)) - { - resultPath = Serialization.SerializationManager.getValidSavePathIfDuplicatesExist(I, savePath, count); - count++; - } - StardustCore.ModCore.ModHelper.WriteJsonFile(resultPath, sAxe); - } - - /// - /// Serializes the said item to a chest. - /// - /// - /// - public static void SerializeToContainer(Item I, string s) - { - SerializationInformation.Serialization_ExtendedPickaxe sAxe = new SerializationInformation.Serialization_ExtendedPickaxe((I as ExtendedPickaxe)); - String savePath = s; - String fileName = I.Name + ".json"; - String resultPath = Path.Combine(savePath, fileName); - int count = 0; - while (File.Exists(resultPath)) - { - resultPath = Serialization.SerializationManager.getValidSavePathIfDuplicatesExist(I, savePath, count); - count++; - } - StardustCore.ModCore.ModHelper.WriteJsonFile(resultPath, sAxe); - } - - /// - /// Deserializes the object from a .json. - /// - /// - /// - public static ExtendedPickaxe Deserialize(string data) - { - Serialization_ExtendedPickaxe axeData = ModCore.ModHelper.ReadJsonFile(data); - return new ExtendedPickaxe(axeData); - } - - - } -} diff --git a/GeneralMods/StardustCore/Objects/Tools/ExtendedWateringCan.cs b/GeneralMods/StardustCore/Objects/Tools/ExtendedWateringCan.cs deleted file mode 100644 index 48b90d38..00000000 --- a/GeneralMods/StardustCore/Objects/Tools/ExtendedWateringCan.cs +++ /dev/null @@ -1,156 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using StardewModdingAPI; -using StardewValley; -using StardustCore.Interfaces; -using StardustCore.Objects.Tools.SerializationInformation; -using StardustCore.UIUtilities; - -namespace StardustCore.Objects.Tools -{ - public class ExtendedWateringCan : StardewValley.Tools.WateringCan, IItemSerializeable, IToolSerializer - { - public Texture2DExtended texture; - - public override string DisplayName { get => this.displayName; set => this.displayName = value; } - public override string Name { get => this.displayName; set => this.displayName = value; } - - /// - /// Generates a default axe. Doens't really do much. - /// - public ExtendedWateringCan() : base() - { - this.texture = new Texture2DExtended(StardustCore.ModCore.ModHelper, ModCore.Manifest,Path.Combine("Content", "Graphics", "Tools", "CustomAxe.png")); - this.waterCanMax = 30; - this.WaterLeft = 0; - } - - public ExtendedWateringCan(BasicToolInfo info, Texture2DExtended texture, int waterMax, int waterCurrent) - { - this.texture = texture; - this.displayName = info.name; - this.description = info.description; - this.UpgradeLevel = info.level; - this.waterCanMax = waterMax; - this.WaterLeft = waterCurrent; - } - - public ExtendedWateringCan(SerializedObjectBase dataBase) : base() - { - StardustCore.ModCore.ModMonitor.Log((dataBase as Serialization_ExtendedWateringCan).Name); - this.displayName = "Hello"; - this.description = (dataBase as Serialization_ExtendedWateringCan).Description; - this.texture = StardustCore.ModCore.TextureManager.getTexture((dataBase as Serialization_ExtendedWateringCan).TextureInformation.Name); - this.UpgradeLevel = (dataBase as Serialization_ExtendedWateringCan).UpgradeLevel; - this.waterCanMax= (dataBase as Serialization_ExtendedWateringCan).MaxCapacity; - this.WaterLeft= (dataBase as Serialization_ExtendedWateringCan).WaterLeft; - } - - public override void draw(SpriteBatch b) - { - base.draw(b); - } - - public override void drawInMenu(SpriteBatch spriteBatch, Vector2 location, float scaleSize, float transparency, float layerDepth, bool drawStackNumber, Color color, bool drawShadow) - { - spriteBatch.Draw(texture.getTexture(), location + new Vector2(32f, 32f), new Rectangle(0, 0, 16, 16), color * transparency, 0.0f, new Vector2(8f, 8f), 4f * scaleSize, SpriteEffects.None, layerDepth); - if (!drawStackNumber || Game1.player.hasWateringCanEnchantment) - return; - spriteBatch.Draw(Game1.mouseCursors, location + new Vector2(4f, 44f), new Rectangle?(new Rectangle(297, 420, 14, 5)), Color.White * transparency, 0.0f, Vector2.Zero, 4f, SpriteEffects.None, layerDepth + 0.0001f); - spriteBatch.Draw(Game1.staminaRect, new Rectangle((int)location.X + 8, (int)location.Y + 64 - 16, (int)((double)this.WaterLeft / (double)this.waterCanMax * 48.0), 8), Color.DodgerBlue * 0.7f * transparency); - } - - public override bool canBeDropped() - { - return true; - } - - public override bool canBeTrashed() - { - return true; - } - - public Type getCustomType() - { - return this.GetType(); - } - - public string GetSerializationName() - { - return this.GetType().ToString(); - } - - public override int maximumStackSize() - { - return 1; - } - - public override void setNewTileIndexForUpgradeLevel() - { - //Do nothing. - } - - public void upgradeWateringCapacity(int amount) - { - this.waterCanMax += amount; - } - - /// - /// Serializes the said item properly. - /// - /// - public static void Serialize(Item I) - { - SerializationInformation.Serialization_ExtendedWateringCan tool = new SerializationInformation.Serialization_ExtendedWateringCan((I as ExtendedWateringCan)); - String savePath = ModCore.SerializationManager.playerInventoryPath; - String fileName = I.Name + ".json"; - String resultPath = Path.Combine(savePath, fileName); - int count = 0; - while (File.Exists(resultPath)) - { - resultPath = Serialization.SerializationManager.getValidSavePathIfDuplicatesExist(I, savePath, count); - count++; - } - StardustCore.ModCore.ModHelper.WriteJsonFile(resultPath, tool); - } - - /// - /// Serializes the said item to a chest. - /// - /// - /// - public static void SerializeToContainer(Item I, string s) - { - SerializationInformation.Serialization_ExtendedWateringCan tool = new SerializationInformation.Serialization_ExtendedWateringCan((I as ExtendedWateringCan)); - String savePath = s; - String fileName = I.Name + ".json"; - String resultPath = Path.Combine(savePath, fileName); - int count = 0; - while (File.Exists(resultPath)) - { - resultPath = Serialization.SerializationManager.getValidSavePathIfDuplicatesExist(I, savePath, count); - count++; - } - StardustCore.ModCore.ModHelper.WriteJsonFile(resultPath, tool); - } - - /// - /// Deserializes the object from a .json. - /// - /// - /// - public static ExtendedWateringCan Deserialize(string data) - { - SerializationInformation.Serialization_ExtendedWateringCan toolData = ModCore.ModHelper.ReadJsonFile< SerializationInformation.Serialization_ExtendedWateringCan>(data); - return new ExtendedWateringCan(toolData); - } - - - } -} diff --git a/GeneralMods/StardustCore/Objects/Tools/SerializationInformation/Serialization_ExtendedAxe.cs b/GeneralMods/StardustCore/Objects/Tools/SerializationInformation/Serialization_ExtendedAxe.cs deleted file mode 100644 index fc296b61..00000000 --- a/GeneralMods/StardustCore/Objects/Tools/SerializationInformation/Serialization_ExtendedAxe.cs +++ /dev/null @@ -1,43 +0,0 @@ -using StardustCore.Interfaces; -using StardustCore.Objects.Tools.SerializationInformation; -using StardustCore.UIUtilities; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace StardustCore.Objects.Tools.SerializationInformation -{ - public class Serialization_ExtendedAxe : SerializedObjectBase - { - public string Name; - public string Description; - public int UpgradeLevel; - public Texture2DExtended TextureInformation; - - public Serialization_ExtendedAxe() : base() - { - this.SerializationName = GetSerializationName(); - } - - public Serialization_ExtendedAxe(ExtendedAxe axe) : base() - { - this.UpgradeLevel = axe.UpgradeLevel; - this.Name = axe.Name; - this.Description = axe.description; - this.TextureInformation = axe.texture; - this.SerializationName = GetSerializationName(); - } - - public override Type getCustomType() - { - return typeof(ExtendedAxe); - } - - public override string GetSerializationName() - { - return typeof(ExtendedAxe).ToString(); - } - } -} diff --git a/GeneralMods/StardustCore/Objects/Tools/SerializationInformation/Serialization_ExtendedHoe.cs b/GeneralMods/StardustCore/Objects/Tools/SerializationInformation/Serialization_ExtendedHoe.cs deleted file mode 100644 index a314f0c6..00000000 --- a/GeneralMods/StardustCore/Objects/Tools/SerializationInformation/Serialization_ExtendedHoe.cs +++ /dev/null @@ -1,43 +0,0 @@ -using StardustCore.Interfaces; -using StardustCore.Objects.Tools.SerializationInformation; -using StardustCore.UIUtilities; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace StardustCore.Objects.Tools.SerializationInformation -{ - public class Serialization_ExtendedHoe : SerializedObjectBase - { - public string Name; - public string Description; - public int UpgradeLevel; - public Texture2DExtended TextureInformation; - - public Serialization_ExtendedHoe() : base() - { - this.SerializationName = GetSerializationName(); - } - - public Serialization_ExtendedHoe(ExtendedHoe axe) : base() - { - this.UpgradeLevel = axe.UpgradeLevel; - this.Name = axe.Name; - this.Description = axe.description; - this.TextureInformation = axe.texture; - this.SerializationName = GetSerializationName(); - } - - public override Type getCustomType() - { - return typeof(ExtendedHoe); - } - - public override string GetSerializationName() - { - return typeof(ExtendedHoe).ToString(); - } - } -} diff --git a/GeneralMods/StardustCore/Objects/Tools/SerializationInformation/Serialization_ExtendedPickaxe.cs b/GeneralMods/StardustCore/Objects/Tools/SerializationInformation/Serialization_ExtendedPickaxe.cs deleted file mode 100644 index 15a78bd3..00000000 --- a/GeneralMods/StardustCore/Objects/Tools/SerializationInformation/Serialization_ExtendedPickaxe.cs +++ /dev/null @@ -1,42 +0,0 @@ -using StardustCore.Interfaces; -using StardustCore.UIUtilities; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace StardustCore.Objects.Tools.SerializationInformation -{ - public class Serialization_ExtendedPickaxe : SerializedObjectBase - { - public string Name; - public string Description; - public int UpgradeLevel; - public Texture2DExtended TextureInformation; - - public Serialization_ExtendedPickaxe() : base() - { - this.SerializationName = GetSerializationName(); - } - - public Serialization_ExtendedPickaxe(ExtendedPickaxe axe) : base() - { - this.UpgradeLevel = axe.UpgradeLevel; - this.Name = axe.Name; - this.Description = axe.description; - this.TextureInformation = axe.texture; - this.SerializationName = GetSerializationName(); - } - - public override Type getCustomType() - { - return typeof(ExtendedPickaxe); - } - - public override string GetSerializationName() - { - return typeof(ExtendedPickaxe).ToString(); - } - } -} diff --git a/GeneralMods/StardustCore/Objects/Tools/SerializationInformation/Serialization_ExtendedWateringCan.cs b/GeneralMods/StardustCore/Objects/Tools/SerializationInformation/Serialization_ExtendedWateringCan.cs deleted file mode 100644 index 7f99ebd7..00000000 --- a/GeneralMods/StardustCore/Objects/Tools/SerializationInformation/Serialization_ExtendedWateringCan.cs +++ /dev/null @@ -1,46 +0,0 @@ -using StardustCore.Interfaces; -using StardustCore.UIUtilities; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace StardustCore.Objects.Tools.SerializationInformation -{ - public class Serialization_ExtendedWateringCan : SerializedObjectBase - { - public string Name; - public string Description; - public int UpgradeLevel; - public Texture2DExtended TextureInformation; - public int MaxCapacity; - public int WaterLeft; - - public Serialization_ExtendedWateringCan() : base() - { - this.SerializationName = GetSerializationName(); - } - - public Serialization_ExtendedWateringCan(ExtendedWateringCan tool) : base() - { - this.UpgradeLevel = tool.UpgradeLevel; - this.Name = tool.Name; - this.Description = tool.description; - this.TextureInformation = tool.texture; - this.SerializationName = GetSerializationName(); - this.MaxCapacity = tool.waterCanMax; - this.WaterLeft = tool.WaterLeft; - } - - public override Type getCustomType() - { - return typeof(ExtendedWateringCan); - } - - public override string GetSerializationName() - { - return typeof(ExtendedWateringCan).ToString(); - } - } -} diff --git a/GeneralMods/StardustCore/Objects/Tools/SerializationInformation/SerializedObjectBase.cs b/GeneralMods/StardustCore/Objects/Tools/SerializationInformation/SerializedObjectBase.cs deleted file mode 100644 index c315a1e5..00000000 --- a/GeneralMods/StardustCore/Objects/Tools/SerializationInformation/SerializedObjectBase.cs +++ /dev/null @@ -1,29 +0,0 @@ -using StardustCore.Interfaces; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace StardustCore.Objects.Tools.SerializationInformation -{ - public class SerializedObjectBase : IItemSerializeable - { - public string SerializationName; - - public SerializedObjectBase() - { - this.SerializationName = this.GetSerializationName(); - } - - public virtual Type getCustomType() - { - return this.GetType(); - } - - public virtual string GetSerializationName() - { - return this.GetType().ToString(); - } - } -} diff --git a/GeneralMods/StardustCore/Serialization/Serialization.cs b/GeneralMods/StardustCore/Serialization/Serialization.cs deleted file mode 100644 index b432640a..00000000 --- a/GeneralMods/StardustCore/Serialization/Serialization.cs +++ /dev/null @@ -1,971 +0,0 @@ -using Microsoft.Xna.Framework; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using StardewModdingAPI; -using StardewValley; -using StardewValley.Buildings; -using StardewValley.Objects; -using StardustCore.Interfaces; -using StardustCore.Objects.Tools; -using StardustCore.Objects.Tools.SerializationInformation; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Xml; - -namespace StardustCore.Serialization -{ - - /// - /// TODO: Find a way to serialize objects and tools. - /// - - - public class SerializationManager - { - public string objectsInWorldPath; - public string playerInventoryPath; - public string serializerTrashPath; - public string storageContainerPath; - - - public Dictionary acceptedTypes = new Dictionary(); - public List trackedObjectList = new List(); - - - - public SerializationManager(string PlayerInventoryPath,string SerializerTrashPath,string ObjectsInWorldPath,string StorageContainerPath) - { - objectsInWorldPath = ObjectsInWorldPath; - playerInventoryPath = PlayerInventoryPath; - serializerTrashPath = SerializerTrashPath; - storageContainerPath = StorageContainerPath; - verifyAllDirectoriesExist(); - } - - private void verifyAllDirectoriesExist() - { - if (!Directory.Exists(playerInventoryPath)) Directory.CreateDirectory(playerInventoryPath); - if (!Directory.Exists(serializerTrashPath)) Directory.CreateDirectory(serializerTrashPath); - if (!Directory.Exists(objectsInWorldPath)) Directory.CreateDirectory(objectsInWorldPath); - if (!Directory.Exists(storageContainerPath)) Directory.CreateDirectory(storageContainerPath); - } - - public void cleanUpInventory() - { - - return; - - ProcessDirectoryForDeletion(playerInventoryPath); - - //ProcessDirectoryForDeletion(SerializerTrashPath); - - List removalList = new List(); - foreach (Item d in Game1.player.Items) - { - try - { - if (d == null) - { - //Log.AsyncG("WTF"); - continue; - } - // Log.AsyncC(d.GetType()); - } - catch (Exception err) - { - ModCore.ModMonitor.Log(err.ToString()); - } - - string s = Convert.ToString((d.GetType())); - - if (acceptedTypes.ContainsKey(s)) - { - SerializerDataNode t; - - bool works = acceptedTypes.TryGetValue(s, out t); - if (works == true) - { - t.serialize.Invoke(d); - removalList.Add(d); - } - } - } - foreach (var i in removalList) - { - Game1.player.removeItemFromInventory(i); - } - - if (Game1.IsMasterGame) - { - foreach (Farmer f in Game1.getAllFarmhands()) - { - List farmHandCleaner = new List(); - foreach (Item i in f.Items) - { - if (i == null) continue; - string s = Convert.ToString((i.GetType())); - - if (acceptedTypes.ContainsKey(s)) - { - SerializerDataNode t; - - bool works = acceptedTypes.TryGetValue(s, out t); - if (works == true) - { - farmHandCleaner.Add(i); - } - } - - - } - foreach(Item i in farmHandCleaner) - { - f.removeItemFromInventory(i); - } - } - } - removalList.Clear(); - } - - /// - /// Removes custom objects from the world and saves them to a file. - /// - public void cleanUpWorld() - { - return; - - try - { - ProcessDirectoryForDeletion(objectsInWorldPath); - } - catch(Exception e) - { - ModCore.ModMonitor.Log(e.ToString()); - } - List removalList = new List(); - int countProcessed = 0; - List idk = new List(); - - List allLocations = new List(); - foreach (GameLocation location in Game1.locations) - { - allLocations.Add(location); - } - foreach(Building b in Game1.getFarm().buildings) - { - allLocations.Add(b.indoors); - } - - foreach(GameLocation loc in allLocations) - { - foreach(var layer in loc.objects) - { - foreach(var pair in layer) - { - if (removalList.Contains((pair.Value as CoreObject))) continue; - try - { - if (pair.Value == null) - { - //Log.AsyncG("WTF"); - continue; - } - // Log.AsyncC(d.GetType()); - } - catch (Exception e) - { - //ModCore.ModMonitor.Log(e.ToString()); - } - string s = Convert.ToString((pair.Value.GetType())); - - if (acceptedTypes.ContainsKey(s)) - { - // Log.AsyncM("Object is of accepted type: " + s); - SerializerDataNode t; - - bool works = acceptedTypes.TryGetValue(s, out t); - if (works == true) - { - countProcessed++; - if ((pair.Value as CoreObject).useXML == false) - { - // Log.AsyncY("Saving the object"); - //Removes the object from the world and saves it to a file. - t.worldObj.Invoke((pair.Value as CoreObject)); - } - else - { - idk.Add((pair.Value as CoreObject)); - } - // Log.AsyncC("Progress on saving objects: " + countProcessed + "/" + Lists.trackedObjectList.Count); - removalList.Add((pair.Value as CoreObject)); - } - } - } - } - } - - foreach (CoreObject d in trackedObjectList) - { - - if (removalList.Contains(d)) continue; - try - { - if (d == null) - { - //Log.AsyncG("WTF"); - continue; - } - // Log.AsyncC(d.GetType()); - } - catch (Exception e) - { - //ModCore.ModMonitor.Log(e.ToString()); - } - string s = Convert.ToString((d.GetType())); - - if (acceptedTypes.ContainsKey(s)) - { - // Log.AsyncM("Object is of accepted type: " + s); - SerializerDataNode t; - - bool works = acceptedTypes.TryGetValue(s, out t); - if (works == true) - { - countProcessed++; - if (d.useXML == false) - { - // Log.AsyncY("Saving the object"); - //Removes the object from the world and saves it to a file. - t.worldObj.Invoke(d); - } - else - { - idk.Add(d); - } - // Log.AsyncC("Progress on saving objects: " + countProcessed + "/" + Lists.trackedObjectList.Count); - removalList.Add(d); - } - } - } - foreach (var i in removalList) - { - if (i.getCustomType() == typeof(CoreObject)) - { - (i as CoreObject).thisLocation.removeObject((i as CoreObject).TileLocation, false); - } - } - foreach (var v in idk) - { - string s = Convert.ToString((v.GetType())); - - if (acceptedTypes.ContainsKey(s)) - { - SerializerDataNode t; - - bool works = acceptedTypes.TryGetValue(s, out t); - if (works == true) - { - countProcessed++; - //If the item is a core object I can validate that it is in the world and not in an inventory. - if ((v is CoreObject)) - { - if ((v as CoreObject).useXML == true) - { - t.worldObj.Invoke(v as CoreObject); - } - //Log.AsyncG("Progress on saving objects: " + countProcessed + "/" + Lists.trackedObjectList.Count); - removalList.Add(v as CoreObject); - } - } - } - } - - removalList.Clear(); - // Log.AsyncM("Revitalize: Done cleaning world for saving."); - - } - - /// - /// Clean all of the storage containers in the game from custom objects. - /// - public void cleanUpStorageContainers() - { - return; - ProcessDirectoryForDeletion(storageContainerPath); - - List removalList = new List(); - foreach (GameLocation loc in Game1.locations) - { - int i = loc.objects.Pairs.Count(); - int j = 0; - foreach (KeyValuePair obj in loc.objects.Pairs) - { - j++; - //ModCore.ModMonitor.Log("Parsing location " + loc.Name + " : object number" + j + "/" + i + " : object name: " + obj.Value.name); - - //If the object is a chest get the items from it. - if (obj.Value is StardewValley.Objects.Chest) { - int k = (obj.Value as StardewValley.Objects.Chest).items.Count; - int l = 0; - foreach (var item in (obj.Value as StardewValley.Objects.Chest).items) - { - l++; - //ModCore.ModMonitor.Log("Parsing Chest at : " + loc.Name + " X: " + obj.Key.X + " Y: " + obj.Key.Y + " : object number: " + l + "/" + k + "object name: " + item.Name); - if (item is IItemSerializeable) removalList.Add(item); - } - - foreach(var v in removalList) - { - (obj.Value as StardewValley.Objects.Chest).items.Remove(v); - - SerializerDataNode t; - if (acceptedTypes.ContainsKey((v as IItemSerializeable).GetSerializationName())) - { - acceptedTypes.TryGetValue((v as IItemSerializeable).GetSerializationName(), out t); - string s = Path.Combine(loc.Name, "Chest," + Convert.ToString((int)obj.Key.X) + "," + Convert.ToString((int)obj.Key.Y)); - string s2 = Path.Combine(ModCore.SerializationManager.storageContainerPath, s); - if (!Directory.Exists(s)) Directory.CreateDirectory(s2); - t.serializeToContainer.Invoke(v, s2); - } - } - removalList.Clear(); - } - } - } - if (Game1.getFarm() == null) return; - if (Game1.getFarm().buildings == null) return; - //Look through all farm buildings for custom items. - foreach (Building building in Game1.getFarm().buildings) - { - if (building == null) continue; - if (String.IsNullOrEmpty(building.nameOfIndoors)) continue; - GameLocation loc =Game1.getLocationFromName(building.nameOfIndoors,true); - //ModCore.ModMonitor.Log("Cleaning up farm building: "+loc.uniqueName.Value); - int i = loc.objects.Pairs.Count(); - int j = 0; - foreach (KeyValuePair obj in loc.objects.Pairs) - { - j++; - //ModCore.ModMonitor.Log("Parsing location " + loc.Name + " : object number" + j + "/" + i + " : object name: " + obj.Value.name); - //Look through all chests in all farm buildings. - if (obj.Value is StardewValley.Objects.Chest) - { - int k = (obj.Value as StardewValley.Objects.Chest).items.Count; - int l = 0; - foreach (var item in (obj.Value as StardewValley.Objects.Chest).items) - { - l++; - //ModCore.ModMonitor.Log("Parsing Chest at : " + loc.Name + " X: " + obj.Key.X + " Y: " + obj.Key.Y + " : object number: " + l + "/" + k + "object name: " + item.Name); - if (item is IItemSerializeable) removalList.Add(item); - } - foreach(var v in removalList) - { - (obj.Value as StardewValley.Objects.Chest).items.Remove(v); - - SerializerDataNode t; - if(acceptedTypes.ContainsKey((v as IItemSerializeable).GetSerializationName())){ - acceptedTypes.TryGetValue((v as IItemSerializeable).GetSerializationName(), out t); - string s = Path.Combine(building.nameOfIndoors, "Chest,"+Convert.ToString( (int)obj.Key.X)+","+Convert.ToString((int)obj.Key.Y)); - string s2 = Path.Combine(ModCore.SerializationManager.storageContainerPath, s); - if (!Directory.Exists(s)) Directory.CreateDirectory(s2); - t.serializeToContainer.Invoke(v, s2); - } - } - removalList.Clear(); - } - } - } - } - - /// - /// Reloads all modded objects added by this mod back to the game in proper locations. - /// - /// - public void restoreAllModObjects(List thingsToAddBackIn, bool onlyInventory=false) - { - return; - processDirectoryForDeserialization(playerInventoryPath,thingsToAddBackIn); - if (onlyInventory) return; - - // Log.AsyncG("Done deserializing player inventory."); - try - { - trackedObjectList.Clear(); //clear whatever mod objects I'm tracking - processDirectoryForDeserialization(objectsInWorldPath,thingsToAddBackIn); //restore whatever I'm tracking here when I replace the object back into the world. This also works when loading up the game, not just when saving/loading - processDirectoryForDeserializationIntoContainer(storageContainerPath, thingsToAddBackIn); - } - catch (Exception e) - { - ModCore.ModMonitor.Log(e.ToString()); - } - } - - - public void ProcessDirectoryForDeletion(string targetDirectory) - { - // Process the list of files found in the directory. - string[] fileEntries = Directory.GetFiles(targetDirectory); - foreach (string fileName in fileEntries) - { - File.Delete(fileName); - // File.Delete(fileName); - } - - // Recurse into subdirectories of this directory. - string[] subdirectoryEntries = Directory.GetDirectories(targetDirectory); - foreach (string subdirectory in subdirectoryEntries) - ProcessDirectoryForDeletion(subdirectory); - - } - - - public void serializeXML(Item I) - { - System.Xml.Serialization.XmlSerializer xmlSerializer = new System.Xml.Serialization.XmlSerializer(typeof(T)); - var newWriter = new StringWriter(); - using (var writer = XmlWriter.Create(newWriter)) - { - xmlSerializer.Serialize(writer,I); - } - } - - /// - /// - /// - /// - /// Typically this would be the trackedObjectList. - public void processDirectoryForDeserialization(string pathToFile,List thingsToAddBackIn) - { - //StardustCore.ModCore.ModMonitor.Log("Look through dir: " + pathToFile); - string[] fileEntries = Directory.GetFiles(pathToFile); - // Log.AsyncC(pathToFile); - - foreach(var fileName in fileEntries) - { - ProcessFileForCleanUp(fileName,thingsToAddBackIn); - // Log.AsyncG(fileName); - } - - string[] subDirectories = Directory.GetDirectories(pathToFile); - foreach(var folder in subDirectories) - { - processDirectoryForDeserialization(folder,thingsToAddBackIn); - } - - } - - public void processDirectoryForDeserializationIntoContainer(string pathToFile, List thingsToAddBackIn) - { - string[] fileEntries = Directory.GetFiles(pathToFile); - // Log.AsyncC(pathToFile); - - foreach (var fileName in fileEntries) - { - ProcessFileForCleanUpIntoContainer(fileName, thingsToAddBackIn); - // Log.AsyncG(fileName); - } - - string[] subDirectories = Directory.GetDirectories(pathToFile); - foreach (var folder in subDirectories) - { - processDirectoryForDeserializationIntoContainer(folder, thingsToAddBackIn); - } - - } - - public void ProcessFileForCleanUp(string path, List thingsToAddBackIn) - { - - try - { - string type = ""; - int count = 0; - while (type == "" || type==null) - { - if (count == 0) - { - //THE ERROR LIES HERE AS IT THINKS IT CAN TRY TO BE A CORE OBJECT WHEN IT IS NOT!!!! - CoreObject core_obj = StardustCore.ModCore.ModHelper.ReadJsonFile(path); //FIND A WAY TO FIX THIS!!!! - type = (core_obj as CoreObject).serializationName; - //ModCore.ModMonitor.Log("UMM THIS CAN't BE RIGHT 1" + type); - } - - if (count == 1) - { - //THIS NEEDS TO BE SOMETHING GENERIC!!! - SerializedObjectBase core_obj = StardustCore.ModCore.ModHelper.ReadJsonFile(path); - type = (core_obj as SerializedObjectBase).SerializationName; - //ModCore.ModMonitor.Log("UMM THIS CAN't BE RIGHT 2" + type); - } - - if (count == 2) - { - ModCore.ModMonitor.Log("A valid type could not be found for the file: "+path); - return; - } - - count++; - } - - foreach (KeyValuePair pair in acceptedTypes) - { - // Log.AsyncY(pair.Key); - if (pair.Key == type) - { - try - { - //parse from Json Style - // Log.AsyncR("1"); - var cObj = pair.Value.parse.Invoke(path); - if (cObj is CoreObject) - { - (cObj as CoreObject).thisLocation = Game1.getLocationFromName((cObj as CoreObject).locationsName); - - if ((cObj as CoreObject).thisLocation == null) - { - Game1.player.addItemToInventory(cObj); - // Log.AsyncY("ADDED ITEM TO INVENTORY"); - return; - } - else - { - try - { - (cObj as CoreObject).thisLocation.objects.Add((cObj as CoreObject).TileLocation, (StardewValley.Object)cObj); - thingsToAddBackIn.Add(cObj as CoreObject); - } - catch(Exception err) - { - //throw new Exception(err.ToString()); - return; - } - //Util.placementAction(cObj, cObj.thisLocation,(int)cObj.tileLocation.X,(int) cObj.tileLocation.Y,null,false); - } - } - else - { - Game1.player.addItemToInventory(cObj); - } - } - catch (Exception e) - { - ModCore.ModMonitor.Log(e.ToString()); - // Log.AsyncO(e); - } - } - } - } - catch (Exception err) - { - ModCore.ModMonitor.Log(err.ToString()); - //Tool t = StardustCore.ModCore.ModHelper.ReadJsonFile(path); - } - - } - - - /* - /// - /// Process an item from a file back into it's original storage container. - /// - /// - /// - public void ProcessFileForCleanUpIntoContainer(string path, List thingsToAddBackIn) - { - - //Log.AsyncC(path); - string newLine = Environment.NewLine; - - string[] chestArray= path.Split(new string[] { "/"}, StringSplitOptions.None); - string[] chestArray2= path.Split(new string[] { "\\" }, StringSplitOptions.None); - /* - foreach (var v in chestArray) - { - Log.AsyncC("PART OF PATH "+v); - } - foreach (var v in chestArray2) - { - Log.AsyncC("PART OF PATH2 " + v); - } - - if (chestArray2.Length > chestArray.Length) chestArray = chestArray2; - - GameLocation loc = Game1.getLocationFromName(chestArray[chestArray.Length - 3]); - string[] chest = chestArray[chestArray.Length - 2].Split(','); - StardewValley.Object chestObject; - bool f = loc.objects.TryGetValue(new Microsoft.Xna.Framework.Vector2( Convert.ToInt32(chest[1]),Convert.ToInt32(chest[2])),out chestObject); - if (f == true) - { - ModCore.ModMonitor.Log("YAY"); - } - else - { - ModCore.ModMonitor.Log("BOO"); - } - - string[] ehh = File.ReadAllLines(path); - Item cObj; - string a; - string[] b; - string s = ""; - // Log.AsyncC(path); - // Log.AsyncC(data); - SerializedObjectBase obj = StardustCore.ModCore.ModHelper.ReadJsonFile(path); - try - { - // Log.AsyncC(obj.thisType); - - a = obj.SerializationName; - ModCore.ModMonitor.Log(":THIS IS MY TYPE!!!:" + a); - b = a.Split(','); - s = b.ElementAt(0); - // Log.AsyncC(s); - } - catch (Exception e) - { - ModCore.ModMonitor.Log(e.ToString()); - - //USE XML STYLE DESERIALIZING - foreach (KeyValuePair pair in acceptedTypes) - { - var word = ParseXMLType(path); - if (pair.Key == word.ToString()) - { - cObj = pair.Value.parse.Invoke(path); - if (cObj is CoreObject) - { - (cObj as CoreObject).thisLocation = Game1.getLocationFromName((cObj as CoreObject).locationsName); - (cObj as CoreObject).resetTexture(); - if ((cObj as CoreObject).thisLocation == null) - { - // Game1.player.addItemToInventory(cObj); - try - { - - Utilities.addItemToOtherInventory((chestObject as StardewValley.Objects.Chest).items, (cObj as CoreObject)); - } - catch (Exception err) - { - ModCore.ModMonitor.Log(err.ToString(), LogLevel.Error); - } - // Log.AsyncY("ADDED ITEM TO INVENTORY"); - return; - } - else - { - (cObj as CoreObject).thisLocation.objects.Add((cObj as CoreObject).TileLocation, (StardewValley.Object)cObj); - thingsToAddBackIn.Add((cObj as CoreObject)); - //Util.placementAction(cObj, cObj.thisLocation,(int)cObj.tileLocation.X,(int) cObj.tileLocation.Y,null,false); - } - } - else - { - - try - { - Utilities.addItemToOtherInventory((chestObject as StardewValley.Objects.Chest).items, cObj); - } - catch (Exception err) - { - ModCore.ModMonitor.Log(err.ToString(), LogLevel.Error); - } - - } - } - } - - // Log.AsyncG("attempting to parse from path and value of s is " + s); - } - - // var cObj = parseBagOfHolding(path); //pair.Value.parse.Invoke(path); - // cObj.TextureSheet = Game1.content.Load(Path.Combine("Revitalize", "CropsNSeeds", "Graphics", "seeds")); - /* - cObj.thisLocation = Game1.getLocationFromName(cObj.locationsName); - if (cObj.thisLocation == null) - { - Game1.player.addItemToInventory(cObj); - return; - } - else - { - cObj.thisLocation.objects.Add(cObj.tileLocation, cObj); - Lists.trackedObjectList.Add(cObj); - //Util.placementAction(cObj, cObj.thisLocation,(int)cObj.tileLocation.X,(int) cObj.tileLocation.Y,null,false); - } - - - //USE JSON STYLE DESERIALIZNG - if (acceptedTypes.ContainsKey(s)) - { - foreach (KeyValuePair pair in acceptedTypes) - { - // Log.AsyncY(pair.Key); - if (pair.Key == s) - { - try - { - //parse from Json Style - // Log.AsyncR("1"); - cObj = pair.Value.parse.Invoke(path); - if (cObj is CoreObject) - { - (cObj as CoreObject).thisLocation = Game1.getLocationFromName((cObj as CoreObject).locationsName); - if ((cObj as CoreObject).thisLocation == null) - { - try - { - Utilities.addItemToOtherInventory((chestObject as StardewValley.Objects.Chest).items, (cObj as CoreObject)); - - foreach (var v in (chestObject as StardewValley.Objects.Chest).items) - { - ModCore.ModMonitor.Log(v.Name); - } - - } - catch (Exception err) - { - ModCore.ModMonitor.Log(err.ToString(), LogLevel.Error); - } - // Log.AsyncY("ADDED ITEM TO INVENTORY"); - return; - } - else - { - (cObj as CoreObject).thisLocation.objects.Add((cObj as CoreObject).TileLocation, (StardewValley.Object)cObj); - thingsToAddBackIn.Add((cObj as CoreObject)); - //Util.placementAction(cObj, cObj.thisLocation,(int)cObj.tileLocation.X,(int) cObj.tileLocation.Y,null,false); - } - } - else - { - try - { - Utilities.addItemToOtherInventory((chestObject as StardewValley.Objects.Chest).items, cObj); - } - catch (Exception err) - { - ModCore.ModMonitor.Log(err.ToString(), LogLevel.Error); - } - } - - } - catch (Exception e) - { - ModCore.ModMonitor.Log(e.ToString()); - // Log.AsyncO(e); - } - } - } - } - else - { - ModCore.ModMonitor.Log("Error parsing unknown object type: " + s, LogLevel.Error); - } - - } - */ - - public void ProcessFileForCleanUpIntoContainer(string path, List thingsToAddBackIn) - { - - - - //Log.AsyncC(path); - string newLine = Environment.NewLine; - - string[] chestArray = path.Split(new string[] { "/" }, StringSplitOptions.None); - string[] chestArray2 = path.Split(new string[] { "\\" }, StringSplitOptions.None); - /* - foreach (var v in chestArray) - { - Log.AsyncC("PART OF PATH "+v); - } - foreach (var v in chestArray2) - { - Log.AsyncC("PART OF PATH2 " + v); - } - */ - if (chestArray2.Length > chestArray.Length) chestArray = chestArray2; - - GameLocation loc = Game1.getLocationFromName(chestArray[chestArray.Length - 3]); - string[] chest = chestArray[chestArray.Length - 2].Split(','); - StardewValley.Object chestObject; - bool f = loc.objects.TryGetValue(new Microsoft.Xna.Framework.Vector2(Convert.ToInt32(chest[1]), Convert.ToInt32(chest[2])), out chestObject); - - try - { - string type = ""; - int count = 0; - while (type == "" || type == null) - { - if (count == 0) - { - //THE ERROR LIES HERE AS IT THINKS IT CAN TRY TO BE A CORE OBJECT WHEN IT IS NOT!!!! - CoreObject core_obj = StardustCore.ModCore.ModHelper.ReadJsonFile(path); //FIND A WAY TO FIX THIS!!!! - type = (core_obj as CoreObject).serializationName; - //ModCore.ModMonitor.Log("UMM THIS CAN't BE RIGHT 1" + type); - } - - if (count == 1) - { - //THIS NEEDS TO BE SOMETHING GENERIC!!! - SerializedObjectBase core_obj = StardustCore.ModCore.ModHelper.ReadJsonFile(path); - type = (core_obj as SerializedObjectBase).SerializationName; - //ModCore.ModMonitor.Log("UMM THIS CAN't BE RIGHT 2" + type); - } - - if (count == 2) - { - ModCore.ModMonitor.Log("A valid type could not be found for the file: " + path); - return; - } - - count++; - } - - foreach (KeyValuePair pair in acceptedTypes) - { - // Log.AsyncY(pair.Key); - if (pair.Key == type) - { - try - { - //parse from Json Style - // Log.AsyncR("1"); - var cObj = pair.Value.parse.Invoke(path); - if (cObj is CoreObject) - { - (cObj as CoreObject).thisLocation = Game1.getLocationFromName((cObj as CoreObject).locationsName); - - if ((cObj as CoreObject).thisLocation == null) - { - Utilities.addItemToOtherInventory((chestObject as Chest).items, cObj); - // Log.AsyncY("ADDED ITEM TO INVENTORY"); - return; - } - else - { - (cObj as CoreObject).thisLocation.objects.Add((cObj as CoreObject).TileLocation, (StardewValley.Object)cObj); - thingsToAddBackIn.Add(cObj as CoreObject); - //Util.placementAction(cObj, cObj.thisLocation,(int)cObj.tileLocation.X,(int) cObj.tileLocation.Y,null,false); - } - } - else - { - Utilities.addItemToOtherInventory((chestObject as Chest).items, cObj); - } - } - catch (Exception e) - { - ModCore.ModMonitor.Log(e.ToString()); - // Log.AsyncO(e); - } - } - } - } - catch (Exception err) - { - ModCore.ModMonitor.Log(err.ToString()); - //Tool t = StardustCore.ModCore.ModHelper.ReadJsonFile(path); - } - - } - - - - -/// -/// ??? -/// -/// -/// -public string ParseXMLType(string path) - { - string[] s = File.ReadAllLines(path); - string returnString = ""; - foreach (string v in s) - { - // Log.AsyncC(v); - if (v.Contains("serializationName")) - { - returnString = v.Remove(0, 12); - returnString = returnString.Remove(returnString.Length - 11, 11); - } - - } - return returnString; - } - - /// - /// Parse rectangles. - /// - /// - /// - public static Microsoft.Xna.Framework.Rectangle parseRectFromJson(string s) - { - s = s.Replace('{', ' '); - s = s.Replace('}', ' '); - s = s.Replace('^', ' '); - s = s.Replace(':', ' '); - string[] parsed = s.Split(' '); - foreach (var v in parsed) - { - //Log.AsyncY(v); - } - return new Microsoft.Xna.Framework.Rectangle(Convert.ToInt32(parsed[2]), Convert.ToInt32(parsed[4]), Convert.ToInt32(parsed[6]), Convert.ToInt32(parsed[8])); - } - - /// - /// Remove all objects that there are a copy of this thing? - /// - /// - public void removeObjectWithCopy(CoreObject c) - { - foreach(var v in StardustCore.ModCore.SerializationManager.trackedObjectList) - { - if (v.getCustomType() == typeof(CoreObject)) - { - if (c.TileLocation == (v as CoreObject).TileLocation && c.thisLocation == (v as CoreObject).thisLocation) - { - StardustCore.ModCore.SerializationManager.trackedObjectList.Remove(v); - } - } - } - } - - /// - /// Initializes a list of default supported types added by Stardust Core. - /// - public void initializeDefaultSuportedTypes() - { - initializeSupportedToolTypes(); - initializeSupportedObjectTypes(); - } - - private void initializeSupportedObjectTypes() - { - this.acceptedTypes.Add(typeof(CoreObject).ToString(), new SerializerDataNode(CoreObject.Serialize, CoreObject.Deserialize, new SerializerDataNode.WorldParsingFunction(CoreObject.Serialize), new SerializerDataNode.SerializingToContainerFunction(CoreObject.SerializeToContainer))); - } - - /// - /// Initializes supported tools made by Stardust Core. - /// - private void initializeSupportedToolTypes() - { - this.acceptedTypes.Add(typeof(ExtendedAxe).ToString(), new SerializerDataNode(ExtendedAxe.Serialize, ExtendedAxe.Deserialize, null, new SerializerDataNode.SerializingToContainerFunction(ExtendedAxe.SerializeToContainer))); - } - - public static string getValidSavePathIfDuplicatesExist(Item I, string path, int number) - { - String savePath = path; - String fileName = I.Name + number + ".json"; - String resultPath = Path.Combine(savePath, fileName); - return resultPath; - } - } -} diff --git a/GeneralMods/StardustCore/Serialization/SerializerDataNode.cs b/GeneralMods/StardustCore/Serialization/SerializerDataNode.cs deleted file mode 100644 index 92c4a6d2..00000000 --- a/GeneralMods/StardustCore/Serialization/SerializerDataNode.cs +++ /dev/null @@ -1,73 +0,0 @@ -using StardewValley; -using StardustCore.Objects.Tools.SerializationInformation; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace StardustCore.Serialization -{ - /// - /// A class that handles saving/loading custom objects to and from the world. - /// - public class SerializerDataNode - { - /// - /// A function that handles loading an object back into it's Item form. - /// - /// The path to the file. - /// - public delegate Item ParsingFunction(string path); - /// - /// A function that handles saving an item. - /// - /// - public delegate void SerializingFunction(Item item); - - /// - /// A function that handles saving an item from/to a container. - /// - /// - /// - public delegate void SerializingToContainerFunction(Item item, string s); - - /// - /// A function that handles saving.loading items into the world. - /// - /// - public delegate void WorldParsingFunction(Item obj); - - /// - /// Saves an object to an inventory. - /// - public SerializingFunction serialize; - /// - /// Saves an object to a container - /// - public SerializingToContainerFunction serializeToContainer; - /// - /// Loads in an object. - /// - public ParsingFunction parse; - /// - /// Loads in an object to the game world. - /// - public WorldParsingFunction worldObj; - - /// - /// Constructor. - /// - /// A function to be ran to save this object. - /// A function to be ran to load this object. - /// A function to be ran to load this object to the world. - /// A function to be ran to save/load objects to storage containers such as chests. - public SerializerDataNode(SerializingFunction serializeFunction, ParsingFunction parsingFunction, WorldParsingFunction worldObjectParsingFunction, SerializingToContainerFunction containerSerializationFunction) - { - serialize = serializeFunction; - parse = parsingFunction; - worldObj = worldObjectParsingFunction; - serializeToContainer = containerSerializationFunction; - } - } -} diff --git a/GeneralMods/StardustCore/StardustCore.csproj b/GeneralMods/StardustCore/StardustCore.csproj index 5a69ed44..b0f3c63b 100644 --- a/GeneralMods/StardustCore/StardustCore.csproj +++ b/GeneralMods/StardustCore/StardustCore.csproj @@ -87,35 +87,10 @@ - - - - - - - - - - - - - - - - - - - - - - - - - @@ -130,18 +105,13 @@ - - - - - diff --git a/GeneralMods/StardustCore/Utilities.cs b/GeneralMods/StardustCore/Utilities.cs deleted file mode 100644 index efdabb01..00000000 --- a/GeneralMods/StardustCore/Utilities.cs +++ /dev/null @@ -1,673 +0,0 @@ - -using Microsoft.Xna.Framework; -using Netcode; -using StardewModdingAPI; -using StardewValley; -using StardewValley.Characters; -using StardewValley.Locations; -using StardewValley.Objects; -using StardewValley.TerrainFeatures; -using StardewValley.Tools; -using StardustCore; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using xTile.Dimensions; - -namespace StardustCore -{ - - - public class Utilities - { - - public static List masterRemovalList = new List(); - - - public static string getShortenedDirectory(string modName,string path) - { - string lol = (string)path.Clone(); - string[] spliter = lol.Split(new string[] { modName }, StringSplitOptions.None); - return spliter[1]; - } - - public static string getShortenedDirectory(IModHelper modHelper, string path) - { - string lol = (string)path.Clone(); - string[] spliter = lol.Split(new string[] { modHelper.DirectoryPath }, StringSplitOptions.None); - return spliter[1]; - } - - public static int sellToStorePrice(CoreObject c) - { - return (int)((double)c.Price * (1.0 + (double)c.Quality * 0.25)); - } - - - - /// - /// Create some object debris at my game location. - /// - /// - /// - /// - /// - /// - /// - /// - public static void createObjectDebris(int objectIndex, int xTile, int yTile, int groundLevel = -1, int itemQuality = 0, float velocityMultiplyer = 1f, GameLocation location = null) - { - if (location == null) - location = Game1.currentLocation; - Debris debris = new Debris(objectIndex, new Vector2((float)(xTile * 64 + 32), (float)(yTile * 64 + 32)), new Vector2((float)Game1.player.getStandingX(), (float)Game1.player.getStandingY())) - { - itemQuality = itemQuality - }; - foreach (Chunk chunk in (IEnumerable)debris.Chunks) - { - chunk.xVelocity.Value *= (float)(double)velocityMultiplyer; - chunk.yVelocity.Value *= (float)(double)velocityMultiplyer; - } - if (groundLevel != -1) - debris.chunkFinalYLevel = groundLevel; - location.debris.Add(debris); - } - - - - /// - /// Place a core object into a game location. - /// - /// - /// - /// - /// - /// - /// - /// - /// - public static bool placementAction(CoreObject cObj, GameLocation location, int x, int y,Serialization.SerializationManager s, StardewValley.Farmer who = null, bool playSound = true) - { - Vector2 vector = new Vector2((float)(x / Game1.tileSize), (float)(y / Game1.tileSize)); - // cObj.health = 10; - if (who != null) - { - if (cObj == null) - { - StardustCore.ModCore.ModMonitor.Log("WHY IS MY COMPONENT NULL???"); - } - cObj.owner.Value = who.UniqueMultiplayerID; - } - else - { - cObj.owner.Value = Game1.player.UniqueMultiplayerID; - } - - int num = cObj.ParentSheetIndex; - if (num <= 130) - { - if (num == 71) - { - if (location is MineShaft) - { - if ((location as MineShaft).mineLevel != 120 && (location as MineShaft).recursiveTryToCreateLadderDown(vector, "hoeHit", 16)) - { - return true; - } - Game1.showRedMessage("Unsuitable Location"); - } - return false; - } - if (num == 130) - { - if (location.objects.ContainsKey(vector) || Game1.currentLocation is MineShaft) - { - Game1.showRedMessage("Unsuitable Location"); - return false; - } - location.objects.Add(vector, new Chest(true) - { - shakeTimer = 50 - }); - Game1.playSound("axe"); - return true; - } - } - else - { - switch (num) - { - case 143: - case 144: - case 145: - case 146: - case 147: - case 148: - case 149: - case 150: - case 151: - if (location.objects.ContainsKey(vector)) - { - return false; - } - new Torch(vector, cObj.ParentSheetIndex, true) - { - shakeTimer = 25 - }.placementAction(location, x, y, who); - return true; - default: - if (num == 163) - { - location.objects.Add(vector, new Cask(vector)); - Game1.playSound("hammer"); - } - break; - } - } - - if (cObj.name.Equals("Tapper")) - { - if (location.terrainFeatures.ContainsKey(vector) && location.terrainFeatures[vector] is Tree && (location.terrainFeatures[vector] as Tree).growthStage.Value >= 5 && !(location.terrainFeatures[vector] as Tree).stump.Value && !location.objects.ContainsKey(vector)) - { - cObj.TileLocation = vector; - location.objects.Add(vector, cObj); - int treeType = (location.terrainFeatures[vector] as Tree).treeType.Value; - (location.terrainFeatures[vector] as Tree).tapped.Value = true; - switch (treeType) - { - case 1: - cObj.heldObject.Value = new StardewValley.Object(725, 1, false, -1, 0); - cObj.MinutesUntilReady = 13000 - Game1.timeOfDay; - break; - case 2: - cObj.heldObject.Value = new StardewValley.Object(724, 1, false, -1, 0); - cObj.MinutesUntilReady = 16000 - Game1.timeOfDay; - break; - case 3: - cObj.heldObject.Value = new StardewValley.Object(726, 1, false, -1, 0); - cObj.MinutesUntilReady = 10000 - Game1.timeOfDay; - break; - case 7: - cObj.heldObject.Value = new StardewValley.Object(420, 1, false, -1, 0); - cObj.MinutesUntilReady = 3000 - Game1.timeOfDay; - if (!Game1.currentSeason.Equals("fall")) - { - cObj.heldObject.Value = new StardewValley.Object(404, 1, false, -1, 0); - cObj.MinutesUntilReady = 6000 - Game1.timeOfDay; - } - break; - } - Game1.playSound("axe"); - return true; - } - return false; - } - else if (cObj.name.Contains("Sapling")) - { - Vector2 key = default(Vector2); - for (int i = x / Game1.tileSize - 2; i <= x / Game1.tileSize + 2; i++) - { - for (int j = y / Game1.tileSize - 2; j <= y / Game1.tileSize + 2; j++) - { - key.X = (float)i; - key.Y = (float)j; - if (location.terrainFeatures.ContainsKey(key) && (location.terrainFeatures[key] is Tree || location.terrainFeatures[key] is FruitTree)) - { - Game1.showRedMessage("Too close to another tree"); - return false; - } - } - } - if (location.terrainFeatures.ContainsKey(vector)) - { - if (!(location.terrainFeatures[vector] is HoeDirt) || (location.terrainFeatures[vector] as HoeDirt).crop != null) - { - return false; - } - location.terrainFeatures.Remove(vector); - } - if (location is Farm && (location.doesTileHaveProperty((int)vector.X, (int)vector.Y, "Diggable", "Back") != null || location.doesTileHavePropertyNoNull((int)vector.X, (int)vector.Y, "Type", "Back").Equals("Grass"))) - { - Game1.playSound("dirtyHit"); - DelayedAction.playSoundAfterDelay("coin", 100); - location.terrainFeatures.Add(vector, new FruitTree(cObj.ParentSheetIndex)); - return true; - } - Game1.showRedMessage("Can't be planted here."); - return false; - } - else - { - - //Game1.showRedMessage("STEP 1"); - - if (cObj.Category == -74) - { - return true; - } - if (!cObj.performDropDownAction(who)) - { - CoreObject @object = cObj; - @object.shakeTimer = 50; - @object.TileLocation = vector; - @object.performDropDownAction(who); - if (location.objects.ContainsKey(vector)) - { - if (location.objects[vector].ParentSheetIndex != cObj.ParentSheetIndex) - { - Game1.createItemDebris(location.objects[vector], vector * (float)Game1.tileSize, Game1.random.Next(4)); - location.objects[vector] = @object; - } - } - - else - { - // Game1.showRedMessage("STEP 2"); - //ModCore.ModMonitor.Log(vector.ToString()); - - Vector2 newVec = new Vector2(vector.X, vector.Y); - // cObj.boundingBox.Inflate(32, 32); - location.objects.Add(newVec, cObj); - } - @object.initializeLightSource(vector); - } - if (playSound == true) Game1.playSound("woodyStep"); - else - { - ModCore.ModMonitor.Log("restoring item from file"); - } - //Log.AsyncM("Placed and object"); - cObj.locationsName = location.Name; - s.trackedObjectList.Add(cObj); - return true; - - } - } - - - public static bool addItemToInventoryAndCleanTrackedList(CoreObject I,Serialization.SerializationManager s) - { - if (Game1.player.isInventoryFull() == false) - { - Game1.player.addItemToInventoryBool(I, false); - s.trackedObjectList.Remove(I); - return true; - } - else - { - Random random = new Random(129); - int i = random.Next(); - i = i % 4; - Vector2 v2 = new Vector2(Game1.player.getTileX() * Game1.tileSize, Game1.player.getTileY() * Game1.tileSize); - Game1.createItemDebris(I, v2, i); - return false; - } - } - - - public static Microsoft.Xna.Framework.Rectangle parseRectFromJson(string s) - { - - - - s = s.Replace('{', ' '); - s = s.Replace('}', ' '); - s = s.Replace('^', ' '); - s = s.Replace(':', ' '); - string[] parsed = s.Split(' '); - foreach (var v in parsed) - { - //Log.AsyncY(v); - } - return new Microsoft.Xna.Framework.Rectangle(Convert.ToInt32(parsed[2]), Convert.ToInt32(parsed[4]), Convert.ToInt32(parsed[6]), Convert.ToInt32(parsed[8])); - } - - /// - /// Add an object to a list fo items. - /// - /// - /// - /// - public static bool addItemToOtherInventory(List inventory, Item I) - { - if (I == null) return false; - if (isInventoryFull(inventory) == false) - { - if (inventory == null) - { - return false; - } - if (inventory.Count == 0) - { - inventory.Add(I); - return true; - } - for (int i = 0; i < inventory.Capacity; i++) - { - // Log.AsyncC("OK????"); - - foreach (var v in inventory) - { - - if (inventory.Count == 0) - { - addItemToOtherInventory(inventory, I); - return true; - } - if (v == null) continue; - if (v.canStackWith(I)) - { - v.addToStack(I.getStack()); - return true; - } - } - } - - inventory.Add(I); - return true; - } - else - { - return false; - } - } - - - /// - /// Add an object to a netList of items. - /// - /// - /// - /// - public static bool addItemToOtherInventory(NetObjectList inventory, Item I) - { - if (I == null) return false; - if (isInventoryFull(inventory) == false) - { - if (inventory == null) - { - return false; - } - if (inventory.Count == 0) - { - inventory.Add(I); - return true; - } - for (int i = 0; i < inventory.Capacity; i++) - { - // Log.AsyncC("OK????"); - - foreach (var v in inventory) - { - - if (inventory.Count == 0) - { - addItemToOtherInventory(inventory, I); - return true; - } - if (v == null) continue; - if (v.canStackWith(I)) - { - v.addToStack(I.getStack()); - return true; - } - } - } - - inventory.Add(I); - return true; - } - else - { - return false; - } - } - - /// - /// Checks whether or not the inventory list is full of items. - /// - /// - /// - /// - public static bool isInventoryFull(List inventory, bool logInfo = false) - { - if (logInfo) - { - ModCore.ModMonitor.Log("size " + inventory.Count); - ModCore.ModMonitor.Log("max " + inventory.Capacity); - } - - if (inventory.Count == inventory.Capacity) return true; - else return false; - } - - - - - /// - /// Checks whether or not the net inventory list is full of items. - /// - /// - /// - /// - public static bool isInventoryFull(NetObjectList inventory, bool logInfo = false) - { - if (logInfo) - { - ModCore.ModMonitor.Log("size " + inventory.Count); - ModCore.ModMonitor.Log("max " + inventory.Capacity); - } - - if (inventory.Count == inventory.Capacity) return true; - else return false; - } - - - public static bool isWithinRange(int tileLength,Vector2 positionToCheck) - { - Vector2 v = Game1.player.getTileLocation(); - if (v.X < positionToCheck.X - tileLength || v.X > positionToCheck.X + tileLength) return false; - if (v.Y < positionToCheck.Y - tileLength || v.Y > positionToCheck.Y + tileLength) return false; - - return true; - } - - public static bool isWithinDirectionRange(int direction,int range, Vector2 positionToCheck) - { - Vector2 v = Game1.player.getTileLocation(); - if (direction==3 && (v.X >= positionToCheck.X - range)) return true; //face left - if (direction==1 && (v.X <= positionToCheck.X + range)) return true; //face right - if (direction==0 && (v.Y <= positionToCheck.Y + range)) return true; //face up - if (direction==2 && (v.Y >= positionToCheck.Y - range)) return true; //face down - - return true; - } - - - - /// - /// Draws the green mouse cursor plus sign. - /// - public static void drawGreenPlus() - { - try - { - Game1.spriteBatch.Draw(Game1.mouseCursors, new Vector2(Game1.getMouseX() + 34, Game1.getMouseY() + 34), new Microsoft.Xna.Framework.Rectangle(0, 410, 17, 17), Color.White, 0, new Vector2(0, 0), 2f, Microsoft.Xna.Framework.Graphics.SpriteEffects.None, 0); - } - catch(Exception e) - { - e.ToString(); - } - } - - - public static StardewValley.Object checkRadiusForObject(int radius, string name) - { - for (int x = -radius; x <= radius; x++) - { - for (int y = -radius; y <= radius; y++) - { - bool f = Game1.player.currentLocation.isObjectAt((Game1.player.getTileX() + x) * Game1.tileSize, (Game1.player.getTileY() + y) * Game1.tileSize); - if (f == false) continue; - StardewValley.Object obj = Game1.player.currentLocation.getObjectAt((Game1.player.getTileX() + x) * Game1.tileSize, (Game1.player.getTileY() + y) * Game1.tileSize); - if (obj == null) continue; - if (obj.name == name) - { - return obj; - } - } - } - return null; - } - - public static StardewValley.Object checkCardinalForObject(string name) - { - for (int x = -1; x <= 1; x++) - { - for (int y = -1; y <= 1; y++) - { - if (x == -1 && y == -1) continue; //upper left - if (x == -1 && y == 1) continue; //bottom left - if (x == 1 && y == -1) continue; //upper right - if (x == 1 && y == 1) continue; //bottom right - bool f = Game1.player.currentLocation.isObjectAt((Game1.player.getTileX() + x) * Game1.tileSize, (Game1.player.getTileY() + y) * Game1.tileSize); - if (f == false) continue; - StardewValley.Object obj = Game1.player.currentLocation.getObjectAt((Game1.player.getTileX() + x) * Game1.tileSize, (Game1.player.getTileY() + y) * Game1.tileSize); - if (obj == null) continue; - if (obj.name == name) - { - return obj; - } - } - } - return null; - } - - public static void faceDirectionTowardsSomething(Vector2 tileLocation) - { - - if (tileLocation.X < Game1.player.getTileX()) - { - Game1.player.faceDirection(3); - } - else if (tileLocation.X > Game1.player.getTileX()) - { - Game1.player.faceDirection(1); - } - else if (tileLocation.Y < Game1.player.getTileY()) - { - Game1.player.faceDirection(0); - } - else if (tileLocation.Y > Game1.player.getTileY()) - { - Game1.player.faceDirection(2); - } - } - - /// - /// Checks if a game location contains an object with the exact name passed in. - /// - /// The location to check. - /// The name of the object to check. - /// - public static bool doesLocationContainObject(GameLocation location, string name) - { - foreach (KeyValuePair v in location.objects.Pairs) - { - if (name == v.Value.name) return true; - } - return false; - } - - - public static KeyValuePair checkRadiusForTerrainFeature(int radius, Type terrainType) - { - for (int x = -radius; x <= radius; x++) - { - for (int y = -radius; y <= radius; y++) - { - Vector2 pos = new Vector2((Game1.player.getTileX() + x), (Game1.player.getTileY() + y)); - bool f = Game1.player.currentLocation.isTerrainFeatureAt((int)pos.X,(int)pos.Y); - if (f == false) continue; - TerrainFeature t = Game1.player.currentLocation.terrainFeatures[pos]; //((Game1.player.getTileX() + x) * Game1.tileSize, (Game1.player.getTileY() + y) * Game1.tileSize); - if (t == null) continue; - if (t.GetType() == terrainType) - { - return new KeyValuePair (pos,t); - } - } - } - return new KeyValuePair(new Vector2(),null); - } - - public static KeyValuePair checkCardinalForTerrainFeature(Type terrainType) - { - for (int x = -1; x <= 1; x++) - { - for (int y = -1; y <= 1; y++) - { - if (x == -1 && y == -1) continue; //upper left - if (x == -1 && y == 1) continue; //bottom left - if (x == 1 && y == -1) continue; //upper right - if (x == 1 && y == 1) continue; //bottom right - Vector2 pos = new Vector2((Game1.player.getTileX() + x), (Game1.player.getTileY() + y)); - bool f = Game1.player.currentLocation.isTerrainFeatureAt((int)pos.X, (int)pos.Y); - if (f == false) continue; - TerrainFeature t = Game1.player.currentLocation.terrainFeatures[pos]; //((Game1.player.getTileX() + x) * Game1.tileSize, (Game1.player.getTileY() + y) * Game1.tileSize); - if (t == null) continue; - if (t.GetType() == terrainType) - { - return new KeyValuePair(pos, t); - } - } - } - return new KeyValuePair(new Vector2(), null); - } - - - /// - /// Checks if the game location has this terrain feature. - /// - /// The game location to check. - /// The terrain feature type to check if it exists at said location. - /// - public static bool doesLocationContainTerrainFeature(GameLocation location, Type terrain) - { - foreach (KeyValuePair v in location.terrainFeatures.Pairs) - { - if (terrain == v.Value.GetType()) return true; - } - return false; - } - - /// - /// Get an item from the player's inventory. - /// - /// The index in the player's inventory of the item. - /// - public static Item getItemFromInventory(int index) - { - foreach(var v in Game1.player.Items) - { - if (v.ParentSheetIndex == index) return v; - } - return null; - } - - /// - /// Get an item from the player's inventory. - /// - /// The name of the item in the player's inventory - /// - public static Item getItemFromInventory(string name) - { - foreach (var v in Game1.player.Items) - { - if (v.Name == name) return v; - } - return null; - } - } -} From 78b2755fba53664698b912559ae2fe5bfce57305 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sun, 30 Dec 2018 00:27:37 -0500 Subject: [PATCH 26/72] add .editorconfig to keep code style consistent --- .editorconfig | 67 +++++++++++++++++++++++++++++++++++++ GeneralMods/StardewMods.sln | 2 +- 2 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..5bfc44bd --- /dev/null +++ b/.editorconfig @@ -0,0 +1,67 @@ +# topmost editorconfig +root: true + +########## +## General formatting +## documentation: https://editorconfig.org +########## +[*] +indent_style = space +indent_size = 4 +insert_final_newline = true +trim_trailing_whitespace = true +charset = utf-8 + +[*.{csproj,json,nuspec,targets}] +indent_size = 2 + +[*.csproj] +insert_final_newline = false + +########## +## C# formatting +## documentation: https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference +########## +[*.cs] + +#sort 'system' usings first +dotnet_sort_system_directives_first = true + +# use 'this.' qualifier +dotnet_style_qualification_for_field = true:error +dotnet_style_qualification_for_property = true:error +dotnet_style_qualification_for_method = true:error +dotnet_style_qualification_for_event = true:error + +# use language keywords (like int) instead of type (like Int32) +dotnet_style_predefined_type_for_locals_parameters_members = true:error +dotnet_style_predefined_type_for_member_access = true:error + +# don't use 'var' for language keywords +csharp_style_var_for_built_in_types = false:error + +# suggest modern C# features where simpler +dotnet_style_object_initializer = true:suggestion +dotnet_style_collection_initializer = true:suggestion +dotnet_style_coalesce_expression = true:suggestion +dotnet_style_null_propagation = true:suggestion +dotnet_style_explicit_tuple_names = true:suggestion +csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion +csharp_style_pattern_matching_over_as_with_null_check = true:suggestion +csharp_style_conditional_delegate_call = true:suggestion +csharp_prefer_simple_default_expression = true:suggestion + +# prefer method block bodies +csharp_style_expression_bodied_methods = false:suggestion +csharp_style_expression_bodied_constructors = false:suggestion + +# prefer property expression bodies +csharp_style_expression_bodied_properties = true:suggestion +csharp_style_expression_bodied_indexers = true:suggestion +csharp_style_expression_bodied_accessors = true:suggestion + +# prefer inline out variables +csharp_style_inlined_variable_declaration = true:warning + +# avoid superfluous braces +csharp_prefer_braces = false:suggestion diff --git a/GeneralMods/StardewMods.sln b/GeneralMods/StardewMods.sln index 47b5fc95..5ccc93d6 100644 --- a/GeneralMods/StardewMods.sln +++ b/GeneralMods/StardewMods.sln @@ -33,9 +33,9 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TimeFreeze", "TimeFreeze\Ti EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "~metadata", "~metadata", "{90EB59CA-51F6-49CF-8DCE-A8BB62C58E17}" ProjectSection(SolutionItems) = preProject + ..\.editorconfig = ..\.editorconfig deploy.targets = deploy.targets GlobalAssemblyInfo.cs = GlobalAssemblyInfo.cs - AdditionalCropsFramework\ModularCropObject.cs = AdditionalCropsFramework\ModularCropObject.cs ..\README.md = ..\README.md EndProjectSection EndProject From 691515072bba252a8083f2c33c1339be4ec4052d Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sun, 30 Dec 2018 05:00:05 -0500 Subject: [PATCH 27/72] apply consistent code style conventions (no logic changes) --- .../AdvancedSaveBackup/Framework/ModConfig.cs | 2 +- GeneralMods/AdvancedSaveBackup/SaveBackup.cs | 2 +- GeneralMods/AutoSpeed/AutoSpeed.cs | 2 +- GeneralMods/AutoSpeed/Framework/ModConfig.cs | 2 +- .../BillboardAnywhere/BillboardAnywhere.cs | 2 +- .../BillboardAnywhere/Framework/ModConfig.cs | 2 +- GeneralMods/BuildEndurance/BuildEndurance.cs | 11 +- GeneralMods/BuildHealth/BuildHealth.cs | 4 +- .../BuildHealth/Framework/ModConfig.cs | 2 +- .../BuildHealth/Framework/PlayerData.cs | 2 +- .../BuyBackCollectables.cs | 2 +- .../Framework/BuyBackMenu.cs | 2 +- .../Framework/ModConfig.cs | 2 +- GeneralMods/CustomNPCFramework/Class1.cs | 153 +- .../CustomNPCFramework.csproj | 29 +- .../Framework/Enums/AnimationType.cs | 29 +- .../Framework/Enums/Direction.cs | 42 +- .../Framework/Enums/Genders.cs | 31 +- .../Framework/Enums/PartType.cs | 59 +- .../Framework/Enums/Seasons.cs | 34 +- .../Framework/Graphics/AssetInfo.cs | 91 +- .../Framework/Graphics/AssetManager.cs | 269 +-- .../Framework/Graphics/AssetPool.cs | 363 ++-- .../Framework/Graphics/AssetSheet.cs | 90 +- .../Framework/Graphics/DirectionalTexture.cs | 148 +- .../Framework/Graphics/ExtendedAssetInfo.cs | 86 +- .../Graphics/TextureGroups/TextureGroup.cs | 111 +- .../ModularNPCS/AnimatedSpriteCollection.cs | 169 +- .../ModularNPCS/AnimatedSpriteExtended.cs | 45 +- .../CharacterAnimationBase.cs | 134 +- .../StandardCharacterAnimation.cs | 186 +- .../StandardColorCollection.cs | 113 +- .../ModularRenderers/AnimationKeys.cs | 31 +- .../ModularRenderers/BasicRenderer.cs | 180 +- .../Framework/ModularNPCS/Portrait.cs | 41 +- .../Framework/ModularNPCS/Sprite.cs | 104 +- .../CustomNPCFramework/Framework/NPCNames.cs | 46 +- .../Framework/NPCS/ExtendedNPC.cs | 424 ++-- .../Framework/NPCS/MerchantNPC.cs | 45 +- .../Framework/Utilities/NPCTracker.cs | 85 +- GeneralMods/CustomNPCFramework/manifest.json | 2 +- .../DailyQuestAnywhere/DailyQuestAnywhere.cs | 55 +- .../DailyQuestAnywhere/Framework/ModConfig.cs | 6 +- GeneralMods/Fall28SnowDay/Fall28SnowDay.cs | 2 +- GeneralMods/FarmersMarketStall/Class1.cs | 30 +- .../FarmersMarketStall.csproj | 3 + .../MapEvents/ShopInteractionEvent.cs | 23 +- .../Framework/MarketStall.cs | 19 +- .../Framework/Menus/MarketStallMenu.cs | 10 +- GeneralMods/FarmersMarketStall/manifest.json | 9 +- GeneralMods/HappyBirthday/BirthdayEvents.cs | 17 +- GeneralMods/HappyBirthday/BirthdayMessages.cs | 79 +- .../HappyBirthday/Framework/BirthdayMenu.cs | 8 +- .../HappyBirthday/Framework/Messages.cs | 5 +- .../HappyBirthday/Framework/ModConfig.cs | 36 +- .../Framework/MultiplayerSupport.cs | 17 +- .../HappyBirthday/Framework/ObjectUtility.cs | 2 +- .../HappyBirthday/Framework/PlayerData.cs | 2 +- .../Framework/TranslationInfo.cs | 156 +- GeneralMods/HappyBirthday/GiftManager.cs | 160 +- GeneralMods/HappyBirthday/HappyBirthday.cs | 299 ++- GeneralMods/HappyBirthday/manifest.json | 1 - GeneralMods/MapEvents/EventSystem.cs | 29 +- GeneralMods/MapEvents/EventSystem.csproj | 3 + GeneralMods/MapEvents/Framework/Delegates.cs | 4 - .../MapEvents/Framework/EventManager.cs | 125 +- .../Framework/Events/DialogueDisplayEvent.cs | 26 +- .../MapEvents/Framework/Events/WarpEvent.cs | 56 +- .../FunctionEvents/MouseButtonEvents.cs | 40 +- .../FunctionEvents/MouseEntryLeaveEvent.cs | 23 +- .../Framework/FunctionEvents/PlayerEvents.cs | 27 +- .../Framework/FunctionEvents/functionEvent.cs | 20 +- .../Framework/Information/WarpInformation.cs | 16 +- GeneralMods/MapEvents/Framework/MapEvent.cs | 231 +-- GeneralMods/MapEvents/manifest.json | 2 +- GeneralMods/MoreRain/Framework/ModConfig.cs | 2 +- GeneralMods/MoreRain/MoreRain.cs | 5 +- .../MuseumRearranger/Framework/ModConfig.cs | 2 +- .../Framework/NewMuseumMenu.cs | 2 +- .../MuseumRearranger/MuseumRearranger.cs | 2 +- GeneralMods/NightOwl/Framework/ModConfig.cs | 6 +- .../NightOwl/Framework/NightFishing.cs | 12 +- GeneralMods/NightOwl/NightOwl.cs | 170 +- GeneralMods/NoMorePets/NoMorePets.cs | 4 +- .../Revitalize/Framework/Crafting/Recipe.cs | 171 +- .../Framework/Environment/DarkerNight.cs | 84 +- .../Environment/DarkerNightConfig.cs | 8 - .../Graphics/Animations/Animation.cs | 73 +- .../Graphics/Animations/AnimationManager.cs | 198 +- .../Framework/Graphics/Texture2DExtended.cs | 24 +- .../Framework/Illuminate/ColorExtensions.cs | 7 +- .../Framework/Illuminate/LightManager.cs | 161 +- .../Framework/Objects/BasicItemInformation.cs | 66 +- .../Framework/Objects/CustomObject.cs | 305 +-- .../Framework/Objects/MultiTiledComponent.cs | 66 +- .../Framework/Objects/MultiTiledObject.cs | 124 +- .../Framework/Player/Managers/SittingInfo.cs | 104 +- .../Revitalize/Framework/Player/PlayerInfo.cs | 12 +- .../Framework/Utilities/InventoryManager.cs | 187 +- GeneralMods/Revitalize/ModCore.cs | 182 +- .../SaveAnywhere/Framework/ModConfig.cs | 2 +- .../Framework/Models/CharacterType.cs | 2 +- .../Framework/Models/PositionData.cs | 2 +- .../SaveAnywhere/Framework/NewSaveGameMenu.cs | 33 +- .../SaveAnywhere/Framework/NewShippingMenu.cs | 11 +- .../SaveAnywhere/Framework/SaveManager.cs | 52 +- GeneralMods/SaveAnywhere/SaveAnywhere.cs | 98 +- GeneralMods/SaveAnywhere/manifest.json | 2 +- .../SimpleSoundManager/Framework/Sound.cs | 35 +- .../Framework/SoundManager.cs | 191 +- .../SimpleSoundManager/Framework/WavSound.cs | 204 +- .../SimpleSoundManager/Framework/XACTSound.cs | 88 +- .../Framework/XactMusicPair.cs | 20 +- .../SimpleSoundManagerMod.cs | 6 +- .../StardewSymphonyRemastered/Config.cs | 44 +- .../Framework/Menus/MusicManagerMenu.cs | 1024 ++++------ .../Framework/Music/MusicHexProcessor.cs | 124 +- .../Framework/Music/MusicManager.cs | 456 ++--- .../Framework/Music/MusicPack.cs | 88 +- .../Framework/Music/MusicPackMetaData.cs | 80 +- .../Framework/Music/Song.cs | 79 +- .../Framework/Music/SongListNode.cs | 44 +- .../Framework/Music/SongSpecifics.cs | 417 ++-- .../Framework/Music/WavMusicPack.cs | 177 +- .../Framework/Music/XACTMusicPack.cs | 108 +- .../StardewSymphony.cs | 347 ++-- .../StardewSymphonyRemastered.csproj | 1 - .../StaticExtentions.cs | 23 - .../StardewSymphonyRemastered/manifest.json | 7 +- .../StardustCore/Animations/Animation.cs | 73 +- .../Animations/AnimationManager.cs | 197 +- GeneralMods/StardustCore/Enums/Directions.cs | 49 +- GeneralMods/StardustCore/Enums/Weather.cs | 15 +- .../IlluminateFramework/Colors.cs | 123 +- GeneralMods/StardustCore/Math/Hex.cs | 64 +- GeneralMods/StardustCore/Math/Hex32.cs | 74 +- .../StardustCore/Menus/ModualGameMenu.cs | 177 +- GeneralMods/StardustCore/ModConfig.cs | 12 +- GeneralMods/StardustCore/ModCore.cs | 7 +- GeneralMods/StardustCore/StaticClass.cs | 15 +- .../UIUtilities/IClickableMenuExtended.cs | 237 +-- .../UIUtilities/LayeredTexture.cs | 36 +- .../UIUtilities/MenuComponents/Button.cs | 295 +-- .../UIUtilities/MenuComponents/CycleButton.cs | 67 +- .../Delegates/DelegatePairing.cs | 21 +- .../MenuComponents/Delegates/Delegates.cs | 5 - .../Functionality/ButtonFunctionality.cs | 28 +- .../MenuComponents/SliderButton.cs | 406 ++-- .../CharacterSheets/GenericCharacterSheets.cs | 7 +- .../CharacterSheets/VanillaCharacterSheet.cs | 11 +- .../Fonts/Components/CharacterSpacing.cs | 57 +- .../Fonts/Components/TexturedCharacter.cs | 30 +- .../Fonts/Components/TexturedString.cs | 120 +- .../SpriteFonts/Fonts/GenericFont.cs | 7 - .../SpriteFonts/Fonts/VanillaFont.cs | 108 +- .../UIUtilities/SpriteFonts/SpriteFont.cs | 18 +- .../UIUtilities/Texture2DExtended.cs | 36 +- .../UIUtilities/TextureManager.cs | 26 +- GeneralMods/SundropMapEvents/Class1.cs | 21 +- .../SundropMapEvents/SundropMapEvents.csproj | 3 + GeneralMods/SundropMapEvents/manifest.json | 9 +- GeneralMods/TimeFreeze/Framework/ModConfig.cs | 22 +- GeneralMods/TimeFreeze/TimeFreeze.cs | 68 +- .../Vocalization/Framework/AudioCues.cs | 30 +- .../Framework/CharacterVoiceCue.cs | 289 ++- .../Framework/Menus/VocalizationMenu.cs | 115 +- .../Framework/ReplacementStrings.cs | 79 +- .../Vocalization/Framework/TranslationInfo.cs | 182 +- .../Vocalization/Framework/Vocabulary.cs | 45 +- .../Framework/VoiceAudioOptions.cs | 56 +- .../Vocalization/Vocalization/ModConfig.cs | 62 +- .../Vocalization/Vocalization/Vocalization.cs | 1722 +++++++---------- .../Vocalization/Vocalization/manifest.json | 6 +- 173 files changed, 5391 insertions(+), 10099 deletions(-) delete mode 100644 GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/StaticExtentions.cs diff --git a/GeneralMods/AdvancedSaveBackup/Framework/ModConfig.cs b/GeneralMods/AdvancedSaveBackup/Framework/ModConfig.cs index 1612c9f8..be464717 100644 --- a/GeneralMods/AdvancedSaveBackup/Framework/ModConfig.cs +++ b/GeneralMods/AdvancedSaveBackup/Framework/ModConfig.cs @@ -1,4 +1,4 @@ -namespace Omegasis.SaveBackup.Framework +namespace Omegasis.SaveBackup.Framework { /// The mod configuration. internal class ModConfig diff --git a/GeneralMods/AdvancedSaveBackup/SaveBackup.cs b/GeneralMods/AdvancedSaveBackup/SaveBackup.cs index b10f0878..fb19a21e 100644 --- a/GeneralMods/AdvancedSaveBackup/SaveBackup.cs +++ b/GeneralMods/AdvancedSaveBackup/SaveBackup.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.IO; using System.IO.Compression; using System.Linq; diff --git a/GeneralMods/AutoSpeed/AutoSpeed.cs b/GeneralMods/AutoSpeed/AutoSpeed.cs index ec6bb545..80d44cdb 100644 --- a/GeneralMods/AutoSpeed/AutoSpeed.cs +++ b/GeneralMods/AutoSpeed/AutoSpeed.cs @@ -1,4 +1,4 @@ -using System; +using System; using Omegasis.AutoSpeed.Framework; using StardewModdingAPI; using StardewModdingAPI.Events; diff --git a/GeneralMods/AutoSpeed/Framework/ModConfig.cs b/GeneralMods/AutoSpeed/Framework/ModConfig.cs index ee3eef38..2e6dc10f 100644 --- a/GeneralMods/AutoSpeed/Framework/ModConfig.cs +++ b/GeneralMods/AutoSpeed/Framework/ModConfig.cs @@ -1,4 +1,4 @@ -namespace Omegasis.AutoSpeed.Framework +namespace Omegasis.AutoSpeed.Framework { /// The mod configuration. internal class ModConfig diff --git a/GeneralMods/BillboardAnywhere/BillboardAnywhere.cs b/GeneralMods/BillboardAnywhere/BillboardAnywhere.cs index 50480d7b..e09dadda 100644 --- a/GeneralMods/BillboardAnywhere/BillboardAnywhere.cs +++ b/GeneralMods/BillboardAnywhere/BillboardAnywhere.cs @@ -1,4 +1,4 @@ -using Omegasis.BillboardAnywhere.Framework; +using Omegasis.BillboardAnywhere.Framework; using StardewModdingAPI; using StardewModdingAPI.Events; using StardewValley; diff --git a/GeneralMods/BillboardAnywhere/Framework/ModConfig.cs b/GeneralMods/BillboardAnywhere/Framework/ModConfig.cs index e57f51ce..ec6f3b5c 100644 --- a/GeneralMods/BillboardAnywhere/Framework/ModConfig.cs +++ b/GeneralMods/BillboardAnywhere/Framework/ModConfig.cs @@ -1,4 +1,4 @@ -namespace Omegasis.BillboardAnywhere.Framework +namespace Omegasis.BillboardAnywhere.Framework { /// The mod configuration. internal class ModConfig diff --git a/GeneralMods/BuildEndurance/BuildEndurance.cs b/GeneralMods/BuildEndurance/BuildEndurance.cs index 763e619a..bcaf75cb 100644 --- a/GeneralMods/BuildEndurance/BuildEndurance.cs +++ b/GeneralMods/BuildEndurance/BuildEndurance.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.IO; using System.Linq; using Omegasis.BuildEndurance.Framework; @@ -107,9 +107,9 @@ namespace Omegasis.BuildEndurance } // give XP when player stays up too late or collapses - if (!this.WasCollapsed && shouldFarmerPassout()) + if (!this.WasCollapsed && this.shouldFarmerPassout()) { - + this.PlayerData.CurrentExp += this.Config.ExpForCollapsing; this.WasCollapsed = true; //this.Monitor.Log("The player has collapsed!"); @@ -221,10 +221,7 @@ namespace Omegasis.BuildEndurance } } - /// - /// Try and emulate the old Game1.shouldFarmerPassout logic. - /// - /// + /// Try and emulate the old Game1.shouldFarmerPassout logic. public bool shouldFarmerPassout() { if (Game1.player.stamina <= 0 || Game1.player.health <= 0 || Game1.timeOfDay >= 2600) return true; diff --git a/GeneralMods/BuildHealth/BuildHealth.cs b/GeneralMods/BuildHealth/BuildHealth.cs index 1ba8210c..2ac4a440 100644 --- a/GeneralMods/BuildHealth/BuildHealth.cs +++ b/GeneralMods/BuildHealth/BuildHealth.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.IO; using System.Linq; using Omegasis.BuildHealth.Framework; @@ -103,7 +103,7 @@ namespace Omegasis.BuildHealth this.LastHealth = player.health; // give XP when player stays up too late or collapses - if (!this.WasCollapsed && shouldFarmerPassout()) + if (!this.WasCollapsed && this.shouldFarmerPassout()) { this.PlayerData.CurrentExp += this.Config.ExpForCollapsing; this.WasCollapsed = true; diff --git a/GeneralMods/BuildHealth/Framework/ModConfig.cs b/GeneralMods/BuildHealth/Framework/ModConfig.cs index e0849f74..e627f69b 100644 --- a/GeneralMods/BuildHealth/Framework/ModConfig.cs +++ b/GeneralMods/BuildHealth/Framework/ModConfig.cs @@ -1,4 +1,4 @@ -namespace Omegasis.BuildHealth.Framework +namespace Omegasis.BuildHealth.Framework { /// The mod settings and player data. internal class ModConfig diff --git a/GeneralMods/BuildHealth/Framework/PlayerData.cs b/GeneralMods/BuildHealth/Framework/PlayerData.cs index 1e9cbb8e..2995d74f 100644 --- a/GeneralMods/BuildHealth/Framework/PlayerData.cs +++ b/GeneralMods/BuildHealth/Framework/PlayerData.cs @@ -1,4 +1,4 @@ -namespace Omegasis.BuildHealth.Framework +namespace Omegasis.BuildHealth.Framework { /// The data for the current player. internal class PlayerData diff --git a/GeneralMods/BuyBackCollectables/BuyBackCollectables.cs b/GeneralMods/BuyBackCollectables/BuyBackCollectables.cs index 91d89a06..2493af01 100644 --- a/GeneralMods/BuyBackCollectables/BuyBackCollectables.cs +++ b/GeneralMods/BuyBackCollectables/BuyBackCollectables.cs @@ -1,4 +1,4 @@ -using Omegasis.BuyBackCollectables.Framework; +using Omegasis.BuyBackCollectables.Framework; using StardewModdingAPI; using StardewModdingAPI.Events; using StardewValley; diff --git a/GeneralMods/BuyBackCollectables/Framework/BuyBackMenu.cs b/GeneralMods/BuyBackCollectables/Framework/BuyBackMenu.cs index 92e6b3e6..24bfcbf4 100644 --- a/GeneralMods/BuyBackCollectables/Framework/BuyBackMenu.cs +++ b/GeneralMods/BuyBackCollectables/Framework/BuyBackMenu.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using Microsoft.Xna.Framework; diff --git a/GeneralMods/BuyBackCollectables/Framework/ModConfig.cs b/GeneralMods/BuyBackCollectables/Framework/ModConfig.cs index deee9c28..c1299949 100644 --- a/GeneralMods/BuyBackCollectables/Framework/ModConfig.cs +++ b/GeneralMods/BuyBackCollectables/Framework/ModConfig.cs @@ -1,4 +1,4 @@ -namespace Omegasis.BuyBackCollectables.Framework +namespace Omegasis.BuyBackCollectables.Framework { /// The mod configuration. internal class ModConfig diff --git a/GeneralMods/CustomNPCFramework/Class1.cs b/GeneralMods/CustomNPCFramework/Class1.cs index 117b59eb..49ea38ef 100644 --- a/GeneralMods/CustomNPCFramework/Class1.cs +++ b/GeneralMods/CustomNPCFramework/Class1.cs @@ -1,20 +1,14 @@ -using CustomNPCFramework.Framework.Enums; -using CustomNPCFramework.Framework.Graphics; -using CustomNPCFramework.Framework.ModularNPCS; -using CustomNPCFramework.Framework.ModularNPCS.CharacterAnimationBases; -using CustomNPCFramework.Framework.ModularNPCS.ColorCollections; -using CustomNPCFramework.Framework.NPCS; -using CustomNPCFramework.Framework.Utilities; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using StardewModdingAPI; -using StardewValley; using System; using System.Collections.Generic; using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using CustomNPCFramework.Framework.Enums; +using CustomNPCFramework.Framework.Graphics; +using CustomNPCFramework.Framework.ModularNpcs.ColorCollections; +using CustomNPCFramework.Framework.NPCS; +using CustomNPCFramework.Framework.Utilities; +using Microsoft.Xna.Framework; +using StardewModdingAPI; +using StardewValley; namespace CustomNPCFramework { @@ -44,91 +38,73 @@ namespace CustomNPCFramework /// Find way to make sideways shirts render correctly. /// ///Get suggestions from modding community on requests and ways to improve the mod. - /// - public class Class1 : Mod { - /// - /// The mod helper for the mod. - /// + /// The mod helper for the mod. public static IModHelper ModHelper; - /// - /// The mod monitor for the mod. - /// + + /// The mod monitor for the mod. public static IMonitor ModMonitor; - /// - /// The npc tracker for the mod. Keeps track of all npcs added by the custom framework and cleans them up during saving. - /// - public static NPCTracker npcTracker; - /// - /// Keeps track of all of the asets/textures added in by the framework. Also manages all of the asset managers that are the ones actually managing the textures. - /// + /// The npc tracker for the mod. Keeps track of all npcs added by the custom framework and cleans them up during saving. + public static NpcTracker npcTracker; + + /// Keeps track of all of the asets/textures added in by the framework. Also manages all of the asset managers that are the ones actually managing the textures. public static AssetPool assetPool; public static IManifest Manifest; - - /// - /// Ran when loading the SMAPI. Used to initialize data. - /// - /// + + /// The mod entry point, called after the mod is first loaded. + /// Provides simplified APIs for writing mods. public override void Entry(IModHelper helper) { ModHelper = this.Helper; ModMonitor = this.Monitor; - Manifest = ModManifest; + Manifest = this.ModManifest; - StardewModdingAPI.Events.SaveEvents.AfterLoad += SaveEvents_LoadChar; + StardewModdingAPI.Events.SaveEvents.AfterLoad += this.SaveEvents_LoadChar; - StardewModdingAPI.Events.SaveEvents.BeforeSave += SaveEvents_BeforeSave; - StardewModdingAPI.Events.SaveEvents.AfterSave += SaveEvents_AfterSave; + StardewModdingAPI.Events.SaveEvents.BeforeSave += this.SaveEvents_BeforeSave; + StardewModdingAPI.Events.SaveEvents.AfterSave += this.SaveEvents_AfterSave; - StardewModdingAPI.Events.PlayerEvents.Warped += LocationEvents_CurrentLocationChanged; - StardewModdingAPI.Events.GameEvents.UpdateTick += GameEvents_UpdateTick; - npcTracker = new NPCTracker(); + StardewModdingAPI.Events.PlayerEvents.Warped += this.LocationEvents_CurrentLocationChanged; + StardewModdingAPI.Events.GameEvents.UpdateTick += this.GameEvents_UpdateTick; + npcTracker = new NpcTracker(); assetPool = new AssetPool(); var assetManager = new AssetManager(); assetPool.addAssetManager(new KeyValuePair("testNPC", assetManager)); - initializeExamples(); - initializeAssetPool(); + this.initializeExamples(); + this.initializeAssetPool(); assetPool.loadAllAssets(); } - /// - /// Initialize the asset pool with some test variables. - /// + /// Initialize the asset pool with some test variables. public void initializeAssetPool() { string path = Path.Combine(ModHelper.DirectoryPath, "Content", "Graphics", "NPCS"); assetPool.getAssetManager("testNPC").addPathCreateDirectory(new KeyValuePair("characters", path)); } - /// - /// A function that is called when the game finishes saving. - /// - /// - /// + /// A function that is called when the game finishes saving. + /// The event sender. + /// The event arguments. private void SaveEvents_AfterSave(object sender, EventArgs e) { npcTracker.afterSave(); } - /// - /// A function that is called when the game is about to load. Used to clean up all the npcs from the game world to prevent it from crashing. - /// - /// - /// + /// A function that is called when the game is about to load. Used to clean up all the npcs from the game world to prevent it from crashing. + /// The event sender. + /// The event arguments. private void SaveEvents_BeforeSave(object sender, EventArgs e) { npcTracker.cleanUpBeforeSave(); } - /// - /// Called upon 60 times a second. For testing purposes only. Will remove in future release. - /// - /// - /// + /// Called upon 60 times a second. For testing purposes only. Will remove in future release. + /// The event sender. + /// The event arguments. private void GameEvents_UpdateTick(object sender, EventArgs e) { /* @@ -147,47 +123,37 @@ namespace CustomNPCFramework */ } - /// - /// Called when the player's location changes. - /// - /// - /// - private void LocationEvents_CurrentLocationChanged(object sender, StardewModdingAPI.Events.EventArgsPlayerWarped e) - { - - } + /// Called when the player's location changes. + /// The event sender. + /// The event arguments. + private void LocationEvents_CurrentLocationChanged(object sender, StardewModdingAPI.Events.EventArgsPlayerWarped e) { } - /// - /// Used to spawn a custom npc just as an example. Don't keep this code. - /// GENERATE NPC AND CALL THE CODE - /// - /// - /// + /// Used to spawn a custom npc just as an example. Don't keep this code. GENERATE NPC AND CALL THE CODE + /// The event sender. + /// The event arguments. private void SaveEvents_LoadChar(object sender, EventArgs e) { - ExtendedNPC myNpc3 = assetPool.generateNPC(Genders.female, 0, 1,new StandardColorCollection(null, null, Color.Blue, null, Color.Yellow, null)); - MerchantNPC merch = new MerchantNPC(new List() + ExtendedNpc myNpc3 = assetPool.generateNPC(Genders.female, 0, 1, new StandardColorCollection(null, null, Color.Blue, null, Color.Yellow, null)); + MerchantNpc merch = new MerchantNpc(new List() { new StardewValley.Object(475,999) }, myNpc3); - npcTracker.addNewNPCToLocation(Game1.getLocationFromName("BusStop", false), merch,new Vector2(2,23)); + npcTracker.addNewNpcToLocation(Game1.getLocationFromName("BusStop", false), merch, new Vector2(2, 23)); } - /// - /// Used to initialize examples for other modders to look at as reference. - /// + /// Used to initialize examples for other modders to look at as reference. public void initializeExamples() { return; string dirPath = Path.Combine(ModHelper.DirectoryPath, "Content", "Templates"); - var aManager=assetPool.getAssetManager("testNPC"); + var aManager = assetPool.getAssetManager("testNPC"); aManager.addPathCreateDirectory(new KeyValuePair("templates", dirPath)); - string filePath =Path.Combine(dirPath, "Example.json"); + string filePath = Path.Combine(dirPath, "Example.json"); if (!File.Exists(filePath)) { string getRelativePath = getShortenedDirectory(filePath); ModMonitor.Log("THIS IS THE PATH::: " + getRelativePath); - AssetInfo info = new AssetInfo("MyExample",new NamePairings("StandingExampleL", "StandingExampleR", "StandingExampleU", "StandingExampleD"), new NamePairings("MovingExampleL", "MovingExampleR", "MovingExampleU", "MovingExampleD"), new NamePairings("SwimmingExampleL", "SwimmingExampleR", "SwimmingExampleU", "SwimmingExampleD"), new NamePairings("SittingExampleL", "SittingExampleR", "SittingExampleU", "SittingExampleD"), new Vector2(16, 16), false); + AssetInfo info = new AssetInfo("MyExample", new NamePairings("StandingExampleL", "StandingExampleR", "StandingExampleU", "StandingExampleD"), new NamePairings("MovingExampleL", "MovingExampleR", "MovingExampleU", "MovingExampleD"), new NamePairings("SwimmingExampleL", "SwimmingExampleR", "SwimmingExampleU", "SwimmingExampleD"), new NamePairings("SittingExampleL", "SittingExampleR", "SittingExampleU", "SittingExampleD"), new Vector2(16, 16), false); info.writeToJson(filePath); } @@ -205,31 +171,22 @@ namespace CustomNPCFramework } } - /// - /// Used to splice the mod directory to get relative paths. - /// - /// - /// + /// Used to splice the mod directory to get relative paths. public static string getShortenedDirectory(string path) { string lol = (string)path.Clone(); - string[] spliter = lol.Split(new string[] { ModHelper.DirectoryPath },StringSplitOptions.None); + string[] spliter = lol.Split(new string[] { ModHelper.DirectoryPath }, StringSplitOptions.None); try { return spliter[1]; } - catch(Exception err) + catch { - err.ToString(); return spliter[0]; } } - /// - /// Used to finish cleaning up absolute asset paths into a shortened relative path. - /// - /// - /// + /// Used to finish cleaning up absolute asset paths into a shortened relative path. public static string getRelativeDirectory(string path) { string s = getShortenedDirectory(path); diff --git a/GeneralMods/CustomNPCFramework/CustomNPCFramework.csproj b/GeneralMods/CustomNPCFramework/CustomNPCFramework.csproj index 5d0e36ed..a6467cf3 100644 --- a/GeneralMods/CustomNPCFramework/CustomNPCFramework.csproj +++ b/GeneralMods/CustomNPCFramework/CustomNPCFramework.csproj @@ -93,20 +93,20 @@ - - - - + + + + - - - - - - - - - + + + + + + + + + @@ -115,5 +115,8 @@ StardustCore + + + \ No newline at end of file diff --git a/GeneralMods/CustomNPCFramework/Framework/Enums/AnimationType.cs b/GeneralMods/CustomNPCFramework/Framework/Enums/AnimationType.cs index 15fa24b8..9f3300b2 100644 --- a/GeneralMods/CustomNPCFramework/Framework/Enums/AnimationType.cs +++ b/GeneralMods/CustomNPCFramework/Framework/Enums/AnimationType.cs @@ -1,31 +1,18 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - namespace CustomNPCFramework.Framework.Enums { - /// - /// A enum of different types of animations supported by the framework. - /// + /// A enum of different types of animations supported by the framework. public enum AnimationType { - /// - /// A key to be used whenever an npc uses a standing animation. - /// + /// A key to be used whenever an npc uses a standing animation. standing, - /// - /// A key to be used wheneven an npc uses a walking/moving animation. - /// + + /// A key to be used wheneven an npc uses a walking/moving animation. walking, - /// - /// A key to be used whenever an npc uses a swimming animation. - /// + + /// A key to be used whenever an npc uses a swimming animation. swimming, - /// - /// A key to be used whenever an npc uses a sitting animation. - /// + + /// A key to be used whenever an npc uses a sitting animation. sitting } } diff --git a/GeneralMods/CustomNPCFramework/Framework/Enums/Direction.cs b/GeneralMods/CustomNPCFramework/Framework/Enums/Direction.cs index e894f068..6d0c753f 100644 --- a/GeneralMods/CustomNPCFramework/Framework/Enums/Direction.cs +++ b/GeneralMods/CustomNPCFramework/Framework/Enums/Direction.cs @@ -1,36 +1,18 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - namespace CustomNPCFramework.Framework.Enums { - /// - /// An enum to be used to signify directions. - /// The enum order corresponds to the same order Stardew Valley uses for directions where - /// Up=0 - /// Right=1 - /// Down=2 - /// Left=3 - /// + /// An enum to be used to signify directions. The enum order corresponds to the same order Stardew Valley uses for directions. public enum Direction { - /// - /// Used to signify something to face/move up. - /// - up, - /// - /// Used to signify something to face/move right. - /// - right, - /// - /// Used to signify something to face/move down. - /// - down, - /// - /// Used to signify something to face/move left. - /// - left + /// Used to signify something to face/move up. + up = 0, + + /// Used to signify something to face/move right. + right = 1, + + /// Used to signify something to face/move down. + down = 2, + + /// Used to signify something to face/move left. + left = 3 } } diff --git a/GeneralMods/CustomNPCFramework/Framework/Enums/Genders.cs b/GeneralMods/CustomNPCFramework/Framework/Enums/Genders.cs index b1299af0..15050941 100644 --- a/GeneralMods/CustomNPCFramework/Framework/Enums/Genders.cs +++ b/GeneralMods/CustomNPCFramework/Framework/Enums/Genders.cs @@ -1,28 +1,17 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using StardewValley; namespace CustomNPCFramework.Framework.Enums { - /// - /// Gender enum to signify the different genders for npcs. - /// Do what you want with this. For code simplicity anything that is non-binary is specified under other. - /// + /// Gender enum to signify the different genders for NPCs. Do what you want with this. For code simplicity anything that is non-binary is specified under other. public enum Genders { - /// - /// Used for npcs to signify that they are the male gender. - /// - male, - /// - /// Used for npcs to signify that they are the female gender. - /// - female, - /// - /// Used for npcs to signify that they are a non gender binary gender. - /// - other + /// Used for npcs to signify that they are the male gender. + male = NPC.male, + + /// Used for npcs to signify that they are the female gender. + female = NPC.female, + + /// Used for npcs to signify that they are a non gender binary gender. + other = NPC.undefined } } diff --git a/GeneralMods/CustomNPCFramework/Framework/Enums/PartType.cs b/GeneralMods/CustomNPCFramework/Framework/Enums/PartType.cs index aab5d3b7..46712e60 100644 --- a/GeneralMods/CustomNPCFramework/Framework/Enums/PartType.cs +++ b/GeneralMods/CustomNPCFramework/Framework/Enums/PartType.cs @@ -1,55 +1,36 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - namespace CustomNPCFramework.Framework.Enums { - /// - /// An enum used to signify the different asset types that can be used for npcs. - /// + /// An enum used to signify the different asset types that can be used for NPCs. public enum PartType { - /// - /// Used to signify that the asset is of the body part category. Without this the npc is basically a ghost. - /// + /// Used to signify that the asset is of the body part category. Without this the npc is basically a ghost. body, - /// - /// Used to signify that the asset is of the eyes part category. The window to the soul. - /// + + /// Used to signify that the asset is of the eyes part category. The window to the soul. eyes, - /// - /// Used to signify that the asset is of the hair part category. Volume looks good in 2D. - /// + + /// Used to signify that the asset is of the hair part category. Volume looks good in 2D. hair, - /// - /// Used to signify that the asset is of the shirt part category.No shirt = no service. - /// + + /// Used to signify that the asset is of the shirt part category.No shirt = no service. shirt, - /// - /// Used to signify that the asset is of the pants/bottoms part category. Also known as bottoms, skirts, shorts, etc. - /// + + /// Used to signify that the asset is of the pants/bottoms part category. Also known as bottoms, skirts, shorts, etc. pants, - /// - /// Used to signify that the asset is of the shoes part category. Lace up those kicks. - /// + + /// Used to signify that the asset is of the shoes part category. Lace up those kicks. shoes, - /// - /// Used to signify that the asset is of the accessort part category. Got to wear that bling. - /// + + /// Used to signify that the asset is of the accessort part category. Got to wear that bling. accessory, - /// - /// Used to signify that the asset is of the other part category. Who knows what this really is... - /// + + /// Used to signify that the asset is of the other part category. Who knows what this really is... other, - /// - /// Used to signify that the asset is of the swimsuit part category. Got to be decent when taking a dip. - /// + + /// Used to signify that the asset is of the swimsuit part category. Got to be decent when taking a dip. swimsuit, - /// - /// Used to signify that the asset is of the amrs part category. Arms need to be rendered above a shirt on npcs otherwise they get covered. - /// + + /// Used to signify that the asset is of the amrs part category. Arms need to be rendered above a shirt on npcs otherwise they get covered. arms } } diff --git a/GeneralMods/CustomNPCFramework/Framework/Enums/Seasons.cs b/GeneralMods/CustomNPCFramework/Framework/Enums/Seasons.cs index e8e6cd7f..47f0a22b 100644 --- a/GeneralMods/CustomNPCFramework/Framework/Enums/Seasons.cs +++ b/GeneralMods/CustomNPCFramework/Framework/Enums/Seasons.cs @@ -1,36 +1,18 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - - namespace CustomNPCFramework.Framework.Enums { - /// - /// An enum signifying the different seasons that are supported when chosing npc graphics. - /// + /// An enum signifying the different seasons that are supported when choosing NPC graphics. public enum Seasons { - /// - /// The spring season. This ensures that a corresponding graphic with this enum in it's seasons list can be chosen in the spring time. - /// Also used for functionality to check seasons. - /// + /// The spring season. This ensures that a corresponding graphic with this enum in it's seasons list can be chosen in the spring time. Also used for functionality to check seasons. spring, - /// - /// The summer season. This ensures that a corresponding graphic with this enum in it's seasons list can be chosen in the summer time. - /// Also used for functionality to check seasons. - /// + + /// The summer season. This ensures that a corresponding graphic with this enum in it's seasons list can be chosen in the summer time. Also used for functionality to check seasons. summer, - /// - /// The fall season. This ensures that a corresponding graphic with this enum in it's seasons list can be chosen in the fall time. - /// Also used for functionality to check seasons. - /// + + /// The fall season. This ensures that a corresponding graphic with this enum in it's seasons list can be chosen in the fall time. Also used for functionality to check seasons. fall, - /// - /// The winter season. This ensures that a corresponding graphic with this enum in it's seasons list can be chosen in the winter time. - /// Also used for functionality to check seasons. - /// + + /// The winter season. This ensures that a corresponding graphic with this enum in it's seasons list can be chosen in the winter time. Also used for functionality to check seasons. winter } } diff --git a/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetInfo.cs b/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetInfo.cs index adc5d387..8ad12a14 100644 --- a/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetInfo.cs +++ b/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetInfo.cs @@ -1,92 +1,65 @@ -using Microsoft.Xna.Framework; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using Microsoft.Xna.Framework; namespace CustomNPCFramework.Framework.Graphics { - /// - /// A class to be used to hold information regarding assets such as the name of the assets and the paths to the images. - /// + /// A class to be used to hold information regarding assets such as the name of the assets and the paths to the images. public class AssetInfo { - /// - /// The name of the asset to be used in the main asset pool. - /// + /// The name of the asset to be used in the main asset pool. public string assetName; - /// - /// The list of files to be used for the standing animation. - /// + + /// The list of files to be used for the standing animation. public NamePairings standingAssetPaths; - /// - /// The list of files to be used for the swimming animation. - /// + + /// The list of files to be used for the swimming animation. public NamePairings swimmingAssetPaths; - /// - /// The list of files to be used with the moving animation. - /// + + /// The list of files to be used with the moving animation. public NamePairings movingAssetPaths; - /// - /// The list of files to be used with the sitting animation. - /// + + /// The list of files to be used with the sitting animation. public NamePairings sittingAssetPaths; - /// - /// The size of the asset texture. Width and height. - /// + + /// The size of the asset texture. Width and height. public Vector2 assetSize; - /// - /// Not really used anymore. More of a legacy feature. - /// + + /// Not really used anymore. More of a legacy feature. public bool randomizeUponLoad; - - /// - /// Empty constructor. - /// - public AssetInfo() - { - } + /// Construct an instance. + public AssetInfo() { } - /// - /// Constructor that assigns values to the class. - /// + /// Construct an instance. /// The name of the asset. This is the name that will be referenced in any asset manager or asset pool. - /// The name of the files to be used for the standing animation. - /// The name of the files to be used for the moving animation. - /// The name of the files to be used for the swimming animation. - /// The name of the files to be used for the sitting animation. + /// The name of the files to be used for the standing animation. + /// The name of the files to be used for the moving animation. + /// The name of the files to be used for the swimming animation. + /// The name of the files to be used for the sitting animation. /// The size of the asset. Width and height of the texture. /// Legacy, not really used anymore. - public AssetInfo(string assetName,NamePairings StandingAssetPaths, NamePairings MovingAssetPaths, NamePairings SwimmingAssetPaths, NamePairings SittingAssetPaths, Vector2 assetSize, bool randomizeUponLoad) + public AssetInfo(string assetName, NamePairings standingAssetPaths, NamePairings movingAssetPaths, NamePairings swimmingAssetPaths, NamePairings sittingAssetPaths, Vector2 assetSize, bool randomizeUponLoad) { this.assetName = assetName; - this.sittingAssetPaths = SittingAssetPaths; - this.standingAssetPaths = StandingAssetPaths; - this.movingAssetPaths = MovingAssetPaths; - this.swimmingAssetPaths = SwimmingAssetPaths; + this.sittingAssetPaths = sittingAssetPaths; + this.standingAssetPaths = standingAssetPaths; + this.movingAssetPaths = movingAssetPaths; + this.swimmingAssetPaths = swimmingAssetPaths; this.assetSize = assetSize; this.randomizeUponLoad = randomizeUponLoad; } - /// - /// Save the json to a certain location. - /// - /// + /// Save the json to a certain location. + /// The absolute path to save. public void writeToJson(string path) { Class1.ModHelper.WriteJsonFile(path, this); } - /// - /// Read the json from a certain location. - /// - /// - /// + /// Read the json from a certain location. + /// The absolute path to save. public static AssetInfo readFromJson(string path) { - return Class1.ModHelper.ReadJsonFile(path); + return Class1.ModHelper.ReadJsonFile(path); } } } diff --git a/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetManager.cs b/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetManager.cs index 1cd90755..ef6fc18f 100644 --- a/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetManager.cs +++ b/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetManager.cs @@ -1,286 +1,229 @@ -using CustomNPCFramework.Framework.Enums; using System; using System.Collections.Generic; using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using CustomNPCFramework.Framework.Enums; namespace CustomNPCFramework.Framework.Graphics { - /// - /// Used to hold assets from specified directories. - /// + /// Used to hold assets from specified directories. public class AssetManager { - /// - /// A list of all of the assets held by this asset manager. - /// + /// A list of all of the assets held by this asset manager. public List assets; - /// - /// A list of all of the directories managed by this asset manager. - /// - public Dictionary paths; - /// - /// Basic constructor. - /// + /// A list of all of the directories managed by this asset manager. + public Dictionary paths; + + /// Construct an instance. public AssetManager() { this.assets = new List(); this.paths = new Dictionary(); } - /// - /// Constructor. - /// + /// Construct an instance. /// A list of all directories to be managed by the asset manager. Name, path is the key pair value. - public AssetManager(Dictionary assetsPathsToLoadFrom) + public AssetManager(Dictionary assetsPathsToLoadFrom) { this.assets = new List(); this.paths = assetsPathsToLoadFrom; } - /// - /// Default loading function from hard coded paths. - /// + /// Default loading function from hardcoded paths. public void loadAssets() { - foreach(var path in this.paths) - { - ProcessDirectory(path.Value); - } + foreach (var path in this.paths) + this.ProcessDirectory(path.Value); } - /// - /// Taken from Microsoft c# documented webpages. - /// Process all .json files in the given directory. If there are more nested directories, keep digging to find more .json files. Also allows us to specify a broader directory like Content/Grahphics/ModularNPC/Hair to have multiple hair styles. - /// - /// + /// Process all .json files in the given directory. If there are more nested directories, keep digging to find more .json files. Also allows us to specify a broader directory like Content/Grahphics/ModularNPC/Hair to have multiple hair styles. + /// The absolute directory path to process. + /// Taken from Microsoft c# documented webpages. private void ProcessDirectory(string targetDirectory) { // Process the list of files found in the directory. string[] files = Directory.GetFiles(targetDirectory, "*.json"); - foreach (var file in files) - { - ProcessFile(file,targetDirectory); - } + foreach (string file in files) + this.ProcessFile(file, targetDirectory); + // Recurse into subdirectories of this directory. string[] subdirectoryEntries = Directory.GetDirectories(targetDirectory); foreach (string subdirectory in subdirectoryEntries) - ProcessDirectory(subdirectory); + this.ProcessDirectory(subdirectory); } - /// - /// Actually load in the asset information. - /// - /// - /// - private void ProcessFile(string file,string path) + /// Actually load in the asset information. + /// The absolute file path to process. + /// The absolute directory path containing the file. + private void ProcessFile(string file, string path) { try { ExtendedAssetInfo info = ExtendedAssetInfo.readFromJson(file); AssetSheet sheet = new AssetSheet(info, path); - addAsset(sheet); + this.addAsset(sheet); Class1.ModMonitor.Log("Loaded in new modular asset: " + info.assetName + " asset type: " + info.type); } - catch (Exception err) + catch { AssetInfo info = AssetInfo.readFromJson(file); AssetSheet sheet = new AssetSheet(info, path); - addAsset(sheet); + this.addAsset(sheet); } } - /// - /// Add an asset to be handled from the asset manager. - /// - /// + /// Add an asset to be handled from the asset manager. + /// The asset sheet. public void addAsset(AssetSheet asset) { this.assets.Add(asset); } - /// - /// Get an individual asset by its name. - /// - /// - /// + /// Get an individual asset by its name. + /// The asset name. public AssetSheet getAssetByName(string s) { - foreach(var v in assets) + foreach (var v in this.assets) { - if (v.assetInfo.assetName == s) return v; + if (v.assetInfo.assetName == s) + return v; } return null; } - - /// - /// Add a new path to the asset manager and create the directory for it. - /// - /// - public void addPathCreateDirectory(KeyValuePair path) + + /// Add a new path to the asset manager and create the directory for it. + /// The absolute path to add. + public void addPathCreateDirectory(KeyValuePair path) { this.addPath(path); string dir = Path.Combine(Class1.ModHelper.DirectoryPath, path.Value); if (!Directory.Exists(dir)) - { Directory.CreateDirectory(Path.Combine(Class1.ModHelper.DirectoryPath, path.Value)); - } } - /// - /// Add a path to the dictionary. - /// - /// - private void addPath(KeyValuePair path) + /// Add a path to the dictionary. + /// The absolute path to add. + private void addPath(KeyValuePair path) { this.paths.Add(path.Key, path.Value); } - /// - /// Create appropriate directories for the path. - /// + /// Create appropriate directories for the path. private void createDirectoriesFromPaths() { - foreach(var v in paths) - { - Directory.CreateDirectory(Path.Combine(Class1.ModHelper.DirectoryPath,v.Value)); - } + foreach (var v in this.paths) + Directory.CreateDirectory(Path.Combine(Class1.ModHelper.DirectoryPath, v.Value)); } - /// - /// Returns a list of assets from this manager that match the given critera. - /// - /// The criteria we are searching for this time is gender. - /// + /// Get a list of assets which match the given critera. + /// The gender to match. public List getListOfAssetsThatMatchThisCriteria(Genders gender) { - List aSheet = new List(); - foreach(var v in this.assets) + List sheets = new List(); + foreach (var v in this.assets) { - if(v.assetInfo is ExtendedAssetInfo) + if (v.assetInfo is ExtendedAssetInfo info) { - if ((v.assetInfo as ExtendedAssetInfo).gender == gender) aSheet.Add(v); + if (info.gender == gender) + sheets.Add(v); } } - return aSheet; + return sheets; } - /// - /// Get a list of all the assets of this kind of part. - /// - /// The type of part to return a list of from this asset manager. - /// + /// Get a list of assets which match the given critera. + /// The part type to match. public List getListOfAssetsThatMatchThisCriteria(PartType type) { - List aSheet = new List(); + List sheets = new List(); foreach (var v in this.assets) { - if (v.assetInfo is ExtendedAssetInfo) + if (v.assetInfo is ExtendedAssetInfo info) { - if ((v.assetInfo as ExtendedAssetInfo).type == type) aSheet.Add(v); + if (info.type == type) + sheets.Add(v); } } - return aSheet; + return sheets; } - /// - /// Get a list of assets that match the critera. - /// - /// The gender criteria for this asset, such as if this part belongs to either a female or male character. - /// The type of asset to return. Hair eyes, shoes, etc. - /// - public List getListOfAssetsThatMatchThisCriteria(Genders gender,PartType type) + /// Get a list of assets which match the given critera. + /// The gender to match. + /// The part type to match. + public List getListOfAssetsThatMatchThisCriteria(Genders gender, PartType type) { - List aSheet = new List(); + List sheets = new List(); foreach (var v in this.assets) { - if (v.assetInfo is ExtendedAssetInfo) + if (v.assetInfo is ExtendedAssetInfo info) { - if ((v.assetInfo as ExtendedAssetInfo).type == type && (v.assetInfo as ExtendedAssetInfo).gender == gender) aSheet.Add(v); + if (info.type == type && info.gender == gender) + sheets.Add(v); } } - return aSheet; + return sheets; } - /// - /// Returns a list of assets from this manager that match the given critera. - /// - /// The criteria we are searching for this time is gender. - /// + /// Get a list of assets which match the given critera. + /// The season to match. public List getListOfAssetsThatMatchThisCriteria(Seasons season) { - List aSheet = new List(); + List sheets = new List(); foreach (var v in this.assets) { - if (v.assetInfo is ExtendedAssetInfo) + if (v.assetInfo is ExtendedAssetInfo info) { - foreach (var sea in (v.assetInfo as ExtendedAssetInfo).seasons) { - if (sea == season) aSheet.Add(v); - break; //Only need to find first validation that this is a valid asset. - } - } - } - return aSheet; - } - - /// - /// Get a list of assets that match this criteria of gender and seasons. - /// - /// - /// - /// - public List getListOfAssetsThatMatchThisCriteria(Genders gender,Seasons season) - { - List aSheet = new List(); - foreach (var v in this.assets) - { - if (v.assetInfo is ExtendedAssetInfo) - { - foreach (var sea in (v.assetInfo as ExtendedAssetInfo).seasons) + foreach (var sea in info.seasons) { - if (sea == season && (v.assetInfo as ExtendedAssetInfo).gender==gender) aSheet.Add(v); + if (sea == season) + sheets.Add(v); break; //Only need to find first validation that this is a valid asset. } } } - return aSheet; + return sheets; } - /// - /// Get a list of asssets that match certain critera. - /// - /// The gengder certain assets belong to, such as male or female. - /// The season that an asset can be displayed in. Good for seasonal assets. - /// The type of part to return a list of such as hair, eyes, or pants. - /// + /// Get a list of assets which match the given critera. + /// The gender to match. + /// The season to match. + public List getListOfAssetsThatMatchThisCriteria(Genders gender, Seasons season) + { + List sheets = new List(); + foreach (var v in this.assets) + { + if (v.assetInfo is ExtendedAssetInfo info) + { + foreach (var sea in info.seasons) + { + if (sea == season && info.gender == gender) + sheets.Add(v); + break; //Only need to find first validation that this is a valid asset. + } + } + } + return sheets; + } + + /// Get a list of assets which match the given critera. + /// The gender to match. + /// The season to match. + /// The part type to match. public List getListOfAssetsThatMatchThisCriteria(Genders gender, Seasons season, PartType type) { - List aSheet = new List(); + List sheets = new List(); foreach (var v in this.assets) { - if (v.assetInfo is ExtendedAssetInfo) + if (v.assetInfo is ExtendedAssetInfo info) { - foreach (var sea in (v.assetInfo as ExtendedAssetInfo).seasons) + foreach (var sea in info.seasons) { - //Class1.ModMonitor.Log("Searching: seasons"); - if (sea == season && (v.assetInfo as ExtendedAssetInfo).gender == gender && (v.assetInfo as ExtendedAssetInfo).type == type) - { - aSheet.Add(v); - } - else - { - //Class1.ModMonitor.Log("Not what I was looking for."); - } + if (sea == season && info.gender == gender && info.type == type) + sheets.Add(v); } } } - //Class1.ModMonitor.Log("ok it's over: "+aSheet.Count.ToString()); - return aSheet; + return sheets; } - - } } diff --git a/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetPool.cs b/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetPool.cs index 5b1f593d..caf97e00 100644 --- a/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetPool.cs +++ b/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetPool.cs @@ -1,32 +1,26 @@ - -using CustomNPCFramework.Framework.Enums; -using CustomNPCFramework.Framework.ModularNPCS; -using CustomNPCFramework.Framework.ModularNPCS.CharacterAnimationBases; -using CustomNPCFramework.Framework.ModularNPCS.ColorCollections; -using CustomNPCFramework.Framework.ModularNPCS.ModularRenderers; -using CustomNPCFramework.Framework.NPCS; -using Microsoft.Xna.Framework; -using StardewValley; using System; using System.Collections.Generic; using System.IO; using System.Linq; -using System.Text; -using System.Threading.Tasks; +using CustomNPCFramework.Framework.Enums; +using CustomNPCFramework.Framework.ModularNpcs; +using CustomNPCFramework.Framework.ModularNpcs.CharacterAnimationBases; +using CustomNPCFramework.Framework.ModularNpcs.ColorCollections; +using CustomNPCFramework.Framework.ModularNpcs.ModularRenderers; +using CustomNPCFramework.Framework.NPCS; +using StardewValley; namespace CustomNPCFramework.Framework.Graphics { - - /// - /// Used to hold a collection of strings. - /// + /// Used to hold a collection of strings. public class NamePairings { public string leftString; public string rightString; public string upString; public string downString; - public NamePairings(string LeftString,string RightString, string UpString, string DownString) + + public NamePairings(string LeftString, string RightString, string UpString, string DownString) { this.leftString = LeftString; this.rightString = RightString; @@ -35,37 +29,26 @@ namespace CustomNPCFramework.Framework.Graphics } } - /// - /// Used to contain all of the asset managers. - /// + /// Used to contain all of the asset managers. public class AssetPool { - - /// - /// A dictionary holding all of the asset managers. (Name, AssetManager) - /// + /// A dictionary holding all of the asset managers. (Name, AssetManager) public Dictionary assetPool; - /// - /// Constructor. - /// + /// Construct an instance. public AssetPool() { this.assetPool = new Dictionary(); } - /// - /// Adds an asset manager to the asset pool. - /// + /// Adds an asset manager to the asset pool. /// A key value pair with the convention being (Manager Name, Asset Manager) public void addAssetManager(KeyValuePair pair) { this.assetPool.Add(pair.Key, pair.Value); } - /// - /// Adds an asset manager to the asset pool. - /// + /// Adds an asset manager to the asset pool. /// The name of the asset manager to be added. /// The asset manager object to be added to the asset pool. public void addAssetManager(string assetManagerName, AssetManager assetManager) @@ -73,99 +56,74 @@ namespace CustomNPCFramework.Framework.Graphics this.assetPool.Add(assetManagerName, assetManager); } - /// - /// Get an asset manager from the asset pool from a name. - /// + /// Get an asset manager from the asset pool from a name. /// The name of the asset manager to return. - /// public AssetManager getAssetManager(string name) { - assetPool.TryGetValue(name, out AssetManager asset); + this.assetPool.TryGetValue(name, out AssetManager asset); return asset; } - /// - /// Remove an asset manager from the asset pool. - /// + /// Remove an asset manager from the asset pool. /// The name of the asset manager to remove. public void removeAssetManager(string key) { - assetPool.Remove(key); + this.assetPool.Remove(key); } - /// - /// Go through all of the asset managers and load assets according to their respective paths. - /// + /// Go through all of the asset managers and load assets according to their respective paths. public void loadAllAssets() { foreach (KeyValuePair assetManager in this.assetPool) - { assetManager.Value.loadAssets(); - } } - /// - /// Creates an extended animated sprite object given the asset name in the asset manager. - /// - /// - /// + /// Creates an extended animated sprite object given the asset name in the asset manager. + /// The asset name. public AnimatedSpriteExtended getAnimatedSpriteFromAsset(string name) { - assetPool.TryGetValue(name, out AssetManager asset); + this.assetPool.TryGetValue(name, out AssetManager asset); var assetSheet = asset.getAssetByName(name); - return new AnimatedSpriteExtended(assetSheet.path.Clone().ToString(),assetSheet.index, (int)assetSheet.assetInfo.assetSize.X, (int)assetSheet.assetInfo.assetSize.Y); + return new AnimatedSpriteExtended(assetSheet.path.Clone().ToString(), assetSheet.index, (int)assetSheet.assetInfo.assetSize.X, (int)assetSheet.assetInfo.assetSize.Y); } - - /// - /// Generates a new AnimatedSpriteCollection object from the data held in an asset sheet. - /// + /// Generates a new AnimatedSpriteCollection object from the data held in an asset sheet. /// An asset sheet that holds the data for textures. /// The type of asset to get from the sheet. Hair, eyes, shoes, etc. - /// public AnimatedSpriteCollection getSpriteCollectionFromSheet(AssetSheet assetSheet, AnimationType type) - { - var left = new AnimatedSpriteExtended(assetSheet.clone().getTexture(Direction.left, type),assetSheet); - var right = new AnimatedSpriteExtended(assetSheet.clone().getTexture(Direction.right, type), assetSheet); - var up = new AnimatedSpriteExtended(assetSheet.clone().getTexture(Direction.up, type), assetSheet); - var down = new AnimatedSpriteExtended(assetSheet.clone().getTexture(Direction.down, type), assetSheet); - return new AnimatedSpriteCollection(left, right, up, down, Direction.down); + { + var left = new AnimatedSpriteExtended(assetSheet.clone().getTexture(Direction.left, type), assetSheet); + var right = new AnimatedSpriteExtended(assetSheet.clone().getTexture(Direction.right, type), assetSheet); + var up = new AnimatedSpriteExtended(assetSheet.clone().getTexture(Direction.up, type), assetSheet); + var down = new AnimatedSpriteExtended(assetSheet.clone().getTexture(Direction.down, type), assetSheet); + return new AnimatedSpriteCollection(left, right, up, down, Direction.down); } - - /// - /// Gets an animated sprite collection (ie a hair style facing all four directions) from a list of asset names. - /// + /// Gets an animated sprite collection (ie a hair style facing all four directions) from a list of asset names. /// The name of the asset for the left facing sprite. /// The name of the asset for the right facing sprite. /// The name of the asset for the up facing sprite. /// The name of the asset for the down facing sprite. - /// - /// + /// The sprite's starting direction. public AnimatedSpriteCollection getAnimatedSpriteCollectionFromAssets(string left, string right, string up, string down, Direction startingDirection = Direction.down) { - var Left = getAnimatedSpriteFromAsset(left); - var Right = getAnimatedSpriteFromAsset(right); - var Up = getAnimatedSpriteFromAsset(up); - var Down = getAnimatedSpriteFromAsset(down); - return new AnimatedSpriteCollection(Left, Right, Up, Down, startingDirection); + var leftSprite = this.getAnimatedSpriteFromAsset(left); + var rightSprite = this.getAnimatedSpriteFromAsset(right); + var upSprite = this.getAnimatedSpriteFromAsset(up); + var downSprite = this.getAnimatedSpriteFromAsset(down); + return new AnimatedSpriteCollection(leftSprite, rightSprite, upSprite, downSprite, startingDirection); } - /// - /// Get an AnimatedSpriteCollection from a name pairing. - /// + /// Get an AnimatedSpriteCollection from a name pairing. /// A collection of strings that hold information on directional textures. /// The direction in which the sprite should face. - /// public AnimatedSpriteCollection getAnimatedSpriteCollectionFromAssets(NamePairings pair, Direction startingDirection = Direction.down) { - return getAnimatedSpriteCollectionFromAssets(pair.leftString, pair.rightString, pair.upString, pair.downString); + return this.getAnimatedSpriteCollectionFromAssets(pair.leftString, pair.rightString, pair.upString, pair.downString); } - /// - /// Get a collection of sprites to generate a collective animated sprite. - /// + /// Get a collection of sprites to generate a collective animated sprite. /// The collection of sprites to be used for the boyd of the npc. /// The collection of sprites to be used for the eye of the npc. /// The collection of sprites to be used for the hair of the npc. @@ -174,48 +132,44 @@ namespace CustomNPCFramework.Framework.Graphics /// The collection of sprites to be used for the shoes of the npc. /// The collection of sprites to be used for the accessories of the npc. /// The collection of collors to be used for chaing the color of an individual asset. - /// - public StandardCharacterAnimation GetStandardCharacterAnimation(NamePairings BodySprites, NamePairings EyeSprites, NamePairings HairSprites, NamePairings ShirtsSprites, NamePairings PantsSprites, NamePairings ShoesSprites,List AccessoriesSprites,StandardColorCollection DrawColors=null) + public StandardCharacterAnimation GetStandardCharacterAnimation(NamePairings BodySprites, NamePairings EyeSprites, NamePairings HairSprites, NamePairings ShirtsSprites, NamePairings PantsSprites, NamePairings ShoesSprites, List AccessoriesSprites, StandardColorCollection DrawColors = null) { - var body = getAnimatedSpriteCollectionFromAssets(BodySprites); - var eyes = getAnimatedSpriteCollectionFromAssets(EyeSprites); - var hair = getAnimatedSpriteCollectionFromAssets(HairSprites); - var shirts = getAnimatedSpriteCollectionFromAssets(ShirtsSprites); - var pants = getAnimatedSpriteCollectionFromAssets(PantsSprites); - var shoes = getAnimatedSpriteCollectionFromAssets(ShoesSprites); + var body = this.getAnimatedSpriteCollectionFromAssets(BodySprites); + var eyes = this.getAnimatedSpriteCollectionFromAssets(EyeSprites); + var hair = this.getAnimatedSpriteCollectionFromAssets(HairSprites); + var shirts = this.getAnimatedSpriteCollectionFromAssets(ShirtsSprites); + var pants = this.getAnimatedSpriteCollectionFromAssets(PantsSprites); + var shoes = this.getAnimatedSpriteCollectionFromAssets(ShoesSprites); + List accessories = new List(); - foreach(var v in AccessoriesSprites) - { - accessories.Add(getAnimatedSpriteCollectionFromAssets(v)); - } - if (DrawColors == null) DrawColors = new StandardColorCollection(); - return new StandardCharacterAnimation(body,eyes,hair,shirts,pants,shoes,accessories,DrawColors); + foreach (var v in AccessoriesSprites) + accessories.Add(this.getAnimatedSpriteCollectionFromAssets(v)); + + if (DrawColors == null) + DrawColors = new StandardColorCollection(); + + return new StandardCharacterAnimation(body, eyes, hair, shirts, pants, shoes, accessories, DrawColors); } - /// - /// Get a list of parts that can apply for this criteria. - /// + /// Get a list of parts that can apply for this criteria. /// The name of the asset manager. /// The gender critera. /// The season critera. /// The part type critera. - /// - public List getListOfApplicableBodyParts(string assetManagerName,Genders gender, Seasons season, PartType type) + public List getListOfApplicableBodyParts(string assetManagerName, Genders gender, Seasons season, PartType type) { var parts = this.getAssetManager(assetManagerName).getListOfAssetsThatMatchThisCriteria(gender, season, type); return parts; } - - /// - /// Generate a basic npc based off of all all of the NPC data here. - /// - /// - /// - /// - public ExtendedNPC generateNPC(Genders gender, int minNumOfAccessories, int maxNumOfAccessories ,StandardColorCollection DrawColors=null) + /// Generate a basic NPC based on the NPC data here. + /// The NPC gender. + /// The minimum number of accessories to generate. + /// The maximum number of accessories to generate. + /// The colors for the NPC's different assets. + public ExtendedNpc generateNPC(Genders gender, int minNumOfAccessories, int maxNumOfAccessories, StandardColorCollection drawColors = null) { - Seasons myseason=Seasons.spring; + Seasons myseason = Seasons.spring; if (Game1.currentSeason == "spring") myseason = Seasons.spring; if (Game1.currentSeason == "summer") myseason = Seasons.summer; @@ -233,95 +187,87 @@ namespace CustomNPCFramework.Framework.Graphics //Get all applicable parts from this current asset manager foreach (var assetManager in this.assetPool) { - var body = getListOfApplicableBodyParts(assetManager.Key, gender, myseason, PartType.body); + var body = this.getListOfApplicableBodyParts(assetManager.Key, gender, myseason, PartType.body); foreach (var piece in body) bodyList.Add(piece); - var eyes = getListOfApplicableBodyParts(assetManager.Key, gender, myseason, PartType.eyes); + var eyes = this.getListOfApplicableBodyParts(assetManager.Key, gender, myseason, PartType.eyes); foreach (var piece in eyes) eyesList.Add(piece); - var hair = getListOfApplicableBodyParts(assetManager.Key, gender, myseason, PartType.hair); + var hair = this.getListOfApplicableBodyParts(assetManager.Key, gender, myseason, PartType.hair); foreach (var piece in hair) hairList.Add(piece); - var shirt = getListOfApplicableBodyParts(assetManager.Key, gender, myseason, PartType.shirt); + var shirt = this.getListOfApplicableBodyParts(assetManager.Key, gender, myseason, PartType.shirt); foreach (var piece in shirt) shirtList.Add(piece); - var pants = getListOfApplicableBodyParts(assetManager.Key, gender, myseason, PartType.pants); + var pants = this.getListOfApplicableBodyParts(assetManager.Key, gender, myseason, PartType.pants); foreach (var piece in pants) pantsList.Add(piece); - var shoes = getListOfApplicableBodyParts(assetManager.Key, gender, myseason, PartType.shoes); + var shoes = this.getListOfApplicableBodyParts(assetManager.Key, gender, myseason, PartType.shoes); foreach (var piece in shoes) shoesList.Add(piece); - var accessory = getListOfApplicableBodyParts(assetManager.Key, gender, myseason, PartType.accessory); + var accessory = this.getListOfApplicableBodyParts(assetManager.Key, gender, myseason, PartType.accessory); foreach (var piece in accessory) accessoryList.Add(piece); } - - Random r = new Random(System.DateTime.Now.Millisecond); - int amount = 0; - - amount = r.Next(minNumOfAccessories,maxNumOfAccessories + 1); //Necessary since r.next returns a num between min and (max-1) - int bodyIndex = 0; - int eyesIndex = 0; - int hairIndex = 0; - int shirtIndex = 0; - int pantsIndex = 0; - int shoesIndex = 0; + Random r = new Random(DateTime.Now.Millisecond); + int amount = r.Next(minNumOfAccessories, maxNumOfAccessories + 1); - if (bodyList.Count != 0) { + int bodyIndex; + int eyesIndex; + int hairIndex; + int shirtIndex; + int pantsIndex; + int shoesIndex; + + if (bodyList.Count != 0) bodyIndex = r.Next(0, bodyList.Count - 1); - } else { Class1.ModMonitor.Log("Error: Not enough body templates to generate an npc. Aborting", StardewModdingAPI.LogLevel.Error); return null; } - if (eyesList.Count != 0) { + if (eyesList.Count != 0) eyesIndex = r.Next(0, eyesList.Count - 1); - } else { Class1.ModMonitor.Log("Error: Not enough eyes templates to generate an npc. Aborting", StardewModdingAPI.LogLevel.Error); return null; } - if (hairList.Count != 0) { + if (hairList.Count != 0) hairIndex = r.Next(0, hairList.Count - 1); - } else { Class1.ModMonitor.Log("Error: Not enough hair templates to generate an npc. Aborting", StardewModdingAPI.LogLevel.Error); return null; } - if (shirtList.Count != 0) { + if (shirtList.Count != 0) shirtIndex = r.Next(0, shirtList.Count - 1); - } else { Class1.ModMonitor.Log("Error: Not enough shirt templates to generate an npc. Aborting", StardewModdingAPI.LogLevel.Error); return null; } - if (pantsList.Count != 0) { + if (pantsList.Count != 0) pantsIndex = r.Next(0, pantsList.Count - 1); - } else { Class1.ModMonitor.Log("Error: Not enough pants templates to generate an npc. Aborting", StardewModdingAPI.LogLevel.Error); return null; } - if (shoesList.Count != 0) { + if (shoesList.Count != 0) shoesIndex = r.Next(0, shoesList.Count - 1); - - } else { Class1.ModMonitor.Log("Error: Not enough shoes templates to generate an npc. Aborting", StardewModdingAPI.LogLevel.Error); return null; } + List accIntList = new List(); if (accessoryList.Count != 0) { @@ -333,97 +279,80 @@ namespace CustomNPCFramework.Framework.Graphics } //Get a single sheet to pull from. - AssetSheet bodySheet; - AssetSheet eyesSheet; - AssetSheet hairSheet; - AssetSheet shirtSheet; - AssetSheet shoesSheet; - AssetSheet pantsSheet; - - bodySheet = bodyList.ElementAt(bodyIndex); - eyesSheet = eyesList.ElementAt(eyesIndex); - hairSheet = hairList.ElementAt(hairIndex); - shirtSheet = shirtList.ElementAt(shirtIndex); - pantsSheet = pantsList.ElementAt(pantsIndex); - shoesSheet = shoesList.ElementAt(shoesIndex); - + AssetSheet bodySheet = bodyList.ElementAt(bodyIndex); + AssetSheet eyesSheet = eyesList.ElementAt(eyesIndex); + AssetSheet hairSheet = hairList.ElementAt(hairIndex); + AssetSheet shirtSheet = shirtList.ElementAt(shirtIndex); + AssetSheet pantsSheet = pantsList.ElementAt(pantsIndex); + AssetSheet shoesSheet = shoesList.ElementAt(shoesIndex); List accessorySheet = new List(); - - foreach (var v in accIntList) - { + foreach (int v in accIntList) accessorySheet.Add(accessoryList.ElementAt(v)); - } - if (DrawColors == null) DrawColors = new StandardColorCollection(); - var render = generateBasicRenderer(bodySheet, eyesSheet, hairSheet, shirtSheet, pantsSheet, shoesSheet, accessorySheet,DrawColors); - ExtendedNPC npc = new ExtendedNPC(new Sprite(getDefaultSpriteImage(bodySheet)), render, new Microsoft.Xna.Framework.Vector2(0,0) * Game1.tileSize, 2, NPCNames.getRandomNPCName(gender)); - return npc; - } - /// - /// Creates a character renderer (a collection of textures) from a bunch of different asset sheets. - /// - /// The textures for the npc's body. - /// The textures for the npc's eyes. - /// The textures for the npc's hair. - /// The textures for the npc's shirt. - /// The textures for the npc's pants. - /// The textures for the npc's shoes. - /// The textures for the npc's accessories. - /// The colors for the npc's different assets. - /// - public virtual BasicRenderer generateBasicRenderer(AssetSheet bodySheet, AssetSheet eyesSheet, AssetSheet hairSheet, AssetSheet shirtSheet, AssetSheet pantsSheet, AssetSheet shoesSheet, List accessorySheet, StandardColorCollection DrawColors=null) - { - if (DrawColors == null) DrawColors = new StandardColorCollection(); - //Get all of the appropriate animations. - AnimationType type = AnimationType.standing; - var standingAnimation = generateCharacterAnimation(bodySheet, eyesSheet, hairSheet, shirtSheet, pantsSheet, shoesSheet, accessorySheet, type,DrawColors); - type = AnimationType.walking; - var movingAnimation = generateCharacterAnimation(bodySheet, eyesSheet, hairSheet, shirtSheet, pantsSheet, shoesSheet, accessorySheet, type,DrawColors); - type = AnimationType.swimming; - var swimmingAnimation = generateCharacterAnimation(bodySheet, eyesSheet, hairSheet, shirtSheet, pantsSheet, shoesSheet, accessorySheet, type,DrawColors); + if (drawColors == null) + drawColors = new StandardColorCollection(); - BasicRenderer render = new BasicRenderer(standingAnimation, movingAnimation, swimmingAnimation); - return render; + var render = this.generateBasicRenderer(bodySheet, eyesSheet, hairSheet, shirtSheet, pantsSheet, shoesSheet, accessorySheet, drawColors); + return new ExtendedNpc(new Sprite(this.getDefaultSpriteImage(bodySheet)), render, new Microsoft.Xna.Framework.Vector2(0, 0) * Game1.tileSize, 2, NpcNames.getRandomNpcName(gender)); } - /// - /// Generate a Standard Character Animation from some asset sheets. - /// (collection of textures to animations) - /// - /// The textures for the npc's body. - /// The textures for the npc's eyes. - /// The textures for the npc's hair. - /// The textures for the npc's shirt. - /// The textures for the npc's pants. - /// The textures for the npc's shoes. - /// The textures for the npc's accessories. - /// The colors for the npc's different assets. - /// - public virtual StandardCharacterAnimation generateCharacterAnimation(AssetSheet body, AssetSheet eyes, AssetSheet hair, AssetSheet shirt, AssetSheet pants, AssetSheet shoes,List accessories, AnimationType animationType, StandardColorCollection DrawColors=null) + /// Creates a character renderer (a collection of textures) from a bunch of different asset sheets. + /// The textures for the NPC's body. + /// The textures for the NPC's eyes. + /// The textures for the NPC's hair. + /// The textures for the NPC's shirt. + /// The textures for the NPC's pants. + /// The textures for the NPC's shoes. + /// The textures for the NPC's accessories. + /// The colors for the NPC's different assets. + public virtual BasicRenderer generateBasicRenderer(AssetSheet bodySheet, AssetSheet eyesSheet, AssetSheet hairSheet, AssetSheet shirtSheet, AssetSheet pantsSheet, AssetSheet shoesSheet, List accessorySheet, StandardColorCollection drawColors = null) { - var bodySprite = getSpriteCollectionFromSheet(body, animationType); - var eyesSprite = getSpriteCollectionFromSheet(eyes, animationType); - var hairSprite = getSpriteCollectionFromSheet(hair, animationType); - var shirtSprite = getSpriteCollectionFromSheet(shirt, animationType); - var pantsSprite = getSpriteCollectionFromSheet(pants, animationType); - var shoesSprite = getSpriteCollectionFromSheet(shoes, animationType); + if (drawColors == null) + drawColors = new StandardColorCollection(); + + // Get all of the appropriate animations. + StandardCharacterAnimation standingAnimation = this.generateCharacterAnimation(bodySheet, eyesSheet, hairSheet, shirtSheet, pantsSheet, shoesSheet, accessorySheet, AnimationType.standing, drawColors); + StandardCharacterAnimation movingAnimation = this.generateCharacterAnimation(bodySheet, eyesSheet, hairSheet, shirtSheet, pantsSheet, shoesSheet, accessorySheet, AnimationType.walking, drawColors); + StandardCharacterAnimation swimmingAnimation = this.generateCharacterAnimation(bodySheet, eyesSheet, hairSheet, shirtSheet, pantsSheet, shoesSheet, accessorySheet, AnimationType.swimming, drawColors); + + return new BasicRenderer(standingAnimation, movingAnimation, swimmingAnimation); + } + + /// Generate a Standard Character Animation from some asset sheets. (collection of textures to animations) + /// The textures for the NPC's body. + /// The textures for the NPC's eyes. + /// The textures for the NPC's hair. + /// The textures for the NPC's shirt. + /// The textures for the NPC's pants. + /// The textures for the NPC's shoes. + /// The textures for the NPC's accessories. + /// The animation type to generate. + /// The colors for the NPC's different assets. + public virtual StandardCharacterAnimation generateCharacterAnimation(AssetSheet body, AssetSheet eyes, AssetSheet hair, AssetSheet shirt, AssetSheet pants, AssetSheet shoes, List accessories, AnimationType animationType, StandardColorCollection drawColors = null) + { + AnimatedSpriteCollection bodySprite = this.getSpriteCollectionFromSheet(body, animationType); + AnimatedSpriteCollection eyesSprite = this.getSpriteCollectionFromSheet(eyes, animationType); + AnimatedSpriteCollection hairSprite = this.getSpriteCollectionFromSheet(hair, animationType); + AnimatedSpriteCollection shirtSprite = this.getSpriteCollectionFromSheet(shirt, animationType); + AnimatedSpriteCollection pantsSprite = this.getSpriteCollectionFromSheet(pants, animationType); + AnimatedSpriteCollection shoesSprite = this.getSpriteCollectionFromSheet(shoes, animationType); + List accessoryCollection = new List(); foreach (var v in accessories) { - AnimatedSpriteCollection acc = getSpriteCollectionFromSheet(v, AnimationType.standing); + AnimatedSpriteCollection acc = this.getSpriteCollectionFromSheet(v, AnimationType.standing); accessoryCollection.Add(acc); } - if (DrawColors == null) DrawColors = new StandardColorCollection(); - StandardCharacterAnimation standingAnimation = new StandardCharacterAnimation(bodySprite, eyesSprite, hairSprite, shirtSprite, pantsSprite, shoesSprite, accessoryCollection,DrawColors); - return standingAnimation; + + if (drawColors == null) + drawColors = new StandardColorCollection(); + + return new StandardCharacterAnimation(bodySprite, eyesSprite, hairSprite, shirtSprite, pantsSprite, shoesSprite, accessoryCollection, drawColors); } - /// - /// Get the string for the standard character sprite to be used from this asset sheet. - /// + /// Get the string for the standard character sprite to be used from this asset sheet. /// The standard asset sheet to be used. - /// public virtual string getDefaultSpriteImage(AssetSheet imageGraphics) { return Class1.getRelativeDirectory(Path.Combine(imageGraphics.path, imageGraphics.assetInfo.standingAssetPaths.downString)); diff --git a/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetSheet.cs b/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetSheet.cs index d2b7eabc..d868de75 100644 --- a/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetSheet.cs +++ b/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetSheet.cs @@ -1,131 +1,95 @@ -using CustomNPCFramework.Framework.Enums; +using System.Collections.Generic; +using CustomNPCFramework.Framework.Enums; using CustomNPCFramework.Framework.Graphics.TextureGroups; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; using StardustCore.UIUtilities; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace CustomNPCFramework.Framework.Graphics { - /// - /// Used to handle loading different textures and handling opperations on those textures. - /// + /// Used to handle loading different textures and handling opperations on those textures. public class AssetSheet { - /// - /// Used to hold the textures for the AssetSheet. - /// - public TextureGroups.TextureGroup textures; + /// Used to hold the textures for the AssetSheet. + public TextureGroup textures; - /// - /// Used to hold the info for the paths to these textures. - /// + /// Used to hold the info for the paths to these textures. public AssetInfo assetInfo; - - /// - /// The path to this assetinfo.json file - /// + + /// The path to this assetinfo.json file public string path; - /// - /// The soruce rectangle for the current texture to draw. - /// + /// The source rectangle for the current texture to draw. public Rectangle currentAsset; public int index; - /// - /// Constructor. - /// + + /// Construct an instance. /// The asset info file to be read in or created. Holds path information. /// The path to the assetinfo file. /// The direction to set the animation. - public AssetSheet(AssetInfo info,string path,Direction direction=Direction.down) + public AssetSheet(AssetInfo info, string path, Direction direction = Direction.down) { this.assetInfo = info; - this.textures = new TextureGroup(info,path,direction); + this.textures = new TextureGroup(info, path, direction); try { this.path = Class1.getShortenedDirectory(path); } - catch(Exception err) + catch { this.path = path; } this.index = 0; } - /// - /// Get the path to the current texture. - /// - /// + + /// Get the path to the current texture. public virtual KeyValuePair getPathTexturePair() { return new KeyValuePair(this.path, this.textures.currentTexture.currentTexture); } - - /// - /// Used just to get a copy of this asset sheet. - /// + /// Used just to get a copy of this asset sheet. public virtual AssetSheet clone() { - var asset = new AssetSheet(this.assetInfo,(string)this.path.Clone()); + var asset = new AssetSheet(this.assetInfo, (string)this.path.Clone()); return asset; } - /// - /// Sets the textures for this sheet to face left. - /// + /// Sets the textures for this sheet to face left. public virtual void setLeft() { this.textures.setLeft(); } - /// - /// Sets the textures for this sheet to face up. - /// + /// Sets the textures for this sheet to face up. public virtual void setUp() { this.textures.setUp(); } - /// - /// Sets the textures for this sheet to face down. - /// + /// Sets the textures for this sheet to face down. public virtual void setDown() { this.textures.setDown(); } - /// - /// Sets the textures for this sheet to face left. - /// + /// Sets the textures for this sheet to face left. public virtual void setRight() { this.textures.setRight(); } - /// - /// Get the current animation texture. - /// - /// + /// Get the current animation texture. public virtual Texture2DExtended getCurrentSpriteTexture() { return this.textures.currentTexture.currentTexture; } - /// - /// Get the specific texture depending on the direction and animation type. - /// - /// - /// - /// - public virtual Texture2DExtended getTexture(Direction direction,AnimationType type) + /// Get the specific texture depending on the direction and animation type. + /// The facing direction. + /// The animation type. + public virtual Texture2DExtended getTexture(Direction direction, AnimationType type) { return this.textures.getTextureFromAnimation(type).getTextureFromDirection(direction); } diff --git a/GeneralMods/CustomNPCFramework/Framework/Graphics/DirectionalTexture.cs b/GeneralMods/CustomNPCFramework/Framework/Graphics/DirectionalTexture.cs index 4303cf5a..d87d532e 100644 --- a/GeneralMods/CustomNPCFramework/Framework/Graphics/DirectionalTexture.cs +++ b/GeneralMods/CustomNPCFramework/Framework/Graphics/DirectionalTexture.cs @@ -1,134 +1,138 @@ -using CustomNPCFramework.Framework.Enums; -using Microsoft.Xna.Framework.Graphics; +using System.IO; +using CustomNPCFramework.Framework.Enums; using StardewModdingAPI; using StardustCore.UIUtilities; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace CustomNPCFramework.Framework.Graphics { - /// - /// A class that's used to hold textures for different directions. - /// + /// A class that's used to hold textures for different directions. public class DirectionalTexture { - /// - /// The left texture for this group. - /// + /// The left texture for this group. public Texture2DExtended leftTexture; - /// - /// The right texture for this group. - /// + + /// The right texture for this group. public Texture2DExtended rightTexture; - - /// - /// The down textiure for this group. - /// + + /// The down textiure for this group. public Texture2DExtended downTexture; - /// - /// The up texture for this group. - /// + + /// The up texture for this group. public Texture2DExtended upTexture; - /// - /// The current texture for this group. - /// + /// The current texture for this group. public Texture2DExtended currentTexture; - /// - /// Constructor. - /// + /// Construct an instance. /// The left texture to use. /// The right texture to use. /// The up texture to use. /// The down texture to use. /// The direction texture for the sprite to face. - public DirectionalTexture(Texture2DExtended left, Texture2DExtended right, Texture2DExtended up, Texture2DExtended down, Direction direction=Direction.down) + public DirectionalTexture(Texture2DExtended left, Texture2DExtended right, Texture2DExtended up, Texture2DExtended down, Direction direction = Direction.down) { this.leftTexture = left; this.rightTexture = right; this.upTexture = up; this.downTexture = down; - if (direction == Direction.left) this.currentTexture = leftTexture; - if (direction == Direction.right) this.currentTexture = rightTexture; - if (direction == Direction.up) this.currentTexture = upTexture; - if (direction == Direction.down) this.currentTexture = downTexture; + switch (direction) + { + case Direction.left: + this.currentTexture = this.leftTexture; + break; + case Direction.right: + this.currentTexture = this.rightTexture; + break; + case Direction.up: + this.currentTexture = this.upTexture; + break; + + case Direction.down: + this.currentTexture = this.downTexture; + break; + } } - - public DirectionalTexture(IModHelper helper ,NamePairings info, string path, Direction direction = Direction.down) + public DirectionalTexture(IModHelper helper, NamePairings info, string path, Direction direction = Direction.down) { - - new Texture2DExtended(helper, Class1.Manifest, path); - - string leftString= Class1.getShortenedDirectory(Path.Combine(path, info.leftString + ".png")).Remove(0, 1); + string leftString = Class1.getShortenedDirectory(Path.Combine(path, info.leftString + ".png")).Remove(0, 1); string rightString = Class1.getShortenedDirectory(Path.Combine(path, info.rightString + ".png")).Remove(0, 1); string upString = Class1.getShortenedDirectory(Path.Combine(path, info.upString + ".png")).Remove(0, 1); string downString = Class1.getShortenedDirectory(Path.Combine(path, info.downString + ".png")).Remove(0, 1); - this.leftTexture = new Texture2DExtended(helper, Class1.Manifest, leftString); this.rightTexture = new Texture2DExtended(helper, Class1.Manifest, rightString); this.upTexture = new Texture2DExtended(helper, Class1.Manifest, upString); this.downTexture = new Texture2DExtended(helper, Class1.Manifest, downString); - if (direction == Direction.left) this.currentTexture = leftTexture; - if (direction == Direction.right) this.currentTexture = rightTexture; - if (direction == Direction.up) this.currentTexture = upTexture; - if (direction == Direction.down) this.currentTexture = downTexture; + switch (direction) + { + case Direction.left: + this.currentTexture = this.leftTexture; + break; + + case Direction.right: + this.currentTexture = this.rightTexture; + break; + + case Direction.up: + this.currentTexture = this.upTexture; + break; + + case Direction.down: + this.currentTexture = this.downTexture; + break; + } } - /// - /// Sets the direction of this current texture to left. - /// + /// Sets the direction of this current texture to left. public void setLeft() { - this.currentTexture = leftTexture; + this.currentTexture = this.leftTexture; } - /// - /// Sets the direction of this current texture to up. - /// + /// Sets the direction of this current texture to up. public void setUp() { - this.currentTexture = upTexture; + this.currentTexture = this.upTexture; } - /// - /// Sets the direction of this current texture to down. - /// + /// Sets the direction of this current texture to down. public void setDown() { - this.currentTexture = downTexture; + this.currentTexture = this.downTexture; } - /// - /// Sets the direction of this current texture to right. - /// + /// Sets the direction of this current texture to right. public void setRight() { - this.currentTexture = rightTexture; + this.currentTexture = this.rightTexture; } - /// - /// Gets the texture from this texture group depending on the direction. - /// - /// - /// + /// Gets the texture from this texture group depending on the direction. + /// The facing direction. public virtual Texture2DExtended getTextureFromDirection(Direction direction) { - if (direction == Direction.left) return this.leftTexture; - if (direction == Direction.right) return this.rightTexture; - if (direction == Direction.up) return this.upTexture; - if (direction == Direction.down) return this.downTexture; - return null; + switch (direction) + { + case Direction.left: + return this.leftTexture; + + case Direction.right: + return this.rightTexture; + + case Direction.up: + return this.upTexture; + + case Direction.down: + return this.downTexture; + + default: + return null; + } } } } diff --git a/GeneralMods/CustomNPCFramework/Framework/Graphics/ExtendedAssetInfo.cs b/GeneralMods/CustomNPCFramework/Framework/Graphics/ExtendedAssetInfo.cs index 0590fee3..41745722 100644 --- a/GeneralMods/CustomNPCFramework/Framework/Graphics/ExtendedAssetInfo.cs +++ b/GeneralMods/CustomNPCFramework/Framework/Graphics/ExtendedAssetInfo.cs @@ -1,73 +1,55 @@ -using CustomNPCFramework.Framework.Enums; -using Microsoft.Xna.Framework; -using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using CustomNPCFramework.Framework.Enums; +using Microsoft.Xna.Framework; namespace CustomNPCFramework.Framework.Graphics { - /// - /// An expanded Asset info class that deals with seasons and genders. - /// - public class ExtendedAssetInfo :AssetInfo + /// An expanded Asset info class that deals with seasons and genders. + public class ExtendedAssetInfo : AssetInfo { - /// - /// The genders this part is associated with. 0=Male, 1=female, 2=other. - /// + /// The genders this part is associated with. public Genders gender; - /// - /// A list of seasons where this part can be displayed - /// - public List seasons=new List(); - /// - /// The part type to be used for this asset such as hair, eyes, etc. - /// + + /// A list of seasons where this part can be displayed. + public List seasons = new List(); + + /// The part type to be used for this asset such as hair, eyes, etc. public PartType type; - - /// - /// Constructor. - /// - public ExtendedAssetInfo() + + /// Construct an instance. + public ExtendedAssetInfo() { } + + /// Construct an instance. + /// The name of the asset. This is the name that will be referenced in any asset manager or asset pool. + /// The name of the files to be used for the standing animation. + /// The name of the files to be used for the moving animation. + /// The name of the files to be used for the swimming animation. + /// The name of the files to be used for the sitting animation. + /// The size of the asset. Width and height of the texture. + /// Legacy, not really used anymore. + /// The type of gender this asset will be associated with. + /// The type of season this asset will be associated with. + /// The part type to be used for this asset such as hair, eyes, etc. + public ExtendedAssetInfo(string name, NamePairings standingAssetPaths, NamePairings movingAssetPaths, NamePairings swimmingAssetPaths, NamePairings sittingAssetPaths, Vector2 assetSize, bool randomizeOnLoad, Genders gender, List season, PartType type) + : base(name, standingAssetPaths, movingAssetPaths, swimmingAssetPaths, sittingAssetPaths, assetSize, randomizeOnLoad) { - this.seasons = new List(); - } - - /// - /// Constructor. - /// - /// - /// - /// - /// The type of gender this asset will be associated with. - /// The type of season this asset will be associated with. - public ExtendedAssetInfo(string name, NamePairings StandingAssetPaths, NamePairings MovingAssetPaths, NamePairings SwimmingAssetPaths, NamePairings SittingAssetPaths, Vector2 assetSize, bool randomizeOnLoad, Genders Gender, List Season, PartType Type): base(name,StandingAssetPaths,MovingAssetPaths,SwimmingAssetPaths,SittingAssetPaths, assetSize, randomizeOnLoad) - { - this.gender = Gender; - this.seasons = Season; - if (this.seasons == null) this.seasons = new List(); - this.type = Type; + this.gender = gender; + this.seasons = season ?? new List(); + this.type = type; } - /// - /// Save the json to a certain location. - /// - /// + /// Save the json to a certain location. + /// The absolute path to write. public new void writeToJson(string path) { Class1.ModHelper.WriteJsonFile(path, this); } - /// - /// Read the json from a certain location. - /// - /// - /// + /// Read the json from a certain location. + /// The absolute path to read. public new static ExtendedAssetInfo readFromJson(string path) { return Class1.ModHelper.ReadJsonFile(path); } - } } diff --git a/GeneralMods/CustomNPCFramework/Framework/Graphics/TextureGroups/TextureGroup.cs b/GeneralMods/CustomNPCFramework/Framework/Graphics/TextureGroups/TextureGroup.cs index 7b9f67d6..c5e9bd47 100644 --- a/GeneralMods/CustomNPCFramework/Framework/Graphics/TextureGroups/TextureGroup.cs +++ b/GeneralMods/CustomNPCFramework/Framework/Graphics/TextureGroups/TextureGroup.cs @@ -1,96 +1,67 @@ -using CustomNPCFramework.Framework.Enums; -using Microsoft.Xna.Framework.Graphics; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using CustomNPCFramework.Framework.Enums; namespace CustomNPCFramework.Framework.Graphics.TextureGroups { - /// - /// A group of a textures used to hold all of the textures associated with a single asset such as a hair style or a shirt. - /// + /// A group of a textures used to hold all of the textures associated with a single asset such as a hair style or a shirt. public class TextureGroup { - /// - /// The directional (Left, Right, Up, Down) textures to be used when the NPC is standing. - /// + /// The directional (Left, Right, Up, Down) textures to be used when the NPC is standing. public DirectionalTexture standingTexture; - /// - /// The directional (Left, Right, Up, Down) textures to be used when the NPC is sitting. - /// + + /// The directional (Left, Right, Up, Down) textures to be used when the NPC is sitting. public DirectionalTexture sittingTexture; - /// - /// The directional (Left, Right, Up, Down) textures to be used when the NPC is swimming. - /// + + /// The directional (Left, Right, Up, Down) textures to be used when the NPC is swimming. public DirectionalTexture swimmingTexture; - /// - /// The directional (Left, Right, Up, Down) textures to be used when the NPC is moving. - /// + + /// The directional (Left, Right, Up, Down) textures to be used when the NPC is moving. public DirectionalTexture movingTexture; - /// - /// The current directional texture to be used by the npc. Can be things such as the standing, swimming, moving, or sitting texture. - /// + /// The current directional texture to be used by the npc. Can be things such as the standing, swimming, moving, or sitting texture. public DirectionalTexture currentTexture; - /// - /// Asset info loaded in from the corresponding .json file. - /// - private AssetInfo info; - /// - /// The path to the .json file. - /// - private string path; - /// - /// The current direction of the texture group. See Direction.cs - /// - private Direction dir; - /// - /// The type of asset this is. Body, hair, eyes, shirt,etc... - /// - private AnimationType type; + /// Asset info loaded in from the corresponding .json file. + private readonly AssetInfo info; - /// - /// Constructor. - /// + /// The path to the .json file. + private readonly string path; + + /// The current direction of the texture group. + private readonly Direction dir; + + /// The type of asset this is. Body, hair, eyes, shirt, etc. + private readonly AnimationType type; + + /// Construct an instance. /// The asset info file to be stored with this texture group. /// Use to locate the files on disk. /// Used to determine the current direction/animation to load /// The type of asset this is. Eyes, Hair, Shirts, etc - public TextureGroup(AssetInfo info, string path,Direction direction ,AnimationType animationType=AnimationType.standing) + public TextureGroup(AssetInfo info, string path, Direction direction, AnimationType animationType = AnimationType.standing) { - this.standingTexture = new DirectionalTexture(Class1.ModHelper,info.standingAssetPaths, path, direction); + this.standingTexture = new DirectionalTexture(Class1.ModHelper, info.standingAssetPaths, path, direction); this.sittingTexture = new DirectionalTexture(Class1.ModHelper, info.sittingAssetPaths, path, direction); this.swimmingTexture = new DirectionalTexture(Class1.ModHelper, info.swimmingAssetPaths, path, direction); - this.movingTexture = new DirectionalTexture(Class1.ModHelper,info.movingAssetPaths, path, direction); + this.movingTexture = new DirectionalTexture(Class1.ModHelper, info.movingAssetPaths, path, direction); this.info = info; this.path = path; this.dir = direction; this.type = animationType; - if (animationType == AnimationType.standing) this.currentTexture = standingTexture; - if (animationType == AnimationType.sitting) this.currentTexture = sittingTexture; - if (animationType == AnimationType.swimming) this.currentTexture = swimmingTexture; - if (animationType == AnimationType.walking) this.currentTexture = movingTexture; - + if (animationType == AnimationType.standing) this.currentTexture = this.standingTexture; + if (animationType == AnimationType.sitting) this.currentTexture = this.sittingTexture; + if (animationType == AnimationType.swimming) this.currentTexture = this.swimmingTexture; + if (animationType == AnimationType.walking) this.currentTexture = this.movingTexture; } - /// - /// Gets a clone of this texture group. - /// - /// + /// Gets a clone of this texture group. public TextureGroup clone() { return new TextureGroup(this.info, this.path, this.dir, this.type); } - - /// - /// Sets all of the different animations to use their left facing sprites. - /// + /// Sets all of the different animations to use their left facing sprites. public virtual void setLeft() { this.movingTexture.setLeft(); @@ -99,9 +70,7 @@ namespace CustomNPCFramework.Framework.Graphics.TextureGroups this.swimmingTexture.setLeft(); } - /// - /// Sets all of the different animations to use their up facing sprites. - /// + /// Sets all of the different animations to use their up facing sprites. public virtual void setUp() { this.movingTexture.setUp(); @@ -110,9 +79,7 @@ namespace CustomNPCFramework.Framework.Graphics.TextureGroups this.swimmingTexture.setUp(); } - /// - /// Sets all of the different animations to use their down facing sprites. - /// + /// Sets all of the different animations to use their down facing sprites. public virtual void setDown() { this.movingTexture.setDown(); @@ -121,9 +88,7 @@ namespace CustomNPCFramework.Framework.Graphics.TextureGroups this.swimmingTexture.setDown(); } - /// - /// Sets all of the different animations to use their right facing sprites. - /// + /// Sets all of the different animations to use their right facing sprites. public virtual void setRight() { this.movingTexture.setRight(); @@ -132,11 +97,8 @@ namespace CustomNPCFramework.Framework.Graphics.TextureGroups this.swimmingTexture.setRight(); } - /// - /// Get's the appropriate animation texture based on the type of animation key passed in. - /// - /// - /// + /// Gets the appropriate animation texture based on the type of animation key passed in. + /// The animation type. public virtual DirectionalTexture getTextureFromAnimation(AnimationType type) { if (type == AnimationType.standing) return this.standingTexture; @@ -145,6 +107,5 @@ namespace CustomNPCFramework.Framework.Graphics.TextureGroups if (type == AnimationType.sitting) return this.sittingTexture; return null; } - } } diff --git a/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/AnimatedSpriteCollection.cs b/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/AnimatedSpriteCollection.cs index 33f7caef..ce1160af 100644 --- a/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/AnimatedSpriteCollection.cs +++ b/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/AnimatedSpriteCollection.cs @@ -1,78 +1,62 @@ -using CustomNPCFramework.Framework.Enums; +using CustomNPCFramework.Framework.Enums; using CustomNPCFramework.Framework.NPCS; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using StardewValley; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -namespace CustomNPCFramework.Framework.ModularNPCS +namespace CustomNPCFramework.Framework.ModularNpcs { - /// - /// Used to hold all of the sprites for a single asset such as hair or bodies. - /// + /// Used to hold all of the sprites for a single asset such as hair or bodies. public class AnimatedSpriteCollection { - /// - /// The left sprite for this sprite asset part. - /// + /// The left sprite for this sprite asset part. AnimatedSpriteExtended leftSprite; - /// - /// The right sprite for this sprite asset part. - /// + + /// The right sprite for this sprite asset part. AnimatedSpriteExtended rightSprite; - /// - /// The up sprite for this sprite asset part. - /// + + /// The up sprite for this sprite asset part. AnimatedSpriteExtended upSprite; - /// - /// The down sprite for this sprite asset part. - /// + + /// The down sprite for this sprite asset part. AnimatedSpriteExtended downSprite; - /// - /// The current sprite for this sprite collection. This is one of the four directions for this collection. - /// + /// The current sprite for this sprite collection. This is one of the four directions for this collection. public AnimatedSpriteExtended currentSprite; - /// - /// Constructor. - /// + /// Construct an instance. /// Left animated sprite for this piece. /// Right animated sprite for this piece. /// Up animated sprite for this piece. /// Down animated sprite for this piece. - /// - public AnimatedSpriteCollection(AnimatedSpriteExtended LeftSprite,AnimatedSpriteExtended RightSprite,AnimatedSpriteExtended UpSprite,AnimatedSpriteExtended DownSprite,Direction startingSpriteDirection) + /// The sprite's initial facing direction. + public AnimatedSpriteCollection(AnimatedSpriteExtended LeftSprite, AnimatedSpriteExtended RightSprite, AnimatedSpriteExtended UpSprite, AnimatedSpriteExtended DownSprite, Direction startingSpriteDirection) { this.leftSprite = LeftSprite; this.rightSprite = RightSprite; this.upSprite = UpSprite; this.downSprite = DownSprite; - if (startingSpriteDirection == Direction.down) + switch (startingSpriteDirection) { - setDown(); - } - if (startingSpriteDirection == Direction.left) - { - setLeft(); - } - if (startingSpriteDirection == Direction.right) - { - setRight(); - } - if (startingSpriteDirection == Direction.up) - { - setUp(); + case Direction.down: + this.setDown(); + break; + + case Direction.left: + this.setLeft(); + break; + + case Direction.right: + this.setRight(); + break; + + case Direction.up: + this.setUp(); + break; } } - /// - /// Reloads all of the directional textures for this texture collection. - /// + /// Reloads all of the directional textures for this texture collection. public virtual void reload() { this.leftSprite.reload(); @@ -81,109 +65,66 @@ namespace CustomNPCFramework.Framework.ModularNPCS this.downSprite.reload(); } - /// - /// Sets the current sprite direction to face left. - /// + /// Sets the current sprite direction to face left. public void setLeft() { - this.currentSprite = leftSprite; + this.currentSprite = this.leftSprite; } - /// - /// Sets the current sprite direction to face right. - /// + /// Sets the current sprite direction to face right. public void setRight() { - this.currentSprite = rightSprite; + this.currentSprite = this.rightSprite; } - /// - /// Sets the current sprite direction to face down. - /// + /// Sets the current sprite direction to face down. public void setDown() { - this.currentSprite = downSprite; + this.currentSprite = this.downSprite; } - /// - /// Sets the current sprite direction to face up. - /// + /// Sets the current sprite direction to face up. public void setUp() { - this.currentSprite = upSprite; + this.currentSprite = this.upSprite; } - /// - /// Used to draw the sprite to the screen. - /// - /// - /// - /// + /// Used to draw the sprite to the screen. public void draw(SpriteBatch b, Vector2 screenPosition, float layerDepth) { b.Draw(this.currentSprite.sprite.Texture, screenPosition, new Rectangle?(this.currentSprite.sprite.sourceRect), Color.White, 0.0f, Vector2.Zero, (float)Game1.pixelZoom, this.currentSprite.sprite.currentAnimation == null || !this.currentSprite.sprite.currentAnimation[this.currentSprite.sprite.currentAnimationIndex].flip ? SpriteEffects.None : SpriteEffects.FlipHorizontally, layerDepth); } - /// - /// Used to draw the sprite to the screen. - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// + /// Used to draw the sprite to the screen. public void draw(SpriteBatch b, Vector2 screenPosition, float layerDepth, int xOffset, int yOffset, Color c, bool flip = false, float scale = 1f, float rotation = 0.0f, bool characterSourceRectOffset = false) { b.Draw(this.currentSprite.sprite.Texture, screenPosition, new Rectangle?(new Rectangle(this.currentSprite.sprite.sourceRect.X + xOffset, this.currentSprite.sprite.sourceRect.Y + yOffset, this.currentSprite.sprite.sourceRect.Width, this.currentSprite.sprite.sourceRect.Height)), c, rotation, characterSourceRectOffset ? new Vector2((float)(this.currentSprite.sprite.SpriteWidth / 2), (float)((double)this.currentSprite.sprite.SpriteHeight * 3.0 / 4.0)) : Vector2.Zero, scale, flip || this.currentSprite.sprite.currentAnimation != null && this.currentSprite.sprite.currentAnimation[this.currentSprite.sprite.currentAnimationIndex].flip ? SpriteEffects.FlipHorizontally : SpriteEffects.None, layerDepth); } - /// - /// A very verbose asset drawer. - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - public void draw(SpriteBatch b, ExtendedNPC npc, Vector2 position, Rectangle sourceRectangle,Color color, float alpha,Vector2 origin,float scale,SpriteEffects effects,float layerDepth) + /// A very verbose asset drawer. + public void draw(SpriteBatch b, ExtendedNpc npc, Vector2 position, Rectangle sourceRectangle, Color color, float alpha, Vector2 origin, float scale, SpriteEffects effects, float layerDepth) { //DEFINITELY FIX THIS PART. Something is wrong with how these two functions handle the drawing of my npc to the scene. //this.draw(b, position, layerDepth); - b.Draw(this.currentSprite.sprite.Texture,position,this.currentSprite.sprite.sourceRect, color, 0.0f, origin,scale,effects,layerDepth); + b.Draw(this.currentSprite.sprite.Texture, position, this.currentSprite.sprite.sourceRect, color, 0.0f, origin, scale, effects, layerDepth); //b.Draw(this.Sprite.Texture, npc.getLocalPosition(Game1.viewport) + new Vector2((float)(this.sprite.spriteWidth * Game1.pixelZoom / 2), (float)(this.GetBoundingBox().Height / 2)) + (this.shakeTimer > 0 ? new Vector2((float)Game1.random.Next(-1, 2), (float)Game1.random.Next(-1, 2)) : Vector2.Zero), new Microsoft.Xna.Framework.Rectangle?(this.Sprite.SourceRect), Color.White * alpha, this.rotation, new Vector2((float)(this.sprite.spriteWidth / 2), (float)((double)this.sprite.spriteHeight * 3.0 / 4.0)), Math.Max(0.2f, this.scale) * (float)Game1.pixelZoom, this.flip || this.sprite.currentAnimation != null && this.sprite.currentAnimation[this.sprite.currentAnimationIndex].flip ? SpriteEffects.FlipHorizontally : SpriteEffects.None, Math.Max(0.0f, this.drawOnTop ? 0.991f : (float)this.getStandingY() / 10000f)); } - - /// - /// Animate the current sprite. Theoreticlly works from index offset to how many frames - /// + /// Animate the current sprite. Theoreticlly works from index offset to how many frames /// The delay in milliseconds between frames. - public void Animate(float intervalDelay,bool loop=true) + public void Animate(float intervalDelay, bool loop = true) { - this.Animate(Game1.currentGameTime, 0,2, intervalDelay,this.currentSprite.sprite,loop); + this.Animate(Game1.currentGameTime, 0, 2, intervalDelay, this.currentSprite.sprite, loop); } - /// - /// Animate the current sprite. - /// + /// Animate the current sprite. /// The game time from Monogames/XNA /// The starting frame of the animation on the sprite sheet. /// The number of frames to animate the sprite. /// The delay between frames in milliseconds. /// The animated sprite from the npc. /// If true, the animation plays over and over again. - /// - public virtual bool Animate(GameTime gameTime, int startFrame, int numberOfFrames, float interval, AnimatedSprite sprite, bool loop=true) + public virtual bool Animate(GameTime gameTime, int startFrame, int numberOfFrames, float interval, AnimatedSprite sprite, bool loop = true) { if (sprite.CurrentFrame >= startFrame + numberOfFrames + 1 || sprite.CurrentFrame < startFrame) sprite.CurrentFrame = startFrame + sprite.CurrentFrame % numberOfFrames; @@ -204,10 +145,7 @@ namespace CustomNPCFramework.Framework.ModularNPCS return false; } - /// - /// Update the source rectangle on the sprite sheet. Needed for animation. - /// - /// + /// Update the source rectangle on the sprite sheet. Needed for animation. public virtual void UpdateSourceRect(AnimatedSprite sprite) { if (sprite.ignoreSourceRectUpdates) @@ -217,11 +155,8 @@ namespace CustomNPCFramework.Framework.ModularNPCS //sprite.SourceRect = new Rectangle(, 0, sprite.spriteWidth, sprite.spriteHeight); } - /// - /// Animate the current sprite. Theoreticlly works from index offset to how many frames - /// - /// - public void Animate(float intervalFromCharacter,int startFrame,int endFrame, bool loop) + /// Animate the current sprite. Theoreticlly works from index offset to how many frames + public void Animate(float intervalFromCharacter, int startFrame, int endFrame, bool loop) { this.currentSprite.sprite.loop = loop; this.currentSprite.sprite.Animate(Game1.currentGameTime, startFrame, endFrame, intervalFromCharacter); diff --git a/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/AnimatedSpriteExtended.cs b/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/AnimatedSpriteExtended.cs index e7132923..9403c62b 100644 --- a/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/AnimatedSpriteExtended.cs +++ b/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/AnimatedSpriteExtended.cs @@ -1,32 +1,21 @@ -using CustomNPCFramework.Framework.Graphics; -using Microsoft.Xna.Framework.Content; +using CustomNPCFramework.Framework.Graphics; using Microsoft.Xna.Framework.Graphics; using StardewValley; using StardustCore.UIUtilities; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -namespace CustomNPCFramework.Framework.ModularNPCS +namespace CustomNPCFramework.Framework.ModularNpcs { - /// - /// Used as a wrapper for the AnimatedSprite class. - /// + /// Used as a wrapper for the AnimatedSprite class. public class AnimatedSpriteExtended { - /// - /// The actual sprite of the object. - /// + /// The actual sprite of the object. public AnimatedSprite sprite; - /// - /// The path to the texture to load the sprite from. - /// + + /// The path to the texture to load the sprite from. public string path; - - public AnimatedSpriteExtended(Texture2DExtended texture,AssetSheet assetSheet) + /// Construct an instance. + public AnimatedSpriteExtended(Texture2DExtended texture, AssetSheet assetSheet) { //Set the sprite texture this.sprite = new AnimatedSprite(); @@ -39,25 +28,17 @@ namespace CustomNPCFramework.Framework.ModularNPCS this.sprite.SpriteWidth = (int)assetSheet.assetInfo.assetSize.X; this.sprite.SpriteHeight = (int)assetSheet.assetInfo.assetSize.Y; - - } - /// - /// Constructor. - /// - /// - /// - /// - /// - public AnimatedSpriteExtended(string path ,int currentFrame, int spriteWidth, int spriteHeight) + /// Construct an instance. + public AnimatedSpriteExtended(string path, int currentFrame, int spriteWidth, int spriteHeight) { this.path = Class1.getRelativeDirectory(path); //Set the sprite texture this.sprite = new AnimatedSprite(); Texture2D load = Class1.ModHelper.Content.Load(this.path); - var thing=Class1.ModHelper.Reflection.GetField(this.sprite, "Texture", true); + var thing = Class1.ModHelper.Reflection.GetField(this.sprite, "Texture", true); thing.SetValue(load); //Set the fields. @@ -68,9 +49,7 @@ namespace CustomNPCFramework.Framework.ModularNPCS //this.sprite = new AnimatedSprite(texture, currentFrame, spriteWidth, spriteHeight); } - /// - /// Reloads the asset from disk. - /// + /// Reloads the asset from disk. public void reload() { //Set the sprite texture diff --git a/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/CharacterAnimationBases/CharacterAnimationBase.cs b/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/CharacterAnimationBases/CharacterAnimationBase.cs index 2eb3f08b..c4073e35 100644 --- a/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/CharacterAnimationBases/CharacterAnimationBase.cs +++ b/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/CharacterAnimationBases/CharacterAnimationBase.cs @@ -1,131 +1,43 @@ -using CustomNPCFramework.Framework.NPCS; +using CustomNPCFramework.Framework.NPCS; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -namespace CustomNPCFramework.Framework.ModularNPCS +namespace CustomNPCFramework.Framework.ModularNpcs { - /// - /// Used as a base class for character animations. - /// + /// Used as a base class for character animations. public class CharacterAnimationBase { + /// Set the character sprites to left. + public virtual void setLeft() { } - /// - /// Constructor. - /// - public CharacterAnimationBase() - { - } + /// Set the character sprites to right. + public virtual void setRight() { } - /// - /// Set the character sprites to left. - /// - public virtual void setLeft() - { - } + /// Set the character sprites to up. + public virtual void setUp() { } - /// - /// Set the character sprites to right. - /// - public virtual void setRight() - { + /// Set the character sprites to down. + public virtual void setDown() { } - } + /// Used to reload the sprite textures. + public virtual void reload() { } - /// - /// Set the character sprites to up. - /// - public virtual void setUp() - { - - } - /// - /// Set the character sprites to down. - /// - public virtual void setDown() - { - - } - - /// - /// Used to reload the sprite textures. - /// - public virtual void reload() - { - } - - /// - /// Animate the sprites. - /// + /// Animate the sprites. /// How long between animation frames in milliseconds. - public virtual void Animate(float animationInterval) - { + public virtual void Animate(float animationInterval) { } - } - - /// - /// Used to animate sprites. - /// + /// Used to animate sprites. /// How long between animation frames in milliseconds. /// Loop the animation. - public virtual void Animate(float animationInterval, bool loop=true) - { + public virtual void Animate(float animationInterval, bool loop = true) { } - } + /// Used to draw the sprite to the screen. + public virtual void draw(SpriteBatch b, Vector2 screenPosition, float layerDepth) { } - /// - /// Used to draw the sprite to the screen. - /// - /// - /// - /// - public virtual void draw(SpriteBatch b, Vector2 screenPosition, float layerDepth) - { - - } - - - - /// - /// Used to draw the sprite to the screen. - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - public virtual void draw(SpriteBatch b, Vector2 screenPosition, float layerDepth, int xOffset, int yOffset, Color c, bool flip = false, float scale = 1f, float rotation = 0.0f, bool characterSourceRectOffset = false) - { - - } - - /// - /// A very verbose asset drawer. - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - public virtual void draw(SpriteBatch b, ExtendedNPC npc, Vector2 position, Rectangle sourceRectangle, Color color, float alpha, Vector2 origin, float scale, SpriteEffects effects, float layerDepth) - { - - } + /// Used to draw the sprite to the screen. + public virtual void draw(SpriteBatch b, Vector2 screenPosition, float layerDepth, int xOffset, int yOffset, Color c, bool flip = false, float scale = 1f, float rotation = 0.0f, bool characterSourceRectOffset = false) { } + /// A very verbose asset drawer. + public virtual void draw(SpriteBatch b, ExtendedNpc npc, Vector2 position, Rectangle sourceRectangle, Color color, float alpha, Vector2 origin, float scale, SpriteEffects effects, float layerDepth) { } } } diff --git a/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/CharacterAnimationBases/StandardCharacterAnimation.cs b/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/CharacterAnimationBases/StandardCharacterAnimation.cs index c563354b..20f5e843 100644 --- a/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/CharacterAnimationBases/StandardCharacterAnimation.cs +++ b/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/CharacterAnimationBases/StandardCharacterAnimation.cs @@ -1,54 +1,39 @@ -using CustomNPCFramework.Framework.ModularNPCS.ColorCollections; +using System; +using System.Collections.Generic; +using CustomNPCFramework.Framework.ModularNpcs.ColorCollections; using CustomNPCFramework.Framework.NPCS; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using StardewValley; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -namespace CustomNPCFramework.Framework.ModularNPCS.CharacterAnimationBases +namespace CustomNPCFramework.Framework.ModularNpcs.CharacterAnimationBases { - /// - /// A class used to reference the different textures used to comprise the different parts for character rendering. - /// - public class StandardCharacterAnimation :CharacterAnimationBase + /// A class used to reference the different textures used to comprise the different parts for character rendering. + public class StandardCharacterAnimation : CharacterAnimationBase { - /// - /// Used to hold all of the information for the npc hair part. - /// + /// Used to hold all of the information for the npc hair part. public AnimatedSpriteCollection hair; - /// - /// Used to hold all of the information for the npc body part. - /// + + /// Used to hold all of the information for the npc body part. public AnimatedSpriteCollection body; - /// - /// Used to hold all of the information for the npc eyes part. - /// + + /// Used to hold all of the information for the npc eyes part. public AnimatedSpriteCollection eyes; - /// - /// Used to hold all of the information for the npc shirt part. - /// + + /// Used to hold all of the information for the npc shirt part. public AnimatedSpriteCollection shirt; - /// - /// Used to hold all of the information for the npc pants part. - /// + + /// Used to hold all of the information for the npc pants part. public AnimatedSpriteCollection pants; - /// - /// Used to hold all of the information for the npc shoes part. - /// + + /// Used to hold all of the information for the npc shoes part. public AnimatedSpriteCollection shoes; - /// - /// Used to hold all of the information for draw colors for the different parts. - /// + + /// Used to hold all of the information for draw colors for the different parts. public StandardColorCollection drawColors; public List accessories; - /// - /// Constructor. - /// + /// Construct an instance. /// The collection of textures to be used for the body part for the npc. /// The collection of textures to be used for the eyes part for the npc. /// The collection of textures to be used for the hair part for the npc. @@ -57,7 +42,7 @@ namespace CustomNPCFramework.Framework.ModularNPCS.CharacterAnimationBases /// The collection of textures to be used for the shoes part for the npc. /// The collection of textures to be used for the accessories part for the npc. /// The collection of draw colors for the different parts for the npc. - public StandardCharacterAnimation(AnimatedSpriteCollection bodyAnimation, AnimatedSpriteCollection eyeAnimation, AnimatedSpriteCollection hairAnimation, AnimatedSpriteCollection shirtAnimation, AnimatedSpriteCollection pantsAnimation, AnimatedSpriteCollection shoesAnimation,List accessoriesWithAnimations, StandardColorCollection DrawColors) :base() + public StandardCharacterAnimation(AnimatedSpriteCollection bodyAnimation, AnimatedSpriteCollection eyeAnimation, AnimatedSpriteCollection hairAnimation, AnimatedSpriteCollection shirtAnimation, AnimatedSpriteCollection pantsAnimation, AnimatedSpriteCollection shoesAnimation, List accessoriesWithAnimations, StandardColorCollection DrawColors) { this.body = bodyAnimation; this.hair = hairAnimation; @@ -69,9 +54,7 @@ namespace CustomNPCFramework.Framework.ModularNPCS.CharacterAnimationBases this.drawColors = DrawColors; } - /// - /// Sets all of the different textures to face left. - /// + /// Sets all of the different textures to face left. public override void setLeft() { this.body.setLeft(); @@ -81,14 +64,11 @@ namespace CustomNPCFramework.Framework.ModularNPCS.CharacterAnimationBases this.pants.setLeft(); this.shoes.setLeft(); - foreach(var accessory in this.accessories) - { + foreach (var accessory in this.accessories) accessory.setLeft(); - } } - /// - /// Sets all of the different textures to face right. - /// + + /// Sets all of the different textures to face right. public override void setRight() { this.body.setRight(); @@ -99,13 +79,10 @@ namespace CustomNPCFramework.Framework.ModularNPCS.CharacterAnimationBases this.shoes.setRight(); foreach (var accessory in this.accessories) - { accessory.setRight(); - } } - /// - /// Sets all of the different textures to face up. - /// + + /// Sets all of the different textures to face up. public override void setUp() { this.body.setUp(); @@ -116,13 +93,10 @@ namespace CustomNPCFramework.Framework.ModularNPCS.CharacterAnimationBases this.shoes.setUp(); foreach (var accessory in this.accessories) - { accessory.setUp(); - } } - /// - /// Sets all of the different textures to face down. - /// + + /// Sets all of the different textures to face down. public override void setDown() { this.body.setDown(); @@ -133,14 +107,10 @@ namespace CustomNPCFramework.Framework.ModularNPCS.CharacterAnimationBases this.shoes.setDown(); foreach (var accessory in this.accessories) - { accessory.setDown(); - } } - /// - /// Reloads all of the sprite textures. - /// + /// Reloads all of the sprite textures. public override void reload() { this.body.reload(); @@ -151,119 +121,77 @@ namespace CustomNPCFramework.Framework.ModularNPCS.CharacterAnimationBases this.shoes.reload(); } - /// - /// Animates all of the textures for this sprite. - /// + /// Animates all of the textures for this sprite. /// The delay in milliseconds between animation frames. /// Determines if the animation continuously plays over and over. - public override void Animate(float animationInterval,bool loop=true) + public override void Animate(float animationInterval, bool loop = true) { - this.body.Animate(animationInterval,loop); - this.hair.Animate(animationInterval,loop); - this.eyes.Animate(animationInterval,loop); - this.shirt.Animate(animationInterval,loop); - this.pants.Animate(animationInterval,loop); - this.shoes.Animate(animationInterval,loop); - foreach(var accessory in this.accessories) - { - accessory.Animate(animationInterval,loop); - } - + this.body.Animate(animationInterval, loop); + this.hair.Animate(animationInterval, loop); + this.eyes.Animate(animationInterval, loop); + this.shirt.Animate(animationInterval, loop); + this.pants.Animate(animationInterval, loop); + this.shoes.Animate(animationInterval, loop); + foreach (var accessory in this.accessories) + accessory.Animate(animationInterval, loop); } - /// - /// Used to draw the sprite to the screen. - /// - /// - /// - /// + /// Used to draw the sprite to the screen. public override void draw(SpriteBatch b, Vector2 screenPosition, float layerDepth) { - this.body.draw(b,screenPosition,layerDepth); + this.body.draw(b, screenPosition, layerDepth); this.hair.draw(b, screenPosition, layerDepth); this.eyes.draw(b, screenPosition, layerDepth); this.shirt.draw(b, screenPosition, layerDepth); this.pants.draw(b, screenPosition, layerDepth); this.shoes.draw(b, screenPosition, layerDepth); foreach (var accessory in this.accessories) - { accessory.draw(b, screenPosition, layerDepth); - } //b.Draw(this.currentSprite.Texture, screenPosition, new Rectangle?(this.currentSprite.sourceRect), Color.White, 0.0f, Vector2.Zero, (float)Game1.pixelZoom, this.currentSprite.currentAnimation == null || !this.currentSprite.currentAnimation[this.currentSprite.currentAnimationIndex].flip ? SpriteEffects.None : SpriteEffects.FlipHorizontally, layerDepth); } - - - /// - /// Used to draw the sprite to the screen. - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// + /// Used to draw the sprite to the screen. public override void draw(SpriteBatch b, Vector2 screenPosition, float layerDepth, int xOffset, int yOffset, Color c, bool flip = false, float scale = 1f, float rotation = 0.0f, bool characterSourceRectOffset = false) { // b.Draw(this.currentSprite.Texture, screenPosition, new Rectangle?(new Rectangle(this.currentSprite.sourceRect.X + xOffset, this.currentSprite.sourceRect.Y + yOffset, this.currentSprite.sourceRect.Width, this.currentSprite.sourceRect.Height)), c, rotation, characterSourceRectOffset ? new Vector2((float)(this.currentSprite.spriteWidth / 2), (float)((double)this.currentSprite.spriteHeight * 3.0 / 4.0)) : Vector2.Zero, scale, flip || this.currentSprite.currentAnimation != null && this.currentSprite.currentAnimation[this.currentSprite.currentAnimationIndex].flip ? SpriteEffects.FlipHorizontally : SpriteEffects.None, layerDepth); - this.body.draw(b, screenPosition, layerDepth, xOffset, yOffset, StandardColorCollection.colorMult(c,this.drawColors.bodyColor), flip, scale, rotation, characterSourceRectOffset); + this.body.draw(b, screenPosition, layerDepth, xOffset, yOffset, StandardColorCollection.colorMult(c, this.drawColors.bodyColor), flip, scale, rotation, characterSourceRectOffset); this.hair.draw(b, screenPosition, layerDepth, xOffset, yOffset, StandardColorCollection.colorMult(c, this.drawColors.hairColor), flip, scale, rotation, characterSourceRectOffset); this.eyes.draw(b, screenPosition, layerDepth, xOffset, yOffset, StandardColorCollection.colorMult(c, this.drawColors.eyeColor), flip, scale, rotation, characterSourceRectOffset); this.shirt.draw(b, screenPosition, layerDepth, xOffset, yOffset, StandardColorCollection.colorMult(c, this.drawColors.shirtColor), flip, scale, rotation, characterSourceRectOffset); this.pants.draw(b, screenPosition, layerDepth, xOffset, yOffset, StandardColorCollection.colorMult(c, this.drawColors.bottomsColor), flip, scale, rotation, characterSourceRectOffset); this.shoes.draw(b, screenPosition, layerDepth, xOffset, yOffset, StandardColorCollection.colorMult(c, this.drawColors.shoesColor), flip, scale, rotation, characterSourceRectOffset); - foreach(var accessory in this.accessories) - { + foreach (var accessory in this.accessories) accessory.draw(b, screenPosition, layerDepth, xOffset, yOffset, c, flip, scale, rotation, characterSourceRectOffset); - } } - /// - /// A very verbose asset drawer. - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - public override void draw(SpriteBatch b, ExtendedNPC npc, Vector2 position, Rectangle sourceRectangle, Color color, float alpha, Vector2 origin, float scale, SpriteEffects effects, float layerDepth) + /// A very verbose asset drawer. + public override void draw(SpriteBatch b, ExtendedNpc npc, Vector2 position, Rectangle sourceRectangle, Color color, float alpha, Vector2 origin, float scale, SpriteEffects effects, float layerDepth) { //Class1.ModMonitor.Log(sourceRectangle.ToString()); - Vector2 generalOffset = new Vector2(0, 1*Game1.tileSize); //Puts the sprite at the correct positioning. + Vector2 generalOffset = new Vector2(0, 1 * Game1.tileSize); //Puts the sprite at the correct positioning. position -= new Vector2(0, 0.25f * Game1.tileSize); float smallOffset = 0.001f; float tinyOffset = 0.0001f; //Class1.ModMonitor.Log((position - generalOffset).ToString()); float num = Math.Max(0.0f, (float)(Math.Ceiling(Math.Sin(Game1.currentGameTime.TotalGameTime.TotalMilliseconds / 600.0 + (double)npc.DefaultPosition.X * 20.0)) / 4.0)); - this.body.draw(b, npc, position-generalOffset, sourceRectangle, StandardColorCollection.colorMult(color, this.drawColors.bodyColor), alpha, origin, scale*Game1.pixelZoom, effects, layerDepth + smallOffset); - this.eyes.draw(b, npc, position - generalOffset, sourceRectangle, StandardColorCollection.colorMult(color, this.drawColors.eyeColor), alpha, origin, scale*Game1.pixelZoom, effects, layerDepth + smallOffset+(tinyOffset *1)); - this.hair.draw(b, npc, position-generalOffset, sourceRectangle, StandardColorCollection.colorMult(color, this.drawColors.hairColor), alpha, origin, scale*Game1.pixelZoom, effects, layerDepth + smallOffset+(tinyOffset *2)); + this.body.draw(b, npc, position - generalOffset, sourceRectangle, StandardColorCollection.colorMult(color, this.drawColors.bodyColor), alpha, origin, scale * Game1.pixelZoom, effects, layerDepth + smallOffset); + this.eyes.draw(b, npc, position - generalOffset, sourceRectangle, StandardColorCollection.colorMult(color, this.drawColors.eyeColor), alpha, origin, scale * Game1.pixelZoom, effects, layerDepth + smallOffset + (tinyOffset * 1)); + this.hair.draw(b, npc, position - generalOffset, sourceRectangle, StandardColorCollection.colorMult(color, this.drawColors.hairColor), alpha, origin, scale * Game1.pixelZoom, effects, layerDepth + smallOffset + (tinyOffset * 2)); if (num > 0.0f) { Vector2 shirtOffset = new Vector2((1 * Game1.tileSize) / 4, (1 * Game1.tileSize) / 4); - this.shirt.draw(b, npc, position - generalOffset, sourceRectangle, StandardColorCollection.colorMult(color, this.drawColors.shirtColor), alpha, new Vector2(0.5f,1), scale * Game1.pixelZoom + num, effects, layerDepth + smallOffset + (tinyOffset * 3)); + this.shirt.draw(b, npc, position - generalOffset, sourceRectangle, StandardColorCollection.colorMult(color, this.drawColors.shirtColor), alpha, new Vector2(0.5f, 1), scale * Game1.pixelZoom + num, effects, layerDepth + smallOffset + (tinyOffset * 3)); } else { this.shirt.draw(b, npc, position - generalOffset, sourceRectangle, StandardColorCollection.colorMult(color, this.drawColors.shirtColor), alpha, origin, scale * Game1.pixelZoom, effects, layerDepth + smallOffset + (tinyOffset * 3)); } - this.pants.draw(b, npc, position-generalOffset, sourceRectangle, StandardColorCollection.colorMult(color, this.drawColors.bottomsColor), alpha, origin, scale*Game1.pixelZoom, effects, layerDepth + smallOffset+(tinyOffset*4)); - this.shoes.draw(b, npc, position-generalOffset, sourceRectangle, StandardColorCollection.colorMult(color, this.drawColors.shoesColor), alpha, origin, scale*Game1.pixelZoom, effects, layerDepth + smallOffset+(tinyOffset*5)); - foreach(var accessory in this.accessories) - { - accessory.draw(b, npc, position-generalOffset, sourceRectangle, color, alpha, origin, scale, effects, layerDepth +0.0006f); - } - } + this.pants.draw(b, npc, position - generalOffset, sourceRectangle, StandardColorCollection.colorMult(color, this.drawColors.bottomsColor), alpha, origin, scale * Game1.pixelZoom, effects, layerDepth + smallOffset + (tinyOffset * 4)); + this.shoes.draw(b, npc, position - generalOffset, sourceRectangle, StandardColorCollection.colorMult(color, this.drawColors.shoesColor), alpha, origin, scale * Game1.pixelZoom, effects, layerDepth + smallOffset + (tinyOffset * 5)); + foreach (var accessory in this.accessories) + accessory.draw(b, npc, position - generalOffset, sourceRectangle, color, alpha, origin, scale, effects, layerDepth + 0.0006f); + } } } diff --git a/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/ColorCollections/StandardColorCollection.cs b/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/ColorCollections/StandardColorCollection.cs index c27922e7..7b50eceb 100644 --- a/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/ColorCollections/StandardColorCollection.cs +++ b/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/ColorCollections/StandardColorCollection.cs @@ -1,93 +1,72 @@ -using Microsoft.Xna.Framework; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using Microsoft.Xna.Framework; -namespace CustomNPCFramework.Framework.ModularNPCS.ColorCollections +namespace CustomNPCFramework.Framework.ModularNpcs.ColorCollections { - /// - /// Collection of colors to be used for the StandardCharacterAnimation object. - /// + /// Collection of colors to be used for the StandardCharacterAnimation object. public class StandardColorCollection { - /// - /// The draw color to be used for the body sprite for the npc. - /// + /// The draw color to be used for the body sprite for the npc. public Color bodyColor; - /// - /// The draw color to be used for the eye sprite for the npc. - /// + + /// The draw color to be used for the eye sprite for the npc. public Color eyeColor; - /// - /// The draw color to be used for the hair sprite for the npc. - /// + + /// The draw color to be used for the hair sprite for the npc. public Color hairColor; - /// - /// The draw color to be used for the shirt sprite for the npc. - /// + + /// The draw color to be used for the shirt sprite for the npc. public Color shirtColor; - /// - /// The draw color to be used for the bottoms/pants sprite for the npc. - /// + + /// The draw color to be used for the bottoms/pants sprite for the npc. public Color bottomsColor; - /// - /// The draw color to be used for the shoes sprite for the npc. - /// + + /// The draw color to be used for the shoes sprite for the npc. public Color shoesColor; - /// - /// Default constrctor that sets all of the draw colors to white. - /// + /// Construct an instance. public StandardColorCollection() { - defaultColor(this.bodyColor); - defaultColor(this.eyeColor); - defaultColor(this.hairColor); - defaultColor(this.shirtColor); - defaultColor(this.bottomsColor); - defaultColor(this.shoesColor); + this.defaultColor(this.bodyColor); + this.defaultColor(this.eyeColor); + this.defaultColor(this.hairColor); + this.defaultColor(this.shirtColor); + this.defaultColor(this.bottomsColor); + this.defaultColor(this.shoesColor); } - /// - /// Constructor that takes different colors as parameters. - /// - /// Color for the body texture. - /// Color for the eyes texture. - /// Color for the hair texture. - /// Color for the shirt texture. - /// Color for the bottoms texture. - /// Color for the shoes texture. - public StandardColorCollection(Color? BodyColor, Color? EyeColor, Color? HairColor, Color? ShirtColor, Color? BottomsColor, Color? ShoesColor) + /// Construct an instance. + /// Color for the body texture. + /// Color for the eyes texture. + /// Color for the hair texture. + /// Color for the shirt texture. + /// Color for the bottoms texture. + /// Color for the shoes texture. + public StandardColorCollection(Color? bodyColor, Color? eyeColor, Color? hairColor, Color? shirtColor, Color? bottomsColor, Color? shoesColor) { - this.bodyColor = (Color)BodyColor.GetValueOrDefault(Color.White); - this.eyeColor = (Color)EyeColor.GetValueOrDefault(Color.White); - this.hairColor = (Color)HairColor.GetValueOrDefault(Color.White); - this.shirtColor = (Color)ShirtColor.GetValueOrDefault(Color.White); - this.bottomsColor = (Color)BottomsColor.GetValueOrDefault(Color.White); - this.shoesColor = (Color)ShoesColor.GetValueOrDefault(Color.White); + this.bodyColor = bodyColor.GetValueOrDefault(Color.White); + this.eyeColor = eyeColor.GetValueOrDefault(Color.White); + this.hairColor = hairColor.GetValueOrDefault(Color.White); + this.shirtColor = shirtColor.GetValueOrDefault(Color.White); + this.bottomsColor = bottomsColor.GetValueOrDefault(Color.White); + this.shoesColor = shoesColor.GetValueOrDefault(Color.White); - defaultColor(this.bodyColor); - defaultColor(this.eyeColor); - defaultColor(this.hairColor); - defaultColor(this.shirtColor); - defaultColor(this.bottomsColor); - defaultColor(this.shoesColor); + this.defaultColor(this.bodyColor); + this.defaultColor(this.eyeColor); + this.defaultColor(this.hairColor); + this.defaultColor(this.shirtColor); + this.defaultColor(this.bottomsColor); + this.defaultColor(this.shoesColor); } - /// - /// If a color is null, make it white. - /// - /// + /// If a color is null, make it white. + /// The color to check. public void defaultColor(Color color) { - if (color == null) color = Color.White; + if (color == null) + color = Color.White; } - /// - /// Used to mix colors together. - /// + /// Used to mix colors together. /// The base color to mix. /// The modifier color to mix. /// A color that is a mix between the two colors passed in. diff --git a/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/ModularRenderers/AnimationKeys.cs b/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/ModularRenderers/AnimationKeys.cs index de9249ae..d862d2be 100644 --- a/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/ModularRenderers/AnimationKeys.cs +++ b/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/ModularRenderers/AnimationKeys.cs @@ -1,31 +1,18 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace CustomNPCFramework.Framework.ModularNPCS.ModularRenderers +namespace CustomNPCFramework.Framework.ModularNpcs.ModularRenderers { - /// - /// A class used instead of an enum to hold keys for all of the different animations. - /// + /// A class used instead of an enum to hold keys for all of the different animations. public class AnimationKeys { - /// - /// The string that is used for the standing animation. - /// + /// The string that is used for the standing animation. public static string standingKey = "standing"; - /// - /// The string that is used for the walking/moving animation. - /// + + /// The string that is used for the walking/moving animation. public static string walkingKey = "walking"; - /// - /// The string that is used for the sitting animation. - /// + + /// The string that is used for the sitting animation. public static string sittingKey = "sitting"; - /// - /// The string that is used for the swimming animation. - /// + + /// The string that is used for the swimming animation. public static string swimmingKey = "swimming"; } } diff --git a/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/ModularRenderers/BasicRenderer.cs b/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/ModularRenderers/BasicRenderer.cs index 6ea6629b..eb4ae60f 100644 --- a/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/ModularRenderers/BasicRenderer.cs +++ b/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/ModularRenderers/BasicRenderer.cs @@ -1,205 +1,137 @@ -using CustomNPCFramework.Framework.Enums; -using CustomNPCFramework.Framework.Graphics; -using CustomNPCFramework.Framework.ModularNPCS.CharacterAnimationBases; +using System.Collections.Generic; +using CustomNPCFramework.Framework.Enums; +using CustomNPCFramework.Framework.ModularNpcs.CharacterAnimationBases; using CustomNPCFramework.Framework.NPCS; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using StardewValley; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -namespace CustomNPCFramework.Framework.ModularNPCS.ModularRenderers +namespace CustomNPCFramework.Framework.ModularNpcs.ModularRenderers { - /// - /// A class used to hold all of the textures/animations/information to make modular npc rendering possible. - /// + /// A class used to hold all of the textures/animations/information to make modular npc rendering possible. public class BasicRenderer { - /// - /// Dictionary that holds key pair values of (animationName,Animation). USed to manage multiple animations. - /// + /// Dictionary that holds key pair values of (animationName,Animation). USed to manage multiple animations. public Dictionary animationList; - /// - /// Used to keep track of what animation is currently being used. - /// + + /// Used to keep track of what animation is currently being used. public StandardCharacterAnimation currentAnimation; - /// - /// Constructor. - /// + /// Construct an instance. /// The animation information to be used when the character is standing. /// The animation information to be used when the character is walking/moving. /// The animation information to be used when the character is walking/moving. - public BasicRenderer(StandardCharacterAnimation standingAnimation,StandardCharacterAnimation walkingAnimation, StandardCharacterAnimation swimmingAnimation) + public BasicRenderer(StandardCharacterAnimation standingAnimation, StandardCharacterAnimation walkingAnimation, StandardCharacterAnimation swimmingAnimation) { - animationList = new Dictionary(); - animationList.Add(AnimationKeys.standingKey, standingAnimation); - animationList.Add(AnimationKeys.walkingKey, walkingAnimation); - animationList.Add(AnimationKeys.swimmingKey, swimmingAnimation); - setAnimation(AnimationKeys.standingKey); + this.animationList = new Dictionary(); + this.animationList.Add(AnimationKeys.standingKey, standingAnimation); + this.animationList.Add(AnimationKeys.walkingKey, walkingAnimation); + this.animationList.Add(AnimationKeys.swimmingKey, swimmingAnimation); + this.setAnimation(AnimationKeys.standingKey); } - /// - /// Sets the animation associated with the key name; If it fails the npc will just default to standing. - /// + /// Sets the animation associated with the key name; If it fails the npc will just default to standing. /// The name of the animation to swap the current animation to. public virtual void setAnimation(string key) { - this.currentAnimation = animationList[key]; + this.currentAnimation = this.animationList[key]; if (this.currentAnimation == null) { - Class1.ModMonitor.Log("ERROR SETTING AN ANIMATION: "+key); + Class1.ModMonitor.Log("ERROR SETTING AN ANIMATION: " + key); this.setAnimation(AnimationKeys.standingKey); } } - /// - /// Sets the direction of the current animated sprite respectively. - /// + /// Sets the direction of the current animated sprite respectively. /// The direction to face. 0=up, 1=right, 2= down, 3=left. public virtual void setDirection(int facingDirection) { - if (facingDirection == 0) setUp(); - if (facingDirection == 1) setRight(); - if (facingDirection == 2) setDown(); - if (facingDirection == 2) setLeft(); + this.setDirection((Direction)facingDirection); } - /// - /// Sets the direction of the current animated sprite respectively to the direction passed in. - /// + /// Sets the direction of the current animated sprite respectively to the direction passed in. /// The direction to face. public virtual void setDirection(Direction direction) { - if (direction == Direction.up) setUp(); - if (direction == Direction.right) setRight(); - if (direction == Direction.down) setDown(); - if (direction == Direction.left) setLeft(); + switch (direction) + { + case Direction.up: + this.setUp(); + break; + + case Direction.right: + this.setRight(); + break; + + case Direction.down: + this.setDown(); + break; + + case Direction.left: + this.setLeft(); + break; + } } - - /// - /// Sets the current animated sprite to face left. - /// + /// Sets the current animated sprite to face left. public virtual void setLeft() { this.currentAnimation.setLeft(); } - /// - /// Sets the current animated sprite to face right. - /// + /// Sets the current animated sprite to face right. public virtual void setRight() { this.currentAnimation.setRight(); } - /// - /// Sets the current animated sprite to face up. - /// + /// Sets the current animated sprite to face up. public virtual void setUp() { this.currentAnimation.setUp(); } - - /// - /// Sets the current animated sprite to face down. - /// + + /// Sets the current animated sprite to face down. public virtual void setDown() { this.currentAnimation.setDown(); } - /// - /// Used to reload all of the sprites pertaining to all of the animations stored in this renderer. - /// + /// Used to reload all of the sprites pertaining to all of the animations stored in this renderer. public virtual void reloadSprites() { - foreach(var v in this.animationList) - { + foreach (var v in this.animationList) v.Value.reload(); - } } - /// - /// Used to draw the sprite to the screen. - /// - /// - /// - /// + /// Used to draw the sprite to the screen. public virtual void draw(SpriteBatch b, Vector2 screenPosition, float layerDepth) { this.currentAnimation.draw(b, screenPosition, layerDepth); } - /// - /// Used to draw the sprite to the screen. - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// + /// Used to draw the sprite to the screen. public virtual void draw(SpriteBatch b, Vector2 screenPosition, float layerDepth, int xOffset, int yOffset, Color c, bool flip = false, float scale = 1f, float rotation = 0.0f, bool characterSourceRectOffset = false) { this.currentAnimation.draw(b, screenPosition, layerDepth, xOffset, yOffset, c, flip, scale, rotation, characterSourceRectOffset); } - /// - /// A very verbose asset drawer. - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - public virtual void draw(SpriteBatch b, ExtendedNPC npc, Vector2 position, Rectangle sourceRectangle, Color color, float alpha, Vector2 origin, float scale, SpriteEffects effects, float layerDepth) + /// A very verbose asset drawer. + public virtual void draw(SpriteBatch b, ExtendedNpc npc, Vector2 position, Rectangle sourceRectangle, Color color, float alpha, Vector2 origin, float scale, SpriteEffects effects, float layerDepth) { - this.currentAnimation.draw(b, npc, position, sourceRectangle, color, alpha, origin, scale, effects, layerDepth); } - /// - /// Animates the current animation for the current sprite. - /// - /// - /// - public virtual void Animate(float interval, bool loop=true) + /// Animates the current animation for the current sprite. + public virtual void Animate(float interval, bool loop = true) { - this.currentAnimation.Animate(interval,loop); + this.currentAnimation.Animate(interval, loop); } - - /// - /// Wrapper for a draw function that accepts rectangles to be null. - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - public virtual void draw(SpriteBatch b, ExtendedNPC extendedNPC, Vector2 position, Rectangle? v1, Color white, float rotation, Vector2 origin, float scale, SpriteEffects spriteEffects, float v3) + /// Wrapper for a draw function that accepts rectangles to be null. + public virtual void draw(SpriteBatch b, ExtendedNpc extendedNPC, Vector2 position, Rectangle? v1, Color white, float rotation, Vector2 origin, float scale, SpriteEffects spriteEffects, float v3) { - this.draw(b, extendedNPC, position, new Rectangle(0,0,16,32), white, rotation, origin, scale, spriteEffects, v3); + this.draw(b, extendedNPC, position, new Rectangle(0, 0, 16, 32), white, rotation, origin, scale, spriteEffects, v3); } } } diff --git a/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/Portrait.cs b/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/Portrait.cs index 4e6b10aa..2ec8b3e6 100644 --- a/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/Portrait.cs +++ b/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/Portrait.cs @@ -1,49 +1,32 @@ -using CustomNPCFramework.Framework.NPCS; +using CustomNPCFramework.Framework.NPCS; using Microsoft.Xna.Framework.Graphics; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -namespace CustomNPCFramework.Framework.ModularNPCS +namespace CustomNPCFramework.Framework.ModularNpcs { - /// - /// Used as a wrapper for npc portraits. - /// + /// Used as a wrapper for npc portraits. public class Portrait { - /// - /// Used to display the npc portrait. - /// + /// Used to display the npc portrait. public Texture2D portrait; - /// - /// Used to hold the path to the texture to use for the npc portrait. - /// + + /// Used to hold the path to the texture to use for the npc portrait. public string relativePath; - /// - /// A class for handling portraits. - /// + /// /// The full path to the file. public Portrait(string path) { - this.relativePath =Class1.getRelativeDirectory(path); - this.portrait=Class1.ModHelper.Content.Load(path); + this.relativePath = Class1.getRelativeDirectory(path); + this.portrait = Class1.ModHelper.Content.Load(path); } - /// - /// Sets the npc's portrait to be this portrait texture. - /// - /// - public void setCharacterPortraitFromThis(ExtendedNPC npc) + /// Sets the npc's portrait to be this portrait texture. + public void setCharacterPortraitFromThis(ExtendedNpc npc) { npc.Portrait = this.portrait; } - /// - /// Reloads the texture for the NPC portrait. - /// + /// Reloads the texture for the NPC portrait. public void reload() { this.portrait = Class1.ModHelper.Content.Load(this.relativePath); diff --git a/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/Sprite.cs b/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/Sprite.cs index e821bebc..2a02bbff 100644 --- a/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/Sprite.cs +++ b/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/Sprite.cs @@ -1,32 +1,19 @@ -using CustomNPCFramework.Framework.ModularNPCS.ModularRenderers; using CustomNPCFramework.Framework.NPCS; using Microsoft.Xna.Framework.Graphics; using StardewValley; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -namespace CustomNPCFramework.Framework.ModularNPCS +namespace CustomNPCFramework.Framework.ModularNpcs { - /// - /// Used as a wrapper for the npcs to hold sprite information. - /// + /// Used as a wrapper for the npcs to hold sprite information. public class Sprite { - /// - /// The actual sprite to draw for the npc. - /// + /// The actual sprite to draw for the npc. public AnimatedSprite sprite; - /// - /// The path to the texture to use for the animated sprite. - /// + + /// The path to the texture to use for the animated sprite. public string relativePath; - /// - /// A class for handling character sprites. - /// + /// Construct an instance. /// The full path to the file. public Sprite(string path) { @@ -34,7 +21,7 @@ namespace CustomNPCFramework.Framework.ModularNPCS { this.relativePath = Class1.getShortenedDirectory(path); } - catch(Exception err) + catch { this.relativePath = path; } @@ -42,11 +29,11 @@ namespace CustomNPCFramework.Framework.ModularNPCS { this.sprite = new AnimatedSprite(); Texture2D text = Class1.ModHelper.Content.Load(this.relativePath); - var reflect=Class1.ModHelper.Reflection.GetField(this.sprite, "Texture", true); + var reflect = Class1.ModHelper.Reflection.GetField(this.sprite, "Texture", true); reflect.SetValue(text); - + } - catch(Exception err) + catch { this.sprite = new AnimatedSprite(); Texture2D text = Class1.ModHelper.Content.Load(this.relativePath); @@ -57,9 +44,7 @@ namespace CustomNPCFramework.Framework.ModularNPCS this.sprite.SpriteHeight = this.sprite.Texture.Height; } - /// - /// Constructor. - /// + /// Construct an instance. /// Used to hold the path to the asset. /// Used to assign the texture to the sprite from a pre-loaded asset. public Sprite(string path, string texture) @@ -70,75 +55,42 @@ namespace CustomNPCFramework.Framework.ModularNPCS this.sprite.SpriteHeight = this.sprite.Texture.Height; } - /// - /// Sets the npc's portrait to be this portrait texture. - /// - /// - public void setCharacterSpriteFromThis(ExtendedNPC npc) + /// Sets the npc's portrait to be this portrait texture. + public void setCharacterSpriteFromThis(ExtendedNpc npc) { npc.Sprite = this.sprite; } - /// - /// Reloads the texture for the NPC portrait. - /// + /// Reloads the texture for the NPC portrait. public void reload() { - var text=CustomNPCFramework.Class1.ModHelper.Reflection.GetField(this.sprite.Texture, "Texture", true); - Texture2D loaded= Class1.ModHelper.Content.Load(this.relativePath); + var text = Class1.ModHelper.Reflection.GetField(this.sprite.Texture, "Texture", true); + Texture2D loaded = Class1.ModHelper.Content.Load(this.relativePath); text.SetValue(loaded); } - /// - /// Set's the npc's sprites to face left IF and only if there is a non-null modular Renderer attached to the npc. - /// - /// - public void setLeft(ExtendedNPC npc) + /// Set's the npc's sprites to face left IF and only if there is a non-null modular Renderer attached to the npc. + public void setLeft(ExtendedNpc npc) { - if (npc.characterRenderer == null) - { - return; - } - else npc.characterRenderer.setLeft(); + npc.characterRenderer?.setLeft(); } - /// - /// Set's the npc's sprites to face left IF and only if there is a non-null modular Renderer attached to the npc. - /// - /// - public void setRight(ExtendedNPC npc) + /// Set's the npc's sprites to face left IF and only if there is a non-null modular Renderer attached to the npc. + public void setRight(ExtendedNpc npc) { - if (npc.characterRenderer == null) - { - return; - } - else npc.characterRenderer.setRight(); + npc.characterRenderer?.setRight(); } - /// - /// Set's the npc's sprites to face left IF and only if there is a non-null modular Renderer attached to the npc. - /// - /// - public void setDown(ExtendedNPC npc) + /// Set's the npc's sprites to face left IF and only if there is a non-null modular Renderer attached to the npc. + public void setDown(ExtendedNpc npc) { - if (npc.characterRenderer == null) - { - return; - } - else npc.characterRenderer.setDown(); + npc.characterRenderer?.setDown(); } - /// - /// Set's the npc's sprites to face left IF and only if there is a non-null modular Renderer attached to the npc. - /// - /// - public void setUp(ExtendedNPC npc) + /// Set's the npc's sprites to face left IF and only if there is a non-null modular Renderer attached to the npc. + public void setUp(ExtendedNpc npc) { - if (npc.characterRenderer == null) - { - return; - } - else npc.characterRenderer.setUp(); + npc.characterRenderer?.setUp(); } } } diff --git a/GeneralMods/CustomNPCFramework/Framework/NPCNames.cs b/GeneralMods/CustomNPCFramework/Framework/NPCNames.cs index 6ede8e02..f511193a 100644 --- a/GeneralMods/CustomNPCFramework/Framework/NPCNames.cs +++ b/GeneralMods/CustomNPCFramework/Framework/NPCNames.cs @@ -1,77 +1,59 @@ -using CustomNPCFramework.Framework.Enums; -using StardewValley; -using System; using System.Collections.Generic; using System.Linq; -using System.Text; -using System.Threading.Tasks; +using CustomNPCFramework.Framework.Enums; +using StardewValley; namespace CustomNPCFramework.Framework { - /// - /// Used as a class to hold all of the possible npc names. - /// - public class NPCNames + /// Used as a class to hold all of the possible NPC names. + public class NpcNames { - /// - /// Holds all of the npc male names. - /// - public static List maleNames = new List() + /// Holds all of the NPC male names. + public static List maleNames = new List { "Freddy", "Josh", "Ash" }; - /// - /// Holds all of the npc female names. - /// - public static List femaleNames = new List() + /// Holds all of the NPC female names. + public static List femaleNames = new List { "Rebecca", "Sierra", "Lisa" }; - /// - /// Holds all of the npc gender non-binary names. - /// - public static List otherGenderNames = new List() + /// Holds all of the NPC gender non-binary names. + public static List otherGenderNames = new List { "Jayden", "Ryanne", "Skylar" }; - /// - /// Get a gender appropriate name from the pool of npc names. - /// - /// - /// - public static string getRandomNPCName(Genders gender) + /// Get a gender appropriate name from the pool of NPC names. + public static string getRandomNpcName(Genders gender) { - if (gender == Genders.female) { - + if (gender == Genders.female) + { int rand = Game1.random.Next(0, femaleNames.Count - 1); return femaleNames.ElementAt(rand); } if (gender == Genders.male) { - int rand = Game1.random.Next(0, maleNames.Count - 1); return maleNames.ElementAt(rand); } if (gender == Genders.other) { - int rand = Game1.random.Next(0, otherGenderNames.Count - 1); return otherGenderNames.ElementAt(rand); } return ""; - } } } diff --git a/GeneralMods/CustomNPCFramework/Framework/NPCS/ExtendedNPC.cs b/GeneralMods/CustomNPCFramework/Framework/NPCS/ExtendedNPC.cs index 925fd7c3..9a3e4d08 100644 --- a/GeneralMods/CustomNPCFramework/Framework/NPCS/ExtendedNPC.cs +++ b/GeneralMods/CustomNPCFramework/Framework/NPCS/ExtendedNPC.cs @@ -1,35 +1,22 @@ -using CustomNPCFramework.Framework.Enums; -using CustomNPCFramework.Framework.ModularNPCS; -using CustomNPCFramework.Framework.ModularNPCS.ModularRenderers; +using System; +using CustomNPCFramework.Framework.Enums; +using CustomNPCFramework.Framework.ModularNpcs; +using CustomNPCFramework.Framework.ModularNpcs.ModularRenderers; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using StardewValley; -using StardewValley.Buildings; -using StardewValley.Characters; -using StardewValley.Locations; -using StardewValley.Menus; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using xTile.Dimensions; -using xTile.ObjectModel; -using xTile.Tiles; namespace CustomNPCFramework.Framework.NPCS { - /// - /// TODO: Add in an resource loader for all of the character graphics and use it to populate some character graphics. - /// Make .json way to load in assets to the mod. - /// Organize it all. - /// Profit??? - /// - public class ExtendedNPC :StardewValley.NPC + // TODO: + // - Add in an resource loader for all of the character graphics and use it to populate some character graphics. + // - Make .json way to load in assets to the mod. + // - Organize it all. + // - Profit??? + + public class ExtendedNpc : NPC { - /// - /// The custom character renderer for this npc. - /// + /// The custom character renderer for this npc. public BasicRenderer characterRenderer; public bool hasBeenKissedToday; public Point previousEndPoint; @@ -37,122 +24,89 @@ namespace CustomNPCFramework.Framework.NPCS public bool hasSaidAfternoonDialogue; public int timeAfterSquare; - /// - /// Used to hold sprite information to be used in the case the npc renderer is null. - /// + /// Used to hold sprite information to be used in the case the npc renderer is null. public Sprite spriteInformation; - /// - /// Used to hold the portrait information for the npc and display it. - /// + /// Used to hold the portrait information for the npc and display it. public Portrait portraitInformation; - /// - /// The default location for this npc to reside in. - /// + /// The default location for this npc to reside in. public GameLocation defaultLocation; - /// - /// Empty Constructor. - /// - public ExtendedNPC() :base() - { - } + /// Construct an instance. + public ExtendedNpc() { } - /// - /// Non modular npc Constructor. - /// + /// Construct an instance. /// The sprite for the character. /// The position of the npc on the map. /// The direction of the npc /// The name of the npc. - public ExtendedNPC(Sprite sprite, Vector2 position, int facingDirection, string name) : base(sprite.sprite, position, facingDirection, name, null) + public ExtendedNpc(Sprite sprite, Vector2 position, int facingDirection, string name) + : base(sprite.sprite, position, facingDirection, name) { this.characterRenderer = null; - this.Portrait = (Texture2D)null; + this.Portrait = null; this.portraitInformation = null; this.spriteInformation = sprite; - if (this.spriteInformation != null) - { - this.spriteInformation.setCharacterSpriteFromThis(this); - } + this.spriteInformation?.setCharacterSpriteFromThis(this); this.swimming.Value = false; } - /// - /// Non modular npc Constructor. - /// + /// Construct an instance. /// The sprite for the character. /// The portrait texture for this npc. /// The position of the npc on the map. /// The direction of the npc /// The name of the npc. - public ExtendedNPC(Sprite sprite, Portrait portrait, Vector2 position, int facingDirection, string name) : base(sprite.sprite, position, facingDirection, name, null) + public ExtendedNpc(Sprite sprite, Portrait portrait, Vector2 position, int facingDirection, string name) + : base(sprite.sprite, position, facingDirection, name) { this.characterRenderer = null; this.portraitInformation = portrait; - if (this.portraitInformation != null) - { - this.portraitInformation.setCharacterPortraitFromThis(this); - } + this.portraitInformation?.setCharacterPortraitFromThis(this); this.spriteInformation = sprite; this.spriteInformation.setCharacterSpriteFromThis(this); this.swimming.Value = false; } - /// - /// Modular npc constructor. - /// + /// Construct an instance. /// The sprite for the character to use incase the renderer is null. /// The custom npc render. Used to draw the npcfrom a collection of assets. - /// The portrait texture for this npc. /// The position of the npc on the map. /// The direction of the npc /// The name of the npc. - public ExtendedNPC(Sprite sprite,BasicRenderer renderer,Vector2 position,int facingDirection,string name): base(sprite.sprite, position, facingDirection, name, null) + public ExtendedNpc(Sprite sprite, BasicRenderer renderer, Vector2 position, int facingDirection, string name) + : base(sprite.sprite, position, facingDirection, name) { this.characterRenderer = renderer; - this.Portrait = (Texture2D)null; + this.Portrait = null; this.portraitInformation = null; this.spriteInformation = sprite; - if (this.spriteInformation != null) - { - this.spriteInformation.setCharacterSpriteFromThis(this); - } + this.spriteInformation?.setCharacterSpriteFromThis(this); this.swimming.Value = false; } - /// - /// Modular constructor for the npc. - /// + /// Construct an instance. /// The sprite for the npc to use incase the renderer is null. /// The custom npc renderer used to draw the npc from the collection of textures. /// The portrait texture for the npc. /// The positon for the npc to be. /// The direction for the npc to face. /// The name for the npc. - public ExtendedNPC(Sprite sprite,BasicRenderer renderer,Portrait portrait, Vector2 position, int facingDirection, string name) : base(sprite.sprite, position, facingDirection, name, null) + public ExtendedNpc(Sprite sprite, BasicRenderer renderer, Portrait portrait, Vector2 position, int facingDirection, string name) + : base(sprite.sprite, position, facingDirection, name) { this.characterRenderer = renderer; this.portraitInformation = portrait; - if (this.portraitInformation != null) - { - this.portraitInformation.setCharacterPortraitFromThis(this); - } + this.portraitInformation?.setCharacterPortraitFromThis(this); this.spriteInformation = sprite; - if (this.spriteInformation != null) - { - this.spriteInformation.setCharacterSpriteFromThis(this); - } + this.spriteInformation?.setCharacterSpriteFromThis(this); this.swimming.Value = false; } - /// - /// Used to reload the sprite for the npc. - /// + /// Used to reload the sprite for the npc. public void reloadSprite() { - if (this.characterRenderer == null) { this.spriteInformation.reload(); @@ -160,10 +114,9 @@ namespace CustomNPCFramework.Framework.NPCS { this.portraitInformation.reload(); } - catch (Exception ex) + catch { - ex.ToString(); - this.Portrait = (Texture2D)null; + this.Portrait = null; } } else @@ -173,14 +126,12 @@ namespace CustomNPCFramework.Framework.NPCS { this.portraitInformation.reload(); } - catch (Exception ex) + catch { - ex.ToString(); - this.Portrait = (Texture2D)null; + this.Portrait = null; } } - int num = this.IsInvisible ? 1 : 0; - if (!Game1.newDay && (int)Game1.gameMode != 6) + if (!Game1.newDay && Game1.gameMode != 6) return; this.faceDirection(this.DefaultFacingDirection); this.scheduleTimeToTry = 9999999; @@ -188,164 +139,133 @@ namespace CustomNPCFramework.Framework.NPCS this.Schedule = this.getSchedule(Game1.dayOfMonth); this.faceDirection(this.defaultFacingDirection); this.Sprite.standAndFaceDirection(this.defaultFacingDirection); - + if (this.isMarried()) this.marriageDuties(); - bool flag = Utility.isFestivalDay(Game1.dayOfMonth, Game1.currentSeason); try { this.displayName = this.Name; } - catch (Exception ex) - { - ex.ToString(); - } - + catch { } } - /// - /// Functionality used when interacting with the npc. - /// - /// - /// - /// - public override bool checkAction(StardewValley.Farmer who, GameLocation l) + /// Functionality used when interacting with the npc. + public override bool checkAction(Farmer who, GameLocation l) { base.checkAction(who, l); return false; } - /// - /// Used to move the npc. Different code is used depending if the character renderer is null or not. - /// - /// - /// - /// + /// Used to move the npc. Different code is used depending if the character renderer is null or not. public override void MovePosition(GameTime time, xTile.Dimensions.Rectangle viewport, GameLocation currentLocation) { if (this.characterRenderer != null) - { - ModularMovement(time,viewport,currentLocation); - } + this.ModularMovement(time, viewport, currentLocation); else - { - NonModularMovement(time,viewport,currentLocation); - } - return; - + this.NonModularMovement(time, viewport, currentLocation); } - /// - /// Set's the npc to move a certain direction and then executes the movement. - /// - /// - /// - /// - /// The direction to move the npc. + /// Set's the npc to move a certain direction and then executes the movement. + /// The direction to move the npc. /// Set's the npc's sprite to halt if Move=false. Else set it to true. - public virtual void SetMovingAndMove(GameTime time, xTile.Dimensions.Rectangle viewport, GameLocation currentLocation, Direction MoveDirection, bool Move=true) + public virtual void SetMovingAndMove(GameTime time, xTile.Dimensions.Rectangle viewport, GameLocation currentLocation, Direction moveDirection, bool Move = true) { - if (MoveDirection == Direction.down) this.SetMovingDown(Move); - if (MoveDirection == Direction.left) this.SetMovingLeft(Move); - if (MoveDirection == Direction.up) this.SetMovingUp(Move); - if (MoveDirection == Direction.right) this.SetMovingRight(Move); + switch (moveDirection) + { + case Direction.down: + this.SetMovingDown(Move); + break; + + case Direction.left: + this.SetMovingLeft(Move); + break; + + case Direction.up: + this.SetMovingUp(Move); + break; + + case Direction.right: + this.SetMovingRight(Move); + break; + } + this.MovePosition(time, viewport, currentLocation); } - /// - /// USed to move the npc if the character renderer is null. - /// - /// - /// - /// + /// USed to move the npc if the character renderer is null. public virtual void NonModularMovement(GameTime time, xTile.Dimensions.Rectangle viewport, GameLocation location) { - base.MovePosition(time, viewport, currentLocation); - return; + base.MovePosition(time, viewport, this.currentLocation); } - /// - /// Used to determine if the npc can move past the next location. - /// - /// - /// + /// Used to determine if the npc can move past the next location. public virtual bool canMovePastNextLocation(xTile.Dimensions.Rectangle viewport) { //Up - if (!currentLocation.isTilePassable(this.nextPosition(0), viewport) || !this.willDestroyObjectsUnderfoot) - { + if (!this.currentLocation.isTilePassable(this.nextPosition(0), viewport) || !this.willDestroyObjectsUnderfoot) return false; - } + //Right - if (!currentLocation.isTilePassable(this.nextPosition(1), viewport) || !this.willDestroyObjectsUnderfoot) - { + if (!this.currentLocation.isTilePassable(this.nextPosition(1), viewport) || !this.willDestroyObjectsUnderfoot) return false; - } + //Down - if (!currentLocation.isTilePassable(this.nextPosition(2), viewport) || !this.willDestroyObjectsUnderfoot) - { + if (!this.currentLocation.isTilePassable(this.nextPosition(2), viewport) || !this.willDestroyObjectsUnderfoot) return false; - } + //Left - if (!currentLocation.isTilePassable(this.nextPosition(3), viewport) || !this.willDestroyObjectsUnderfoot) - { + if (!this.currentLocation.isTilePassable(this.nextPosition(3), viewport) || !this.willDestroyObjectsUnderfoot) return false; - } + return true; } - /// - /// Used to move the npc if the character renderer is valid. Handles animating all of the sprites associated with the renderer. - /// - /// - /// - /// - /// + /// Used to move the npc if the character renderer is valid. Handles animating all of the sprites associated with the renderer. public virtual void ModularMovement(GameTime time, xTile.Dimensions.Rectangle viewport, GameLocation location, float interval = 1000f) { this.characterRenderer.setAnimation(AnimationKeys.walkingKey); - if (this.canMovePastNextLocation(viewport) == false) + if (!this.canMovePastNextLocation(viewport)) { this.Halt(); return; } if (this.GetType() == typeof(FarmAnimal)) this.willDestroyObjectsUnderfoot = false; - if ((double)this.xVelocity != 0.0 || (double)this.yVelocity != 0.0) + if (this.xVelocity != 0.0 || this.yVelocity != 0.0) { - Microsoft.Xna.Framework.Rectangle boundingBox = this.GetBoundingBox(); + var boundingBox = this.GetBoundingBox(); boundingBox.X += (int)this.xVelocity; boundingBox.Y -= (int)this.yVelocity; - if (currentLocation == null || !currentLocation.isCollidingPosition(boundingBox, viewport, false, 0, false, this)) + if (this.currentLocation == null || !this.currentLocation.isCollidingPosition(boundingBox, viewport, false, 0, false, this)) { this.position.X += this.xVelocity; this.position.Y -= this.yVelocity; } - this.xVelocity = (float)(int)((double)this.xVelocity - (double)this.xVelocity / 2.0); - this.yVelocity = (float)(int)((double)this.yVelocity - (double)this.yVelocity / 2.0); + this.xVelocity = (int)(this.xVelocity - this.xVelocity / 2.0); + this.yVelocity = (int)(this.yVelocity - this.yVelocity / 2.0); } else if (this.moveUp) { - if (currentLocation == null || !currentLocation.isCollidingPosition(this.nextPosition(0), viewport, false, 0, false, this) || this.isCharging) + if (this.currentLocation == null || !this.currentLocation.isCollidingPosition(this.nextPosition(0), viewport, false, 0, false, this) || this.isCharging) { - this.position.Y -= (float)(this.speed + this.addedSpeed); + this.position.Y -= this.speed + this.addedSpeed; if (!this.ignoreMovementAnimation) { this.spriteInformation.setUp(this); - this.characterRenderer.Animate(interval,true); + this.characterRenderer.Animate(interval); //this.sprite.AnimateUp(time, (this.speed - 2 + this.addedSpeed) * -25, Utility.isOnScreen(this.getTileLocationPoint(), 1, currentLocation) ? "Cowboy_Footstep" : ""); this.faceDirection(0); } } - else if (!currentLocation.isTilePassable(this.nextPosition(0), viewport) || !this.willDestroyObjectsUnderfoot) + else if (!this.currentLocation.isTilePassable(this.nextPosition(0), viewport) || !this.willDestroyObjectsUnderfoot) this.Halt(); else if (this.willDestroyObjectsUnderfoot) { - Vector2 vector2 = new Vector2((float)(this.getStandingX() / Game1.tileSize), (float)(this.getStandingY() / Game1.tileSize - 1)); - if (currentLocation.characterDestroyObjectWithinRectangle(this.nextPosition(0), true)) + Vector2 vector2 = new Vector2(this.getStandingX() / Game1.tileSize, this.getStandingY() / Game1.tileSize - 1); + if (this.currentLocation.characterDestroyObjectWithinRectangle(this.nextPosition(0), true)) { - this.doEmote(12, true); - this.position.Y -= (float)(this.speed + this.addedSpeed); + this.doEmote(12); + this.position.Y -= this.speed + this.addedSpeed; } else this.blockedInterval = this.blockedInterval + time.ElapsedGameTime.Milliseconds; @@ -353,27 +273,27 @@ namespace CustomNPCFramework.Framework.NPCS } else if (this.moveRight) { - if (currentLocation == null || !currentLocation.isCollidingPosition(this.nextPosition(1), viewport, false, 0, false, this) || this.isCharging) + if (this.currentLocation == null || !this.currentLocation.isCollidingPosition(this.nextPosition(1), viewport, false, 0, false, this) || this.isCharging) { - this.position.X += (float)(this.speed + this.addedSpeed); + this.position.X += this.speed + this.addedSpeed; if (!this.ignoreMovementAnimation) { this.spriteInformation.setRight(this); - this.characterRenderer.Animate(interval,true); + this.characterRenderer.Animate(interval); //this.spriteInformation.sprite.Animate(time, 0, 3, 1f); //this.sprite.AnimateRight(time, (this.speed - 2 + this.addedSpeed) * -25, Utility.isOnScreen(this.getTileLocationPoint(), 1, currentLocation) ? "Cowboy_Footstep" : ""); this.faceDirection(1); } } - else if (!currentLocation.isTilePassable(this.nextPosition(1), viewport) || !this.willDestroyObjectsUnderfoot) + else if (!this.currentLocation.isTilePassable(this.nextPosition(1), viewport) || !this.willDestroyObjectsUnderfoot) this.Halt(); else if (this.willDestroyObjectsUnderfoot) { - Vector2 vector2 = new Vector2((float)(this.getStandingX() / Game1.tileSize + 1), (float)(this.getStandingY() / Game1.tileSize)); - if (currentLocation.characterDestroyObjectWithinRectangle(this.nextPosition(1), true)) + Vector2 vector2 = new Vector2(this.getStandingX() / Game1.tileSize + 1, this.getStandingY() / Game1.tileSize); + if (this.currentLocation.characterDestroyObjectWithinRectangle(this.nextPosition(1), true)) { - this.doEmote(12, true); - this.position.X += (float)(this.speed + this.addedSpeed); + this.doEmote(12); + this.position.X += this.speed + this.addedSpeed; } else this.blockedInterval = this.blockedInterval + time.ElapsedGameTime.Milliseconds; @@ -381,27 +301,27 @@ namespace CustomNPCFramework.Framework.NPCS } else if (this.moveDown) { - if (currentLocation == null || !currentLocation.isCollidingPosition(this.nextPosition(2), viewport, false, 0, false, this) || this.isCharging) + if (this.currentLocation == null || !this.currentLocation.isCollidingPosition(this.nextPosition(2), viewport, false, 0, false, this) || this.isCharging) { - this.position.Y += (float)(this.speed + this.addedSpeed); + this.position.Y += this.speed + this.addedSpeed; if (!this.ignoreMovementAnimation) { this.spriteInformation.setDown(this); - this.characterRenderer.Animate(interval,true); + this.characterRenderer.Animate(interval); //this.spriteInformation.sprite.Animate(time, 0, 3, 1f); //this.sprite.AnimateDown(time, (this.speed - 2 + this.addedSpeed) * -25, Utility.isOnScreen(this.getTileLocationPoint(), 1, currentLocation) ? "Cowboy_Footstep" : ""); this.faceDirection(2); } } - else if (!currentLocation.isTilePassable(this.nextPosition(2), viewport) || !this.willDestroyObjectsUnderfoot) + else if (!this.currentLocation.isTilePassable(this.nextPosition(2), viewport) || !this.willDestroyObjectsUnderfoot) this.Halt(); else if (this.willDestroyObjectsUnderfoot) { - Vector2 vector2 = new Vector2((float)(this.getStandingX() / Game1.tileSize), (float)(this.getStandingY() / Game1.tileSize + 1)); - if (currentLocation.characterDestroyObjectWithinRectangle(this.nextPosition(2), true)) + Vector2 vector2 = new Vector2(this.getStandingX() / Game1.tileSize, this.getStandingY() / Game1.tileSize + 1); + if (this.currentLocation.characterDestroyObjectWithinRectangle(this.nextPosition(2), true)) { - this.doEmote(12, true); - this.position.Y += (float)(this.speed + this.addedSpeed); + this.doEmote(12); + this.position.Y += this.speed + this.addedSpeed; } else this.blockedInterval = this.blockedInterval + time.ElapsedGameTime.Milliseconds; @@ -409,35 +329,35 @@ namespace CustomNPCFramework.Framework.NPCS } else if (this.moveLeft) { - if (currentLocation == null || !currentLocation.isCollidingPosition(this.nextPosition(3), viewport, false, 0, false, this) || this.isCharging) + if (this.currentLocation == null || !this.currentLocation.isCollidingPosition(this.nextPosition(3), viewport, false, 0, false, this) || this.isCharging) { - this.position.X -= (float)(this.speed + this.addedSpeed); + this.position.X -= this.speed + this.addedSpeed; if (!this.ignoreMovementAnimation) { this.spriteInformation.setLeft(this); - this.characterRenderer.Animate(interval,true); + this.characterRenderer.Animate(interval); //this.spriteInformation.sprite.Animate(time, 0, 3, 1f); //this.sprite.AnimateLeft(time, (this.speed - 2 + this.addedSpeed) * -25, Utility.isOnScreen(this.getTileLocationPoint(), 1, currentLocation) ? "Cowboy_Footstep" : ""); this.faceDirection(3); } } - else if (!currentLocation.isTilePassable(this.nextPosition(3), viewport) || !this.willDestroyObjectsUnderfoot) + else if (!this.currentLocation.isTilePassable(this.nextPosition(3), viewport) || !this.willDestroyObjectsUnderfoot) this.Halt(); else if (this.willDestroyObjectsUnderfoot) { - Vector2 vector2 = new Vector2((float)(this.getStandingX() / Game1.tileSize - 1), (float)(this.getStandingY() / Game1.tileSize)); - if (currentLocation.characterDestroyObjectWithinRectangle(this.nextPosition(3), true)) + Vector2 vector2 = new Vector2(this.getStandingX() / Game1.tileSize - 1, this.getStandingY() / Game1.tileSize); + if (this.currentLocation.characterDestroyObjectWithinRectangle(this.nextPosition(3), true)) { - this.doEmote(12, true); - this.position.X -= (float)(this.speed + this.addedSpeed); + this.doEmote(12); + this.position.X -= this.speed + this.addedSpeed; } else this.blockedInterval = this.blockedInterval + time.ElapsedGameTime.Milliseconds; } } - if (this.blockedInterval >= 3000 && (double)this.blockedInterval <= 3750.0 && !Game1.eventUp) + if (this.blockedInterval >= 3000 && this.blockedInterval <= 3750.0 && !Game1.eventUp) { - this.doEmote(Game1.random.NextDouble() < 0.5 ? 8 : 40, true); + this.doEmote(Game1.random.NextDouble() < 0.5 ? 8 : 40); this.blockedInterval = 3750; } else @@ -450,33 +370,15 @@ namespace CustomNPCFramework.Framework.NPCS } } - /// - /// Used to halt the npc sprite. Sets the npc's animation to the standing animation if the character renderer is not null. - /// + /// Used to halt the npc sprite. Sets the npc's animation to the standing animation if the character renderer is not null. public override void Halt() { - if (this.characterRenderer != null) - { - this.characterRenderer.setAnimation(AnimationKeys.standingKey); - } + this.characterRenderer?.setAnimation(AnimationKeys.standingKey); base.Halt(); } - /// - /// Used to update npc information. - /// - /// - /// - public override void update(GameTime time, GameLocation location) - { - base.update(time, location); - } - - /// - /// Pathfinding code. - /// - /// - public virtual void routeEndAnimationFinished(StardewValley.Farmer who) + /// Pathfinding code. + public virtual void routeEndAnimationFinished(Farmer who) { this.doingEndOfRouteAnimation.Value = false; this.freezeMotion = false; @@ -493,26 +395,15 @@ namespace CustomNPCFramework.Framework.NPCS this.timeAfterSquare = Game1.timeOfDay; } - /// - /// Pathfinding code. - /// - /// - /// - public virtual void doAnimationAtEndOfScheduleRoute(Character c, GameLocation l) - { - } + /// Pathfinding code. + public virtual void doAnimationAtEndOfScheduleRoute(Character c, GameLocation l) { } - /// - /// Pathfinding code. - /// - /// + /// Pathfinding code. public virtual void startRouteBehavior(string behaviorName) { if (behaviorName.Length > 0 && (int)behaviorName[0] == 34) - { this.endOfRouteMessage.Value = behaviorName.Replace("\"", ""); - } else { if (behaviorName.Contains("square_")) @@ -524,24 +415,20 @@ namespace CustomNPCFramework.Framework.NPCS } else { - Utility.getGameLocationOfCharacter(this).temporarySprites.Add(new TemporaryAnimatedSprite("LooseSprites\\Cursors", new Microsoft.Xna.Framework.Rectangle(167, 1714, 19, 14), 100f, 3, 999999, new Vector2(2f, 3f) * (float)Game1.tileSize + new Vector2(7f, 12f) * (float)Game1.pixelZoom, false, false, 0.0002f, 0.0f, Color.White, (float)Game1.pixelZoom, 0.0f, 0.0f, 0.0f, false) + Utility.getGameLocationOfCharacter(this).temporarySprites.Add(new TemporaryAnimatedSprite("LooseSprites\\Cursors", new Microsoft.Xna.Framework.Rectangle(167, 1714, 19, 14), 100f, 3, 999999, new Vector2(2f, 3f) * (float)Game1.tileSize + new Vector2(7f, 12f) * (float)Game1.pixelZoom, false, false, 0.0002f, 0.0f, Color.White, (float)Game1.pixelZoom, 0.0f, 0.0f, 0.0f) { id = 688f }); - this.doEmote(52, true); + this.doEmote(52); } } } - /// - /// Occurs when the npc gets hit by the player. - /// - /// - /// + /// Occurs when the npc gets hit by the player. public new void getHitByPlayer(StardewValley.Farmer who, GameLocation location) { - this.doEmote(12, true); + this.doEmote(12); if (who == null) { if (Game1.IsMultiplayer) @@ -550,8 +437,7 @@ namespace CustomNPCFramework.Framework.NPCS } if (who.friendshipData.ContainsKey(this.Name)) { - Friendship f; - who.friendshipData.TryGetValue(this.Name, out f); + who.friendshipData.TryGetValue(this.Name, out Friendship f); f.Points -= 30; if (who.IsMainPlayer) { @@ -570,7 +456,7 @@ namespace CustomNPCFramework.Framework.NPCS public override void dayUpdate(int dayOfMonth) { if (this.currentLocation != null) - Game1.warpCharacter(this, this.DefaultMap, this.DefaultPosition / (float)Game1.tileSize); + Game1.warpCharacter(this, this.DefaultMap, this.DefaultPosition / Game1.tileSize); Game1.player.mailReceived.Remove(this.Name); Game1.player.mailReceived.Remove(this.Name + "Cooking"); this.doingEndOfRouteAnimation.Value = false; @@ -582,18 +468,18 @@ namespace CustomNPCFramework.Framework.NPCS this.hasSaidAfternoonDialogue = false; this.ignoreScheduleToday = false; this.Halt(); - this.controller = (PathFindController)null; - this.temporaryController = (PathFindController)null; - this.DirectionsToNewLocation = (SchedulePathDescription)null; + this.controller = null; + this.temporaryController = null; + this.DirectionsToNewLocation = null; this.faceDirection(this.DefaultFacingDirection); this.scheduleTimeToTry = 9999999; this.previousEndPoint = new Point((int)this.DefaultPosition.X / Game1.tileSize, (int)this.DefaultPosition.Y / Game1.tileSize); this.IsWalkingInSquare = false; this.returningToEndPoint = false; - this.lastCrossroad = Microsoft.Xna.Framework.Rectangle.Empty; + this.lastCrossroad = Rectangle.Empty; if (this.isVillager()) this.Schedule = this.getSchedule(dayOfMonth); - this.endOfRouteMessage.Value = (string)null; + this.endOfRouteMessage.Value = null; bool flag = Utility.isFestivalDay(dayOfMonth, Game1.currentSeason); if (!this.isMarried()) return; @@ -602,18 +488,10 @@ namespace CustomNPCFramework.Framework.NPCS //this.daysMarried = this.daysMarried + 1; } - /// - /// Does effectively nothing. - /// - public new void setUpForOutdoorPatioActivity() - { - } + /// Does effectively nothing. + public new void setUpForOutdoorPatioActivity() { } - /// - /// Used to draw the npc with the custom renderer. - /// - /// - /// + /// Used to draw the npc with the custom renderer. public virtual void drawModular(SpriteBatch b, float alpha = 1f) { if (this.characterRenderer == null || this.IsInvisible || !Utility.isOnScreen(this.position, 2 * Game1.tileSize)) @@ -623,7 +501,7 @@ namespace CustomNPCFramework.Framework.NPCS { this.characterRenderer.setAnimation(AnimationKeys.swimmingKey); this.characterRenderer.setDirection(this.facingDirection); - this.characterRenderer.draw(b,this,this.getLocalPosition(Game1.viewport) + new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize + Game1.tileSize / 4 + this.yJumpOffset * 2)) + (this.shakeTimer > 0 ? new Vector2((float)Game1.random.Next(-1, 2), (float)Game1.random.Next(-1, 2)) : Vector2.Zero) - new Vector2(0.0f, this.yOffset), new Microsoft.Xna.Framework.Rectangle?(new Microsoft.Xna.Framework.Rectangle(this.Sprite.SourceRect.X, this.Sprite.SourceRect.Y, this.Sprite.SourceRect.Width, this.Sprite.SourceRect.Height / 2 - (int)((double)this.yOffset / (double)Game1.pixelZoom))), Color.White, this.rotation, new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize * 3 / 2)) / 4f, Math.Max(0.2f, this.Scale) * (float)Game1.pixelZoom, this.flip ? SpriteEffects.FlipHorizontally : SpriteEffects.None, Math.Max(0.0f, (float)this.getStandingY() / 10000f)); + this.characterRenderer.draw(b, this, this.getLocalPosition(Game1.viewport) + new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize + Game1.tileSize / 4 + this.yJumpOffset * 2)) + (this.shakeTimer > 0 ? new Vector2((float)Game1.random.Next(-1, 2), (float)Game1.random.Next(-1, 2)) : Vector2.Zero) - new Vector2(0.0f, this.yOffset), new Microsoft.Xna.Framework.Rectangle?(new Microsoft.Xna.Framework.Rectangle(this.Sprite.SourceRect.X, this.Sprite.SourceRect.Y, this.Sprite.SourceRect.Width, this.Sprite.SourceRect.Height / 2 - (int)((double)this.yOffset / (double)Game1.pixelZoom))), Color.White, this.rotation, new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize * 3 / 2)) / 4f, Math.Max(0.2f, this.Scale) * (float)Game1.pixelZoom, this.flip ? SpriteEffects.FlipHorizontally : SpriteEffects.None, Math.Max(0.0f, (float)this.getStandingY() / 10000f)); //Vector2 localPosition = this.getLocalPosition(Game1.viewport); //b.Draw(Game1.staminaRect, new Microsoft.Xna.Framework.Rectangle((int)localPosition.X + (int)this.yOffset + Game1.pixelZoom * 2, (int)localPosition.Y - 32 * Game1.pixelZoom + this.sprite.SourceRect.Height * Game1.pixelZoom + Game1.tileSize * 3 / 4 + this.yJumpOffset * 2 - (int)this.yOffset, this.sprite.SourceRect.Width * Game1.pixelZoom - (int)this.yOffset * 2 - Game1.pixelZoom * 4, Game1.pixelZoom), new Microsoft.Xna.Framework.Rectangle?(Game1.staminaRect.Bounds), Color.White * 0.75f, 0.0f, Vector2.Zero, SpriteEffects.None, (float)((double)this.getStandingY() / 10000.0 + 1.0 / 1000.0)); } @@ -655,7 +533,7 @@ namespace CustomNPCFramework.Framework.NPCS sourceRect.Height /= 2; } //The actual character drawing to the screen? - this.characterRenderer.draw(b, this, this.getLocalPosition(Game1.viewport) + (this.shakeTimer > 0 ? new Vector2((float)Game1.random.Next(-1, 2), (float)Game1.random.Next(-1, 2)) : Vector2.Zero), new Microsoft.Xna.Framework.Rectangle?(sourceRect), Color.White * alpha, this.rotation,Vector2.Zero, Math.Max(0.2f, this.Scale), this.flip ? SpriteEffects.FlipHorizontally : SpriteEffects.None, Math.Max(0.0f, this.drawOnTop ? 0.992f : (float)((double)this.getStandingY() / 10000.0 + 1.0 / 1000.0))); + this.characterRenderer.draw(b, this, this.getLocalPosition(Game1.viewport) + (this.shakeTimer > 0 ? new Vector2((float)Game1.random.Next(-1, 2), (float)Game1.random.Next(-1, 2)) : Vector2.Zero), new Microsoft.Xna.Framework.Rectangle?(sourceRect), Color.White * alpha, this.rotation, Vector2.Zero, Math.Max(0.2f, this.Scale), this.flip ? SpriteEffects.FlipHorizontally : SpriteEffects.None, Math.Max(0.0f, this.drawOnTop ? 0.992f : (float)((double)this.getStandingY() / 10000.0 + 1.0 / 1000.0))); //this.characterRenderer.draw(b,this, this.getLocalPosition(Game1.viewport) + vector2 + (this.shakeTimer > 0 ? new Vector2((float)Game1.random.Next(-1, 2), (float)Game1.random.Next(-1, 2)) : Vector2.Zero), new Microsoft.Xna.Framework.Rectangle?(sourceRect), Color.White * alpha, this.rotation, new Vector2((float)(sourceRect.Width / 2), (float)(sourceRect.Height / 2 + 1)), Math.Max(0.2f, this.scale) * (float)Game1.pixelZoom + num, this.flip ? SpriteEffects.FlipHorizontally : SpriteEffects.None, Math.Max(0.0f, this.drawOnTop ? 0.992f : (float)((double)this.getStandingY() / 10000.0 + 1.0 / 1000.0))); //this.characterRenderer.draw(b, this, this.getLocalPosition(Game1.viewport) + vector2 + (this.shakeTimer > 0 ? new Vector2((float)Game1.random.Next(-1, 2), (float)Game1.random.Next(-1, 2)) : Vector2.Zero), new Microsoft.Xna.Framework.Rectangle?(sourceRect), Color.White * alpha, this.rotation, new Vector2((float)(sourceRect.Width / 2), (float)(sourceRect.Height / 2 + 1)), Math.Max(0.2f, this.scale) * (float)Game1.pixelZoom + num, this.flip ? SpriteEffects.FlipHorizontally : SpriteEffects.None, .99f); } @@ -667,7 +545,7 @@ namespace CustomNPCFramework.Framework.NPCS //Checks if the npc is glowing. if (this.isGlowing) - this.characterRenderer.draw(b,this, this.getLocalPosition(Game1.viewport) + new Vector2((float)(this.Sprite.SpriteWidth * Game1.pixelZoom / 2), (float)(this.GetBoundingBox().Height / 2)) + (this.shakeTimer > 0 ? new Vector2((float)Game1.random.Next(-1, 2), (float)Game1.random.Next(-1, 2)) : Vector2.Zero), new Microsoft.Xna.Framework.Rectangle?(this.Sprite.SourceRect), this.glowingColor * this.glowingTransparency, this.rotation, new Vector2((float)(this.Sprite.SpriteWidth / 2), (float)((double)this.Sprite.SpriteHeight * 3.0 / 4.0)), Math.Max(0.2f, this.Scale) * 4f, this.flip ? SpriteEffects.FlipHorizontally : SpriteEffects.None, Math.Max(0.0f, this.drawOnTop ? 0.99f : (float)((double)this.getStandingY() / 10000.0 + 1.0 / 1000.0))); + this.characterRenderer.draw(b, this, this.getLocalPosition(Game1.viewport) + new Vector2((float)(this.Sprite.SpriteWidth * Game1.pixelZoom / 2), (float)(this.GetBoundingBox().Height / 2)) + (this.shakeTimer > 0 ? new Vector2((float)Game1.random.Next(-1, 2), (float)Game1.random.Next(-1, 2)) : Vector2.Zero), new Microsoft.Xna.Framework.Rectangle?(this.Sprite.SourceRect), this.glowingColor * this.glowingTransparency, this.rotation, new Vector2((float)(this.Sprite.SpriteWidth / 2), (float)((double)this.Sprite.SpriteHeight * 3.0 / 4.0)), Math.Max(0.2f, this.Scale) * 4f, this.flip ? SpriteEffects.FlipHorizontally : SpriteEffects.None, Math.Max(0.0f, this.drawOnTop ? 0.99f : (float)((double)this.getStandingY() / 10000.0 + 1.0 / 1000.0))); //This code runs if the npc is emoting. if (!this.IsEmoting || Game1.eventUp) @@ -677,9 +555,7 @@ namespace CustomNPCFramework.Framework.NPCS b.Draw(Game1.emoteSpriteSheet, localPosition1, new Microsoft.Xna.Framework.Rectangle?(new Microsoft.Xna.Framework.Rectangle(this.CurrentEmoteIndex * 16 % Game1.emoteSpriteSheet.Width, this.CurrentEmoteIndex * 16 / Game1.emoteSpriteSheet.Width * 16, 16, 16)), Color.White, 0.0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, (float)this.getStandingY() / 10000f); } - /// - /// Used to draw the sprite without the modular npc renderer - /// + /// Used to draw the sprite without the modular npc renderer /// /// public virtual void drawNonModularSprite(SpriteBatch b, float alpha = 1f) @@ -728,9 +604,7 @@ namespace CustomNPCFramework.Framework.NPCS } - /// - /// Basic draw functionality to checkn whether or not to draw the npc using it's default sprite or using a custom character renderer. - /// + /// Basic draw functionality to checkn whether or not to draw the npc using it's default sprite or using a custom character renderer. /// /// public override void draw(SpriteBatch b, float alpha = 1f) diff --git a/GeneralMods/CustomNPCFramework/Framework/NPCS/MerchantNPC.cs b/GeneralMods/CustomNPCFramework/Framework/NPCS/MerchantNPC.cs index 457523cc..34433679 100644 --- a/GeneralMods/CustomNPCFramework/Framework/NPCS/MerchantNPC.cs +++ b/GeneralMods/CustomNPCFramework/Framework/NPCS/MerchantNPC.cs @@ -1,56 +1,41 @@ -using CustomNPCFramework.Framework.ModularNPCS; -using CustomNPCFramework.Framework.ModularNPCS.ModularRenderers; +using System.Collections.Generic; +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 { - /// - /// Extended merchant npc from ExtendedNPC. - /// - class MerchantNPC: ExtendedNPC + /// Extended merchant npc from ExtendedNPC. + class MerchantNpc : ExtendedNpc { - /// - /// Thelist of items this npc has for sale. - /// + /// The list of items this npc has for sale. public List stock; - /// - /// Constructor. - /// + + /// 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) + public MerchantNpc(List Stock, Sprite sprite, BasicRenderer renderer, Vector2 position, int facingDirection, string name) + : base(sprite, renderer, position, facingDirection, name) { this.stock = Stock; } - - /// - /// Constructor. - /// + /// 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) + 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(StardewValley.Farmer who, GameLocation l) + /// 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) { diff --git a/GeneralMods/CustomNPCFramework/Framework/Utilities/NPCTracker.cs b/GeneralMods/CustomNPCFramework/Framework/Utilities/NPCTracker.cs index 4240bd0d..571aca1c 100644 --- a/GeneralMods/CustomNPCFramework/Framework/Utilities/NPCTracker.cs +++ b/GeneralMods/CustomNPCFramework/Framework/Utilities/NPCTracker.cs @@ -1,89 +1,64 @@ -using CustomNPCFramework.Framework.NPCS; +using System.Collections.Generic; +using CustomNPCFramework.Framework.NPCS; 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.Utilities { - /// - /// Used to keep track of all of the custom npcs. - /// - public class NPCTracker + /// Used to keep track of all of the custom npcs. + public class NpcTracker { - /// - /// A list used to keep track of the npcs. - /// - public List moddedNPCS; + /// A list used to keep track of the npcs. + public List moddedNpcs; - /// - /// Constructor. - /// - public NPCTracker() + /// Construct an instance. + public NpcTracker() { - this.moddedNPCS = new List(); + this.moddedNpcs = new List(); } - /// - /// Use this to add a new npc into the game. - /// + /// Use this to add a new npc into the game. /// The game location to add the npc to. /// The extended npc to add to the location. - public void addNewNPCToLocation(GameLocation loc,ExtendedNPC npc) + public void addNewNpcToLocation(GameLocation loc, ExtendedNpc npc) { - this.moddedNPCS.Add(npc); + this.moddedNpcs.Add(npc); npc.defaultLocation = loc; npc.currentLocation = loc; loc.addCharacter(npc); } - /// - /// Add a npc to a location. - /// + /// Add a npc to a location. /// The game location to add an npc to. /// The extended npc to add to the location. /// The tile position at the game location to add the mpc to. - public void addNewNPCToLocation(GameLocation loc, ExtendedNPC npc, Vector2 tilePosition) + public void addNewNpcToLocation(GameLocation loc, ExtendedNpc npc, Vector2 tilePosition) { - this.moddedNPCS.Add(npc); + this.moddedNpcs.Add(npc); npc.defaultLocation = loc; npc.currentLocation = loc; - npc.position.Value = tilePosition*Game1.tileSize; + npc.position.Value = tilePosition * Game1.tileSize; loc.addCharacter(npc); } - /// - /// Use this simply to remove a single npc from a location. - /// - /// - /// - public void removeCharacterFromLocation(GameLocation loc, ExtendedNPC npc) + /// Use this simply to remove a single npc from a location. + public void removeCharacterFromLocation(GameLocation loc, ExtendedNpc npc) { loc.characters.Remove(npc); } - - /// - /// Use this to completly remove and npc from the game as it is removed from the location and is no longer tracked. - /// + + /// Use this to completly remove and npc from the game as it is removed from the location and is no longer tracked. /// The npc to remove from the location. - public void removeFromLocationAndTrackingList(ExtendedNPC npc) + public void removeFromLocationAndTrackingList(ExtendedNpc npc) { - if (npc.currentLocation != null) - { - npc.currentLocation.characters.Remove(npc); - } - this.moddedNPCS.Remove(npc); + npc.currentLocation?.characters.Remove(npc); + this.moddedNpcs.Remove(npc); } - /// - /// Use this to clean up all of the npcs before the game is saved. - /// + /// Use this to clean up all of the npcs before the game is saved. public void cleanUpBeforeSave() { - foreach(ExtendedNPC npc in this.moddedNPCS) + foreach (ExtendedNpc npc in this.moddedNpcs) { //npc.currentLocation.characters.Remove(npc); //Game1.removeThisCharacterFromAllLocations(npc); @@ -91,19 +66,13 @@ namespace CustomNPCFramework.Framework.Utilities Class1.ModMonitor.Log("Removed an npc!"); //Do some saving code here. } - } - /// - /// Use this to load in all of the npcs again after saving. - /// + /// Use this to load in all of the npcs again after saving. public void afterSave() { - foreach(ExtendedNPC npc in this.moddedNPCS) - { + foreach (ExtendedNpc npc in this.moddedNpcs) npc.defaultLocation.addCharacter(npc); - } } - } } diff --git a/GeneralMods/CustomNPCFramework/manifest.json b/GeneralMods/CustomNPCFramework/manifest.json index 56346973..0aec6403 100644 --- a/GeneralMods/CustomNPCFramework/manifest.json +++ b/GeneralMods/CustomNPCFramework/manifest.json @@ -6,5 +6,5 @@ "UniqueID": "Omegasis.CustomNPCFramework", "EntryDll": "CustomNPCFramework.dll", "MinimumApiVersion": "2.0", - "UpdateKeys": [ ] + "UpdateKeys": [] } diff --git a/GeneralMods/DailyQuestAnywhere/DailyQuestAnywhere.cs b/GeneralMods/DailyQuestAnywhere/DailyQuestAnywhere.cs index 0be9151e..e8e4fe99 100644 --- a/GeneralMods/DailyQuestAnywhere/DailyQuestAnywhere.cs +++ b/GeneralMods/DailyQuestAnywhere/DailyQuestAnywhere.cs @@ -1,17 +1,16 @@ -using Omegasis.DailyQuestAnywhere.Framework; +using System; +using Omegasis.DailyQuestAnywhere.Framework; using StardewModdingAPI; using StardewModdingAPI.Events; using StardewValley; using StardewValley.Menus; using StardewValley.Quests; -using System; namespace Omegasis.DailyQuestAnywhere { /* *TODO: Make quest core mod??? */ - /// The mod entry point. public class DailyQuestAnywhere : Mod { @@ -34,12 +33,10 @@ namespace Omegasis.DailyQuestAnywhere this.Config = helper.ReadConfig(); ControlEvents.KeyPressed += this.ControlEvents_KeyPressed; - StardewModdingAPI.Events.SaveEvents.AfterSave += SaveEvents_AfterSave; + SaveEvents.AfterSave += this.SaveEvents_AfterSave; } - - /********* ** Private methods *********/ @@ -49,31 +46,26 @@ namespace Omegasis.DailyQuestAnywhere private void ControlEvents_KeyPressed(object sender, EventArgsKeyPressed e) { if (Context.IsPlayerFree && e.KeyPressed.ToString() == this.Config.KeyBinding) - if (Game1.player.hasDailyQuest() == false ) + if (!Game1.player.hasDailyQuest()) { if (this.dailyQuest == null) { - this.dailyQuest = generateDailyQuest(); + this.dailyQuest = this.generateDailyQuest(); } Game1.questOfTheDay = this.dailyQuest; Game1.activeClickableMenu = new Billboard(true); - } + } } - /// - /// Makes my daily quest referene null so we can't just keep getting a new reference. - /// - /// - /// + /// Makes my daily quest referene null so we can't just keep getting a new reference. + /// The event sender. + /// The event data. private void SaveEvents_AfterSave(object sender, System.EventArgs e) { this.dailyQuest = null; //Nullify my quest reference. } - /// - /// Generate a daily quest for sure. - /// - /// + /// Generate a daily quest for sure. public Quest generateDailyQuest() { @@ -82,18 +74,27 @@ namespace Omegasis.DailyQuestAnywhere float actualChance = chance / 100; //If we hit the chance for actually generating a daily quest do so, otherwise don't generate a daily quest. - if (actualChance <= Config.chanceForDailyQuest) + if (actualChance <= this.Config.chanceForDailyQuest) { Random r = new Random((int)Game1.uniqueIDForThisGame + (int)Game1.stats.DaysPlayed); int rand = r.Next(0, 7); - - if (rand == 0) return new ItemDeliveryQuest(); - if (rand == 1) return new FishingQuest(); - if (rand == 2) return new StardewValley.Quests.CraftingQuest(); - if (rand == 3) return new StardewValley.Quests.ItemDeliveryQuest(); - if (rand == 4) return new StardewValley.Quests.ItemHarvestQuest(); - if (rand == 5) return new StardewValley.Quests.ResourceCollectionQuest(); - if (rand == 6) return new StardewValley.Quests.SlayMonsterQuest(); + switch (rand) + { + case 0: + return new ItemDeliveryQuest(); + case 1: + return new FishingQuest(); + case 2: + return new StardewValley.Quests.CraftingQuest(); + case 3: + return new StardewValley.Quests.ItemDeliveryQuest(); + case 4: + return new StardewValley.Quests.ItemHarvestQuest(); + case 5: + return new StardewValley.Quests.ResourceCollectionQuest(); + case 6: + return new StardewValley.Quests.SlayMonsterQuest(); + } } return null; //This should never happen. } diff --git a/GeneralMods/DailyQuestAnywhere/Framework/ModConfig.cs b/GeneralMods/DailyQuestAnywhere/Framework/ModConfig.cs index a6f01664..a88ee0fe 100644 --- a/GeneralMods/DailyQuestAnywhere/Framework/ModConfig.cs +++ b/GeneralMods/DailyQuestAnywhere/Framework/ModConfig.cs @@ -1,4 +1,4 @@ -namespace Omegasis.DailyQuestAnywhere.Framework +namespace Omegasis.DailyQuestAnywhere.Framework { /// The mod configuration. internal class ModConfig @@ -6,9 +6,7 @@ /// The key which shows the menu. public string KeyBinding { get; set; } = "H"; - /// - /// The chance for a daily quest to actually happen. - /// + /// The chance for a daily quest to actually happen. public float chanceForDailyQuest { get; set; } = .75f; } } diff --git a/GeneralMods/Fall28SnowDay/Fall28SnowDay.cs b/GeneralMods/Fall28SnowDay/Fall28SnowDay.cs index 58d7f373..00b042d6 100644 --- a/GeneralMods/Fall28SnowDay/Fall28SnowDay.cs +++ b/GeneralMods/Fall28SnowDay/Fall28SnowDay.cs @@ -1,4 +1,4 @@ -using System; +using System; using StardewModdingAPI; using StardewModdingAPI.Events; using StardewValley; diff --git a/GeneralMods/FarmersMarketStall/Class1.cs b/GeneralMods/FarmersMarketStall/Class1.cs index 036a74a5..6d4e3138 100644 --- a/GeneralMods/FarmersMarketStall/Class1.cs +++ b/GeneralMods/FarmersMarketStall/Class1.cs @@ -1,17 +1,12 @@ -using EventSystem.Framework.FunctionEvents; +using System; +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 @@ -21,21 +16,21 @@ namespace FarmersMarketStall /// Make a selling menu /// Make a minigame event for bonus money to earn. /// - /// - - public class Class1 :Mod + public class Class1 : Mod { - public static IModHelper ModHelper; public static IMonitor ModMonitor; - public static FarmersMarketStall.Framework.MarketStall marketStall; + public static Framework.MarketStall marketStall; + + /// The mod entry point, called after the mod is first loaded. + /// Provides simplified APIs for writing mods. public override void Entry(IModHelper helper) { - ModHelper = Helper; - ModMonitor = Monitor; + ModHelper = this.Helper; + ModMonitor = this.Monitor; - StardewModdingAPI.Events.SaveEvents.BeforeSave += SaveEvents_BeforeSave; - StardewModdingAPI.Events.SaveEvents.AfterLoad += SaveEvents_AfterLoad; + StardewModdingAPI.Events.SaveEvents.BeforeSave += this.SaveEvents_BeforeSave; + StardewModdingAPI.Events.SaveEvents.AfterLoad += this.SaveEvents_AfterLoad; marketStall = new Framework.MarketStall(); } @@ -46,7 +41,8 @@ namespace FarmersMarketStall private void SaveEvents_BeforeSave(object sender, EventArgs e) { - if (marketStall.stock.Count > 0) { + 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 index 84e57097..d77edb4c 100644 --- a/GeneralMods/FarmersMarketStall/FarmersMarketStall.csproj +++ b/GeneralMods/FarmersMarketStall/FarmersMarketStall.csproj @@ -91,5 +91,8 @@ EventSystem + + + \ No newline at end of file diff --git a/GeneralMods/FarmersMarketStall/Framework/MapEvents/ShopInteractionEvent.cs b/GeneralMods/FarmersMarketStall/Framework/MapEvents/ShopInteractionEvent.cs index 25fbd4b1..7ee285b6 100644 --- a/GeneralMods/FarmersMarketStall/Framework/MapEvents/ShopInteractionEvent.cs +++ b/GeneralMods/FarmersMarketStall/Framework/MapEvents/ShopInteractionEvent.cs @@ -1,18 +1,13 @@ -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 class ShopInteractionEvent : EventSystem.Framework.MapEvent { - public ShopInteractionEvent(string Name, GameLocation Location, Vector2 Position, MouseButtonEvents MouseEvents, MouseEntryLeaveEvent EntryLeave) : base(Name, Location, Position) + public ShopInteractionEvent(string Name, GameLocation Location, Vector2 Position, MouseButtonEvents MouseEvents, MouseEntryLeaveEvent EntryLeave) + : base(Name, Location, Position) { this.name = Name; this.location = Location; @@ -24,18 +19,17 @@ namespace FarmersMarketStall.Framework.MapEvents 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; + if (!base.OnLeftClick()) + 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. - /// + /// Used to update the event and check for interaction. public override void update() { this.clickEvent(); @@ -43,6 +37,5 @@ namespace FarmersMarketStall.Framework.MapEvents this.OnMouseEnter(); this.OnMouseLeave(); } - } } diff --git a/GeneralMods/FarmersMarketStall/Framework/MarketStall.cs b/GeneralMods/FarmersMarketStall/Framework/MarketStall.cs index c043bcf6..5ae3c5e6 100644 --- a/GeneralMods/FarmersMarketStall/Framework/MarketStall.cs +++ b/GeneralMods/FarmersMarketStall/Framework/MarketStall.cs @@ -1,9 +1,5 @@ -using StardewValley; -using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using StardewValley; namespace FarmersMarketStall.Framework { @@ -11,10 +7,7 @@ namespace FarmersMarketStall.Framework { public List stock; - public MarketStall() - { - - } + public MarketStall() { } public void addItemToSell(Item item) { @@ -28,12 +21,10 @@ namespace FarmersMarketStall.Framework public void sellAllItems() { - foreach(var item in stock) - { - Game1.player.money+=(int)(item.salePrice() * 1.10f); //Replace the multiplier with some sort of level. - } + foreach (var item in this.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 index 466833db..47b8cecc 100644 --- a/GeneralMods/FarmersMarketStall/Framework/Menus/MarketStallMenu.cs +++ b/GeneralMods/FarmersMarketStall/Framework/Menus/MarketStallMenu.cs @@ -1,10 +1,5 @@ -using StardewValley; -using StardewValley.Menus; using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using StardewValley.Menus; namespace FarmersMarketStall.Framework.Menus { @@ -17,9 +12,8 @@ namespace FarmersMarketStall.Framework.Menus public static IClickableMenu openMenu(MarketStall marketStall) { - throw new NotImplementedException("This menu isn't implemented because the author is busy/lazy. Please encorage Omegasis to finish it!",null); + throw new NotImplementedException("This menu isn't implemented because the author is busy/lazy. Please encorage Omegasis to finish it!", null); //return new StardewValley.Menus.InventoryMenu((int)(Game1.viewport.Width*.25f),(int)(Game1.viewport.Height*.25f),true,marketStall.stock); } - } } diff --git a/GeneralMods/FarmersMarketStall/manifest.json b/GeneralMods/FarmersMarketStall/manifest.json index c6ed000c..6cf9b432 100644 --- a/GeneralMods/FarmersMarketStall/manifest.json +++ b/GeneralMods/FarmersMarketStall/manifest.json @@ -6,11 +6,8 @@ "UniqueID": "SunDrop.SunDropMapEvents.FarmersMarketStall", "EntryDll": "FarmersMarketStall.dll", "MinimumApiVersion": "2.0", - "UpdateKeys": [ ], + "UpdateKeys": [], "Dependencies": [ - { - "UniqueID": "Omegasis.EventSystem", - "IsRequired": true - } -] + { "UniqueID": "Omegasis.EventSystem" } + ] } diff --git a/GeneralMods/HappyBirthday/BirthdayEvents.cs b/GeneralMods/HappyBirthday/BirthdayEvents.cs index 1d71cd3d..8da384ae 100644 --- a/GeneralMods/HappyBirthday/BirthdayEvents.cs +++ b/GeneralMods/HappyBirthday/BirthdayEvents.cs @@ -1,16 +1,9 @@ -using StardewValley; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using StardewValley; namespace Omegasis.HappyBirthday { - /// - /// TODO:Make all the events - /// Resources:https://stardewvalleywiki.com/Modding:Event_data - /// + // TODO: Make all the events + // Resources:https://stardewvalleywiki.com/Modding:Event_data public class BirthdayEvents { public Event communityCenterJunimoEvent; @@ -21,7 +14,7 @@ namespace Omegasis.HappyBirthday public BirthdayEvents() { - initializeEvents(); + this.initializeEvents(); } public void initializeEvents() @@ -29,7 +22,5 @@ namespace Omegasis.HappyBirthday Event e = new Event("", -1, Game1.player); Game1.player.currentLocation.currentEvent = new Event(); } - - } } diff --git a/GeneralMods/HappyBirthday/BirthdayMessages.cs b/GeneralMods/HappyBirthday/BirthdayMessages.cs index 49c33786..1d31f427 100644 --- a/GeneralMods/HappyBirthday/BirthdayMessages.cs +++ b/GeneralMods/HappyBirthday/BirthdayMessages.cs @@ -1,25 +1,17 @@ -using Newtonsoft.Json; -using System; using System.Collections.Generic; using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using Newtonsoft.Json; namespace Omegasis.HappyBirthday { public class BirthdayMessages { - /// - /// The actual birthday wishes given by an npc. - /// + /// The actual birthday wishes given by an npc. public Dictionary birthdayWishes; public Dictionary spouseBirthdayWishes; - /// - /// TODO: Make this. - /// + // TODO: Make this. public Dictionary defaultSpouseBirthdayWishes = new Dictionary() { ["Alex"] = "", @@ -36,9 +28,7 @@ namespace Omegasis.HappyBirthday ["Penny"] = "", }; - /// - /// Used to contain - /// + /// Used to contain public Dictionary defaultBirthdayWishes = new Dictionary() { ["Robin"] = "Hey @, happy birthday! I'm glad you choose this town to move here to. ", @@ -76,12 +66,9 @@ namespace Omegasis.HappyBirthday ["Krobus"] = "I have heard that it is tradition to give a gift to others on their birthday. In that case, happy birthday @." }; - /// - /// Used to load all of the default birthday greetings. - /// + /// Used to load all of the default birthday greetings. public void createBirthdayGreetings() { - var serializer = JsonSerializer.Create(); serializer.Formatting = Formatting.Indented; @@ -89,75 +76,64 @@ namespace Omegasis.HappyBirthday string defaultPath = Path.Combine(HappyBirthday.ModHelper.DirectoryPath, "Content", "Dialogue", HappyBirthday.Config.translationInfo.currentTranslation); if (!Directory.Exists(defaultPath)) Directory.CreateDirectory(defaultPath); - string birthdayFileDict=HappyBirthday.Config.translationInfo.getjsonForTranslation("BirthdayWishes", HappyBirthday.Config.translationInfo.currentTranslation); - string path = Path.Combine( "Content", "Dialogue", HappyBirthday.Config.translationInfo.currentTranslation, birthdayFileDict); + string birthdayFileDict = HappyBirthday.Config.translationInfo.getjsonForTranslation("BirthdayWishes", HappyBirthday.Config.translationInfo.currentTranslation); + string path = Path.Combine("Content", "Dialogue", HappyBirthday.Config.translationInfo.currentTranslation, birthdayFileDict); //Handle normal birthday wishes. - if (!File.Exists(Path.Combine(HappyBirthday.ModHelper.DirectoryPath,path))) + if (!File.Exists(Path.Combine(HappyBirthday.ModHelper.DirectoryPath, path))) { HappyBirthday.ModMonitor.Log("Creating Villager Birthday Messages", StardewModdingAPI.LogLevel.Alert); - HappyBirthday.ModHelper.Data.WriteJsonFile>(path, defaultBirthdayWishes); - this.birthdayWishes = defaultBirthdayWishes; + HappyBirthday.ModHelper.Data.WriteJsonFile>(path, this.defaultBirthdayWishes); + this.birthdayWishes = this.defaultBirthdayWishes; } else - { - birthdayWishes = HappyBirthday.ModHelper.Data.ReadJsonFile>(path); - } + this.birthdayWishes = HappyBirthday.ModHelper.Data.ReadJsonFile>(path); //handle spouse birthday wishes. string spouseBirthdayFileDict = HappyBirthday.Config.translationInfo.getjsonForTranslation("SpouseBirthdayWishes", HappyBirthday.Config.translationInfo.currentTranslation); string spousePath = Path.Combine("Content", "Dialogue", HappyBirthday.Config.translationInfo.currentTranslation, spouseBirthdayFileDict); - if (!File.Exists(Path.Combine(HappyBirthday.ModHelper.DirectoryPath,spousePath))) + if (!File.Exists(Path.Combine(HappyBirthday.ModHelper.DirectoryPath, spousePath))) { HappyBirthday.ModMonitor.Log("Creating Spouse Messages", StardewModdingAPI.LogLevel.Alert); - HappyBirthday.ModHelper.Data.WriteJsonFile>(spousePath, defaultSpouseBirthdayWishes); - this.spouseBirthdayWishes = defaultSpouseBirthdayWishes; + HappyBirthday.ModHelper.Data.WriteJsonFile>(spousePath, this.defaultSpouseBirthdayWishes); + this.spouseBirthdayWishes = this.defaultSpouseBirthdayWishes; } else - { - spouseBirthdayWishes = HappyBirthday.ModHelper.Data.ReadJsonFile>(spousePath); - } + this.spouseBirthdayWishes = HappyBirthday.ModHelper.Data.ReadJsonFile>(spousePath); //Non-english logic for creating templates. - foreach(var translation in HappyBirthday.Config.translationInfo.translationCodes) + foreach (var translation in HappyBirthday.Config.translationInfo.translationCodes) { - if (translation.Key == "English") continue; - string basePath = Path.Combine(HappyBirthday.ModHelper.DirectoryPath,"Content", "Dialogue", translation.Key); - if (!Directory.Exists(basePath)) Directory.CreateDirectory(basePath); - string tempBirthdayFile =Path.Combine("Content", "Dialogue", translation.Key, HappyBirthday.Config.translationInfo.getjsonForTranslation("BirthdayWishes", translation.Key)); - string tempSpouseBirthdayFile =Path.Combine("Content", "Dialogue", translation.Key, HappyBirthday.Config.translationInfo.getjsonForTranslation("SpouseBirthdayWishes", translation.Key)); + if (translation.Key == "English") + continue; + + string basePath = Path.Combine(HappyBirthday.ModHelper.DirectoryPath, "Content", "Dialogue", translation.Key); + if (!Directory.Exists(basePath)) + Directory.CreateDirectory(basePath); + string tempBirthdayFile = Path.Combine("Content", "Dialogue", translation.Key, HappyBirthday.Config.translationInfo.getjsonForTranslation("BirthdayWishes", translation.Key)); + string tempSpouseBirthdayFile = Path.Combine("Content", "Dialogue", translation.Key, HappyBirthday.Config.translationInfo.getjsonForTranslation("SpouseBirthdayWishes", translation.Key)); Dictionary tempBirthdayDict = new Dictionary(); if (!File.Exists(Path.Combine(HappyBirthday.ModHelper.DirectoryPath, tempBirthdayFile))) { - - foreach (var pair in defaultBirthdayWishes) - { + foreach (var pair in this.defaultBirthdayWishes) tempBirthdayDict.Add(pair.Key, ""); - } HappyBirthday.ModHelper.Data.WriteJsonFile>(tempBirthdayFile, tempBirthdayDict); } else - { tempBirthdayDict = HappyBirthday.ModHelper.Data.ReadJsonFile>(tempBirthdayFile); - } Dictionary tempSpouseBirthdayDict = new Dictionary(); if (!File.Exists(Path.Combine(HappyBirthday.ModHelper.DirectoryPath, tempSpouseBirthdayFile))) { - - foreach (var pair in defaultSpouseBirthdayWishes) - { + foreach (var pair in this.defaultSpouseBirthdayWishes) tempSpouseBirthdayDict.Add(pair.Key, ""); - } HappyBirthday.ModHelper.Data.WriteJsonFile>(tempSpouseBirthdayFile, tempSpouseBirthdayDict); } else - { tempSpouseBirthdayDict = HappyBirthday.ModHelper.Data.ReadJsonFile>(tempSpouseBirthdayFile); - } //Set translated birthday info. if (HappyBirthday.Config.translationInfo.currentTranslation == translation.Key) @@ -166,10 +142,7 @@ namespace Omegasis.HappyBirthday this.spouseBirthdayWishes = tempSpouseBirthdayDict; HappyBirthday.ModMonitor.Log("Language set to: " + translation); } - } } - - } } diff --git a/GeneralMods/HappyBirthday/Framework/BirthdayMenu.cs b/GeneralMods/HappyBirthday/Framework/BirthdayMenu.cs index 4e9d1c9c..8c6f8e9b 100644 --- a/GeneralMods/HappyBirthday/Framework/BirthdayMenu.cs +++ b/GeneralMods/HappyBirthday/Framework/BirthdayMenu.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -50,9 +50,7 @@ namespace Omegasis.HappyBirthday.Framework this.OnChanged = onChanged; this.SetUpPositions(); } - - - + /// The method called when the game window changes size. /// The former viewport. /// The new viewport. @@ -155,7 +153,7 @@ namespace Omegasis.HappyBirthday.Framework case "OK": if (this.BirthdayDay >= 1 || this.BirthdayDay <= 28) MultiplayerSupport.SendBirthdayInfoToOtherPlayers(); //Send updated info to others. - Game1.exitActiveMenu(); + Game1.exitActiveMenu(); break; default: diff --git a/GeneralMods/HappyBirthday/Framework/Messages.cs b/GeneralMods/HappyBirthday/Framework/Messages.cs index 14d720bd..4cf68e86 100644 --- a/GeneralMods/HappyBirthday/Framework/Messages.cs +++ b/GeneralMods/HappyBirthday/Framework/Messages.cs @@ -1,6 +1,5 @@ - + using StardewValley; -using System.Collections.Generic; namespace Omegasis.HappyBirthday.Framework { @@ -28,8 +27,6 @@ namespace Omegasis.HappyBirthday.Framework Game1.player.mailReceived.Add("BackpackTip"); Game1.addMailForTomorrow("pierreBackpack", false, false); } - - } } diff --git a/GeneralMods/HappyBirthday/Framework/ModConfig.cs b/GeneralMods/HappyBirthday/Framework/ModConfig.cs index fb501b14..87d56ad5 100644 --- a/GeneralMods/HappyBirthday/Framework/ModConfig.cs +++ b/GeneralMods/HappyBirthday/Framework/ModConfig.cs @@ -1,4 +1,4 @@ -namespace Omegasis.HappyBirthday.Framework +namespace Omegasis.HappyBirthday.Framework { /// The mod configuration. public class ModConfig @@ -6,14 +6,10 @@ /// The key which shows the menu. public string KeyBinding { get; set; } = "O"; - /// - /// The minimum amount of friendship needed to get a birthday gift. - /// + /// The minimum amount of friendship needed to get a birthday gift. public int minNeutralFriendshipGiftLevel = 3; - /// - /// The max amount of friendship needed to get a neutral gift from an npc. - /// + /// The max amount of friendship needed to get a neutral gift from an npc. public int maxNeutralFriendshipGiftLevel = 4; /// @@ -21,34 +17,22 @@ /// public int minLikeFriendshipLevel = 5; - /// - /// The max amount of friendship needed to get a liked gift from an npc. - /// + /// The max amount of friendship needed to get a liked gift from an npc. public int maxLikeFriendshipLevel = 6; - /// - /// The minimum amount of friendship needed to get a loved gift from an npc. - /// + /// The minimum amount of friendship needed to get a loved gift from an npc. public int minLoveFriendshipLevel = 7; - /// - /// The minimum amount of friendship needed to get a happy birthday greeting from an npc. - /// - public int minimumFriendshipLevelForBirthdayWish=2; + /// The minimum amount of friendship needed to get a happy birthday greeting from an npc. + public int minimumFriendshipLevelForBirthdayWish = 2; - /// - /// Handles different translations of files. - /// + /// Handles different translations of files. public TranslationInfo translationInfo; - /// - /// Whether or not to load from the old BirthdayGifts.xnb located in StardewValley/Data or from the new BirthdayGifts.json located in the mod directory. - /// + /// Whether or not to load from the old BirthdayGifts.xnb located in StardewValley/Data or from the new BirthdayGifts.json located in the mod directory. public bool useLegacyBirthdayFiles; - /// - /// Constructor. - /// + /// Construct an instance. public ModConfig() { this.translationInfo = new TranslationInfo(); diff --git a/GeneralMods/HappyBirthday/Framework/MultiplayerSupport.cs b/GeneralMods/HappyBirthday/Framework/MultiplayerSupport.cs index 83eb234f..931bcacd 100644 --- a/GeneralMods/HappyBirthday/Framework/MultiplayerSupport.cs +++ b/GeneralMods/HappyBirthday/Framework/MultiplayerSupport.cs @@ -1,27 +1,20 @@ -using StardewValley; -using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using StardewValley; namespace Omegasis.HappyBirthday.Framework { public class MultiplayerSupport { - public static string FSTRING_SendBirthdayMessageToOthers = "Omegasis.HappyBirthday.Framework.Messages.SendBirthdayMessageToOtherPlayers"; public static string FSTRING_SendBirthdayInfoToOthers = "Omegasis.HappyBirthday.Framework.Messages.SendBirthdayInfoToOtherPlayers"; - public static void SendBirthdayMessageToOtherPlayers() { HUDMessage message = new HUDMessage("It's " + Game1.player.Name + "'s birthday! Happy birthday to them!", 1); - - foreach (KeyValuePair f in Game1.otherFarmers) + foreach (KeyValuePair f in Game1.otherFarmers) { - HappyBirthday.ModHelper.Multiplayer.SendMessage(message.message, FSTRING_SendBirthdayMessageToOthers,new string[] { HappyBirthday.ModHelper.Multiplayer.ModID }, new long[] { f.Key }); + HappyBirthday.ModHelper.Multiplayer.SendMessage(message.message, FSTRING_SendBirthdayMessageToOthers, new string[] { HappyBirthday.ModHelper.Multiplayer.ModID }, new long[] { f.Key }); //ModdedUtilitiesNetworking.ModCore.multiplayer.sendMessage(FSTRING_SendBirthdayMessageToOthers, ModdedUtilitiesNetworking.Framework.Extentions.StrardewValleyExtentions.MessagesExtentions.HUDMessageIconIdentifier, message, ModdedUtilitiesNetworking.Framework.Enums.MessageTypes.messageTypes.SendToSpecific, f); } } @@ -30,10 +23,9 @@ namespace Omegasis.HappyBirthday.Framework { foreach (KeyValuePair f in Game1.otherFarmers) { - HappyBirthday.ModHelper.Multiplayer.SendMessage>(new KeyValuePair(Game1.player.uniqueMultiplayerID, HappyBirthday.PlayerBirthdayData), FSTRING_SendBirthdayInfoToOthers, new string[] { HappyBirthday.ModHelper.Multiplayer.ModID }, new long[] { f.Key }); + HappyBirthday.ModHelper.Multiplayer.SendMessage>(new KeyValuePair(Game1.player.uniqueMultiplayerID, HappyBirthday.PlayerBirthdayData), FSTRING_SendBirthdayInfoToOthers, new string[] { HappyBirthday.ModHelper.Multiplayer.ModID }, new long[] { f.Key }); //ModdedUtilitiesNetworking.ModCore.multiplayer.sendMessage(FSTRING_SendBirthdayMessageToOthers, ModdedUtilitiesNetworking.Framework.Extentions.StrardewValleyExtentions.MessagesExtentions.HUDMessageIconIdentifier, message, ModdedUtilitiesNetworking.Framework.Enums.MessageTypes.messageTypes.SendToSpecific, f); } - } public static void SendBirthdayInfoToConnectingPlayer(long id) @@ -42,6 +34,5 @@ namespace Omegasis.HappyBirthday.Framework //ModdedUtilitiesNetworking.ModCore.multiplayer.sendMessage(FSTRING_SendBirthdayMessageToOthers, ModdedUtilitiesNetworking.Framework.Extentions.StrardewValleyExtentions.MessagesExtentions.HUDMessageIconIdentifier, message, ModdedUtilitiesNetworking.Framework.Enums.MessageTypes.messageTypes.SendToSpecific, f); } - } } diff --git a/GeneralMods/HappyBirthday/Framework/ObjectUtility.cs b/GeneralMods/HappyBirthday/Framework/ObjectUtility.cs index 49e9c263..469a0b31 100644 --- a/GeneralMods/HappyBirthday/Framework/ObjectUtility.cs +++ b/GeneralMods/HappyBirthday/Framework/ObjectUtility.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using StardewValley; using Object = StardewValley.Object; diff --git a/GeneralMods/HappyBirthday/Framework/PlayerData.cs b/GeneralMods/HappyBirthday/Framework/PlayerData.cs index f956b797..bfee948f 100644 --- a/GeneralMods/HappyBirthday/Framework/PlayerData.cs +++ b/GeneralMods/HappyBirthday/Framework/PlayerData.cs @@ -1,4 +1,4 @@ -namespace Omegasis.HappyBirthday.Framework +namespace Omegasis.HappyBirthday.Framework { /// The data for the current player. public class PlayerData diff --git a/GeneralMods/HappyBirthday/Framework/TranslationInfo.cs b/GeneralMods/HappyBirthday/Framework/TranslationInfo.cs index abc244eb..d534dd4d 100644 --- a/GeneralMods/HappyBirthday/Framework/TranslationInfo.cs +++ b/GeneralMods/HappyBirthday/Framework/TranslationInfo.cs @@ -1,70 +1,56 @@ -using StardewValley; -using System; using System.Collections.Generic; using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using StardewValley; namespace Omegasis.HappyBirthday.Framework { - /// - /// A class which deals with handling different translations for Vocalization should other voice teams ever wish to voice act for that language. - /// + /// A class which deals with handling different translations for Vocalization should other voice teams ever wish to voice act for that language. public class TranslationInfo { - /// - /// The list of all supported translations by this mod. - /// + /// The list of all supported translations by this mod. public List translations; - /// - /// The current translation mode for the mod, so that it knows what files to load at the beginning of the game. - /// + /// The current translation mode for the mod, so that it knows what files to load at the beginning of the game. public string currentTranslation; - /// - /// Holds the info for what translation has what file extension. - /// + /// Holds the info for what translation has what file extension. public Dictionary translationFileInfo; - public Dictionary translationCodes; - /// - /// Default constructor. - /// + + /// Construct an instance.. public TranslationInfo() { - translations = new List(); + this.translations = new List(); - translationFileInfo = new Dictionary(); - translationCodes = new Dictionary(); - translations.Add("English"); - translations.Add("Spanish"); - translations.Add("Chinese"); - translations.Add("Japanese"); - translations.Add("Russian"); - translations.Add("German"); - translations.Add("Brazillian Portuguese"); + this.translationFileInfo = new Dictionary(); + this.translationCodes = new Dictionary(); + this.translations.Add("English"); + this.translations.Add("Spanish"); + this.translations.Add("Chinese"); + this.translations.Add("Japanese"); + this.translations.Add("Russian"); + this.translations.Add("German"); + this.translations.Add("Brazillian Portuguese"); - currentTranslation = "English"; + this.currentTranslation = "English"; - translationFileInfo.Add("English", ".json"); - translationFileInfo.Add("Spanish", ".es-ES.json"); - translationFileInfo.Add("Chinese", ".zh-CN.json"); - translationFileInfo.Add("Japanese", ".ja-JP.json"); - translationFileInfo.Add("Russian", ".ru-RU.json"); - translationFileInfo.Add("German", ".de-DE.json"); - translationFileInfo.Add("Brazillian Portuguese", ".pt-BR.json"); + this.translationFileInfo.Add("English", ".json"); + this.translationFileInfo.Add("Spanish", ".es-ES.json"); + this.translationFileInfo.Add("Chinese", ".zh-CN.json"); + this.translationFileInfo.Add("Japanese", ".ja-JP.json"); + this.translationFileInfo.Add("Russian", ".ru-RU.json"); + this.translationFileInfo.Add("German", ".de-DE.json"); + this.translationFileInfo.Add("Brazillian Portuguese", ".pt-BR.json"); - translationCodes.Add("English", LocalizedContentManager.LanguageCode.en); - translationCodes.Add("Spanish", LocalizedContentManager.LanguageCode.es); - translationCodes.Add("Chinese", LocalizedContentManager.LanguageCode.zh); - translationCodes.Add("Japanese", LocalizedContentManager.LanguageCode.ja); - translationCodes.Add("Russian", LocalizedContentManager.LanguageCode.ru); - translationCodes.Add("German", LocalizedContentManager.LanguageCode.de); - translationCodes.Add("Brazillian Portuguese", LocalizedContentManager.LanguageCode.pt); + this.translationCodes.Add("English", LocalizedContentManager.LanguageCode.en); + this.translationCodes.Add("Spanish", LocalizedContentManager.LanguageCode.es); + this.translationCodes.Add("Chinese", LocalizedContentManager.LanguageCode.zh); + this.translationCodes.Add("Japanese", LocalizedContentManager.LanguageCode.ja); + this.translationCodes.Add("Russian", LocalizedContentManager.LanguageCode.ru); + this.translationCodes.Add("German", LocalizedContentManager.LanguageCode.de); + this.translationCodes.Add("Brazillian Portuguese", LocalizedContentManager.LanguageCode.pt); } @@ -73,12 +59,11 @@ namespace Omegasis.HappyBirthday.Framework return Path.GetFileName(fullPath); } - public void changeLocalizedContentManagerFromTranslation(string translation) { - string tra = getTranslationNameFromPath(translation); - bool f = translationCodes.TryGetValue(tra, out LocalizedContentManager.LanguageCode code); - if (f == false) LocalizedContentManager.CurrentLanguageCode = LocalizedContentManager.LanguageCode.en; + string tra = this.getTranslationNameFromPath(translation); + bool f = this.translationCodes.TryGetValue(tra, out LocalizedContentManager.LanguageCode code); + if (!f) LocalizedContentManager.CurrentLanguageCode = LocalizedContentManager.LanguageCode.en; else LocalizedContentManager.CurrentLanguageCode = code; return; } @@ -88,24 +73,21 @@ namespace Omegasis.HappyBirthday.Framework LocalizedContentManager.CurrentLanguageCode = LocalizedContentManager.LanguageCode.en; } - /// - /// Gets the proper file extension for the current translation. - /// + /// Gets the proper file extension for the current translation. /// - /// public string getFileExtentionForTranslation(string path) { /* bool f = translationFileInfo.TryGetValue(translation, out string value); - if (f == false) return ".json"; + if (!f) return ".json"; else return value; */ string translation = Path.GetFileName(path); try { - return translationFileInfo[translation]; + return this.translationFileInfo[translation]; } - catch (Exception err) + catch { HappyBirthday.ModMonitor.Log("WTF SOMETHING IS WRONG!", StardewModdingAPI.LogLevel.Warn); //Vocalization.ModMonitor.Log(err.ToString()); @@ -114,45 +96,34 @@ namespace Omegasis.HappyBirthday.Framework } } - /// - /// Gets the proper json for Buildings (aka Blueprints) from the data folder. - /// - /// - /// + /// Gets the proper json for Buildings (aka Blueprints) from the data folder. public string getBuildingjsonForTranslation(string translation) { string buildings = "Blueprints"; - return buildings + getFileExtentionForTranslation(translation); + return buildings + this.getFileExtentionForTranslation(translation); } - /// - /// Gets the proper json file for the name passed in. Combines the file name with it's proper translation extension. - /// + /// Gets the proper json file for the name passed in. Combines the file name with it's proper translation extension. /// /// - /// public string getjsonForTranslation(string jsonFileName, string translation) { - return jsonFileName + getFileExtentionForTranslation(translation); + return jsonFileName + this.getFileExtentionForTranslation(translation); } - /// - /// Loads an json file from StardewValley/Content - /// + /// Loads an json file from StardewValley/Content /// /// /// - /// public string LoadjsonFile(string jsonFileName, string key, string translation) { - string json = jsonFileName + getFileExtentionForTranslation(translation); + string json = jsonFileName + this.getFileExtentionForTranslation(translation); Dictionary loadedDict = Game1.content.Load>(json); - string loaded; - bool f = loadedDict.TryGetValue(key, out loaded); - if (f == false) + bool f = loadedDict.TryGetValue(key, out string loaded); + if (!f) { //Vocalization.ModMonitor.Log("Big issue: Key not found in file:" + json + " " + key); return ""; @@ -160,15 +131,12 @@ namespace Omegasis.HappyBirthday.Framework else return loaded; } - /// - /// Loads a string dictionary from a json file. - /// + /// Loads a string dictionary from a json file. /// /// - /// - public Dictionary LoadJsonFileDictionary(string jsonFileName, string translation) + public Dictionary LoadJsonFileDictionary(string jsonFileName, string translation) { - string json = jsonFileName + getFileExtentionForTranslation(translation); + string json = jsonFileName + this.getFileExtentionForTranslation(translation); Dictionary loadedDict = Game1.content.Load>(json); return loadedDict; @@ -181,9 +149,7 @@ namespace Omegasis.HappyBirthday.Framework { return string.Format(format, sub1, sub2, sub3); } - catch (Exception ex) - { - } + catch { } return format; } @@ -195,9 +161,7 @@ namespace Omegasis.HappyBirthday.Framework { return string.Format(format, sub1, sub2); } - catch (Exception ex) - { - } + catch { } return format; } @@ -209,20 +173,15 @@ namespace Omegasis.HappyBirthday.Framework { return string.Format(format, sub1); } - catch (Exception ex) - { - } + catch { } return format; } public virtual string LoadString(string path, string translation) { - string assetName; - string key; - this.parseStringPath(path, out assetName, out key); - - return LoadjsonFile(assetName, key, translation); + this.parseStringPath(path, out string assetName, out string key); + return this.LoadjsonFile(assetName, key, translation); } public virtual string LoadString(string path, string translation, params object[] substitutions) @@ -234,14 +193,11 @@ namespace Omegasis.HappyBirthday.Framework { return string.Format(format, substitutions); } - catch (Exception ex) - { - } + catch { } } return format; } - private void parseStringPath(string path, out string assetName, out string key) { int length = path.IndexOf(':'); diff --git a/GeneralMods/HappyBirthday/GiftManager.cs b/GeneralMods/HappyBirthday/GiftManager.cs index 18972ab3..b7aa8032 100644 --- a/GeneralMods/HappyBirthday/GiftManager.cs +++ b/GeneralMods/HappyBirthday/GiftManager.cs @@ -1,65 +1,60 @@ -using Omegasis.HappyBirthday.Framework; -using StardewModdingAPI; -using StardewValley; using System; using System.Collections.Generic; using System.IO; using System.Linq; +using Omegasis.HappyBirthday.Framework; +using StardewValley; +using static System.String; using SObject = StardewValley.Object; namespace Omegasis.HappyBirthday { public class GiftManager { - public ModConfig Config + public ModConfig Config => HappyBirthday.Config; + + private Dictionary defaultBirthdayGifts = new Dictionary() { - get - { - return HappyBirthday.Config; - } - } + ["Universal_Love_Gift"] = "74 1 446 1 204 1 446 5 773 1", + ["Universal_Like_Gift"] = "-2 3 -7 1 -26 2 -75 5 -80 3 72 1 220 1 221 1 395 1 613 1 634 1 635 1 636 1 637 1 638 1 724 1 233 1 223 1 465 20 -79 5", + ["Universal_Neutral_Gift"] = "194 1 262 5 -74 5 -75 3 334 5 335 1 390 20 388 20 -81 5 -79 3", + ["Robin"] = " BestGifts/224 1 426 1 636 1/GoodGift/-6 5 -79 5 424 1 709 1/NeutralGift//", + ["Demetrius"] = " Best Gifts/207 1 232 1 233 1 400 1/Good Gifts/-5 3 -79 5 422 1/NeutralGift/-4 3/", + ["Maru"] = " BestGift/72 1 197 1 190 1 215 1 222 1 243 1 336 1 337 1 400 1 787 1/Good Gift/-260 1 62 1 64 1 66 1 68 1 70 1 334 1 335 1 725 1 726 1/NeutralGift/", + ["Sebastian"] = " Best/84 1 227 1 236 1 575 1 305 1 /Good/267 1 276 1/Neutral/-4 3/", + ["Linus"] = " Best/88 1 90 1 234 1 242 1 280 1/Good/-5 3 -6 5 -79 5 -81 10/Neutral/-4 3/", + ["Pierre"] = " Best/202 1/Good/-5 3 -6 5 -7 1 18 1 22 1 402 1 418 1 259 1/Neutral//", + ["Caroline"] = " Best/213 1 593 1/Good/-7 1 18 1 402 1 418 1/Neutral// ", + ["Abigail"] = " Best/66 1 128 1 220 1 226 1 276 1 611 1/Good//Neutral// ", + ["Alex"] = " Best/201 1 212 1 662 1 664 1/Good/-5 3/Neutral// ", + ["George"] = " Best/20 1 205 1/Good/18 1 195 1 199 1 200 1 214 1 219 1 223 1 231 1 233 1/Neutral// ", + ["Evelyn"] = " Best/72 1 220 1 239 1 284 1 591 1 595 1/Good/-6 5 18 1 402 1 418 1/Neutral// ", + ["Lewis"] = " Best/200 1 208 1 235 1 260 1/Good/-80 5 24 1 88 1 90 1 192 1 258 1 264 1 272 1 274 1 278 1/Neutral// ", + ["Clint"] = " Best/60 1 62 1 64 1 66 1 68 1 70 1 336 1 337 1 605 1 649 1 749 1 337 5/Good/334 20 335 10 336 5/Neutral// ", + ["Penny"] = " Best/60 1 376 1 651 1 72 1 164 1 218 1 230 1 244 1 254 1/Good/-6 5 20 1 22 1/Neutral// ", + ["Pam"] = " Best/24 1 90 1 199 1 208 1 303 1 346 1/Good/-6 5 -75 5 -79 5 18 1 227 1 228 1 231 1 232 1 233 1 234 1 235 1 236 1 238 1 402 1 418 1/Neutral/-4 3/ ", + ["Emily"] = " Best/60 1 62 1 64 1 66 1 68 1 70 1 241 1 428 1 440 1 /Good/18 1 82 1 84 1 86 1 196 1 200 1 207 1 230 1 235 1 402 1 418 1/Neutral// ", + ["Haley"] = " Best/221 1 421 1 610 1 88 1 /Good/18 1 60 1 62 1 64 1 70 1 88 1 222 1 223 1 232 1 233 1 234 1 402 1 418 1 /Neutral// ", + ["Jas"] = " Best/221 1 595 1 604 1 /Good/18 1 60 1 64 1 70 1 88 1 232 1 233 1 234 1 222 1 223 1 340 1 344 1 402 1 418 1 /Neutral// ", + ["Vincent"] = " Best/221 1 398 1 612 1 /Good/18 1 60 1 64 1 70 1 88 1 232 1 233 1 234 1 222 1 223 1 340 1 344 1 402 1 418 1 /Neutral// ", + ["Jodi"] = " Best/72 1 200 1 211 1 214 1 220 1 222 1 225 1 231 1 /Good/-5 3 -6 5 -79 5 18 1 402 1 418 1 /Neutral// ", + ["Kent"] = " Best/607 1 649 1 /Good/-5 3 -79 5 18 1 402 1 418 1 /Neutral// ", + ["Sam"] = " Best/90 1 206 1 655 1 658 1 562 1 731 1/Good/167 1 210 1 213 1 220 1 223 1 224 1 228 1 232 1 233 1 239 1 -5 3/Neutral// ", + ["Leah"] = " Best/196 1 200 1 348 1 606 1 651 1 650 1 426 1 430 1 /Good/-5 3 -6 5 -79 5 -81 10 18 1 402 1 406 1 408 1 418 1 86 1 /Neutral// ", + ["Shane"] = " Best/206 1 215 1 260 1 346 1 /Good/-5 3 -79 5 303 1 /Neutral// ", + ["Marnie"] = " Best/72 1 221 1 240 1 608 1 /Good/-5 3 -6 5 402 1 418 1 /Neutral// ", + ["Elliott"] = " Best/715 1 732 1 218 1 444 1 /Good/727 1 728 1 -79 5 60 1 80 1 82 1 84 1 149 1 151 1 346 1 348 1 728 1 /Neutral/-4 3 / ", + ["Gus"] = " Best/72 1 213 1 635 1 729 1 /Good/348 1 303 1 -7 1 18 1 /Neutral// ", + ["Dwarf"] = " Best/60 1 62 1 64 1 66 1 68 1 70 1 749 1 /Good/82 1 84 1 86 1 96 1 97 1 98 1 99 1 121 1 122 1 /Neutral/-28 20 / ", + ["Wizard"] = " Best/107 1 155 1 422 1 769 1 768 1 /Good/-12 3 72 1 82 1 84 1/Neutral// ", + ["Harvey"] = " Best/348 1 237 1 432 1 395 1 342 1 /Good/-81 10 -79 5 -7 1 402 1 418 1 422 1 436 1 438 1 442 1 444 1 422 1 /Neutral// ", + ["Sandy"] = " Best/18 1 402 1 418 1 /Good/-75 5 -79 5 88 1 428 1 436 1 438 1 440 1 /Neutral// ", + ["Willy"] = " Best/72 1 143 1 149 1 154 1 276 1 337 1 698 1 /Good/66 1 336 1 340 1 699 1 707 1 /Neutral/-4 3 / ", + ["Krobus"] = " Best/72 1 16 1 276 1 337 1 305 1 /Good/66 1 336 1 340 1 /Neutral// " + }; - - private Dictionary defaultBirthdayGifts=new Dictionary() { - ["Universal_Love_Gift"] = "74 1 446 1 204 1 446 5 773 1", - ["Universal_Like_Gift"] = "-2 3 -7 1 -26 2 -75 5 -80 3 72 1 220 1 221 1 395 1 613 1 634 1 635 1 636 1 637 1 638 1 724 1 233 1 223 1 465 20 -79 5", - ["Universal_Neutral_Gift"] = "194 1 262 5 -74 5 -75 3 334 5 335 1 390 20 388 20 -81 5 -79 3", - ["Robin"] = " BestGifts/224 1 426 1 636 1/GoodGift/-6 5 -79 5 424 1 709 1/NeutralGift//", - ["Demetrius"] = " Best Gifts/207 1 232 1 233 1 400 1/Good Gifts/-5 3 -79 5 422 1/NeutralGift/-4 3/", - ["Maru"] = " BestGift/72 1 197 1 190 1 215 1 222 1 243 1 336 1 337 1 400 1 787 1/Good Gift/-260 1 62 1 64 1 66 1 68 1 70 1 334 1 335 1 725 1 726 1/NeutralGift/", - ["Sebastian"] = " Best/84 1 227 1 236 1 575 1 305 1 /Good/267 1 276 1/Neutral/-4 3/", - ["Linus"] = " Best/88 1 90 1 234 1 242 1 280 1/Good/-5 3 -6 5 -79 5 -81 10/Neutral/-4 3/", - ["Pierre"] = " Best/202 1/Good/-5 3 -6 5 -7 1 18 1 22 1 402 1 418 1 259 1/Neutral//", - ["Caroline"] = " Best/213 1 593 1/Good/-7 1 18 1 402 1 418 1/Neutral// ", - ["Abigail"] = " Best/66 1 128 1 220 1 226 1 276 1 611 1/Good//Neutral// ", - ["Alex"] = " Best/201 1 212 1 662 1 664 1/Good/-5 3/Neutral// ", - ["George"] = " Best/20 1 205 1/Good/18 1 195 1 199 1 200 1 214 1 219 1 223 1 231 1 233 1/Neutral// ", - ["Evelyn"] = " Best/72 1 220 1 239 1 284 1 591 1 595 1/Good/-6 5 18 1 402 1 418 1/Neutral// ", - ["Lewis"] = " Best/200 1 208 1 235 1 260 1/Good/-80 5 24 1 88 1 90 1 192 1 258 1 264 1 272 1 274 1 278 1/Neutral// ", - ["Clint"] = " Best/60 1 62 1 64 1 66 1 68 1 70 1 336 1 337 1 605 1 649 1 749 1 337 5/Good/334 20 335 10 336 5/Neutral// ", - ["Penny"] = " Best/60 1 376 1 651 1 72 1 164 1 218 1 230 1 244 1 254 1/Good/-6 5 20 1 22 1/Neutral// ", - ["Pam"] = " Best/24 1 90 1 199 1 208 1 303 1 346 1/Good/-6 5 -75 5 -79 5 18 1 227 1 228 1 231 1 232 1 233 1 234 1 235 1 236 1 238 1 402 1 418 1/Neutral/-4 3/ ", - ["Emily"] = " Best/60 1 62 1 64 1 66 1 68 1 70 1 241 1 428 1 440 1 /Good/18 1 82 1 84 1 86 1 196 1 200 1 207 1 230 1 235 1 402 1 418 1/Neutral// ", - ["Haley"] = " Best/221 1 421 1 610 1 88 1 /Good/18 1 60 1 62 1 64 1 70 1 88 1 222 1 223 1 232 1 233 1 234 1 402 1 418 1 /Neutral// ", - ["Jas"] = " Best/221 1 595 1 604 1 /Good/18 1 60 1 64 1 70 1 88 1 232 1 233 1 234 1 222 1 223 1 340 1 344 1 402 1 418 1 /Neutral// ", - ["Vincent"] = " Best/221 1 398 1 612 1 /Good/18 1 60 1 64 1 70 1 88 1 232 1 233 1 234 1 222 1 223 1 340 1 344 1 402 1 418 1 /Neutral// ", - ["Jodi"] = " Best/72 1 200 1 211 1 214 1 220 1 222 1 225 1 231 1 /Good/-5 3 -6 5 -79 5 18 1 402 1 418 1 /Neutral// ", - ["Kent"] = " Best/607 1 649 1 /Good/-5 3 -79 5 18 1 402 1 418 1 /Neutral// ", - ["Sam"] = " Best/90 1 206 1 655 1 658 1 562 1 731 1/Good/167 1 210 1 213 1 220 1 223 1 224 1 228 1 232 1 233 1 239 1 -5 3/Neutral// ", - ["Leah"] = " Best/196 1 200 1 348 1 606 1 651 1 650 1 426 1 430 1 /Good/-5 3 -6 5 -79 5 -81 10 18 1 402 1 406 1 408 1 418 1 86 1 /Neutral// ", - ["Shane"] = " Best/206 1 215 1 260 1 346 1 /Good/-5 3 -79 5 303 1 /Neutral// ", - ["Marnie"] = " Best/72 1 221 1 240 1 608 1 /Good/-5 3 -6 5 402 1 418 1 /Neutral// ", - ["Elliott"] = " Best/715 1 732 1 218 1 444 1 /Good/727 1 728 1 -79 5 60 1 80 1 82 1 84 1 149 1 151 1 346 1 348 1 728 1 /Neutral/-4 3 / ", - ["Gus"] = " Best/72 1 213 1 635 1 729 1 /Good/348 1 303 1 -7 1 18 1 /Neutral// ", - ["Dwarf"] = " Best/60 1 62 1 64 1 66 1 68 1 70 1 749 1 /Good/82 1 84 1 86 1 96 1 97 1 98 1 99 1 121 1 122 1 /Neutral/-28 20 / ", - ["Wizard"] = " Best/107 1 155 1 422 1 769 1 768 1 /Good/-12 3 72 1 82 1 84 1/Neutral// ", - ["Harvey"] = " Best/348 1 237 1 432 1 395 1 342 1 /Good/-81 10 -79 5 -7 1 402 1 418 1 422 1 436 1 438 1 442 1 444 1 422 1 /Neutral// ", - ["Sandy"] = " Best/18 1 402 1 418 1 /Good/-75 5 -79 5 88 1 428 1 436 1 438 1 440 1 /Neutral// ", - ["Willy"] = " Best/72 1 143 1 149 1 154 1 276 1 337 1 698 1 /Good/66 1 336 1 340 1 699 1 707 1 /Neutral/-4 3 / ", - ["Krobus"] = " Best/72 1 16 1 276 1 337 1 305 1 /Good/66 1 336 1 340 1 /Neutral// " - }; - - public Dictionary defaultSpouseBirthdayGifts = new Dictionary() { + public Dictionary defaultSpouseBirthdayGifts = new Dictionary() + { ["Universal_Gifts"] = "74 1 446 1 204 1 446 5 773 1", ["Alex"] = "", @@ -74,8 +69,6 @@ namespace Omegasis.HappyBirthday ["Leah"] = "", ["Maru"] = "", ["Penny"] = "", - - }; public List BirthdayGifts; @@ -83,7 +76,7 @@ namespace Omegasis.HappyBirthday /// The next birthday gift the player will receive. public Item BirthdayGiftToReceive; - + /// Construct an instance. public GiftManager() { this.BirthdayGifts = new List(); @@ -91,30 +84,22 @@ namespace Omegasis.HappyBirthday this.loadSpouseBirthdayGifts(); } - /// - /// Load birthday gift information from disk. Preferably from BirthdayGift.json in the mod's directory. - /// - /// + /// Load birthday gift information from disk. Preferably from BirthdayGift.json in the mod's directory. public void loadVillagerBirthdayGifts() { - if (HappyBirthday.Config.useLegacyBirthdayFiles == false) + if (!HappyBirthday.Config.useLegacyBirthdayFiles) { string villagerGifts = Path.Combine("Content", "Gifts", "BirthdayGifts.json"); if (File.Exists(Path.Combine(HappyBirthday.ModHelper.DirectoryPath, villagerGifts))) - { this.defaultBirthdayGifts = HappyBirthday.ModHelper.Data.ReadJsonFile>(villagerGifts); - } else - { HappyBirthday.ModHelper.Data.WriteJsonFile>(villagerGifts, this.defaultBirthdayGifts); - } - } else { - - if (File.Exists(Path.Combine(Game1.content.RootDirectory, "Data", "PossibleBirthdayGifts.xnb"))){ + if (File.Exists(Path.Combine(Game1.content.RootDirectory, "Data", "PossibleBirthdayGifts.xnb"))) + { HappyBirthday.ModMonitor.Log("Legacy loading detected. Attempting to load from StardewValley/Content/Data/PossibleBirthdayGifts.xnb"); this.defaultBirthdayGifts = Game1.content.Load>(Path.Combine("Data", "PossibleBirthdayGifts")); @@ -122,16 +107,11 @@ namespace Omegasis.HappyBirthday HappyBirthday.ModHelper.Data.WriteJsonFile>(villagerGifts, this.defaultBirthdayGifts); } else - { HappyBirthday.ModMonitor.Log("No birthday gift information found. Loading from internal birthday list"); - } } } - /// - /// Used to load spouse birthday gifts from disk. - /// - /// + /// Used to load spouse birthday gifts from disk. public void loadSpouseBirthdayGifts() { string spouseGifts = Path.Combine("Content", "Gifts", "SpouseBirthdayGifts.json"); @@ -147,7 +127,6 @@ namespace Omegasis.HappyBirthday } } - /// Get the default gift items. /// The villager's name. private IEnumerable GetDefaultBirthdayGifts(string name) @@ -156,14 +135,14 @@ namespace Omegasis.HappyBirthday try { // read from birthday gifts file - IDictionary data = defaultBirthdayGifts; + IDictionary data = this.defaultBirthdayGifts; data.TryGetValue(name, out string text); if (text != null) { string[] fields = text.Split('/'); // love - if (Game1.player.getFriendshipHeartLevelForNPC(name) >= Config.minLoveFriendshipLevel) + if (Game1.player.getFriendshipHeartLevelForNPC(name) >= this.Config.minLoveFriendshipLevel) { string[] loveFields = fields[1].Split(' '); for (int i = 0; i < loveFields.Length; i += 2) @@ -177,7 +156,7 @@ namespace Omegasis.HappyBirthday } // like - if (Game1.player.getFriendshipHeartLevelForNPC(name) >= Config.minLikeFriendshipLevel && Game1.player.getFriendshipHeartLevelForNPC(name) <= Config.maxLikeFriendshipLevel) + if (Game1.player.getFriendshipHeartLevelForNPC(name) >= this.Config.minLikeFriendshipLevel && Game1.player.getFriendshipHeartLevelForNPC(name) <= this.Config.maxLikeFriendshipLevel) { string[] likeFields = fields[3].Split(' '); for (int i = 0; i < likeFields.Length; i += 2) @@ -191,7 +170,7 @@ namespace Omegasis.HappyBirthday } // neutral - if (Game1.player.getFriendshipHeartLevelForNPC(name) >= Config.minNeutralFriendshipGiftLevel && Game1.player.getFriendshipHeartLevelForNPC(name) <= Config.maxNeutralFriendshipGiftLevel) + if (Game1.player.getFriendshipHeartLevelForNPC(name) >= this.Config.minNeutralFriendshipGiftLevel && Game1.player.getFriendshipHeartLevelForNPC(name) <= this.Config.maxNeutralFriendshipGiftLevel) { string[] neutralFields = fields[5].Split(' '); @@ -207,54 +186,48 @@ namespace Omegasis.HappyBirthday } // get NPC's preferred gifts - if (Game1.player.getFriendshipHeartLevelForNPC(name) >= Config.minLoveFriendshipLevel) + if (Game1.player.getFriendshipHeartLevelForNPC(name) >= this.Config.minLoveFriendshipLevel) gifts.AddRange(this.GetUniversalItems("Love", true)); - if (Game1.player.getFriendshipHeartLevelForNPC(name) >= Config.minLikeFriendshipLevel && Game1.player.getFriendshipHeartLevelForNPC(name) <= Config.maxLikeFriendshipLevel) + if (Game1.player.getFriendshipHeartLevelForNPC(name) >= this.Config.minLikeFriendshipLevel && Game1.player.getFriendshipHeartLevelForNPC(name) <= this.Config.maxLikeFriendshipLevel) this.BirthdayGifts.AddRange(this.GetUniversalItems("Like", true)); - if (Game1.player.getFriendshipHeartLevelForNPC(name) >= Config.minNeutralFriendshipGiftLevel && Game1.player.getFriendshipHeartLevelForNPC(name) <= Config.maxNeutralFriendshipGiftLevel) + if (Game1.player.getFriendshipHeartLevelForNPC(name) >= this.Config.minNeutralFriendshipGiftLevel && Game1.player.getFriendshipHeartLevelForNPC(name) <= this.Config.maxNeutralFriendshipGiftLevel) this.BirthdayGifts.AddRange(this.GetUniversalItems("Neutral", true)); } catch { // get NPC's preferred gifts - if (Game1.player.getFriendshipHeartLevelForNPC(name) >= Config.minLoveFriendshipLevel) + if (Game1.player.getFriendshipHeartLevelForNPC(name) >= this.Config.minLoveFriendshipLevel) { this.BirthdayGifts.AddRange(this.GetUniversalItems("Love", false)); this.BirthdayGifts.AddRange(this.GetLovedItems(name)); } - if (Game1.player.getFriendshipHeartLevelForNPC(name) >= Config.minLikeFriendshipLevel && Game1.player.getFriendshipHeartLevelForNPC(name) <= Config.maxLikeFriendshipLevel) + if (Game1.player.getFriendshipHeartLevelForNPC(name) >= this.Config.minLikeFriendshipLevel && Game1.player.getFriendshipHeartLevelForNPC(name) <= this.Config.maxLikeFriendshipLevel) { this.BirthdayGifts.AddRange(this.GetLikedItems(name)); this.BirthdayGifts.AddRange(this.GetUniversalItems("Like", false)); } - if (Game1.player.getFriendshipHeartLevelForNPC(name) >= Config.minNeutralFriendshipGiftLevel && Game1.player.getFriendshipHeartLevelForNPC(name) <= Config.maxNeutralFriendshipGiftLevel) + if (Game1.player.getFriendshipHeartLevelForNPC(name) >= this.Config.minNeutralFriendshipGiftLevel && Game1.player.getFriendshipHeartLevelForNPC(name) <= this.Config.maxNeutralFriendshipGiftLevel) this.BirthdayGifts.AddRange(this.GetUniversalItems("Neutral", false)); } - + //Add in spouse specific birthday gifts. if (Game1.player.isMarried()) { if (name == Game1.player.spouse) { - this.BirthdayGifts.AddRange(getSpouseBirthdayGifts(name)); - this.BirthdayGifts.AddRange(getSpouseBirthdayGifts("Universal_Gifts")); + this.BirthdayGifts.AddRange(this.getSpouseBirthdayGifts(name)); + this.BirthdayGifts.AddRange(this.getSpouseBirthdayGifts("Universal_Gifts")); } } return gifts; } - /// - /// Get - /// - /// - /// - /// private IEnumerable getSpouseBirthdayGifts(string npcName) { Dictionary data = this.defaultSpouseBirthdayGifts; data.TryGetValue(npcName, out string text); - if (String.IsNullOrEmpty(text)) + if (IsNullOrEmpty(text)) yield break; // parse @@ -266,7 +239,6 @@ namespace Omegasis.HappyBirthday } } - /// Get the items loved by all villagers. /// The group to get (one of Like, Love, Neutral). /// Whether to get data from Data\BirthdayGifts.xnb instead of the game data. @@ -352,8 +324,6 @@ namespace Omegasis.HappyBirthday : new[] { new SObject(id, 1) }; } - - /// Get the items matching the given ID. /// The category or item ID. /// The stack size. diff --git a/GeneralMods/HappyBirthday/HappyBirthday.cs b/GeneralMods/HappyBirthday/HappyBirthday.cs index 86742385..628acc30 100644 --- a/GeneralMods/HappyBirthday/HappyBirthday.cs +++ b/GeneralMods/HappyBirthday/HappyBirthday.cs @@ -1,10 +1,9 @@ -using System; +using System; using System.Collections.Generic; using System.IO; using System.Linq; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using Newtonsoft.Json; using Omegasis.HappyBirthday.Framework; using StardewModdingAPI; using StardewModdingAPI.Events; @@ -12,7 +11,6 @@ using StardewValley; using StardewValley.Characters; using StardewValley.Menus; using StardewValley.Monsters; -using SObject = StardewValley.Object; namespace Omegasis.HappyBirthday { @@ -34,19 +32,11 @@ namespace Omegasis.HappyBirthday /// The data for the current player. public static PlayerData PlayerBirthdayData; - /// - /// Wrapper for static field PlayerBirthdayData; - /// + /// Wrapper for static field PlayerBirthdayData; public PlayerData PlayerData { - get - { - return PlayerBirthdayData; - } - set - { - PlayerBirthdayData = value; - } + get => PlayerBirthdayData; + set => PlayerBirthdayData = value; } /// Whether the player has chosen a birthday. @@ -55,49 +45,26 @@ namespace Omegasis.HappyBirthday /// The queue of villagers who haven't given a gift yet. private List VillagerQueue; - /// Whether we've already checked for and (if applicable) set up the player's birthday today. private bool CheckedForBirthday; //private Dictionary Dialogue; //private bool SeenEvent; - public bool CanEdit(IAssetInfo asset) - { - return asset.AssetNameEquals(@"Data\mail"); - } - - public void Edit(IAssetData asset) - { - asset - .AsDictionary() - .Set("birthdayMom", "Dear @,^ Happy birthday sweetheart. It's been amazing watching you grow into the kind, hard working person that I've always dreamed that you would become. I hope you continue to make many more fond memories with the ones you love. ^ Love, Mom ^ P.S. Here's a little something that I made for you. %item object 221 1 %%"); - - asset - .AsDictionary() - .Set("birthdayDad", "Dear @,^ Happy birthday kiddo. It's been a little quiet around here on your birthday since you aren't around, but your mother and I know that you are making both your grandpa and us proud. We both know that living on your own can be tough but we believe in you one hundred percent, just keep following your dreams.^ Love, Dad ^ P.S. Here's some spending money to help you out on the farm. Good luck! %item money 5000 5001 %%"); - } - public static IModHelper ModHelper; public static IMonitor ModMonitor; - /// - /// Class to handle all birthday messages for this mod. - /// + /// Class to handle all birthday messages for this mod. public BirthdayMessages messages; - /// - /// Class to handle all birthday gifts for this mod. - /// + /// Class to handle all birthday gifts for this mod. public GiftManager giftManager; - /// - /// Checks if the current billboard is the daily quest screen or not. - /// + /// Checks if the current billboard is the daily quest screen or not. bool isDailyQuestBoard; + Dictionary othersBirthdays; - Dictionary othersBirthdays; /********* ** Public methods @@ -114,35 +81,54 @@ namespace Omegasis.HappyBirthday SaveEvents.AfterLoad += this.SaveEvents_AfterLoad; SaveEvents.BeforeSave += this.SaveEvents_BeforeSave; ControlEvents.KeyPressed += this.ControlEvents_KeyPressed; - MenuEvents.MenuChanged += MenuEvents_MenuChanged; - MenuEvents.MenuClosed += MenuEvents_MenuClosed; + MenuEvents.MenuChanged += this.MenuEvents_MenuChanged; + MenuEvents.MenuClosed += this.MenuEvents_MenuClosed; - - - GraphicsEvents.OnPostRenderGuiEvent += GraphicsEvents_OnPostRenderGuiEvent; - StardewModdingAPI.Events.GraphicsEvents.OnPostRenderHudEvent += GraphicsEvents_OnPostRenderHudEvent; + GraphicsEvents.OnPostRenderGuiEvent += this.GraphicsEvents_OnPostRenderGuiEvent; + StardewModdingAPI.Events.GraphicsEvents.OnPostRenderHudEvent += this.GraphicsEvents_OnPostRenderHudEvent; //MultiplayerSupport.initializeMultiplayerSupport(); - ModHelper = Helper; - ModMonitor = Monitor; + ModHelper = this.Helper; + ModMonitor = this.Monitor; - messages = new BirthdayMessages(); - giftManager = new GiftManager(); - messages.createBirthdayGreetings(); - isDailyQuestBoard = false; + this.messages = new BirthdayMessages(); + this.giftManager = new GiftManager(); + this.messages.createBirthdayGreetings(); + this.isDailyQuestBoard = false; - ModHelper.Events.Multiplayer.ModMessageReceived += Multiplayer_ModMessageReceived; + ModHelper.Events.Multiplayer.ModMessageReceived += this.Multiplayer_ModMessageReceived; - ModHelper.Events.Multiplayer.PeerDisconnected += Multiplayer_PeerDisconnected; + ModHelper.Events.Multiplayer.PeerDisconnected += this.Multiplayer_PeerDisconnected; this.othersBirthdays = new Dictionary(); - } - /// - /// Used to check for player disconnections. - /// - /// - /// + /// Get whether this instance can edit the given asset. + /// Basic metadata about the asset being loaded. + public bool CanEdit(IAssetInfo asset) + { + return asset.AssetNameEquals(@"Data\mail"); + } + + /// Edit a matched asset. + /// A helper which encapsulates metadata about an asset and enables changes to it. + public void Edit(IAssetData asset) + { + asset + .AsDictionary() + .Set("birthdayMom", "Dear @,^ Happy birthday sweetheart. It's been amazing watching you grow into the kind, hard working person that I've always dreamed that you would become. I hope you continue to make many more fond memories with the ones you love. ^ Love, Mom ^ P.S. Here's a little something that I made for you. %item object 221 1 %%"); + + asset + .AsDictionary() + .Set("birthdayDad", "Dear @,^ Happy birthday kiddo. It's been a little quiet around here on your birthday since you aren't around, but your mother and I know that you are making both your grandpa and us proud. We both know that living on your own can be tough but we believe in you one hundred percent, just keep following your dreams.^ Love, Dad ^ P.S. Here's some spending money to help you out on the farm. Good luck! %item money 5000 5001 %%"); + } + + + /********* + ** Private methods + *********/ + /// Used to check for player disconnections. + /// The event sender. + /// The event arguments. private void Multiplayer_PeerDisconnected(object sender, PeerDisconnectedEventArgs e) { this.othersBirthdays.Remove(e.Peer.PlayerID); @@ -150,60 +136,50 @@ namespace Omegasis.HappyBirthday private void Multiplayer_ModMessageReceived(object sender, ModMessageReceivedEventArgs e) { - if (e.FromModID == ModHelper.Multiplayer.ModID && e.Type==MultiplayerSupport.FSTRING_SendBirthdayMessageToOthers) + if (e.FromModID == ModHelper.Multiplayer.ModID && e.Type == MultiplayerSupport.FSTRING_SendBirthdayMessageToOthers) { string message = e.ReadAs(); - Game1.hudMessages.Add(new HUDMessage(message,1)); + Game1.hudMessages.Add(new HUDMessage(message, 1)); } if (e.FromModID == ModHelper.Multiplayer.ModID && e.Type == MultiplayerSupport.FSTRING_SendBirthdayInfoToOthers) { - KeyValuePair message = e.ReadAs>(); + KeyValuePair message = e.ReadAs>(); if (!this.othersBirthdays.ContainsKey(message.Key)) { - this.othersBirthdays.Add(message.Key,message.Value); + this.othersBirthdays.Add(message.Key, message.Value); MultiplayerSupport.SendBirthdayInfoToConnectingPlayer(e.FromPlayerID); - Monitor.Log("Got other player's birthday data from: "+ Game1.getFarmer(e.FromPlayerID).name); + this.Monitor.Log("Got other player's birthday data from: " + Game1.getFarmer(e.FromPlayerID).name); } else { //Brute force update birthday info if it has already been recevived but dont send birthday info again. this.othersBirthdays.Remove(message.Key); this.othersBirthdays.Add(message.Key, message.Value); - Monitor.Log("Got other player's birthday data from: " + Game1.getFarmer(e.FromPlayerID).name); + this.Monitor.Log("Got other player's birthday data from: " + Game1.getFarmer(e.FromPlayerID).name); } - - - } - } - /// - /// Used to check when a menu is closed. - /// - /// - /// + /// Used to check when a menu is closed. + /// The event sender. + /// The event arguments. private void MenuEvents_MenuClosed(object sender, EventArgsClickableMenuClosed e) { this.isDailyQuestBoard = false; } - - /// - /// Used to properly display hovertext for all events happening on a calendar day. - /// - /// - /// + /// Used to properly display hovertext for all events happening on a calendar day. + /// The event sender. + /// The event arguments. private void GraphicsEvents_OnPostRenderHudEvent(object sender, EventArgs e) { if (Game1.activeClickableMenu == null) return; - if (PlayerData == null) return; - if (PlayerData.BirthdaySeason == null) return; - if (PlayerData.BirthdaySeason.ToLower() != Game1.currentSeason.ToLower()) return; + if (this.PlayerData?.BirthdaySeason == null) return; + if (this.PlayerData.BirthdaySeason.ToLower() != Game1.currentSeason.ToLower()) return; if (Game1.activeClickableMenu is Billboard) { - if (isDailyQuestBoard) return; + if (this.isDailyQuestBoard) return; if ((Game1.activeClickableMenu as Billboard).calendarDays == null) return; //Game1.player.FarmerRenderer.drawMiniPortrat(Game1.spriteBatch, new Vector2(Game1.activeClickableMenu.xPositionOnScreen + 152 + (index - 1) % 7 * 32 * 4, Game1.activeClickableMenu.yPositionOnScreen + 230 + (index - 1) / 7 * 32 * 4), 1f, 4f, 2, Game1.player); @@ -211,115 +187,96 @@ namespace Omegasis.HappyBirthday string hoverText = ""; List texts = new List(); - foreach (var clicky in (Game1.activeClickableMenu as Billboard).calendarDays) + foreach (var clicky in ((Billboard)Game1.activeClickableMenu).calendarDays) { if (clicky.containsPoint(Game1.getMouseX(), Game1.getMouseY())) { - if (!String.IsNullOrEmpty(clicky.hoverText)) - { + if (!string.IsNullOrEmpty(clicky.hoverText)) texts.Add(clicky.hoverText); //catches npc birhday names. - } - else if (!String.IsNullOrEmpty(clicky.name)) - { + else if (!string.IsNullOrEmpty(clicky.name)) texts.Add(clicky.name); //catches festival dates. - } } } - - for(int i = 0; i< texts.Count; i++) - { + for (int i = 0; i < texts.Count; i++) + { hoverText += texts[i]; //Append text. - if (i == texts.Count - 1) continue; - else - { + if (i != texts.Count - 1) hoverText += Environment.NewLine; //Append new line. - } } - if (!String.IsNullOrEmpty(hoverText)) + if (!string.IsNullOrEmpty(hoverText)) { - var oldText = Helper.Reflection.GetField(Game1.activeClickableMenu, "hoverText", true); + var oldText = this.Helper.Reflection.GetField(Game1.activeClickableMenu, "hoverText"); oldText.SetValue(hoverText); } - } } - /// - /// Used to show the farmer's portrait on the billboard menu. - /// - /// - /// + /// Used to show the farmer's portrait on the billboard menu. + /// The event sender. + /// The event arguments. private void GraphicsEvents_OnPostRenderGuiEvent(object sender, EventArgs e) { - if (Game1.activeClickableMenu == null) return; - //Don't do anything if birthday has not been chosen yet. - if (PlayerData == null) return; - + if (Game1.activeClickableMenu == null || this.isDailyQuestBoard) + return; + //Don't do anything if birthday has not been chosen yet. + if (this.PlayerData == null) + return; if (Game1.activeClickableMenu is Billboard) { - if (isDailyQuestBoard) return; - - if (!String.IsNullOrEmpty(PlayerData.BirthdaySeason)) + if (!string.IsNullOrEmpty(this.PlayerData.BirthdaySeason)) { - if (PlayerData.BirthdaySeason.ToLower() == Game1.currentSeason.ToLower()) + if (this.PlayerData.BirthdaySeason.ToLower() == Game1.currentSeason.ToLower()) { - int index = PlayerData.BirthdayDay; + int index = this.PlayerData.BirthdayDay; Game1.player.FarmerRenderer.drawMiniPortrat(Game1.spriteBatch, new Vector2(Game1.activeClickableMenu.xPositionOnScreen + 152 + (index - 1) % 7 * 32 * 4, Game1.activeClickableMenu.yPositionOnScreen + 230 + (index - 1) / 7 * 32 * 4), 0.5f, 4f, 2, Game1.player); } } - foreach(var pair in this.othersBirthdays) + foreach (var pair in this.othersBirthdays) { int index = pair.Value.BirthdayDay; if (pair.Value.BirthdaySeason != Game1.currentSeason.ToLower()) continue; //Hide out of season birthdays. index = pair.Value.BirthdayDay; Game1.player.FarmerRenderer.drawMiniPortrat(Game1.spriteBatch, new Vector2(Game1.activeClickableMenu.xPositionOnScreen + 152 + (index - 1) % 7 * 32 * 4, Game1.activeClickableMenu.yPositionOnScreen + 230 + (index - 1) / 7 * 32 * 4), 0.5f, 4f, 2, Game1.getFarmer(pair.Key)); } - } } - /// - /// Functionality to display the player's birthday on the billboard. - /// - /// - /// - public void MenuEvents_MenuChanged(object sender, EventArgsClickableMenuChanged e) + /// Functionality to display the player's birthday on the billboard. + /// The event sender. + /// The event arguments. + private void MenuEvents_MenuChanged(object sender, EventArgsClickableMenuChanged e) { if (Game1.activeClickableMenu == null) { - isDailyQuestBoard = false; + this.isDailyQuestBoard = false; return; } - if(Game1.activeClickableMenu is Billboard) + if (Game1.activeClickableMenu is Billboard) { - isDailyQuestBoard = ModHelper.Reflection.GetField((Game1.activeClickableMenu as Billboard), "dailyQuestBoard", true).GetValue(); - if (isDailyQuestBoard) return; + this.isDailyQuestBoard = ModHelper.Reflection.GetField((Game1.activeClickableMenu as Billboard), "dailyQuestBoard", true).GetValue(); + if (this.isDailyQuestBoard) return; - - - Texture2D text = new Texture2D(Game1.graphics.GraphicsDevice,1,1); + Texture2D text = new Texture2D(Game1.graphics.GraphicsDevice, 1, 1); Color[] col = new Color[1]; col[0] = new Color(0, 0, 0, 1); text.SetData(col); - //players birthdy position rect=new .... + //players birthday position rect=new .... - if (!String.IsNullOrEmpty(PlayerData.BirthdaySeason)) + if (!string.IsNullOrEmpty(this.PlayerData.BirthdaySeason)) { - if (PlayerData.BirthdaySeason.ToLower() == Game1.currentSeason.ToLower()) + if (this.PlayerData.BirthdaySeason.ToLower() == Game1.currentSeason.ToLower()) { - int index = PlayerData.BirthdayDay; + int index = this.PlayerData.BirthdayDay; Rectangle birthdayRect = new Rectangle(Game1.activeClickableMenu.xPositionOnScreen + 152 + (index - 1) % 7 * 32 * 4, Game1.activeClickableMenu.yPositionOnScreen + 200 + (index - 1) / 7 * 32 * 4, 124, 124); (Game1.activeClickableMenu as Billboard).calendarDays.Add(new ClickableTextureComponent("", birthdayRect, "", Game1.player.name + "'s Birthday", text, new Rectangle(0, 0, 124, 124), 1f, false)); - } } - foreach (var pair in this.othersBirthdays) { if (pair.Value.BirthdaySeason != Game1.currentSeason.ToLower()) continue; @@ -327,14 +284,9 @@ namespace Omegasis.HappyBirthday Rectangle otherBirthdayRect = new Rectangle(Game1.activeClickableMenu.xPositionOnScreen + 152 + (index - 1) % 7 * 32 * 4, Game1.activeClickableMenu.yPositionOnScreen + 200 + (index - 1) / 7 * 32 * 4, 124, 124); (Game1.activeClickableMenu as Billboard).calendarDays.Add(new ClickableTextureComponent("", otherBirthdayRect, "", Game1.getFarmer(pair.Key).name + "'s Birthday", text, new Rectangle(0, 0, 124, 124), 1f, false)); } - } } - - /********* - ** Private methods - *********/ /// The method invoked after a new day starts. /// The event sender. /// The event data. @@ -359,7 +311,7 @@ namespace Omegasis.HappyBirthday /// The event data. private void SaveEvents_AfterLoad(object sender, EventArgs e) { - this.DataFilePath = Path.Combine("data", Game1.player.Name + "_" + Game1.player.UniqueMultiplayerID+".json"); + this.DataFilePath = Path.Combine("data", Game1.player.Name + "_" + Game1.player.UniqueMultiplayerID + ".json"); // reset state this.VillagerQueue = new List(); @@ -396,13 +348,13 @@ namespace Omegasis.HappyBirthday { if (!Context.IsWorldReady || Game1.eventUp || Game1.isFestival()) return; - if (!this.HasChosenBirthday && Game1.activeClickableMenu == null && Game1.player.Name.ToLower()!="unnamed farmhand") + if (!this.HasChosenBirthday && Game1.activeClickableMenu == null && Game1.player.Name.ToLower() != "unnamed farmhand") { Game1.activeClickableMenu = new BirthdayMenu(this.PlayerData.BirthdaySeason, this.PlayerData.BirthdayDay, this.SetBirthday); this.CheckedForBirthday = false; } - if (!this.CheckedForBirthday && Game1.activeClickableMenu==null) + if (!this.CheckedForBirthday && Game1.activeClickableMenu == null) { this.CheckedForBirthday = true; @@ -440,28 +392,26 @@ namespace Omegasis.HappyBirthday { bool spouseMessage = false; //Used to determine if there is a valid spouse message for the player. If false load in the generic birthday wish. //Check if npc name is spouse's name. If no spouse then add in generic dialogue. - if (messages.spouseBirthdayWishes.ContainsKey(npc.Name) && Game1.player.isMarried()) + if (this.messages.spouseBirthdayWishes.ContainsKey(npc.Name) && Game1.player.isMarried()) { - Monitor.Log("Spouse Checks out"); + this.Monitor.Log("Spouse Checks out"); //Check to see if spouse message exists. - if (!String.IsNullOrEmpty(messages.spouseBirthdayWishes[npc.Name])) + if (!string.IsNullOrEmpty(this.messages.spouseBirthdayWishes[npc.Name])) { spouseMessage = true; - Dialogue d = new Dialogue(messages.spouseBirthdayWishes[npc.Name], npc); + Dialogue d = new Dialogue(this.messages.spouseBirthdayWishes[npc.Name], npc); npc.CurrentDialogue.Push(d); - if (npc.CurrentDialogue.ElementAt(0) != d) npc.setNewDialogue(messages.spouseBirthdayWishes[npc.Name]); + if (npc.CurrentDialogue.ElementAt(0) != d) npc.setNewDialogue(this.messages.spouseBirthdayWishes[npc.Name]); } else - { - Monitor.Log("No spouse message???", LogLevel.Warn); - } + this.Monitor.Log("No spouse message???", LogLevel.Warn); } - if (spouseMessage == false) + if (!spouseMessage) { //Load in - Dialogue d = new Dialogue(messages.birthdayWishes[npc.Name], npc); + Dialogue d = new Dialogue(this.messages.birthdayWishes[npc.Name], npc); npc.CurrentDialogue.Push(d); - if (npc.CurrentDialogue.ElementAt(0) != d) npc.setNewDialogue(messages.birthdayWishes[npc.Name]); + if (npc.CurrentDialogue.ElementAt(0) != d) npc.setNewDialogue(this.messages.birthdayWishes[npc.Name]); } } } @@ -480,12 +430,11 @@ namespace Omegasis.HappyBirthday } //Don't constantly set the birthday menu. - if (Game1.activeClickableMenu != null) - { - if (Game1.activeClickableMenu.GetType() == typeof(BirthdayMenu)) return; - } + if (Game1.activeClickableMenu?.GetType() == typeof(BirthdayMenu)) + return; + // ask for birthday date - if (!this.HasChosenBirthday && Game1.activeClickableMenu==null) + if (!this.HasChosenBirthday && Game1.activeClickableMenu == null) { Game1.activeClickableMenu = new BirthdayMenu(this.PlayerData.BirthdaySeason, this.PlayerData.BirthdayDay, this.SetBirthday); this.CheckedForBirthday = false; @@ -501,7 +450,7 @@ namespace Omegasis.HappyBirthday { try { - giftManager.SetNextBirthdayGift(Game1.currentSpeaker.Name); + this.giftManager.SetNextBirthdayGift(Game1.currentSpeaker.Name); this.VillagerQueue.Remove(Game1.currentSpeaker.Name); } catch (Exception ex) @@ -511,15 +460,14 @@ namespace Omegasis.HappyBirthday } //Validate the gift and give it to the player. - if (giftManager.BirthdayGiftToReceive != null) + if (this.giftManager.BirthdayGiftToReceive != null) { - while (giftManager.BirthdayGiftToReceive.Name == "Error Item" || giftManager.BirthdayGiftToReceive.Name == "Rock" || giftManager.BirthdayGiftToReceive.Name == "???") - giftManager.SetNextBirthdayGift(Game1.currentSpeaker.Name); - Game1.player.addItemByMenuIfNecessaryElseHoldUp(giftManager.BirthdayGiftToReceive); - giftManager.BirthdayGiftToReceive = null; + while (this.giftManager.BirthdayGiftToReceive.Name == "Error Item" || this.giftManager.BirthdayGiftToReceive.Name == "Rock" || this.giftManager.BirthdayGiftToReceive.Name == "???") + this.giftManager.SetNextBirthdayGift(Game1.currentSpeaker.Name); + Game1.player.addItemByMenuIfNecessaryElseHoldUp(this.giftManager.BirthdayGiftToReceive); + this.giftManager.BirthdayGiftToReceive = null; } } - } /// Set the player's birthday/ @@ -564,12 +512,13 @@ namespace Omegasis.HappyBirthday try { if (!File.Exists(this.LegacyDataFilePath) || File.Exists(this.DataFilePath)) - if (this.PlayerData == null) this.PlayerData = new PlayerData(); - return; + { + if (this.PlayerData == null) + this.PlayerData = new PlayerData(); + } } - catch(Exception err) + catch { - err.ToString(); // migrate to new file try { @@ -590,10 +539,6 @@ namespace Omegasis.HappyBirthday this.Monitor.Log($"Error migrating data from the legacy 'Player_Birthdays' folder for the current player. Technical details:\n {ex}", LogLevel.Error); } } - } - - - } } diff --git a/GeneralMods/HappyBirthday/manifest.json b/GeneralMods/HappyBirthday/manifest.json index 54b399eb..eceefd57 100644 --- a/GeneralMods/HappyBirthday/manifest.json +++ b/GeneralMods/HappyBirthday/manifest.json @@ -2,7 +2,6 @@ "Name": "Happy Birthday", "Author": "Alpha_Omegasis", "Version": "1.8.2", - "MinimumApiVersion": "1.15", "Description": "Adds the farmer's birthday to the game.", "UniqueID": "Omegasis.HappyBirthday", "EntryDll": "HappyBirthday.dll", diff --git a/GeneralMods/MapEvents/EventSystem.cs b/GeneralMods/MapEvents/EventSystem.cs index a173367e..8b11646c 100644 --- a/GeneralMods/MapEvents/EventSystem.cs +++ b/GeneralMods/MapEvents/EventSystem.cs @@ -1,31 +1,25 @@ -using EventSystem.Framework; -using StardewModdingAPI; using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using EventSystem.Framework; +using StardewModdingAPI; namespace EventSystem -{ - /* - *TODO: Make Bed/Sleep Event. - * - * - */ - public class EventSystem: Mod +{ + // TODO: Make Bed/Sleep Event. + public class EventSystem : Mod { public static IModHelper ModHelper; public static IMonitor ModMonitor; public static EventManager eventManager; + + /// The mod entry point, called after the mod is first loaded. + /// Provides simplified APIs for writing mods. public override void Entry(IModHelper helper) { - ModHelper = this.Helper; ModMonitor = this.Monitor; - StardewModdingAPI.Events.GameEvents.UpdateTick += GameEvents_UpdateTick; - StardewModdingAPI.Events.SaveEvents.AfterLoad += SaveEvents_AfterLoad; + StardewModdingAPI.Events.GameEvents.UpdateTick += this.GameEvents_UpdateTick; + StardewModdingAPI.Events.SaveEvents.AfterLoad += this.SaveEvents_AfterLoad; } private void SaveEvents_AfterLoad(object sender, EventArgs e) @@ -35,8 +29,7 @@ namespace EventSystem private void GameEvents_UpdateTick(object sender, EventArgs e) { - if (eventManager == null) return; - eventManager.update(); + eventManager?.update(); } } } diff --git a/GeneralMods/MapEvents/EventSystem.csproj b/GeneralMods/MapEvents/EventSystem.csproj index dbf9baee..227d5cbf 100644 --- a/GeneralMods/MapEvents/EventSystem.csproj +++ b/GeneralMods/MapEvents/EventSystem.csproj @@ -92,5 +92,8 @@ + + + \ No newline at end of file diff --git a/GeneralMods/MapEvents/Framework/Delegates.cs b/GeneralMods/MapEvents/Framework/Delegates.cs index 617d0080..1447e614 100644 --- a/GeneralMods/MapEvents/Framework/Delegates.cs +++ b/GeneralMods/MapEvents/Framework/Delegates.cs @@ -1,8 +1,4 @@ -using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace EventSystem.Framework { diff --git a/GeneralMods/MapEvents/Framework/EventManager.cs b/GeneralMods/MapEvents/Framework/EventManager.cs index e4ddeb32..6be0aedb 100644 --- a/GeneralMods/MapEvents/Framework/EventManager.cs +++ b/GeneralMods/MapEvents/Framework/EventManager.cs @@ -1,9 +1,5 @@ -using StardewValley; -using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using StardewValley; namespace EventSystem.Framework { @@ -11,111 +7,80 @@ namespace EventSystem.Framework { public Dictionary> mapEvents; - /// - /// Constructor. - /// + /// Construct an instance. public EventManager() { this.mapEvents = new Dictionary>(); - foreach(var v in Game1.locations) - { - addLocation(v.Name, false); - } + foreach (var v in Game1.locations) + this.addLocation(v.Name, false); } - /// - /// Adds an event to the map given the name of the map. - /// - /// - /// - public virtual void addEvent(string mapName,MapEvent mapEvent) - { - foreach(var pair in this.mapEvents) - { - if (pair.Key.Name == mapName) - { - pair.Value.Add(mapEvent); - } - } - } - - /// - /// Adds an event to a map. - /// - /// - /// - public virtual void addEvent(GameLocation Location, MapEvent mapEvent) + /// Adds an event to the map given the name of the map. + public virtual void addEvent(string mapName, MapEvent mapEvent) { foreach (var pair in this.mapEvents) { - if (pair.Key == Location) - { - + if (pair.Key.Name == mapName) pair.Value.Add(mapEvent); - } } } - /// - /// Adds a location to have events handled. - /// - /// The location to handle events. - public virtual void addLocation(GameLocation Location) + /// Adds an event to a map. + public virtual void addEvent(GameLocation location, MapEvent mapEvent) { - EventSystem.ModMonitor.Log("Adding event processing for location: " + Location.Name); - this.mapEvents.Add(Location, new List()); + foreach (var pair in this.mapEvents) + { + if (pair.Key == location) + pair.Value.Add(mapEvent); + } } - /// - /// Adds a location to have events handled. - /// - /// - /// - public virtual void addLocation(GameLocation Location,List Events) + /// Adds a location to have events handled. + /// The location to handle events. + public virtual void addLocation(GameLocation location) { - EventSystem.ModMonitor.Log("Adding event processing for location: " + Location.Name); - this.mapEvents.Add(Location, Events); + EventSystem.ModMonitor.Log($"Adding event processing for location: {location.Name}"); + this.mapEvents.Add(location, new List()); } - /// - /// Adds a location to handle events. - /// - /// The name of the location. Can include farm buildings. + /// Adds a location to have events handled. + public virtual void addLocation(GameLocation location, List events) + { + EventSystem.ModMonitor.Log($"Adding event processing for location: {location.Name}"); + this.mapEvents.Add(location, events); + } + + /// Adds a location to handle events. + /// The name of the location. Can include farm buildings. /// Used if the building is a stucture. True=building. - public virtual void addLocation(string Location,bool isStructure) + public virtual void addLocation(string location, bool isStructure) { - EventSystem.ModMonitor.Log("Adding event processing for location: " + Location); - this.mapEvents.Add(Game1.getLocationFromName(Location,isStructure), new List()); + EventSystem.ModMonitor.Log($"Adding event processing for location: {location}"); + this.mapEvents.Add(Game1.getLocationFromName(location, isStructure), new List()); } - /// - /// Adds a location to have events handled. - /// - /// The name of the location. Can include farm buildings. + /// Adds a location to have events handled. + /// The name of the location. Can include farm buildings. /// Used if the building is a stucture. True=building. - /// A list of pre-initialized events. - public virtual void addLocation(string Location, bool isStructure, List Events) + /// A list of pre-initialized events. + public virtual void addLocation(string location, bool isStructure, List events) { - EventSystem.ModMonitor.Log("Adding event processing for location: " + Location); - this.mapEvents.Add(Game1.getLocationFromName(Location,isStructure), Events); + EventSystem.ModMonitor.Log($"Adding event processing for location: {location}"); + this.mapEvents.Add(Game1.getLocationFromName(location, isStructure), events); } - /// - /// Updates all events associated with the event manager. - /// + /// Updates all events associated with the event manager. public virtual void update() { - List events = new List(); - if (Game1.player == null) return; - if (Game1.hasLoadedGame == false) return; - bool ok=this.mapEvents.TryGetValue(Game1.player.currentLocation, out events); - if (ok == false) return; - else + if (Game1.player == null) + return; + if (!Game1.hasLoadedGame) + return; + + if (this.mapEvents.TryGetValue(Game1.player.currentLocation, out List events)) { - foreach(var v in events) - { + foreach (var v in events) v.update(); - } } } } diff --git a/GeneralMods/MapEvents/Framework/Events/DialogueDisplayEvent.cs b/GeneralMods/MapEvents/Framework/Events/DialogueDisplayEvent.cs index 54e143c1..fec23321 100644 --- a/GeneralMods/MapEvents/Framework/Events/DialogueDisplayEvent.cs +++ b/GeneralMods/MapEvents/Framework/Events/DialogueDisplayEvent.cs @@ -1,19 +1,15 @@ -using EventSystem.Framework.FunctionEvents; -using EventSystem.Framework.Information; +using EventSystem.Framework.FunctionEvents; using Microsoft.Xna.Framework; using StardewValley; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace EventSystem.Framework.Events { - public class DialogueDisplayEvent :MapEvent + public class DialogueDisplayEvent : MapEvent { - string dialogue; - public DialogueDisplayEvent(string Name, GameLocation Location, Vector2 Position, MouseButtonEvents MouseEvents,MouseEntryLeaveEvent EntryLeave, string Dialogue) : base(Name, Location, Position) + private readonly string dialogue; + + public DialogueDisplayEvent(string Name, GameLocation Location, Vector2 Position, MouseButtonEvents MouseEvents, MouseEntryLeaveEvent EntryLeave, string Dialogue) + : base(Name, Location, Position) { this.name = Name; this.location = Location; @@ -26,18 +22,15 @@ namespace EventSystem.Framework.Events 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; + if (!base.OnLeftClick()) return false; + if (this.location.isObjectAt((int)this.tilePosition.X * Game1.tileSize, (int)this.tilePosition.Y * Game1.tileSize)) return false; Game1.activeClickableMenu = new StardewValley.Menus.DialogueBox(this.dialogue); return true; } - /// - /// Used to update the event and check for interaction. - /// + /// Used to update the event and check for interaction. public override void update() { this.clickEvent(); @@ -45,6 +38,5 @@ namespace EventSystem.Framework.Events this.OnMouseEnter(); this.OnMouseLeave(); } - } } diff --git a/GeneralMods/MapEvents/Framework/Events/WarpEvent.cs b/GeneralMods/MapEvents/Framework/Events/WarpEvent.cs index ac661f48..360f3e3d 100644 --- a/GeneralMods/MapEvents/Framework/Events/WarpEvent.cs +++ b/GeneralMods/MapEvents/Framework/Events/WarpEvent.cs @@ -1,31 +1,23 @@ -using EventSystem.Framework.FunctionEvents; +using EventSystem.Framework.FunctionEvents; using EventSystem.Framework.Information; using Microsoft.Xna.Framework; using StardewValley; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace EventSystem.Framework.Events { - /// - /// Used to handle warp events on the map. - /// - public class WarpEvent :MapEvent + /// Used to handle warp events on the map. + public class WarpEvent : MapEvent { - WarpInformation warpInfo; + private readonly WarpInformation warpInfo; - /// - /// Constructor for handling warp events. - /// + /// Constructor for handling warp events. /// The name of the event. /// The game location that this event is located at. /// The x,y tile position of the event. /// The events to occur when the player enters the warp tile before the warp. /// The information for warping the farmer. - public WarpEvent(string Name, GameLocation Location, Vector2 Position, PlayerEvents playerEvents,WarpInformation WarpInfo) : base(Name, Location, Position, playerEvents) + public WarpEvent(string Name, GameLocation Location, Vector2 Position, PlayerEvents playerEvents, WarpInformation WarpInfo) + : base(Name, Location, Position, playerEvents) { this.name = Name; this.location = Location; @@ -36,38 +28,28 @@ namespace EventSystem.Framework.Events this.doesInteractionNeedToRun = true; } - /// - /// Occurs when the player enters the warp tile event position. - /// + /// Occurs when the player enters the warp tile event position. public override bool OnPlayerEnter() { - if (base.OnPlayerEnter() == false) return false; - else - { - - Game1.warpFarmer(this.warpInfo.targetMapName, this.warpInfo.targetX, this.warpInfo.targetY, this.warpInfo.facingDirection, this.warpInfo.isStructure); - return true; - } - } + if (!base.OnPlayerEnter()) + return false; - /// - /// Runs when the player is not on the tile and resets player interaction. - /// - public override bool OnPlayerLeave() - { - if (base.OnPlayerLeave() == false) return false; + Game1.warpFarmer(this.warpInfo.targetMapName, this.warpInfo.targetX, this.warpInfo.targetY, this.warpInfo.facingDirection, this.warpInfo.isStructure); return true; } - /// - /// Used to update the event and check for interaction. - /// + /// Runs when the player is not on the tile and resets player interaction. + public override bool OnPlayerLeave() + { + if (!base.OnPlayerLeave()) return false; + return true; + } + + /// Used to update the event and check for interaction. public override void update() { this.OnPlayerEnter(); this.OnPlayerLeave(); } - - } } diff --git a/GeneralMods/MapEvents/Framework/FunctionEvents/MouseButtonEvents.cs b/GeneralMods/MapEvents/Framework/FunctionEvents/MouseButtonEvents.cs index 634f9086..f2d921e7 100644 --- a/GeneralMods/MapEvents/Framework/FunctionEvents/MouseButtonEvents.cs +++ b/GeneralMods/MapEvents/Framework/FunctionEvents/MouseButtonEvents.cs @@ -1,43 +1,27 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - namespace EventSystem.Framework.FunctionEvents { - /// - /// Used to handle mouse interactions with button clicks and scrolling the mouse wheel. - /// + /// Used to handle mouse interactions with button clicks and scrolling the mouse wheel. public class MouseButtonEvents { - /// - /// Function that runs when the user left clicks. - /// + /// Function that runs when the user left clicks. public functionEvent onLeftClick; - /// - /// Function that runs when the user right clicks. - /// + + /// Function that runs when the user right clicks. public functionEvent onRightClick; - /// - /// Function that runs when the user scrolls the mouse wheel. - /// + + /// Function that runs when the user scrolls the mouse wheel. public functionEvent onMouseScroll; - /// - /// A constructor used to set a single function to a mouse button. - /// + /// A constructor used to set a single function to a mouse button. /// /// If true the function is set to the left click. If false the function is set to the right click. public MouseButtonEvents(functionEvent clickFunction, bool leftClick) { - if (leftClick == true) this.onLeftClick = clickFunction; + if (leftClick) this.onLeftClick = clickFunction; else this.onRightClick = clickFunction; } - /// - /// A constructor used to map functions to mouse clicks. - /// + /// A constructor used to map functions to mouse clicks. /// A function to be ran when the mouse left clicks this position. /// A function to be ran when the mouse right clicks this position. public MouseButtonEvents(functionEvent OnLeftClick, functionEvent OnRightClick) @@ -46,13 +30,11 @@ namespace EventSystem.Framework.FunctionEvents this.onRightClick = OnRightClick; } - /// - /// A constructor used to map functions to mouse clicks and scrolling the mouse wheel. - /// + /// A constructor used to map functions to mouse clicks and scrolling the mouse wheel. /// A function to be ran when the mouse left clicks this position. /// A function to be ran when the mouse right clicks this position. /// A function to be ran when the user scrolls the mouse - public MouseButtonEvents(functionEvent OnLeftClick,functionEvent OnRightClick, functionEvent OnMouseScroll) + public MouseButtonEvents(functionEvent OnLeftClick, functionEvent OnRightClick, functionEvent OnMouseScroll) { this.onLeftClick = OnLeftClick; this.onRightClick = OnRightClick; diff --git a/GeneralMods/MapEvents/Framework/FunctionEvents/MouseEntryLeaveEvent.cs b/GeneralMods/MapEvents/Framework/FunctionEvents/MouseEntryLeaveEvent.cs index 7ae55635..1a7e408b 100644 --- a/GeneralMods/MapEvents/Framework/FunctionEvents/MouseEntryLeaveEvent.cs +++ b/GeneralMods/MapEvents/Framework/FunctionEvents/MouseEntryLeaveEvent.cs @@ -1,28 +1,15 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - namespace EventSystem.Framework.FunctionEvents { - /// - /// Used to handle events that happens when a mouse enters/leaves a specified position. - /// + /// Used to handle events that happens when a mouse enters/leaves a specified position. public class MouseEntryLeaveEvent { - /// - /// A function that is called when a mouse enters a certain position. - /// + /// A function that is called when a mouse enters a certain position. public functionEvent onMouseEnter; - /// - /// A function that is called when a mouse leaves a certain position. - /// + + /// A function that is called when a mouse leaves a certain position. public functionEvent onMouseLeave; - /// - /// Constructor. - /// + /// Construct an instance. /// The function that occurs when the mouse enters a certain position. /// The function that occurs when the mouse leaves a certain position. public MouseEntryLeaveEvent(functionEvent OnMouseEnter, functionEvent OnMouseLeave) diff --git a/GeneralMods/MapEvents/Framework/FunctionEvents/PlayerEvents.cs b/GeneralMods/MapEvents/Framework/FunctionEvents/PlayerEvents.cs index e29d55ae..bc30d63d 100644 --- a/GeneralMods/MapEvents/Framework/FunctionEvents/PlayerEvents.cs +++ b/GeneralMods/MapEvents/Framework/FunctionEvents/PlayerEvents.cs @@ -1,30 +1,17 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - namespace EventSystem.Framework.FunctionEvents { - /// - /// Used to handle various functions that occur on player interaction. - /// + /// Used to handle various functions that occur on player interaction. public class PlayerEvents { - /// - /// Occurs when the player enters the same tile as this event. - /// + /// Occurs when the player enters the same tile as this event. public functionEvent onPlayerEnter; - /// - /// Occurs when the player leaves the same tile as this event. - /// + + /// Occurs when the player leaves the same tile as this event. public functionEvent onPlayerLeave; - /// - /// Constructor. - /// - /// - /// + /// Construct an instance. + /// Occurs when the player enters the same tile as this event. + /// Occurs when the player leaves the same tile as this event. public PlayerEvents(functionEvent OnPlayerEnter, functionEvent OnPlayerLeave) { this.onPlayerEnter = OnPlayerEnter; diff --git a/GeneralMods/MapEvents/Framework/FunctionEvents/functionEvent.cs b/GeneralMods/MapEvents/Framework/FunctionEvents/functionEvent.cs index 896c2050..b3b0ff33 100644 --- a/GeneralMods/MapEvents/Framework/FunctionEvents/functionEvent.cs +++ b/GeneralMods/MapEvents/Framework/FunctionEvents/functionEvent.cs @@ -1,23 +1,15 @@ -using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using static EventSystem.Framework.Delegates; namespace EventSystem.Framework { - /// - /// Used to pair a function and a parameter list using the super object class to run virtually any function for map events. - /// + /// Used to pair a function and a parameter list using the super object class to run virtually any function for map events. public class functionEvent { public paramFunction function; public List parameters; - /// - /// Constructor. - /// + /// Construct an instance. /// The function to be called when running an event. /// The list of system.objects to be used in the function. Can include objects,strings, ints, etc. Anything can be passed in as a parameter or can be passed in as empty. Passing in null will just create an empty list. public functionEvent(paramFunction Function, List Parameters) @@ -27,17 +19,13 @@ namespace EventSystem.Framework this.parameters = Parameters; } - /// - /// Runs the function with the passed in parameters. - /// + /// Runs the function with the passed in parameters. public void run() { this.function.Invoke(this.parameters); } - /// - /// Simply swaps out the old parameters list for a new one. - /// + /// Simply swaps out the old parameters list for a new one. /// public void updateParameters(List newParameters) { diff --git a/GeneralMods/MapEvents/Framework/Information/WarpInformation.cs b/GeneralMods/MapEvents/Framework/Information/WarpInformation.cs index 7cda2745..f63a4031 100644 --- a/GeneralMods/MapEvents/Framework/Information/WarpInformation.cs +++ b/GeneralMods/MapEvents/Framework/Information/WarpInformation.cs @@ -1,14 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - namespace EventSystem.Framework.Information { - /// - /// Used to store all of the information necessary to warp the farmer. - /// + /// Used to store all of the information necessary to warp the farmer. public class WarpInformation { public string targetMapName; @@ -17,15 +9,13 @@ namespace EventSystem.Framework.Information public int facingDirection; public bool isStructure; - /// - /// Constructor used to bundle together necessary information to warp the player character. - /// + /// Constructor used to bundle together necessary information to warp the player character. /// The target map name to warp the farmer to. /// The target X location on the map to warp the farmer to. /// The target Y location on the map to warp the farmer to. /// The facing direction for the farmer to be facing after the warp. /// Used to determine the position to be warped to when leaving a structure. - public WarpInformation(string MapName, int TargetX,int TargetY, int FacingDirection, bool IsStructure) + public WarpInformation(string MapName, int TargetX, int TargetY, int FacingDirection, bool IsStructure) { this.targetMapName = MapName; this.targetX = TargetX; diff --git a/GeneralMods/MapEvents/Framework/MapEvent.cs b/GeneralMods/MapEvents/Framework/MapEvent.cs index fbf2913d..90e88983 100644 --- a/GeneralMods/MapEvents/Framework/MapEvent.cs +++ b/GeneralMods/MapEvents/Framework/MapEvent.cs @@ -1,27 +1,17 @@ -using EventSystem.Framework.FunctionEvents; +using EventSystem.Framework.FunctionEvents; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Input; using StardewValley; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace EventSystem.Framework { - /// - /// Base class used to handle map tile events. - /// + /// Base class used to handle map tile events. public class MapEvent { - /// - /// //MAKE NAME FOR EVENTS - /// - + /// //MAKE NAME FOR EVENTS public string name; - + public Vector2 tilePosition; public GameLocation location; @@ -41,84 +31,64 @@ namespace EventSystem.Framework *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #region + /// Empty Constructor. + public MapEvent() { } - - /// - /// Empty Constructor - /// - public MapEvent() - { - - } - - /// - /// A simple map event that doesn't do anything. - /// - /// - /// - public MapEvent(string name,GameLocation Location,Vector2 Position) + /// A simple map event that doesn't do anything. + public MapEvent(string name, GameLocation location, Vector2 position) { this.name = name; - this.location = Location; - this.tilePosition = Position; - } - - /// - /// A simple map function that runs when the player enters and leaves a tile. Set values to null for nothing to happen. - /// - /// The game location where the event is. I.E Farm, Town, Mine etc. - /// The x,y position on the map the event is. - /// Handles various events that runs when the player enters/leaves a tile, etc. - - public MapEvent(string name,GameLocation Location,Vector2 position, PlayerEvents PlayerEvents) - { - this.name = name; - this.location = Location; + this.location = location; this.tilePosition = position; - this.playerEvents = PlayerEvents; } - /// - /// A constructor that handles when the mouse leaves and enters a tile. - /// - /// The game location where the event is. - /// The x,y position of the tile at the game location. - /// A class used to handle mouse entry/leave events. - public MapEvent(string name,GameLocation Location, Vector2 Position, MouseEntryLeaveEvent mouseEvents) + /// A simple map function that runs when the player enters and leaves a tile. Set values to null for nothing to happen. + /// The game location where the event is. I.E Farm, Town, Mine etc. + /// The x,y position on the map the event is. + /// Handles various events that runs when the player enters/leaves a tile, etc. + public MapEvent(string name, GameLocation location, Vector2 position, PlayerEvents playerEvents) { this.name = name; - this.location = Location; - this.tilePosition = Position; + this.location = location; + this.tilePosition = position; + this.playerEvents = playerEvents; + } + + /// A constructor that handles when the mouse leaves and enters a tile. + /// The game location where the event is. + /// The x,y position of the tile at the game location. + /// A class used to handle mouse entry/leave events. + public MapEvent(string name, GameLocation location, Vector2 position, MouseEntryLeaveEvent mouseEvents) + { + this.name = name; + this.location = location; + this.tilePosition = position; this.mouseEntryLeaveEvents = mouseEvents; } - /// - /// A constructor that handles when the mouse leaves and enters a tile. - /// - /// The game location where the event is. - /// The x,y position of the tile at the game location. + /// A constructor that handles when the mouse leaves and enters a tile. + /// The game location where the event is. + /// The x,y position of the tile at the game location. /// A class used to handle mouse click/scroll events. - public MapEvent(string name,GameLocation Location, Vector2 Position, MouseButtonEvents mouseEvents) + public MapEvent(string name, GameLocation location, Vector2 position, MouseButtonEvents mouseEvents) { this.name = name; - this.location = Location; - this.tilePosition = Position; + this.location = location; + this.tilePosition = position; this.mouseButtonEvents = mouseEvents; } - /// - /// A constructor encapsulating player, mouse button, and mouse entry events. - /// - /// The game location for which the event is located. I.E Town, Farm, etc. - /// The x,y cordinates for this event to be located at. + /// A constructor encapsulating player, mouse button, and mouse entry events. + /// The game location for which the event is located. I.E Town, Farm, etc. + /// The x,y cordinates for this event to be located at. /// The events that occur associated with the player. I.E player entry, etc. /// The events associated with clicking a mouse button while on this tile. /// The events that occur when the mouse enters or leaves the same tile position as this event. - public MapEvent(string name,GameLocation Location, Vector2 Position, PlayerEvents playerEvents, MouseButtonEvents mouseButtonEvents, MouseEntryLeaveEvent mouseEntryLeaveEvents) + public MapEvent(string name, GameLocation location, Vector2 position, PlayerEvents playerEvents, MouseButtonEvents mouseButtonEvents, MouseEntryLeaveEvent mouseEntryLeaveEvents) { this.name = name; - this.location = Location; - this.tilePosition = Position; + this.location = location; + this.tilePosition = position; this.playerEvents = playerEvents; this.mouseButtonEvents = mouseButtonEvents; this.mouseEntryLeaveEvents = mouseEntryLeaveEvents; @@ -126,129 +96,109 @@ namespace EventSystem.Framework #endregion - /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - Player related functions + /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + Player related functions - *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - */ + *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + */ #region - /// - /// Occurs when the player enters the same tile as this event. The function associated with this event is then ran. - /// + /// Occurs when the player enters the same tile as this event. The function associated with this event is then ran. public virtual bool OnPlayerEnter() { if (this.playerEvents == null) return false; - if (isPlayerOnTile() == true && this.doesInteractionNeedToRun==true) + if (this.isPlayerOnTile() && this.doesInteractionNeedToRun) { this.playerOnTile = true; this.doesInteractionNeedToRun = false; - if (this.playerEvents.onPlayerEnter != null) this.playerEvents.onPlayerEnter.run(); + this.playerEvents.onPlayerEnter?.run(); return true; } return false; } - /// - /// Occurs when the player leaves the same tile that this event is on. The function associated with thie event is then ran. - /// + /// Occurs when the player leaves the same tile that this event is on. The function associated with thie event is then ran. public virtual bool OnPlayerLeave() { if (this.playerEvents == null) return false; - if (isPlayerOnTile() == false && this.playerOnTile==true){ + if (!this.isPlayerOnTile() && this.playerOnTile) + { this.playerOnTile = false; this.doesInteractionNeedToRun = true; - if (this.playerEvents.onPlayerLeave != null) this.playerEvents.onPlayerLeave.run(); + this.playerEvents.onPlayerLeave?.run(); return true; } return false; } - /// - /// Checks if the player is on the same tile as this event. - /// - /// + /// Checks if the player is on the same tile as this event. public virtual bool isPlayerOnTile() { - if (Game1.player.getTileX() == this.tilePosition.X && Game1.player.getTileY() == this.tilePosition.Y) return true; - else return false; + return + Game1.player.getTileX() == this.tilePosition.X + && Game1.player.getTileY() == this.tilePosition.Y; } #endregion - /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - Mouse related functions + /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + Mouse related functions - *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - */ + *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + */ #region - /// - /// Occurs when the player left clicks the same tile that this event is on. - /// + /// Occurs when the player left clicks the same tile that this event is on. public virtual bool OnLeftClick() { - if (this.mouseOnTile==false) return false; + if (!this.mouseOnTile) return false; if (this.mouseButtonEvents == null) return false; - if (this.mouseButtonEvents.onLeftClick != null) this.mouseButtonEvents.onLeftClick.run(); + this.mouseButtonEvents.onLeftClick?.run(); return true; } - /// - /// Occurs when the player right clicks the same tile that this event is on. - /// + /// Occurs when the player right clicks the same tile that this event is on. public virtual bool OnRightClick() { - if (this.mouseOnTile == false) return false; + if (!this.mouseOnTile) return false; if (this.mouseButtonEvents == null) return false; - if (this.mouseButtonEvents.onRightClick != null) this.mouseButtonEvents.onRightClick.run(); + this.mouseButtonEvents.onRightClick?.run(); return true; } - /// - /// Occurs when the mouse tile position is the same as this event's x,y position. - /// + /// Occurs when the mouse tile position is the same as this event's x,y position. public virtual bool OnMouseEnter() { if (this.mouseEntryLeaveEvents == null) return false; - if (isMouseOnTile()) + if (this.isMouseOnTile()) { this.mouseOnTile = true; - if (this.mouseEntryLeaveEvents.onMouseEnter != null) this.mouseEntryLeaveEvents.onMouseEnter.run(); + this.mouseEntryLeaveEvents.onMouseEnter?.run(); return true; } return false; } - /// - /// Occurs when the mouse tile position leaves the the same x,y position as this event. - /// + /// Occurs when the mouse tile position leaves the the same x,y position as this event. public virtual bool OnMouseLeave() { if (this.mouseEntryLeaveEvents == null) return false; - if (isMouseOnTile() == false && this.mouseOnTile == true) + if (!this.isMouseOnTile() && this.mouseOnTile) { this.mouseOnTile = false; - if (this.mouseEntryLeaveEvents.onMouseLeave != null) this.mouseEntryLeaveEvents.onMouseLeave.run(); + this.mouseEntryLeaveEvents.onMouseLeave?.run(); return true; } return false; } - /// - /// UNUSED!!!! - /// Occurs when the mouse is on the same position as the tile AND the user scrolls the mouse wheel. - /// + /// UNUSED!!!! Occurs when the mouse is on the same position as the tile AND the user scrolls the mouse wheel. public virtual bool OnMouseScroll() { - - if (isMouseOnTile() == false) return false; - if (this.mouseButtonEvents.onMouseScroll != null) this.mouseButtonEvents.onMouseScroll.run(); + if (!this.isMouseOnTile()) return false; + this.mouseButtonEvents.onMouseScroll?.run(); return true; } - /// - /// Checks if the mouse is on the tile. - /// - /// + /// Checks if the mouse is on the tile. public virtual bool isMouseOnTile() { Vector2 mousePosition = Game1.currentCursorTile; @@ -256,30 +206,27 @@ namespace EventSystem.Framework return false; } - /// - /// Occurs when the tile is clicked. Runs the appropriate event. - /// + /// Occurs when the tile is clicked. Runs the appropriate event. public virtual void clickEvent() { - if (this.mouseOnTile == false) return; - var mouseState=Mouse.GetState(); - if (mouseState.LeftButton == ButtonState.Pressed) OnLeftClick(); - if (mouseState.RightButton == ButtonState.Pressed) OnRightClick(); + if (!this.mouseOnTile) return; + var mouseState = Mouse.GetState(); + if (mouseState.LeftButton == ButtonState.Pressed) + this.OnLeftClick(); + if (mouseState.RightButton == ButtonState.Pressed) + this.OnRightClick(); } -#endregion + #endregion - - /// - /// Used to check if any sort of events need to run on this tile right now. - /// + /// Used to check if any sort of events need to run on this tile right now. public virtual void update() { if (Game1.activeClickableMenu != null) return; - clickEvent(); //click events - OnPlayerEnter(); //player enter events - OnPlayerLeave(); //player leave events - OnMouseEnter(); //on mouse enter events - OnMouseLeave(); //on mouse leave events. + this.clickEvent(); //click events + this.OnPlayerEnter(); //player enter events + this.OnPlayerLeave(); //player leave events + this.OnMouseEnter(); //on mouse enter events + this.OnMouseLeave(); //on mouse leave events. } } } diff --git a/GeneralMods/MapEvents/manifest.json b/GeneralMods/MapEvents/manifest.json index 4579d6f3..4c72d707 100644 --- a/GeneralMods/MapEvents/manifest.json +++ b/GeneralMods/MapEvents/manifest.json @@ -6,5 +6,5 @@ "UniqueID": "Omegasis.EventSystem", "EntryDll": "EventSystem.dll", "MinimumApiVersion": "2.0", - "UpdateKeys": [ ] + "UpdateKeys": [] } diff --git a/GeneralMods/MoreRain/Framework/ModConfig.cs b/GeneralMods/MoreRain/Framework/ModConfig.cs index ce34e80f..791216b4 100644 --- a/GeneralMods/MoreRain/Framework/ModConfig.cs +++ b/GeneralMods/MoreRain/Framework/ModConfig.cs @@ -1,4 +1,4 @@ -namespace Omegasis.MoreRain.Framework +namespace Omegasis.MoreRain.Framework { /// The mod configuration. internal class ModConfig diff --git a/GeneralMods/MoreRain/MoreRain.cs b/GeneralMods/MoreRain/MoreRain.cs index 8b1adfbd..d17e32ba 100644 --- a/GeneralMods/MoreRain/MoreRain.cs +++ b/GeneralMods/MoreRain/MoreRain.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using Omegasis.MoreRain.Framework; using StardewModdingAPI; @@ -88,7 +88,6 @@ namespace Omegasis.MoreRain this.VerboseLog("It will be stormy tomorrow."); return; } - break; case "summer": @@ -143,7 +142,7 @@ namespace Omegasis.MoreRain } } - /// Log a message if is false. + /// Log a message if is false. /// The message to log. private void VerboseLog(string message) { diff --git a/GeneralMods/MuseumRearranger/Framework/ModConfig.cs b/GeneralMods/MuseumRearranger/Framework/ModConfig.cs index f14ea7ad..923c969b 100644 --- a/GeneralMods/MuseumRearranger/Framework/ModConfig.cs +++ b/GeneralMods/MuseumRearranger/Framework/ModConfig.cs @@ -1,4 +1,4 @@ -namespace Omegasis.MuseumRearranger.Framework +namespace Omegasis.MuseumRearranger.Framework { /// The mod configuration. internal class ModConfig diff --git a/GeneralMods/MuseumRearranger/Framework/NewMuseumMenu.cs b/GeneralMods/MuseumRearranger/Framework/NewMuseumMenu.cs index dcef035a..a81eca27 100644 --- a/GeneralMods/MuseumRearranger/Framework/NewMuseumMenu.cs +++ b/GeneralMods/MuseumRearranger/Framework/NewMuseumMenu.cs @@ -1,4 +1,4 @@ -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using StardewModdingAPI; using StardewValley; diff --git a/GeneralMods/MuseumRearranger/MuseumRearranger.cs b/GeneralMods/MuseumRearranger/MuseumRearranger.cs index 98df59ee..8494f4ae 100644 --- a/GeneralMods/MuseumRearranger/MuseumRearranger.cs +++ b/GeneralMods/MuseumRearranger/MuseumRearranger.cs @@ -1,4 +1,4 @@ -using Omegasis.MuseumRearranger.Framework; +using Omegasis.MuseumRearranger.Framework; using StardewModdingAPI; using StardewModdingAPI.Events; using StardewValley; diff --git a/GeneralMods/NightOwl/Framework/ModConfig.cs b/GeneralMods/NightOwl/Framework/ModConfig.cs index 7dfcbed4..43edd686 100644 --- a/GeneralMods/NightOwl/Framework/ModConfig.cs +++ b/GeneralMods/NightOwl/Framework/ModConfig.cs @@ -1,4 +1,4 @@ -namespace Omegasis.NightOwl.Framework +namespace Omegasis.NightOwl.Framework { /// The mod configuration. internal class ModConfig @@ -25,9 +25,7 @@ public bool KeepStaminaAfterCollapse { get; set; } = true; - /// - /// Whether or not to use the internal NightFish asset editor. When false, it will just use the Fish.xnb file. - /// + /// Whether or not to use the internal NightFish asset editor. When false, it will just use the Fish.xnb file. public bool UseInternalNightFishAssetEditor { get; set; } = true; } } diff --git a/GeneralMods/NightOwl/Framework/NightFishing.cs b/GeneralMods/NightOwl/Framework/NightFishing.cs index 79541d6b..21b1f06c 100644 --- a/GeneralMods/NightOwl/Framework/NightFishing.cs +++ b/GeneralMods/NightOwl/Framework/NightFishing.cs @@ -1,9 +1,5 @@ -using StardewModdingAPI; -using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using StardewModdingAPI; namespace Omegasis.NightOwl.Framework { @@ -16,7 +12,7 @@ namespace Omegasis.NightOwl.Framework public void Edit(IAssetData asset) { - Dictionary nightFish=new Dictionary // (T)(object) is a trick to cast anything to T if we know it's compatible + Dictionary nightFish = new Dictionary // (T)(object) is a trick to cast anything to T if we know it's compatible { [128] = "Pufferfish/80/floater/1/36/1200 1600/summer/sunny/690 .4 685 .1/4/.3/.5/0", [129] = "Anchovy/30/dart/1/16/600 3000/spring fall/both/682 .2/1/.25/.3/0", @@ -82,10 +78,10 @@ namespace Omegasis.NightOwl.Framework [799] = "Spook Fish/60/dart/8/25/600 3000/spring summer fall winter/both/685 .35/3/.4/.1/0", [800] = "Blobfish/75/floater/8/25/600 3000/spring summer fall winter/both/685 .35/3/.4/.1/0", }; - foreach (KeyValuePair pair in nightFish) { + foreach (KeyValuePair pair in nightFish) + { asset.AsDictionary().Set(pair.Key, pair.Value); } } - } } diff --git a/GeneralMods/NightOwl/NightOwl.cs b/GeneralMods/NightOwl/NightOwl.cs index eb4a978e..41b37fbb 100644 --- a/GeneralMods/NightOwl/NightOwl.cs +++ b/GeneralMods/NightOwl/NightOwl.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.IO; using System.Linq; @@ -11,15 +11,11 @@ using StardewValley; using StardewValley.Characters; using StardewValley.Locations; -/*TODO: -Issues: --Mail can't be wiped without destroying all mail. --Lighting transition does not work if it is raining. - -set the weather to clear if you are stayig up late. - -transition still doesnt work. However atleast it is dark now. - --Known glitched -*/ +// TODO: +// -Mail can't be wiped without destroying all mail. +// -Lighting transition does not work if it is raining. +// -set the weather to clear if you are stayig up late. +// -transition still doesnt work. However atleast it is dark now. namespace Omegasis.NightOwl { /// The mod entry point. @@ -64,32 +60,21 @@ namespace Omegasis.NightOwl /// The player's health before they collapsed. private int PreCollapseHealth; - /// - /// Checks if the player was bathing or not before passing out. - /// + /// Checks if the player was bathing or not before passing out. private bool isBathing; - /// - /// Checks if the player was in their swimsuit before passing out. - /// + /// Checks if the player was in their swimsuit before passing out. private bool isInSwimSuit; - - /// - /// The horse the player was riding before they collapsed. - /// + + /// The horse the player was riding before they collapsed. private Horse horse; - /// - /// Determines whehther or not to rewarp the player's horse to them. - /// + /// Determines whehther or not to rewarp the player's horse to them. private bool shouldWarpHorse; - /// - /// Event in the night taht simulates the earthquake event that should happen. - /// + /// Event in the night taht simulates the earthquake event that should happen. StardewValley.Events.SoundInTheNightEvent eve; - private List oldAnimalHappiness; @@ -103,37 +88,28 @@ namespace Omegasis.NightOwl this.oldAnimalHappiness = new List(); this.Config = helper.ReadConfig(); - if (Config.UseInternalNightFishAssetEditor) - { + if (this.Config.UseInternalNightFishAssetEditor) this.Helper.Content.AssetEditors.Add(new NightFishing()); - } + TimeEvents.TimeOfDayChanged += this.TimeEvents_TimeOfDayChanged; TimeEvents.AfterDayStarted += this.TimeEvents_AfterDayStarted; SaveEvents.AfterLoad += this.SaveEvents_AfterLoad; SaveEvents.BeforeSave += this.SaveEvents_BeforeSave; GameEvents.FourthUpdateTick += this.GameEvents_FourthUpdateTick; - GameEvents.UpdateTick += GameEvents_UpdateTick; - shouldWarpHorse = false; + GameEvents.UpdateTick += this.GameEvents_UpdateTick; + this.shouldWarpHorse = false; } - /********* ** Private methods *********/ - - /// - /// Updates the earthquake event. - /// - /// - /// + /// Updates the earthquake event. + /// The event sender. + /// The event data. private void GameEvents_UpdateTick(object sender, EventArgs e) { - if (eve == null) return; - else - { - eve.tickUpdate(Game1.currentGameTime); - } + this.eve?.tickUpdate(Game1.currentGameTime); } /// The method invoked every fourth game update (roughly 15 times per second). @@ -160,7 +136,7 @@ namespace Omegasis.NightOwl this.WriteErrorLog(); } } - + /// The method invoked before the game saves. /// The event sender. /// The event data. @@ -170,17 +146,14 @@ namespace Omegasis.NightOwl string[] passOutFees = Game1.player.mailbox .Where(p => p.Contains("passedOut")) .ToArray(); - for (int idx=0; idx< passOutFees.Length; idx++) - { - string[] msg = passOutFees[idx].Split(' '); - collapseFee += Int32.Parse(msg[1]); - } - - if (this.Config.KeepMoneyAfterCollapse) - { - Game1.player.money += collapseFee; - } - + foreach (string fee in passOutFees) + { + string[] msg = fee.Split(' '); + collapseFee += int.Parse(msg[1]); + } + + if (this.Config.KeepMoneyAfterCollapse) + Game1.player.money += collapseFee; } /// The method invoked after the player loads a save. @@ -213,51 +186,39 @@ namespace Omegasis.NightOwl if (this.Config.KeepHealthAfterCollapse) Game1.player.health = this.PreCollapseHealth; if (this.Config.KeepPositionAfterCollapse) - if (Game1.weddingToday == false) - { + { + if (!Game1.weddingToday) Game1.warpFarmer(this.PreCollapseMap, this.PreCollapseTile.X, this.PreCollapseTile.Y, false); - } - if (horse != null && shouldWarpHorse==true) - { - Game1.warpCharacter(horse, Game1.player.currentLocation, Game1.player.position); - shouldWarpHorse = false; } - if (isInSwimSuit) + + if (this.horse != null && this.shouldWarpHorse) { + Game1.warpCharacter(this.horse, Game1.player.currentLocation, Game1.player.position); + this.shouldWarpHorse = false; + } + if (this.isInSwimSuit) Game1.player.changeIntoSwimsuit(); - } - if (isBathing) - { + if (this.isBathing) Game1.player.swimming.Value = true; - } + //Reflction to ensure that the railroad becomes properly unblocked. if (Game1.dayOfMonth == 1 && Game1.currentSeason == "summer" && Game1.year == 1) { Mountain mountain = (Mountain)Game1.getLocationFromName("Mountain"); - var reflect2 = Helper.Reflection.GetField(mountain, "railroadAreaBlocked", true); - var netBool2 = reflect2.GetValue(); + NetBool netBool2 = this.Helper.Reflection.GetField(mountain, "railroadAreaBlocked").GetValue(); netBool2.Value = false; - reflect2.SetValue(netBool2); + this.Helper.Reflection.GetField(mountain, "railroadBlockRect").SetValue(Rectangle.Empty); - var reflect3 = Helper.Reflection.GetField(mountain, "railroadBlockRect", true); - var netBool3 = reflect3.GetValue(); - netBool3 = new Rectangle(0, 0, 0, 0); - reflect3.SetValue(netBool3); - - - eve = new StardewValley.Events.SoundInTheNightEvent(4); - eve.setUp(); - eve.makeChangesToLocation(); - + this.eve = new StardewValley.Events.SoundInTheNightEvent(4); + this.eve.setUp(); + this.eve.makeChangesToLocation(); } } - if(Game1.currentSeason!="spring" && Game1.year >= 1) - { - clearRailRoadBlock(); - } + if (Game1.currentSeason != "spring" && Game1.year >= 1) + this.clearRailRoadBlock(); // delete annoying charge messages (if only I could do this with mail IRL) if (this.Config.SkipCollapseMail) @@ -280,23 +241,15 @@ namespace Omegasis.NightOwl } } - /// - /// If the user for this mod never gets the event that makes the railroad blok go away we will always force it to go away if they have met the conditions for it. I.E not being in spring of year 1. - /// + /// If the user for this mod never gets the event that makes the railroad blok go away we will always force it to go away if they have met the conditions for it. I.E not being in spring of year 1. private void clearRailRoadBlock() { Mountain mountain = (Mountain)Game1.getLocationFromName("Mountain"); - var reflect2 = Helper.Reflection.GetField(mountain, "railroadAreaBlocked", true); - var netBool2 = reflect2.GetValue(); + var netBool2 = this.Helper.Reflection.GetField(mountain, "railroadAreaBlocked").GetValue(); netBool2.Value = false; - reflect2.SetValue(netBool2); - - var reflect3 = Helper.Reflection.GetField(mountain, "railroadBlockRect", true); - var netBool3 = reflect3.GetValue(); - netBool3 = new Rectangle(0, 0, 0, 0); - reflect3.SetValue(netBool3); + this.Helper.Reflection.GetField(mountain, "railroadBlockRect").SetValue(Rectangle.Empty); } /// The method invoked when changes. @@ -322,11 +275,10 @@ namespace Omegasis.NightOwl Game1.isRaining = false; // remove rain, otherwise lighting gets screwy Game1.updateWeatherIcon(); Game1.timeOfDay = 150; //change it from 1:50 am late, to 1:50 am early - foreach(FarmAnimal animal in Game1.getFarm().getAllFarmAnimals()) + foreach (FarmAnimal animal in Game1.getFarm().getAllFarmAnimals()) { this.oldAnimalHappiness.Add(animal.happiness); } - } // collapse player at 6am to save & reset @@ -343,15 +295,11 @@ namespace Omegasis.NightOwl if (character is Horse) { (character as Horse).dismount(); - horse = (character as Horse); - shouldWarpHorse = true; + this.horse = (character as Horse); + this.shouldWarpHorse = true; } - - } - catch (Exception err) - { - } + catch { } } } this.JustCollapsed = true; @@ -366,7 +314,6 @@ namespace Omegasis.NightOwl this.isBathing = Game1.player.swimming.Value; - if (Game1.currentMinigame != null) Game1.currentMinigame = null; @@ -375,14 +322,12 @@ namespace Omegasis.NightOwl Game1.timeOfDay += 2400; //Recalculate for the sake of technically being up a whole day. //Reset animal happiness since it drains over night. - for(int i=0; i < oldAnimalHappiness.Count; i++) + for (int i = 0; i < this.oldAnimalHappiness.Count; i++) { - Game1.getFarm().getAllFarmAnimals()[i].happiness.Value = oldAnimalHappiness[i].Value; + Game1.getFarm().getAllFarmAnimals()[i].happiness.Value = this.oldAnimalHappiness[i].Value; } Game1.player.startToPassOut(); - - } } catch (Exception ex) @@ -412,10 +357,7 @@ namespace Omegasis.NightOwl this.Helper.WriteJsonFile(path, state); } - /// - /// Try and emulate the old Game1.shouldFarmerPassout logic. - /// - /// + /// Try and emulate the old Game1.shouldFarmerPassout logic. public bool shouldFarmerPassout() { if (Game1.player.stamina <= 0 || Game1.player.health <= 0 || Game1.timeOfDay >= 2600) return true; diff --git a/GeneralMods/NoMorePets/NoMorePets.cs b/GeneralMods/NoMorePets/NoMorePets.cs index 07982c33..7b38c409 100644 --- a/GeneralMods/NoMorePets/NoMorePets.cs +++ b/GeneralMods/NoMorePets/NoMorePets.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Linq; using StardewModdingAPI; using StardewModdingAPI.Events; @@ -28,7 +28,7 @@ namespace Omegasis.NoMorePets /// The event sender. /// The event data. public void SaveEvents_AfterLoad(object sender, EventArgs e) - { + { foreach (Pet pet in Game1.player.currentLocation.getCharacters().OfType().ToArray()) pet.currentLocation.characters.Remove(pet); } diff --git a/GeneralMods/Revitalize/Framework/Crafting/Recipe.cs b/GeneralMods/Revitalize/Framework/Crafting/Recipe.cs index 0a9d8589..40906ab2 100644 --- a/GeneralMods/Revitalize/Framework/Crafting/Recipe.cs +++ b/GeneralMods/Revitalize/Framework/Crafting/Recipe.cs @@ -1,10 +1,7 @@ -using Revitalize.Framework.Utilities; -using StardewValley; -using System; using System.Collections.Generic; using System.Linq; -using System.Text; -using System.Threading.Tasks; +using Revitalize.Framework.Utilities; +using StardewValley; namespace Revitalize.Framework.Crafting { @@ -17,45 +14,32 @@ namespace Revitalize.Framework.Crafting public Item DisplayItem { - get - { - if (this.displayItem == null) return outputs.ElementAt(0).Key; - else - { - return displayItem; - } - } - set - { - this.displayItem = value; - } + get => this.displayItem ?? this.outputs.ElementAt(0).Key; + set => this.displayItem = value; } public string outputDescription; public string outputName; - public Recipe() - { + public Recipe() { } - } - - /// - /// Constructor for single item output. - /// + /// Constructor for single item output. /// All the ingredients required to make the output. /// The item given as output with how many - public Recipe(Dictionary inputs,KeyValuePair output) + public Recipe(Dictionary inputs, KeyValuePair output) { this.ingredients = inputs; this.DisplayItem = output.Key; this.outputDescription = output.Key.getDescription(); this.outputName = output.Key.DisplayName; - this.outputs = new Dictionary(); - this.outputs.Add(output.Key, output.Value); + this.outputs = new Dictionary + { + [output.Key] = output.Value + }; } - public Recipe(Dictionary inputs,Dictionary outputs,string OutputName, string OutputDescription,Item DisplayItem=null) + public Recipe(Dictionary inputs, Dictionary outputs, string OutputName, string OutputDescription, Item DisplayItem = null) { this.ingredients = inputs; this.outputs = outputs; @@ -64,165 +48,122 @@ namespace Revitalize.Framework.Crafting this.DisplayItem = DisplayItem; } - - /// - /// Checks if a player contains all recipe ingredients. - /// - /// + /// Checks if a player contains all recipe ingredients. public bool PlayerContainsAllIngredients() { - return InventoryContainsAllIngredient(Game1.player.Items.ToList()); + return this.InventoryContainsAllIngredient(Game1.player.Items.ToList()); } - /// - /// Checks if a player contains a recipe ingredient. - /// - /// - /// - public bool PlayerContainsIngredient(KeyValuePair pair) + /// Checks if a player contains a recipe ingredient. + public bool PlayerContainsIngredient(KeyValuePair pair) { - return InventoryContainsIngredient(Game1.player.Items.ToList(), pair); + return this.InventoryContainsIngredient(Game1.player.Items.ToList(), pair); } - - /// - /// Checks if an inventory contains all items. - /// - /// - /// + /// Checks if an inventory contains all items. public bool InventoryContainsAllIngredient(List items) { foreach (KeyValuePair pair in this.ingredients) - { - if (InventoryContainsIngredient(items,pair) == false) return false; - } + if (!this.InventoryContainsIngredient(items, pair)) return false; return true; } - /// - /// Checks if an inventory contains an ingredient. - /// - /// - /// - /// - public bool InventoryContainsIngredient(List items,KeyValuePair pair) + /// Checks if an inventory contains an ingredient. + public bool InventoryContainsIngredient(List items, KeyValuePair pair) { foreach (Item i in items) { - if (i == null) continue; - if (ItemEqualsOther(i, pair.Key) && pair.Value == i.Stack) - { + if (i != null && this.ItemEqualsOther(i, pair.Key) && pair.Value == i.Stack) return true; - } } return false; } - - /// - /// Checks roughly if two items equal each other. - /// - /// - /// - /// + /// Checks roughly if two items equal each other. public bool ItemEqualsOther(Item self, Item other) { - if (self.Name == other.Name && self.getCategoryName() == other.getCategoryName() && self.GetType() == other.GetType()) return true; - return false; + return + self.Name == other.Name + && self.getCategoryName() == other.getCategoryName() + && self.GetType() == other.GetType(); } public void consume(ref List from) { - if (!InventoryContainsAllIngredient(from)) return; + if (!this.InventoryContainsAllIngredient(from)) + return; + InventoryManager manager = new InventoryManager(from); - List removalList = new List(); - - foreach (KeyValuePair pair in this.ingredients) + foreach (KeyValuePair pair in this.ingredients) { - foreach(Item InventoryItem in manager.items) + foreach (Item item in manager.items) { - if (InventoryItem == null) continue; - if (ItemEqualsOther(InventoryItem, pair.Key)) + if (item == null) continue; + if (this.ItemEqualsOther(item, pair.Key)) { - if (InventoryItem.Stack == pair.Value) - { - removalList.Add(InventoryItem); //remove the item - } + if (item.Stack == pair.Value) + removalList.Add(item); //remove the item else - { - InventoryItem.Stack -= pair.Value; //or reduce the stack size. - } + item.Stack -= pair.Value; //or reduce the stack size. } } } foreach (var v in removalList) - { manager.items.Remove(v); - } removalList.Clear(); from = manager.items; } - public void produce(ref List to,bool dropToGround=false,bool isPlayerInventory=false) + public void produce(ref List to, bool dropToGround = false, bool isPlayerInventory = false) { - InventoryManager manager; - if (isPlayerInventory == true) + var manager = isPlayerInventory + ? new InventoryManager(new List()) + : new InventoryManager(to); + foreach (KeyValuePair pair in this.outputs) { - manager = new InventoryManager(new List()); - } - else - { - manager = new InventoryManager(to); - } - foreach(KeyValuePair pair in this.outputs) - { - Item I = pair.Key.getOne(); - I.addToStack(pair.Value - 1); - bool added=manager.addItem(I); - if (added == false && dropToGround==true) - { - Game1.createItemDebris(I, Game1.player.getStandingPosition(), Game1.player.getDirection()); - } + Item item = pair.Key.getOne(); + item.addToStack(pair.Value - 1); + bool added = manager.addItem(item); + if (!added && dropToGround) + Game1.createItemDebris(item, Game1.player.getStandingPosition(), Game1.player.getDirection()); } to = manager.items; } - public void craft(ref List from,ref List to,bool dropToGround=false,bool isPlayerInventory=false) + public void craft(ref List from, ref List to, bool dropToGround = false, bool isPlayerInventory = false) { InventoryManager manager = new InventoryManager(to); if (manager.ItemCount + this.outputs.Count >= manager.capacity) { - if (isPlayerInventory) Game1.showRedMessage("Inventory Full"); + if (isPlayerInventory) + Game1.showRedMessage("Inventory Full"); else return; } - consume(ref from); - produce(ref to,dropToGround,isPlayerInventory); + this.consume(ref from); + this.produce(ref to, dropToGround, isPlayerInventory); } public void craft() { List playerItems = Game1.player.Items.ToList(); List outPutItems = new List(); - craft(ref playerItems,ref outPutItems, true,true); + this.craft(ref playerItems, ref outPutItems, true, true); Game1.player.Items = playerItems; //Set the items to be post consumption. - foreach(Item I in outPutItems) - { + foreach (Item I in outPutItems) Game1.player.addItemToInventory(I); //Add all items produced. - } } public bool PlayerCanCraft() { - return PlayerContainsAllIngredients(); + return this.PlayerContainsAllIngredients(); } public bool CanCraft(List items) { - return InventoryContainsAllIngredient(items); + return this.InventoryContainsAllIngredient(items); } - } } diff --git a/GeneralMods/Revitalize/Framework/Environment/DarkerNight.cs b/GeneralMods/Revitalize/Framework/Environment/DarkerNight.cs index f2075411..c0b505cf 100644 --- a/GeneralMods/Revitalize/Framework/Environment/DarkerNight.cs +++ b/GeneralMods/Revitalize/Framework/Environment/DarkerNight.cs @@ -1,108 +1,80 @@ -using StardewValley; using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Revitalize.Framework.Illuminate; using System.IO; using Microsoft.Xna.Framework; +using StardewValley; namespace Revitalize.Framework.Environment { - /// - /// Deals with making night time darker in Stardew. - /// + /// Deals with making night time darker in Stardew. public class DarkerNight { - - /// - /// Darkness intensity. - /// + /// Darkness intensity. public static float IncrediblyDark = 0.9f; - /// - /// Darkness intensity. - /// + + /// Darkness intensity. public static float VeryDark = 0.75f; - /// - /// Darkness intensity. - /// + + /// Darkness intensity. public static float SomewhatDark = 0.50f; - /// - /// The config file. - /// + /// The config file. public static DarkerNightConfig Config; - /// - /// The calculated night color. - /// + /// The calculated night color. private static Color CalculatedColor; - /// - /// Initializes the config for DarkerNight. - /// + /// Initializes the config for DarkerNight. public static void InitializeConfig() { - if (File.Exists(Path.Combine(Revitalize.ModCore.ModHelper.DirectoryPath, "Configs", "DarkerNightConfig.json"))) - { - Config = Revitalize.ModCore.ModHelper.Data.ReadJsonFile(Path.Combine("Configs", "DarkerNightConfig.json")); - } + if (File.Exists(Path.Combine(ModCore.ModHelper.DirectoryPath, "Configs", "DarkerNightConfig.json"))) + Config = ModCore.ModHelper.Data.ReadJsonFile(Path.Combine("Configs", "DarkerNightConfig.json")); else { Config = new DarkerNightConfig(); - Revitalize.ModCore.ModHelper.Data.WriteJsonFile(Path.Combine("Configs", "DarkerNightConfig.json"),Config); + ModCore.ModHelper.Data.WriteJsonFile(Path.Combine("Configs", "DarkerNightConfig.json"), Config); } } - /// - /// Sets the color of darkness at night. - /// + /// Sets the color of darkness at night. public static void SetDarkerColor() { - if (Config.Enabled == false) return; - if (Game1.player == null) return; - if (Game1.player.currentLocation == null) return; + if (!Config.Enabled || Game1.player?.currentLocation == null) + return; + if (Game1.player.currentLocation.IsOutdoors && Game1.timeOfDay >= Game1.getStartingToGetDarkTime()) - { Game1.outdoorLight = CalculatedColor; - } } - /// - /// Calculates how dark it should be a night. - /// + /// Calculates how dark it should be a night. public static void CalculateDarkerNightColor() { - if (Config.Enabled == false) return; - if (Game1.player == null) return; - if (Game1.player.currentLocation == null) return; + if (!Config.Enabled || Game1.player?.currentLocation == null) + return; + //Calculate original lighting. if (Game1.timeOfDay >= Game1.getTrulyDarkTime()) { - float num = Math.Min(0.93f, (float)(0.75 + ((double)((int)((double)(Game1.timeOfDay - Game1.timeOfDay % 100) + (double)(Game1.timeOfDay % 100 / 10) * 16.6599998474121) - Game1.getTrulyDarkTime()) + (double)Game1.gameTimeInterval / 7000.0 * 16.6000003814697) * 0.000624999986030161)); + float num = Math.Min(0.93f, (float)(0.75 + ((int)(Game1.timeOfDay - Game1.timeOfDay % 100 + Game1.timeOfDay % 100 / 10 * 16.6599998474121) - Game1.getTrulyDarkTime() + Game1.gameTimeInterval / 7000.0 * 16.6000003814697) * 0.000624999986030161)); Game1.outdoorLight = (Game1.isRaining ? Game1.ambientLight : Game1.eveningColor) * num; } else if (Game1.timeOfDay >= Game1.getStartingToGetDarkTime()) { - float num = Math.Min(0.93f, (float)(0.300000011920929 + ((double)((int)((double)(Game1.timeOfDay - Game1.timeOfDay % 100) + (double)(Game1.timeOfDay % 100 / 10) * 16.6599998474121) - Game1.getStartingToGetDarkTime()) + (double)Game1.gameTimeInterval / 7000.0 * 16.6000003814697) * 0.00224999990314245)); + float num = Math.Min(0.93f, (float)(0.300000011920929 + ((int)(Game1.timeOfDay - Game1.timeOfDay % 100 + Game1.timeOfDay % 100 / 10 * 16.6599998474121) - Game1.getStartingToGetDarkTime() + Game1.gameTimeInterval / 7000.0 * 16.6000003814697) * 0.00224999990314245)); Game1.outdoorLight = (Game1.isRaining ? Game1.ambientLight : Game1.eveningColor) * num; } - Revitalize.ModCore.log("OUT: " + Game1.outdoorLight); + ModCore.log("OUT: " + Game1.outdoorLight); int red = Game1.outdoorLight.R; - if (Game1.player.currentLocation.IsOutdoors && Game1.timeOfDay>= Game1.getStartingToGetDarkTime()) + if (Game1.player.currentLocation.IsOutdoors && Game1.timeOfDay >= Game1.getStartingToGetDarkTime()) { //Game1.ambientLight = Game1.ambientLight.GreyScaleAverage(); - CalculatedColor = Game1.ambientLight* ( (red+30) / 255f) * Config.DarknessIntensity; + CalculatedColor = Game1.ambientLight * ((red + 30) / 255f) * Config.DarknessIntensity; - Revitalize.ModCore.log("OUT: " + CalculatedColor); - Revitalize.ModCore.log("Ambient"+Game1.ambientLight); + ModCore.log("OUT: " + CalculatedColor); + ModCore.log("Ambient" + Game1.ambientLight); } } - - } } diff --git a/GeneralMods/Revitalize/Framework/Environment/DarkerNightConfig.cs b/GeneralMods/Revitalize/Framework/Environment/DarkerNightConfig.cs index 6d2c4b93..71819fff 100644 --- a/GeneralMods/Revitalize/Framework/Environment/DarkerNightConfig.cs +++ b/GeneralMods/Revitalize/Framework/Environment/DarkerNightConfig.cs @@ -1,10 +1,3 @@ -using Microsoft.Xna.Framework; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - namespace Revitalize.Framework.Environment { public class DarkerNightConfig @@ -16,6 +9,5 @@ namespace Revitalize.Framework.Environment this.Enabled = true; this.DarknessIntensity = .9f; } - } } diff --git a/GeneralMods/Revitalize/Framework/Graphics/Animations/Animation.cs b/GeneralMods/Revitalize/Framework/Graphics/Animations/Animation.cs index 70c86246..9218b13b 100644 --- a/GeneralMods/Revitalize/Framework/Graphics/Animations/Animation.cs +++ b/GeneralMods/Revitalize/Framework/Graphics/Animations/Animation.cs @@ -1,80 +1,59 @@ -using Microsoft.Xna.Framework; -using Netcode; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Xml.Serialization; +using Microsoft.Xna.Framework; +using Netcode; namespace Revitalize.Framework.Graphics.Animations { - /// - /// A custom class used to deal with custom animations/ - /// - public class Animation + /// A custom class used to deal with custom animations/ + public class Animation { - /// - /// The source rectangle on the texture to display. - /// - public Rectangle sourceRectangle; - /// - /// The duration of the frame in length. - /// - public int frameDuration; - /// - /// The duration until the next frame. - /// - public int frameCountUntilNextAnimation; + /// The source rectangle on the texture to display. + public Rectangle sourceRectangle; - [XmlIgnore] - public NetFields NetFields { get; } = new NetFields(); + /// The duration of the frame in length. + public int frameDuration; + + /// The duration until the next frame. + public int frameCountUntilNextAnimation; + + [XmlIgnore] + public NetFields NetFields { get; } = new NetFields(); public Animation() { - this.sourceRectangle = new Rectangle(0,0,16,16); + this.sourceRectangle = new Rectangle(0, 0, 16, 16); this.frameCountUntilNextAnimation = -1; this.frameDuration = -1; } - /// - /// Constructor that causes the animation frame count to be set to -1; This forces it to never change. - /// + /// Constructor that causes the animation frame count to be set to -1; This forces it to never change. /// The draw source for this animation. public Animation(Rectangle SourceRectangle) { - sourceRectangle = SourceRectangle; + this.sourceRectangle = SourceRectangle; this.frameCountUntilNextAnimation = -1; - frameDuration = -1; + this.frameDuration = -1; } - /// - /// Constructor. - /// + /// Construct an instance. /// The draw source for this animation. /// How many on screen frames this animation stays for. Every draw frame decrements an active animation by 1 frame. Set this to -1 to have it be on the screen infinitely. - public Animation(Rectangle SourceRectangle,int existForXFrames) + public Animation(Rectangle SourceRectangle, int existForXFrames) { - sourceRectangle = SourceRectangle; - frameDuration = existForXFrames; + this.sourceRectangle = SourceRectangle; + this.frameDuration = existForXFrames; } - /// - /// Decrements the amount of frames this animation is on the screen for by 1. - /// + /// Decrements the amount of frames this animation is on the screen for by 1. public void tickAnimationFrame() { - frameCountUntilNextAnimation--; + this.frameCountUntilNextAnimation--; } - /// - /// This sets the animation frame count to be the max duration. I.E restart the timer. - /// + /// This sets the animation frame count to be the max duration. I.E restart the timer. public void startAnimation() { - frameCountUntilNextAnimation = frameDuration; + this.frameCountUntilNextAnimation = this.frameDuration; } - - } } diff --git a/GeneralMods/Revitalize/Framework/Graphics/Animations/AnimationManager.cs b/GeneralMods/Revitalize/Framework/Graphics/Animations/AnimationManager.cs index 4611ceba..dbc1520e 100644 --- a/GeneralMods/Revitalize/Framework/Graphics/Animations/AnimationManager.cs +++ b/GeneralMods/Revitalize/Framework/Graphics/Animations/AnimationManager.cs @@ -1,165 +1,131 @@ -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using StardewModdingAPI; -using StardewValley; using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using StardewValley; namespace Revitalize.Framework.Graphics.Animations { - /// - /// Used to play animations for Stardust.CoreObject type objects and all objects that extend from it. In draw code of object make sure to use this info instead. - /// - public class AnimationManager + /// Used to play animations for Stardust.CoreObject type objects and all objects that extend from it. In draw code of object make sure to use this info instead. + public class AnimationManager { - public Dictionary> animations = new SerializableDictionary>(); - public string currentAnimationName; - public int currentAnimationListIndex; - public List currentAnimationList = new List(); - private Texture2DExtended objectTexture; ///Might not be necessary if I use the CoreObject texture sheet. - public Animation defaultDrawFrame; - public Animation currentAnimation; - public bool enabled; - + public Dictionary> animations = new SerializableDictionary>(); + public string currentAnimationName; + public int currentAnimationListIndex; + public List currentAnimationList = new List(); + private Texture2DExtended objectTexture; ///Might not be necessary if I use the CoreObject texture sheet. + public Animation defaultDrawFrame; + public Animation currentAnimation; + public bool enabled; public string animationDataString; + public bool IsNull => this.defaultDrawFrame == null && this.objectTexture == null; - public bool IsNull - { - get - { - if (this.defaultDrawFrame == null && this.objectTexture == null) return true; - else return false; - } - } - /// - /// Empty constructor. - /// - public AnimationManager() - { - - } + /// Construct an instance. + public AnimationManager() { } - /// - /// Constructor for Animation Manager class. - /// + /// Constructor for Animation Manager class. /// The texture that will be used for the animation. This is typically the same as the object this class is attached to. /// This is used if no animations will be available to the animation manager. /// Whether or not animations play by default. Default value is true. - public AnimationManager (Texture2DExtended ObjectTexture,Animation DefaultFrame, bool EnabledByDefault=true) + public AnimationManager(Texture2DExtended ObjectTexture, Animation DefaultFrame, bool EnabledByDefault = true) { - currentAnimationListIndex = 0; + this.currentAnimationListIndex = 0; this.objectTexture = ObjectTexture; this.defaultDrawFrame = DefaultFrame; this.enabled = EnabledByDefault; - currentAnimation = this.defaultDrawFrame; + this.currentAnimation = this.defaultDrawFrame; this.currentAnimationName = ""; this.animationDataString = ""; } - - public AnimationManager(Texture2DExtended ObjectTexture,Animation DefaultFrame ,string animationString, string startingAnimationKey, int startingAnimationFrame=0,bool EnabledByDefault=true) + + public AnimationManager(Texture2DExtended ObjectTexture, Animation DefaultFrame, string animationString, string startingAnimationKey, int startingAnimationFrame = 0, bool EnabledByDefault = true) { - currentAnimationListIndex = 0; + this.currentAnimationListIndex = 0; this.objectTexture = ObjectTexture; this.defaultDrawFrame = DefaultFrame; this.enabled = EnabledByDefault; this.animationDataString = animationString; this.animations = parseAnimationsFromXNB(animationString); - bool f = animations.TryGetValue(startingAnimationKey, out currentAnimationList); - if (f == true) - { - setAnimation(startingAnimationKey, startingAnimationFrame); - } + if (this.animations.TryGetValue(startingAnimationKey, out this.currentAnimationList)) + this.setAnimation(startingAnimationKey, startingAnimationFrame); else { - currentAnimation = this.defaultDrawFrame; + this.currentAnimation = this.defaultDrawFrame; this.currentAnimationName = ""; } } - public AnimationManager(Texture2DExtended ObjectTexture, Animation DefaultFrame, Dictionary> animationString, string startingAnimationKey, int startingAnimationFrame = 0, bool EnabledByDefault = true) + public AnimationManager(Texture2DExtended ObjectTexture, Animation DefaultFrame, Dictionary> animationString, string startingAnimationKey, int startingAnimationFrame = 0, bool EnabledByDefault = true) { - currentAnimationListIndex = 0; + this.currentAnimationListIndex = 0; this.objectTexture = ObjectTexture; this.defaultDrawFrame = DefaultFrame; this.enabled = EnabledByDefault; this.animations = animationString; - bool f = animations.TryGetValue(startingAnimationKey, out currentAnimationList); - if (f == true) - { - setAnimation(startingAnimationKey, startingAnimationFrame); - } + if (this.animations.TryGetValue(startingAnimationKey, out this.currentAnimationList)) + this.setAnimation(startingAnimationKey, startingAnimationFrame); else { - currentAnimation = this.defaultDrawFrame; + this.currentAnimation = this.defaultDrawFrame; this.currentAnimationName = ""; } } - /// - /// Update the animation frame once after drawing the object. - /// + /// Update the animation frame once after drawing the object. public void tickAnimation() { try { - if (this.currentAnimation.frameDuration == -1 || this.enabled == false || this.currentAnimation == this.defaultDrawFrame) return; //This is if this is a default animation or the animation stops here. - if (this.currentAnimation.frameCountUntilNextAnimation == 0) getNextAnimation(); + if (this.currentAnimation.frameDuration == -1 || !this.enabled || this.currentAnimation == this.defaultDrawFrame) + return; //This is if this is a default animation or the animation stops here. + if (this.currentAnimation.frameCountUntilNextAnimation == 0) + this.getNextAnimation(); this.currentAnimation.tickAnimationFrame(); } - catch(Exception err) + catch (Exception err) { ModCore.ModMonitor.Log("An internal error occured when trying to tick the animation."); ModCore.ModMonitor.Log(err.ToString(), StardewModdingAPI.LogLevel.Error); } } - /// - /// Get the next animation in the list of animations. - /// + /// Get the next animation in the list of animations. public void getNextAnimation() { - currentAnimationListIndex++; - if(currentAnimationListIndex==currentAnimationList.Count) //If the animation frame I'm tryting to get is 1 outside my list length, reset the list. - { - currentAnimationListIndex = 0; - } - - //Get the next animation from the list and reset it's counter to the starting frame value. - this.currentAnimation = currentAnimationList[currentAnimationListIndex]; - this.currentAnimation.startAnimation(); + this.currentAnimationListIndex++; + if (this.currentAnimationListIndex == this.currentAnimationList.Count) //If the animation frame I'm tryting to get is 1 outside my list length, reset the list. + this.currentAnimationListIndex = 0; + + //Get the next animation from the list and reset it's counter to the starting frame value. + this.currentAnimation = this.currentAnimationList[this.currentAnimationListIndex]; + this.currentAnimation.startAnimation(); } - /// - /// Gets the animation from the dictionary of all animations available. - /// + /// Gets the animation from the dictionary of all animations available. /// /// - /// - public bool setAnimation(string AnimationName, int StartingFrame=0) + public bool setAnimation(string AnimationName, int StartingFrame = 0) { - List dummyList = new List(); - bool f = animations.TryGetValue(AnimationName, out dummyList); - if (f == true) + if (this.animations.TryGetValue(AnimationName, out List dummyList)) { - if (dummyList.Count != 0 || StartingFrame>=dummyList.Count) + if (dummyList.Count != 0 || StartingFrame >= dummyList.Count) { - currentAnimationList = dummyList; - currentAnimation = currentAnimationList[StartingFrame]; - currentAnimationName = AnimationName; + this.currentAnimationList = dummyList; + this.currentAnimation = this.currentAnimationList[StartingFrame]; + this.currentAnimationName = AnimationName; return true; } else { - if(dummyList.Count==0) ModCore.ModMonitor.Log("Error: Current animation " + AnimationName+ " has no animation frames associated with it."); - if (dummyList.Count > dummyList.Count) ModCore.ModMonitor.Log("Error: Animation frame "+ StartingFrame+ " is outside the range of provided animations. Which has a maximum count of "+ dummyList.Count); + if (dummyList.Count == 0) + ModCore.ModMonitor.Log("Error: Current animation " + AnimationName + " has no animation frames associated with it."); + if (dummyList.Count > dummyList.Count) + ModCore.ModMonitor.Log("Error: Animation frame " + StartingFrame + " is outside the range of provided animations. Which has a maximum count of " + dummyList.Count); return false; } } @@ -170,17 +136,13 @@ namespace Revitalize.Framework.Graphics.Animations } } - /// - /// Sets the animation manager to an on state, meaning that this animation will update on the draw frame. - /// + /// Sets the animation manager to an on state, meaning that this animation will update on the draw frame. public void enableAnimation() { this.enabled = true; } - /// - /// Sets the animation manager to an off state, meaning that this animation will no longer update on the draw frame. - /// + /// Sets the animation manager to an off state, meaning that this animation will no longer update on the draw frame. public void disableAnimation() { this.enabled = false; @@ -189,28 +151,27 @@ namespace Revitalize.Framework.Graphics.Animations public static Dictionary> parseAnimationsFromXNB(string s) { string[] array = s.Split('*'); - Dictionary> parsedDic = new Dictionary>(); - foreach(var v in array) + Dictionary> parsedDic = new Dictionary>(); + foreach (string v in array) { - // Log.AsyncC(v); - string[] AnimationArray = v.Split(' '); - if (parsedDic.ContainsKey(AnimationArray[0])) + // Log.AsyncC(v); + string[] animationArray = v.Split(' '); + if (parsedDic.ContainsKey(animationArray[0])) { - List aniList = new List(); - aniList = parseAnimationFromString(v); - foreach(var ani in aniList) { - parsedDic[AnimationArray[0]].Add(ani); + List animations = parseAnimationFromString(v); + foreach (var animation in animations) + { + parsedDic[animationArray[0]].Add(animation); } - } else { - parsedDic.Add(AnimationArray[0], new List()); + parsedDic.Add(animationArray[0], new List()); List aniList = new List(); aniList = parseAnimationFromString(v); foreach (var ani in aniList) { - parsedDic[AnimationArray[0]].Add(ani); + parsedDic[animationArray[0]].Add(ani); } } } @@ -219,28 +180,22 @@ namespace Revitalize.Framework.Graphics.Animations public static List parseAnimationFromString(string s) { - List ok = new List(); + List ok = new List(); string[] array2 = s.Split('>'); - foreach(var q in array2) { + foreach (string q in array2) + { string[] array = q.Split(' '); try { Animation ani = new Animation(new Rectangle(Convert.ToInt32(array[1]), Convert.ToInt32(array[2]), Convert.ToInt32(array[3]), Convert.ToInt32(array[4])), Convert.ToInt32(array[5])); - // ModCore.ModMonitor.Log(ani.sourceRectangle.ToString()); + // ModCore.ModMonitor.Log(ani.sourceRectangle.ToString()); ok.Add(ani); } - catch(Exception err) - { - err.ToString(); - continue; - } - + catch { } } return ok; } - /// - /// Used to handle general drawing functionality using the animation manager. - /// + /// Used to handle general drawing functionality using the animation manager. /// We need a spritebatch to draw. /// The texture to draw. /// The onscreen position to draw to. @@ -251,7 +206,7 @@ namespace Revitalize.Framework.Graphics.Animations /// The scale of the texture. /// Effects that get applied to the sprite. /// The dept at which to draw the texture. - public void draw(SpriteBatch spriteBatch,Texture2D texture, Vector2 Position, Rectangle? sourceRectangle,Color drawColor, float rotation, Vector2 origin, float scale,SpriteEffects spriteEffects, float LayerDepth) + public void draw(SpriteBatch spriteBatch, Texture2D texture, Vector2 Position, Rectangle? sourceRectangle, Color drawColor, float rotation, Vector2 origin, float scale, SpriteEffects spriteEffects, float LayerDepth) { //Log.AsyncC("Animation Manager is working!"); spriteBatch.Draw(texture, Position, sourceRectangle, drawColor, rotation, origin, scale, spriteEffects, LayerDepth); @@ -285,6 +240,5 @@ namespace Revitalize.Framework.Graphics.Animations { return this.objectTexture.getTexture(); } - } } diff --git a/GeneralMods/Revitalize/Framework/Graphics/Texture2DExtended.cs b/GeneralMods/Revitalize/Framework/Graphics/Texture2DExtended.cs index 3d316a96..e78447f2 100644 --- a/GeneralMods/Revitalize/Framework/Graphics/Texture2DExtended.cs +++ b/GeneralMods/Revitalize/Framework/Graphics/Texture2DExtended.cs @@ -1,11 +1,6 @@ -using Microsoft.Xna.Framework.Graphics; -using StardewModdingAPI; -using System; -using System.Collections.Generic; using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using Microsoft.Xna.Framework.Graphics; +using StardewModdingAPI; namespace Revitalize.Framework.Graphics { @@ -14,13 +9,11 @@ namespace Revitalize.Framework.Graphics public string Name; public Texture2D texture; public string path; - IModHelper helper; public string modID; public ContentSource source; + private readonly IModHelper helper; - /// - /// Empty/null constructor. - /// + /// Empty/null constructor. public Texture2DExtended() { this.Name = ""; @@ -39,9 +32,7 @@ namespace Revitalize.Framework.Graphics this.modID = ""; } - /// - /// Constructor. - /// + /// Construct an instance. /// The relative path to file on disk. See StardustCore.Utilities.getRelativePath(modname,path); public Texture2DExtended(IModHelper helper, IManifest manifest, string path, ContentSource contentSource = ContentSource.ModFolder) { @@ -73,10 +64,7 @@ namespace Revitalize.Framework.Graphics return this.helper; } - /// - /// Returns the actual 2D texture held by this wrapper class. - /// - /// + /// Returns the actual 2D texture held by this wrapper class. public Texture2D getTexture() { return this.texture; diff --git a/GeneralMods/Revitalize/Framework/Illuminate/ColorExtensions.cs b/GeneralMods/Revitalize/Framework/Illuminate/ColorExtensions.cs index c3a03831..e4e65c52 100644 --- a/GeneralMods/Revitalize/Framework/Illuminate/ColorExtensions.cs +++ b/GeneralMods/Revitalize/Framework/Illuminate/ColorExtensions.cs @@ -1,9 +1,5 @@ -using Microsoft.Xna.Framework; using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using Microsoft.Xna.Framework; namespace Revitalize.Framework.Illuminate { @@ -22,6 +18,5 @@ namespace Revitalize.Framework.Illuminate int b = Math.Abs(255 - color.B); return new Color(r, g, b); } - } } diff --git a/GeneralMods/Revitalize/Framework/Illuminate/LightManager.cs b/GeneralMods/Revitalize/Framework/Illuminate/LightManager.cs index 0dbb3efe..f963d00d 100644 --- a/GeneralMods/Revitalize/Framework/Illuminate/LightManager.cs +++ b/GeneralMods/Revitalize/Framework/Illuminate/LightManager.cs @@ -1,167 +1,112 @@ -using Microsoft.Xna.Framework; -using StardewValley; using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using Microsoft.Xna.Framework; +using StardewValley; namespace Revitalize.Framework.Illuminate { public class LightManager { - public Dictionary lights; + public Dictionary lights; public bool lightsOn; public LightManager() { this.lights = new Dictionary(); - lightsOn = false; + this.lightsOn = false; } - /// - /// Add a light to the list of tracked lights. - /// - /// - /// - /// - /// - public bool addLight(Vector2 IdKey,LightSource light,StardewValley.Object gameObject) + /// Add a light to the list of tracked lights. + public bool addLight(Vector2 IdKey, LightSource light, StardewValley.Object gameObject) { - Vector2 initialPosition = gameObject.TileLocation*Game1.tileSize; + Vector2 initialPosition = gameObject.TileLocation * Game1.tileSize; initialPosition += IdKey; if (this.lights.ContainsKey(IdKey)) - { return false; - } - else - { - light.position.Value = initialPosition; - this.lights.Add(IdKey, light); - return true; - } + + light.position.Value = initialPosition; + this.lights.Add(IdKey, light); + return true; } - /// - /// Turn off a single light. - /// - /// - /// - /// + /// Turn off a single light. public bool turnOffLight(Vector2 IdKey, GameLocation location) { - if (!lights.ContainsKey(IdKey)) - { + if (!this.lights.ContainsKey(IdKey)) return false; - } - else - { - LightSource light = new LightSource(); - this.lights.TryGetValue(IdKey, out light); - Game1.currentLightSources.Remove(light); - location.sharedLights.Remove(light); - return true; - } + + this.lights.TryGetValue(IdKey, out LightSource light); + Game1.currentLightSources.Remove(light); + location.sharedLights.Remove(light); + return true; } - /// - /// Turn on a single light. - /// - /// - /// - /// - public bool turnOnLight(Vector2 IdKey, GameLocation location,StardewValley.Object gameObject) + /// Turn on a single light. + public bool turnOnLight(Vector2 IdKey, GameLocation location, StardewValley.Object gameObject) { - if (!lights.ContainsKey(IdKey)) - { + if (!this.lights.ContainsKey(IdKey)) return false; - } - else - { - LightSource light = new LightSource(); - this.lights.TryGetValue(IdKey, out light); - if (light == null) - { - throw new Exception("Light is null????"); - } - Game1.currentLightSources.Add(light); - if (location == null) - { - throw new Exception("WHY IS LOC NULL???"); - } - if (location.sharedLights == null) - { - throw new Exception("Locational lights is null!"); - - } - Game1.showRedMessage("TURN ON!"); - Game1.currentLightSources.Add(light); - location.sharedLights.Add(light); - repositionLight(light,IdKey,gameObject); - return true; - } + + this.lights.TryGetValue(IdKey, out var light); + if (light == null) + throw new Exception("Light is null????"); + + Game1.currentLightSources.Add(light); + if (location == null) + throw new Exception("WHY IS LOC NULL???"); + + if (location.sharedLights == null) + throw new Exception("Locational lights is null!"); + + Game1.showRedMessage("TURN ON!"); + Game1.currentLightSources.Add(light); + location.sharedLights.Add(light); + this.repositionLight(light, IdKey, gameObject); + return true; } - - - - /// - /// Add a light source to this location. - /// + /// Add a light source to this location. /// The game location to add the light source in. - /// The color of the light to be added - public virtual void turnOnLights(GameLocation environment,StardewValley.Object gameObject) + public virtual void turnOnLights(GameLocation environment, StardewValley.Object gameObject) { - foreach(KeyValuePair pair in this.lights) - { - turnOnLight(pair.Key, environment,gameObject); - } - repositionLights(gameObject); + foreach (KeyValuePair pair in this.lights) + this.turnOnLight(pair.Key, environment, gameObject); + this.repositionLights(gameObject); } - /// - /// Removes a lightsource from the game location. - /// + /// Removes a lightsource from the game location. /// The game location to remove the light source from. public void turnOffLights(GameLocation environment) { foreach (KeyValuePair pair in this.lights) - { - turnOffLight(pair.Key, environment); - } - + this.turnOffLight(pair.Key, environment); } public void repositionLights(StardewValley.Object gameObject) { foreach (KeyValuePair pair in this.lights) - { - repositionLight(pair.Value, pair.Key, gameObject); - } + this.repositionLight(pair.Value, pair.Key, gameObject); } - public void repositionLight(LightSource light,Vector2 offset,StardewValley.Object gameObject) + public void repositionLight(LightSource light, Vector2 offset, StardewValley.Object gameObject) { Vector2 initialPosition = gameObject.TileLocation * Game1.tileSize; light.position.Value = initialPosition + offset; } - public virtual void toggleLights(GameLocation location,StardewValley.Object gameObject) + public virtual void toggleLights(GameLocation location, StardewValley.Object gameObject) { - - if (lightsOn == false) + if (!this.lightsOn) { - this.turnOnLights(location,gameObject); - lightsOn = true; + this.turnOnLights(location, gameObject); + this.lightsOn = true; } - else if (lightsOn == true) + else if (this.lightsOn) { - this.turnOffLights(Game1.player.currentLocation); - lightsOn = false; + this.lightsOn = false; } } - } } diff --git a/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs b/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs index bccfe455..21207f61 100644 --- a/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs +++ b/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs @@ -1,18 +1,14 @@ -using Microsoft.Xna.Framework; +using System; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using PyTK.CustomElementHandler; using Revitalize.Framework.Graphics.Animations; using Revitalize.Framework.Illuminate; using Revitalize.Framework.Utilities; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Revitalize.Framework.Objects { - public class BasicItemInformation: CustomObjectData + public class BasicItemInformation : CustomObjectData { public string name; public string description; @@ -37,14 +33,14 @@ namespace Revitalize.Framework.Objects public LightManager lightManager; - public BasicItemInformation() : base() + public BasicItemInformation() { - name = ""; - description = ""; - categoryName = ""; - categoryColor = new Color(0, 0, 0); - price = 0; - TileLocation = Vector2.Zero; + this.name = ""; + this.description = ""; + this.categoryName = ""; + this.categoryColor = new Color(0, 0, 0); + this.price = 0; + this.TileLocation = Vector2.Zero; this.edibility = -300; this.canBeSetIndoors = false; this.canBeSetOutdoors = false; @@ -56,7 +52,7 @@ namespace Revitalize.Framework.Objects this.lightManager = new LightManager(); } - public BasicItemInformation(string name, string description, string categoryName, Color categoryColor,int edibility,int fragility,bool isLamp,int price, Vector2 TileLocation,bool canBeSetOutdoors,bool canBeSetIndoors,string id, string data, Texture2D texture, Color color,int tileIndex, bool bigCraftable, Type type, CraftingData craftingData, AnimationManager animationManager,Color DrawColor,bool ignoreBoundingBox, InventoryManager Inventory,LightManager Lights):base(id,data,texture,color,tileIndex,bigCraftable,type,craftingData) + public BasicItemInformation(string name, string description, string categoryName, Color categoryColor, int edibility, int fragility, bool isLamp, int price, Vector2 TileLocation, bool canBeSetOutdoors, bool canBeSetIndoors, string id, string data, Texture2D texture, Color color, int tileIndex, bool bigCraftable, Type type, CraftingData craftingData, AnimationManager animationManager, Color drawColor, bool ignoreBoundingBox, InventoryManager Inventory, LightManager Lights) : base(id, data, texture, color, tileIndex, bigCraftable, type, craftingData) { this.name = name; this.description = description; @@ -78,49 +74,19 @@ namespace Revitalize.Framework.Objects this.animationManager.getExtendedTexture().texture = this.texture; } else - { this.texture = this.animationManager.getTexture(); - } this.drawPosition = Vector2.Zero; - - if (DrawColor == null) - { - this.drawColor = Color.White; - } - else - { - this.drawColor = DrawColor; - } - + this.drawColor = drawColor; this.ignoreBoundingBox = ignoreBoundingBox; - - recreateDataString(); - if (Inventory == null) - { - this.inventory = new InventoryManager(); - } - else - { - this.inventory = Inventory; - } - - if (Lights == null) - { - this.lightManager = new LightManager(); - } - else - { - this.lightManager = Lights; - } + this.recreateDataString(); + this.inventory = Inventory ?? new InventoryManager(); + this.lightManager = Lights ?? new LightManager(); } public void recreateDataString() { - this.data=this.name+"/"+this.price+"/"+this.edibility+"/"+"Crafting -9"+"/"+this.description+"/"+this.canBeSetOutdoors+"/"+this.canBeSetIndoors+"/"+this.fragility+"/"+this.isLamp+"/"+this.name; + this.data = $"{this.name}/{this.price}/{this.edibility}/Crafting -9/{this.description}/{this.canBeSetOutdoors}/{this.canBeSetIndoors}/{this.fragility}/{this.isLamp}/{this.name}"; } - - - } } diff --git a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs index 8949ce30..b9c111bb 100644 --- a/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs +++ b/GeneralMods/Revitalize/Framework/Objects/CustomObject.cs @@ -1,111 +1,71 @@ -using Microsoft.Xna.Framework; +using System; +using System.Collections.Generic; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; using PyTK.CustomElementHandler; -using Revitalize.Framework.Graphics; using Revitalize.Framework.Graphics.Animations; using StardewValley; using StardewValley.Objects; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Revitalize.Framework.Objects { - /// - /// A custom object template. - /// - /// Todo: - /// -Multiple Lights - /// -Events when walking over? - /// -Inventories - /// + // TODO: + // -Multiple Lights + // -Events when walking over? + // -Inventories + + /// A custom object template. public class CustomObject : PySObject { public string id; public BasicItemInformation info; public GameLocation location; - /// - /// The animation manager. - /// - public AnimationManager animationManager - { - get - { - return info.animationManager; - } - } + /// The animation manager. + public AnimationManager animationManager => this.info.animationManager; - /// - /// The display texture for this object. - /// - public Texture2D displayTexture - { - get - { - return animationManager.getTexture(); - } - } + /// The display texture for this object. + public Texture2D displayTexture => this.animationManager.getTexture(); - /// - /// Empty constructor. - /// - public CustomObject() - { - - } + /// Empty constructor. + public CustomObject() { } - /// - /// Constructor. - /// - /// - public CustomObject(BasicItemInformation info):base(info,Vector2.Zero) + /// Construct an instance. + public CustomObject(BasicItemInformation info) + : base(info, Vector2.Zero) { this.info = info; this.initializeBasics(); } - /// - /// Constructor. - /// - /// - /// - public CustomObject(BasicItemInformation info,Vector2 TileLocation) : base(info, TileLocation) + /// Construct an instance. + public CustomObject(BasicItemInformation info, Vector2 TileLocation) + : base(info, TileLocation) { this.info = info; this.initializeBasics(); } - /// - /// Sets some basic information up. - /// + /// Sets some basic information up. public virtual void initializeBasics() { - this.name = info.name; - this.displayName = getDisplayNameFromStringsFile(this.id); - this.Edibility = info.edibility; + this.name = this.info.name; + this.displayName = this.getDisplayNameFromStringsFile(this.id); + this.Edibility = this.info.edibility; this.Category = -9; //For crafting. - this.displayName = info.name; + this.displayName = this.info.name; this.setOutdoors.Value = true; this.setIndoors.Value = true; this.isLamp.Value = false; this.fragility.Value = 0; - this.updateDrawPosition(0,0); + this.updateDrawPosition(0, 0); this.bigCraftable.Value = false; - - if (this.info.ignoreBoundingBox) - { - //this.boundingBox.Value = new Rectangle(Int32.MinValue, Int32.MinValue, 0, 0); - } - - + //if (this.info.ignoreBoundingBox) + // this.boundingBox.Value = new Rectangle(int.MinValue, int.MinValue, 0, 0); } public override bool isPassable() @@ -115,56 +75,39 @@ namespace Revitalize.Framework.Objects public override Rectangle getBoundingBox(Vector2 tileLocation) { - if (this.info.ignoreBoundingBox) - { - return new Rectangle(Int32.MinValue, Int32.MinValue, 0, 0); - } - else - { - return base.getBoundingBox(tileLocation); - } + return this.info.ignoreBoundingBox + ? new Rectangle(int.MinValue, int.MinValue, 0, 0) + : base.getBoundingBox(tileLocation); } - /// - /// Checks for interaction with the object. - /// - /// - /// - /// + /// Checks for interaction with the object. public override bool checkForAction(Farmer who, bool justCheckingForActivity = false) { - var mState = Microsoft.Xna.Framework.Input.Mouse.GetState(); - var keyboardState = Game1.GetKeyboardState(); + MouseState mState = Mouse.GetState(); + KeyboardState keyboardState = Game1.GetKeyboardState(); - if (mState.RightButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed && (keyboardState.IsKeyDown(Keys.LeftShift) || keyboardState.IsKeyDown(Keys.RightShift))==false) + if (mState.RightButton == ButtonState.Pressed && (keyboardState.IsKeyDown(Keys.LeftShift) || !keyboardState.IsKeyDown(Keys.RightShift))) { - Revitalize.ModCore.log("Right clicked!"); - return rightClicked(who); - } - else if(mState.RightButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed && (keyboardState.IsKeyDown(Keys.LeftShift) || keyboardState.IsKeyDown(Keys.RightShift))) - { - return shiftRightClicked(who); + ModCore.log("Right clicked!"); + return this.rightClicked(who); } + if (mState.RightButton == ButtonState.Pressed && (keyboardState.IsKeyDown(Keys.LeftShift) || keyboardState.IsKeyDown(Keys.RightShift))) + return this.shiftRightClicked(who); + if (justCheckingForActivity) - { return true; - } - Revitalize.ModCore.log("Left clicked!"); + ModCore.log("Left clicked!"); return this.clicked(who); } public override ICustomObject recreate(Dictionary additionalSaveData, object replacement) { - BasicItemInformation data =(BasicItemInformation) CustomObjectData.collection[additionalSaveData["id"]]; - return new CustomObject((BasicItemInformation) CustomObjectData.collection[additionalSaveData["id"]], (replacement as Chest).TileLocation); + BasicItemInformation data = (BasicItemInformation)CustomObjectData.collection[additionalSaveData["id"]]; + return new CustomObject(data, (replacement as Chest).TileLocation); } - /// - /// What happens when the player right clicks the object. - /// - /// - /// + /// What happens when the player right clicks the object. public virtual bool rightClicked(Farmer who) { // Game1.showRedMessage("YOOO"); @@ -183,42 +126,28 @@ namespace Revitalize.Framework.Objects return true; } - /// - /// What happens when the player shift-right clicks this object. - /// - /// - /// + /// What happens when the player shift-right clicks this object. public virtual bool shiftRightClicked(Farmer who) { - Revitalize.ModCore.log("Shift right clicked!"); + ModCore.log("Shift right clicked!"); return true; } - /// - /// What happens when the player left clicks the object. - /// - /// - /// + /// What happens when the player left clicks the object. public override bool clicked(Farmer who) { - Revitalize.ModCore.log("Clicky click!"); + ModCore.log("Clicky click!"); - Revitalize.ModCore.log(System.Environment.StackTrace); + ModCore.log(System.Environment.StackTrace); - return removeAndAddToPlayersInventory(); + return this.removeAndAddToPlayersInventory(); //return base.clicked(who); } - /// - /// What happens when a player uses a tool on this object. - /// - /// - /// - /// + /// What happens when a player uses a tool on this object. public override bool performToolAction(Tool t, GameLocation location) { - - if(t.GetType()== typeof(StardewValley.Tools.Axe) || t.GetType()== typeof(StardewValley.Tools.Pickaxe)) + if (t.GetType() == typeof(StardewValley.Tools.Axe) || t.GetType() == typeof(StardewValley.Tools.Pickaxe)) { Game1.createItemDebris(this, Game1.player.getStandingPosition(), Game1.player.getDirection()); this.location = null; @@ -232,10 +161,7 @@ namespace Revitalize.Framework.Objects //return base.performToolAction(t, location); } - /// - /// Remove the object from the world and add it to the player's inventory if possible. - /// - /// + /// Remove the object from the world and add it to the player's inventory if possible. public virtual bool removeAndAddToPlayersInventory() { if (Game1.player.isInventoryFull()) @@ -250,102 +176,72 @@ namespace Revitalize.Framework.Objects return true; } - /// - /// Gets the category color for the object. - /// - /// + /// Gets the category color for the object. public override Color getCategoryColor() { - return info.categoryColor; + return this.info.categoryColor; //return data.categoryColor; } - /// - /// Gets the category name for the object. - /// - /// + /// Gets the category name for the object. public override string getCategoryName() { - return info.categoryName; + return this.info.categoryName; } - /// - /// Gets the description for the object. - /// - /// + /// Gets the description for the object. public override string getDescription() { - string text = info.description; + string text = this.info.description; SpriteFont smallFont = Game1.smallFont; int width = Game1.tileSize * 4 + Game1.tileSize / 4; return Game1.parseText(text, smallFont, width); } - /// - /// Places an object down. - /// - /// - /// - /// - /// - /// + /// Places an object down. public override bool placementAction(GameLocation location, int x, int y, Farmer who = null) { - this.updateDrawPosition(x,y); + this.updateDrawPosition(x, y); this.location = location; return base.placementAction(location, x, y, who); } - /// - /// Updates a visual draw position. - /// + /// Updates a visual draw position. public virtual void updateDrawPosition(int x, int y) { this.info.drawPosition = new Vector2((int)(x / Game1.tileSize), (int)(y / Game1.tileSize)); //this.info.drawPosition = new Vector2((float)this.boundingBox.X, (float)(this.boundingBox.Y - (this.animationManager.currentAnimation.sourceRectangle.Height * Game1.pixelZoom - this.boundingBox.Height))); } - /// - /// Gets a clone of the game object. - /// - /// + /// Gets a clone of the game object. public override Item getOne() { return new CustomObject((BasicItemInformation)this.data); } - /// - /// What happens when the object is drawn at a tile location. - /// - /// - /// - /// - /// + /// What happens when the object is drawn at a tile location. public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1f) { if (x <= -1) { - spriteBatch.Draw(this.info.animationManager.getTexture(), Game1.GlobalToLocal(Game1.viewport, this.info.drawPosition), new Rectangle?(this.animationManager.currentAnimation.sourceRectangle), info.drawColor * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, Math.Max(0f, (float)(this.TileLocation.Y*Game1.tileSize) / 10000f)); + spriteBatch.Draw(this.info.animationManager.getTexture(), Game1.GlobalToLocal(Game1.viewport, this.info.drawPosition), new Rectangle?(this.animationManager.currentAnimation.sourceRectangle), this.info.drawColor * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, Math.Max(0f, (float)(this.TileLocation.Y * Game1.tileSize) / 10000f)); } else { //The actual planter box being drawn. - if (animationManager == null) + if (this.animationManager == null) { if (this.animationManager.getExtendedTexture() == null) - { ModCore.ModMonitor.Log("Tex Extended is null???"); - } - - spriteBatch.Draw(this.displayTexture, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(x * Game1.tileSize), y * Game1.tileSize)), new Rectangle?(this.animationManager.currentAnimation.sourceRectangle), info.drawColor * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, Math.Max(0f, (float)(this.TileLocation.Y*Game1.tileSize) / 10000f)); + spriteBatch.Draw(this.displayTexture, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(x * Game1.tileSize), y * Game1.tileSize)), new Rectangle?(this.animationManager.currentAnimation.sourceRectangle), this.info.drawColor * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, Math.Max(0f, (float)(this.TileLocation.Y * Game1.tileSize) / 10000f)); // Log.AsyncG("ANIMATION IS NULL?!?!?!?!"); } else { //Log.AsyncC("Animation Manager is working!"); - this.animationManager.draw(spriteBatch, this.displayTexture, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(x * Game1.tileSize), y * Game1.tileSize)), new Rectangle?(this.animationManager.currentAnimation.sourceRectangle), info.drawColor * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, Math.Max(0f, (float)(this.TileLocation.Y*Game1.tileSize) / 10000f)); + this.animationManager.draw(spriteBatch, this.displayTexture, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(x * Game1.tileSize), y * Game1.tileSize)), new Rectangle?(this.animationManager.currentAnimation.sourceRectangle), this.info.drawColor * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, Math.Max(0f, (float)(this.TileLocation.Y * Game1.tileSize) / 10000f)); try { this.animationManager.tickAnimation(); @@ -358,23 +254,12 @@ namespace Revitalize.Framework.Objects } // spriteBatch.Draw(Game1.mouseCursors, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)((double)tileLocation.X * (double)Game1.tileSize + (((double)tileLocation.X * 11.0 + (double)tileLocation.Y * 7.0) % 10.0 - 5.0)) + (float)(Game1.tileSize / 2), (float)((double)tileLocation.Y * (double)Game1.tileSize + (((double)tileLocation.Y * 11.0 + (double)tileLocation.X * 7.0) % 10.0 - 5.0)) + (float)(Game1.tileSize / 2))), new Rectangle?(new Rectangle((int)((double)tileLocation.X * 51.0 + (double)tileLocation.Y * 77.0) % 3 * 16, 128 + this.whichForageCrop * 16, 16, 16)), Color.White, 0.0f, new Vector2(8f, 8f), (float)Game1.pixelZoom, SpriteEffects.None, (float)(((double)tileLocation.Y * (double)Game1.tileSize + (double)(Game1.tileSize / 2) + (((double)tileLocation.Y * 11.0 + (double)tileLocation.X * 7.0) % 10.0 - 5.0)) / 10000.0)); - - - } } - /// - /// Draw the game object at a non-tile spot. Aka like debris. - /// - /// - /// - /// - /// - /// + /// Draw the game object at a non-tile spot. Aka like debris. public override void draw(SpriteBatch spriteBatch, int xNonTile, int yNonTile, float layerDepth, float alpha = 1f) { - if (Game1.eventUp && Game1.CurrentEvent.isTileWalkedOn(xNonTile / 64, yNonTile / 64)) return; if ((int)(this.ParentSheetIndex) != 590 && (int)(this.Fragility) != 2) @@ -391,33 +276,10 @@ namespace Revitalize.Framework.Objects int num3 = (bool)(this.flipped) ? 1 : 0; double num4 = (double)layerDepth; - spriteBatch1.Draw(this.displayTexture, local, this.animationManager.defaultDrawFrame.sourceRectangle, info.drawColor*alpha, (float)num1, origin, (float)4f, (SpriteEffects)num3, (float)num4); - + spriteBatch1.Draw(this.displayTexture, local, this.animationManager.defaultDrawFrame.sourceRectangle, this.info.drawColor * alpha, (float)num1, origin, (float)4f, (SpriteEffects)num3, (float)num4); } - - - public override void drawAsProp(SpriteBatch b) - { - base.drawAsProp(b); - } - - public override void drawAttachments(SpriteBatch b, int x, int y) - { - base.drawAttachments(b, x, y); - } - - /// - /// What happens when the object is drawn in a menu. - /// - /// - /// - /// - /// - /// - /// - /// - /// + /// What happens when the object is drawn in a menu. public override void drawInMenu(SpriteBatch spriteBatch, Vector2 location, float scaleSize, float transparency, float layerDepth, bool drawStackNumber, Color c, bool drawShadow) { if (drawStackNumber && this.maximumStackSize() > 1 && ((double)scaleSize > 0.3 && this.Stack != int.MaxValue) && this.Stack > 1) @@ -427,30 +289,19 @@ namespace Revitalize.Framework.Objects float num = this.Quality < 4 ? 0.0f : (float)((Math.Cos((double)Game1.currentGameTime.TotalGameTime.Milliseconds * Math.PI / 512.0) + 1.0) * 0.0500000007450581); spriteBatch.Draw(Game1.mouseCursors, location + new Vector2(12f, (float)(Game1.tileSize - 12) + num), new Microsoft.Xna.Framework.Rectangle?(this.Quality < 4 ? new Microsoft.Xna.Framework.Rectangle(338 + (this.Quality - 1) * 8, 400, 8, 8) : new Microsoft.Xna.Framework.Rectangle(346, 392, 8, 8)), Color.White * transparency, 0.0f, new Vector2(4f, 4f), (float)(3.0 * (double)scaleSize * (1.0 + (double)num)), SpriteEffects.None, layerDepth); } - spriteBatch.Draw(this.displayTexture, location + new Vector2((float)(Game1.tileSize/2), (float)(Game1.tileSize*.75)), new Rectangle?(this.animationManager.currentAnimation.sourceRectangle), info.drawColor*transparency, 0f, new Vector2((float)(this.animationManager.currentAnimation.sourceRectangle.Width / 2), (float)(this.animationManager.currentAnimation.sourceRectangle.Height)), 3f, SpriteEffects.None, layerDepth); + spriteBatch.Draw(this.displayTexture, location + new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize * .75)), new Rectangle?(this.animationManager.currentAnimation.sourceRectangle), this.info.drawColor * transparency, 0f, new Vector2((float)(this.animationManager.currentAnimation.sourceRectangle.Width / 2), (float)(this.animationManager.currentAnimation.sourceRectangle.Height)), 3f, SpriteEffects.None, layerDepth); } - public override void drawPlacementBounds(SpriteBatch spriteBatch, GameLocation location) - { - base.drawPlacementBounds(spriteBatch, location); - } - - - /// - /// What happens when the object is drawn when held by a player. - /// - /// - /// - /// + /// What happens when the object is drawn when held by a player. public override void drawWhenHeld(SpriteBatch spriteBatch, Vector2 objectPosition, StardewValley.Farmer f) { if (f.ActiveObject.bigCraftable.Value) { - spriteBatch.Draw(this.displayTexture, objectPosition, this.animationManager.currentAnimation.sourceRectangle, info.drawColor, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, Math.Max(0f, (float)(f.getStandingY() + 2) / 10000f)); + spriteBatch.Draw(this.displayTexture, objectPosition, this.animationManager.currentAnimation.sourceRectangle, this.info.drawColor, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, Math.Max(0f, (float)(f.getStandingY() + 2) / 10000f)); return; } - spriteBatch.Draw(this.displayTexture, objectPosition, this.animationManager.currentAnimation.sourceRectangle, info.drawColor, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, Math.Max(0f, (float)(f.getStandingY() + 2) / 10000f)); + spriteBatch.Draw(this.displayTexture, objectPosition, this.animationManager.currentAnimation.sourceRectangle, this.info.drawColor, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, Math.Max(0f, (float)(f.getStandingY() + 2) / 10000f)); if (f.ActiveObject != null && f.ActiveObject.Name.Contains("=")) { spriteBatch.Draw(this.displayTexture, objectPosition + new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize / 2)), this.animationManager.currentAnimation.sourceRectangle, Color.White, 0f, new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize / 2)), (float)Game1.pixelZoom + Math.Abs(Game1.starCropShimmerPause) / 8f, SpriteEffects.None, Math.Max(0f, (float)(f.getStandingY() + 2) / 10000f)); @@ -467,12 +318,10 @@ namespace Revitalize.Framework.Objects //base.drawWhenHeld(spriteBatch, objectPosition, f); } - public string getDisplayNameFromStringsFile(string objectID) { //Load in a file that has all object names referenced here or something. - return info.name; + return this.info.name; } - } } diff --git a/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs b/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs index a59ee09a..5a1928ca 100644 --- a/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs +++ b/GeneralMods/Revitalize/Framework/Objects/MultiTiledComponent.cs @@ -1,46 +1,32 @@ -using Microsoft.Xna.Framework; +using System; +using System.Collections.Generic; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using PyTK.CustomElementHandler; using StardewValley; using StardewValley.Objects; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Revitalize.Framework.Objects { - public class MultiTiledComponent:CustomObject + public class MultiTiledComponent : CustomObject { - public MultiTiledObject containerObject; - public MultiTiledComponent():base() - { + public MultiTiledComponent() { } - } + public MultiTiledComponent(BasicItemInformation info) : base(info) { } - public MultiTiledComponent(BasicItemInformation info):base(info) - { - - } - - public MultiTiledComponent(BasicItemInformation info, Vector2 TileLocation): base(info, TileLocation) - { - - } + public MultiTiledComponent(BasicItemInformation info, Vector2 TileLocation) : base(info, TileLocation) { } public override bool checkForAction(Farmer who, bool justCheckingForActivity = false) { - //Revitalize.ModCore.log("Checking for a clicky click???"); + //ModCore.log("Checking for a clicky click???"); return base.checkForAction(who, justCheckingForActivity); } public override bool clicked(Farmer who) { - - Revitalize.ModCore.log("Clicked a multiTiledComponent!"); + ModCore.log("Clicked a multiTiledComponent!"); this.containerObject.pickUp(); return true; //return base.clicked(who); @@ -49,12 +35,10 @@ namespace Revitalize.Framework.Objects public override bool rightClicked(Farmer who) { if (this.location == null) - { this.location = Game1.player.currentLocation; - } this.info.lightManager.toggleLights(this.location, this); - Revitalize.ModCore.playerInfo.sittingInfo.sit(this, Vector2.Zero); + ModCore.playerInfo.sittingInfo.sit(this, Vector2.Zero); return true; } @@ -67,25 +51,18 @@ namespace Revitalize.Framework.Objects base.performRemoveAction(this.TileLocation, environment); } - public virtual void removeFromLocation(GameLocation location,Vector2 offset) + public virtual void removeFromLocation(GameLocation location, Vector2 offset) { - location.removeObject(this.TileLocation,false); + location.removeObject(this.TileLocation, false); this.location = null; //this.performRemoveAction(this.TileLocation,location); } - /// - /// Places an object down. - /// - /// - /// - /// - /// - /// + /// Places an object down. public override bool placementAction(GameLocation location, int x, int y, Farmer who = null) { - Revitalize.ModCore.ModMonitor.Log("SCREAMING!!!!"); - this.updateDrawPosition(x,y); + ModCore.ModMonitor.Log("SCREAMING!!!!"); + this.updateDrawPosition(x, y); this.location = location; if (this.location == null) this.location = Game1.player.currentLocation; @@ -103,24 +80,23 @@ namespace Revitalize.Framework.Objects float num = this.Quality < 4 ? 0.0f : (float)((Math.Cos((double)Game1.currentGameTime.TotalGameTime.Milliseconds * Math.PI / 512.0) + 1.0) * 0.0500000007450581); spriteBatch.Draw(Game1.mouseCursors, location + new Vector2(12f, (float)(Game1.tileSize - 12) + num), new Microsoft.Xna.Framework.Rectangle?(this.Quality < 4 ? new Microsoft.Xna.Framework.Rectangle(338 + (this.Quality - 1) * 8, 400, 8, 8) : new Microsoft.Xna.Framework.Rectangle(346, 392, 8, 8)), Color.White * transparency, 0.0f, new Vector2(4f, 4f), (float)(3.0 * (double)scaleSize * (1.0 + (double)num)), SpriteEffects.None, layerDepth); } - spriteBatch.Draw(this.displayTexture, location + new Vector2((float)(Game1.tileSize / 4), (float)(Game1.tileSize * .75)), new Rectangle?(this.animationManager.currentAnimation.sourceRectangle), info.drawColor * transparency, 0f, new Vector2((float)(this.animationManager.currentAnimation.sourceRectangle.Width / 2), (float)(this.animationManager.currentAnimation.sourceRectangle.Height)), scaleSize, SpriteEffects.None, layerDepth); + spriteBatch.Draw(this.displayTexture, location + new Vector2((float)(Game1.tileSize / 4), (float)(Game1.tileSize * .75)), new Rectangle?(this.animationManager.currentAnimation.sourceRectangle), this.info.drawColor * transparency, 0f, new Vector2((float)(this.animationManager.currentAnimation.sourceRectangle.Width / 2), (float)(this.animationManager.currentAnimation.sourceRectangle.Height)), scaleSize, SpriteEffects.None, layerDepth); } public override Item getOne() { - MultiTiledComponent component=new MultiTiledComponent(this.info, this.TileLocation); + MultiTiledComponent component = new MultiTiledComponent(this.info, this.TileLocation); component.containerObject = this.containerObject; return component; - } public override ICustomObject recreate(Dictionary additionalSaveData, object replacement) { BasicItemInformation data = (BasicItemInformation)CustomObjectData.collection[additionalSaveData["id"]]; - MultiTiledComponent component= new MultiTiledComponent((BasicItemInformation)CustomObjectData.collection[additionalSaveData["id"]], (replacement as Chest).TileLocation); - component.containerObject = this.containerObject; - return containerObject; + return new MultiTiledComponent(data, (replacement as Chest).TileLocation) + { + containerObject = this.containerObject + }; } - } } diff --git a/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs b/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs index bc30ba63..056825e6 100644 --- a/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs +++ b/GeneralMods/Revitalize/Framework/Objects/MultiTiledObject.cs @@ -1,42 +1,40 @@ -using Microsoft.Xna.Framework; +using System.Collections.Generic; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using PyTK.CustomElementHandler; using StardewValley; using StardewValley.Objects; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Revitalize.Framework.Objects { - public class MultiTiledObject:CustomObject + public class MultiTiledObject : CustomObject { public Dictionary objects; - public MultiTiledObject() : base() - { - - this.objects = new Dictionary(); - } - - public MultiTiledObject(BasicItemInformation info) : base(info) + public MultiTiledObject() { this.objects = new Dictionary(); } - public MultiTiledObject(BasicItemInformation info, Vector2 TileLocation) : base(info, TileLocation) + public MultiTiledObject(BasicItemInformation info) + : base(info) { this.objects = new Dictionary(); } - public MultiTiledObject(BasicItemInformation info, Vector2 TileLocation, Dictionary ObjectsList) : base(info, TileLocation) + public MultiTiledObject(BasicItemInformation info, Vector2 TileLocation) + : base(info, TileLocation) { this.objects = new Dictionary(); - foreach(var v in ObjectsList) + } + + public MultiTiledObject(BasicItemInformation info, Vector2 TileLocation, Dictionary ObjectsList) + : base(info, TileLocation) + { + this.objects = new Dictionary(); + foreach (var v in ObjectsList) { - MultiTiledComponent component =(MultiTiledComponent)v.Value.getOne(); + MultiTiledComponent component = (MultiTiledComponent)v.Value.getOne(); this.addComponent(v.Key, component); } } @@ -44,102 +42,64 @@ namespace Revitalize.Framework.Objects public bool addComponent(Vector2 key, MultiTiledComponent obj) { if (this.objects.ContainsKey(key)) - { return false; - } - else - { - this.objects.Add(key, obj); - obj.containerObject = this; - return true; - } + + this.objects.Add(key, obj); + obj.containerObject = this; + return true; } public bool removeComponent(Vector2 key) { if (!this.objects.ContainsKey(key)) - { return false; - } - else - { - this.objects.Remove(key); - return true; - } + + this.objects.Remove(key); + return true; } public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1) { foreach (KeyValuePair pair in this.objects) - { pair.Value.draw(spriteBatch, x + (int)pair.Key.X * Game1.tileSize, y + (int)pair.Key.Y * Game1.tileSize, alpha); - } } public override void draw(SpriteBatch spriteBatch, int xNonTile, int yNonTile, float layerDepth, float alpha = 1) { foreach (KeyValuePair pair in this.objects) - { - pair.Value.draw(spriteBatch, xNonTile + (int)pair.Key.X * Game1.tileSize, yNonTile+ (int)pair.Key.Y * Game1.tileSize, layerDepth, alpha); - } + pair.Value.draw(spriteBatch, xNonTile + (int)pair.Key.X * Game1.tileSize, yNonTile + (int)pair.Key.Y * Game1.tileSize, layerDepth, alpha); //base.draw(spriteBatch, xNonTile, yNonTile, layerDepth, alpha); } - public override void drawAsProp(SpriteBatch b) - { - base.drawAsProp(b); - } - - public override void drawAttachments(SpriteBatch b, int x, int y) - { - base.drawAttachments(b, x, y); - } - public override void drawInMenu(SpriteBatch spriteBatch, Vector2 location, float scaleSize, float transparency, float layerDepth, bool drawStackNumber, Color c, bool drawShadow) { foreach (KeyValuePair pair in this.objects) - { - pair.Value.drawInMenu(spriteBatch, location + (pair.Key*16), 1.0f, transparency, layerDepth, drawStackNumber, c, drawShadow); - } - //base.drawInMenu(spriteBatch, location, scaleSize, transparency, layerDepth, drawStackNumber, c, drawShadow); - } - - public override void drawPlacementBounds(SpriteBatch spriteBatch, GameLocation location) - { - base.drawPlacementBounds(spriteBatch, location); + pair.Value.drawInMenu(spriteBatch, location + (pair.Key * 16), 1.0f, transparency, layerDepth, drawStackNumber, c, drawShadow); + //base.drawInMenu(spriteBatch, location, scaleSize, transparency, layerDepth, drawStackNumber, c, drawShadow); } public override void drawWhenHeld(SpriteBatch spriteBatch, Vector2 objectPosition, Farmer f) { - - foreach(KeyValuePair pair in this.objects) - { + foreach (KeyValuePair pair in this.objects) pair.Value.drawWhenHeld(spriteBatch, objectPosition + (pair.Key * Game1.tileSize), f); - } //base.drawWhenHeld(spriteBatch, objectPosition, f); } - - //IMPLEMENT THESE! public virtual void pickUp() { - bool canPickUp= this.removeAndAddToPlayersInventory(); + bool canPickUp = this.removeAndAddToPlayersInventory(); if (canPickUp) { foreach (KeyValuePair pair in this.objects) - { - pair.Value.removeFromLocation(pair.Value.location,pair.Key); - } + pair.Value.removeFromLocation(pair.Value.location, pair.Key); this.location = null; } else - { Game1.showRedMessage("NOOOOOOOO"); - } } public override bool removeAndAddToPlayersInventory() @@ -155,11 +115,10 @@ namespace Revitalize.Framework.Objects public override bool placementAction(GameLocation location, int x, int y, Farmer who = null) { - - foreach(KeyValuePair pair in this.objects) - { - pair.Value.placementAction(location, x + (int)pair.Key.X*Game1.tileSize, y + (int)pair.Key.Y*Game1.tileSize, who); - Revitalize.ModCore.log(pair.Value.TileLocation); + foreach (KeyValuePair pair in this.objects) + { + pair.Value.placementAction(location, x + (int)pair.Key.X * Game1.tileSize, y + (int)pair.Key.Y * Game1.tileSize, who); + ModCore.log(pair.Value.TileLocation); } this.location = location; return true; @@ -168,21 +127,20 @@ namespace Revitalize.Framework.Objects public override bool canBePlacedHere(GameLocation l, Vector2 tile) { - foreach(KeyValuePair pair in this.objects) + foreach (KeyValuePair pair in this.objects) { - if (pair.Value.canBePlacedHere(l, tile + pair.Key) == false) return false; + if (!pair.Value.canBePlacedHere(l, tile + pair.Key)) + return false; } return true; } public override bool clicked(Farmer who) { - Revitalize.ModCore.log("WTF IS HAPPENING???"); - bool cleanUp=clicked(who); + ModCore.log("WTF IS HAPPENING???"); + bool cleanUp = this.clicked(who); if (cleanUp) - { - pickUp(); - } + this.pickUp(); return cleanUp; } @@ -204,13 +162,13 @@ namespace Revitalize.Framework.Objects public override Item getOne() { - return new MultiTiledObject(this.info, this.TileLocation,this.objects); + return new MultiTiledObject(this.info, this.TileLocation, this.objects); } public override ICustomObject recreate(Dictionary additionalSaveData, object replacement) { BasicItemInformation data = (BasicItemInformation)CustomObjectData.collection[additionalSaveData["id"]]; - return new MultiTiledObject((BasicItemInformation)CustomObjectData.collection[additionalSaveData["id"]], (replacement as Chest).TileLocation,this.objects); + return new MultiTiledObject(data, (replacement as Chest).TileLocation, this.objects); } } } diff --git a/GeneralMods/Revitalize/Framework/Player/Managers/SittingInfo.cs b/GeneralMods/Revitalize/Framework/Player/Managers/SittingInfo.cs index ef668982..3e429060 100644 --- a/GeneralMods/Revitalize/Framework/Player/Managers/SittingInfo.cs +++ b/GeneralMods/Revitalize/Framework/Player/Managers/SittingInfo.cs @@ -1,100 +1,61 @@ -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using StardewValley; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Revitalize.Framework.Player.Managers { - /// - /// TODO: - /// Make chair - /// animate player better - /// have it where when player is sitting on chair it is passable so it can't be destoryed underneath - /// + // TODO: + // - Make chair + // - animate player better + // - have it where when player is sitting on chair it is passable so it can't be destoryed underneath public class SittingInfo { - /// - /// If the player is currently sitting. - /// + /// If the player is currently sitting. public bool isSitting; - /// - /// How long a Farmer has sat (in milliseconds) - /// + /// How long a Farmer has sat (in milliseconds) private int elapsedTime; - /// - /// Gets how long the farmer has sat (in milliseconds). - /// - public int ElapsedTime - { - get - { - return elapsedTime; - } - } + /// Gets how long the farmer has sat (in milliseconds). + public int ElapsedTime => this.elapsedTime; - /// - /// Keeps trck of time elapsed. - /// + /// Keeps trck of time elapsed. GameTime timer; + + /// How long a player has to sit to recover energy/health; + public int SittingSpan { get; } - /// - /// The default amount of time a player has to sit to recover some energy/health - /// - private int _sittingSpan; - /// - /// A modified version of how long a player has to sit to recover energy/health; - /// - public int SittingSpan - { - get - { - return _sittingSpan; - } - } - - - - /// - /// Constructor. - /// + /// Construct an instance. public SittingInfo() { - timer = Game1.currentGameTime; - this._sittingSpan = 10000; + this.timer = Game1.currentGameTime; + this.SittingSpan = 10000; } - /// - /// Update the sitting info. - /// + /// Update the sitting info. public void update() { if (Game1.activeClickableMenu != null) return; if (Game1.player.isMoving()) { - isSitting = false; - elapsedTime = 0; + this.isSitting = false; + this.elapsedTime = 0; } - if (isSitting && Game1.player.CanMove) + if (this.isSitting && Game1.player.CanMove) { - showSitting(); - if (timer == null) timer = Game1.currentGameTime; - elapsedTime += timer.ElapsedGameTime.Milliseconds; + this.showSitting(); + if (this.timer == null) this.timer = Game1.currentGameTime; + this.elapsedTime += this.timer.ElapsedGameTime.Milliseconds; } - if (elapsedTime >= SittingSpan) + if (this.elapsedTime >= this.SittingSpan) { - elapsedTime %= SittingSpan; + this.elapsedTime %= this.SittingSpan; Game1.player.health++; Game1.player.Stamina++; } - Revitalize.ModCore.log(elapsedTime); + ModCore.log(this.elapsedTime); } @@ -103,26 +64,25 @@ namespace Revitalize.Framework.Player.Managers switch (Game1.player.FacingDirection) { case 0: - Game1.player.FarmerSprite.setCurrentSingleFrame(113, (short)32000, false, false); + Game1.player.FarmerSprite.setCurrentSingleFrame(113); break; case 1: - Game1.player.FarmerSprite.setCurrentSingleFrame(106, (short)32000, false, false); + Game1.player.FarmerSprite.setCurrentSingleFrame(106); break; case 2: - Game1.player.FarmerSprite.setCurrentSingleFrame(107, (short)32000, false, false); + Game1.player.FarmerSprite.setCurrentSingleFrame(107); break; case 3: - Game1.player.FarmerSprite.setCurrentSingleFrame(106, (short)32000, false, true); + Game1.player.FarmerSprite.setCurrentSingleFrame(106); break; } } - public void sit(StardewValley.Object obj,Vector2 offset) + public void sit(StardewValley.Object obj, Vector2 offset) { this.isSitting = true; Game1.player.Position = (obj.TileLocation * Game1.tileSize + offset); - Game1.player.position.Y += Game1.tileSize/2; + Game1.player.position.Y += Game1.tileSize / 2; } - } } diff --git a/GeneralMods/Revitalize/Framework/Player/PlayerInfo.cs b/GeneralMods/Revitalize/Framework/Player/PlayerInfo.cs index efde5463..3c0dc322 100644 --- a/GeneralMods/Revitalize/Framework/Player/PlayerInfo.cs +++ b/GeneralMods/Revitalize/Framework/Player/PlayerInfo.cs @@ -1,11 +1,4 @@ -using Microsoft.Xna.Framework; using Revitalize.Framework.Player.Managers; -using StardewValley; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Revitalize.Framework.Player { @@ -15,13 +8,12 @@ namespace Revitalize.Framework.Player public PlayerInfo() { - sittingInfo = new SittingInfo(); + this.sittingInfo = new SittingInfo(); } - public void update() { - sittingInfo.update(); + this.sittingInfo.update(); } } } diff --git a/GeneralMods/Revitalize/Framework/Utilities/InventoryManager.cs b/GeneralMods/Revitalize/Framework/Utilities/InventoryManager.cs index 2816519c..1265d65d 100644 --- a/GeneralMods/Revitalize/Framework/Utilities/InventoryManager.cs +++ b/GeneralMods/Revitalize/Framework/Utilities/InventoryManager.cs @@ -1,223 +1,132 @@ -using StardewValley; -using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using StardewValley; namespace Revitalize.Framework.Utilities { - /// - /// Handles dealing with objects. - /// + /// Handles dealing with objects. public class InventoryManager { - /// - /// How many items the inventory can hold. - /// + /// How many items the inventory can hold. public int capacity; - /// - /// The hard uper limit in case of upgrading or resizing. - /// - private int maxCapacity; + /// The hard uper limit for # of items to be held in case of upgrading or resizing. + public int MaxCapacity { get; private set; } - /// - /// The hard uper limit for # of items to be held in case of upgrading or resizing. - /// - public int MaxCapacity - { - get - { - return maxCapacity; - } - } + /// How many items are currently stored in the inventory. + public int ItemCount => this.items.Count; - /// - /// How many items are currently stored in the inventory. - /// - public int ItemCount - { - get - { - return this.items.Count; - } - } - - /// - /// The actual contents of the inventory. - /// + /// The actual contents of the inventory. public List items; - /// - /// Checks if the inventory is full or not. - /// - public bool IsFull - { - get - { - return this.ItemCount >= this.capacity; - } - } + /// Checks if the inventory is full or not. + public bool IsFull => this.ItemCount >= this.capacity; - /// - /// Checks to see if this core object actually has a valid inventory. - /// - public bool HasInventory - { - get - { - if (this.capacity <= 0) return false; - return true; - } - } + /// Checks to see if this core object actually has a valid inventory. + public bool HasInventory => this.capacity > 0; public InventoryManager() { this.capacity = 0; - setMaxLimit(0); + this.setMaxLimit(0); this.items = new List(); } - /// - /// Constructor. - /// - /// + /// Construct an instance. public InventoryManager(List items) { - this.capacity = Int32.MaxValue; - this.setMaxLimit(Int32.MaxValue); + this.capacity = int.MaxValue; + this.setMaxLimit(int.MaxValue); this.items = items; } - /// - /// Constructor. - /// - /// + /// Construct an instance. public InventoryManager(int capacity) { this.capacity = capacity; - this.maxCapacity = Int32.MaxValue; + this.MaxCapacity = int.MaxValue; this.items = new List(); } - /// - /// Constructor. - /// - /// - /// + /// Construct an instance. public InventoryManager(int capacity, int MaxCapacity) { this.capacity = capacity; - setMaxLimit(MaxCapacity); + this.setMaxLimit(MaxCapacity); this.items = new List(); } - /// - /// Add the item to the inventory. - /// - /// - /// - public bool addItem(Item I) + /// Add the item to the inventory. + public bool addItem(Item item) { - if (IsFull) + if (this.IsFull) { return false; } else { - foreach(Item self in this.items) + foreach (Item self in this.items) { - if (self == null) continue; - if (self.canStackWith(I)) + if (self != null && self.canStackWith(item)) { - self.addToStack(I.Stack); + self.addToStack(item.Stack); return true; } } - this.items.Add(I); + this.items.Add(item); return true; } } - /// - /// Gets a reference to the object IF it exists in the inventory. - /// - /// - /// - public Item getItem(Item I) + /// Gets a reference to the object IF it exists in the inventory. + public Item getItem(Item item) { - foreach(Item i in this.items) + foreach (Item i in this.items) { - if (I == i) return I; + if (item == i) + return item; } return null; } - /// - /// Get the item at the specific index. - /// - /// - /// - public Item getItemAtIndex(int Index) + /// Get the item at the specific index. + public Item getItemAtIndex(int index) { - return items[Index]; + return this.items[index]; } - /// - /// Gets only one item from the stack. - /// - /// - /// - public Item getSingleItemFromStack(Item I) + /// Gets only one item from the stack. + public Item getSingleItemFromStack(Item item) { - if (I.Stack == 1) - { - return I; - } - else - { - I.Stack = I.Stack - 1; - return I.getOne(); - } + if (item.Stack == 1) + return item; + + item.Stack = item.Stack - 1; + return item.getOne(); } - /// - /// Empty the inventory. - /// + /// Empty the inventory. public void clear() { this.items.Clear(); } - /// - /// Empty the inventory. - /// + /// Empty the inventory. public void empty() { this.clear(); } - /// - /// Resize how many items can be held by this object. - /// - /// + /// Resize how many items can be held by this object. public void resizeCapacity(int Amount) { - if (this.capacity + Amount < this.maxCapacity) - { + if (this.capacity + Amount < this.MaxCapacity) this.capacity += Amount; - } } - /// - /// Sets the upper limity of the capacity size for the inventory. - /// - /// + /// Sets the upper limity of the capacity size for the inventory. public void setMaxLimit(int amount) { - this.maxCapacity = amount; + this.MaxCapacity = amount; } - } } diff --git a/GeneralMods/Revitalize/ModCore.cs b/GeneralMods/Revitalize/ModCore.cs index c1858c8b..f0a63dfa 100644 --- a/GeneralMods/Revitalize/ModCore.cs +++ b/GeneralMods/Revitalize/ModCore.cs @@ -1,86 +1,79 @@ -using Microsoft.Xna.Framework; -using PyTK.Types; -using PyTK.Extensions; -using Revitalize.Framework.Objects; -using StardewModdingAPI; -using StardewValley; -using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.IO; +using Microsoft.Xna.Framework; +using PyTK.Extensions; +using PyTK.Types; +using Revitalize.Framework.Crafting; +using Revitalize.Framework.Environment; using Revitalize.Framework.Graphics; using Revitalize.Framework.Graphics.Animations; -using Revitalize.Framework.Environment; -using System.IO; -using Revitalize.Framework.Crafting; -using StardewValley.Objects; using Revitalize.Framework.Illuminate; +using Revitalize.Framework.Objects; using Revitalize.Framework.Player; +using StardewModdingAPI; +using StardewValley; +using StardewValley.Objects; namespace Revitalize { - - /* - * Todo: - * -Multiple Lights On Object - * -Illumination Colors - * Furniture: - * -rugs - * -tables - * -lamps - * -chairs - * -dressers/other storage containers - * -fun interactables - * -More crafting tables - * -Machines - * !=Energy - * -Furnace - * -Seed Maker - * -Stone Quarry - * -Materials - * -Tin/Bronze/Alluminum/Silver?Platinum/Etc - * -Crafting Menu - * -Item Grab Menu (Extendable) - * -Gift Boxes - * Magic! - * -Alchemy Bags - * -Transmutation - * -Effect Crystals - * -Spell books - * -Potions! - * -Magic Meter - * Festivals - * -Firework festival? - * Stargazing??? - * -Moon Phases+DarkerNight - * Bigger/Better Museum? - * More Crops? - * More Food? - * - * Equippables! - * -accessories that provide buffs/regen/friendship - * - * Music??? - * -IDK maybe add in instruments??? - * - * More buildings???? - * - * More Animals??? - * - * Readable Books? - * - * Custom NPCs for shops??? - * - * Frisbee Minigame? - * - * HorseRace Minigame/Betting? - * - * Locations: - * -Small Island Home? - * - * More crops - */ + // TODO: + // -Multiple Lights On Object + // -Illumination Colors + // Furniture: + // -rugs + // -tables + // -lamps + // -chairs + // -dressers/other storage containers + // -fun interactables + // -More crafting tables + // -Machines + // !=Energy + // -Furnace + // -Seed Maker + // -Stone Quarry + // -Materials + // -Tin/Bronze/Alluminum/Silver?Platinum/Etc + // -Crafting Menu + // -Item Grab Menu (Extendable) + // -Gift Boxes + // Magic! + // -Alchemy Bags + // -Transmutation + // -Effect Crystals + // -Spell books + // -Potions! + // -Magic Meter + // Festivals + // -Firework festival? + // Stargazing??? + // -Moon Phases+DarkerNight + // Bigger/Better Museum? + // More Crops? + // More Food? + // + // Equippables! + // -accessories that provide buffs/regen/friendship + // + // Music??? + // -IDK maybe add in instruments??? + // + // More buildings???? + // + // More Animals??? + // + // Readable Books? + // + // Custom NPCs for shops??? + // + // Frisbee Minigame? + // + // HorseRace Minigame/Betting? + // + // Locations: + // -Small Island Home? + // + // More crops public class ModCore : Mod { @@ -94,19 +87,17 @@ namespace Revitalize public override void Entry(IModHelper helper) { ModHelper = helper; - ModMonitor = Monitor; + ModMonitor = this.Monitor; - createDirectories(); - initailizeComponents(); + this.createDirectories(); + this.initailizeComponents(); - - ModHelper.Events.GameLoop.SaveLoaded += GameLoop_SaveLoaded; - ModHelper.Events.GameLoop.TimeChanged += GameLoop_TimeChanged; - ModHelper.Events.GameLoop.UpdateTicked += GameLoop_UpdateTicked; + ModHelper.Events.GameLoop.SaveLoaded += this.GameLoop_SaveLoaded; + ModHelper.Events.GameLoop.TimeChanged += this.GameLoop_TimeChanged; + ModHelper.Events.GameLoop.UpdateTicked += this.GameLoop_UpdateTicked; playerInfo = new PlayerInfo(); } - private void createDirectories() { Directory.CreateDirectory(Path.Combine(this.Helper.DirectoryPath, "Configs")); @@ -117,7 +108,6 @@ namespace Revitalize DarkerNight.InitializeConfig(); } - private void GameLoop_UpdateTicked(object sender, StardewModdingAPI.Events.UpdateTickedEventArgs e) { DarkerNight.SetDarkerColor(); @@ -131,14 +121,14 @@ namespace Revitalize private void GameLoop_SaveLoaded(object sender, StardewModdingAPI.Events.SaveLoadedEventArgs e) { - MultiTiledComponent obj = new MultiTiledComponent(new BasicItemInformation("CoreObjectTest","YAY FUN!","Omegasis.Revitalize.MultiTiledComponent",Color.White,-300,0,false,100,Vector2.Zero,true,true,"Omegasis.TEST1", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", Game1.objectSpriteSheet,Color.White,0,true,typeof(MultiTiledComponent),null,new AnimationManager(new Texture2DExtended(Game1.objectSpriteSheet),new Animation(new Rectangle(0,0,16,16))),Color.Red,true,null,null)); - MultiTiledComponent obj2 = new MultiTiledComponent(new BasicItemInformation("CoreObjectTest2", "SomeFun", "Omegasis.Revitalize.MultiTiledComponent", Color.White, -300, 0, false, 100, Vector2.Zero, true, true, "Omegasis.TEST1", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", Game1.objectSpriteSheet, Color.White, 0, true, typeof(MultiTiledComponent), null, new AnimationManager(new Texture2DExtended(Game1.objectSpriteSheet), new Animation(new Rectangle(0, 16, 16, 16))), Color.Red,false,null,null)); - MultiTiledComponent obj3 = new MultiTiledComponent(new BasicItemInformation("CoreObjectTest3", "NoFun", "Omegasis.Revitalize.MultiTiledComponent", Color.White, -300, 0, false, 100, Vector2.Zero, true, true, "Omegasis.TEST1", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", Game1.objectSpriteSheet, Color.White, 0, true, typeof(MultiTiledComponent), null, new AnimationManager(new Texture2DExtended(Game1.objectSpriteSheet), new Animation(new Rectangle(0, 32, 16, 16))), Color.Red,false,null,null)); + MultiTiledComponent obj = new MultiTiledComponent(new BasicItemInformation("CoreObjectTest", "YAY FUN!", "Omegasis.Revitalize.MultiTiledComponent", Color.White, -300, 0, false, 100, Vector2.Zero, true, true, "Omegasis.TEST1", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", Game1.objectSpriteSheet, Color.White, 0, true, typeof(MultiTiledComponent), null, new AnimationManager(new Texture2DExtended(Game1.objectSpriteSheet), new Animation(new Rectangle(0, 0, 16, 16))), Color.Red, true, null, null)); + MultiTiledComponent obj2 = new MultiTiledComponent(new BasicItemInformation("CoreObjectTest2", "SomeFun", "Omegasis.Revitalize.MultiTiledComponent", Color.White, -300, 0, false, 100, Vector2.Zero, true, true, "Omegasis.TEST1", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", Game1.objectSpriteSheet, Color.White, 0, true, typeof(MultiTiledComponent), null, new AnimationManager(new Texture2DExtended(Game1.objectSpriteSheet), new Animation(new Rectangle(0, 16, 16, 16))), Color.Red, false, null, null)); + MultiTiledComponent obj3 = new MultiTiledComponent(new BasicItemInformation("CoreObjectTest3", "NoFun", "Omegasis.Revitalize.MultiTiledComponent", Color.White, -300, 0, false, 100, Vector2.Zero, true, true, "Omegasis.TEST1", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", Game1.objectSpriteSheet, Color.White, 0, true, typeof(MultiTiledComponent), null, new AnimationManager(new Texture2DExtended(Game1.objectSpriteSheet), new Animation(new Rectangle(0, 32, 16, 16))), Color.Red, false, null, null)); obj.info.lightManager.addLight(new Vector2(Game1.tileSize), new LightSource(4, new Vector2(0, 0), 2.5f, Color.Orange.Invert()), obj); - MultiTiledObject bigObject= new MultiTiledObject(new BasicItemInformation("MultiTest", "A really big object", "Omegasis.Revitalize.MultiTiledObject", Color.Blue, -300, 0, false, 100, Vector2.Zero, true, true, "Omegasis.BigTiledTest", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", Game1.objectSpriteSheet, Color.White, 0, true, typeof(MultiTiledObject), null, new AnimationManager(), Color.White,false,null,null)); + MultiTiledObject bigObject = new MultiTiledObject(new BasicItemInformation("MultiTest", "A really big object", "Omegasis.Revitalize.MultiTiledObject", Color.Blue, -300, 0, false, 100, Vector2.Zero, true, true, "Omegasis.BigTiledTest", "2048/0/-300/Crafting -9/Play '2048 by Platonymous' at home!/true/true/0/2048", Game1.objectSpriteSheet, Color.White, 0, true, typeof(MultiTiledObject), null, new AnimationManager(), Color.White, false, null, null)); bigObject.addComponent(new Vector2(0, 0), obj); bigObject.addComponent(new Vector2(1, 0), obj2); bigObject.addComponent(new Vector2(2, 0), obj3); @@ -146,22 +136,20 @@ namespace Revitalize Recipe pie = new Recipe(new Dictionary() { [bigObject] = 1 - },new KeyValuePair(new Furniture(3,Vector2.Zero),1)); + }, new KeyValuePair(new Furniture(3, Vector2.Zero), 1)); - new InventoryItem(bigObject, 100,1).addToNPCShop("Gus"); + new InventoryItem(bigObject, 100, 1).addToNPCShop("Gus"); Game1.player.addItemToInventory(bigObject); - - if (pie.PlayerCanCraft()) - { - //pie.craft(); - } - + + //if (pie.PlayerCanCraft()) + //{ + // pie.craft(); + //} } public static void log(object message) { - ModMonitor.Log(message.ToString()); } } diff --git a/GeneralMods/SaveAnywhere/Framework/ModConfig.cs b/GeneralMods/SaveAnywhere/Framework/ModConfig.cs index 2fc20210..e48269e3 100644 --- a/GeneralMods/SaveAnywhere/Framework/ModConfig.cs +++ b/GeneralMods/SaveAnywhere/Framework/ModConfig.cs @@ -1,4 +1,4 @@ -namespace Omegasis.SaveAnywhere.Framework +namespace Omegasis.SaveAnywhere.Framework { /// The mod configuration. internal class ModConfig diff --git a/GeneralMods/SaveAnywhere/Framework/Models/CharacterType.cs b/GeneralMods/SaveAnywhere/Framework/Models/CharacterType.cs index da6e2530..39d40429 100644 --- a/GeneralMods/SaveAnywhere/Framework/Models/CharacterType.cs +++ b/GeneralMods/SaveAnywhere/Framework/Models/CharacterType.cs @@ -1,4 +1,4 @@ -namespace Omegasis.SaveAnywhere.Framework.Models +namespace Omegasis.SaveAnywhere.Framework.Models { /// The character type for an NPC. public enum CharacterType diff --git a/GeneralMods/SaveAnywhere/Framework/Models/PositionData.cs b/GeneralMods/SaveAnywhere/Framework/Models/PositionData.cs index 5708b451..17ac9cf8 100644 --- a/GeneralMods/SaveAnywhere/Framework/Models/PositionData.cs +++ b/GeneralMods/SaveAnywhere/Framework/Models/PositionData.cs @@ -1,4 +1,4 @@ -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; namespace Omegasis.SaveAnywhere.Framework.Models { diff --git a/GeneralMods/SaveAnywhere/Framework/NewSaveGameMenu.cs b/GeneralMods/SaveAnywhere/Framework/NewSaveGameMenu.cs index b3917895..6a5523c1 100644 --- a/GeneralMods/SaveAnywhere/Framework/NewSaveGameMenu.cs +++ b/GeneralMods/SaveAnywhere/Framework/NewSaveGameMenu.cs @@ -1,40 +1,34 @@ -using Microsoft.Xna.Framework; +using System; +using System.Collections.Generic; +using System.Text; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using StardewValley; using StardewValley.BellsAndWhistles; using StardewValley.Menus; -using System; -using System.Collections.Generic; -using System.Text; namespace Omegasis.SaveAnywhere.Framework { - /// A marker subclass to detect when a custom save is in progress. - internal class NewSaveGameMenu : SaveGameMenu { - + internal class NewSaveGameMenu : SaveGameMenu + { public event EventHandler SaveComplete; private int completePause = -1; private int margin = 500; - private StringBuilder _stringBuilder = new StringBuilder(); + private readonly StringBuilder _stringBuilder = new StringBuilder(); private float _ellipsisDelay = 0.5f; private IEnumerator loader; public bool quit; public bool hasDrawn; - private SparklingText saveText; + private readonly SparklingText saveText; private int _ellipsisCount; - + public NewSaveGameMenu() { - this.saveText = new SparklingText(Game1.dialogueFont, Game1.content.LoadString("Strings\\StringsFromCSFiles:SaveGameMenu.cs.11378"), Color.LimeGreen, new Color((int)(Color.Black.R * (1.0 / 1000.0)),(int)( Color.Black.G * (1.0 / 1000.0)),(int)( Color.Black.B * (1.0 / 1000.0)),255), false, 0.1, 1500, 32, 500); + this.saveText = new SparklingText(Game1.dialogueFont, Game1.content.LoadString("Strings\\StringsFromCSFiles:SaveGameMenu.cs.11378"), Color.LimeGreen, new Color((int)(Color.Black.R * (1.0 / 1000.0)), (int)(Color.Black.G * (1.0 / 1000.0)), (int)(Color.Black.B * (1.0 / 1000.0)), 255), false, 0.1, 1500, 32, 500); } - public override void receiveRightClick(int x, int y, bool playSound = true) - { - } - - public new void complete() { Game1.playSound("money"); @@ -91,9 +85,7 @@ namespace Omegasis.SaveAnywhere.Framework if (Game1.IsMasterGame) { if (Game1.saveOnNewDay) - { this.loader = SaveGame.Save(); - } else { this.margin = -1; @@ -105,7 +97,6 @@ namespace Omegasis.SaveAnywhere.Framework NewSaveGameMenu.saveClientOptions(); this.complete(); } - } if (this.completePause < 0) return; @@ -171,8 +162,4 @@ namespace Omegasis.SaveAnywhere.Framework Game1.game1.IsSaving = false; } } - - } - - diff --git a/GeneralMods/SaveAnywhere/Framework/NewShippingMenu.cs b/GeneralMods/SaveAnywhere/Framework/NewShippingMenu.cs index 87dd59e6..8aa2d542 100644 --- a/GeneralMods/SaveAnywhere/Framework/NewShippingMenu.cs +++ b/GeneralMods/SaveAnywhere/Framework/NewShippingMenu.cs @@ -1,4 +1,4 @@ -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Netcode; using StardewModdingAPI; using StardewValley; @@ -16,8 +16,6 @@ namespace Omegasis.SaveAnywhere.Framework private readonly IReflectedField SavedYet; - - /********* ** Public methods *********/ @@ -30,12 +28,7 @@ namespace Omegasis.SaveAnywhere.Framework this.SavedYet = reflection.GetField(this, "savedYet"); } - /// - /// Overrides some base functionality of the shipping menu to enable proper closing. - /// - /// - /// - /// + /// Overrides some base functionality of the shipping menu to enable proper closing. public override void receiveLeftClick(int x, int y, bool playSound = true) { if (this.okButton.containsPoint(x, y)) this.exitThisMenu(true); diff --git a/GeneralMods/SaveAnywhere/Framework/SaveManager.cs b/GeneralMods/SaveAnywhere/Framework/SaveManager.cs index 16eb42b1..96789e17 100644 --- a/GeneralMods/SaveAnywhere/Framework/SaveManager.cs +++ b/GeneralMods/SaveAnywhere/Framework/SaveManager.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.IO; using System.Linq; @@ -52,10 +52,7 @@ namespace Omegasis.SaveAnywhere.Framework } - private void empty(object o, EventArgs args) - { - - } + private void empty(object o, EventArgs args) { } /// Perform any required update logic. public void Update() @@ -63,22 +60,20 @@ namespace Omegasis.SaveAnywhere.Framework // perform passive save if (this.WaitingToSave && Game1.activeClickableMenu == null) { - currentSaveMenu = new NewSaveGameMenu(); - currentSaveMenu.SaveComplete += CurrentSaveMenu_SaveComplete; - Game1.activeClickableMenu = currentSaveMenu; + this.currentSaveMenu = new NewSaveGameMenu(); + this.currentSaveMenu.SaveComplete += this.CurrentSaveMenu_SaveComplete; + Game1.activeClickableMenu = this.currentSaveMenu; this.WaitingToSave = false; } } - /// - /// Event function for NewSaveGameMenu event SaveComplete - /// - /// - /// + /// Event function for NewSaveGameMenu event SaveComplete + /// The event sender. + /// The event arguments. private void CurrentSaveMenu_SaveComplete(object sender, EventArgs e) { - currentSaveMenu.SaveComplete -= CurrentSaveMenu_SaveComplete; - currentSaveMenu = null; + this.currentSaveMenu.SaveComplete -= this.CurrentSaveMenu_SaveComplete; + this.currentSaveMenu = null; //AfterSave.Invoke(this, EventArgs.Empty); } @@ -92,12 +87,11 @@ namespace Omegasis.SaveAnywhere.Framework /// Initiate a game save. public void BeginSaveData() { - // save game data Farm farm = Game1.getFarm(); if (farm.shippingBin.Any()) { - + Game1.activeClickableMenu = new NewShippingMenu(farm.shippingBin, this.Reflection); farm.shippingBin.Clear(); farm.lastItemShipped = null; @@ -105,11 +99,11 @@ namespace Omegasis.SaveAnywhere.Framework } else { - currentSaveMenu = new NewSaveGameMenu(); - currentSaveMenu.SaveComplete += CurrentSaveMenu_SaveComplete; - Game1.activeClickableMenu = currentSaveMenu; + this.currentSaveMenu = new NewSaveGameMenu(); + this.currentSaveMenu.SaveComplete += this.CurrentSaveMenu_SaveComplete; + Game1.activeClickableMenu = this.currentSaveMenu; } - + // get data PlayerData data = new PlayerData @@ -146,23 +140,19 @@ namespace Omegasis.SaveAnywhere.Framework //AfterLoad.Invoke(this, EventArgs.Empty); } - /// - /// Checks to see if the player was swimming when the game was saved and if so, resumes the swimming animation. - /// - /// + /// Checks to see if the player was swimming when the game was saved and if so, resumes the swimming animation. public void ResumeSwimming(PlayerData data) { try { - if (data.IsCharacterSwimming == true) + if (data.IsCharacterSwimming) { Game1.player.changeIntoSwimsuit(); Game1.player.swimming.Value = true; } } - catch (Exception err) + catch { - err.ToString(); //Here to allow compatability with old save files. } } @@ -178,7 +168,8 @@ namespace Omegasis.SaveAnywhere.Framework var player = Game1.player; string name = player.Name; string map = player.currentLocation.uniqueName.Value; //Try to get a unique name for the location and if we can't we are going to default to the actual name of the map. - if (map == ""|| map==null) map = player.currentLocation.Name; //This is used to account for maps that share the same name but have a unique ID such as Coops, Barns and Sheds. + if (string.IsNullOrEmpty(map)) + map = player.currentLocation.Name; //This is used to account for maps that share the same name but have a unique ID such as Coops, Barns and Sheds. Point tile = player.getTileLocationPoint(); int facingDirection = player.facingDirection; @@ -189,9 +180,8 @@ namespace Omegasis.SaveAnywhere.Framework foreach (NPC npc in Utility.getAllCharacters()) { CharacterType? type = this.GetCharacterType(npc); - if (type == null) + if (type == null || npc?.currentLocation == null) continue; - if (npc == null || npc.currentLocation == null) continue; string name = npc.Name; string map = npc.currentLocation.Name; Point tile = npc.getTileLocationPoint(); diff --git a/GeneralMods/SaveAnywhere/SaveAnywhere.cs b/GeneralMods/SaveAnywhere/SaveAnywhere.cs index 698ffdcb..8908de45 100644 --- a/GeneralMods/SaveAnywhere/SaveAnywhere.cs +++ b/GeneralMods/SaveAnywhere/SaveAnywhere.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using Omegasis.SaveAnywhere.Framework; @@ -31,20 +31,17 @@ namespace Omegasis.SaveAnywhere /// Whether we're performing a non-vanilla save (i.e. not by sleeping in bed). private bool IsCustomSaving; - - /// - /// Used to access the Mod's helper from other files associated with the mod. - /// + /// Used to access the Mod's helper from other files associated with the mod. public static IModHelper ModHelper; - /// - /// Used to access the Mod's monitor to allow for debug logging in other files associated with the mod. - /// + + /// Used to access the Mod's monitor to allow for debug logging in other files associated with the mod. public static IMonitor ModMonitor; private List monsters; private bool customMenuOpen; + /********* ** Public methods *********/ @@ -63,10 +60,11 @@ namespace Omegasis.SaveAnywhere TimeEvents.AfterDayStarted += this.TimeEvents_AfterDayStarted; ModHelper = helper; - ModMonitor = Monitor; - customMenuOpen = false; + ModMonitor = this.Monitor; + this.customMenuOpen = false; } + /********* ** Private methods *********/ @@ -89,28 +87,25 @@ namespace Omegasis.SaveAnywhere private void SaveEvents_AfterSave(object sender, EventArgs e) { // clear custom data after a normal save (to avoid restoring old state) - if (!this.IsCustomSaving) + if (!this.IsCustomSaving) this.SaveManager.ClearData(); else { - IsCustomSaving = false; + this.IsCustomSaving = false; } } - /// The method invoked when the game updates (roughly 60 times per second). /// The event sender. /// The event data. private void GameEvents_UpdateTick(object sender, EventArgs e) { - // let save manager run background logic if (Context.IsWorldReady) { - if (Game1.player.IsMainPlayer == false) return; + if (!Game1.player.IsMainPlayer) return; this.SaveManager.Update(); } - // reset NPC schedules if (Context.IsWorldReady && this.ShouldResetSchedules) @@ -119,10 +114,10 @@ namespace Omegasis.SaveAnywhere this.ApplySchedules(); } - if (Game1.activeClickableMenu == null && this.customMenuOpen == false) return; - if(Game1.activeClickableMenu==null && this.customMenuOpen == true) + if (Game1.activeClickableMenu == null && !this.customMenuOpen) return; + if (Game1.activeClickableMenu == null && this.customMenuOpen) { - restoreMonsters(); + this.restoreMonsters(); this.customMenuOpen = false; return; } @@ -135,43 +130,30 @@ namespace Omegasis.SaveAnywhere } } - /// - /// Saves all monsters from the game world. - /// + /// Saves all monsters from the game world. private void cleanMonsters() { - monsters = new List(); + this.monsters = new List(); - foreach (var monster in Game1.player.currentLocation.characters) + foreach (var npc in Game1.player.currentLocation.characters) { try { - if (monster is Monster) - { - monsters.Add(monster as Monster); - } - } - catch (Exception err) - { - + if (npc is Monster monster) + this.monsters.Add(monster); } + catch { } } foreach (var monster in this.monsters) - { Game1.player.currentLocation.characters.Remove(monster); - } } - /// - /// Adds all saved monster back into the game world. - /// + /// Adds all saved monster back into the game world. private void restoreMonsters() { foreach (var monster in this.monsters) - { Game1.player.currentLocation.characters.Add(monster); - } } /// The method invoked after a new day starts. @@ -199,14 +181,12 @@ namespace Omegasis.SaveAnywhere if (!Context.IsPlayerFree) return; - - // initiate save (if valid context) if (e.KeyPressed.ToString() == this.Config.SaveKey) { - if (Game1.client==null) + if (Game1.client == null) { - cleanMonsters(); + this.cleanMonsters(); // validate: community center Junimos can't be saved if (Game1.player.currentLocation.getCharacters().OfType().Any()) @@ -215,14 +195,13 @@ namespace Omegasis.SaveAnywhere return; } - // save this.IsCustomSaving = true; this.SaveManager.BeginSaveData(); } else { - Game1.addHUDMessage(new HUDMessage("Only server hosts can save anywhere.",HUDMessage.error_type)); + Game1.addHUDMessage(new HUDMessage("Only server hosts can save anywhere.", HUDMessage.error_type)); } } } @@ -245,16 +224,14 @@ namespace Omegasis.SaveAnywhere continue; // get schedule data - string scheduleData; - if (!this.NpcSchedules.TryGetValue(npc.Name, out scheduleData) || string.IsNullOrEmpty(scheduleData)) + if (!this.NpcSchedules.TryGetValue(npc.Name, out string scheduleData) || string.IsNullOrEmpty(scheduleData)) { //this.Monitor.Log("THIS IS AWKWARD"); continue; } // get schedule script - string script; - if (!rawSchedule.TryGetValue(scheduleData, out script)) + if (!rawSchedule.TryGetValue(scheduleData, out string script)) continue; // parse entries @@ -294,10 +271,8 @@ namespace Omegasis.SaveAnywhere .Invoke(npc.currentLocation.Name, npc.getTileX(), npc.getTileY(), endMap, x, y, endFacingDir, null, null); index++; } - catch (Exception ex) + catch { - ex.ToString(); - //this.Monitor.Log($"Error pathfinding NPC {npc.name}: {ex}", LogLevel.Error); continue; } @@ -320,7 +295,7 @@ namespace Omegasis.SaveAnywhere { return Game1.content.Load>($"Characters\\schedules\\{npcName}"); } - catch (Exception) + catch { return null; } @@ -369,9 +344,8 @@ namespace Omegasis.SaveAnywhere if (schedule.ContainsKey(Game1.currentSeason + "_" + Game1.dayOfMonth)) return Game1.currentSeason + "_" + Game1.dayOfMonth; int i; - Friendship f; - Game1.player.friendshipData.TryGetValue(npc.Name, out f); - for (i = (Game1.player.friendshipData.ContainsKey(npc.Name) ? (f.Points/ 250) : -1); i > 0; i--) + Game1.player.friendshipData.TryGetValue(npc.Name, out Friendship f); + for (i = (Game1.player.friendshipData.ContainsKey(npc.Name) ? (f.Points / 250) : -1); i > 0; i--) { if (schedule.ContainsKey(Game1.dayOfMonth + "_" + i)) return Game1.dayOfMonth + "_" + i; @@ -388,8 +362,7 @@ namespace Omegasis.SaveAnywhere return "rain"; } List list = new List { Game1.currentSeason, Game1.shortDayNameFromDayOfSeason(Game1.dayOfMonth) }; - Friendship friendship; - Game1.player.friendshipData.TryGetValue(npc.Name, out friendship); + Game1.player.friendshipData.TryGetValue(npc.Name, out Friendship friendship); i = (Game1.player.friendshipData.ContainsKey(npc.Name) ? (friendship.Points / 250) : -1); while (i > 0) { @@ -419,8 +392,7 @@ namespace Omegasis.SaveAnywhere } list.RemoveAt(list.Count - 1); list.Add("spring"); - Friendship friendship2; - Game1.player.friendshipData.TryGetValue(npc.Name, out friendship2); + Game1.player.friendshipData.TryGetValue(npc.Name, out Friendship friendship2); i = (Game1.player.friendshipData.ContainsKey(npc.Name) ? (friendship2.Points / 250) : -1); while (i > 0) { @@ -430,9 +402,9 @@ namespace Omegasis.SaveAnywhere i--; list.RemoveAt(list.Count - 1); } - if (schedule.ContainsKey("spring")) - return "spring"; - return null; + return schedule.ContainsKey("spring") + ? "spring" + : null; } } } diff --git a/GeneralMods/SaveAnywhere/manifest.json b/GeneralMods/SaveAnywhere/manifest.json index bfaa6bb2..9ff92a6a 100644 --- a/GeneralMods/SaveAnywhere/manifest.json +++ b/GeneralMods/SaveAnywhere/manifest.json @@ -7,5 +7,5 @@ "EntryDll": "SaveAnywhere.dll", "MinimumApiVersion": "2.4", "Dependencies": [ - ] + ] } diff --git a/GeneralMods/SimpleSoundManager/Framework/Sound.cs b/GeneralMods/SimpleSoundManager/Framework/Sound.cs index 3f3d5b44..0fb68e22 100644 --- a/GeneralMods/SimpleSoundManager/Framework/Sound.cs +++ b/GeneralMods/SimpleSoundManager/Framework/Sound.cs @@ -1,38 +1,23 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - namespace SimpleSoundManager.Framework { - /// - /// Interface used for common sound functionality; - /// + /// Interface used for common sound functionality; public interface Sound { - /// - /// Handles playing a sound. - /// + /// Handles playing a sound. void play(); void play(float volume); - /// - /// Handles pausing a song. - /// + + /// Handles pausing a song. void pause(); - /// - /// Handles stopping a song. - /// + + /// Handles stopping a song. void stop(); - /// - /// Handles restarting a song. - /// + + /// Handles restarting a song. void restart(); - /// - /// Handles getting a clone of the song. - /// - /// + + /// Handles getting a clone of the song. Sound clone(); string getSoundName(); diff --git a/GeneralMods/SimpleSoundManager/Framework/SoundManager.cs b/GeneralMods/SimpleSoundManager/Framework/SoundManager.cs index a9ce5a58..617baa6e 100644 --- a/GeneralMods/SimpleSoundManager/Framework/SoundManager.cs +++ b/GeneralMods/SimpleSoundManager/Framework/SoundManager.cs @@ -1,187 +1,117 @@ -using Microsoft.Xna.Framework.Audio; +using System.Collections.Generic; +using Microsoft.Xna.Framework.Audio; using StardewModdingAPI; using StardewValley; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace SimpleSoundManager.Framework { public class SoundManager { - - public Dictionary sounds; + public Dictionary sounds; public Dictionary musicBanks; public float volume; public List currentlyPlayingSounds = new List(); - /// - /// Constructor for this class. - /// + + /// Constructor for this class. public SoundManager() { this.sounds = new Dictionary(); this.musicBanks = new Dictionary(); - currentlyPlayingSounds = new List(); + this.currentlyPlayingSounds = new List(); this.volume = 1.0f; } - /// - /// Constructor for wav files. - /// - /// - /// - public void loadWavFile(string soundName,string pathToWav) + /// Constructor for wav files. + public void loadWavFile(string soundName, string pathToWav) { - WavSound wav = new WavSound(soundName,pathToWav); + WavSound wav = new WavSound(soundName, pathToWav); SimpleSoundManagerMod.ModMonitor.Log("Getting sound file:" + soundName); try { this.sounds.Add(soundName, wav); } - catch(Exception err) - { - - } + catch { } } - - /// - /// Constructor for wav files. - /// - /// - /// - /// - public void loadWavFile(IModHelper helper,string soundName,string pathToWav) + + /// Constructor for wav files. + public void loadWavFile(IModHelper helper, string soundName, string pathToWav) { - WavSound wav = new WavSound(helper ,soundName,pathToWav); + WavSound wav = new WavSound(helper, soundName, pathToWav); SimpleSoundManagerMod.ModMonitor.Log("Getting sound file:" + soundName); try { this.sounds.Add(soundName, wav); } - catch(Exception err) + catch { //Sound already added so no need to worry? } } - /// - /// Constructor for wav files. - /// - /// - /// - /// - public void loadWavFile(IModHelper helper,string songName,List pathToWav) + /// Constructor for wav files. + public void loadWavFile(IModHelper helper, string songName, List pathToWav) { - WavSound wav = new WavSound(helper,songName,pathToWav); + WavSound wav = new WavSound(helper, songName, pathToWav); SimpleSoundManagerMod.ModMonitor.Log("Getting sound file:" + songName); try { this.sounds.Add(songName, wav); } - catch(Exception err) - { - - } + catch { } } - /// - /// Constructor for XACT files. - /// - /// - /// - /// + /// Constructor for XACT files. public void loadXACTFile(WaveBank waveBank, ISoundBank soundBank, string songName) { XACTSound xactSound = new XACTSound(waveBank, soundBank, songName); this.sounds.Add(songName, xactSound); } - /// - /// Constructor for XACT files based on already added music packs. - /// - /// - /// + /// Constructor for XACT files based on already added music packs. public void loadXACTFile(string pairName, string songName) { - XACTMusicPair musicPair = getMusicPack(pairName); + XACTMusicPair musicPair = this.getMusicPack(pairName); if (pairName == null) - { return; - } - loadXACTFile(musicPair.waveBank, musicPair.soundBank, songName); + this.loadXACTFile(musicPair.waveBank, musicPair.soundBank, songName); } - - /// - /// Creates a music pack pair that holds .xwb and .xsb music files. - /// + /// Creates a music pack pair that holds .xwb and .xsb music files. /// The mod's helper that will handle the path of the files. /// The name of this music pack pair. /// The relative path to the .xwb file /// The relative path to the .xsb file - public void loadXACTMusicBank(IModHelper helper,string pairName,string wavName, string soundName) + public void loadXACTMusicBank(IModHelper helper, string pairName, string wavName, string soundName) { - this.musicBanks.Add(pairName,new XACTMusicPair(helper, wavName, soundName)); + this.musicBanks.Add(pairName, new XACTMusicPair(helper, wavName, soundName)); } - /// - /// Gets the music pack pair from the sound pool. - /// - /// - /// + /// Gets the music pack pair from the sound pool. public XACTMusicPair getMusicPack(string name) { - foreach(var pack in this.musicBanks) + foreach (var pack in this.musicBanks) { - if (name == pack.Key) return pack.Value; + if (name == pack.Key) + return pack.Value; } return null; } - /// - /// Gets a clone of the loaded sound. - /// - /// - /// + /// Gets a clone of the loaded sound. public Sound getSoundClone(string name) { - foreach(var sound in this.sounds) + foreach (var sound in this.sounds) { - if (sound.Key == name) return sound.Value.clone(); + if (sound.Key == name) + return sound.Value.clone(); } return null; } - /// - /// Play the sound with the given name. - /// - /// + /// Play the sound with the given name. public void playSound(string soundName) - { - SimpleSoundManagerMod.ModMonitor.Log("Trying to play sound: " + soundName); - foreach(var sound in this.sounds) - { - if (sound.Key == soundName) - { - SimpleSoundManagerMod.ModMonitor.Log("Time to play sound: " + soundName); - var s=getSoundClone(soundName); - s.play(this.volume); - this.currentlyPlayingSounds.Add(s); - break; - } - } - } - - /// - /// Play the sound with the given name and volume. - /// - /// - /// - public void playSound(string soundName,float volume=1.0f) { SimpleSoundManagerMod.ModMonitor.Log("Trying to play sound: " + soundName); foreach (var sound in this.sounds) @@ -189,7 +119,24 @@ namespace SimpleSoundManager.Framework if (sound.Key == soundName) { SimpleSoundManagerMod.ModMonitor.Log("Time to play sound: " + soundName); - var s = getSoundClone(soundName); + var s = this.getSoundClone(soundName); + s.play(this.volume); + this.currentlyPlayingSounds.Add(s); + break; + } + } + } + + /// Play the sound with the given name and volume. + public void playSound(string soundName, float volume = 1.0f) + { + SimpleSoundManagerMod.ModMonitor.Log("Trying to play sound: " + soundName); + foreach (var sound in this.sounds) + { + if (sound.Key == soundName) + { + SimpleSoundManagerMod.ModMonitor.Log("Time to play sound: " + soundName); + var s = this.getSoundClone(soundName); s.play(volume); this.currentlyPlayingSounds.Add(s); break; @@ -197,10 +144,7 @@ namespace SimpleSoundManager.Framework } } - /// - /// Stop the sound that is playing. - /// - /// + /// Stop the sound that is playing. public void stopSound(string soundName) { List removalList = new List(); @@ -212,16 +156,11 @@ namespace SimpleSoundManager.Framework removalList.Add(sound); } } - foreach(var v in removalList) - { + foreach (var v in removalList) this.currentlyPlayingSounds.Remove(v); - } } - /// - /// Pause the sound with this name? - /// - /// + /// Pause the sound with this name? public void pauseSound(string soundName) { List removalList = new List(); @@ -234,9 +173,7 @@ namespace SimpleSoundManager.Framework } } foreach (var v in removalList) - { this.currentlyPlayingSounds.Remove(v); - } } public void swapSounds(string newSong) @@ -247,29 +184,19 @@ namespace SimpleSoundManager.Framework public void update() { List removalList = new List(); - foreach(Sound song in this.currentlyPlayingSounds) + foreach (Sound song in this.currentlyPlayingSounds) { if (song.isStopped()) - { removalList.Add(song); - } } - foreach(var v in removalList) - { + foreach (var v in removalList) this.currentlyPlayingSounds.Remove(v); - } } public void stopAllSounds() { - foreach(var v in this.currentlyPlayingSounds) - { + foreach (var v in this.currentlyPlayingSounds) v.stop(); - } } - - - - } } diff --git a/GeneralMods/SimpleSoundManager/Framework/WavSound.cs b/GeneralMods/SimpleSoundManager/Framework/WavSound.cs index 6926b528..923248e4 100644 --- a/GeneralMods/SimpleSoundManager/Framework/WavSound.cs +++ b/GeneralMods/SimpleSoundManager/Framework/WavSound.cs @@ -1,95 +1,70 @@ -using Microsoft.Xna.Framework.Audio; -using SimpleSoundManager.Framework; -using StardewModdingAPI; -using StardewValley; using System; using System.Collections.Generic; using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using Microsoft.Xna.Framework.Audio; +using SimpleSoundManager.Framework; +using StardewModdingAPI; namespace SimpleSoundManager { class WavSound : Sound { - /// - /// Used to actually play the song. - /// + /// Used to actually play the song. DynamicSoundEffectInstance dynamicSound; - /// - /// Used to keep track of where in the song we are. - /// - int position; - /// - /// ??? - /// - int count; - /// - /// Used to store the info for the song. - /// - byte[] byteArray; + /// Used to keep track of where in the song we are. + int position; + + int count; + + /// Used to store the info for the song. + byte[] byteArray; public string path; public string soundName; - public bool loop; - /// - /// Get a raw disk path to the wav file. - /// - /// - public WavSound(string name,string pathToWavFile,bool Loop=false) + /// Get a raw disk path to the wav file. + public WavSound(string name, string pathToWavFile, bool loop = false) { this.path = pathToWavFile; - LoadWavFromFileToStream(); + this.LoadWavFromFileToStream(); this.soundName = name; - this.loop = Loop; + this.loop = loop; } - /// - /// A constructor that takes a mod helper and a relative path to a wav file. - /// - /// - /// - public WavSound(IModHelper modHelper,string name, string pathInModDirectory,bool Loop=false) + /// A constructor that takes a mod helper and a relative path to a wav file. + public WavSound(IModHelper modHelper, string name, string pathInModDirectory, bool loop = false) { string path = Path.Combine(modHelper.DirectoryPath, pathInModDirectory); this.path = path; this.soundName = name; - this.loop = Loop; + this.loop = loop; } - /// - /// Constructor that is more flexible than typing an absolute path. - /// + /// Constructor that is more flexible than typing an absolute path. /// The mod helper for the mod you wish to use to load the music files from. /// The list of folders and files that make up a complete path. - public WavSound(IModHelper modHelper,string soundName, List pathPieces,bool Loop=false) + public WavSound(IModHelper modHelper, string soundName, List pathPieces, bool loop = false) { - string s = modHelper.DirectoryPath; - foreach(var str in pathPieces) - { - s = Path.Combine(s, str); - } - this.path = s; + string dirPath = modHelper.DirectoryPath; + foreach (string str in pathPieces) + dirPath = Path.Combine(dirPath, str); + this.path = dirPath; this.soundName = soundName; - this.loop = Loop; + this.loop = loop; } - /// - /// Loads the .wav file from disk and plays it. - /// + /// Loads the .wav file from disk and plays it. public void LoadWavFromFileToStream() { // Create a new SpriteBatch, which can be used to draw textures. string file = this.path; - System.IO.Stream waveFileStream = File.OpenRead(file); //TitleContainer.OpenStream(file); + Stream waveFileStream = File.OpenRead(file); //TitleContainer.OpenStream(file); BinaryReader reader = new BinaryReader(waveFileStream); @@ -115,104 +90,83 @@ namespace SimpleSoundManager int dataID = reader.ReadInt32(); int dataSize = reader.ReadInt32(); - byteArray = reader.ReadBytes(dataSize); + this.byteArray = reader.ReadBytes(dataSize); - dynamicSound = new DynamicSoundEffectInstance(sampleRate, (AudioChannels)channels); - count = byteArray.Length;//dynamicSound.GetSampleSizeInBytes(TimeSpan.FromMilliseconds(1000)); + this.dynamicSound = new DynamicSoundEffectInstance(sampleRate, (AudioChannels)channels); + this.count = this.byteArray.Length;//dynamicSound.GetSampleSizeInBytes(TimeSpan.FromMilliseconds(1000)); - dynamicSound.BufferNeeded += new EventHandler(DynamicSound_BufferNeeded); - + this.dynamicSound.BufferNeeded += this.DynamicSound_BufferNeeded; } void DynamicSound_BufferNeeded(object sender, EventArgs e) { try { - dynamicSound.SubmitBuffer(byteArray, position, count); - } - catch (Exception err) - { - //SimpleSoundManagerMod.ModMonitor.Log(err.ToString()); + this.dynamicSound.SubmitBuffer(this.byteArray, this.position, this.count); } + catch { } - position += count; - if (position + count > byteArray.Length) + this.position += this.count; + if (this.position + this.count > this.byteArray.Length) { - if (loop) - { - position = 0; - } - else - { - //this.stop(); - } + if (this.loop) + this.position = 0; + //else + // this.stop(); } } - /// - /// Used to pause the current song. - /// + /// Used to pause the current song. public void pause() { - if (dynamicSound != null) dynamicSound.Pause(); + this.dynamicSound?.Pause(); } - /// - /// Used to play a song. - /// - /// + /// Used to play a song. public void play() { - if (this.isPlaying() == true) return; - LoadWavFromFileToStream(); - dynamicSound.Play(); + if (this.isPlaying()) + return; + + this.LoadWavFromFileToStream(); + this.dynamicSound.Play(); } - /// - /// Used to play a song. - /// - /// + /// Used to play a song. /// How lound the sound is when playing. 0~1.0f public void play(float volume) { - if (this.isPlaying() == true) return; - LoadWavFromFileToStream(); - dynamicSound.Volume = volume; - dynamicSound.Play(); + if (this.isPlaying()) + return; + + this.LoadWavFromFileToStream(); + this.dynamicSound.Volume = volume; + this.dynamicSound.Play(); } - /// - /// Used to resume the currently playing song. - /// + /// Used to resume the currently playing song. public void resume() { - if (dynamicSound == null) return; - dynamicSound.Resume(); + dynamicSound?.Resume(); } - /// - /// Used to stop the currently playing song. - /// + /// Used to stop the currently playing song. public void stop() { - - if (dynamicSound != null) + if (this.dynamicSound != null) { - dynamicSound.Stop(true); - dynamicSound.BufferNeeded -= new EventHandler(DynamicSound_BufferNeeded); - position = 0; - count = 0; - byteArray = new byte[0]; + this.dynamicSound.Stop(true); + this.dynamicSound.BufferNeeded -= this.DynamicSound_BufferNeeded; + this.position = 0; + this.count = 0; + this.byteArray = new byte[0]; } } - /// - /// Used to change from one playing song to another; - /// - /// + /// Used to change from one playing song to another; public void swap(string pathToNewWavFile) { this.stop(); @@ -220,42 +174,27 @@ namespace SimpleSoundManager this.play(); } - /// - /// Checks if the song is currently playing. - /// - /// + /// Checks if the song is currently playing. public bool isPlaying() { - if (this.dynamicSound == null) return false; - if (this.dynamicSound.State == SoundState.Playing) return true; - else return false; + return this.dynamicSound?.State == SoundState.Playing; } - /// - /// Checks if the song is currently paused. - /// - /// + /// Checks if the song is currently paused. public bool isPaused() { - if (this.dynamicSound == null) return false; - if (this.dynamicSound.State == SoundState.Paused) return true; - else return false; + return this.dynamicSound?.State == SoundState.Paused; } - /// - /// Checks if the song is currently stopped. - /// - /// + /// Checks if the song is currently stopped. public bool isStopped() { - if (this.dynamicSound == null) return false; - if (this.dynamicSound.State == SoundState.Stopped) return true; - else return false; + return this.dynamicSound?.State == SoundState.Stopped; } public Sound clone() { - return new WavSound(this.getSoundName(),this.path); + return new WavSound(this.getSoundName(), this.path); } public string getSoundName() @@ -268,6 +207,5 @@ namespace SimpleSoundManager this.stop(); this.play(); } - } } diff --git a/GeneralMods/SimpleSoundManager/Framework/XACTSound.cs b/GeneralMods/SimpleSoundManager/Framework/XACTSound.cs index b3bfad14..a9e6379e 100644 --- a/GeneralMods/SimpleSoundManager/Framework/XACTSound.cs +++ b/GeneralMods/SimpleSoundManager/Framework/XACTSound.cs @@ -1,11 +1,5 @@ -using Microsoft.Xna.Framework.Audio; -using StardewModdingAPI; +using Microsoft.Xna.Framework.Audio; using StardewValley; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace SimpleSoundManager.Framework { @@ -14,29 +8,25 @@ namespace SimpleSoundManager.Framework public WaveBank waveBank; public ISoundBank soundBank; public string soundName; - WaveBank vanillaWaveBank; - ISoundBank vanillaSoundBank; - Cue song; + readonly WaveBank vanillaWaveBank; + readonly ISoundBank vanillaSoundBank; + readonly Cue song; - /// - /// Make a new Sound Manager to play and manage sounds in a modded wave bank. - /// + /// Make a new Sound Manager to play and manage sounds in a modded wave bank. /// The reference to the wave bank in the mod's asset folder. /// The reference to the sound bank in the mod's asset folder. - public XACTSound(WaveBank newWaveBank, ISoundBank newSoundBank,string soundName) + public XACTSound(WaveBank newWaveBank, ISoundBank newSoundBank, string soundName) { this.waveBank = newWaveBank; this.soundBank = newSoundBank; - vanillaSoundBank = Game1.soundBank; - vanillaWaveBank = Game1.waveBank; + this.vanillaSoundBank = Game1.soundBank; + this.vanillaWaveBank = Game1.waveBank; this.soundName = soundName; - song = this.soundBank.GetCue(this.soundName); + this.song = this.soundBank.GetCue(this.soundName); } - /// - /// Play a sound from the mod's wave bank. - /// + /// Play a sound from the mod's wave bank. /// The name of the sound in the mod's wave bank. This will fail if the sound doesn't exists. This is also case sensitive. public void play(string soundName) { @@ -51,89 +41,65 @@ namespace SimpleSoundManager.Framework Game1.soundBank = this.vanillaSoundBank; } - /// - /// Pauses the first instance of this sound. - /// + /// Pauses the first instance of this sound. /// public void pause(string soundName) { - if (this.song == null) return; - this.song.Pause(); + this.song?.Pause(); } - /// - /// Resume the first instance of the sound that has this name. - /// + /// Resume the first instance of the sound that has this name. public void resume(string soundName) { - if (this.song == null) return; - this.song.Resume(); + this.song?.Resume(); } - /// - /// Stop the first instance of the sound that has this name. - /// + /// Stop the first instance of the sound that has this name. /// public void stop(string soundName) { - if (this.song == null) return; - this.song.Stop(AudioStopOptions.Immediate); + this.song?.Stop(AudioStopOptions.Immediate); } - /// - /// Resumes a paused song. - /// + /// Resumes a paused song. public void resume() { - this.resume(soundName); + this.resume(this.soundName); } - /// - /// Plays this song. - /// + /// Plays this song. public void play() { this.play(this.soundName); } - /// - /// Plays this song. - /// + /// Plays this song. public void play(float volume) { this.play(this.soundName); } - /// - /// Pauses this song. - /// + /// Pauses this song. public void pause() { this.pause(this.soundName); } - /// - /// Stops this somg. - /// + /// Stops this somg. public void stop() { this.stop(this.soundName); } - /// - /// Restarts this song. - /// + /// Restarts this song. public void restart() { this.stop(); this.play(); } - /// - /// Gets a clone of this song. - /// - /// + /// Gets a clone of this song. public Sound clone() { return new XACTSound(this.waveBank, this.soundBank, this.soundName); @@ -146,11 +112,7 @@ namespace SimpleSoundManager.Framework public bool isStopped() { - if (this.song == null) return true; - if (this.song.IsStopped) return true; - return false; + return this.song == null || this.song.IsStopped; } - - } } diff --git a/GeneralMods/SimpleSoundManager/Framework/XactMusicPair.cs b/GeneralMods/SimpleSoundManager/Framework/XactMusicPair.cs index fe3a77c2..84129dc1 100644 --- a/GeneralMods/SimpleSoundManager/Framework/XactMusicPair.cs +++ b/GeneralMods/SimpleSoundManager/Framework/XactMusicPair.cs @@ -1,12 +1,7 @@ -using Microsoft.Xna.Framework.Audio; +using System.IO; +using Microsoft.Xna.Framework.Audio; using StardewModdingAPI; using StardewValley; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace SimpleSoundManager { @@ -15,20 +10,17 @@ namespace SimpleSoundManager public WaveBank waveBank; public ISoundBank soundBank; - /// - /// Create a xwb and xsb music pack pair. - /// + /// Create a xwb and xsb music pack pair. /// The mod helper from the mod that will handle loading in the file. /// A relative path to the .xwb file in the mod helper's mod directory. /// A relative path to the .xsb file in the mod helper's mod directory. - public XACTMusicPair(IModHelper helper,string wavBankPath, string soundBankPath) + public XACTMusicPair(IModHelper helper, string wavBankPath, string soundBankPath) { wavBankPath = Path.Combine(helper.DirectoryPath, wavBankPath); soundBankPath = Path.Combine(helper.DirectoryPath, soundBankPath); - - waveBank = new WaveBank(Game1.audioEngine, wavBankPath); - soundBank = new SoundBankWrapper(new SoundBank(Game1.audioEngine, soundBankPath)); + this.waveBank = new WaveBank(Game1.audioEngine, wavBankPath); + this.soundBank = new SoundBankWrapper(new SoundBank(Game1.audioEngine, soundBankPath)); } } } diff --git a/GeneralMods/SimpleSoundManager/SimpleSoundManagerMod.cs b/GeneralMods/SimpleSoundManager/SimpleSoundManagerMod.cs index b93be9b0..1a583b3b 100644 --- a/GeneralMods/SimpleSoundManager/SimpleSoundManagerMod.cs +++ b/GeneralMods/SimpleSoundManager/SimpleSoundManagerMod.cs @@ -1,4 +1,4 @@ -using StardewModdingAPI; +using StardewModdingAPI; namespace SimpleSoundManager { @@ -7,10 +7,12 @@ namespace SimpleSoundManager internal static IModHelper ModHelper; internal static IMonitor ModMonitor; + /// The mod entry point, called after the mod is first loaded. + /// Provides simplified APIs for writing mods. public override void Entry(IModHelper helper) { ModHelper = helper; - ModMonitor = Monitor; + ModMonitor = this.Monitor; } } } diff --git a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Config.cs b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Config.cs index 1e1c81ba..96b93350 100644 --- a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Config.cs +++ b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Config.cs @@ -1,44 +1,24 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - namespace StardewSymphonyRemastered { - /// - /// A class that handles all of the config files for this mod. - /// + /// A class that handles all of the config files for this mod. public class Config { - /// - /// Whether or not to display debug log information on the SMAPI console for this mod. - /// - public bool EnableDebugLog { get; set; }=false; + /// Whether or not to display debug log information on the SMAPI console for this mod. + public bool EnableDebugLog { get; set; } = false; - /// - /// The minimum delay between songs in terms of milliseconds. - /// - public int MinimumDelayBetweenSongsInMilliseconds { get; set; }=5000; + /// The minimum delay between songs in terms of milliseconds. + public int MinimumDelayBetweenSongsInMilliseconds { get; set; } = 5000; - /// - /// The maximum delay between songs in terms of milliseconds. - /// - public int MaximumDelayBetweenSongsInMilliseconds { get; set; }=60000; + /// The maximum delay between songs in terms of milliseconds. + public int MaximumDelayBetweenSongsInMilliseconds { get; set; } = 60000; - /// - /// The key binding to open up the menu music. - /// - public string KeyBinding { get; set; }="L"; - - /// - /// Used to write a .json file for every possible option for a music pack. Use at your own risk! - /// + /// The key binding to open up the menu music. + public string KeyBinding { get; set; } = "L"; + + /// Used to write a .json file for every possible option for a music pack. Use at your own risk! public bool writeAllConfigMusicOptions { get; set; } = false; - /// - /// Used to completely disable the Stardew Valley OST. - /// + /// Used to completely disable the Stardew Valley OST. public bool disableStardewMusic { get; set; } = false; } } diff --git a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Menus/MusicManagerMenu.cs b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Menus/MusicManagerMenu.cs index e4118a5f..c618f97e 100644 --- a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Menus/MusicManagerMenu.cs +++ b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Menus/MusicManagerMenu.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using Microsoft.Xna.Framework; @@ -11,18 +11,13 @@ using StardustCore.UIUtilities.MenuComponents; using StardustCore.UIUtilities.MenuComponents.Delegates; using StardustCore.UIUtilities.MenuComponents.Delegates.Functionality; using StardustCore.UIUtilities.SpriteFonts; -using StardustCore.UIUtilities.SpriteFonts.Components; namespace StardewSymphonyRemastered.Framework.Menus { - /// - /// Interface for the menu for selection music. - /// + /// Interface for the menu for selection music. public class MusicManagerMenu : IClickableMenuExtended { - /// - /// The different displays for this menu. - /// + /// The different displays for this menu. public enum DrawMode { AlbumSelection, @@ -47,7 +42,7 @@ namespace StardewSymphonyRemastered.Framework.Menus SeasonSelection, } - public List