From aa8d59b67b2251d18df04c7077cd2e90b4b05f6e Mon Sep 17 00:00:00 2001 From: Date: Sun, 4 Mar 2018 03:05:01 -0800 Subject: [PATCH 01/54] Updated the mainifest for Happy Birthday to reflect a new version of the mod. --- GeneralMods/HappyBirthday/manifest.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/GeneralMods/HappyBirthday/manifest.json b/GeneralMods/HappyBirthday/manifest.json index 2cffb970..43131b79 100644 --- a/GeneralMods/HappyBirthday/manifest.json +++ b/GeneralMods/HappyBirthday/manifest.json @@ -3,8 +3,8 @@ "Author": "Alpha_Omegasis", "Version": { "MajorVersion": 1, - "MinorVersion": 4, - "PatchVersion": 3, + "MinorVersion": 5, + "PatchVersion": 0, "Build": null }, "MinimumApiVersion": "1.15", From e6696d8bb09878042c35d4500377289b8961a69e Mon Sep 17 00:00:00 2001 From: Date: Sun, 4 Mar 2018 03:36:19 -0800 Subject: [PATCH 02/54] Made a way to keep track of npcs so that way they can be safely removed before saving and NOT crash the game. --- GeneralMods/CustomNPCFramework/Class1.cs | 24 +++++- .../CustomNPCFramework.csproj | 1 + .../Framework/NPCS/ExtendedNPC.cs | 3 + .../Framework/Utilities/NPCTracker.cs | 84 +++++++++++++++++++ 4 files changed, 111 insertions(+), 1 deletion(-) create mode 100644 GeneralMods/CustomNPCFramework/Framework/Utilities/NPCTracker.cs diff --git a/GeneralMods/CustomNPCFramework/Class1.cs b/GeneralMods/CustomNPCFramework/Class1.cs index 24bdda7f..ef40153a 100644 --- a/GeneralMods/CustomNPCFramework/Class1.cs +++ b/GeneralMods/CustomNPCFramework/Class1.cs @@ -2,6 +2,7 @@ using CustomNPCFramework.Framework.ModularNPCS; using CustomNPCFramework.Framework.ModularNPCS.CharacterAnimationBases; using CustomNPCFramework.Framework.NPCS; +using CustomNPCFramework.Framework.Utilities; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using StardewModdingAPI; @@ -20,6 +21,7 @@ namespace CustomNPCFramework public static IModHelper ModHelper; public static IMonitor ModMonitor; public static AssetManager assetManager; + public static NPCTracker npcTracker; public override void Entry(IModHelper helper) { ModHelper = this.Helper; @@ -28,8 +30,23 @@ namespace CustomNPCFramework initializeExamples(); assetManager.loadAssets(); StardewModdingAPI.Events.SaveEvents.AfterLoad += SaveEvents_LoadChar; + + StardewModdingAPI.Events.SaveEvents.BeforeSave += SaveEvents_BeforeSave; + StardewModdingAPI.Events.SaveEvents.AfterSave += SaveEvents_AfterSave; + StardewModdingAPI.Events.LocationEvents.CurrentLocationChanged += LocationEvents_CurrentLocationChanged; StardewModdingAPI.Events.GameEvents.UpdateTick += GameEvents_UpdateTick; + npcTracker = new NPCTracker(); + } + + private void SaveEvents_AfterSave(object sender, EventArgs e) + { + npcTracker.afterSave(); + } + + private void SaveEvents_BeforeSave(object sender, EventArgs e) + { + npcTracker.cleanUpBeforeSave(); } private void GameEvents_UpdateTick(object sender, EventArgs e) @@ -48,6 +65,11 @@ namespace CustomNPCFramework } + /// + /// Used to spawn a custom npc just as an example. Don't keep this code. + /// + /// + /// private void SaveEvents_LoadChar(object sender, EventArgs e) { string path = Path.Combine(ModHelper.DirectoryPath, "Content", "Graphics", "NPCS", "Characters", "RainMan"); @@ -55,7 +77,7 @@ namespace CustomNPCFramework Texture2D tex = ModHelper.Content.Load(Path.Combine(getShortenedDirectory(path).Remove(0, 1), "character.png")); ModMonitor.Log("PATH???: " + path); ExtendedNPC myNpc3 = new ExtendedNPC(new Framework.ModularNPCS.Sprite(Path.Combine(path,"character.png")),null, new Vector2(14, 14)*Game1.tileSize, 2, "b2"); - Game1.getLocationFromName("BusStop").addCharacter(myNpc3); + npcTracker.addNewNPCToLocation(Game1.getLocationFromName("BusStop"),myNpc3); myNpc3.SetMovingDown(true); } diff --git a/GeneralMods/CustomNPCFramework/CustomNPCFramework.csproj b/GeneralMods/CustomNPCFramework/CustomNPCFramework.csproj index 8711c538..15e84c87 100644 --- a/GeneralMods/CustomNPCFramework/CustomNPCFramework.csproj +++ b/GeneralMods/CustomNPCFramework/CustomNPCFramework.csproj @@ -56,6 +56,7 @@ + diff --git a/GeneralMods/CustomNPCFramework/Framework/NPCS/ExtendedNPC.cs b/GeneralMods/CustomNPCFramework/Framework/NPCS/ExtendedNPC.cs index 173c4e3f..336e15ff 100644 --- a/GeneralMods/CustomNPCFramework/Framework/NPCS/ExtendedNPC.cs +++ b/GeneralMods/CustomNPCFramework/Framework/NPCS/ExtendedNPC.cs @@ -36,6 +36,9 @@ namespace CustomNPCFramework.Framework.NPCS public Sprite spriteInformation; public Portrait portraitInformation; + + public GameLocation defaultLocation; + public ExtendedNPC() :base() { } diff --git a/GeneralMods/CustomNPCFramework/Framework/Utilities/NPCTracker.cs b/GeneralMods/CustomNPCFramework/Framework/Utilities/NPCTracker.cs new file mode 100644 index 00000000..f05bfbe5 --- /dev/null +++ b/GeneralMods/CustomNPCFramework/Framework/Utilities/NPCTracker.cs @@ -0,0 +1,84 @@ +using CustomNPCFramework.Framework.NPCS; +using StardewValley; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CustomNPCFramework.Framework.Utilities +{ + public class NPCTracker + { + public List moddedNPCS; + + + public NPCTracker() + { + this.moddedNPCS = new List(); + } + + /// + /// Use this to add a new npc into the game. + /// + /// + /// + public void addNewNPCToLocation(GameLocation loc,ExtendedNPC npc) + { + this.moddedNPCS.Add(npc); + npc.defaultLocation = loc; + loc.addCharacter(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. + /// + /// + public void removeFromLocationAndTrackingList(ExtendedNPC npc) + { + if (npc.currentLocation != null) + { + npc.currentLocation.characters.Remove(npc); + } + this.moddedNPCS.Remove(npc); + } + + /// + /// Use this to clean up all of the npcs before the game is saved. + /// + public void cleanUpBeforeSave() + { + foreach(ExtendedNPC npc in this.moddedNPCS) + { + //npc.currentLocation.characters.Remove(npc); + //Game1.removeThisCharacterFromAllLocations(npc); + Game1.removeCharacterFromItsLocation(npc.name); + Class1.ModMonitor.Log("Removed an npc!"); + //Do some saving code here. + } + + } + + /// + /// Use this to load in all of the npcs again after saving. + /// + public void afterSave() + { + foreach(ExtendedNPC npc in this.moddedNPCS) + { + npc.defaultLocation.addCharacter(npc); + } + } + + } +} From b9e42ae256d3317e8fcc73bf7ea82a2928895590 Mon Sep 17 00:00:00 2001 From: Date: Sun, 4 Mar 2018 04:36:46 -0800 Subject: [PATCH 03/54] Got the asset loaded up and running. Currently I can load in normal npc sprites using .json files. --- GeneralMods/CustomNPCFramework/Class1.cs | 51 ++++++++++++++---- .../CustomNPCFramework.csproj | 1 + .../Framework/Graphics/AssetManager.cs | 42 ++++++++++++--- .../Framework/Graphics/AssetSheet.cs | 7 ++- .../Graphics/NewFolder1/AssetPool.cs | 53 +++++++++++++++++++ .../Framework/ModularNPCS/Sprite.cs | 15 +++++- .../Framework/NPCS/ExtendedNPC.cs | 2 +- .../Framework/Utilities/NPCTracker.cs | 7 ++- 8 files changed, 155 insertions(+), 23 deletions(-) create mode 100644 GeneralMods/CustomNPCFramework/Framework/Graphics/NewFolder1/AssetPool.cs diff --git a/GeneralMods/CustomNPCFramework/Class1.cs b/GeneralMods/CustomNPCFramework/Class1.cs index ef40153a..2cbc5b97 100644 --- a/GeneralMods/CustomNPCFramework/Class1.cs +++ b/GeneralMods/CustomNPCFramework/Class1.cs @@ -1,4 +1,5 @@ using CustomNPCFramework.Framework.Graphics; +using CustomNPCFramework.Framework.Graphics.NewFolder1; using CustomNPCFramework.Framework.ModularNPCS; using CustomNPCFramework.Framework.ModularNPCS.CharacterAnimationBases; using CustomNPCFramework.Framework.NPCS; @@ -16,19 +17,25 @@ using System.Threading.Tasks; namespace CustomNPCFramework { + /// + /// TODO: + /// List all asset managers in use. + /// Have all asset managers list what assets they are using. + /// + + public class Class1 : Mod { public static IModHelper ModHelper; public static IMonitor ModMonitor; - public static AssetManager assetManager; + public static NPCTracker npcTracker; + public static AssetPool assetPool; public override void Entry(IModHelper helper) { ModHelper = this.Helper; ModMonitor = this.Monitor; - assetManager = new AssetManager(); - initializeExamples(); - assetManager.loadAssets(); + StardewModdingAPI.Events.SaveEvents.AfterLoad += SaveEvents_LoadChar; StardewModdingAPI.Events.SaveEvents.BeforeSave += SaveEvents_BeforeSave; @@ -37,6 +44,18 @@ namespace CustomNPCFramework StardewModdingAPI.Events.LocationEvents.CurrentLocationChanged += LocationEvents_CurrentLocationChanged; StardewModdingAPI.Events.GameEvents.UpdateTick += GameEvents_UpdateTick; npcTracker = new NPCTracker(); + assetPool = new AssetPool(); + var assetManager = new AssetManager(); + assetPool.addAssetManager(new KeyValuePair("testNPC", assetManager)); + initializeExamples(); + initializeAssetPool(); + assetPool.loadAllAssets(); + } + + public void initializeAssetPool() + { + string path = Path.Combine(ModHelper.DirectoryPath, "Content", "Graphics", "NPCS", "Characters", "RainMan"); + assetPool.getAssetManager("testNPC").addPathCreateDirectory(new KeyValuePair("characters", path)); } private void SaveEvents_AfterSave(object sender, EventArgs e) @@ -56,7 +75,7 @@ namespace CustomNPCFramework { v.speed = 5; //v.MovePosition(Game1.currentGameTime, Game1.viewport, Game1.player.currentLocation); - ModMonitor.Log(v.sprite.spriteHeight.ToString()); + //ModMonitor.Log(v.sprite.spriteHeight.ToString()); } } @@ -72,11 +91,20 @@ namespace CustomNPCFramework /// private void SaveEvents_LoadChar(object sender, EventArgs e) { - string path = Path.Combine(ModHelper.DirectoryPath, "Content", "Graphics", "NPCS", "Characters", "RainMan"); - assetManager.addPathCreateDirectory(new KeyValuePair("characters", path)); - Texture2D tex = ModHelper.Content.Load(Path.Combine(getShortenedDirectory(path).Remove(0, 1), "character.png")); - ModMonitor.Log("PATH???: " + path); - ExtendedNPC myNpc3 = new ExtendedNPC(new Framework.ModularNPCS.Sprite(Path.Combine(path,"character.png")),null, new Vector2(14, 14)*Game1.tileSize, 2, "b2"); + + //Texture2D tex = ModHelper.Content.Load(Path.Combine(getShortenedDirectory(path).Remove(0, 1), "character.png")); + if (assetPool.getAssetManager("testNPC").getAssetByName("character") == null) + { + + ModMonitor.Log("HMMMMM", LogLevel.Error); + + } + var pair= assetPool.getAssetManager("testNPC").getAssetByName("character").getPathTexturePair(); + if (pair.Value == null) + { + ModMonitor.Log("UGGGGGGG", LogLevel.Error); + } + ExtendedNPC myNpc3 = new ExtendedNPC(new Framework.ModularNPCS.Sprite(pair.Key,pair.Value),null, new Vector2(14, 14)*Game1.tileSize, 2, "b2"); npcTracker.addNewNPCToLocation(Game1.getLocationFromName("BusStop"),myNpc3); myNpc3.SetMovingDown(true); } @@ -84,7 +112,8 @@ namespace CustomNPCFramework public void initializeExamples() { string dirPath = Path.Combine(ModHelper.DirectoryPath, "Content", "Templates"); - assetManager.addPathCreateDirectory(new KeyValuePair("templates", dirPath)); + var aManager=assetPool.getAssetManager("testNPC"); + aManager.addPathCreateDirectory(new KeyValuePair("templates", dirPath)); string filePath =Path.Combine(dirPath, "Example.json"); if (File.Exists(filePath)) return; string getRelativePath = getShortenedDirectory(filePath); diff --git a/GeneralMods/CustomNPCFramework/CustomNPCFramework.csproj b/GeneralMods/CustomNPCFramework/CustomNPCFramework.csproj index 15e84c87..ad998e2e 100644 --- a/GeneralMods/CustomNPCFramework/CustomNPCFramework.csproj +++ b/GeneralMods/CustomNPCFramework/CustomNPCFramework.csproj @@ -46,6 +46,7 @@ + diff --git a/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetManager.cs b/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetManager.cs index d430ee19..6527f6b7 100644 --- a/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetManager.cs +++ b/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetManager.cs @@ -21,23 +21,49 @@ namespace CustomNPCFramework.Framework.Graphics this.paths = new Dictionary(); } + public AssetManager(Dictionary assetsPathsToLoadFrom) + { + this.assets = new List(); + this.paths = assetsPathsToLoadFrom; + } + /// - /// Default loading function from paths. + /// Default loading function from hard coded paths. /// public void loadAssets() { foreach(var path in this.paths) { - string[] files= Directory.GetFiles(path.Value, "*.json"); - foreach(var file in files) - { - AssetInfo info = AssetInfo.readFromJson(file); - AssetSheet sheet = new AssetSheet(info,path.Value); - this.assets.Add(sheet); - } + 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. + /// + /// + 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); + } + // Recurse into subdirectories of this directory. + string[] subdirectoryEntries = Directory.GetDirectories(targetDirectory); + foreach (string subdirectory in subdirectoryEntries) + ProcessDirectory(subdirectory); + } + + private void ProcessFile(string file,string path) + { + AssetInfo info = AssetInfo.readFromJson(file); + AssetSheet sheet = new AssetSheet(info, path); + addAsset(sheet); + } + /// /// Add an asset to be handled from the asset manager. /// diff --git a/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetSheet.cs b/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetSheet.cs index d07ccdef..98aedc7d 100644 --- a/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetSheet.cs +++ b/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetSheet.cs @@ -31,7 +31,7 @@ namespace CustomNPCFramework.Framework.Graphics { this.assetInfo = info; this.texture = Class1.ModHelper.Content.Load(Class1.getShortenedDirectory(Path.Combine(path,info.name+".png")).Remove(0,1)); - + this.path = Class1.getShortenedDirectory(Path.Combine(path, info.name + ".png")); this.widthIndexMax = this.texture.Width / (int)this.assetInfo.assetSize.X; this.heightIndexMax = this.texture.Width / (int)this.assetInfo.assetSize.Y; this.index = 0; @@ -48,6 +48,11 @@ namespace CustomNPCFramework.Framework.Graphics this.currentAsset = new Rectangle(widthIndex * (int)this.assetInfo.assetSize.X, heightIndex * (int)this.assetInfo.assetSize.Y, (int)this.assetInfo.assetSize.X, (int)this.assetInfo.assetSize.Y); } + public KeyValuePair getPathTexturePair() + { + return new KeyValuePair(this.path, this.texture); + } + /// /// Get the next graphic from the texture. /// diff --git a/GeneralMods/CustomNPCFramework/Framework/Graphics/NewFolder1/AssetPool.cs b/GeneralMods/CustomNPCFramework/Framework/Graphics/NewFolder1/AssetPool.cs new file mode 100644 index 00000000..98a73434 --- /dev/null +++ b/GeneralMods/CustomNPCFramework/Framework/Graphics/NewFolder1/AssetPool.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CustomNPCFramework.Framework.Graphics.NewFolder1 +{ + /// + /// Used to contain all of the asset managers. + /// + public class AssetPool + { + + public Dictionary assetPool; + + public AssetPool() + { + this.assetPool = new Dictionary(); + } + + public void addAssetManager(KeyValuePair pair) + { + this.assetPool.Add(pair.Key,pair.Value); + } + + public void addAssetManager(string assetManagerName, AssetManager assetManager) + { + this.assetPool.Add(assetManagerName, assetManager); + } + + public AssetManager getAssetManager(string name) + { + assetPool.TryGetValue(name, out AssetManager asset); + return asset; + } + + public void removeAssetManager(string key) + { + assetPool.Remove(key); + } + + public void loadAllAssets() + { + foreach(KeyValuePair assetManager in this.assetPool) + { + assetManager.Value.loadAssets(); + } + } + + + } +} diff --git a/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/Sprite.cs b/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/Sprite.cs index 578d7867..f2095393 100644 --- a/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/Sprite.cs +++ b/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/Sprite.cs @@ -15,7 +15,7 @@ namespace CustomNPCFramework.Framework.ModularNPCS public string relativePath; /// - /// A class for handling portraits. + /// A class for handling character sprites. /// /// The full path to the file. public Sprite(string path) @@ -26,6 +26,19 @@ namespace CustomNPCFramework.Framework.ModularNPCS this.sprite.spriteHeight = this.sprite.Texture.Height; } + /// + /// Constructor. + /// + /// 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, Texture2D texture) + { + this.relativePath = path; + this.sprite = new AnimatedSprite(texture); + this.sprite.spriteWidth = this.sprite.Texture.Width; + this.sprite.spriteHeight = this.sprite.Texture.Height; + } + /// /// Sets the npc's portrait to be this portrait texture. /// diff --git a/GeneralMods/CustomNPCFramework/Framework/NPCS/ExtendedNPC.cs b/GeneralMods/CustomNPCFramework/Framework/NPCS/ExtendedNPC.cs index 336e15ff..32c90672 100644 --- a/GeneralMods/CustomNPCFramework/Framework/NPCS/ExtendedNPC.cs +++ b/GeneralMods/CustomNPCFramework/Framework/NPCS/ExtendedNPC.cs @@ -115,6 +115,7 @@ namespace CustomNPCFramework.Framework.NPCS public override bool checkAction(StardewValley.Farmer who, GameLocation l) { + base.checkAction(who, l); return false; } @@ -253,7 +254,6 @@ namespace CustomNPCFramework.Framework.NPCS } } - //ERROR NEED FIXING public override void update(GameTime time, GameLocation location) { base.update(time, location); diff --git a/GeneralMods/CustomNPCFramework/Framework/Utilities/NPCTracker.cs b/GeneralMods/CustomNPCFramework/Framework/Utilities/NPCTracker.cs index f05bfbe5..a3aea34c 100644 --- a/GeneralMods/CustomNPCFramework/Framework/Utilities/NPCTracker.cs +++ b/GeneralMods/CustomNPCFramework/Framework/Utilities/NPCTracker.cs @@ -10,9 +10,14 @@ namespace CustomNPCFramework.Framework.Utilities { public class NPCTracker { + /// + /// A list used to keep track of the npcs. + /// public List moddedNPCS; - + /// + /// Constructor. + /// public NPCTracker() { this.moddedNPCS = new List(); From 005ad14cfd45853792c45069d918c1e8e047fe54 Mon Sep 17 00:00:00 2001 From: Date: Sun, 4 Mar 2018 07:53:55 -0800 Subject: [PATCH 04/54] I think the asset loader works this time. I can have 4 pngs assigned per .json file. Only way to know for sure is to start loading in a ton of art... --- GeneralMods/CustomNPCFramework/Class1.cs | 31 +- .../CustomNPCFramework.csproj | 11 +- .../Framework/Enums/AnimationType.cs | 16 + .../{ModularNPCS => Enums}/Direction.cs | 2 +- .../Framework/Enums/Genders.cs | 18 ++ .../Framework/Enums/PartType.cs | 20 ++ .../Framework/Enums/Seasons.cs | 16 + .../Framework/Graphics/AssetInfo.cs | 37 ++- .../Framework/Graphics/AssetManager.cs | 127 +++++++- .../Framework/Graphics/AssetPool.cs | 284 ++++++++++++++++++ .../Framework/Graphics/AssetSheet.cs | 139 +++------ .../Framework/Graphics/DirectionalTexture.cs | 69 +++++ .../Framework/Graphics/ExtendedAssetInfo.cs | 58 ++++ .../Graphics/NewFolder1/AssetPool.cs | 53 ---- .../ModularNPCS/AnimatedSpriteCollection.cs | 6 +- .../ModularNPCS/AnimatedSpriteExtended.cs | 13 + .../CustomNPCFramework/Framework/NPCNames.cs | 60 ++++ 17 files changed, 777 insertions(+), 183 deletions(-) create mode 100644 GeneralMods/CustomNPCFramework/Framework/Enums/AnimationType.cs rename GeneralMods/CustomNPCFramework/Framework/{ModularNPCS => Enums}/Direction.cs (80%) create mode 100644 GeneralMods/CustomNPCFramework/Framework/Enums/Genders.cs create mode 100644 GeneralMods/CustomNPCFramework/Framework/Enums/PartType.cs create mode 100644 GeneralMods/CustomNPCFramework/Framework/Enums/Seasons.cs create mode 100644 GeneralMods/CustomNPCFramework/Framework/Graphics/AssetPool.cs create mode 100644 GeneralMods/CustomNPCFramework/Framework/Graphics/DirectionalTexture.cs create mode 100644 GeneralMods/CustomNPCFramework/Framework/Graphics/ExtendedAssetInfo.cs delete mode 100644 GeneralMods/CustomNPCFramework/Framework/Graphics/NewFolder1/AssetPool.cs create mode 100644 GeneralMods/CustomNPCFramework/Framework/NPCNames.cs diff --git a/GeneralMods/CustomNPCFramework/Class1.cs b/GeneralMods/CustomNPCFramework/Class1.cs index 2cbc5b97..867b7b2d 100644 --- a/GeneralMods/CustomNPCFramework/Class1.cs +++ b/GeneralMods/CustomNPCFramework/Class1.cs @@ -1,5 +1,5 @@ -using CustomNPCFramework.Framework.Graphics; -using CustomNPCFramework.Framework.Graphics.NewFolder1; +using CustomNPCFramework.Framework.Enums; +using CustomNPCFramework.Framework.Graphics; using CustomNPCFramework.Framework.ModularNPCS; using CustomNPCFramework.Framework.ModularNPCS.CharacterAnimationBases; using CustomNPCFramework.Framework.NPCS; @@ -21,6 +21,7 @@ namespace CustomNPCFramework /// TODO: /// List all asset managers in use. /// Have all asset managers list what assets they are using. + /// FIX NPC GENERATION IN ASSETPOOL.CS /// @@ -111,15 +112,31 @@ namespace CustomNPCFramework public void initializeExamples() { + string dirPath = Path.Combine(ModHelper.DirectoryPath, "Content", "Templates"); var aManager=assetPool.getAssetManager("testNPC"); aManager.addPathCreateDirectory(new KeyValuePair("templates", dirPath)); string filePath =Path.Combine(dirPath, "Example.json"); - if (File.Exists(filePath)) return; - string getRelativePath = getShortenedDirectory(filePath); - ModMonitor.Log("THIS IS THE PATH::: " + getRelativePath); - AssetInfo info = new AssetInfo("Example", new Vector2(16, 16), false); - info.writeToJson(filePath); + if (!File.Exists(filePath)) + { + string getRelativePath = getShortenedDirectory(filePath); + ModMonitor.Log("THIS IS THE PATH::: " + getRelativePath); + AssetInfo info = new AssetInfo("MyExample",new NamePairings("ExampleL","ExampleR","ExampleU","ExampleD"), new Vector2(16, 16), false); + info.writeToJson(filePath); + + } + string filePath2 = Path.Combine(dirPath, "AdvancedExample.json"); + if (!File.Exists(filePath2)) + { + + ExtendedAssetInfo info2 = new ExtendedAssetInfo("AdvancedExample", new NamePairings("AdvancedExampleL", "AdvancedExampleR", "AdvancedExampleU", "AdvancedExampleD"), new Vector2(16, 16), false, Genders.female, new List() + { + Seasons.spring, + Seasons.summer + }, PartType.hair + ); + info2.writeToJson(filePath2); + } } public static string getShortenedDirectory(string path) diff --git a/GeneralMods/CustomNPCFramework/CustomNPCFramework.csproj b/GeneralMods/CustomNPCFramework/CustomNPCFramework.csproj index ad998e2e..ddd6ae3f 100644 --- a/GeneralMods/CustomNPCFramework/CustomNPCFramework.csproj +++ b/GeneralMods/CustomNPCFramework/CustomNPCFramework.csproj @@ -43,19 +43,26 @@ + - + + + + + + - + + diff --git a/GeneralMods/CustomNPCFramework/Framework/Enums/AnimationType.cs b/GeneralMods/CustomNPCFramework/Framework/Enums/AnimationType.cs new file mode 100644 index 00000000..1440f1a4 --- /dev/null +++ b/GeneralMods/CustomNPCFramework/Framework/Enums/AnimationType.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CustomNPCFramework.Framework.Enums +{ + public enum AnimationType + { + standing, + walking, + swimming, + sitting + } +} diff --git a/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/Direction.cs b/GeneralMods/CustomNPCFramework/Framework/Enums/Direction.cs similarity index 80% rename from GeneralMods/CustomNPCFramework/Framework/ModularNPCS/Direction.cs rename to GeneralMods/CustomNPCFramework/Framework/Enums/Direction.cs index e34d3623..bf31c6bc 100644 --- a/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/Direction.cs +++ b/GeneralMods/CustomNPCFramework/Framework/Enums/Direction.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace CustomNPCFramework.Framework.ModularNPCS +namespace CustomNPCFramework.Framework.Enums { public enum Direction { diff --git a/GeneralMods/CustomNPCFramework/Framework/Enums/Genders.cs b/GeneralMods/CustomNPCFramework/Framework/Enums/Genders.cs new file mode 100644 index 00000000..acd8d46e --- /dev/null +++ b/GeneralMods/CustomNPCFramework/Framework/Enums/Genders.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CustomNPCFramework.Framework.Enums +{ + /// + /// Do what you want with this. For code simplicity anything that is non-binary is specified under other. + /// + public enum Genders + { + male, + female, + other + } +} diff --git a/GeneralMods/CustomNPCFramework/Framework/Enums/PartType.cs b/GeneralMods/CustomNPCFramework/Framework/Enums/PartType.cs new file mode 100644 index 00000000..5f20d719 --- /dev/null +++ b/GeneralMods/CustomNPCFramework/Framework/Enums/PartType.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CustomNPCFramework.Framework.Enums +{ + public enum PartType + { + body, + eyes, + hair, + shirt, + pants, + shoes, + accessory, + other + } +} diff --git a/GeneralMods/CustomNPCFramework/Framework/Enums/Seasons.cs b/GeneralMods/CustomNPCFramework/Framework/Enums/Seasons.cs new file mode 100644 index 00000000..97404edd --- /dev/null +++ b/GeneralMods/CustomNPCFramework/Framework/Enums/Seasons.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CustomNPCFramework.Framework.Enums +{ + public enum Seasons + { + spring, + summer, + fall, + winter + } +} diff --git a/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetInfo.cs b/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetInfo.cs index 0ed38ff3..4ec36962 100644 --- a/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetInfo.cs +++ b/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetInfo.cs @@ -9,18 +9,37 @@ namespace CustomNPCFramework.Framework.Graphics { public class AssetInfo { - public string name; + public string assetName; + public string leftAssetName; + public string rightAssetName; + public string upAssetName; + public string downAssetName; public Vector2 assetSize; public bool randomizeUponLoad; - /// - /// A constructor use to create asset info which can then be used to create asset sheets. - /// - /// The name of the texture sheet. Can be different than the actual file name. - /// The size of the individual sprites on the texture sheet. Ex 16x16 pixels. - /// If true, the index for the asset will be randomized. Good for getting variation from a texture. - public AssetInfo(string name, Vector2 assetSize, bool randomizeUponLoad) + + public AssetInfo() { - this.name = name; + + } + + public AssetInfo(string assetName,string Lname, string Rname, string Uname, string Dname, Vector2 assetSize, bool randomizeUponLoad) + { + this.assetName = assetName; + this.leftAssetName = Lname; + this.rightAssetName = Rname; + this.upAssetName = Uname; + this.downAssetName = Dname; + this.assetSize = assetSize; + this.randomizeUponLoad = randomizeUponLoad; + } + + public AssetInfo(string assetName,NamePairings pair, Vector2 assetSize, bool randomizeUponLoad) + { + this.assetName = assetName; + this.leftAssetName = pair.leftString; + this.rightAssetName = pair.rightString; + this.upAssetName = pair.upString; + this.downAssetName = pair.downString; this.assetSize = assetSize; this.randomizeUponLoad = randomizeUponLoad; } diff --git a/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetManager.cs b/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetManager.cs index 6527f6b7..40fb18e1 100644 --- a/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetManager.cs +++ b/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetManager.cs @@ -1,4 +1,5 @@ -using System; +using CustomNPCFramework.Framework.Enums; +using System; using System.Collections.Generic; using System.IO; using System.Linq; @@ -59,9 +60,18 @@ namespace CustomNPCFramework.Framework.Graphics private void ProcessFile(string file,string path) { - AssetInfo info = AssetInfo.readFromJson(file); - AssetSheet sheet = new AssetSheet(info, path); - addAsset(sheet); + try + { + ExtendedAssetInfo info = ExtendedAssetInfo.readFromJson(file); + AssetSheet sheet = new AssetSheet(info, path); + addAsset(sheet); + } + catch (Exception err) + { + AssetInfo info = AssetInfo.readFromJson(file); + AssetSheet sheet = new AssetSheet(info, path); + addAsset(sheet); + } } /// @@ -82,7 +92,7 @@ namespace CustomNPCFramework.Framework.Graphics { foreach(var v in assets) { - if (v.assetInfo.name == s) return v; + if (v.assetInfo.assetName == s) return v; } return null; } @@ -120,5 +130,112 @@ namespace CustomNPCFramework.Framework.Graphics 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. + /// + public List getListOfAssetsThatMatchThisCriteria(Genders gender) + { + List aSheet = new List(); + foreach(var v in this.assets) + { + if(v.assetInfo is ExtendedAssetInfo) + { + if ((v.assetInfo as ExtendedAssetInfo).gender == gender) aSheet.Add(v); + } + } + return aSheet; + } + + public List getListOfAssetsThatMatchThisCriteria(PartType type) + { + List aSheet = new List(); + foreach (var v in this.assets) + { + if (v.assetInfo is ExtendedAssetInfo) + { + if ((v.assetInfo as ExtendedAssetInfo).type == type) aSheet.Add(v); + } + } + return aSheet; + } + + public List getListOfAssetsThatMatchThisCriteria(Genders gender,PartType type) + { + List aSheet = new List(); + foreach (var v in this.assets) + { + if (v.assetInfo is ExtendedAssetInfo) + { + if ((v.assetInfo as ExtendedAssetInfo).type == type && (v.assetInfo as ExtendedAssetInfo).gender == gender) aSheet.Add(v); + } + } + return aSheet; + } + + /// + /// Returns a list of assets from this manager that match the given critera. + /// + /// The criteria we are searching for this time is gender. + /// + public List getListOfAssetsThatMatchThisCriteria(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) { + 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) + { + if (sea == season && (v.assetInfo as ExtendedAssetInfo).gender==gender) aSheet.Add(v); + break; //Only need to find first validation that this is a valid asset. + } + } + } + return aSheet; + } + + public List getListOfAssetsThatMatchThisCriteria(Genders gender, Seasons season, PartType type) + { + List aSheet = new List(); + foreach (var v in this.assets) + { + if (v.assetInfo is ExtendedAssetInfo) + { + foreach (var sea in (v.assetInfo as ExtendedAssetInfo).seasons) + { + if (sea == season && (v.assetInfo as ExtendedAssetInfo).gender == gender && (v.assetInfo as ExtendedAssetInfo).type == type) aSheet.Add(v); + break; //Only need to find first validation that this is a valid asset. + } + } + } + return aSheet; + } + + } } diff --git a/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetPool.cs b/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetPool.cs new file mode 100644 index 00000000..58d11b0c --- /dev/null +++ b/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetPool.cs @@ -0,0 +1,284 @@ + +using CustomNPCFramework.Framework.Enums; +using CustomNPCFramework.Framework.ModularNPCS; +using CustomNPCFramework.Framework.ModularNPCS.CharacterAnimationBases; +using CustomNPCFramework.Framework.ModularNPCS.ModularRenderers; +using CustomNPCFramework.Framework.NPCS; +using StardewValley; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CustomNPCFramework.Framework.Graphics +{ + /// + /// Used to contain all of the asset managers. + /// + /// + + 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) + { + this.leftString = LeftString; + this.rightString = RightString; + this.upString = UpString; + this.downString = DownString; + } + } + + public class AssetPool + { + + public Dictionary assetPool; + + public AssetPool() + { + this.assetPool = new Dictionary(); + } + + public void addAssetManager(KeyValuePair pair) + { + this.assetPool.Add(pair.Key, pair.Value); + } + + public void addAssetManager(string assetManagerName, AssetManager assetManager) + { + this.assetPool.Add(assetManagerName, assetManager); + } + + public AssetManager getAssetManager(string name) + { + assetPool.TryGetValue(name, out AssetManager asset); + return asset; + } + + public void removeAssetManager(string key) + { + assetPool.Remove(key); + } + + 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. + /// + /// + /// + public AnimatedSpriteExtended getAnimatedSpriteFromAsset(string name) + { + assetPool.TryGetValue(name, out AssetManager asset); + var assetSheet = asset.getAssetByName(name); + return new AnimatedSpriteExtended(assetSheet.clone().texture.currentTexture, assetSheet.index, (int)assetSheet.assetInfo.assetSize.X, (int)assetSheet.assetInfo.assetSize.Y); + } + + + public AnimatedSpriteCollection getSpriteCollectionFromSheet(AssetSheet assetSheet) + { + var left=new AnimatedSpriteExtended(assetSheet.clone().texture.leftTexture, assetSheet.index, (int)assetSheet.assetInfo.assetSize.X, (int)assetSheet.assetInfo.assetSize.Y); + var right = new AnimatedSpriteExtended(assetSheet.clone().texture.rightTexture, assetSheet.index, (int)assetSheet.assetInfo.assetSize.X, (int)assetSheet.assetInfo.assetSize.Y); + var up = new AnimatedSpriteExtended(assetSheet.clone().texture.upTexture, assetSheet.index, (int)assetSheet.assetInfo.assetSize.X, (int)assetSheet.assetInfo.assetSize.Y); + var down = new AnimatedSpriteExtended(assetSheet.clone().texture.downTexture, assetSheet.index, (int)assetSheet.assetInfo.assetSize.X, (int)assetSheet.assetInfo.assetSize.Y); + 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. + /// + /// 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. + /// + /// + 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); + + } + + public AnimatedSpriteCollection getAnimatedSpriteCollectionFromAssets(NamePairings pair, Direction startingDirection = Direction.down) + { + return getAnimatedSpriteCollectionFromAssets(pair.leftString, pair.rightString, pair.upString, pair.downString); + } + + public StandardCharacterAnimation GetStandardCharacterAnimation(NamePairings BodySprites, NamePairings EyeSprites, NamePairings HairSprites, NamePairings ShirtsSprites, NamePairings PantsSprites, NamePairings ShoesSprites,List AccessoriesSprites) + { + var body = getAnimatedSpriteCollectionFromAssets(BodySprites); + var eyes = getAnimatedSpriteCollectionFromAssets(EyeSprites); + var hair = getAnimatedSpriteCollectionFromAssets(HairSprites); + var shirts = getAnimatedSpriteCollectionFromAssets(ShirtsSprites); + var pants = getAnimatedSpriteCollectionFromAssets(PantsSprites); + var shoes = getAnimatedSpriteCollectionFromAssets(ShoesSprites); + List accessories = new List(); + foreach(var v in AccessoriesSprites) + { + accessories.Add(getAnimatedSpriteCollectionFromAssets(v)); + } + return new StandardCharacterAnimation(body,eyes,hair,shirts,pants,shoes,accessories); + } + + public List getListOfApplicableBodyParts(string assetManagerName,Genders gender, Seasons season, PartType type) + { + var parts = this.getAssetManager(assetManagerName).getListOfAssetsThatMatchThisCriteria(gender, season, type); + return parts; + } + + public void generateNPC(Genders gender, int minNumOfAccessories, int maxNumOfAccessories) + { + Seasons myseason=Seasons.spring; + + AnimationType currentType = AnimationType.standing; + + if (Game1.currentSeason == "spring") myseason = Seasons.spring; + if (Game1.currentSeason == "summer") myseason = Seasons.summer; + if (Game1.currentSeason == "fall") myseason = Seasons.fall; + if (Game1.currentSeason == "winter") myseason = Seasons.winter; + + List bodyList = new List(); + List eyesList = new List(); + List hairList = new List(); + List shirtList = new List(); + List shoesList = new List(); + List pantsList = new List(); + List accessoryList = new List(); + + //Get all applicable parts from this current asset manager + foreach (var assetManager in this.assetPool) + { + var body = getListOfApplicableBodyParts(assetManager.Key, gender, myseason, PartType.body); + foreach (var piece in body) bodyList.Add(piece); + + var eyes = getListOfApplicableBodyParts(assetManager.Key, gender, myseason, PartType.eyes); + foreach (var piece in eyes) eyesList.Add(piece); + + var hair = getListOfApplicableBodyParts(assetManager.Key, gender, myseason, PartType.hair); + foreach (var piece in hair) hairList.Add(piece); + + var shirt = getListOfApplicableBodyParts(assetManager.Key, gender, myseason, PartType.shirt); + foreach (var piece in shirt) shirtList.Add(piece); + + var pants = getListOfApplicableBodyParts(assetManager.Key, gender, myseason, PartType.pants); + foreach (var piece in pants) pantsList.Add(piece); + + var shoes = getListOfApplicableBodyParts(assetManager.Key, gender, myseason, PartType.shoes); + foreach (var piece in shoes) bodyList.Add(piece); + + var accessory = getListOfApplicableBodyParts(assetManager.Key, gender, myseason, PartType.accessory); + foreach (var piece in accessory) accessoryList.Add(piece); + } + + Random r = new Random(Game1.random.Next()); + int amount = r.Next(minNumOfAccessories, maxNumOfAccessories); + + int bodyIndex = r.Next(0, bodyList.Count - 1); + int eyesIndex = r.Next(0, eyesList.Count - 1); + int hairIndex = r.Next(0, hairList.Count - 1); + int shirtIndex = r.Next(0, shirtList.Count - 1); + int pantsIndex = r.Next(0, pantsList.Count - 1); + int shoesIndex = r.Next(0, shoesList.Count - 1); + List accIntList = new List(); + for (int i = 0; i < amount; i++) + { + int acc = r.Next(0, accessoryList.Count - 1); + accIntList.Add(acc); + } + + AssetSheet bodySheet = bodyList.ElementAt(bodyIndex); + AssetSheet eyesSheet = eyesList.ElementAt(bodyIndex); + AssetSheet hairSheet = hairList.ElementAt(bodyIndex); + AssetSheet shirtSheet = shirtList.ElementAt(bodyIndex); + AssetSheet pantsSheet = pantsList.ElementAt(bodyIndex); + AssetSheet shoesSheet = shoesList.ElementAt(bodyIndex); + List accessorySheet = new List(); + + foreach (var v in accIntList) + { + accessorySheet.Add(accessoryList.ElementAt(v)); + } + + var bodySprite = getSpriteCollectionFromSheet(bodySheet); + var eyesSprite = getSpriteCollectionFromSheet(eyesSheet); + var hairSprite = getSpriteCollectionFromSheet(hairSheet); + var shirtSprite = getSpriteCollectionFromSheet(shirtSheet); + var pantsSprite = getSpriteCollectionFromSheet(pantsSheet); + var shoesSprite = getSpriteCollectionFromSheet(shoesSheet); + List accessoryCollection = new List(); + foreach(var v in accessorySheet) + { + AnimatedSpriteCollection acc = getSpriteCollectionFromSheet(v); + accessoryCollection.Add(acc); + } + + StandardCharacterAnimation standingAnimation = new StandardCharacterAnimation(bodySprite, eyesSprite, hairSprite, shirtSprite, pantsSprite, shoesSprite, accessoryCollection); + + + + BasicRenderer render = new BasicRenderer(standingAnimation,standingAnimation,standingAnimation); + + ExtendedNPC npc = new ExtendedNPC(null, render, new Microsoft.Xna.Framework.Vector2(13, 15) * Game1.tileSize, 2, NPCNames.getRandomNPCName(gender)); + + } + + + /* + public void generateNPC(string assetManagerName,Genders gender, Seasons season, int minNumOfAccessories,int maxNumOfAccessories) + { + var body= this.getAssetManager(assetManagerName).getListOfAssetsThatMatchThisCriteria(gender, season, PartType.body); + var eyes = this.getAssetManager(assetManagerName).getListOfAssetsThatMatchThisCriteria(gender, season, PartType.eyes); + var hair = this.getAssetManager(assetManagerName).getListOfAssetsThatMatchThisCriteria(gender, season, PartType.hair); + var shirt = this.getAssetManager(assetManagerName).getListOfAssetsThatMatchThisCriteria(gender, season, PartType.shirt); + var pants = this.getAssetManager(assetManagerName).getListOfAssetsThatMatchThisCriteria(gender, season, PartType.pants); + var shoes = this.getAssetManager(assetManagerName).getListOfAssetsThatMatchThisCriteria(gender, season, PartType.shoes); + List accessories = new List(); + Random r = new Random(Game1.random.Next()); + int amount=r.Next(minNumOfAccessories, maxNumOfAccessories); + var accessoriesList= this.getAssetManager(assetManagerName).getListOfAssetsThatMatchThisCriteria(gender, season, PartType.shoes); + + int bodyIndex = r.Next(0, body.Count - 1); + int eyesIndex = r.Next(0, eyes.Count - 1); + int hairIndex = r.Next(0, hair.Count - 1); + int shirtIndex = r.Next(0, shirt.Count - 1); + int pantsIndex = r.Next(0, pants.Count - 1); + int shoesIndex = r.Next(0, shoes.Count - 1); + List accIntList = new List(); + for(int i=0; i < amount; i++) + { + int acc= r.Next(0, accessoriesList.Count - 1); + accIntList.Add(acc); + } + + AssetSheet bodySheet = body.ElementAt(bodyIndex); + AssetSheet eyesSheet = body.ElementAt(bodyIndex); + AssetSheet hairSheet = body.ElementAt(bodyIndex); + AssetSheet shirtSheet = body.ElementAt(bodyIndex); + AssetSheet pantsSheet = body.ElementAt(bodyIndex); + AssetSheet shoesSheet = body.ElementAt(bodyIndex); + + foreach(var v in accIntList) + { + accessories.Add(accessoriesList.ElementAt(v)); + } + + + } + */ + + } +} diff --git a/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetSheet.cs b/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetSheet.cs index 98aedc7d..916cb21e 100644 --- a/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetSheet.cs +++ b/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetSheet.cs @@ -1,4 +1,5 @@ -using Microsoft.Xna.Framework; +using CustomNPCFramework.Framework.Enums; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; using System.Collections.Generic; @@ -14,132 +15,60 @@ namespace CustomNPCFramework.Framework.Graphics /// public class AssetSheet { - public Texture2D texture; + public DirectionalTexture texture; + public AssetInfo assetInfo; public string path; public int index; - private int widthIndex; - private int heightIndex; - private int widthIndexMax; - private int heightIndexMax; - public Rectangle currentAsset; - public AssetSheet(AssetInfo info,string path) + public AssetSheet(AssetInfo info,string path,Direction direction=Direction.down) { this.assetInfo = info; - this.texture = Class1.ModHelper.Content.Load(Class1.getShortenedDirectory(Path.Combine(path,info.name+".png")).Remove(0,1)); - this.path = Class1.getShortenedDirectory(Path.Combine(path, info.name + ".png")); - this.widthIndexMax = this.texture.Width / (int)this.assetInfo.assetSize.X; - this.heightIndexMax = this.texture.Width / (int)this.assetInfo.assetSize.Y; + + this.texture = new DirectionalTexture(info, path, direction); + + this.path = Class1.getShortenedDirectory(path); this.index = 0; - if (this.assetInfo.randomizeUponLoad == false) - { - this.widthIndex = 0; - this.heightIndex = 0; - } - else - { - getRandomAssetIndicies(); - setIndex(); - } - this.currentAsset = new Rectangle(widthIndex * (int)this.assetInfo.assetSize.X, heightIndex * (int)this.assetInfo.assetSize.Y, (int)this.assetInfo.assetSize.X, (int)this.assetInfo.assetSize.Y); + } public KeyValuePair getPathTexturePair() { - return new KeyValuePair(this.path, this.texture); + return new KeyValuePair(this.path, this.texture.currentTexture); } - /// - /// Get the next graphic from the texture. - /// - public void getNext() - { - //If I can still iterate through my list but my width is maxed, increment height. - if (this.widthIndex == this.widthIndexMax - 1 && this.heightIndex != this.heightIndexMax) - { - this.widthIndex -= 0; - this.heightIndex++; - } - //If I reached the end of my image loop to 0; - else if (this.heightIndex == this.heightIndexMax && this.widthIndex == this.widthIndexMax - 1) - { - this.heightIndex = 0; - this.widthIndex = 0; - } - else - { - //If I can still iterate through my list do so. - widthIndex++; - } - this.setIndex(); - this.setAsset(); - } - - /// - /// Get the last graphic from my texture. - /// - public void getPrevious() - { - //If my width index is 0 and my height index isn't decrement my height index and set the width index to the far right. - if (this.widthIndex == 0 && this.heightIndex != 0) - { - this.heightIndex--; - this.widthIndex = this.widthIndexMax - 1; - } - //If both my height and width indicies are 0, loop to the bottom right of the texture. - else if (this.widthIndex == 0 && this.heightIndex == 0) - { - this.widthIndex = this.widthIndexMax - 1; - this.heightIndex = this.heightIndexMax - 1; - } - else - { - //Just decrement my width index by 1. - this.widthIndex--; - } - this.setIndex(); - this.setAsset(); - } - - /// - /// sets the current positioning for the rectangle index; - /// - private void setAsset() - { - this.currentAsset.X = widthIndex * (int)this.assetInfo.assetSize.X; - this.currentAsset.Y = heightIndex * (int)this.assetInfo.assetSize.Y; - } - - /// - /// Used mainly for display purposes and length purposes. - /// - public void setIndex() - { - this.index = heightIndex * widthIndexMax + widthIndex; - } - - /// - /// Sets the asset index to a random value. - /// - public void getRandomAssetIndicies() - { - Random r = new Random(DateTime.Now.Millisecond); - this.widthIndex = r.Next(0, this.widthIndexMax); - this.widthIndex = r.Next(0, this.heightIndexMax); - setIndex(); - setAsset(); - } /// /// Used just to get a copy of this asset sheet. /// - public void clone() + public AssetSheet clone() { var asset = new AssetSheet(this.assetInfo,(string)this.path.Clone()); + return asset; + } + + + public void setLeft() + { + this.texture.setLeft(); + } + + public void setUp() + { + this.texture.setUp(); + } + + public void setDown() + { + this.texture.setDown(); + } + + public void setRight() + { + this.texture.setRight(); } } } diff --git a/GeneralMods/CustomNPCFramework/Framework/Graphics/DirectionalTexture.cs b/GeneralMods/CustomNPCFramework/Framework/Graphics/DirectionalTexture.cs new file mode 100644 index 00000000..a69d1535 --- /dev/null +++ b/GeneralMods/CustomNPCFramework/Framework/Graphics/DirectionalTexture.cs @@ -0,0 +1,69 @@ +using CustomNPCFramework.Framework.Enums; +using Microsoft.Xna.Framework.Graphics; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CustomNPCFramework.Framework.Graphics +{ + public class DirectionalTexture + { + public Texture2D leftTexture; + public Texture2D rightTexture; + public Texture2D downTexture; + public Texture2D upTexture; + + public Texture2D currentTexture; + + public DirectionalTexture(Texture2D left, Texture2D right, Texture2D up, Texture2D 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; + + + } + + public DirectionalTexture(AssetInfo info, string path, Direction direction = Direction.down) + { + this.leftTexture = Class1.ModHelper.Content.Load(Class1.getShortenedDirectory(Path.Combine(path, info.leftAssetName + ".png")).Remove(0, 1)); + this.rightTexture = Class1.ModHelper.Content.Load(Class1.getShortenedDirectory(Path.Combine(path, info.rightAssetName + ".png")).Remove(0, 1)); + this.upTexture = Class1.ModHelper.Content.Load(Class1.getShortenedDirectory(Path.Combine(path, info.upAssetName + ".png")).Remove(0, 1)); + this.downTexture = Class1.ModHelper.Content.Load(Class1.getShortenedDirectory(Path.Combine(path, info.downAssetName + ".png")).Remove(0, 1)); + + 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; + } + + public void setLeft() + { + this.currentTexture = leftTexture; + } + + public void setUp() + { + this.currentTexture = upTexture; + } + + public void setDown() + { + this.currentTexture = downTexture; + } + + public void setRight() + { + this.currentTexture = rightTexture; + } + } +} diff --git a/GeneralMods/CustomNPCFramework/Framework/Graphics/ExtendedAssetInfo.cs b/GeneralMods/CustomNPCFramework/Framework/Graphics/ExtendedAssetInfo.cs new file mode 100644 index 00000000..09521a8e --- /dev/null +++ b/GeneralMods/CustomNPCFramework/Framework/Graphics/ExtendedAssetInfo.cs @@ -0,0 +1,58 @@ +using CustomNPCFramework.Framework.Enums; +using Microsoft.Xna.Framework; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CustomNPCFramework.Framework.Graphics +{ + public class ExtendedAssetInfo :AssetInfo + { + public Genders gender; + public List seasons; + public PartType type; + public AnimationType animationType; + + public ExtendedAssetInfo() + { + + } + + /// + /// 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 pair,Vector2 assetSize, bool randomizeOnLoad, Genders Gender, List Season, PartType Type): base(name,pair, assetSize, randomizeOnLoad) + { + this.gender = Gender; + this.seasons = Season; + this.type = Type; + } + + /// + /// Save the json to a certain location. + /// + /// + public new void writeToJson(string path) + { + Class1.ModHelper.WriteJsonFile(path, this); + } + + /// + /// Read the json from a certain location. + /// + /// + /// + public new static ExtendedAssetInfo readFromJson(string path) + { + return Class1.ModHelper.ReadJsonFile(path); + } + + } +} diff --git a/GeneralMods/CustomNPCFramework/Framework/Graphics/NewFolder1/AssetPool.cs b/GeneralMods/CustomNPCFramework/Framework/Graphics/NewFolder1/AssetPool.cs deleted file mode 100644 index 98a73434..00000000 --- a/GeneralMods/CustomNPCFramework/Framework/Graphics/NewFolder1/AssetPool.cs +++ /dev/null @@ -1,53 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace CustomNPCFramework.Framework.Graphics.NewFolder1 -{ - /// - /// Used to contain all of the asset managers. - /// - public class AssetPool - { - - public Dictionary assetPool; - - public AssetPool() - { - this.assetPool = new Dictionary(); - } - - public void addAssetManager(KeyValuePair pair) - { - this.assetPool.Add(pair.Key,pair.Value); - } - - public void addAssetManager(string assetManagerName, AssetManager assetManager) - { - this.assetPool.Add(assetManagerName, assetManager); - } - - public AssetManager getAssetManager(string name) - { - assetPool.TryGetValue(name, out AssetManager asset); - return asset; - } - - public void removeAssetManager(string key) - { - assetPool.Remove(key); - } - - public void loadAllAssets() - { - foreach(KeyValuePair assetManager in this.assetPool) - { - assetManager.Value.loadAssets(); - } - } - - - } -} diff --git a/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/AnimatedSpriteCollection.cs b/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/AnimatedSpriteCollection.cs index 711eb092..7098da73 100644 --- a/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/AnimatedSpriteCollection.cs +++ b/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/AnimatedSpriteCollection.cs @@ -1,4 +1,5 @@ -using CustomNPCFramework.Framework.NPCS; +using CustomNPCFramework.Framework.Enums; +using CustomNPCFramework.Framework.NPCS; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using StardewValley; @@ -10,6 +11,9 @@ using System.Threading.Tasks; namespace CustomNPCFramework.Framework.ModularNPCS { + /// + /// Used to hold all of the sprites for a single asset such as hair or bodies. + /// public class AnimatedSpriteCollection { AnimatedSpriteExtended leftSprite; diff --git a/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/AnimatedSpriteExtended.cs b/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/AnimatedSpriteExtended.cs index 037b3679..3a467e5f 100644 --- a/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/AnimatedSpriteExtended.cs +++ b/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/AnimatedSpriteExtended.cs @@ -28,6 +28,19 @@ namespace CustomNPCFramework.Framework.ModularNPCS this.sprite=new AnimatedSprite(Class1.ModHelper.Content.Load(this.path),currentFrame,spriteWidth,spriteHeight); } + /// + /// Constructor. + /// + /// The texture for the sprite. + /// Starting animation frame. + /// Sprite width. + /// Sprite height + public AnimatedSpriteExtended(Texture2D texture, int currentFrame, int spriteWidth, int spriteHeight) + { + this.path = Class1.getRelativeDirectory(path); + this.sprite = new AnimatedSprite(texture, currentFrame, spriteWidth, spriteHeight); + } + /// /// Reloads the asset from disk. /// diff --git a/GeneralMods/CustomNPCFramework/Framework/NPCNames.cs b/GeneralMods/CustomNPCFramework/Framework/NPCNames.cs new file mode 100644 index 00000000..f849952c --- /dev/null +++ b/GeneralMods/CustomNPCFramework/Framework/NPCNames.cs @@ -0,0 +1,60 @@ +using CustomNPCFramework.Framework.Enums; +using StardewValley; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CustomNPCFramework.Framework +{ + public class NPCNames + { + public static List maleNames = new List() + { + "Freddy", + "Josh", + "Ash" + }; + + public static List femaleNames = new List() + { + "Rebecca", + "Sierra", + "Lisa" + }; + + public static List otherGenderNames = new List() + { + "Jayden", + "Ryanne", + "Skylar" + }; + + public static string getRandomNPCName(Genders gender) + { + 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 ""; + + } + } +} From d5536b9e52d31fceaa07b265d5bd056d41880705 Mon Sep 17 00:00:00 2001 From: Date: Sun, 4 Mar 2018 13:23:40 -0800 Subject: [PATCH 05/54] Getting closer to the finished product. Assets are grouped together now with .json holding all the info for the different animation types. --- GeneralMods/CustomNPCFramework/Class1.cs | 4 +- .../CustomNPCFramework.csproj | 1 + .../Framework/Graphics/AssetInfo.cs | 29 ++---- .../Framework/Graphics/AssetPool.cs | 20 ++-- .../Framework/Graphics/AssetSheet.cs | 38 +++++--- .../Framework/Graphics/DirectionalTexture.cs | 19 +++- .../Graphics/TextureGroups/TextureGroup.cs | 92 +++++++++++++++++++ 7 files changed, 156 insertions(+), 47 deletions(-) create mode 100644 GeneralMods/CustomNPCFramework/Framework/Graphics/TextureGroups/TextureGroup.cs diff --git a/GeneralMods/CustomNPCFramework/Class1.cs b/GeneralMods/CustomNPCFramework/Class1.cs index 867b7b2d..a666b961 100644 --- a/GeneralMods/CustomNPCFramework/Class1.cs +++ b/GeneralMods/CustomNPCFramework/Class1.cs @@ -22,6 +22,8 @@ namespace CustomNPCFramework /// List all asset managers in use. /// Have all asset managers list what assets they are using. /// FIX NPC GENERATION IN ASSETPOOL.CS + /// + /// Load in the assets and go go go. /// @@ -121,7 +123,7 @@ namespace CustomNPCFramework { string getRelativePath = getShortenedDirectory(filePath); ModMonitor.Log("THIS IS THE PATH::: " + getRelativePath); - AssetInfo info = new AssetInfo("MyExample",new NamePairings("ExampleL","ExampleR","ExampleU","ExampleD"), 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); } diff --git a/GeneralMods/CustomNPCFramework/CustomNPCFramework.csproj b/GeneralMods/CustomNPCFramework/CustomNPCFramework.csproj index ddd6ae3f..254d76b4 100644 --- a/GeneralMods/CustomNPCFramework/CustomNPCFramework.csproj +++ b/GeneralMods/CustomNPCFramework/CustomNPCFramework.csproj @@ -53,6 +53,7 @@ + diff --git a/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetInfo.cs b/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetInfo.cs index 4ec36962..a326bf22 100644 --- a/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetInfo.cs +++ b/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetInfo.cs @@ -10,9 +10,10 @@ namespace CustomNPCFramework.Framework.Graphics public class AssetInfo { public string assetName; - public string leftAssetName; - public string rightAssetName; - public string upAssetName; + public NamePairings standingAssetPaths; + public NamePairings swimmingAssetPaths; + public NamePairings movingAssetPaths; + public NamePairings sittingAssetPaths; public string downAssetName; public Vector2 assetSize; public bool randomizeUponLoad; @@ -22,24 +23,12 @@ namespace CustomNPCFramework.Framework.Graphics } - public AssetInfo(string assetName,string Lname, string Rname, string Uname, string Dname, Vector2 assetSize, bool randomizeUponLoad) + public AssetInfo(string assetName,NamePairings StandingAssetPaths, NamePairings MovingAssetPaths, NamePairings SwimmingAssetPaths, NamePairings SittingAssetPaths, Vector2 assetSize, bool randomizeUponLoad) { - this.assetName = assetName; - this.leftAssetName = Lname; - this.rightAssetName = Rname; - this.upAssetName = Uname; - this.downAssetName = Dname; - this.assetSize = assetSize; - this.randomizeUponLoad = randomizeUponLoad; - } - - public AssetInfo(string assetName,NamePairings pair, Vector2 assetSize, bool randomizeUponLoad) - { - this.assetName = assetName; - this.leftAssetName = pair.leftString; - this.rightAssetName = pair.rightString; - this.upAssetName = pair.upString; - this.downAssetName = pair.downString; + this.sittingAssetPaths = SittingAssetPaths; + this.standingAssetPaths = StandingAssetPaths; + this.movingAssetPaths = MovingAssetPaths; + this.swimmingAssetPaths = SwimmingAssetPaths; this.assetSize = assetSize; this.randomizeUponLoad = randomizeUponLoad; } diff --git a/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetPool.cs b/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetPool.cs index 58d11b0c..7c6d223e 100644 --- a/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetPool.cs +++ b/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetPool.cs @@ -81,18 +81,24 @@ namespace CustomNPCFramework.Framework.Graphics { assetPool.TryGetValue(name, out AssetManager asset); var assetSheet = asset.getAssetByName(name); - return new AnimatedSpriteExtended(assetSheet.clone().texture.currentTexture, assetSheet.index, (int)assetSheet.assetInfo.assetSize.X, (int)assetSheet.assetInfo.assetSize.Y); + return new AnimatedSpriteExtended(assetSheet.clone().getCurrentSpriteTexture(), assetSheet.index, (int)assetSheet.assetInfo.assetSize.X, (int)assetSheet.assetInfo.assetSize.Y); } - public AnimatedSpriteCollection getSpriteCollectionFromSheet(AssetSheet assetSheet) + + public AnimatedSpriteCollection getSpriteCollectionFromSheet(AssetSheet assetSheet, AnimationType type) { - var left=new AnimatedSpriteExtended(assetSheet.clone().texture.leftTexture, assetSheet.index, (int)assetSheet.assetInfo.assetSize.X, (int)assetSheet.assetInfo.assetSize.Y); - var right = new AnimatedSpriteExtended(assetSheet.clone().texture.rightTexture, assetSheet.index, (int)assetSheet.assetInfo.assetSize.X, (int)assetSheet.assetInfo.assetSize.Y); - var up = new AnimatedSpriteExtended(assetSheet.clone().texture.upTexture, assetSheet.index, (int)assetSheet.assetInfo.assetSize.X, (int)assetSheet.assetInfo.assetSize.Y); - var down = new AnimatedSpriteExtended(assetSheet.clone().texture.downTexture, assetSheet.index, (int)assetSheet.assetInfo.assetSize.X, (int)assetSheet.assetInfo.assetSize.Y); - return new AnimatedSpriteCollection(left, right, up, down, Direction.down); + if (type == AnimationType.standing) + { + var ok = assetSheet.getTexture(Direction, AnimationType); + var left = new AnimatedSpriteExtended(assetSheet.clone().textures.standingTexture.leftTexture, assetSheet.index, (int)assetSheet.assetInfo.assetSize.X, (int)assetSheet.assetInfo.assetSize.Y); + var right = new AnimatedSpriteExtended(assetSheet.clone().texture.rightTexture, assetSheet.index, (int)assetSheet.assetInfo.assetSize.X, (int)assetSheet.assetInfo.assetSize.Y); + var up = new AnimatedSpriteExtended(assetSheet.clone().texture.upTexture, assetSheet.index, (int)assetSheet.assetInfo.assetSize.X, (int)assetSheet.assetInfo.assetSize.Y); + var down = new AnimatedSpriteExtended(assetSheet.clone().texture.downTexture, assetSheet.index, (int)assetSheet.assetInfo.assetSize.X, (int)assetSheet.assetInfo.assetSize.Y); + 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. diff --git a/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetSheet.cs b/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetSheet.cs index 916cb21e..875ab188 100644 --- a/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetSheet.cs +++ b/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetSheet.cs @@ -15,7 +15,7 @@ namespace CustomNPCFramework.Framework.Graphics /// public class AssetSheet { - public DirectionalTexture texture; + public TextureGroups.TextureGroup textures; public AssetInfo assetInfo; public string path; @@ -28,47 +28,57 @@ namespace CustomNPCFramework.Framework.Graphics { this.assetInfo = info; - this.texture = new DirectionalTexture(info, path, direction); - + + this.path = Class1.getShortenedDirectory(path); this.index = 0; } - public KeyValuePair getPathTexturePair() + public virtual KeyValuePair getPathTexturePair() { - return new KeyValuePair(this.path, this.texture.currentTexture); + return new KeyValuePair(this.path, this.textures.currentTexture.currentTexture); } /// /// Used just to get a copy of this asset sheet. /// - public AssetSheet clone() + public virtual AssetSheet clone() { var asset = new AssetSheet(this.assetInfo,(string)this.path.Clone()); return asset; } - public void setLeft() + public virtual void setLeft() { - this.texture.setLeft(); + this.textures.setLeft(); } - public void setUp() + public virtual void setUp() { - this.texture.setUp(); + this.textures.setUp(); } - public void setDown() + public virtual void setDown() { - this.texture.setDown(); + this.textures.setDown(); } - public void setRight() + public virtual void setRight() { - this.texture.setRight(); + this.textures.setRight(); + } + + public virtual Texture2D getCurrentSpriteTexture() + { + return this.textures.currentTexture.currentTexture; + } + + public virtual Texture2D 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 a69d1535..8b7d0353 100644 --- a/GeneralMods/CustomNPCFramework/Framework/Graphics/DirectionalTexture.cs +++ b/GeneralMods/CustomNPCFramework/Framework/Graphics/DirectionalTexture.cs @@ -33,12 +33,12 @@ namespace CustomNPCFramework.Framework.Graphics } - public DirectionalTexture(AssetInfo info, string path, Direction direction = Direction.down) + public DirectionalTexture(NamePairings info, string path, Direction direction = Direction.down) { - this.leftTexture = Class1.ModHelper.Content.Load(Class1.getShortenedDirectory(Path.Combine(path, info.leftAssetName + ".png")).Remove(0, 1)); - this.rightTexture = Class1.ModHelper.Content.Load(Class1.getShortenedDirectory(Path.Combine(path, info.rightAssetName + ".png")).Remove(0, 1)); - this.upTexture = Class1.ModHelper.Content.Load(Class1.getShortenedDirectory(Path.Combine(path, info.upAssetName + ".png")).Remove(0, 1)); - this.downTexture = Class1.ModHelper.Content.Load(Class1.getShortenedDirectory(Path.Combine(path, info.downAssetName + ".png")).Remove(0, 1)); + this.leftTexture = Class1.ModHelper.Content.Load(Class1.getShortenedDirectory(Path.Combine(path, info.leftString + ".png")).Remove(0, 1)); + this.rightTexture = Class1.ModHelper.Content.Load(Class1.getShortenedDirectory(Path.Combine(path, info.rightString + ".png")).Remove(0, 1)); + this.upTexture = Class1.ModHelper.Content.Load(Class1.getShortenedDirectory(Path.Combine(path, info.upString + ".png")).Remove(0, 1)); + this.downTexture = Class1.ModHelper.Content.Load(Class1.getShortenedDirectory(Path.Combine(path, info.downString + ".png")).Remove(0, 1)); if (direction == Direction.left) this.currentTexture = leftTexture; if (direction == Direction.right) this.currentTexture = rightTexture; @@ -65,5 +65,14 @@ namespace CustomNPCFramework.Framework.Graphics { this.currentTexture = rightTexture; } + + public virtual Texture2D 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; + } } } diff --git a/GeneralMods/CustomNPCFramework/Framework/Graphics/TextureGroups/TextureGroup.cs b/GeneralMods/CustomNPCFramework/Framework/Graphics/TextureGroups/TextureGroup.cs new file mode 100644 index 00000000..b46103cf --- /dev/null +++ b/GeneralMods/CustomNPCFramework/Framework/Graphics/TextureGroups/TextureGroup.cs @@ -0,0 +1,92 @@ +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; + +namespace CustomNPCFramework.Framework.Graphics.TextureGroups +{ + public class TextureGroup + { + public DirectionalTexture standingTexture; + public DirectionalTexture sittingTexture; + public DirectionalTexture swimmingTexture; + public DirectionalTexture movingTexture; + + public DirectionalTexture currentTexture; + + private AssetInfo info; + private string path; + private Direction dir; + private AnimationType type; + + public TextureGroup(AssetInfo info, string path,Direction direction ,AnimationType animationType=AnimationType.standing) + { + this.standingTexture = new DirectionalTexture(info.standingAssetPaths, path, direction); + this.sittingTexture = new DirectionalTexture(info.sittingAssetPaths, path, direction); + this.swimmingTexture = new DirectionalTexture(info.swimmingAssetPaths, path, direction); + this.movingTexture = new DirectionalTexture(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; + + } + + public TextureGroup clone() + { + return new TextureGroup(this.info, this.path, this.dir, this.type); + } + + + public virtual void setLeft() + { + this.movingTexture.setLeft(); + this.sittingTexture.setLeft(); + this.standingTexture.setLeft(); + this.swimmingTexture.setLeft(); + } + + public virtual void setUp() + { + this.movingTexture.setUp(); + this.sittingTexture.setUp(); + this.standingTexture.setUp(); + this.swimmingTexture.setUp(); + } + + public virtual void setDown() + { + this.movingTexture.setDown(); + this.sittingTexture.setDown(); + this.standingTexture.setDown(); + this.swimmingTexture.setDown(); + } + + public virtual void setRight() + { + this.movingTexture.setRight(); + this.sittingTexture.setRight(); + this.standingTexture.setRight(); + this.swimmingTexture.setRight(); + } + + public virtual DirectionalTexture getTextureFromAnimation(AnimationType type) + { + if (type == AnimationType.standing) return this.standingTexture; + if (type == AnimationType.walking) return this.movingTexture; + if (type == AnimationType.swimming) return this.swimmingTexture; + if (type == AnimationType.sitting) return this.sittingTexture; + return null; + } + + } +} From c73702459951b298c735724e87b5fb6d5dbeef79 Mon Sep 17 00:00:00 2001 From: Date: Sun, 4 Mar 2018 14:32:59 -0800 Subject: [PATCH 06/54] The asset loader should now have all like assets bundled together. So all swimming animations will pull from the same body sprite as defined instead of always random. --- GeneralMods/CustomNPCFramework/Class1.cs | 2 +- .../Framework/Graphics/AssetInfo.cs | 2 +- .../Framework/Graphics/AssetPool.cs | 58 +++++++++++-------- .../Framework/Graphics/AssetSheet.cs | 6 +- .../Framework/Graphics/ExtendedAssetInfo.cs | 2 +- 5 files changed, 38 insertions(+), 32 deletions(-) diff --git a/GeneralMods/CustomNPCFramework/Class1.cs b/GeneralMods/CustomNPCFramework/Class1.cs index a666b961..bf42db8c 100644 --- a/GeneralMods/CustomNPCFramework/Class1.cs +++ b/GeneralMods/CustomNPCFramework/Class1.cs @@ -131,7 +131,7 @@ namespace CustomNPCFramework if (!File.Exists(filePath2)) { - ExtendedAssetInfo info2 = new ExtendedAssetInfo("AdvancedExample", new NamePairings("AdvancedExampleL", "AdvancedExampleR", "AdvancedExampleU", "AdvancedExampleD"), new Vector2(16, 16), false, Genders.female, new List() + ExtendedAssetInfo info2 = new ExtendedAssetInfo("AdvancedExample", new NamePairings("AdvancedStandingExampleL", "AdvancedStandingExampleR", "AdvancedStandingExampleU", "AdvancedStandingExampleD"), new NamePairings("AdvancedMovingExampleL", "AdvancedMovingExampleR", "AdvancedMovingExampleU", "AdvancedMovingExampleD"), new NamePairings("AdvancedSwimmingExampleL", "AdvancedSwimmingExampleR", "AdvancedSwimmingExampleU", "AdvancedSwimmingExampleD"), new NamePairings("AdvancedSittingExampleL", "AdvancedSittingExampleR", "AdvancedSittingExampleU", "AdvancedSittingExampleD"), new Vector2(16, 16), false, Genders.female, new List() { Seasons.spring, Seasons.summer diff --git a/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetInfo.cs b/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetInfo.cs index a326bf22..da3239ca 100644 --- a/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetInfo.cs +++ b/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetInfo.cs @@ -14,7 +14,6 @@ namespace CustomNPCFramework.Framework.Graphics public NamePairings swimmingAssetPaths; public NamePairings movingAssetPaths; public NamePairings sittingAssetPaths; - public string downAssetName; public Vector2 assetSize; public bool randomizeUponLoad; @@ -25,6 +24,7 @@ namespace CustomNPCFramework.Framework.Graphics 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; diff --git a/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetPool.cs b/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetPool.cs index 7c6d223e..e52d930b 100644 --- a/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetPool.cs +++ b/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetPool.cs @@ -87,16 +87,12 @@ namespace CustomNPCFramework.Framework.Graphics public AnimatedSpriteCollection getSpriteCollectionFromSheet(AssetSheet assetSheet, AnimationType type) - { - if (type == AnimationType.standing) - { - var ok = assetSheet.getTexture(Direction, AnimationType); - var left = new AnimatedSpriteExtended(assetSheet.clone().textures.standingTexture.leftTexture, assetSheet.index, (int)assetSheet.assetInfo.assetSize.X, (int)assetSheet.assetInfo.assetSize.Y); - var right = new AnimatedSpriteExtended(assetSheet.clone().texture.rightTexture, assetSheet.index, (int)assetSheet.assetInfo.assetSize.X, (int)assetSheet.assetInfo.assetSize.Y); - var up = new AnimatedSpriteExtended(assetSheet.clone().texture.upTexture, assetSheet.index, (int)assetSheet.assetInfo.assetSize.X, (int)assetSheet.assetInfo.assetSize.Y); - var down = new AnimatedSpriteExtended(assetSheet.clone().texture.downTexture, assetSheet.index, (int)assetSheet.assetInfo.assetSize.X, (int)assetSheet.assetInfo.assetSize.Y); - return new AnimatedSpriteCollection(left, right, up, down, Direction.down); - } + { + var left = new AnimatedSpriteExtended(assetSheet.clone().getTexture(Direction.left, type), assetSheet.index, (int)assetSheet.assetInfo.assetSize.X, (int)assetSheet.assetInfo.assetSize.Y); + var right = new AnimatedSpriteExtended(assetSheet.clone().getTexture(Direction.right, type), assetSheet.index, (int)assetSheet.assetInfo.assetSize.X, (int)assetSheet.assetInfo.assetSize.Y); + var up = new AnimatedSpriteExtended(assetSheet.clone().getTexture(Direction.up, type), assetSheet.index, (int)assetSheet.assetInfo.assetSize.X, (int)assetSheet.assetInfo.assetSize.Y); + var down = new AnimatedSpriteExtended(assetSheet.clone().getTexture(Direction.down, type), assetSheet.index, (int)assetSheet.assetInfo.assetSize.X, (int)assetSheet.assetInfo.assetSize.Y); + return new AnimatedSpriteCollection(left, right, up, down, Direction.down); } @@ -219,29 +215,41 @@ namespace CustomNPCFramework.Framework.Graphics accessorySheet.Add(accessoryList.ElementAt(v)); } - var bodySprite = getSpriteCollectionFromSheet(bodySheet); - var eyesSprite = getSpriteCollectionFromSheet(eyesSheet); - var hairSprite = getSpriteCollectionFromSheet(hairSheet); - var shirtSprite = getSpriteCollectionFromSheet(shirtSheet); - var pantsSprite = getSpriteCollectionFromSheet(pantsSheet); - var shoesSprite = getSpriteCollectionFromSheet(shoesSheet); - List accessoryCollection = new List(); - foreach(var v in accessorySheet) - { - AnimatedSpriteCollection acc = getSpriteCollectionFromSheet(v); - accessoryCollection.Add(acc); - } - StandardCharacterAnimation standingAnimation = new StandardCharacterAnimation(bodySprite, eyesSprite, hairSprite, shirtSprite, pantsSprite, shoesSprite, accessoryCollection); + AnimationType type = AnimationType.standing; + var standingAnimation = generateCharacterAnimation(bodySheet, eyesSheet, hairSheet, shirtSheet, pantsSheet, shoesSheet, accessorySheet, type); + type = AnimationType.walking; + var movingAnimation = generateCharacterAnimation(bodySheet, eyesSheet, hairSheet, shirtSheet, pantsSheet, shoesSheet, accessorySheet, type); + type = AnimationType.swimming; + var swimmingAnimation = generateCharacterAnimation(bodySheet, eyesSheet, hairSheet, shirtSheet, pantsSheet, shoesSheet, accessorySheet, type); + //type = AnimationType.standing; + //var sAnimation = generateCharacterAnimation(bodySheet, eyesSheet, hairSheet, shirtSheet, pantsSheet, shoesSheet, accessorySheet, type); - - BasicRenderer render = new BasicRenderer(standingAnimation,standingAnimation,standingAnimation); + BasicRenderer render = new BasicRenderer(standingAnimation,movingAnimation,swimmingAnimation); ExtendedNPC npc = new ExtendedNPC(null, render, new Microsoft.Xna.Framework.Vector2(13, 15) * Game1.tileSize, 2, NPCNames.getRandomNPCName(gender)); } + public virtual StandardCharacterAnimation generateCharacterAnimation(AssetSheet body, AssetSheet eyes, AssetSheet hair, AssetSheet shirt, AssetSheet pants, AssetSheet shoes,List accessories, AnimationType animationType) + { + 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); + List accessoryCollection = new List(); + foreach (var v in accessories) + { + AnimatedSpriteCollection acc = getSpriteCollectionFromSheet(v, AnimationType.standing); + accessoryCollection.Add(acc); + } + StandardCharacterAnimation standingAnimation = new StandardCharacterAnimation(bodySprite, eyesSprite, hairSprite, shirtSprite, pantsSprite, shoesSprite, accessoryCollection); + return standingAnimation; + } + /* public void generateNPC(string assetManagerName,Genders gender, Seasons season, int minNumOfAccessories,int maxNumOfAccessories) diff --git a/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetSheet.cs b/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetSheet.cs index 875ab188..7d2c1b13 100644 --- a/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetSheet.cs +++ b/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetSheet.cs @@ -1,4 +1,5 @@ using CustomNPCFramework.Framework.Enums; +using CustomNPCFramework.Framework.Graphics.TextureGroups; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; @@ -27,12 +28,9 @@ namespace CustomNPCFramework.Framework.Graphics public AssetSheet(AssetInfo info,string path,Direction direction=Direction.down) { this.assetInfo = info; - - - + this.textures = new TextureGroup(info,path,direction); this.path = Class1.getShortenedDirectory(path); this.index = 0; - } public virtual KeyValuePair getPathTexturePair() diff --git a/GeneralMods/CustomNPCFramework/Framework/Graphics/ExtendedAssetInfo.cs b/GeneralMods/CustomNPCFramework/Framework/Graphics/ExtendedAssetInfo.cs index 09521a8e..161ac213 100644 --- a/GeneralMods/CustomNPCFramework/Framework/Graphics/ExtendedAssetInfo.cs +++ b/GeneralMods/CustomNPCFramework/Framework/Graphics/ExtendedAssetInfo.cs @@ -28,7 +28,7 @@ namespace CustomNPCFramework.Framework.Graphics /// /// 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 pair,Vector2 assetSize, bool randomizeOnLoad, Genders Gender, List Season, PartType Type): base(name,pair, assetSize, randomizeOnLoad) + 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; From e17dd9ea7c3f8030edc5173805fffcc342b7564a Mon Sep 17 00:00:00 2001 From: Date: Sun, 4 Mar 2018 14:44:52 -0800 Subject: [PATCH 07/54] Made a function to generate renderers. --- GeneralMods/CustomNPCFramework/Class1.cs | 2 +- .../Framework/Graphics/AssetPool.cs | 64 +++---------------- .../Framework/Graphics/ExtendedAssetInfo.cs | 1 - 3 files changed, 11 insertions(+), 56 deletions(-) diff --git a/GeneralMods/CustomNPCFramework/Class1.cs b/GeneralMods/CustomNPCFramework/Class1.cs index bf42db8c..7fe00ede 100644 --- a/GeneralMods/CustomNPCFramework/Class1.cs +++ b/GeneralMods/CustomNPCFramework/Class1.cs @@ -21,9 +21,9 @@ namespace CustomNPCFramework /// TODO: /// List all asset managers in use. /// Have all asset managers list what assets they are using. - /// FIX NPC GENERATION IN ASSETPOOL.CS /// /// Load in the assets and go go go. + /// -Collect a bunch of assets together to test this thing. /// diff --git a/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetPool.cs b/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetPool.cs index e52d930b..1cca96ae 100644 --- a/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetPool.cs +++ b/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetPool.cs @@ -146,8 +146,6 @@ namespace CustomNPCFramework.Framework.Graphics { Seasons myseason=Seasons.spring; - AnimationType currentType = AnimationType.standing; - if (Game1.currentSeason == "spring") myseason = Seasons.spring; if (Game1.currentSeason == "summer") myseason = Seasons.summer; if (Game1.currentSeason == "fall") myseason = Seasons.fall; @@ -202,6 +200,7 @@ namespace CustomNPCFramework.Framework.Graphics accIntList.Add(acc); } + //Get a single sheet to pull from. AssetSheet bodySheet = bodyList.ElementAt(bodyIndex); AssetSheet eyesSheet = eyesList.ElementAt(bodyIndex); AssetSheet hairSheet = hairList.ElementAt(bodyIndex); @@ -215,21 +214,23 @@ namespace CustomNPCFramework.Framework.Graphics accessorySheet.Add(accessoryList.ElementAt(v)); } + var render = generateBasicRenderer(bodySheet, eyesSheet, hairSheet, shirtSheet, pantsSheet, shoesSheet, accessorySheet); + ExtendedNPC npc = new ExtendedNPC(null, render, new Microsoft.Xna.Framework.Vector2(13, 15) * Game1.tileSize, 2, NPCNames.getRandomNPCName(gender)); + } + + public virtual BasicRenderer generateBasicRenderer(AssetSheet bodySheet, AssetSheet eyesSheet, AssetSheet hairSheet, AssetSheet shirtSheet, AssetSheet pantsSheet, AssetSheet shoesSheet, List accessorySheet) + { + //Get all of the appropriate animations. AnimationType type = AnimationType.standing; var standingAnimation = generateCharacterAnimation(bodySheet, eyesSheet, hairSheet, shirtSheet, pantsSheet, shoesSheet, accessorySheet, type); type = AnimationType.walking; var movingAnimation = generateCharacterAnimation(bodySheet, eyesSheet, hairSheet, shirtSheet, pantsSheet, shoesSheet, accessorySheet, type); type = AnimationType.swimming; var swimmingAnimation = generateCharacterAnimation(bodySheet, eyesSheet, hairSheet, shirtSheet, pantsSheet, shoesSheet, accessorySheet, type); - //type = AnimationType.standing; - //var sAnimation = generateCharacterAnimation(bodySheet, eyesSheet, hairSheet, shirtSheet, pantsSheet, shoesSheet, accessorySheet, type); - - - BasicRenderer render = new BasicRenderer(standingAnimation,movingAnimation,swimmingAnimation); - - ExtendedNPC npc = new ExtendedNPC(null, render, new Microsoft.Xna.Framework.Vector2(13, 15) * Game1.tileSize, 2, NPCNames.getRandomNPCName(gender)); + BasicRenderer render = new BasicRenderer(standingAnimation, movingAnimation, swimmingAnimation); + return render; } public virtual StandardCharacterAnimation generateCharacterAnimation(AssetSheet body, AssetSheet eyes, AssetSheet hair, AssetSheet shirt, AssetSheet pants, AssetSheet shoes,List accessories, AnimationType animationType) @@ -249,50 +250,5 @@ namespace CustomNPCFramework.Framework.Graphics StandardCharacterAnimation standingAnimation = new StandardCharacterAnimation(bodySprite, eyesSprite, hairSprite, shirtSprite, pantsSprite, shoesSprite, accessoryCollection); return standingAnimation; } - - - /* - public void generateNPC(string assetManagerName,Genders gender, Seasons season, int minNumOfAccessories,int maxNumOfAccessories) - { - var body= this.getAssetManager(assetManagerName).getListOfAssetsThatMatchThisCriteria(gender, season, PartType.body); - var eyes = this.getAssetManager(assetManagerName).getListOfAssetsThatMatchThisCriteria(gender, season, PartType.eyes); - var hair = this.getAssetManager(assetManagerName).getListOfAssetsThatMatchThisCriteria(gender, season, PartType.hair); - var shirt = this.getAssetManager(assetManagerName).getListOfAssetsThatMatchThisCriteria(gender, season, PartType.shirt); - var pants = this.getAssetManager(assetManagerName).getListOfAssetsThatMatchThisCriteria(gender, season, PartType.pants); - var shoes = this.getAssetManager(assetManagerName).getListOfAssetsThatMatchThisCriteria(gender, season, PartType.shoes); - List accessories = new List(); - Random r = new Random(Game1.random.Next()); - int amount=r.Next(minNumOfAccessories, maxNumOfAccessories); - var accessoriesList= this.getAssetManager(assetManagerName).getListOfAssetsThatMatchThisCriteria(gender, season, PartType.shoes); - - int bodyIndex = r.Next(0, body.Count - 1); - int eyesIndex = r.Next(0, eyes.Count - 1); - int hairIndex = r.Next(0, hair.Count - 1); - int shirtIndex = r.Next(0, shirt.Count - 1); - int pantsIndex = r.Next(0, pants.Count - 1); - int shoesIndex = r.Next(0, shoes.Count - 1); - List accIntList = new List(); - for(int i=0; i < amount; i++) - { - int acc= r.Next(0, accessoriesList.Count - 1); - accIntList.Add(acc); - } - - AssetSheet bodySheet = body.ElementAt(bodyIndex); - AssetSheet eyesSheet = body.ElementAt(bodyIndex); - AssetSheet hairSheet = body.ElementAt(bodyIndex); - AssetSheet shirtSheet = body.ElementAt(bodyIndex); - AssetSheet pantsSheet = body.ElementAt(bodyIndex); - AssetSheet shoesSheet = body.ElementAt(bodyIndex); - - foreach(var v in accIntList) - { - accessories.Add(accessoriesList.ElementAt(v)); - } - - - } - */ - } } diff --git a/GeneralMods/CustomNPCFramework/Framework/Graphics/ExtendedAssetInfo.cs b/GeneralMods/CustomNPCFramework/Framework/Graphics/ExtendedAssetInfo.cs index 161ac213..69458519 100644 --- a/GeneralMods/CustomNPCFramework/Framework/Graphics/ExtendedAssetInfo.cs +++ b/GeneralMods/CustomNPCFramework/Framework/Graphics/ExtendedAssetInfo.cs @@ -13,7 +13,6 @@ namespace CustomNPCFramework.Framework.Graphics public Genders gender; public List seasons; public PartType type; - public AnimationType animationType; public ExtendedAssetInfo() { From 68c831029b212706b736ca7d349f331222f1362d Mon Sep 17 00:00:00 2001 From: Date: Sun, 4 Mar 2018 15:21:39 -0800 Subject: [PATCH 08/54] New constructors for ExtendedNPC that don't take a CharacterRenderer, just a basic Sprite. --- GeneralMods/CustomNPCFramework/Class1.cs | 12 +++++++++++ .../Framework/NPCS/ExtendedNPC.cs | 21 +++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/GeneralMods/CustomNPCFramework/Class1.cs b/GeneralMods/CustomNPCFramework/Class1.cs index 7fe00ede..a55121ac 100644 --- a/GeneralMods/CustomNPCFramework/Class1.cs +++ b/GeneralMods/CustomNPCFramework/Class1.cs @@ -22,6 +22,18 @@ namespace CustomNPCFramework /// List all asset managers in use. /// Have all asset managers list what assets they are using. /// + /// Have asset info have a var called age. + /// ...where + /// 0=adult + /// 1=child + /// + /// /// Have asset info have a var called bodyType. + /// ...where + /// 0=thin + /// 1=normal + /// 2=muscular + /// 3=big + /// /// Load in the assets and go go go. /// -Collect a bunch of assets together to test this thing. /// diff --git a/GeneralMods/CustomNPCFramework/Framework/NPCS/ExtendedNPC.cs b/GeneralMods/CustomNPCFramework/Framework/NPCS/ExtendedNPC.cs index 32c90672..0e8e8ddd 100644 --- a/GeneralMods/CustomNPCFramework/Framework/NPCS/ExtendedNPC.cs +++ b/GeneralMods/CustomNPCFramework/Framework/NPCS/ExtendedNPC.cs @@ -42,6 +42,27 @@ namespace CustomNPCFramework.Framework.NPCS public ExtendedNPC() :base() { } + + public ExtendedNPC(Sprite sprite, Vector2 position, int facingDirection, string name) : base(sprite.sprite, position, facingDirection, name, null) + { + this.characterRenderer = null; + this.Portrait = (Texture2D)null; + this.portraitInformation = null; + this.spriteInformation = sprite; + this.spriteInformation.setCharacterSpriteFromThis(this); + this.swimming = false; + } + + public ExtendedNPC(Sprite sprite, Portrait portrait, Vector2 position, int facingDirection, string name) : base(sprite.sprite, position, facingDirection, name, null) + { + this.characterRenderer = null; + this.portraitInformation = portrait; + this.portraitInformation.setCharacterPortraitFromThis(this); + this.spriteInformation = sprite; + this.spriteInformation.setCharacterSpriteFromThis(this); + this.swimming = false; + } + public ExtendedNPC(Sprite sprite,BasicRenderer renderer,Vector2 position,int facingDirection,string name): base(sprite.sprite, position, facingDirection, name, null) { this.characterRenderer = renderer; From 4fc3466608153c51ca8f51b525d98b26cd4517d5 Mon Sep 17 00:00:00 2001 From: Date: Mon, 5 Mar 2018 20:46:45 -0800 Subject: [PATCH 09/54] Made dialogue map event, and updated Button for UIUtilities to use Texture2DExtended. Spent awhile just fixing it. --- .../AdditionalCropsFramework/PlanterBox.cs | 2 +- GeneralMods/CustomNPCFramework/Class1.cs | 2 +- GeneralMods/MapEvents/EventSystem.csproj | 1 + .../Framework/Events/DialogueDisplayEvent.cs | 65 +++++++++++++++++++ GeneralMods/StardewMods.sln | 16 ++--- .../Framework/Menus/MusicManagerMenu.cs | 23 +++++-- .../{ => Music}/MusicHexProcessor.cs | 0 .../Framework/{ => Music}/MusicManager.cs | 0 .../Framework/{ => Music}/MusicPack.cs | 0 .../{ => Music}/MusicPackMetaData.cs | 0 .../Framework/{ => Music}/Song.cs | 0 .../Framework/{ => Music}/SongListNode.cs | 0 .../Framework/{ => Music}/SongSpecifics.cs | 0 .../Framework/{ => Music}/WavMusicPack.cs | 0 .../Framework/{ => Music}/XACTMusicPack.cs | 0 .../StardewSymphony.cs | 16 ++++- .../StardewSymphonyRemastered.csproj | 18 ++--- .../StardewSymphonyRemastered/manifest.json | 8 ++- .../StardustCore/Animations/Animation.cs | 27 +++++++- .../Animations/AnimationManager.cs | 35 +++++++++- GeneralMods/StardustCore/StardustCore.csproj | 2 + .../UIUtilities/IClickableMenuExtended.cs | 19 ++++++ .../UIUtilities/MenuComponents/Button.cs | 6 +- .../UIUtilities/Texture2DExtended.cs | 13 ++-- .../UIUtilities/TextureManager.cs | 38 +++++++++++ GeneralMods/StardustCore/Utilities.cs | 13 ++++ GeneralMods/SundropMapEvents/Class1.cs | 5 +- 27 files changed, 265 insertions(+), 44 deletions(-) create mode 100644 GeneralMods/MapEvents/Framework/Events/DialogueDisplayEvent.cs rename GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/{ => Music}/MusicHexProcessor.cs (100%) rename GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/{ => Music}/MusicManager.cs (100%) rename GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/{ => Music}/MusicPack.cs (100%) rename GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/{ => Music}/MusicPackMetaData.cs (100%) rename GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/{ => Music}/Song.cs (100%) rename GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/{ => Music}/SongListNode.cs (100%) rename GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/{ => Music}/SongSpecifics.cs (100%) rename GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/{ => Music}/WavMusicPack.cs (100%) rename GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/{ => Music}/XACTMusicPack.cs (100%) create mode 100644 GeneralMods/StardustCore/UIUtilities/IClickableMenuExtended.cs create mode 100644 GeneralMods/StardustCore/UIUtilities/TextureManager.cs diff --git a/GeneralMods/AdditionalCropsFramework/PlanterBox.cs b/GeneralMods/AdditionalCropsFramework/PlanterBox.cs index e47435f1..95a0fad2 100644 --- a/GeneralMods/AdditionalCropsFramework/PlanterBox.cs +++ b/GeneralMods/AdditionalCropsFramework/PlanterBox.cs @@ -946,7 +946,7 @@ namespace AdditionalCropsFramework else { //Log.AsyncC("Animation Manager is working!"); - spriteBatch.Draw(animationManager.objectTexture, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(x * Game1.tileSize), y * Game1.tileSize)), new Rectangle?(animationManager.currentAnimation.sourceRectangle), Color.White * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0); + this.animationManager.draw(spriteBatch,animationManager.objectTexture, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(x * Game1.tileSize), y * Game1.tileSize)), new Rectangle?(animationManager.currentAnimation.sourceRectangle), Color.White * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0); try { this.animationManager.tickAnimation(); diff --git a/GeneralMods/CustomNPCFramework/Class1.cs b/GeneralMods/CustomNPCFramework/Class1.cs index a55121ac..383f5c5c 100644 --- a/GeneralMods/CustomNPCFramework/Class1.cs +++ b/GeneralMods/CustomNPCFramework/Class1.cs @@ -119,7 +119,7 @@ namespace CustomNPCFramework { ModMonitor.Log("UGGGGGGG", LogLevel.Error); } - ExtendedNPC myNpc3 = new ExtendedNPC(new Framework.ModularNPCS.Sprite(pair.Key,pair.Value),null, new Vector2(14, 14)*Game1.tileSize, 2, "b2"); + ExtendedNPC myNpc3 = new ExtendedNPC(new Framework.ModularNPCS.Sprite(pair.Key,pair.Value),null,null, new Vector2(14, 14)*Game1.tileSize, 2, "b2"); npcTracker.addNewNPCToLocation(Game1.getLocationFromName("BusStop"),myNpc3); myNpc3.SetMovingDown(true); } diff --git a/GeneralMods/MapEvents/EventSystem.csproj b/GeneralMods/MapEvents/EventSystem.csproj index 6b437ff4..8ba76bf0 100644 --- a/GeneralMods/MapEvents/EventSystem.csproj +++ b/GeneralMods/MapEvents/EventSystem.csproj @@ -45,6 +45,7 @@ + diff --git a/GeneralMods/MapEvents/Framework/Events/DialogueDisplayEvent.cs b/GeneralMods/MapEvents/Framework/Events/DialogueDisplayEvent.cs new file mode 100644 index 00000000..0d0dec7c --- /dev/null +++ b/GeneralMods/MapEvents/Framework/Events/DialogueDisplayEvent.cs @@ -0,0 +1,65 @@ +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 +{ + public class DialogueDisplayEvent :MapEvent + { + string dialogue; + public DialogueDisplayEvent(string Name, GameLocation Location, Vector2 Position, PlayerEvents playerEvents, string Dialogue) : base(Name, Location, Position, playerEvents) + { + this.name = Name; + this.location = Location; + this.tilePosition = Position; + this.playerEvents = playerEvents; + + this.doesInteractionNeedToRun = true; + this.dialogue = Dialogue; + } + + /// + /// Occurs when the player enters the warp tile event position. + /// s + public override void OnPlayerEnter() + { + if (isPlayerOnTile() == true && this.doesInteractionNeedToRun == true) + { + this.doesInteractionNeedToRun = false; + this.playerOnTile = true; + if (this.playerEvents.onPlayerEnter != null) this.playerEvents.onPlayerEnter.run(); //used to run a function before the warp. + Game1.activeClickableMenu =new StardewValley.Menus.DialogueBox(this.dialogue); + //Game1.drawDialogueBox(this.dialogue); + } + } + + /// + /// Runs when the player is not on the tile and resets player interaction. + /// + public override void OnPlayerLeave() + { + if (isPlayerOnTile() == false && this.playerOnTile == true) + { + this.playerOnTile = false; + this.doesInteractionNeedToRun = true; + if (this.playerEvents.onPlayerLeave != null) this.playerEvents.onPlayerLeave.run(); + } + } + + /// + /// Used to update the event and check for interaction. + /// + public override void update() + { + this.OnPlayerEnter(); + this.OnPlayerLeave(); + } + + } +} diff --git a/GeneralMods/StardewMods.sln b/GeneralMods/StardewMods.sln index d346b575..62058292 100644 --- a/GeneralMods/StardewMods.sln +++ b/GeneralMods/StardewMods.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Express 14 for Windows Desktop -VisualStudioVersion = 14.0.25420.1 +# Visual Studio 15 +VisualStudioVersion = 15.0.27130.2036 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoSpeed", "AutoSpeed\AutoSpeed.csproj", "{57E7D17E-C237-448B-A50F-CFB67F9BB146}" EndProject @@ -61,11 +61,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RuneFactoryCropsMod", "Rune {C5F88D48-EA20-40CD-91E2-C8725DC11795} = {C5F88D48-EA20-40CD-91E2-C8725DC11795} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StarAI", "..\StarAI\StarAI\StarAI.csproj", "{93632675-991D-425B-96F9-9C2B6BFC4EFE}" - ProjectSection(ProjectDependencies) = postProject - {0756D36A-95C8-480D-8EA6-4584C03010C6} = {0756D36A-95C8-480D-8EA6-4584C03010C6} - EndProjectSection -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StardewSymphonyRemastered", "StardewSymphonyRemastered\StardewSymphonyRemastered\StardewSymphonyRemastered.csproj", "{19F64B03-6A9B-49E1-854A-C05D5A014646}" ProjectSection(ProjectDependencies) = postProject {0756D36A-95C8-480D-8EA6-4584C03010C6} = {0756D36A-95C8-480D-8EA6-4584C03010C6} @@ -174,10 +169,6 @@ Global {8415BB0C-94A7-4E11-B6D5-C31649C3A95D}.Debug|Any CPU.Build.0 = Debug|Any CPU {8415BB0C-94A7-4E11-B6D5-C31649C3A95D}.Release|Any CPU.ActiveCfg = Release|Any CPU {8415BB0C-94A7-4E11-B6D5-C31649C3A95D}.Release|Any CPU.Build.0 = Release|Any CPU - {93632675-991D-425B-96F9-9C2B6BFC4EFE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {93632675-991D-425B-96F9-9C2B6BFC4EFE}.Debug|Any CPU.Build.0 = Debug|Any CPU - {93632675-991D-425B-96F9-9C2B6BFC4EFE}.Release|Any CPU.ActiveCfg = Release|Any CPU - {93632675-991D-425B-96F9-9C2B6BFC4EFE}.Release|Any CPU.Build.0 = Release|Any CPU {19F64B03-6A9B-49E1-854A-C05D5A014646}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {19F64B03-6A9B-49E1-854A-C05D5A014646}.Debug|Any CPU.Build.0 = Debug|Any CPU {19F64B03-6A9B-49E1-854A-C05D5A014646}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -205,4 +196,7 @@ Global {29A68F94-B23C-442B-8867-8B8F3502E64F} = {BAAC8F21-C12F-42B0-A51C-0C5F33B52575} {89C7DF45-8AE5-49AC-ADA9-6312E9590829} = {3EE26DA0-0337-4991-8B02-BCB8D408008C} EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {4135247C-1326-43F4-A762-3916E50635EF} + EndGlobalSection EndGlobal diff --git a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Menus/MusicManagerMenu.cs b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Menus/MusicManagerMenu.cs index f4d9d61c..8e97d10d 100644 --- a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Menus/MusicManagerMenu.cs +++ b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Menus/MusicManagerMenu.cs @@ -3,31 +3,40 @@ 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; +using StardustCore.UIUtilities.MenuComponents; namespace StardewSymphonyRemastered.Framework.Menus { - class MusicManagerMenu : StardewValley.Menus.IClickableMenu + public class MusicManagerMenu : IClickableMenuExtended { - public List texturedStrings; + private string musicNotePath; + public MusicManagerMenu(float width, float height) { + + + this.width = (int)width; this.height = (int)height; this.texturedStrings = new List(); this.texturedStrings.Add(StardustCore.UIUtilities.SpriteFonts.SpriteFont.vanillaFont.ParseString("Hello", new Microsoft.Xna.Framework.Vector2(100, 100),StardustCore.IlluminateFramework.Colors.invertColor(StardustCore.IlluminateFramework.LightColorsList.Blue))); + this.buttons = new List(); + this.buttons.Add(new Button("myButton", new Rectangle(100, 100, 200, 100), StardewSymphony.textureManager.getTexture("MusicNote").Copy(StardewSymphony.ModHelper), "mynote", new Rectangle(0, 0, 16, 16), 4f, new StardustCore.Animations.Animation(new Rectangle(0, 0, 16, 16)), Color.White, Color.White, false)); + } public override void receiveRightClick(int x, int y, bool playSound = true) { - throw new NotImplementedException(); + } public override void drawBackground(SpriteBatch b) { Game1.drawDialogueBox(this.xPositionOnScreen, this.yPositionOnScreen, this.width, this.height, false, true); - //base.drawBackground(b); } public override void draw(SpriteBatch b) @@ -38,6 +47,12 @@ namespace StardewSymphonyRemastered.Framework.Menus { v.draw(b); } + + foreach (var v in buttons) + { + v.draw(b); + } + this.drawMouse(b); } } } diff --git a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/MusicHexProcessor.cs b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Music/MusicHexProcessor.cs similarity index 100% rename from GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/MusicHexProcessor.cs rename to GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Music/MusicHexProcessor.cs diff --git a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/MusicManager.cs b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Music/MusicManager.cs similarity index 100% rename from GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/MusicManager.cs rename to GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Music/MusicManager.cs diff --git a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/MusicPack.cs b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Music/MusicPack.cs similarity index 100% rename from GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/MusicPack.cs rename to GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Music/MusicPack.cs diff --git a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/MusicPackMetaData.cs b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Music/MusicPackMetaData.cs similarity index 100% rename from GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/MusicPackMetaData.cs rename to GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Music/MusicPackMetaData.cs diff --git a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Song.cs b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Music/Song.cs similarity index 100% rename from GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Song.cs rename to GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Music/Song.cs diff --git a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/SongListNode.cs b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Music/SongListNode.cs similarity index 100% rename from GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/SongListNode.cs rename to GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Music/SongListNode.cs diff --git a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/SongSpecifics.cs b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Music/SongSpecifics.cs similarity index 100% rename from GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/SongSpecifics.cs rename to GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Music/SongSpecifics.cs diff --git a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/WavMusicPack.cs b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Music/WavMusicPack.cs similarity index 100% rename from GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/WavMusicPack.cs rename to GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Music/WavMusicPack.cs diff --git a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/XACTMusicPack.cs b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Music/XACTMusicPack.cs similarity index 100% rename from GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/XACTMusicPack.cs rename to GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Music/XACTMusicPack.cs diff --git a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/StardewSymphony.cs b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/StardewSymphony.cs index 5f761eb0..edbd4fa8 100644 --- a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/StardewSymphony.cs +++ b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/StardewSymphony.cs @@ -9,6 +9,7 @@ using StardewModdingAPI; using StardewValley; using StardewSymphonyRemastered.Framework; using System.IO; +using StardustCore.UIUtilities; namespace StardewSymphonyRemastered { @@ -42,6 +43,8 @@ namespace StardewSymphonyRemastered public bool musicPacksInitialized; + + public static TextureManager textureManager; /// /// Entry point for the mod. /// @@ -64,12 +67,14 @@ namespace StardewSymphonyRemastered WavMusicDirectory = Path.Combine(MusicPath, "Wav"); XACTMusicDirectory = Path.Combine(MusicPath, "XACT"); TemplateMusicDirectory = Path.Combine(MusicPath, "Templates"); - + textureManager = new TextureManager(); this.createDirectories(); this.createBlankXACTTemplate(); this.createBlankWAVTemplate(); musicPacksInitialized = false; + + } private void SaveEvents_BeforeSave(object sender, EventArgs e) @@ -84,9 +89,9 @@ namespace StardewSymphonyRemastered private void ControlEvents_KeyPressed(object sender, StardewModdingAPI.Events.EventArgsKeyPressed e) { - if (e.KeyPressed == Microsoft.Xna.Framework.Input.Keys.O) + if (e.KeyPressed == Microsoft.Xna.Framework.Input.Keys.K) { - Game1.activeClickableMenu = new StardewSymphonyRemastered.Framework.Menus.MusicManagerMenu(Game1.viewport.Width,Game1.viewport.Height); + Game1.activeClickableMenu = new Framework.Menus.MusicManagerMenu(Game1.viewport.Width,Game1.viewport.Height); } } @@ -121,6 +126,11 @@ namespace StardewSymphonyRemastered /// public void createDirectories() { + string path = Path.Combine(ModHelper.DirectoryPath, "Content", "Graphics", "MusicMenu"); + if (!Directory.Exists(path)) Directory.CreateDirectory(path); + string musicNote = Path.Combine(path, "MusicNote.png"); + textureManager.addTexture("MusicNote",new Texture2DExtended(ModHelper,StardustCore.Utilities.getRelativeDirectory("StardewSymphonyRemastered", musicNote))); + if (!Directory.Exists(MusicPath)) Directory.CreateDirectory(MusicPath); if (!Directory.Exists(WavMusicDirectory)) Directory.CreateDirectory(WavMusicDirectory); if (!Directory.Exists(XACTMusicDirectory)) Directory.CreateDirectory(XACTMusicDirectory); diff --git a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/StardewSymphonyRemastered.csproj b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/StardewSymphonyRemastered.csproj index da8dd107..92659f97 100644 --- a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/StardewSymphonyRemastered.csproj +++ b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/StardewSymphonyRemastered.csproj @@ -46,17 +46,17 @@ - - - + + + - - - - - - + + + + + + diff --git a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/manifest.json b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/manifest.json index d9b57173..fa3d9fb2 100644 --- a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/manifest.json +++ b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/manifest.json @@ -6,5 +6,11 @@ "UniqueID": "Omegasis.StardewSymphony", "EntryDll": "StardewSymphonyRemastered.dll", "MinimumApiVersion": "2.0", - "UpdateKeys": [ "Nexus:425" ] + "UpdateKeys": [ "Nexus:425" ], + "Dependencies": [ + { + "UniqueID": "Omegasis.StardustCore", + "IsRequired": true + } +] } diff --git a/GeneralMods/StardustCore/Animations/Animation.cs b/GeneralMods/StardustCore/Animations/Animation.cs index 862a18bd..226139a7 100644 --- a/GeneralMods/StardustCore/Animations/Animation.cs +++ b/GeneralMods/StardustCore/Animations/Animation.cs @@ -13,17 +13,40 @@ namespace StardustCore.Animations public readonly int frameDuration; public int frameCountUntilNextAnimation; - public Animation(Rectangle rec,int existForXFrames) + + + /// + /// 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 = rec; + sourceRectangle = SourceRectangle; + 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/StardustCore/Animations/AnimationManager.cs b/GeneralMods/StardustCore/Animations/AnimationManager.cs index ec94a8c1..a421a96b 100644 --- a/GeneralMods/StardustCore/Animations/AnimationManager.cs +++ b/GeneralMods/StardustCore/Animations/AnimationManager.cs @@ -1,6 +1,8 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using StardewModdingAPI; +using StardewValley; +using StardustCore.UIUtilities; using System; using System.Collections.Generic; using System.Linq; @@ -18,7 +20,7 @@ namespace StardustCore.Animations public string currentAnimationName; public int currentAnimationListIndex; public List currentAnimationList = new List(); - public Texture2D objectTexture; ///Might not be necessary if I use the CoreObject texture sheet. + public Texture2DExtended objectTexture; ///Might not be necessary if I use the CoreObject texture sheet. public Animation defaultDrawFrame; public Animation currentAnimation; bool enabled; @@ -29,7 +31,7 @@ namespace StardustCore.Animations /// 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 (Texture2D ObjectTexture,Animation DefaultFrame, bool EnabledByDefault=true) + public AnimationManager (Texture2DExtended ObjectTexture,Animation DefaultFrame, bool EnabledByDefault=true) { currentAnimationListIndex = 0; this.objectTexture = ObjectTexture; @@ -38,7 +40,7 @@ namespace StardustCore.Animations currentAnimation = this.defaultDrawFrame; } - public AnimationManager(Texture2D ObjectTexture,Animation DefaultFrame ,Dictionary> animationsToPlay, string startingAnimationKey, int startingAnimationFrame=0,bool EnabledByDefault=true) + public AnimationManager(Texture2DExtended ObjectTexture,Animation DefaultFrame ,Dictionary> animationsToPlay, string startingAnimationKey, int startingAnimationFrame=0,bool EnabledByDefault=true) { currentAnimationListIndex = 0; this.objectTexture = ObjectTexture; @@ -187,6 +189,33 @@ namespace StardustCore.Animations } 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()); + } + } } } diff --git a/GeneralMods/StardustCore/StardustCore.csproj b/GeneralMods/StardustCore/StardustCore.csproj index 9d1d2321..c2d4554a 100644 --- a/GeneralMods/StardustCore/StardustCore.csproj +++ b/GeneralMods/StardustCore/StardustCore.csproj @@ -47,6 +47,7 @@ + @@ -65,6 +66,7 @@ + diff --git a/GeneralMods/StardustCore/UIUtilities/IClickableMenuExtended.cs b/GeneralMods/StardustCore/UIUtilities/IClickableMenuExtended.cs new file mode 100644 index 00000000..5531bf51 --- /dev/null +++ b/GeneralMods/StardustCore/UIUtilities/IClickableMenuExtended.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StardustCore.UIUtilities +{ + public class IClickableMenuExtended : StardewValley.Menus.IClickableMenu + { + public List texturedStrings; + public List buttons; + + public override void receiveRightClick(int x, int y, bool playSound = true) + { + + } + } +} diff --git a/GeneralMods/StardustCore/UIUtilities/MenuComponents/Button.cs b/GeneralMods/StardustCore/UIUtilities/MenuComponents/Button.cs index 65ec9f73..ebfc9119 100644 --- a/GeneralMods/StardustCore/UIUtilities/MenuComponents/Button.cs +++ b/GeneralMods/StardustCore/UIUtilities/MenuComponents/Button.cs @@ -18,12 +18,12 @@ namespace StardustCore.UIUtilities.MenuComponents /// Basic Button constructor. /// /// - /// + /// The texture sheet to be drawn to the screen. Used with the animation manager this allows you to reference different parts of the sheet at any given time. /// /// /// /// - public Button(string Name,Rectangle Bounds,Texture2D Texture,string displayText,Rectangle sourceRect,float Scale,Animations.Animation defaultAnimation, Color DrawColor,Color TextColor, bool AnimationEnabled=true) : base(Bounds,Texture,sourceRect,Scale) + public Button(string Name,Rectangle Bounds,Texture2DExtended Texture,string displayText,Rectangle sourceRect,float Scale,Animations.Animation defaultAnimation, Color DrawColor,Color TextColor, bool AnimationEnabled=true) : base(Bounds,Texture.texture,sourceRect,Scale) { this.animationManager = new Animations.AnimationManager(Texture, defaultAnimation,AnimationEnabled); this.label = displayText; @@ -54,7 +54,7 @@ namespace StardustCore.UIUtilities.MenuComponents /// /// /// - public Button(string Name,Rectangle Bounds,Texture2D Texture, string displayText, Rectangle sourceRect,float Scale, Animations.Animation defaultAnimation,Dictionary> animationsToPlay,string startingAnimationKey,Color DrawColor,Color TextColor,int startingAnimationFrame=0,bool AnimationEnabled=true) : base(Bounds, Texture, sourceRect, Scale) + public Button(string Name,Rectangle Bounds,Texture2DExtended Texture, string displayText, Rectangle sourceRect,float Scale, Animations.Animation defaultAnimation,Dictionary> animationsToPlay,string startingAnimationKey,Color DrawColor,Color TextColor,int startingAnimationFrame=0,bool AnimationEnabled=true) : base(Bounds, Texture.texture, sourceRect, Scale) { this.animationManager = new Animations.AnimationManager(Texture, defaultAnimation, animationsToPlay, startingAnimationKey, startingAnimationFrame, AnimationEnabled); this.label = displayText; diff --git a/GeneralMods/StardustCore/UIUtilities/Texture2DExtended.cs b/GeneralMods/StardustCore/UIUtilities/Texture2DExtended.cs index 134d3608..abd9f2ec 100644 --- a/GeneralMods/StardustCore/UIUtilities/Texture2DExtended.cs +++ b/GeneralMods/StardustCore/UIUtilities/Texture2DExtended.cs @@ -1,4 +1,5 @@ using Microsoft.Xna.Framework.Graphics; +using StardewModdingAPI; using System; using System.Collections.Generic; using System.IO; @@ -14,16 +15,20 @@ namespace StardustCore.UIUtilities public Texture2D texture; public string path; - public Texture2DExtended(string path) + /// + /// Constructor. + /// + /// The relative path to file on disk. See StardustCore.Utilities.getRelativePath(modname,path); + public Texture2DExtended(IModHelper helper,string path) { this.Name = Path.GetFileName(path); this.path = path; - this.texture = StardustCore.ModCore.ModHelper.Content.Load(path); + this.texture = helper.Content.Load(path); } - public Texture2DExtended Copy() + public Texture2DExtended Copy(IModHelper helper) { - return new Texture2DExtended(this.path); + return new Texture2DExtended(helper,this.path); } } } diff --git a/GeneralMods/StardustCore/UIUtilities/TextureManager.cs b/GeneralMods/StardustCore/UIUtilities/TextureManager.cs new file mode 100644 index 00000000..c4c0402a --- /dev/null +++ b/GeneralMods/StardustCore/UIUtilities/TextureManager.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StardustCore.UIUtilities +{ + public class TextureManager + { + public Dictionary textures; + + public TextureManager() + { + this.textures = new Dictionary(); + } + + public void addTexture(string name,Texture2DExtended texture) + { + this.textures.Add(name,texture); + } + + /// + /// Returns a Texture2DExtended held by the manager. + /// + /// + /// + public Texture2DExtended getTexture(string name) + { + foreach(var v in textures) + { + if (v.Key == name) return v.Value; + } + return null; + } + + } +} diff --git a/GeneralMods/StardustCore/Utilities.cs b/GeneralMods/StardustCore/Utilities.cs index 9d1595c7..e15b39ab 100644 --- a/GeneralMods/StardustCore/Utilities.cs +++ b/GeneralMods/StardustCore/Utilities.cs @@ -25,6 +25,19 @@ namespace StardustCore 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 getRelativeDirectory(string modName,string path) + { + string s = getShortenedDirectory(modName,path); + return s.Remove(0, 1); + } + public static int sellToStorePrice(CoreObject c) { return (int)((double)c.price * (1.0 + (double)c.quality * 0.25)); diff --git a/GeneralMods/SundropMapEvents/Class1.cs b/GeneralMods/SundropMapEvents/Class1.cs index 62ad006a..a059bf64 100644 --- a/GeneralMods/SundropMapEvents/Class1.cs +++ b/GeneralMods/SundropMapEvents/Class1.cs @@ -9,7 +9,7 @@ using StardewValley; using EventSystem.Framework.FunctionEvents; using EventSystem.Framework.Information; using Microsoft.Xna.Framework; - +using EventSystem.Framework.Events; namespace SundropMapEvents { public class Class1 :Mod @@ -26,7 +26,8 @@ namespace SundropMapEvents private void SaveEvents_AfterLoad(object sender, EventArgs e) { - EventSystem.EventSystem.eventManager.addEvent(Game1.getLocationFromName("BusStop"), new EventSystem.Framework.Events.WarpEvent("toRR", Game1.getLocationFromName("BusStop"), new Vector2(6, 11), new PlayerEvents(null, null), new WarpInformation("BusStop", 10, 12, 2, false))); + EventSystem.EventSystem.eventManager.addEvent(Game1.getLocationFromName("BusStop"), new WarpEvent("toRR", Game1.getLocationFromName("BusStop"), new Vector2(6, 11), new PlayerEvents(null, null), new WarpInformation("BusStop", 10, 12, 2, false))); + EventSystem.EventSystem.eventManager.addEvent(Game1.getLocationFromName("BusStop"), new DialogueDisplayEvent("Hello.", Game1.getLocationFromName("BusStop"), new Vector2(10, 13), new PlayerEvents(null, null), "Hello there!")); } } } From 16c77a1497310dd42164f0d694b84dd7f6429862 Mon Sep 17 00:00:00 2001 From: Date: Mon, 5 Mar 2018 23:06:39 -0800 Subject: [PATCH 10/54] Ui buttons work, dialogue events now work for left click which could lead to some spicy mods. --- .../Framework/Events/DialogueDisplayEvent.cs | 29 +++++++++++-- GeneralMods/MapEvents/Framework/MapEvent.cs | 7 ++-- .../Framework/Menus/MusicManagerMenu.cs | 36 +++++++++++++--- GeneralMods/StardustCore/StardustCore.csproj | 3 ++ .../UIUtilities/MenuComponents/Button.cs | 42 ++++++++++++++++++- .../Delegates/DelegatePairing.cs | 32 ++++++++++++++ .../MenuComponents/Delegates/Delegates.cs | 14 +++++++ .../Functionality/ButtonFunctionality.cs | 22 ++++++++++ GeneralMods/SundropMapEvents/Class1.cs | 2 +- 9 files changed, 172 insertions(+), 15 deletions(-) create mode 100644 GeneralMods/StardustCore/UIUtilities/MenuComponents/Delegates/DelegatePairing.cs create mode 100644 GeneralMods/StardustCore/UIUtilities/MenuComponents/Delegates/Delegates.cs create mode 100644 GeneralMods/StardustCore/UIUtilities/MenuComponents/Delegates/Functionality/ButtonFunctionality.cs diff --git a/GeneralMods/MapEvents/Framework/Events/DialogueDisplayEvent.cs b/GeneralMods/MapEvents/Framework/Events/DialogueDisplayEvent.cs index 0d0dec7c..809a7a35 100644 --- a/GeneralMods/MapEvents/Framework/Events/DialogueDisplayEvent.cs +++ b/GeneralMods/MapEvents/Framework/Events/DialogueDisplayEvent.cs @@ -13,17 +13,21 @@ namespace EventSystem.Framework.Events public class DialogueDisplayEvent :MapEvent { string dialogue; - public DialogueDisplayEvent(string Name, GameLocation Location, Vector2 Position, PlayerEvents playerEvents, string Dialogue) : base(Name, Location, Position, playerEvents) + public DialogueDisplayEvent(string Name, GameLocation Location, Vector2 Position, PlayerEvents playerEvents, MouseButtonEvents MouseEvents,MouseEntryLeaveEvent EntryLeave, string Dialogue) : base(Name, Location, Position, playerEvents) { this.name = Name; this.location = Location; this.tilePosition = Position; this.playerEvents = playerEvents; + this.mouseButtonEvents = MouseEvents; this.doesInteractionNeedToRun = true; this.dialogue = Dialogue; + + this.mouseEntryLeaveEvents = EntryLeave; } + /// /// Occurs when the player enters the warp tile event position. /// s @@ -33,7 +37,10 @@ namespace EventSystem.Framework.Events { this.doesInteractionNeedToRun = false; this.playerOnTile = true; - if (this.playerEvents.onPlayerEnter != null) this.playerEvents.onPlayerEnter.run(); //used to run a function before the warp. + if (this.playerEvents != null) + { + if (this.playerEvents.onPlayerEnter != null) this.playerEvents.onPlayerEnter.run(); //used to run a function before the warp. + } Game1.activeClickableMenu =new StardewValley.Menus.DialogueBox(this.dialogue); //Game1.drawDialogueBox(this.dialogue); } @@ -48,15 +55,31 @@ namespace EventSystem.Framework.Events { this.playerOnTile = false; this.doesInteractionNeedToRun = true; - if (this.playerEvents.onPlayerLeave != null) this.playerEvents.onPlayerLeave.run(); + if (this.playerEvents != null) + { + if (this.playerEvents.onPlayerLeave != null) this.playerEvents.onPlayerLeave.run(); + } } } + public override void OnLeftClick() + { + if (Game1.activeClickableMenu != null) return; + if (this.mouseButtonEvents == null) return; + if (this.mouseOnTile == false) return; + if (this.location.isObjectAt((int)this.tilePosition.X*Game1.tileSize, (int)this.tilePosition.Y*Game1.tileSize)) return; + if (this.mouseButtonEvents.onLeftClick != null) this.mouseButtonEvents.onLeftClick.run(); + Game1.activeClickableMenu = new StardewValley.Menus.DialogueBox(this.dialogue); + } + /// /// Used to update the event and check for interaction. /// public override void update() { + this.clickEvent(); + this.OnMouseEnter(); + this.OnMouseLeave(); this.OnPlayerEnter(); this.OnPlayerLeave(); } diff --git a/GeneralMods/MapEvents/Framework/MapEvent.cs b/GeneralMods/MapEvents/Framework/MapEvent.cs index d07d213e..7156763b 100644 --- a/GeneralMods/MapEvents/Framework/MapEvent.cs +++ b/GeneralMods/MapEvents/Framework/MapEvent.cs @@ -177,6 +177,7 @@ namespace EventSystem.Framework /// public virtual void OnLeftClick() { + if (Game1.activeClickableMenu != null) return; if (this.mouseOnTile==false) return; if (this.mouseButtonEvents.onLeftClick != null) this.mouseButtonEvents.onLeftClick.run(); } @@ -230,7 +231,7 @@ namespace EventSystem.Framework /// public virtual bool isMouseOnTile() { - Vector2 mousePosition = new Vector2(Game1.getMouseX(), Game1.getMouseY()); + Vector2 mousePosition = Game1.currentCursorTile; if (mousePosition.X == this.tilePosition.X && mousePosition.Y == this.tilePosition.Y) return true; return false; } @@ -238,7 +239,7 @@ namespace EventSystem.Framework /// /// Occurs when the tile is clicked. Runs the appropriate event. /// - public virtual void eventClickEvent() + public virtual void clickEvent() { if (this.mouseOnTile == false) return; var mouseState=Mouse.GetState(); @@ -253,7 +254,7 @@ namespace EventSystem.Framework /// public virtual void update() { - eventClickEvent(); //click events + clickEvent(); //click events OnPlayerEnter(); //player enter events OnPlayerLeave(); //player leave events OnMouseEnter(); //on mouse enter events diff --git a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Menus/MusicManagerMenu.cs b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Menus/MusicManagerMenu.cs index 8e97d10d..cf3255a0 100644 --- a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Menus/MusicManagerMenu.cs +++ b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Menus/MusicManagerMenu.cs @@ -8,30 +8,46 @@ using Microsoft.Xna.Framework.Graphics; using StardewValley; using StardustCore.UIUtilities; using StardustCore.UIUtilities.MenuComponents; +using StardustCore.UIUtilities.MenuComponents.Delegates; +using StardustCore.UIUtilities.MenuComponents.Delegates.Functionality; namespace StardewSymphonyRemastered.Framework.Menus { public class MusicManagerMenu : IClickableMenuExtended { - private string musicNotePath; public MusicManagerMenu(float width, float height) { - - - this.width = (int)width; this.height = (int)height; this.texturedStrings = new List(); this.texturedStrings.Add(StardustCore.UIUtilities.SpriteFonts.SpriteFont.vanillaFont.ParseString("Hello", new Microsoft.Xna.Framework.Vector2(100, 100),StardustCore.IlluminateFramework.Colors.invertColor(StardustCore.IlluminateFramework.LightColorsList.Blue))); this.buttons = new List(); - this.buttons.Add(new Button("myButton", new Rectangle(100, 100, 200, 100), StardewSymphony.textureManager.getTexture("MusicNote").Copy(StardewSymphony.ModHelper), "mynote", new Rectangle(0, 0, 16, 16), 4f, new StardustCore.Animations.Animation(new Rectangle(0, 0, 16, 16)), Color.White, Color.White, false)); - + this.buttons.Add(new Button("myButton", new Rectangle(100, 100, 64, 64), StardewSymphony.textureManager.getTexture("MusicNote").Copy(StardewSymphony.ModHelper), "mynote", new Rectangle(0, 0, 16, 16), 4f, new StardustCore.Animations.Animation(new Rectangle(0, 0, 16, 16)), Color.White, Color.White,new ButtonFunctionality(new DelegatePairing(hello,null),null,null),false)); //A button that does nothing on the left click. } public override void receiveRightClick(int x, int y, bool playSound = true) { + foreach (var v in this.buttons) + { + if (v.containsPoint(x, y)) v.onRightClick(); + } + } + public override void performHoverAction(int x, int y) + { + foreach(var v in this.buttons) + { + if (v.containsPoint(x, y)) v.onHover(); + } + } + + public override void receiveLeftClick(int x, int y, bool playSound = true) + { + foreach (var v in this.buttons) + { + if (v.containsPoint(x, y)) v.onLeftClick(); + } } public override void drawBackground(SpriteBatch b) @@ -54,5 +70,13 @@ namespace StardewSymphonyRemastered.Framework.Menus } this.drawMouse(b); } + + //Button Functionality + #region + private void hello(List param) + { + StardewSymphony.ModMonitor.Log("Hello"); + } + #endregion } } diff --git a/GeneralMods/StardustCore/StardustCore.csproj b/GeneralMods/StardustCore/StardustCore.csproj index c2d4554a..67a0b4eb 100644 --- a/GeneralMods/StardustCore/StardustCore.csproj +++ b/GeneralMods/StardustCore/StardustCore.csproj @@ -49,6 +49,9 @@ + + + diff --git a/GeneralMods/StardustCore/UIUtilities/MenuComponents/Button.cs b/GeneralMods/StardustCore/UIUtilities/MenuComponents/Button.cs index ebfc9119..064022bc 100644 --- a/GeneralMods/StardustCore/UIUtilities/MenuComponents/Button.cs +++ b/GeneralMods/StardustCore/UIUtilities/MenuComponents/Button.cs @@ -1,11 +1,14 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using StardewValley; +using StardustCore.UIUtilities.MenuComponents.Delegates; +using StardustCore.UIUtilities.MenuComponents.Delegates.Functionality; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using static StardustCore.UIUtilities.MenuComponents.Delegates.Delegates; namespace StardustCore.UIUtilities.MenuComponents { @@ -14,6 +17,9 @@ namespace StardustCore.UIUtilities.MenuComponents public Animations.AnimationManager animationManager; public Color textureColor; public Color textColor; + + public ButtonFunctionality buttonFunctionality; + /// /// Basic Button constructor. /// @@ -23,7 +29,7 @@ namespace StardustCore.UIUtilities.MenuComponents /// /// /// - public Button(string Name,Rectangle Bounds,Texture2DExtended Texture,string displayText,Rectangle sourceRect,float Scale,Animations.Animation defaultAnimation, Color DrawColor,Color TextColor, bool AnimationEnabled=true) : base(Bounds,Texture.texture,sourceRect,Scale) + public Button(string Name,Rectangle Bounds,Texture2DExtended Texture,string displayText,Rectangle sourceRect,float Scale,Animations.Animation defaultAnimation, Color DrawColor,Color TextColor, ButtonFunctionality Functionality, bool AnimationEnabled=true) : base(Bounds,Texture.texture,sourceRect,Scale) { this.animationManager = new Animations.AnimationManager(Texture, defaultAnimation,AnimationEnabled); this.label = displayText; @@ -38,6 +44,7 @@ namespace StardustCore.UIUtilities.MenuComponents { this.textColor = StardustCore.IlluminateFramework.Colors.getColorFromList("White"); } + this.buttonFunctionality = Functionality; } /// @@ -54,7 +61,7 @@ namespace StardustCore.UIUtilities.MenuComponents /// /// /// - public Button(string Name,Rectangle Bounds,Texture2DExtended Texture, string displayText, Rectangle sourceRect,float Scale, Animations.Animation defaultAnimation,Dictionary> animationsToPlay,string startingAnimationKey,Color DrawColor,Color TextColor,int startingAnimationFrame=0,bool AnimationEnabled=true) : base(Bounds, Texture.texture, sourceRect, Scale) + public Button(string Name,Rectangle Bounds,Texture2DExtended Texture, string displayText, Rectangle sourceRect,float Scale, Animations.Animation defaultAnimation,Dictionary> animationsToPlay,string startingAnimationKey,Color DrawColor,Color TextColor, ButtonFunctionality Functionality,int startingAnimationFrame=0,bool AnimationEnabled=true) : base(Bounds, Texture.texture, sourceRect, Scale) { this.animationManager = new Animations.AnimationManager(Texture, defaultAnimation, animationsToPlay, startingAnimationKey, startingAnimationFrame, AnimationEnabled); this.label = displayText; @@ -69,6 +76,7 @@ namespace StardustCore.UIUtilities.MenuComponents { this.textColor = StardustCore.IlluminateFramework.Colors.getColorFromList("White"); } + this.buttonFunctionality = Functionality; } /// @@ -104,5 +112,35 @@ namespace StardustCore.UIUtilities.MenuComponents } } + + public void onRightClick() + { + if (this.buttonFunctionality == null) return; + else + { + if (this.buttonFunctionality.rightClick == null) return; + else this.buttonFunctionality.rightClick.run(); + } + } + + public void onLeftClick() + { + if (this.buttonFunctionality == null) return; + else + { + if (this.buttonFunctionality.leftClick == null) return; + else this.buttonFunctionality.leftClick.run(); + } + } + + public void onHover() + { + if (this.buttonFunctionality == null) return; + else + { + if (this.buttonFunctionality.hover == null) return; + else this.buttonFunctionality.hover.run(); + } + } } } diff --git a/GeneralMods/StardustCore/UIUtilities/MenuComponents/Delegates/DelegatePairing.cs b/GeneralMods/StardustCore/UIUtilities/MenuComponents/Delegates/DelegatePairing.cs new file mode 100644 index 00000000..c245d5a6 --- /dev/null +++ b/GeneralMods/StardustCore/UIUtilities/MenuComponents/Delegates/DelegatePairing.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StardustCore.UIUtilities.MenuComponents.Delegates +{ + public class DelegatePairing + { + public Delegates.paramaterDelegate click; + public List paramaters; + + public DelegatePairing(Delegates.paramaterDelegate buttonDelegate,List Paramaters) + { + this.click = buttonDelegate; + if (this.paramaters == null) + { + this.paramaters = new List(); + } + else + { + this.paramaters = Paramaters; + } + } + + public void run() + { + this.click.Invoke(this.paramaters); + } + } +} diff --git a/GeneralMods/StardustCore/UIUtilities/MenuComponents/Delegates/Delegates.cs b/GeneralMods/StardustCore/UIUtilities/MenuComponents/Delegates/Delegates.cs new file mode 100644 index 00000000..a711a47b --- /dev/null +++ b/GeneralMods/StardustCore/UIUtilities/MenuComponents/Delegates/Delegates.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StardustCore.UIUtilities.MenuComponents.Delegates +{ + public class Delegates + { + public delegate void paramaterDelegate(List paramaters); + + } +} diff --git a/GeneralMods/StardustCore/UIUtilities/MenuComponents/Delegates/Functionality/ButtonFunctionality.cs b/GeneralMods/StardustCore/UIUtilities/MenuComponents/Delegates/Functionality/ButtonFunctionality.cs new file mode 100644 index 00000000..5f3b3426 --- /dev/null +++ b/GeneralMods/StardustCore/UIUtilities/MenuComponents/Delegates/Functionality/ButtonFunctionality.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StardustCore.UIUtilities.MenuComponents.Delegates.Functionality +{ + public class ButtonFunctionality + { + public DelegatePairing leftClick; + public DelegatePairing rightClick; + public DelegatePairing hover; + + public ButtonFunctionality(DelegatePairing LeftClick, DelegatePairing RightClick, DelegatePairing OnHover) + { + this.leftClick = LeftClick; + this.rightClick = RightClick; + this.hover = OnHover; + } + } +} diff --git a/GeneralMods/SundropMapEvents/Class1.cs b/GeneralMods/SundropMapEvents/Class1.cs index a059bf64..449bdfb7 100644 --- a/GeneralMods/SundropMapEvents/Class1.cs +++ b/GeneralMods/SundropMapEvents/Class1.cs @@ -27,7 +27,7 @@ namespace SundropMapEvents private void SaveEvents_AfterLoad(object sender, EventArgs e) { EventSystem.EventSystem.eventManager.addEvent(Game1.getLocationFromName("BusStop"), new WarpEvent("toRR", Game1.getLocationFromName("BusStop"), new Vector2(6, 11), new PlayerEvents(null, null), new WarpInformation("BusStop", 10, 12, 2, false))); - EventSystem.EventSystem.eventManager.addEvent(Game1.getLocationFromName("BusStop"), new DialogueDisplayEvent("Hello.", Game1.getLocationFromName("BusStop"), new Vector2(10, 13), new PlayerEvents(null, null), "Hello there!")); + EventSystem.EventSystem.eventManager.addEvent(Game1.getLocationFromName("BusStop"), new DialogueDisplayEvent("Hello.", Game1.getLocationFromName("BusStop"), new Vector2(10, 13), new PlayerEvents(null, null),new MouseButtonEvents(null,null) , new MouseEntryLeaveEvent(null,null),"Hello there!")); } } } From 8d1eef7329c405b7be8dcd8f8e9d6f9e2c4e22d7 Mon Sep 17 00:00:00 2001 From: Date: Mon, 5 Mar 2018 23:46:24 -0800 Subject: [PATCH 11/54] Cleaned up code regarding the Event System mod to prevent lots of redundant code. --- .../Framework/Events/DialogueDisplayEvent.cs | 50 +++---------------- .../MapEvents/Framework/Events/WarpEvent.cs | 21 +++----- GeneralMods/MapEvents/Framework/MapEvent.cs | 47 ++++++++++++----- GeneralMods/SundropMapEvents/Class1.cs | 2 +- 4 files changed, 49 insertions(+), 71 deletions(-) diff --git a/GeneralMods/MapEvents/Framework/Events/DialogueDisplayEvent.cs b/GeneralMods/MapEvents/Framework/Events/DialogueDisplayEvent.cs index 809a7a35..54e143c1 100644 --- a/GeneralMods/MapEvents/Framework/Events/DialogueDisplayEvent.cs +++ b/GeneralMods/MapEvents/Framework/Events/DialogueDisplayEvent.cs @@ -13,12 +13,11 @@ namespace EventSystem.Framework.Events public class DialogueDisplayEvent :MapEvent { string dialogue; - public DialogueDisplayEvent(string Name, GameLocation Location, Vector2 Position, PlayerEvents playerEvents, MouseButtonEvents MouseEvents,MouseEntryLeaveEvent EntryLeave, string Dialogue) : base(Name, Location, Position, playerEvents) + public DialogueDisplayEvent(string Name, GameLocation Location, Vector2 Position, MouseButtonEvents MouseEvents,MouseEntryLeaveEvent EntryLeave, string Dialogue) : base(Name, Location, Position) { this.name = Name; this.location = Location; this.tilePosition = Position; - this.playerEvents = playerEvents; this.mouseButtonEvents = MouseEvents; this.doesInteractionNeedToRun = true; @@ -28,48 +27,12 @@ namespace EventSystem.Framework.Events } - /// - /// Occurs when the player enters the warp tile event position. - /// s - public override void OnPlayerEnter() + public override bool OnLeftClick() { - if (isPlayerOnTile() == true && this.doesInteractionNeedToRun == true) - { - this.doesInteractionNeedToRun = false; - this.playerOnTile = true; - if (this.playerEvents != null) - { - if (this.playerEvents.onPlayerEnter != null) this.playerEvents.onPlayerEnter.run(); //used to run a function before the warp. - } - Game1.activeClickableMenu =new StardewValley.Menus.DialogueBox(this.dialogue); - //Game1.drawDialogueBox(this.dialogue); - } - } - - /// - /// Runs when the player is not on the tile and resets player interaction. - /// - public override void OnPlayerLeave() - { - if (isPlayerOnTile() == false && this.playerOnTile == true) - { - this.playerOnTile = false; - this.doesInteractionNeedToRun = true; - if (this.playerEvents != null) - { - if (this.playerEvents.onPlayerLeave != null) this.playerEvents.onPlayerLeave.run(); - } - } - } - - public override void OnLeftClick() - { - if (Game1.activeClickableMenu != null) return; - if (this.mouseButtonEvents == null) return; - if (this.mouseOnTile == false) return; - if (this.location.isObjectAt((int)this.tilePosition.X*Game1.tileSize, (int)this.tilePosition.Y*Game1.tileSize)) return; - if (this.mouseButtonEvents.onLeftClick != null) this.mouseButtonEvents.onLeftClick.run(); + if (base.OnLeftClick() == false) return false; + if (this.location.isObjectAt((int)this.tilePosition.X*Game1.tileSize, (int)this.tilePosition.Y*Game1.tileSize)) return false; Game1.activeClickableMenu = new StardewValley.Menus.DialogueBox(this.dialogue); + return true; } /// @@ -78,10 +41,9 @@ namespace EventSystem.Framework.Events public override void update() { this.clickEvent(); + //Needed for updating. this.OnMouseEnter(); this.OnMouseLeave(); - this.OnPlayerEnter(); - this.OnPlayerLeave(); } } diff --git a/GeneralMods/MapEvents/Framework/Events/WarpEvent.cs b/GeneralMods/MapEvents/Framework/Events/WarpEvent.cs index 68ae3f3b..fc52d68f 100644 --- a/GeneralMods/MapEvents/Framework/Events/WarpEvent.cs +++ b/GeneralMods/MapEvents/Framework/Events/WarpEvent.cs @@ -39,28 +39,23 @@ namespace EventSystem.Framework.Events /// /// Occurs when the player enters the warp tile event position. /// - public override void OnPlayerEnter() + public override bool OnPlayerEnter() { - if (isPlayerOnTile() == true&& this.doesInteractionNeedToRun==true) + if (base.OnPlayerEnter() == false) return false; + else { - this.doesInteractionNeedToRun = false; - this.playerOnTile = true; - if (this.playerEvents.onPlayerEnter != null) this.playerEvents.onPlayerEnter.run(); //used to run a function before the warp. - Game1.warpFarmer(Game1.getLocationFromName(this.warpInfo.targetMapName),this.warpInfo.targetX,this.warpInfo.targetY,this.warpInfo.facingDirection,this.warpInfo.isStructure); + Game1.warpFarmer(Game1.getLocationFromName(this.warpInfo.targetMapName), this.warpInfo.targetX, this.warpInfo.targetY, this.warpInfo.facingDirection, this.warpInfo.isStructure); + return true; } } /// /// Runs when the player is not on the tile and resets player interaction. /// - public override void OnPlayerLeave() + public override bool OnPlayerLeave() { - if (isPlayerOnTile() == false && this.playerOnTile == true) - { - this.playerOnTile = false; - this.doesInteractionNeedToRun = true; - if (this.playerEvents.onPlayerLeave != null) this.playerEvents.onPlayerLeave.run(); - } + if (base.OnPlayerLeave() == false) return false; + return true; } /// diff --git a/GeneralMods/MapEvents/Framework/MapEvent.cs b/GeneralMods/MapEvents/Framework/MapEvent.cs index 7156763b..fbf2913d 100644 --- a/GeneralMods/MapEvents/Framework/MapEvent.cs +++ b/GeneralMods/MapEvents/Framework/MapEvent.cs @@ -135,24 +135,32 @@ namespace EventSystem.Framework /// /// Occurs when the player enters the same tile as this event. The function associated with this event is then ran. /// - public virtual void OnPlayerEnter() + public virtual bool OnPlayerEnter() { - if (isPlayerOnTile() == true) + if (this.playerEvents == null) return false; + if (isPlayerOnTile() == true && this.doesInteractionNeedToRun==true) { this.playerOnTile = true; + this.doesInteractionNeedToRun = false; if (this.playerEvents.onPlayerEnter != null) 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. /// - public virtual void OnPlayerLeave() + public virtual bool OnPlayerLeave() { - if(isPlayerOnTile() == false && this.playerOnTile==true){ + if (this.playerEvents == null) return false; + if (isPlayerOnTile() == false && this.playerOnTile==true){ this.playerOnTile = false; + this.doesInteractionNeedToRun = true; if (this.playerEvents.onPlayerLeave != null) this.playerEvents.onPlayerLeave.run(); + return true; } + return false; } /// @@ -175,54 +183,66 @@ namespace EventSystem.Framework /// /// Occurs when the player left clicks the same tile that this event is on. /// - public virtual void OnLeftClick() + public virtual bool OnLeftClick() { - if (Game1.activeClickableMenu != null) return; - if (this.mouseOnTile==false) return; + if (this.mouseOnTile==false) return false; + if (this.mouseButtonEvents == null) return false; if (this.mouseButtonEvents.onLeftClick != null) this.mouseButtonEvents.onLeftClick.run(); + return true; + } /// /// Occurs when the player right clicks the same tile that this event is on. /// - public virtual void OnRightClick() + public virtual bool OnRightClick() { - if (this.mouseOnTile == false) return; + if (this.mouseOnTile == false) return false; + if (this.mouseButtonEvents == null) return false; if (this.mouseButtonEvents.onRightClick != null) this.mouseButtonEvents.onRightClick.run(); + return true; } /// /// Occurs when the mouse tile position is the same as this event's x,y position. /// - public virtual void OnMouseEnter() + public virtual bool OnMouseEnter() { + if (this.mouseEntryLeaveEvents == null) return false; if (isMouseOnTile()) { this.mouseOnTile = true; if (this.mouseEntryLeaveEvents.onMouseEnter != null) this.mouseEntryLeaveEvents.onMouseEnter.run(); + return true; } + return false; } /// /// Occurs when the mouse tile position leaves the the same x,y position as this event. /// - public virtual void OnMouseLeave() + public virtual bool OnMouseLeave() { + if (this.mouseEntryLeaveEvents == null) return false; if (isMouseOnTile() == false && this.mouseOnTile == true) { this.mouseOnTile = false; if (this.mouseEntryLeaveEvents.onMouseLeave != null) 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. /// - public virtual void OnMouseScroll() + public virtual bool OnMouseScroll() { - if (isMouseOnTile() == false) return; + + if (isMouseOnTile() == false) return false; if (this.mouseButtonEvents.onMouseScroll != null) this.mouseButtonEvents.onMouseScroll.run(); + return true; } /// @@ -254,6 +274,7 @@ namespace EventSystem.Framework /// public virtual void update() { + if (Game1.activeClickableMenu != null) return; clickEvent(); //click events OnPlayerEnter(); //player enter events OnPlayerLeave(); //player leave events diff --git a/GeneralMods/SundropMapEvents/Class1.cs b/GeneralMods/SundropMapEvents/Class1.cs index 449bdfb7..8d824a2f 100644 --- a/GeneralMods/SundropMapEvents/Class1.cs +++ b/GeneralMods/SundropMapEvents/Class1.cs @@ -27,7 +27,7 @@ namespace SundropMapEvents private void SaveEvents_AfterLoad(object sender, EventArgs e) { EventSystem.EventSystem.eventManager.addEvent(Game1.getLocationFromName("BusStop"), new WarpEvent("toRR", Game1.getLocationFromName("BusStop"), new Vector2(6, 11), new PlayerEvents(null, null), new WarpInformation("BusStop", 10, 12, 2, false))); - EventSystem.EventSystem.eventManager.addEvent(Game1.getLocationFromName("BusStop"), new DialogueDisplayEvent("Hello.", Game1.getLocationFromName("BusStop"), new Vector2(10, 13), new PlayerEvents(null, null),new MouseButtonEvents(null,null) , new MouseEntryLeaveEvent(null,null),"Hello there!")); + EventSystem.EventSystem.eventManager.addEvent(Game1.getLocationFromName("BusStop"), new DialogueDisplayEvent("Hello.", Game1.getLocationFromName("BusStop"), new Vector2(10, 13),new MouseButtonEvents(null,null) , new MouseEntryLeaveEvent(null,null),"Hello there!")); } } } From 43573f0bbab3eded32c9140efa0d1a741645cff3 Mon Sep 17 00:00:00 2001 From: Date: Sat, 17 Mar 2018 04:04:04 -0700 Subject: [PATCH 12/54] Fixed glitches pertaining to loading assets in and generating random npcs. Need to fix layer depth to see if NPC will properly render. --- GeneralMods/CustomNPCFramework/Class1.cs | 28 ++-- .../Framework/Graphics/AssetManager.cs | 18 ++- .../Framework/Graphics/AssetPool.cs | 141 ++++++++++++++---- .../Framework/Graphics/AssetSheet.cs | 9 +- .../Framework/Graphics/ExtendedAssetInfo.cs | 5 +- .../ModularNPCS/AnimatedSpriteCollection.cs | 3 + .../ModularNPCS/AnimatedSpriteExtended.cs | 3 +- .../ModularRenderers/BasicRenderer.cs | 2 +- .../Framework/ModularNPCS/Sprite.cs | 18 ++- .../CustomNPCFramework/Framework/NPCNames.cs | 14 ++ .../Framework/NPCS/ExtendedNPC.cs | 6 +- 11 files changed, 191 insertions(+), 56 deletions(-) diff --git a/GeneralMods/CustomNPCFramework/Class1.cs b/GeneralMods/CustomNPCFramework/Class1.cs index 383f5c5c..83bccc2a 100644 --- a/GeneralMods/CustomNPCFramework/Class1.cs +++ b/GeneralMods/CustomNPCFramework/Class1.cs @@ -101,27 +101,14 @@ namespace CustomNPCFramework /// /// Used to spawn a custom npc just as an example. Don't keep this code. + /// GENERATE NPC AND CALL THE CODE /// /// /// private void SaveEvents_LoadChar(object sender, EventArgs e) { - - //Texture2D tex = ModHelper.Content.Load(Path.Combine(getShortenedDirectory(path).Remove(0, 1), "character.png")); - if (assetPool.getAssetManager("testNPC").getAssetByName("character") == null) - { - - ModMonitor.Log("HMMMMM", LogLevel.Error); - - } - var pair= assetPool.getAssetManager("testNPC").getAssetByName("character").getPathTexturePair(); - if (pair.Value == null) - { - ModMonitor.Log("UGGGGGGG", LogLevel.Error); - } - ExtendedNPC myNpc3 = new ExtendedNPC(new Framework.ModularNPCS.Sprite(pair.Key,pair.Value),null,null, new Vector2(14, 14)*Game1.tileSize, 2, "b2"); - npcTracker.addNewNPCToLocation(Game1.getLocationFromName("BusStop"),myNpc3); - myNpc3.SetMovingDown(true); + ExtendedNPC myNpc3 = assetPool.generateNPC(Genders.female, 0, 1); + npcTracker.addNewNPCToLocation(Game1.getLocationFromName("BusStop", false), myNpc3); } public void initializeExamples() @@ -157,7 +144,14 @@ namespace CustomNPCFramework { string lol = (string)path.Clone(); string[] spliter = lol.Split(new string[] { ModHelper.DirectoryPath },StringSplitOptions.None); - return spliter[1]; + try + { + return spliter[1]; + } + catch(Exception err) + { + return spliter[0]; + } } public static string getRelativeDirectory(string path) diff --git a/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetManager.cs b/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetManager.cs index 40fb18e1..0e54d56e 100644 --- a/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetManager.cs +++ b/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetManager.cs @@ -58,6 +58,11 @@ namespace CustomNPCFramework.Framework.Graphics ProcessDirectory(subdirectory); } + /// + /// Actually load in the asset information. + /// + /// + /// private void ProcessFile(string file,string path) { try @@ -65,6 +70,7 @@ namespace CustomNPCFramework.Framework.Graphics ExtendedAssetInfo info = ExtendedAssetInfo.readFromJson(file); AssetSheet sheet = new AssetSheet(info, path); addAsset(sheet); + Class1.ModMonitor.Log("Loaded in new modular asset: " + info.assetName + " asset type: " + info.type); } catch (Exception err) { @@ -228,11 +234,19 @@ namespace CustomNPCFramework.Framework.Graphics { foreach (var sea in (v.assetInfo as ExtendedAssetInfo).seasons) { - if (sea == season && (v.assetInfo as ExtendedAssetInfo).gender == gender && (v.assetInfo as ExtendedAssetInfo).type == type) aSheet.Add(v); - break; //Only need to find first validation that this is a valid asset. + //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."); + } } } } + //Class1.ModMonitor.Log("ok it's over: "+aSheet.Count.ToString()); return aSheet; } diff --git a/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetPool.cs b/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetPool.cs index 1cca96ae..74eba33a 100644 --- a/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetPool.cs +++ b/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetPool.cs @@ -7,6 +7,7 @@ using CustomNPCFramework.Framework.NPCS; using StardewValley; using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -81,17 +82,17 @@ namespace CustomNPCFramework.Framework.Graphics { assetPool.TryGetValue(name, out AssetManager asset); var assetSheet = asset.getAssetByName(name); - return new AnimatedSpriteExtended(assetSheet.clone().getCurrentSpriteTexture(), assetSheet.index, (int)assetSheet.assetInfo.assetSize.X, (int)assetSheet.assetInfo.assetSize.Y); + return new AnimatedSpriteExtended(assetSheet.clone().getCurrentSpriteTexture(),assetSheet.path.Clone().ToString(),assetSheet.index, (int)assetSheet.assetInfo.assetSize.X, (int)assetSheet.assetInfo.assetSize.Y); } public AnimatedSpriteCollection getSpriteCollectionFromSheet(AssetSheet assetSheet, AnimationType type) { - var left = new AnimatedSpriteExtended(assetSheet.clone().getTexture(Direction.left, type), assetSheet.index, (int)assetSheet.assetInfo.assetSize.X, (int)assetSheet.assetInfo.assetSize.Y); - var right = new AnimatedSpriteExtended(assetSheet.clone().getTexture(Direction.right, type), assetSheet.index, (int)assetSheet.assetInfo.assetSize.X, (int)assetSheet.assetInfo.assetSize.Y); - var up = new AnimatedSpriteExtended(assetSheet.clone().getTexture(Direction.up, type), assetSheet.index, (int)assetSheet.assetInfo.assetSize.X, (int)assetSheet.assetInfo.assetSize.Y); - var down = new AnimatedSpriteExtended(assetSheet.clone().getTexture(Direction.down, type), assetSheet.index, (int)assetSheet.assetInfo.assetSize.X, (int)assetSheet.assetInfo.assetSize.Y); + var left = new AnimatedSpriteExtended(assetSheet.clone().getTexture(Direction.left, type),assetSheet.path.Clone().ToString(),assetSheet.index, (int)assetSheet.assetInfo.assetSize.X, (int)assetSheet.assetInfo.assetSize.Y); + var right = new AnimatedSpriteExtended(assetSheet.clone().getTexture(Direction.right, type),assetSheet.path.Clone().ToString(), assetSheet.index, (int)assetSheet.assetInfo.assetSize.X, (int)assetSheet.assetInfo.assetSize.Y); + var up = new AnimatedSpriteExtended(assetSheet.clone().getTexture(Direction.up, type),assetSheet.path.Clone().ToString(), assetSheet.index, (int)assetSheet.assetInfo.assetSize.X, (int)assetSheet.assetInfo.assetSize.Y); + var down = new AnimatedSpriteExtended(assetSheet.clone().getTexture(Direction.down, type), assetSheet.path.Clone().ToString(),assetSheet.index, (int)assetSheet.assetInfo.assetSize.X, (int)assetSheet.assetInfo.assetSize.Y); return new AnimatedSpriteCollection(left, right, up, down, Direction.down); } @@ -142,7 +143,14 @@ namespace CustomNPCFramework.Framework.Graphics return parts; } - public void generateNPC(Genders gender, int minNumOfAccessories, int maxNumOfAccessories) + + /// + /// Generate a basic npc based off of all all of the NPC data here. + /// + /// + /// + /// + public ExtendedNPC generateNPC(Genders gender, int minNumOfAccessories, int maxNumOfAccessories) { Seasons myseason=Seasons.spring; @@ -178,35 +186,105 @@ namespace CustomNPCFramework.Framework.Graphics foreach (var piece in pants) pantsList.Add(piece); var shoes = getListOfApplicableBodyParts(assetManager.Key, gender, myseason, PartType.shoes); - foreach (var piece in shoes) bodyList.Add(piece); + foreach (var piece in shoes) shoesList.Add(piece); var accessory = getListOfApplicableBodyParts(assetManager.Key, gender, myseason, PartType.accessory); foreach (var piece in accessory) accessoryList.Add(piece); } - Random r = new Random(Game1.random.Next()); - int amount = r.Next(minNumOfAccessories, maxNumOfAccessories); - - int bodyIndex = r.Next(0, bodyList.Count - 1); - int eyesIndex = r.Next(0, eyesList.Count - 1); - int hairIndex = r.Next(0, hairList.Count - 1); - int shirtIndex = r.Next(0, shirtList.Count - 1); - int pantsIndex = r.Next(0, pantsList.Count - 1); - int shoesIndex = r.Next(0, shoesList.Count - 1); - List accIntList = new List(); - for (int i = 0; i < amount; i++) + + 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; + + if (bodyList.Count != 0) { + bodyIndex = r.Next(0, bodyList.Count - 1); + } + else { - int acc = r.Next(0, accessoryList.Count - 1); - accIntList.Add(acc); + Class1.ModMonitor.Log("Error: Not enough body templates to generate an npc. Aborting", StardewModdingAPI.LogLevel.Error); + return null; + } + + 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) { + 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) { + 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) { + 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) { + 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) + { + for (int i = 0; i < amount; i++) + { + int acc = r.Next(0, accessoryList.Count - 1); + accIntList.Add(acc); + } } //Get a single sheet to pull from. - AssetSheet bodySheet = bodyList.ElementAt(bodyIndex); - AssetSheet eyesSheet = eyesList.ElementAt(bodyIndex); - AssetSheet hairSheet = hairList.ElementAt(bodyIndex); - AssetSheet shirtSheet = shirtList.ElementAt(bodyIndex); - AssetSheet pantsSheet = pantsList.ElementAt(bodyIndex); - AssetSheet shoesSheet = shoesList.ElementAt(bodyIndex); + 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 = eyesList.ElementAt(shirtIndex); + pantsSheet = pantsList.ElementAt(pantsIndex); + shoesSheet = shoesList.ElementAt(shoesIndex); + + List accessorySheet = new List(); foreach (var v in accIntList) @@ -215,9 +293,9 @@ namespace CustomNPCFramework.Framework.Graphics } var render = generateBasicRenderer(bodySheet, eyesSheet, hairSheet, shirtSheet, pantsSheet, shoesSheet, accessorySheet); - ExtendedNPC npc = new ExtendedNPC(null, render, new Microsoft.Xna.Framework.Vector2(13, 15) * Game1.tileSize, 2, NPCNames.getRandomNPCName(gender)); - - } + ExtendedNPC npc = new ExtendedNPC(new Sprite(getDefaultSpriteImage(bodySheet)), render, new Microsoft.Xna.Framework.Vector2(13, 15) * Game1.tileSize, 2, NPCNames.getRandomNPCName(gender)); + return npc; + } public virtual BasicRenderer generateBasicRenderer(AssetSheet bodySheet, AssetSheet eyesSheet, AssetSheet hairSheet, AssetSheet shirtSheet, AssetSheet pantsSheet, AssetSheet shoesSheet, List accessorySheet) { @@ -250,5 +328,10 @@ namespace CustomNPCFramework.Framework.Graphics StandardCharacterAnimation standingAnimation = new StandardCharacterAnimation(bodySprite, eyesSprite, hairSprite, shirtSprite, pantsSprite, shoesSprite, accessoryCollection); return standingAnimation; } + + 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 7d2c1b13..b67bf0ea 100644 --- a/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetSheet.cs +++ b/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetSheet.cs @@ -29,7 +29,14 @@ namespace CustomNPCFramework.Framework.Graphics { this.assetInfo = info; this.textures = new TextureGroup(info,path,direction); - this.path = Class1.getShortenedDirectory(path); + try + { + this.path = Class1.getShortenedDirectory(path); + } + catch(Exception err) + { + this.path = path; + } this.index = 0; } diff --git a/GeneralMods/CustomNPCFramework/Framework/Graphics/ExtendedAssetInfo.cs b/GeneralMods/CustomNPCFramework/Framework/Graphics/ExtendedAssetInfo.cs index 69458519..39ab9170 100644 --- a/GeneralMods/CustomNPCFramework/Framework/Graphics/ExtendedAssetInfo.cs +++ b/GeneralMods/CustomNPCFramework/Framework/Graphics/ExtendedAssetInfo.cs @@ -11,12 +11,12 @@ namespace CustomNPCFramework.Framework.Graphics public class ExtendedAssetInfo :AssetInfo { public Genders gender; - public List seasons; + public List seasons=new List(); public PartType type; public ExtendedAssetInfo() { - + this.seasons = new List(); } /// @@ -31,6 +31,7 @@ namespace CustomNPCFramework.Framework.Graphics { this.gender = Gender; this.seasons = Season; + if (this.seasons == null) this.seasons = new List(); this.type = Type; } diff --git a/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/AnimatedSpriteCollection.cs b/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/AnimatedSpriteCollection.cs index 7098da73..82ba48de 100644 --- a/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/AnimatedSpriteCollection.cs +++ b/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/AnimatedSpriteCollection.cs @@ -130,6 +130,9 @@ namespace CustomNPCFramework.Framework.ModularNPCS /// public 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("Position: "+position.ToString()); + Class1.ModMonitor.Log("Source Rec: "+sourceRectangle.ToString()); + Class1.ModMonitor.Log("Depth: "+layerDepth.ToString()); b.Draw(this.currentSprite.sprite.Texture,position,sourceRectangle, color* alpha, npc.rotation, 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)); } diff --git a/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/AnimatedSpriteExtended.cs b/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/AnimatedSpriteExtended.cs index 3a467e5f..430c36d8 100644 --- a/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/AnimatedSpriteExtended.cs +++ b/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/AnimatedSpriteExtended.cs @@ -32,10 +32,11 @@ namespace CustomNPCFramework.Framework.ModularNPCS /// Constructor. /// /// The texture for the sprite. + /// Path used for retaining texture location on disk. /// Starting animation frame. /// Sprite width. /// Sprite height - public AnimatedSpriteExtended(Texture2D texture, int currentFrame, int spriteWidth, int spriteHeight) + public AnimatedSpriteExtended(Texture2D texture,string path ,int currentFrame, int spriteWidth, int spriteHeight) { this.path = Class1.getRelativeDirectory(path); this.sprite = new AnimatedSprite(texture, currentFrame, spriteWidth, spriteHeight); diff --git a/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/ModularRenderers/BasicRenderer.cs b/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/ModularRenderers/BasicRenderer.cs index 1222ef84..4f648fa2 100644 --- a/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/ModularRenderers/BasicRenderer.cs +++ b/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/ModularRenderers/BasicRenderer.cs @@ -139,7 +139,7 @@ namespace CustomNPCFramework.Framework.ModularNPCS.ModularRenderers /// public virtual void draw(SpriteBatch b, ExtendedNPC extendedNPC, Vector2 vector21, Rectangle? v1, Color white, float rotation, Vector2 vector22, float v2, SpriteEffects spriteEffects, float v3) { - this.draw(b, extendedNPC, vector21, v1, white, rotation, vector22, v2, spriteEffects, v3); + this.draw(b, extendedNPC, vector21, new Rectangle(v1.Value.X,v1.Value.Y,v1.Value.Width,v1.Value.Height), white, rotation, vector22, v2, spriteEffects, v3); } } } diff --git a/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/Sprite.cs b/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/Sprite.cs index f2095393..76263465 100644 --- a/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/Sprite.cs +++ b/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/Sprite.cs @@ -20,8 +20,22 @@ namespace CustomNPCFramework.Framework.ModularNPCS /// The full path to the file. public Sprite(string path) { - this.relativePath = Class1.getRelativeDirectory(path); - this.sprite = new AnimatedSprite(Class1.ModHelper.Content.Load(this.relativePath)); + try + { + this.relativePath = Class1.getShortenedDirectory(path); + } + catch(Exception err) + { + this.relativePath = path; + } + try + { + this.sprite = new AnimatedSprite(Class1.ModHelper.Content.Load(this.relativePath)); + } + catch(Exception err) + { + this.sprite = new AnimatedSprite(Class1.ModHelper.Content.Load(this.relativePath+".png")); + } this.sprite.spriteWidth = this.sprite.Texture.Width; this.sprite.spriteHeight = this.sprite.Texture.Height; } diff --git a/GeneralMods/CustomNPCFramework/Framework/NPCNames.cs b/GeneralMods/CustomNPCFramework/Framework/NPCNames.cs index f849952c..38ddfdf2 100644 --- a/GeneralMods/CustomNPCFramework/Framework/NPCNames.cs +++ b/GeneralMods/CustomNPCFramework/Framework/NPCNames.cs @@ -10,6 +10,9 @@ namespace CustomNPCFramework.Framework { public class NPCNames { + /// + /// Holds all of the npc male names. + /// public static List maleNames = new List() { "Freddy", @@ -17,6 +20,9 @@ namespace CustomNPCFramework.Framework "Ash" }; + /// + /// Holds all of the npc female names. + /// public static List femaleNames = new List() { "Rebecca", @@ -24,6 +30,9 @@ namespace CustomNPCFramework.Framework "Lisa" }; + /// + /// Holds all of the npc gender non-binary names. + /// public static List otherGenderNames = new List() { "Jayden", @@ -31,6 +40,11 @@ namespace CustomNPCFramework.Framework "Skylar" }; + /// + /// Get a gender appropriate name from the pool of npc names. + /// + /// + /// public static string getRandomNPCName(Genders gender) { if (gender == Genders.female) { diff --git a/GeneralMods/CustomNPCFramework/Framework/NPCS/ExtendedNPC.cs b/GeneralMods/CustomNPCFramework/Framework/NPCS/ExtendedNPC.cs index 0e8e8ddd..4120eac9 100644 --- a/GeneralMods/CustomNPCFramework/Framework/NPCS/ExtendedNPC.cs +++ b/GeneralMods/CustomNPCFramework/Framework/NPCS/ExtendedNPC.cs @@ -69,7 +69,10 @@ namespace CustomNPCFramework.Framework.NPCS this.Portrait = (Texture2D)null; this.portraitInformation = null; this.spriteInformation = sprite; - this.spriteInformation.setCharacterSpriteFromThis(this); + if (this.spriteInformation != null) + { + this.spriteInformation.setCharacterSpriteFromThis(this); + } this.swimming = false; } @@ -416,6 +419,7 @@ namespace CustomNPCFramework.Framework.NPCS } else { + //FIX THIS LINE WITH LAYER DEPTH!!! 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), 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)); } //If the npc breathes then this code is ran. From 07757dac1fedcecd09a194a5ea8a6f8da23e088d Mon Sep 17 00:00:00 2001 From: Date: Sat, 17 Mar 2018 04:18:35 -0700 Subject: [PATCH 13/54] Discovered that the mod is now corectly rendering npcs. Issue: AnimatedSpriteCollection.draw functionality is inconsistent and needs to be fixed. --- .../Framework/ModularNPCS/AnimatedSpriteCollection.cs | 5 ++++- GeneralMods/CustomNPCFramework/Framework/NPCS/ExtendedNPC.cs | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/AnimatedSpriteCollection.cs b/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/AnimatedSpriteCollection.cs index 82ba48de..b980c717 100644 --- a/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/AnimatedSpriteCollection.cs +++ b/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/AnimatedSpriteCollection.cs @@ -133,7 +133,10 @@ namespace CustomNPCFramework.Framework.ModularNPCS Class1.ModMonitor.Log("Position: "+position.ToString()); Class1.ModMonitor.Log("Source Rec: "+sourceRectangle.ToString()); Class1.ModMonitor.Log("Depth: "+layerDepth.ToString()); - b.Draw(this.currentSprite.sprite.Texture,position,sourceRectangle, color* alpha, npc.rotation, origin,scale,effects,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,sourceRectangle, color* alpha, npc.rotation, 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)); } diff --git a/GeneralMods/CustomNPCFramework/Framework/NPCS/ExtendedNPC.cs b/GeneralMods/CustomNPCFramework/Framework/NPCS/ExtendedNPC.cs index 4120eac9..dc249bf2 100644 --- a/GeneralMods/CustomNPCFramework/Framework/NPCS/ExtendedNPC.cs +++ b/GeneralMods/CustomNPCFramework/Framework/NPCS/ExtendedNPC.cs @@ -420,6 +420,7 @@ namespace CustomNPCFramework.Framework.NPCS else { //FIX THIS LINE WITH LAYER DEPTH!!! + //Shadow??? 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), 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)); } //If the npc breathes then this code is ran. @@ -444,7 +445,9 @@ namespace CustomNPCFramework.Framework.NPCS sourceRect.Height /= 2; } float num = Math.Max(0.0f, (float)(Math.Ceiling(Math.Sin(Game1.currentGameTime.TotalGameTime.TotalMilliseconds / 600.0 + (double)this.DefaultPosition.X * 20.0)) / 4.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))); + //The actual character drawing to the screen? + //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); } //Checks if the npc is glowing. From f8517e37c362c2fc01bd3797a1806ecd9c482ba5 Mon Sep 17 00:00:00 2001 From: Date: Sat, 17 Mar 2018 04:39:46 -0700 Subject: [PATCH 14/54] Implemented code for custom npc merchants. Pretty simple actually and the result is very pleasing. --- GeneralMods/CustomNPCFramework/Class1.cs | 6 ++- .../CustomNPCFramework.csproj | 1 + .../Framework/NPCS/ExtendedNPC.cs | 10 ++++- .../Framework/NPCS/MerchantNPC.cs | 39 +++++++++++++++++++ 4 files changed, 53 insertions(+), 3 deletions(-) create mode 100644 GeneralMods/CustomNPCFramework/Framework/NPCS/MerchantNPC.cs diff --git a/GeneralMods/CustomNPCFramework/Class1.cs b/GeneralMods/CustomNPCFramework/Class1.cs index 83bccc2a..8407027f 100644 --- a/GeneralMods/CustomNPCFramework/Class1.cs +++ b/GeneralMods/CustomNPCFramework/Class1.cs @@ -108,7 +108,11 @@ namespace CustomNPCFramework private void SaveEvents_LoadChar(object sender, EventArgs e) { ExtendedNPC myNpc3 = assetPool.generateNPC(Genders.female, 0, 1); - npcTracker.addNewNPCToLocation(Game1.getLocationFromName("BusStop", false), myNpc3); + MerchantNPC merch = new MerchantNPC(new List() + { + new StardewValley.Object(475,999) + }, myNpc3); + npcTracker.addNewNPCToLocation(Game1.getLocationFromName("BusStop", false), merch); } public void initializeExamples() diff --git a/GeneralMods/CustomNPCFramework/CustomNPCFramework.csproj b/GeneralMods/CustomNPCFramework/CustomNPCFramework.csproj index 254d76b4..5562b56b 100644 --- a/GeneralMods/CustomNPCFramework/CustomNPCFramework.csproj +++ b/GeneralMods/CustomNPCFramework/CustomNPCFramework.csproj @@ -65,6 +65,7 @@ + diff --git a/GeneralMods/CustomNPCFramework/Framework/NPCS/ExtendedNPC.cs b/GeneralMods/CustomNPCFramework/Framework/NPCS/ExtendedNPC.cs index dc249bf2..9289d832 100644 --- a/GeneralMods/CustomNPCFramework/Framework/NPCS/ExtendedNPC.cs +++ b/GeneralMods/CustomNPCFramework/Framework/NPCS/ExtendedNPC.cs @@ -49,7 +49,10 @@ namespace CustomNPCFramework.Framework.NPCS this.Portrait = (Texture2D)null; this.portraitInformation = null; this.spriteInformation = sprite; - this.spriteInformation.setCharacterSpriteFromThis(this); + if (this.spriteInformation != null) + { + this.spriteInformation.setCharacterSpriteFromThis(this); + } this.swimming = false; } @@ -57,7 +60,10 @@ namespace CustomNPCFramework.Framework.NPCS { this.characterRenderer = null; this.portraitInformation = portrait; - this.portraitInformation.setCharacterPortraitFromThis(this); + if (this.portraitInformation != null) + { + this.portraitInformation.setCharacterPortraitFromThis(this); + } this.spriteInformation = sprite; this.spriteInformation.setCharacterSpriteFromThis(this); this.swimming = false; diff --git a/GeneralMods/CustomNPCFramework/Framework/NPCS/MerchantNPC.cs b/GeneralMods/CustomNPCFramework/Framework/NPCS/MerchantNPC.cs new file mode 100644 index 00000000..3570d378 --- /dev/null +++ b/GeneralMods/CustomNPCFramework/Framework/NPCS/MerchantNPC.cs @@ -0,0 +1,39 @@ +using CustomNPCFramework.Framework.ModularNPCS; +using CustomNPCFramework.Framework.ModularNPCS.ModularRenderers; +using Microsoft.Xna.Framework; +using StardewValley; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CustomNPCFramework.Framework.NPCS +{ + class MerchantNPC: ExtendedNPC + { + public List stock; + public MerchantNPC(List Stock, Sprite sprite, BasicRenderer renderer,Vector2 position,int facingDirection,string name): base(sprite,renderer,position,facingDirection,name) + { + this.stock = Stock; + } + + public MerchantNPC(List Stock, ExtendedNPC npcBase): base(npcBase.spriteInformation, npcBase.portraitInformation, npcBase.position, npcBase.facingDirection, npcBase.name) + { + this.stock = Stock; + } + + public override bool checkAction(StardewValley.Farmer who, GameLocation l) + { + if (Game1.activeClickableMenu == null) + { + Game1.activeClickableMenu = new StardewValley.Menus.ShopMenu(this.stock); + return true; + } + else + { + return base.checkAction(Game1.player, Game1.player.currentLocation); + } + } + } +} From 91620913298339e5dbdf493301769e7a83629e88 Mon Sep 17 00:00:00 2001 From: Date: Sat, 17 Mar 2018 21:49:22 -0700 Subject: [PATCH 15/54] Fixed drawing glitches with the custom npc renderer. Now just have to get individual assets and make a nice compilation. --- .../ModularNPCS/AnimatedSpriteCollection.cs | 8 ++----- .../StandardCharacterAnimation.cs | 17 ++++++++------ .../ModularRenderers/BasicRenderer.cs | 4 ++-- .../Framework/NPCS/ExtendedNPC.cs | 23 +++++++++++++++---- .../Framework/NPCS/MerchantNPC.cs | 3 ++- 5 files changed, 34 insertions(+), 21 deletions(-) diff --git a/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/AnimatedSpriteCollection.cs b/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/AnimatedSpriteCollection.cs index b980c717..e914c383 100644 --- a/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/AnimatedSpriteCollection.cs +++ b/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/AnimatedSpriteCollection.cs @@ -130,13 +130,9 @@ namespace CustomNPCFramework.Framework.ModularNPCS /// public 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("Position: "+position.ToString()); - Class1.ModMonitor.Log("Source Rec: "+sourceRectangle.ToString()); - Class1.ModMonitor.Log("Depth: "+layerDepth.ToString()); - //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,sourceRectangle, color* alpha, npc.rotation, origin,scale,effects,layerDepth); + //this.draw(b, position, layerDepth); + b.Draw(this.currentSprite.sprite.Texture,position,sourceRectangle, 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)); } diff --git a/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/CharacterAnimationBases/StandardCharacterAnimation.cs b/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/CharacterAnimationBases/StandardCharacterAnimation.cs index 54fb854a..4c237e7a 100644 --- a/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/CharacterAnimationBases/StandardCharacterAnimation.cs +++ b/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/CharacterAnimationBases/StandardCharacterAnimation.cs @@ -1,6 +1,7 @@ using CustomNPCFramework.Framework.NPCS; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using StardewValley; using System; using System.Collections.Generic; using System.Linq; @@ -178,15 +179,17 @@ namespace CustomNPCFramework.Framework.ModularNPCS.CharacterAnimationBases /// public override void draw(SpriteBatch b, ExtendedNPC npc, Vector2 position, Rectangle sourceRectangle, Color color, float alpha, Vector2 origin, float scale, SpriteEffects effects, float layerDepth) { - this.body.draw(b, npc, position, sourceRectangle, color, alpha, origin, scale, effects, layerDepth); - this.hair.draw(b, npc, position, sourceRectangle, color, alpha, origin, scale, effects, layerDepth); - this.eyes.draw(b, npc, position, sourceRectangle, color, alpha, origin, scale, effects, layerDepth); - this.shirt.draw(b, npc, position, sourceRectangle, color, alpha, origin, scale, effects, layerDepth); - this.pants.draw(b, npc, position, sourceRectangle, color, alpha, origin, scale, effects, layerDepth); - this.shoes.draw(b, npc, position, sourceRectangle, color, alpha, origin, scale, effects, layerDepth); + Class1.ModMonitor.Log(sourceRectangle.ToString()); + Vector2 generalOffset = new Vector2(0, 1*Game1.tileSize); + this.body.draw(b, npc, position-generalOffset, sourceRectangle, color, alpha, origin, scale, effects, layerDepth); + this.hair.draw(b, npc, position-generalOffset, sourceRectangle, color, alpha, origin, scale, effects, layerDepth); + this.eyes.draw(b, npc, position-generalOffset, sourceRectangle, color, alpha, origin, scale, effects, layerDepth); + this.shirt.draw(b, npc, position-generalOffset, sourceRectangle, color, alpha, origin, scale, effects, layerDepth); + this.pants.draw(b, npc, position-generalOffset, sourceRectangle, color, alpha, origin, scale, effects, layerDepth); + this.shoes.draw(b, npc, position-generalOffset, sourceRectangle, color, alpha, origin, scale, effects, layerDepth); foreach(var accessory in this.accessories) { - accessory.draw(b, npc, position, sourceRectangle, color, alpha, origin, scale, effects, layerDepth); + accessory.draw(b, npc, position-generalOffset, sourceRectangle, color, alpha, origin, scale, effects, layerDepth); } } diff --git a/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/ModularRenderers/BasicRenderer.cs b/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/ModularRenderers/BasicRenderer.cs index 4f648fa2..02a76460 100644 --- a/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/ModularRenderers/BasicRenderer.cs +++ b/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/ModularRenderers/BasicRenderer.cs @@ -137,9 +137,9 @@ namespace CustomNPCFramework.Framework.ModularNPCS.ModularRenderers /// /// /// - public virtual void draw(SpriteBatch b, ExtendedNPC extendedNPC, Vector2 vector21, Rectangle? v1, Color white, float rotation, Vector2 vector22, float v2, SpriteEffects spriteEffects, float v3) + public virtual void draw(SpriteBatch b, ExtendedNPC extendedNPC, Vector2 position, Rectangle? v1, Color white, float rotation, Vector2 origin, float v2, SpriteEffects spriteEffects, float v3) { - this.draw(b, extendedNPC, vector21, new Rectangle(v1.Value.X,v1.Value.Y,v1.Value.Width,v1.Value.Height), white, rotation, vector22, v2, spriteEffects, v3); + this.draw(b, extendedNPC, position, new Rectangle(0,0,16,32), white, rotation, origin, v2, spriteEffects, v3); } } } diff --git a/GeneralMods/CustomNPCFramework/Framework/NPCS/ExtendedNPC.cs b/GeneralMods/CustomNPCFramework/Framework/NPCS/ExtendedNPC.cs index 9289d832..e52a2d48 100644 --- a/GeneralMods/CustomNPCFramework/Framework/NPCS/ExtendedNPC.cs +++ b/GeneralMods/CustomNPCFramework/Framework/NPCS/ExtendedNPC.cs @@ -86,9 +86,15 @@ namespace CustomNPCFramework.Framework.NPCS { this.characterRenderer = renderer; this.portraitInformation = portrait; - this.portraitInformation.setCharacterPortraitFromThis(this); + if (this.portraitInformation != null) + { + this.portraitInformation.setCharacterPortraitFromThis(this); + } this.spriteInformation = sprite; - this.spriteInformation.setCharacterSpriteFromThis(this); + if (this.spriteInformation != null) + { + this.spriteInformation.setCharacterSpriteFromThis(this); + } this.swimming = false; } @@ -427,7 +433,7 @@ namespace CustomNPCFramework.Framework.NPCS { //FIX THIS LINE WITH LAYER DEPTH!!! //Shadow??? - 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), 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)); + //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), 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)); } //If the npc breathes then this code is ran. if (this.breather && this.shakeTimer <= 0 && (!this.swimming && this.sprite.CurrentFrame < 16) && !this.farmerPassesThrough) @@ -452,8 +458,9 @@ namespace CustomNPCFramework.Framework.NPCS } float num = Math.Max(0.0f, (float)(Math.Ceiling(Math.Sin(Game1.currentGameTime.TotalGameTime.TotalMilliseconds / 600.0 + (double)this.DefaultPosition.X * 20.0)) / 4.0)); //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) * (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, 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); + //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); } //Checks if the npc is glowing. @@ -468,11 +475,17 @@ 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 + /// + /// + /// public virtual void drawNonModularSprite(SpriteBatch b, float alpha = 1f) { if (this.sprite == null || this.isInvisible || !Utility.isOnScreen(this.position, 2 * Game1.tileSize)) return; + + //Swimming just has a height difference on the sprite. if (this.swimming) { b.Draw(this.Sprite.Texture, 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, this.drawOnTop ? 0.991f : (float)this.getStandingY() / 10000f)); diff --git a/GeneralMods/CustomNPCFramework/Framework/NPCS/MerchantNPC.cs b/GeneralMods/CustomNPCFramework/Framework/NPCS/MerchantNPC.cs index 3570d378..95f9ac3c 100644 --- a/GeneralMods/CustomNPCFramework/Framework/NPCS/MerchantNPC.cs +++ b/GeneralMods/CustomNPCFramework/Framework/NPCS/MerchantNPC.cs @@ -18,7 +18,8 @@ namespace CustomNPCFramework.Framework.NPCS this.stock = Stock; } - public MerchantNPC(List Stock, ExtendedNPC npcBase): base(npcBase.spriteInformation, 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; } From bd6e479b4fcc74d8e6248fe31c490ecc4da56cbe Mon Sep 17 00:00:00 2001 From: Date: Sun, 18 Mar 2018 01:48:01 -0700 Subject: [PATCH 16/54] Finished the basics of the npc renderer. I have included the base art assets for generating a female npc and polished off all of the code. Base goal achived. --- GeneralMods/CustomNPCFramework/Class1.cs | 7 +++- .../Framework/Graphics/AssetPool.cs | 2 +- .../StandardCharacterAnimation.cs | 20 +++++----- .../Bodies/FemaleBodyBase/FBodyBaseDown.png | Bin 0 -> 330 bytes .../Bodies/FemaleBodyBase/FBodyBaseLeft.png | Bin 0 -> 302 bytes .../FemaleBodyBase/FBodyBaseMovingDown.png | Bin 0 -> 569 bytes .../FemaleBodyBase/FBodyBaseMovingLeft.png | Bin 0 -> 540 bytes .../FemaleBodyBase/FBodyBaseMovingRight.png | Bin 0 -> 589 bytes .../FemaleBodyBase/FBodyBaseMovingUp.png | Bin 0 -> 520 bytes .../Bodies/FemaleBodyBase/FBodyBaseRight.png | Bin 0 -> 305 bytes .../Bodies/FemaleBodyBase/FBodyBaseUp.png | Bin 0 -> 330 bytes .../FemaleBodyBase/VanillaFemaleBodyBase.json | 37 ++++++++++++++++++ .../Bottoms/Female/GreyPants/DownFacing.png | Bin 0 -> 293 bytes .../Bottoms/Female/GreyPants/GreyPants.json | 37 ++++++++++++++++++ .../Bottoms/Female/GreyPants/LeftFacing.png | Bin 0 -> 269 bytes .../Bottoms/Female/GreyPants/RightFacing.png | Bin 0 -> 264 bytes .../Bottoms/Female/GreyPants/UpFacing.png | Bin 0 -> 289 bytes .../BrownEyes/BrownVanillaEyes.json | 37 ++++++++++++++++++ .../Eyes/VanillaEyes/BrownEyes/EyesDown.png | Bin 0 -> 273 bytes .../Eyes/VanillaEyes/BrownEyes/EyesLeft.png | Bin 0 -> 268 bytes .../Eyes/VanillaEyes/BrownEyes/EyesRight.png | Bin 0 -> 271 bytes .../Eyes/VanillaEyes/BrownEyes/EyesUp.png | Bin 0 -> 224 bytes .../Hair/VanillaPigtails/DownHairStyle.png | Bin 0 -> 314 bytes .../Hair/VanillaPigtails/LeftHairStyle.png | Bin 0 -> 312 bytes .../VanillaPigtails/PigtailsHairStyle.json | 37 ++++++++++++++++++ .../Hair/VanillaPigtails/RightHairStyle.png | Bin 0 -> 318 bytes .../Hair/VanillaPigtails/UpHairStyle.png | Bin 0 -> 282 bytes .../ModularNPCGraphics/Hair/notes.txt | 2 + .../Female/VanillaPinkShirt/DownFacing.png | Bin 0 -> 326 bytes .../Female/VanillaPinkShirt/LeftFacing.png | Bin 0 -> 305 bytes .../Female/VanillaPinkShirt/RightFacing.png | Bin 0 -> 299 bytes .../Female/VanillaPinkShirt/UpFacing.png | Bin 0 -> 306 bytes .../VanillaPinkShirt/VanillaPinkShirt.json | 37 ++++++++++++++++++ .../Shoes/VanillaBrownShoes/DownMoving.png | Bin 0 -> 341 bytes .../Shoes/VanillaBrownShoes/DownStanding.png | Bin 0 -> 297 bytes .../Shoes/VanillaBrownShoes/LeftMoving.png | Bin 0 -> 395 bytes .../Shoes/VanillaBrownShoes/LeftStanding.png | Bin 0 -> 273 bytes .../Shoes/VanillaBrownShoes/RightMoving.png | Bin 0 -> 388 bytes .../Shoes/VanillaBrownShoes/RightStanding.png | Bin 0 -> 276 bytes .../Shoes/VanillaBrownShoes/UpMoving.png | Bin 0 -> 390 bytes .../Shoes/VanillaBrownShoes/UpStanding.png | Bin 0 -> 288 bytes .../VanillaBrownShoes/VanillaBrownShoes.json | 37 ++++++++++++++++++ 42 files changed, 241 insertions(+), 12 deletions(-) create mode 100644 GeneralMods/CustomNPCFramework/ModularNPCGraphics/Bodies/FemaleBodyBase/FBodyBaseDown.png create mode 100644 GeneralMods/CustomNPCFramework/ModularNPCGraphics/Bodies/FemaleBodyBase/FBodyBaseLeft.png create mode 100644 GeneralMods/CustomNPCFramework/ModularNPCGraphics/Bodies/FemaleBodyBase/FBodyBaseMovingDown.png create mode 100644 GeneralMods/CustomNPCFramework/ModularNPCGraphics/Bodies/FemaleBodyBase/FBodyBaseMovingLeft.png create mode 100644 GeneralMods/CustomNPCFramework/ModularNPCGraphics/Bodies/FemaleBodyBase/FBodyBaseMovingRight.png create mode 100644 GeneralMods/CustomNPCFramework/ModularNPCGraphics/Bodies/FemaleBodyBase/FBodyBaseMovingUp.png create mode 100644 GeneralMods/CustomNPCFramework/ModularNPCGraphics/Bodies/FemaleBodyBase/FBodyBaseRight.png create mode 100644 GeneralMods/CustomNPCFramework/ModularNPCGraphics/Bodies/FemaleBodyBase/FBodyBaseUp.png create mode 100644 GeneralMods/CustomNPCFramework/ModularNPCGraphics/Bodies/FemaleBodyBase/VanillaFemaleBodyBase.json create mode 100644 GeneralMods/CustomNPCFramework/ModularNPCGraphics/Bottoms/Female/GreyPants/DownFacing.png create mode 100644 GeneralMods/CustomNPCFramework/ModularNPCGraphics/Bottoms/Female/GreyPants/GreyPants.json create mode 100644 GeneralMods/CustomNPCFramework/ModularNPCGraphics/Bottoms/Female/GreyPants/LeftFacing.png create mode 100644 GeneralMods/CustomNPCFramework/ModularNPCGraphics/Bottoms/Female/GreyPants/RightFacing.png create mode 100644 GeneralMods/CustomNPCFramework/ModularNPCGraphics/Bottoms/Female/GreyPants/UpFacing.png create mode 100644 GeneralMods/CustomNPCFramework/ModularNPCGraphics/Eyes/VanillaEyes/BrownEyes/BrownVanillaEyes.json create mode 100644 GeneralMods/CustomNPCFramework/ModularNPCGraphics/Eyes/VanillaEyes/BrownEyes/EyesDown.png create mode 100644 GeneralMods/CustomNPCFramework/ModularNPCGraphics/Eyes/VanillaEyes/BrownEyes/EyesLeft.png create mode 100644 GeneralMods/CustomNPCFramework/ModularNPCGraphics/Eyes/VanillaEyes/BrownEyes/EyesRight.png create mode 100644 GeneralMods/CustomNPCFramework/ModularNPCGraphics/Eyes/VanillaEyes/BrownEyes/EyesUp.png create mode 100644 GeneralMods/CustomNPCFramework/ModularNPCGraphics/Hair/VanillaPigtails/DownHairStyle.png create mode 100644 GeneralMods/CustomNPCFramework/ModularNPCGraphics/Hair/VanillaPigtails/LeftHairStyle.png create mode 100644 GeneralMods/CustomNPCFramework/ModularNPCGraphics/Hair/VanillaPigtails/PigtailsHairStyle.json create mode 100644 GeneralMods/CustomNPCFramework/ModularNPCGraphics/Hair/VanillaPigtails/RightHairStyle.png create mode 100644 GeneralMods/CustomNPCFramework/ModularNPCGraphics/Hair/VanillaPigtails/UpHairStyle.png create mode 100644 GeneralMods/CustomNPCFramework/ModularNPCGraphics/Hair/notes.txt create mode 100644 GeneralMods/CustomNPCFramework/ModularNPCGraphics/Shirts/Female/VanillaPinkShirt/DownFacing.png create mode 100644 GeneralMods/CustomNPCFramework/ModularNPCGraphics/Shirts/Female/VanillaPinkShirt/LeftFacing.png create mode 100644 GeneralMods/CustomNPCFramework/ModularNPCGraphics/Shirts/Female/VanillaPinkShirt/RightFacing.png create mode 100644 GeneralMods/CustomNPCFramework/ModularNPCGraphics/Shirts/Female/VanillaPinkShirt/UpFacing.png create mode 100644 GeneralMods/CustomNPCFramework/ModularNPCGraphics/Shirts/Female/VanillaPinkShirt/VanillaPinkShirt.json create mode 100644 GeneralMods/CustomNPCFramework/ModularNPCGraphics/Shoes/VanillaBrownShoes/DownMoving.png create mode 100644 GeneralMods/CustomNPCFramework/ModularNPCGraphics/Shoes/VanillaBrownShoes/DownStanding.png create mode 100644 GeneralMods/CustomNPCFramework/ModularNPCGraphics/Shoes/VanillaBrownShoes/LeftMoving.png create mode 100644 GeneralMods/CustomNPCFramework/ModularNPCGraphics/Shoes/VanillaBrownShoes/LeftStanding.png create mode 100644 GeneralMods/CustomNPCFramework/ModularNPCGraphics/Shoes/VanillaBrownShoes/RightMoving.png create mode 100644 GeneralMods/CustomNPCFramework/ModularNPCGraphics/Shoes/VanillaBrownShoes/RightStanding.png create mode 100644 GeneralMods/CustomNPCFramework/ModularNPCGraphics/Shoes/VanillaBrownShoes/UpMoving.png create mode 100644 GeneralMods/CustomNPCFramework/ModularNPCGraphics/Shoes/VanillaBrownShoes/UpStanding.png create mode 100644 GeneralMods/CustomNPCFramework/ModularNPCGraphics/Shoes/VanillaBrownShoes/VanillaBrownShoes.json diff --git a/GeneralMods/CustomNPCFramework/Class1.cs b/GeneralMods/CustomNPCFramework/Class1.cs index 8407027f..f1ef0889 100644 --- a/GeneralMods/CustomNPCFramework/Class1.cs +++ b/GeneralMods/CustomNPCFramework/Class1.cs @@ -36,6 +36,9 @@ namespace CustomNPCFramework /// /// Load in the assets and go go go. /// -Collect a bunch of assets together to test this thing. + /// + /// Fix modular npc breathing. + /// Find way to make sideways shirts render correctly. /// @@ -69,7 +72,7 @@ namespace CustomNPCFramework public void initializeAssetPool() { - string path = Path.Combine(ModHelper.DirectoryPath, "Content", "Graphics", "NPCS", "Characters", "RainMan"); + string path = Path.Combine(ModHelper.DirectoryPath, "Content", "Graphics", "NPCS"); assetPool.getAssetManager("testNPC").addPathCreateDirectory(new KeyValuePair("characters", path)); } @@ -117,7 +120,7 @@ namespace CustomNPCFramework public void initializeExamples() { - + return; string dirPath = Path.Combine(ModHelper.DirectoryPath, "Content", "Templates"); var aManager=assetPool.getAssetManager("testNPC"); aManager.addPathCreateDirectory(new KeyValuePair("templates", dirPath)); diff --git a/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetPool.cs b/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetPool.cs index 74eba33a..2b7a1e3a 100644 --- a/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetPool.cs +++ b/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetPool.cs @@ -280,7 +280,7 @@ namespace CustomNPCFramework.Framework.Graphics bodySheet = bodyList.ElementAt(bodyIndex); eyesSheet = eyesList.ElementAt(eyesIndex); hairSheet = hairList.ElementAt(hairIndex); - shirtSheet = eyesList.ElementAt(shirtIndex); + shirtSheet = shirtList.ElementAt(shirtIndex); pantsSheet = pantsList.ElementAt(pantsIndex); shoesSheet = shoesList.ElementAt(shoesIndex); diff --git a/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/CharacterAnimationBases/StandardCharacterAnimation.cs b/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/CharacterAnimationBases/StandardCharacterAnimation.cs index 4c237e7a..c94853f6 100644 --- a/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/CharacterAnimationBases/StandardCharacterAnimation.cs +++ b/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/CharacterAnimationBases/StandardCharacterAnimation.cs @@ -179,17 +179,19 @@ namespace CustomNPCFramework.Framework.ModularNPCS.CharacterAnimationBases /// 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); - this.body.draw(b, npc, position-generalOffset, sourceRectangle, color, alpha, origin, scale, effects, layerDepth); - this.hair.draw(b, npc, position-generalOffset, sourceRectangle, color, alpha, origin, scale, effects, layerDepth); - this.eyes.draw(b, npc, position-generalOffset, sourceRectangle, color, alpha, origin, scale, effects, layerDepth); - this.shirt.draw(b, npc, position-generalOffset, sourceRectangle, color, alpha, origin, scale, effects, layerDepth); - this.pants.draw(b, npc, position-generalOffset, sourceRectangle, color, alpha, origin, scale, effects, layerDepth); - this.shoes.draw(b, npc, position-generalOffset, sourceRectangle, color, alpha, origin, scale, effects, layerDepth); + //Class1.ModMonitor.Log(sourceRectangle.ToString()); + Vector2 generalOffset = new Vector2(0, 1*Game1.tileSize); //Puts the sprite at the correct positioning. + float smallOffset = 0.001f; + float tinyOffset = 0.0001f; + this.body.draw(b, npc, position-generalOffset, sourceRectangle, color, alpha, origin, scale, effects, layerDepth + smallOffset); + this.eyes.draw(b, npc, position - generalOffset, sourceRectangle, color, alpha, origin, scale, effects, layerDepth + smallOffset+(tinyOffset *1)); + this.hair.draw(b, npc, position-generalOffset, sourceRectangle, color, alpha, origin, scale, effects, layerDepth + smallOffset+(tinyOffset *2)); + this.shirt.draw(b, npc, position-generalOffset, sourceRectangle, color, alpha, origin, scale, effects, layerDepth + smallOffset+(tinyOffset*3)); + this.pants.draw(b, npc, position-generalOffset, sourceRectangle, color, alpha, origin, scale, effects, layerDepth + smallOffset+(tinyOffset*4)); + this.shoes.draw(b, npc, position-generalOffset, sourceRectangle, color, alpha, origin, scale, effects, layerDepth + smallOffset+(tinyOffset*5)); foreach(var accessory in this.accessories) { - accessory.draw(b, npc, position-generalOffset, sourceRectangle, color, alpha, origin, scale, effects, layerDepth); + accessory.draw(b, npc, position-generalOffset, sourceRectangle, color, alpha, origin, scale, effects, layerDepth +0.0006f); } } diff --git a/GeneralMods/CustomNPCFramework/ModularNPCGraphics/Bodies/FemaleBodyBase/FBodyBaseDown.png b/GeneralMods/CustomNPCFramework/ModularNPCGraphics/Bodies/FemaleBodyBase/FBodyBaseDown.png new file mode 100644 index 0000000000000000000000000000000000000000..3546c768fb3215b53fb8928b13e02b778e2d1d1a GIT binary patch literal 330 zcmeAS@N?(olHy`uVBq!ia0vp^0zj<5!3HFyJAa%3QY`6?zK#qG8~eHcB(eheoCO|{ z#S9F5hd`K7RKu$QC@5Lt8c`CQpH@;&qQ5P zy_{;JE-H7r^z-Ms+3iO@DSE8-DOZeVJh3b9teyVH@~@}98F!~jezJ>7Z&@$Ex3y2v`rd)x zZ^d{rVvWy#jXgb$U72BXsNjOqJJTbgxqjA5AE@ozS}N2ar^B>NZepsFg|ySZHB;hL XWLDX&dKvu?=p_bES3j3^P6OrF;_G7+#q;I9^VCq0ew`Zk)mr uhCTaOHdr-SY-e?lP(NHyHBo%U6!R5V-v19glN1efHiM_DpUXO@geCyQP;C(a literal 0 HcmV?d00001 diff --git a/GeneralMods/CustomNPCFramework/ModularNPCGraphics/Bodies/FemaleBodyBase/FBodyBaseMovingDown.png b/GeneralMods/CustomNPCFramework/ModularNPCGraphics/Bodies/FemaleBodyBase/FBodyBaseMovingDown.png new file mode 100644 index 0000000000000000000000000000000000000000..69a879ca89b1376b0cd2324721d6625f0a1dc4fc GIT binary patch literal 569 zcmV-90>=G`P)N2bZe?^J zG%heMGBNQWX_Wu~0k%m*K~z{r?UK=L!!Qg)Jy-YXS0?E)ovCZ|tH}vG<3f>=B_$~W z_yEF|c<)T6-AIvxm|T zD|dv2rg?&dvT6nOGI~Qy^8{&N2=5f;oe#npK0c#Tk72u(cx|9Kv=)a}ui-^{PoB#v zAFY#yWznM?rM-;BGvpQK zdsN!T)9_u|^8+Yv_Dbx->v`U%JR3Adr5-#Z9pPJAn&Fcyf%zgpfF>pjP3^mLG;PASH-i?O7bb(VZ*S1{&Du8*`28LAd00000NkvXX Hu0mjfB$xN0 literal 0 HcmV?d00001 diff --git a/GeneralMods/CustomNPCFramework/ModularNPCGraphics/Bodies/FemaleBodyBase/FBodyBaseMovingLeft.png b/GeneralMods/CustomNPCFramework/ModularNPCGraphics/Bodies/FemaleBodyBase/FBodyBaseMovingLeft.png new file mode 100644 index 0000000000000000000000000000000000000000..6cb4c6c64c60fd06349c125ac54a8936f02cff8b GIT binary patch literal 540 zcmV+%0^|LOP)N2bZe?^J zG%heMGBNQWX_Wu~0hvieK~z{r?UT`M!!Qg)Jy-YXS0?E)ovCZ|EA|fMRnWW?zZ|-Ox1u25AXNqN2{;f`=i1c)qo05RynO{Mm1msKdWx_ za=;3n{~!G+azEqC0Tte|TFg1@UkxY^u*=Jc zvQ5>1@&LPRMuu&w29yWb1wV>xmM;ga;PnF1m!JV>ZgC|K7HgP?(FSBgR`S?~d4dY@ zS@+#O)QFF;knI=d)yM!8h6#u4vV4Yxln?i&NdZ2e{Q#_*6=5Oxv@g~vPa{@^Pz;L> zVtHoFI0`=Y$@Fa?SAtmCJQ_saGBb`MuNfKsSAeZZh~@bl9bnWy$~VDms~?3_;o;@L zr-p|toDEPuI{;bDNcFd1HUM7MnE~MC?_U2y{n!@`gxJ(RH?yNEuOfpL9QXa$7aPEA z8){%PJF>ibBfLueUfxhNd$*;b{ne93&B)Gp)zO6<3Si$p#CP7AmGvka;UW4sJPPl^ eA93klv~54ogkEEIi7ycV0000N2bZe?^J zG%heMGBNQWX_Wu~0m?~4K~z{r?UPYX12GIldoJ$7S5LxaI1|_43p$bCYH-uUX(-~O zBU#w30{U|S@eS^N z0;)&zKLUJkuTcoRe7&660K0q>AsMa&j96-vvCAJKXc@d{G(;t1mv54hAg<%6B-p!} zU$n&od%#L_Nq%y;j-!&cc$qcyy$jG7_D^{k1+e*Qfb;jffDvEHAOOGv!ZMWeu)K`0 z+*IzDd7g*8FE{SIL4H?wXT3MiN;w$WTEAR}Whi)>abMxxOJC38ewamwiovIl$s6UI zuymFCdImh%!z_#f0j7}2dC!>fJw~N_=Vv+10PHmdL-0AL!r$txs`hX4Ag)&ew|;&>|foD;`$$?X3;D+|yRCg0;}=8ksxCK&_( zIXqL(pYt?O99=2%_^W&qA!Q(xxp>^MH4%1#^>4HAx00000NkvXXu0mjf!|n_p literal 0 HcmV?d00001 diff --git a/GeneralMods/CustomNPCFramework/ModularNPCGraphics/Bodies/FemaleBodyBase/FBodyBaseMovingUp.png b/GeneralMods/CustomNPCFramework/ModularNPCGraphics/Bodies/FemaleBodyBase/FBodyBaseMovingUp.png new file mode 100644 index 0000000000000000000000000000000000000000..cb1e74fdf5cb23b5b5f7ab8c42b3d57e8745fa51 GIT binary patch literal 520 zcmV+j0{8uiP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D02y>eSaefwW^{L9 za%BK;VQFr3E^cLXAT%y8E;2FkAZe8V00DSOL_t(oN9~Z&ZNxAPLo-+R>DNutWja&W z=vNyCV!$$TF0v07^bi6>Y)g-pGhMoLDc5a!`%%a7{}2ZLy1g&{{`^?J)ko;#t1Q&b zqgjWiE06Gu3JVSKgmrlONQhrfA01+pf7k=g;;#ps&94C-g8efF808l+gh5A#hn%I4 zW{mQyG^hm5@*%1jL%hQbD22?@oC-&E@d|PH>LZwu@ka*f=23L0;u5+IN-lo*%7SDU7x6qpc}tlzj%j`IEknwx-bIm+C&+ni}O_=K&s2d4N8+ zm)H9>FWTC2pc-&CKOQg(e~*7Kj=F^m=Ec#zGJyL>40P$WG)=$Ztrqf{@`jH90000< KMNUMnLSTY5+2y1F literal 0 HcmV?d00001 diff --git a/GeneralMods/CustomNPCFramework/ModularNPCGraphics/Bodies/FemaleBodyBase/FBodyBaseRight.png b/GeneralMods/CustomNPCFramework/ModularNPCGraphics/Bodies/FemaleBodyBase/FBodyBaseRight.png new file mode 100644 index 0000000000000000000000000000000000000000..ee594eddc40a5cc873836b42a808e3e233974fce GIT binary patch literal 305 zcmeAS@N?(olHy`uVBq!ia0vp^0zj<5!3HFyJAa%3QY`6?zK#qG8~eHcB(eheoCO|{ z#S9F52SJ!|$HeTnKtah8*NBqf{Irtt#G+J&g2c?c61}|C5(N`I13e?dj|!Pnfr{37 zx;Tb-c%Pkck+(^ar)B2p+L~YLg_7w-yz>pxf6Z(Yi0%s1-+95|{o)H%@1y?(%f7wh zemhXd^nTyx)8Ah|eJPT{Q@vavt0QM^@kNu_4t|Vjj&s;v>}~mR`HwGxlJ~W{8QBwp3G(Qczkw0!xS~=f(#^mS`P+Mf{_3sl0Z-olx1RfK7trMlp00i_>zopr02r8arvLx| literal 0 HcmV?d00001 diff --git a/GeneralMods/CustomNPCFramework/ModularNPCGraphics/Bodies/FemaleBodyBase/FBodyBaseUp.png b/GeneralMods/CustomNPCFramework/ModularNPCGraphics/Bodies/FemaleBodyBase/FBodyBaseUp.png new file mode 100644 index 0000000000000000000000000000000000000000..5adb7ca883de25f8f0e5780f27313c7d2ce68e7b GIT binary patch literal 330 zcmeAS@N?(olHy`uVBq!ia0vp^0zj<5!3HFyJAa%3QjEnx?oJHr&dIz4a#+$GeH|GX zHuiJ>Nn{1`ISV`@iy0XB4ude`@%$AjKtah8*NBqf{Irtt#G+J&g2c?c61}|C5(N`I z13e?dj|!Pnfr@r{x;Tb-c)y)+k@t`RkBhPR?+;f!Bid$0H0w|3o?o)-*d*o9KL10e!*X>FVdQ&MBb@0Mr_Mh5!Hn literal 0 HcmV?d00001 diff --git a/GeneralMods/CustomNPCFramework/ModularNPCGraphics/Bodies/FemaleBodyBase/VanillaFemaleBodyBase.json b/GeneralMods/CustomNPCFramework/ModularNPCGraphics/Bodies/FemaleBodyBase/VanillaFemaleBodyBase.json new file mode 100644 index 00000000..a3d9458a --- /dev/null +++ b/GeneralMods/CustomNPCFramework/ModularNPCGraphics/Bodies/FemaleBodyBase/VanillaFemaleBodyBase.json @@ -0,0 +1,37 @@ +{ + "gender": 1, + "seasons": [ + 0, + 1, + 2, + 3 + ], + "type": 0, + "assetName": "VanillaFemaleBodyBase", + "standingAssetPaths": { + "leftString": "FBodyBaseLeft", + "rightString": "FBodyBaseRight", + "upString": "FBodyBaseUp", + "downString": "FBodyBaseDown" + }, + "swimmingAssetPaths": { + "leftString": "FBodyBaseLeft", + "rightString": "FBodyBaseRight", + "upString": "FBodyBaseUp", + "downString": "FBodyBaseDown" + }, + "movingAssetPaths": { + "leftString": "FBodyBaseLeft", + "rightString": "FBodyBaseRight", + "upString": "FBodyBaseUp", + "downString": "FBodyBaseDown" + }, + "sittingAssetPaths": { + "leftString": "FBodyBaseLeft", + "rightString": "FBodyBaseRight", + "upString": "FBodyBaseUp", + "downString": "FBodyBaseDown" + }, + "assetSize": "16, 32", + "randomizeUponLoad": false +} \ No newline at end of file diff --git a/GeneralMods/CustomNPCFramework/ModularNPCGraphics/Bottoms/Female/GreyPants/DownFacing.png b/GeneralMods/CustomNPCFramework/ModularNPCGraphics/Bottoms/Female/GreyPants/DownFacing.png new file mode 100644 index 0000000000000000000000000000000000000000..9fe40916669338775bae5b8a35109552e45c4f92 GIT binary patch literal 293 zcmeAS@N?(olHy`uVBq!ia0vp^0zj<5!3HFyJAa%3QY`6?zK#qG8~eHcB(eheoCO|{ z#S9F5hd`K7RKu$QC@5Lt8c`CQpH@fZ%p+d?%bP0l+XkKJz{Ba literal 0 HcmV?d00001 diff --git a/GeneralMods/CustomNPCFramework/ModularNPCGraphics/Bottoms/Female/GreyPants/GreyPants.json b/GeneralMods/CustomNPCFramework/ModularNPCGraphics/Bottoms/Female/GreyPants/GreyPants.json new file mode 100644 index 00000000..6a35cd9c --- /dev/null +++ b/GeneralMods/CustomNPCFramework/ModularNPCGraphics/Bottoms/Female/GreyPants/GreyPants.json @@ -0,0 +1,37 @@ +{ + "gender": 1, + "seasons": [ + 0, + 1, + 2, + 3 + ], + "type": 4, + "assetName": "VanillaGreyPants", + "standingAssetPaths": { + "leftString": "LeftFacing", + "rightString": "RightFacing", + "upString": "UpFacing", + "downString": "DownFacing" + }, + "swimmingAssetPaths": { + "leftString": "LeftFacing", + "rightString": "RightFacing", + "upString": "UpFacing", + "downString": "DownFacing" + }, + "movingAssetPaths": { + "leftString": "LeftFacing", + "rightString": "RightFacing", + "upString": "UpFacing", + "downString": "DownFacing" + }, + "sittingAssetPaths": { + "leftString": "LeftFacing", + "rightString": "RightFacing", + "upString": "UpFacing", + "downString": "DownFacing" + }, + "assetSize": "16, 32", + "randomizeUponLoad": false +} \ No newline at end of file diff --git a/GeneralMods/CustomNPCFramework/ModularNPCGraphics/Bottoms/Female/GreyPants/LeftFacing.png b/GeneralMods/CustomNPCFramework/ModularNPCGraphics/Bottoms/Female/GreyPants/LeftFacing.png new file mode 100644 index 0000000000000000000000000000000000000000..26acdfbe46836272a1d7061a566867e23429acff GIT binary patch literal 269 zcmeAS@N?(olHy`uVBq!ia0vp^0zfR!!3HGXE%n_3q*&4&eH|GXHuiJ>Nn{1`ISV`@ ziy0XB4uLSEsD@VqP*AeOHKHUqKdq!Zu_%?HATcwqL@zJ3M8QPQK+nkVqeA9XprS5M z7sn6}@1^Gsa<&+Vusytz$~kSzJsrOfd)}_GscmmKmUwc-2U(fP^4>0cnl2v5NH8&w zlHl!Ob7NlIh>e?`pd1Bv3)9t rv-|J+-Qo9@d$tLQAQOMP-ego(-!60O%F!P{S21|H`njxgN@xNA&9q;o literal 0 HcmV?d00001 diff --git a/GeneralMods/CustomNPCFramework/ModularNPCGraphics/Bottoms/Female/GreyPants/RightFacing.png b/GeneralMods/CustomNPCFramework/ModularNPCGraphics/Bottoms/Female/GreyPants/RightFacing.png new file mode 100644 index 0000000000000000000000000000000000000000..cd418410c3cf206917a3f26c32a90b5ccfa5f89f GIT binary patch literal 264 zcmeAS@N?(olHy`uVBq!ia0vp^0zfR!!3HGXE%n_3q*&4&eH|GXHuiJ>Nn{1`ISV`@ ziy0XB4uLSEsD@VqP*AeOHKHUqKdq!Zu_%?HATcwqL@zJ3M8QPQK+nkVqeA9XprTe! z7sn6}@3rR)g&Yh790H%85|rsY_wdY$*!IY69ZGc%m5tY**nab(>k)Mc-X1nL=EaQ{ z4`d{m7)W8`K9)OYte-t0=vVQQnfcCq7axDgI%wecU#Fw?Gxw)JJ&*O`Pxk(6jS6`G mcIDq+_t>~WhW&^sVPBoTU1rMuFqqNS^Ae)^Q-UpX64l;!hHEm^p6?6t?Yl-d(Ki-@@u@*Km;rh zcwNAdQ{B9pRK y$XCDn8Z41io^`;yuXx4#Lrs?&K9wikWca~&Qzvmx+ESoP89ZJ6T-G@yGywoWeRJOc literal 0 HcmV?d00001 diff --git a/GeneralMods/CustomNPCFramework/ModularNPCGraphics/Eyes/VanillaEyes/BrownEyes/BrownVanillaEyes.json b/GeneralMods/CustomNPCFramework/ModularNPCGraphics/Eyes/VanillaEyes/BrownEyes/BrownVanillaEyes.json new file mode 100644 index 00000000..b0d36979 --- /dev/null +++ b/GeneralMods/CustomNPCFramework/ModularNPCGraphics/Eyes/VanillaEyes/BrownEyes/BrownVanillaEyes.json @@ -0,0 +1,37 @@ +{ + "gender": 1, + "seasons": [ + 0, + 1, + 2, + 3 + ], + "type": 1, + "assetName": "VanillaBrownEyes", + "standingAssetPaths": { + "leftString": "EyesLeft", + "rightString": "EyesRight", + "upString": "EyesUp", + "downString": "EyesDown" + }, + "swimmingAssetPaths": { + "leftString": "EyesLeft", + "rightString": "EyesRight", + "upString": "EyesUp", + "downString": "EyesDown" + }, + "movingAssetPaths": { + "leftString": "EyesLeft", + "rightString": "EyesRight", + "upString": "EyesUp", + "downString": "EyesDown" + }, + "sittingAssetPaths": { + "leftString": "EyesLeft", + "rightString": "EyesRight", + "upString": "EyesUp", + "downString": "EyesDown" + }, + "assetSize": "16, 32", + "randomizeUponLoad": false +} \ No newline at end of file diff --git a/GeneralMods/CustomNPCFramework/ModularNPCGraphics/Eyes/VanillaEyes/BrownEyes/EyesDown.png b/GeneralMods/CustomNPCFramework/ModularNPCGraphics/Eyes/VanillaEyes/BrownEyes/EyesDown.png new file mode 100644 index 0000000000000000000000000000000000000000..1bc72059ccc898d227fbddcf22b8881f84f4d452 GIT binary patch literal 273 zcmeAS@N?(olHy`uVBq!ia0vp^0zj<5!3HFyJAa%3QjEnx?oJHr&dIz4a#+$GeH|GX zHuiJ>Nn{1`ISV`@iy0XB4ude`@%$AjKtah8*NBqf{Irtt#G+J&g2c?c61}|C5(N`I z13e?dj|!Pnfr=VET^vI^yqBIi$k|{Zz~DIlk$UTm8B3RPX$Sj#vQXT?7|t&?NpYv9 zQeA6?lZoOi0pAWa7vV*m7q9pxMLx^ueRufe@#?i3*FODs;oRAxlLeog=NwOV+`OlJ m@()w6x)xMzsN9dWhOs>STYp>^U2_EJ7zR&QKbLh*2~7Y~DP6n( literal 0 HcmV?d00001 diff --git a/GeneralMods/CustomNPCFramework/ModularNPCGraphics/Eyes/VanillaEyes/BrownEyes/EyesLeft.png b/GeneralMods/CustomNPCFramework/ModularNPCGraphics/Eyes/VanillaEyes/BrownEyes/EyesLeft.png new file mode 100644 index 0000000000000000000000000000000000000000..1c619fd0cc1b99475395cf7049363b7b665aa7fd GIT binary patch literal 268 zcmeAS@N?(olHy`uVBq!ia0vp^0zj<5!3HFyJAa%3QjEnx?oJHr&dIz4a#+$GeH|GX zHuiJ>Nn{1`ISV`@iy0XB4ude`@%$AjKtah8*NBqf{Irtt#G+J&g2c?c61}|C5(N`I z13e?dj|!Pnfr@H8T^vI^yqBKY$l2f^z$tRo!^{mV*-8v5Hk@hK z75vEU#=N-k;(?3=69Xv;-kz0y$xHTqH&|9Gmz4kZE9bE-x~7k8-cA0_j;f3e2ltQO aDc0QgpH@Y`jPwDzgTd3)&t;ucLK6Ui)>$Nn{1`ISV`@iy0XB4ude`@%$AjKtah8*NBqf{Irtt#G+J&g2c?c61}|C5(N`I z13e?dj|!Pnfr{!qT^vI^yqBKd$k|{Z;BYZS$&B&3!1tmpJ`Yn)%@kpr8vkQsMZwQ< zPr;AeZp@1tFCNH9Ffovl;O!}|lv-T*oiF*i-MghntoXm4G?$P+r@T$|x?q_os!BE- d+&_AkSeMFwTIDF|`VQz622WQ%mvv4FO#lM4S?mA+ literal 0 HcmV?d00001 diff --git a/GeneralMods/CustomNPCFramework/ModularNPCGraphics/Eyes/VanillaEyes/BrownEyes/EyesUp.png b/GeneralMods/CustomNPCFramework/ModularNPCGraphics/Eyes/VanillaEyes/BrownEyes/EyesUp.png new file mode 100644 index 0000000000000000000000000000000000000000..ea240b0b3b1ca84bc9df89bc322126e9da94296b GIT binary patch literal 224 zcmeAS@N?(olHy`uVBq!ia0vp^0zj<5!3HFyJAa%3QjEnx?oJHr&dIz4a#+$GeH|GX zHuiJ>Nn{1`ISV`@iy0XB4ude`@%$AjKtah8*NBqf{Irtt#G+J&g2c?c61}|C5(N`I z13e?dj|!PnfrNn{1`ISV`@iy0XB4ude`@%$AjKtah8*NBqf{Irtt#G+J&g2c?c61}|C5(N`I z13e?dj|!Pnfr?gnx;Tb-c)y)^oA-zU4@+jZ(TcW98SQ?Pe2&}`JfQN^>g5p+v19#5 z3-8E3-g`evdu6popW(b|LAQ#|J^$&^vPj^N`-7<+ac&Ipy;;xph%OKitZ9i7eCl<2 z`Y%^0e!cmNWtM9On4j)AtztCCiS>s`-wM|@rr3gpNcRaBPhC9{qhvF8!46xMg)!DA zeB;v{Bdpc-)v20^D6aT_C$DnaZihormvpvA=+yNWTeBI8tn6CQ-2`+sgQu&X%Q~lo FCIG^jbK(F1 literal 0 HcmV?d00001 diff --git a/GeneralMods/CustomNPCFramework/ModularNPCGraphics/Hair/VanillaPigtails/LeftHairStyle.png b/GeneralMods/CustomNPCFramework/ModularNPCGraphics/Hair/VanillaPigtails/LeftHairStyle.png new file mode 100644 index 0000000000000000000000000000000000000000..0b29dcdb8ed6fb6e747da50ba6a184a21d825163 GIT binary patch literal 312 zcmeAS@N?(olHy`uVBq!ia0vp^0zj<5!3HFyJAa%3QjEnx?oJHr&dIz4a#+$GeH|GX zHuiJ>Nn{1`ISV`@iy0XB4ude`@%$AjKtah8*NBqf{Irtt#G+J&g2c?c61}|C5(N`I z13e?dj|!Pnfr?gmx;Tb-c)y)+n)k4RfXhmS&?TIFnoUeW>`O25O?~hp(t27l=Lt7U z*B+Bi-#;IF@ZoruVP5#{3?1F)bG8SaN_>@hLUPU4eYVRLd04hwE8Fdqkrn7|v9u&& zxilL`-JN&-XLdWBIcMOoVQaG!OF45u{sB&w^7RIj{2EGKrEAp~4y;e$6!2yKVyaz! zG5Ef$!`of|OBrwYdX>-g8H#IH96x|zY#)z4*}Q$iB} DAwF;x literal 0 HcmV?d00001 diff --git a/GeneralMods/CustomNPCFramework/ModularNPCGraphics/Hair/VanillaPigtails/PigtailsHairStyle.json b/GeneralMods/CustomNPCFramework/ModularNPCGraphics/Hair/VanillaPigtails/PigtailsHairStyle.json new file mode 100644 index 00000000..e2e93db3 --- /dev/null +++ b/GeneralMods/CustomNPCFramework/ModularNPCGraphics/Hair/VanillaPigtails/PigtailsHairStyle.json @@ -0,0 +1,37 @@ +{ + "gender": 1, + "seasons": [ + 0, + 1, + 2, + 3 + ], + "type": 2, + "assetName": "VanillaPigTails", + "standingAssetPaths": { + "leftString": "LeftHairStyle", + "rightString": "RightHairStyle", + "upString": "UpHairStyle", + "downString": "DownHairStyle" + }, + "swimmingAssetPaths": { + "leftString": "LeftHairStyle", + "rightString": "RightHairStyle", + "upString": "UpHairStyle", + "downString": "DownHairStyle" + }, + "movingAssetPaths": { + "leftString": "LeftHairStyle", + "rightString": "RightHairStyle", + "upString": "UpHairStyle", + "downString": "DownHairStyle" + }, + "sittingAssetPaths": { + "leftString": "LeftHairStyle", + "rightString": "RightHairStyle", + "upString": "UpHairStyle", + "downString": "DownHairStyle" + }, + "assetSize": "16, 32", + "randomizeUponLoad": false +} \ No newline at end of file diff --git a/GeneralMods/CustomNPCFramework/ModularNPCGraphics/Hair/VanillaPigtails/RightHairStyle.png b/GeneralMods/CustomNPCFramework/ModularNPCGraphics/Hair/VanillaPigtails/RightHairStyle.png new file mode 100644 index 0000000000000000000000000000000000000000..840e2a78617f49f8c61757775e1a68c033ce1446 GIT binary patch literal 318 zcmeAS@N?(olHy`uVBq!ia0vp^0zj<5!3HFyJAa%3QjEnx?oJHr&dIz4a#+$GeH|GX zHuiJ>Nn{1`ISV`@iy0XB4ude`@%$AjKtah8*NBqf{Irtt#G+J&g2c?c61}|C5(N`I z13e?dj|!Pnfr{37x;Tb-c)y)^koT~H0Lw~+&?TI5noUeW>`O25O?{BDDEhQQj>nQ3 zrLZW)`x_4@-kE=@djHmK*CKNI4D&RX-mUR(yj5^+XB6wEw_Dd8S~_KW=xZm9S5pKI z<-KyZm=N6HC(v>0aanzmV_U=H87ynxvg~BZa5Te$Nn{1`ISV`@iy0XB4ude`@%$AjKtah8*NBqf{Irtt#G+J&g2c?c61}|C5(N`I z13e?dj|!Pnfr`33T^vI^yx&f|&3Qn9$2Io!$vKBaV@{~vIa0Jl{8OOGl)9-g93LlE z3z__luza5R*zOyr^V-rr!?f(&wRZ((R=?Nge$p18;;fn4+Th;s_S_4p`EO=5d0Qnh zEHW3kz#9-QJ!dC_Rt>9z$ccorPZmo?HvDB3cSviQXnRmfR?)~t^zA#Rg#j;^mzFTb YeEqoBsq4@#psN@>UHx3vIVCg!0NW#D#sB~S literal 0 HcmV?d00001 diff --git a/GeneralMods/CustomNPCFramework/ModularNPCGraphics/Hair/notes.txt b/GeneralMods/CustomNPCFramework/ModularNPCGraphics/Hair/notes.txt new file mode 100644 index 00000000..bd8149c4 --- /dev/null +++ b/GeneralMods/CustomNPCFramework/ModularNPCGraphics/Hair/notes.txt @@ -0,0 +1,2 @@ +Hairstyles seem to allow for a maximum of three pixels from the adverage top of the hairstyle to the starting of a hairstyle. +This allows for things like volume and depth of view for ponytales that rise above the typical height of a head. \ No newline at end of file diff --git a/GeneralMods/CustomNPCFramework/ModularNPCGraphics/Shirts/Female/VanillaPinkShirt/DownFacing.png b/GeneralMods/CustomNPCFramework/ModularNPCGraphics/Shirts/Female/VanillaPinkShirt/DownFacing.png new file mode 100644 index 0000000000000000000000000000000000000000..78611891fea50de1ab780b8c7b08facc36f139fb GIT binary patch literal 326 zcmeAS@N?(olHy`uVBq!ia0vp^0zj<5!3HFyJAa%3QjEnx?oJHr&dIz4a#+$GeH|GX zHuiJ>Nn{1`ISV`@iy0XB4ude`@%$AjKtah8*NBqf{Irtt#G+J&g2c?c61}|C5(N`I z13e?dj|!Pnfr_?yx;Tb-crTrBkoS;*0E_NLf2oJwqEniu=eatJ$>` zE=wkEntZ!>l9*t9qUu4frl~C2oMA$1R3bb#OiDlq)E)V`r8Q&z>Rpv}948-dI{x~f zO@OE6{Ij2(J+>_P{!jN+UFN~u-Ez%Z*NW_BKX0G#L_6D4_3kD63+34pyOQR~I|X%r tEzz9?lzE{tHLEg{@hFB>r%D&?WfWvQRh0ekFVF)F44$rjF6*2UngE~4dRqVh literal 0 HcmV?d00001 diff --git a/GeneralMods/CustomNPCFramework/ModularNPCGraphics/Shirts/Female/VanillaPinkShirt/LeftFacing.png b/GeneralMods/CustomNPCFramework/ModularNPCGraphics/Shirts/Female/VanillaPinkShirt/LeftFacing.png new file mode 100644 index 0000000000000000000000000000000000000000..c6a4245955cb6e7475e6ba3189880006f23e07cd GIT binary patch literal 305 zcmeAS@N?(olHy`uVBq!ia0vp^0zj<5!3HFyJAa%3QY`6?zK#qG8~eHcB(eheoCO|{ z#S9F52SJ!|$HeTnKtah8*NBqf{Irtt#G+J&g2c?c61}|C5(N`I13e?dj|!Pnfr{37 zx;Tb-crQJFkn@m(Kg(>#zh694Uom#VwJ4is(J{-P8c%xW9ie-{_2TDuth?4Y#=a;C zyIwr+zRZ*ROea6jcHSPh=>0y2dj0d$6r|4O+iiL9LBAlO1P$KNZ!^Eoy`w_>bGSdy O zKNkPLa!B41Iq}lLy-v4%YX$qPz843c%dco)UCM|GpZ>q{h2eVlj*9Fh{TG04X7F_N Kb6Mw<&;$T%rF-iD literal 0 HcmV?d00001 diff --git a/GeneralMods/CustomNPCFramework/ModularNPCGraphics/Shirts/Female/VanillaPinkShirt/UpFacing.png b/GeneralMods/CustomNPCFramework/ModularNPCGraphics/Shirts/Female/VanillaPinkShirt/UpFacing.png new file mode 100644 index 0000000000000000000000000000000000000000..d9442401e3492e0346ecd68f7a5a87ede5a7234a GIT binary patch literal 306 zcmeAS@N?(olHy`uVBq!ia0vp^0zj<5!3HFyJAa%3QY`6?zK#qG8~eHcB(eheoCO|{ z#S9F5hd`K7RKu$QC@5Lt8c`CQpH@aF738wB3(bdO6&F#641sZoQv==slide1=2j2ETW$6Bx5TJSyVG({M@*7;^qoKVS$08UNdhX2xxQWh?!o;+ofGE70-es_ M>FVdQ&MBb@0Mo&6LjV8( literal 0 HcmV?d00001 diff --git a/GeneralMods/CustomNPCFramework/ModularNPCGraphics/Shirts/Female/VanillaPinkShirt/VanillaPinkShirt.json b/GeneralMods/CustomNPCFramework/ModularNPCGraphics/Shirts/Female/VanillaPinkShirt/VanillaPinkShirt.json new file mode 100644 index 00000000..aa071d1a --- /dev/null +++ b/GeneralMods/CustomNPCFramework/ModularNPCGraphics/Shirts/Female/VanillaPinkShirt/VanillaPinkShirt.json @@ -0,0 +1,37 @@ +{ + "gender": 1, + "seasons": [ + 0, + 1, + 2, + 3 + ], + "type": 3, + "assetName": "VanillaPinkShirt", + "standingAssetPaths": { + "leftString": "LeftFacing", + "rightString": "RightFacing", + "upString": "UpFacing", + "downString": "DownFacing" + }, + "swimmingAssetPaths": { + "leftString": "LeftFacing", + "rightString": "RightFacing", + "upString": "UpFacing", + "downString": "DownFacing" + }, + "movingAssetPaths": { + "leftString": "LeftFacing", + "rightString": "RightFacing", + "upString": "UpFacing", + "downString": "DownFacing" + }, + "sittingAssetPaths": { + "leftString": "LeftFacing", + "rightString": "RightFacing", + "upString": "UpFacing", + "downString": "DownFacing" + }, + "assetSize": "16, 32", + "randomizeUponLoad": false +} \ No newline at end of file diff --git a/GeneralMods/CustomNPCFramework/ModularNPCGraphics/Shoes/VanillaBrownShoes/DownMoving.png b/GeneralMods/CustomNPCFramework/ModularNPCGraphics/Shoes/VanillaBrownShoes/DownMoving.png new file mode 100644 index 0000000000000000000000000000000000000000..d331912bb2c8adcc4e4a2af2221bf4fffce85729 GIT binary patch literal 341 zcmeAS@N?(olHy`uVBq!ia0vp^20*O9!3HEluKbn(QjEnx?oJHr&dIz4a#+$GeH|GX zHuiJ>Nn{1`ISV`@iy0XB4ude`@%$AjKtah8*NBqf{Irtt#G+J&g2c?c61}|C5(N`I z13e?dj|!Pnfr^fLx;TbJxL@trD0s+$hb6O7go(*RqiKecM$4)dA2%K_`<|xEWV3qa z-05Mv?r*tvWr0cKB^EDX4PTNOF7`a7H|6f14Y;cRyvlg;6W^=$pZ*%i-95j%%z94T z!$rS}zBq1j+b3W5Lm^W6K5yxV9q)EOUiIqq)pftlsANCcZ#P3?bMaF>W6yg%8+R6M mKjZu4ti){X^7%fuZ5ShFoN={1YbXx%5QC?ypUXO@geCwLnt?t5 literal 0 HcmV?d00001 diff --git a/GeneralMods/CustomNPCFramework/ModularNPCGraphics/Shoes/VanillaBrownShoes/DownStanding.png b/GeneralMods/CustomNPCFramework/ModularNPCGraphics/Shoes/VanillaBrownShoes/DownStanding.png new file mode 100644 index 0000000000000000000000000000000000000000..b9a1ee71890f8552b92a6e90da568abc5491adc3 GIT binary patch literal 297 zcmeAS@N?(olHy`uVBq!ia0vp^0zj<5!3HFyJAa%3QjEnx?oJHr&dIz4a#+$GeH|GX zHuiJ>Nn{1`ISV`@iy0XB4ude`@%$AjKtah8*NBqf{Irtt#G+J&g2c?c61}|C5(N`I z13e?dj|!Pnfr@5&x;Tb-cyB$kQLxEDge@^j;cA0}aJRxX4z7(_*)^ZIxt7msGItpI~AjCBfUn=El6Z@#29D!rZrsamn>jW}i>}`#dM#__EA3@9n1-E_?V# zrti(=fBzly?yNultSIbT=FjPW>z=)CoL>5E@3;TkX1Nn{1`ISV`@iy0XB4ude`@%$AjKtah8*NBqf{Irtt#G+J&g2c?c61}|C5(N`I z13e?dj|!Pnfr@^6x;TbJxL=*PoA;1|2uo(82osZsM$-%>jh0m_K7P2h{o3IkRqH!b z+s;?quYGVKs+%oUNMo|YOqNqB0cwp#oKrj(_%IPGboumz>rb!A9e@2LRrS@2yL&4q zDn>v1?vlOt{qkqF;ftA9e5sswym6i3E6Lmk+;3*yFY+vX#X4<%b#52mgQmd1FQ;U7 z?wX*#AvI3+_kQOoFJ{*D-1_>e zUht|QyuQ2aZ!zQYZ-3V83Vh=+_o!)2htI8t+!Ygl-~D@W#SvgIFnGH9xvXNn{1`ISV`@iy0XB4ude`@%$AjKtah8*NBqf{Irtt#G+J&g2c?c61}|C5(N`I z13e?dj|!Pnfr=VET^vI^yx(5f$l2f^z;H1CU6HE-GBzSw++?W?PUObS2joVv)Z`Q_FNs_N-+`jk!*`FU(3;x($tN3)t w%JlcApAPanP8~mYd^_KiV7V*ob~C1!wd;M1Uvpo7G0-s#p00i_>zopr01SX(1poj5 literal 0 HcmV?d00001 diff --git a/GeneralMods/CustomNPCFramework/ModularNPCGraphics/Shoes/VanillaBrownShoes/RightMoving.png b/GeneralMods/CustomNPCFramework/ModularNPCGraphics/Shoes/VanillaBrownShoes/RightMoving.png new file mode 100644 index 0000000000000000000000000000000000000000..96164528c765ee7be553f04489a232d64c202d3a GIT binary patch literal 388 zcmeAS@N?(olHy`uVBq!ia0vp^20*O9!3HEluKbn(QjEnx?oJHr&dIz4a#+$GeH|GX zHuiJ>Nn{1`ISV`@iy0XB4ude`@%$AjKtah8*NBqf{Irtt#G+J&g2c?c61}|C5(N`I z13e?dj|!Pnfr`F(x;TbJxL@tx$a}~^fF-k0go(*RqiKecM$4)dA1_AjfAL37dim~4 zC%*l;`}gOCsBX4YA&tonGg(fl1gJF{aZd4E;KM|$(Co_CytlRXTaSPIwY;d_#Jl)w z-1HB!cG0JA*mv{qEvfy^8ol!H^+lEQpI5H>%)jIOm!LB@?74N{F3h@At{=PPT3_k6 zS=k}R{~Gqp+xvF<+JBL+gtR_gni{vOk u{^qLc;^J5Q8e7+0n-sh(j{oEm*?k>*e&6MF*vbR+KZB>MpUXO@geCyuM4yBJ literal 0 HcmV?d00001 diff --git a/GeneralMods/CustomNPCFramework/ModularNPCGraphics/Shoes/VanillaBrownShoes/RightStanding.png b/GeneralMods/CustomNPCFramework/ModularNPCGraphics/Shoes/VanillaBrownShoes/RightStanding.png new file mode 100644 index 0000000000000000000000000000000000000000..1a2729838db5e0d69cebf2f38e46eb601d3955d2 GIT binary patch literal 276 zcmeAS@N?(olHy`uVBq!ia0vp^0zj<5!3HFyJAa%3QjEnx?oJHr&dIz4a#+$GeH|GX zHuiJ>Nn{1`ISV`@iy0XB4ude`@%$AjKtah8*NBqf{Irtt#G+J&g2c?c61}|C5(N`I z13e?dj|!Pnfr?r@T^vI^yx(5f$k|{Z;BawG!s^ymGrq*P0(_4`&Q%BnaC{21Z<^Z3 z{_AAyL=nOD2_^ww0O<&I*bcNn{1`ISV`@iy0XB4ude`@%$AjKtah8*NBqf{Irtt#G+J&g2c?c61}|C5(N`I z13e?dj|!Pnfr`F)x;TbJxL=**&3DK^z`2-p+lB;2X}*KAoC^f}j!HVq_9lwlS@vl2 zhNbEg!_zM@EWMW1JH^lAWeeHFADicA7sh=*{yb$(VL+Mp$=El!MO-m)|8*^%)ZM&# zJM%W*o9ltIdvEohFF5@7&H=`S-f{*~P0#;q^N4fLHLIP!<`-+k5$@-Td%J%{-#D6D znfOQ5LOtv7hVy&pm|N{NIM^G@oo8Pf^X9sD;`G1y`VC)< d<29c$vOBqL+V8S^H82DiJYD@<);T3K0RX@$pw$2X literal 0 HcmV?d00001 diff --git a/GeneralMods/CustomNPCFramework/ModularNPCGraphics/Shoes/VanillaBrownShoes/UpStanding.png b/GeneralMods/CustomNPCFramework/ModularNPCGraphics/Shoes/VanillaBrownShoes/UpStanding.png new file mode 100644 index 0000000000000000000000000000000000000000..07f1463dc0a3b50733806f0ba6fe950374ae839b GIT binary patch literal 288 zcmeAS@N?(olHy`uVBq!ia0vp^0zj<5!3HFyJAa%3QjEnx?oJHr&dIz4a#+$GeH|GX zHuiJ>Nn{1`ISV`@iy0XB4ude`@%$AjKtah8*NBqf{Irtt#G+J&g2c?c61}|C5(N`I z13e?dj|!Pnfr=)0x;Tb-c%MDDk+<1FfZ Date: Sun, 18 Mar 2018 03:20:06 -0700 Subject: [PATCH 17/54] Fixed modular npc breathing. --- GeneralMods/CustomNPCFramework/Class1.cs | 5 +- .../CustomNPCFramework.csproj | 1 + .../Framework/Graphics/AssetPool.cs | 26 +++--- .../StandardCharacterAnimation.cs | 42 ++++++---- .../StandardColorCollection.cs | 79 +++++++++++++++++++ .../ModularRenderers/BasicRenderer.cs | 6 +- .../Framework/NPCS/ExtendedNPC.cs | 8 +- 7 files changed, 136 insertions(+), 31 deletions(-) create mode 100644 GeneralMods/CustomNPCFramework/Framework/ModularNPCS/ColorCollections/StandardColorCollection.cs diff --git a/GeneralMods/CustomNPCFramework/Class1.cs b/GeneralMods/CustomNPCFramework/Class1.cs index f1ef0889..46756808 100644 --- a/GeneralMods/CustomNPCFramework/Class1.cs +++ b/GeneralMods/CustomNPCFramework/Class1.cs @@ -2,6 +2,7 @@ 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; @@ -37,8 +38,8 @@ namespace CustomNPCFramework /// Load in the assets and go go go. /// -Collect a bunch of assets together to test this thing. /// - /// Fix modular npc breathing. /// Find way to make sideways shirts render correctly. + /// @@ -110,7 +111,7 @@ namespace CustomNPCFramework /// private void SaveEvents_LoadChar(object sender, EventArgs e) { - ExtendedNPC myNpc3 = assetPool.generateNPC(Genders.female, 0, 1); + 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) diff --git a/GeneralMods/CustomNPCFramework/CustomNPCFramework.csproj b/GeneralMods/CustomNPCFramework/CustomNPCFramework.csproj index 5562b56b..493eaf25 100644 --- a/GeneralMods/CustomNPCFramework/CustomNPCFramework.csproj +++ b/GeneralMods/CustomNPCFramework/CustomNPCFramework.csproj @@ -59,6 +59,7 @@ + diff --git a/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetPool.cs b/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetPool.cs index 2b7a1e3a..bbac2c21 100644 --- a/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetPool.cs +++ b/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetPool.cs @@ -2,6 +2,7 @@ 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; @@ -121,7 +122,7 @@ namespace CustomNPCFramework.Framework.Graphics return getAnimatedSpriteCollectionFromAssets(pair.leftString, pair.rightString, pair.upString, pair.downString); } - public StandardCharacterAnimation GetStandardCharacterAnimation(NamePairings BodySprites, NamePairings EyeSprites, NamePairings HairSprites, NamePairings ShirtsSprites, NamePairings PantsSprites, NamePairings ShoesSprites,List AccessoriesSprites) + 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); @@ -134,7 +135,8 @@ namespace CustomNPCFramework.Framework.Graphics { accessories.Add(getAnimatedSpriteCollectionFromAssets(v)); } - return new StandardCharacterAnimation(body,eyes,hair,shirts,pants,shoes,accessories); + if (DrawColors == null) DrawColors = new StandardColorCollection(); + return new StandardCharacterAnimation(body,eyes,hair,shirts,pants,shoes,accessories,DrawColors); } public List getListOfApplicableBodyParts(string assetManagerName,Genders gender, Seasons season, PartType type) @@ -150,7 +152,7 @@ namespace CustomNPCFramework.Framework.Graphics /// /// /// - public ExtendedNPC generateNPC(Genders gender, int minNumOfAccessories, int maxNumOfAccessories) + public ExtendedNPC generateNPC(Genders gender, int minNumOfAccessories, int maxNumOfAccessories, StandardColorCollection DrawColors=null) { Seasons myseason=Seasons.spring; @@ -291,27 +293,28 @@ namespace CustomNPCFramework.Framework.Graphics { accessorySheet.Add(accessoryList.ElementAt(v)); } - - var render = generateBasicRenderer(bodySheet, eyesSheet, hairSheet, shirtSheet, pantsSheet, shoesSheet, accessorySheet); + 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(13, 15) * Game1.tileSize, 2, NPCNames.getRandomNPCName(gender)); return npc; } - public virtual BasicRenderer generateBasicRenderer(AssetSheet bodySheet, AssetSheet eyesSheet, AssetSheet hairSheet, AssetSheet shirtSheet, AssetSheet pantsSheet, AssetSheet shoesSheet, List accessorySheet) + 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); + 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); + 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); + var swimmingAnimation = generateCharacterAnimation(bodySheet, eyesSheet, hairSheet, shirtSheet, pantsSheet, shoesSheet, accessorySheet, type,DrawColors); BasicRenderer render = new BasicRenderer(standingAnimation, movingAnimation, swimmingAnimation); return render; } - public virtual StandardCharacterAnimation generateCharacterAnimation(AssetSheet body, AssetSheet eyes, AssetSheet hair, AssetSheet shirt, AssetSheet pants, AssetSheet shoes,List accessories, AnimationType animationType) + public virtual StandardCharacterAnimation generateCharacterAnimation(AssetSheet body, AssetSheet eyes, AssetSheet hair, AssetSheet shirt, AssetSheet pants, AssetSheet shoes,List accessories, AnimationType animationType, StandardColorCollection DrawColors=null) { var bodySprite = getSpriteCollectionFromSheet(body, animationType); var eyesSprite = getSpriteCollectionFromSheet(eyes, animationType); @@ -325,7 +328,8 @@ namespace CustomNPCFramework.Framework.Graphics AnimatedSpriteCollection acc = getSpriteCollectionFromSheet(v, AnimationType.standing); accessoryCollection.Add(acc); } - StandardCharacterAnimation standingAnimation = new StandardCharacterAnimation(bodySprite, eyesSprite, hairSprite, shirtSprite, pantsSprite, shoesSprite, accessoryCollection); + if (DrawColors == null) DrawColors = new StandardColorCollection(); + StandardCharacterAnimation standingAnimation = new StandardCharacterAnimation(bodySprite, eyesSprite, hairSprite, shirtSprite, pantsSprite, shoesSprite, accessoryCollection,DrawColors); return standingAnimation; } diff --git a/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/CharacterAnimationBases/StandardCharacterAnimation.cs b/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/CharacterAnimationBases/StandardCharacterAnimation.cs index c94853f6..1504f3b8 100644 --- a/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/CharacterAnimationBases/StandardCharacterAnimation.cs +++ b/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/CharacterAnimationBases/StandardCharacterAnimation.cs @@ -1,4 +1,5 @@ -using CustomNPCFramework.Framework.NPCS; +using CustomNPCFramework.Framework.ModularNPCS.ColorCollections; +using CustomNPCFramework.Framework.NPCS; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using StardewValley; @@ -18,9 +19,10 @@ namespace CustomNPCFramework.Framework.ModularNPCS.CharacterAnimationBases public AnimatedSpriteCollection shirt; public AnimatedSpriteCollection pants; public AnimatedSpriteCollection shoes; + public StandardColorCollection drawColors; public List accessories; - public StandardCharacterAnimation(AnimatedSpriteCollection bodyAnimation, AnimatedSpriteCollection eyeAnimation, AnimatedSpriteCollection hairAnimation, AnimatedSpriteCollection shirtAnimation, AnimatedSpriteCollection pantsAnimation, AnimatedSpriteCollection shoesAnimation,List accessoriesWithAnimations) :base() + public StandardCharacterAnimation(AnimatedSpriteCollection bodyAnimation, AnimatedSpriteCollection eyeAnimation, AnimatedSpriteCollection hairAnimation, AnimatedSpriteCollection shirtAnimation, AnimatedSpriteCollection pantsAnimation, AnimatedSpriteCollection shoesAnimation,List accessoriesWithAnimations, StandardColorCollection DrawColors) :base() { this.body = bodyAnimation; this.hair = hairAnimation; @@ -29,6 +31,7 @@ namespace CustomNPCFramework.Framework.ModularNPCS.CharacterAnimationBases this.pants = pantsAnimation; this.shoes = shoesAnimation; this.accessories = accessoriesWithAnimations; + this.drawColors = DrawColors; } public override void setLeft() @@ -152,12 +155,12 @@ namespace CustomNPCFramework.Framework.ModularNPCS.CharacterAnimationBases 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, c, flip, scale, rotation, characterSourceRectOffset); - this.hair.draw(b, screenPosition, layerDepth, xOffset, yOffset, c, flip, scale, rotation, characterSourceRectOffset); - this.eyes.draw(b, screenPosition, layerDepth, xOffset, yOffset, c, flip, scale, rotation, characterSourceRectOffset); - this.shirt.draw(b, screenPosition, layerDepth, xOffset, yOffset, c, flip, scale, rotation, characterSourceRectOffset); - this.pants.draw(b, screenPosition, layerDepth, xOffset, yOffset, c, flip, scale, rotation, characterSourceRectOffset); - this.shoes.draw(b, screenPosition, layerDepth, xOffset, yOffset, c, 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) { accessory.draw(b, screenPosition, layerDepth, xOffset, yOffset, c, flip, scale, rotation, characterSourceRectOffset); @@ -183,12 +186,23 @@ namespace CustomNPCFramework.Framework.ModularNPCS.CharacterAnimationBases Vector2 generalOffset = new Vector2(0, 1*Game1.tileSize); //Puts the sprite at the correct positioning. float smallOffset = 0.001f; float tinyOffset = 0.0001f; - this.body.draw(b, npc, position-generalOffset, sourceRectangle, color, alpha, origin, scale, effects, layerDepth + smallOffset); - this.eyes.draw(b, npc, position - generalOffset, sourceRectangle, color, alpha, origin, scale, effects, layerDepth + smallOffset+(tinyOffset *1)); - this.hair.draw(b, npc, position-generalOffset, sourceRectangle, color, alpha, origin, scale, effects, layerDepth + smallOffset+(tinyOffset *2)); - this.shirt.draw(b, npc, position-generalOffset, sourceRectangle, color, alpha, origin, scale, effects, layerDepth + smallOffset+(tinyOffset*3)); - this.pants.draw(b, npc, position-generalOffset, sourceRectangle, color, alpha, origin, scale, effects, layerDepth + smallOffset+(tinyOffset*4)); - this.shoes.draw(b, npc, position-generalOffset, sourceRectangle, color, alpha, origin, scale, effects, layerDepth + smallOffset+(tinyOffset*5)); + //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)); + + 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)); + } + 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); diff --git a/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/ColorCollections/StandardColorCollection.cs b/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/ColorCollections/StandardColorCollection.cs new file mode 100644 index 00000000..52d6a073 --- /dev/null +++ b/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/ColorCollections/StandardColorCollection.cs @@ -0,0 +1,79 @@ +using Microsoft.Xna.Framework; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CustomNPCFramework.Framework.ModularNPCS.ColorCollections +{ + /// + /// Collection of colors to be used for the StandardCharacterAnimation object. + /// + public class StandardColorCollection + { + public Color bodyColor; + public Color eyeColor; + public Color hairColor; + public Color shirtColor; + public Color bottomsColor; + public Color shoesColor; + + /// + /// Default constrctor that sets all of the draw colors to white. + /// + public StandardColorCollection() + { + defaultColor(this.bodyColor); + defaultColor(this.eyeColor); + defaultColor(this.hairColor); + defaultColor(this.shirtColor); + defaultColor(this.bottomsColor); + 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) + { + 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); + + defaultColor(this.bodyColor); + defaultColor(this.eyeColor); + defaultColor(this.hairColor); + defaultColor(this.shirtColor); + defaultColor(this.bottomsColor); + defaultColor(this.shoesColor); + } + + /// + /// If a color is null, make it white. + /// + /// + public void defaultColor(Color color) + { + if (color == null) color = Color.White; + } + + public static Color colorMult(Color cBase, Color cMult) + { + Vector3 color1 = cBase.ToVector3(); + Vector3 color2 = cMult.ToVector3(); + Vector3 mixColor = color1 * color2; + Color value = new Color(mixColor); + return value; + } + } +} diff --git a/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/ModularRenderers/BasicRenderer.cs b/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/ModularRenderers/BasicRenderer.cs index 02a76460..d266ec1b 100644 --- a/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/ModularRenderers/BasicRenderer.cs +++ b/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/ModularRenderers/BasicRenderer.cs @@ -2,6 +2,7 @@ using CustomNPCFramework.Framework.NPCS; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using StardewValley; using System; using System.Collections.Generic; using System.Linq; @@ -114,6 +115,7 @@ namespace CustomNPCFramework.Framework.ModularNPCS.ModularRenderers /// 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); } @@ -137,9 +139,9 @@ namespace CustomNPCFramework.Framework.ModularNPCS.ModularRenderers /// /// /// - public virtual void draw(SpriteBatch b, ExtendedNPC extendedNPC, Vector2 position, Rectangle? v1, Color white, float rotation, Vector2 origin, float v2, SpriteEffects spriteEffects, float v3) + 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, v2, 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/NPCS/ExtendedNPC.cs b/GeneralMods/CustomNPCFramework/Framework/NPCS/ExtendedNPC.cs index e52a2d48..45e1a42a 100644 --- a/GeneralMods/CustomNPCFramework/Framework/NPCS/ExtendedNPC.cs +++ b/GeneralMods/CustomNPCFramework/Framework/NPCS/ExtendedNPC.cs @@ -456,12 +456,16 @@ namespace CustomNPCFramework.Framework.NPCS vector2.Y -= (float)Game1.pixelZoom; sourceRect.Height /= 2; } - float num = Math.Max(0.0f, (float)(Math.Ceiling(Math.Sin(Game1.currentGameTime.TotalGameTime.TotalMilliseconds / 600.0 + (double)this.DefaultPosition.X * 20.0)) / 4.0)); //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) * (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) + (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); } + else + { + //float num = Math.Max(0.0f, (float)(Math.Ceiling(Math.Sin(Game1.currentGameTime.TotalGameTime.TotalMilliseconds / 600.0 + (double)this.DefaultPosition.X * 20.0)) / 4.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?(new Microsoft.Xna.Framework.Rectangle()), 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))); + } //Checks if the npc is glowing. if (this.isGlowing) From 9834bbcf28ca2db1f429f2df6ae3f15061cb0a9f Mon Sep 17 00:00:00 2001 From: Date: Sun, 18 Mar 2018 16:06:49 -0700 Subject: [PATCH 18/54] Fixed npc movment, npcs now correctly animate when moving, need to fix graphics for it though. --- GeneralMods/CustomNPCFramework/Class1.cs | 8 +- .../Framework/Graphics/AssetPool.cs | 5 +- .../ModularNPCS/AnimatedSpriteCollection.cs | 45 +++++++- .../CharacterAnimationBase.cs | 6 + .../StandardCharacterAnimation.cs | 17 +-- .../ModularRenderers/BasicRenderer.cs | 10 +- .../Framework/ModularNPCS/Sprite.cs | 55 ++++++++- .../Framework/NPCS/ExtendedNPC.cs | 104 ++++++++++++++++-- .../Framework/Utilities/NPCTracker.cs | 11 ++ .../FemaleBodyBase/VanillaFemaleBodyBase.json | 8 +- 10 files changed, 238 insertions(+), 31 deletions(-) diff --git a/GeneralMods/CustomNPCFramework/Class1.cs b/GeneralMods/CustomNPCFramework/Class1.cs index 46756808..906b9be0 100644 --- a/GeneralMods/CustomNPCFramework/Class1.cs +++ b/GeneralMods/CustomNPCFramework/Class1.cs @@ -92,7 +92,11 @@ namespace CustomNPCFramework if (Game1.player.currentLocation == null) return; foreach (var v in Game1.player.currentLocation.characters) { - v.speed = 5; + v.speed = 1; + if(v is ExtendedNPC) + { + (v as ExtendedNPC).SetMovingAndMove(Game1.currentGameTime, Game1.viewport, Game1.player.currentLocation, Direction.right, true); + } //v.MovePosition(Game1.currentGameTime, Game1.viewport, Game1.player.currentLocation); //ModMonitor.Log(v.sprite.spriteHeight.ToString()); } @@ -116,7 +120,7 @@ namespace CustomNPCFramework { new StardewValley.Object(475,999) }, myNpc3); - npcTracker.addNewNPCToLocation(Game1.getLocationFromName("BusStop", false), merch); + npcTracker.addNewNPCToLocation(Game1.getLocationFromName("BusStop", false), merch,new Vector2(2,23)); } public void initializeExamples() diff --git a/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetPool.cs b/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetPool.cs index bbac2c21..01a75a73 100644 --- a/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetPool.cs +++ b/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetPool.cs @@ -5,6 +5,7 @@ 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; @@ -152,7 +153,7 @@ namespace CustomNPCFramework.Framework.Graphics /// /// /// - public ExtendedNPC generateNPC(Genders gender, int minNumOfAccessories, int maxNumOfAccessories, StandardColorCollection DrawColors=null) + public ExtendedNPC generateNPC(Genders gender, int minNumOfAccessories, int maxNumOfAccessories ,StandardColorCollection DrawColors=null) { Seasons myseason=Seasons.spring; @@ -295,7 +296,7 @@ namespace CustomNPCFramework.Framework.Graphics } 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(13, 15) * Game1.tileSize, 2, NPCNames.getRandomNPCName(gender)); + ExtendedNPC npc = new ExtendedNPC(new Sprite(getDefaultSpriteImage(bodySheet)), render, new Microsoft.Xna.Framework.Vector2(0,0) * Game1.tileSize, 2, NPCNames.getRandomNPCName(gender)); return npc; } diff --git a/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/AnimatedSpriteCollection.cs b/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/AnimatedSpriteCollection.cs index e914c383..0b31d26c 100644 --- a/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/AnimatedSpriteCollection.cs +++ b/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/AnimatedSpriteCollection.cs @@ -132,7 +132,7 @@ namespace CustomNPCFramework.Framework.ModularNPCS { //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,sourceRectangle, 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)); } @@ -141,17 +141,54 @@ namespace CustomNPCFramework.Framework.ModularNPCS /// Animate the current sprite. Theoreticlly works from index offset to how many frames /// /// - public void Animate(float intervalFromCharacter) + public void Animate(float intervalFromCharacter,bool loop=true) { - this.currentSprite.sprite.Animate(Game1.currentGameTime, 0,3, intervalFromCharacter); + //ANIMATE AND UPDATE SOURCE RECTANGLE NOT WORKING!!!! FIGURE THIS OUT!!!! + //Class1.ModMonitor.Log("Current sprite frame:"+this.currentSprite.sprite.currentFrame.ToString()); + //Class1.ModMonitor.Log("Am I ignoring something??: " + this.currentSprite.sprite.ignoreSourceRectUpdates); + //Class1.ModMonitor.Log("Current Sprite Source Rect:" + this.currentSprite.sprite.sourceRect); + //Class1.ModMonitor.Log("Sprite width: " + this.currentSprite.sprite.spriteWidth); + //Class1.ModMonitor.Log("Sprite width: " + this.currentSprite.sprite.spriteHeight); + this.Animate(Game1.currentGameTime, 0,2, intervalFromCharacter,this.currentSprite.sprite,loop); + } + + 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; + sprite.timer = sprite.timer + (float)gameTime.ElapsedGameTime.TotalMilliseconds; + if ((double)sprite.timer > (double)interval) + { + sprite.CurrentFrame = sprite.CurrentFrame + 1; + sprite.timer = 0.0f; + if (sprite.CurrentFrame == startFrame + numberOfFrames + 1 || sprite.currentFrame * sprite.spriteWidth >= sprite.Texture.Width) + { + if (loop) + sprite.CurrentFrame = startFrame; + sprite.UpdateSourceRect(); + return true; + } + } + this.UpdateSourceRect(sprite); + return false; + } + + public virtual void UpdateSourceRect(AnimatedSprite sprite) + { + if (sprite.ignoreSourceRectUpdates) + return; + sprite.sourceRect.X = sprite.CurrentFrame * sprite.spriteWidth; + sprite.sourceRect.Y = 0; + //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) + 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/CharacterAnimationBases/CharacterAnimationBase.cs b/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/CharacterAnimationBases/CharacterAnimationBase.cs index f68f8edb..47a59d45 100644 --- a/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/CharacterAnimationBases/CharacterAnimationBase.cs +++ b/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/CharacterAnimationBases/CharacterAnimationBase.cs @@ -41,6 +41,12 @@ namespace CustomNPCFramework.Framework.ModularNPCS } + + public virtual void Animate(float animationInterval, bool loop=true) + { + + } + /// /// Used to draw the sprite to the screen. /// diff --git a/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/CharacterAnimationBases/StandardCharacterAnimation.cs b/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/CharacterAnimationBases/StandardCharacterAnimation.cs index 1504f3b8..d23aa91b 100644 --- a/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/CharacterAnimationBases/StandardCharacterAnimation.cs +++ b/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/CharacterAnimationBases/StandardCharacterAnimation.cs @@ -101,17 +101,17 @@ namespace CustomNPCFramework.Framework.ModularNPCS.CharacterAnimationBases this.shoes.reload(); } - public override void Animate(float animationInterval) + public override void Animate(float animationInterval,bool loop=true) { - this.body.Animate(animationInterval); - this.hair.Animate(animationInterval); - this.eyes.Animate(animationInterval); - this.shirt.Animate(animationInterval); - this.pants.Animate(animationInterval); - this.shoes.Animate(animationInterval); + 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); + accessory.Animate(animationInterval,loop); } } @@ -184,6 +184,7 @@ namespace CustomNPCFramework.Framework.ModularNPCS.CharacterAnimationBases { //Class1.ModMonitor.Log(sourceRectangle.ToString()); 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()); diff --git a/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/ModularRenderers/BasicRenderer.cs b/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/ModularRenderers/BasicRenderer.cs index d266ec1b..7e69f930 100644 --- a/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/ModularRenderers/BasicRenderer.cs +++ b/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/ModularRenderers/BasicRenderer.cs @@ -32,7 +32,11 @@ namespace CustomNPCFramework.Framework.ModularNPCS.ModularRenderers public virtual void setAnimation(string key) { this.currentAnimation = animationList[key]; - if (this.currentAnimation == null) this.setAnimation(AnimationKeys.standingKey); + if (this.currentAnimation == null) + { + Class1.ModMonitor.Log("ERROR SETTING AN ANIMATION: "+key); + this.setAnimation(AnimationKeys.standingKey); + } } public virtual void setDirection(int facingDirection) @@ -120,9 +124,9 @@ namespace CustomNPCFramework.Framework.ModularNPCS.ModularRenderers } - public virtual void Animate(float interval) + public virtual void Animate(float interval, bool loop=true) { - this.currentAnimation.Animate(interval); + this.currentAnimation.Animate(interval,loop); } diff --git a/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/Sprite.cs b/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/Sprite.cs index 76263465..a076ca1f 100644 --- a/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/Sprite.cs +++ b/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/Sprite.cs @@ -1,4 +1,5 @@ -using CustomNPCFramework.Framework.NPCS; +using CustomNPCFramework.Framework.ModularNPCS.ModularRenderers; +using CustomNPCFramework.Framework.NPCS; using Microsoft.Xna.Framework.Graphics; using StardewValley; using System; @@ -69,5 +70,57 @@ namespace CustomNPCFramework.Framework.ModularNPCS { this.sprite.Texture = Class1.ModHelper.Content.Load(this.relativePath); } + + /// + /// 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(); + } + + /// + /// 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(); + } + + /// + /// 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(); + } + + /// + /// 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(); + } } } diff --git a/GeneralMods/CustomNPCFramework/Framework/NPCS/ExtendedNPC.cs b/GeneralMods/CustomNPCFramework/Framework/NPCS/ExtendedNPC.cs index 45e1a42a..498f4b6b 100644 --- a/GeneralMods/CustomNPCFramework/Framework/NPCS/ExtendedNPC.cs +++ b/GeneralMods/CustomNPCFramework/Framework/NPCS/ExtendedNPC.cs @@ -1,4 +1,5 @@ -using CustomNPCFramework.Framework.ModularNPCS; +using CustomNPCFramework.Framework.Enums; +using CustomNPCFramework.Framework.ModularNPCS; using CustomNPCFramework.Framework.ModularNPCS.ModularRenderers; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -158,8 +159,75 @@ namespace CustomNPCFramework.Framework.NPCS //ERROR NEED FIXING public override void MovePosition(GameTime time, xTile.Dimensions.Rectangle viewport, GameLocation currentLocation) { - base.MovePosition(time,viewport,currentLocation); + if (this.characterRenderer != null) + { + ModularMovement(time,viewport,currentLocation); + } + else + { + NonModularMovement(time,viewport,currentLocation); + } return; + + } + + /// + /// 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) + { + 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); + this.MovePosition(time, viewport, currentLocation); + } + + public virtual void NonModularMovement(GameTime time, xTile.Dimensions.Rectangle viewport, GameLocation location) + { + base.MovePosition(time, viewport, currentLocation); + return; + } + + public virtual bool canMovePastNextLocation(xTile.Dimensions.Rectangle viewport) + { + //Up + if (!currentLocation.isTilePassable(this.nextPosition(0), viewport) || !this.willDestroyObjectsUnderfoot) + { + return false; + } + //Right + if (!currentLocation.isTilePassable(this.nextPosition(1), viewport) || !this.willDestroyObjectsUnderfoot) + { + return false; + } + //Down + if (!currentLocation.isTilePassable(this.nextPosition(2), viewport) || !this.willDestroyObjectsUnderfoot) + { + return false; + } + //Left + if (!currentLocation.isTilePassable(this.nextPosition(3), viewport) || !this.willDestroyObjectsUnderfoot) + { + return false; + } + return true; + } + + public virtual void ModularMovement(GameTime time, xTile.Dimensions.Rectangle viewport, GameLocation location, float interval = 1000f) + { + interval /= 2; + this.characterRenderer.setAnimation(AnimationKeys.walkingKey); + if (this.canMovePastNextLocation(viewport) == false) + { + this.Halt(); + return; + } if (this.GetType() == typeof(FarmAnimal)) this.willDestroyObjectsUnderfoot = false; if ((double)this.xVelocity != 0.0 || (double)this.yVelocity != 0.0) @@ -182,7 +250,9 @@ namespace CustomNPCFramework.Framework.NPCS this.position.Y -= (float)(this.speed + this.addedSpeed); if (!this.ignoreMovementAnimation) { - this.sprite.AnimateUp(time, (this.speed - 2 + this.addedSpeed) * -25, Utility.isOnScreen(this.getTileLocationPoint(), 1, currentLocation) ? "Cowboy_Footstep" : ""); + this.spriteInformation.setUp(this); + this.characterRenderer.Animate(interval,true); + //this.sprite.AnimateUp(time, (this.speed - 2 + this.addedSpeed) * -25, Utility.isOnScreen(this.getTileLocationPoint(), 1, currentLocation) ? "Cowboy_Footstep" : ""); this.faceDirection(0); } } @@ -207,7 +277,10 @@ namespace CustomNPCFramework.Framework.NPCS this.position.X += (float)(this.speed + this.addedSpeed); if (!this.ignoreMovementAnimation) { - this.sprite.AnimateRight(time, (this.speed - 2 + this.addedSpeed) * -25, Utility.isOnScreen(this.getTileLocationPoint(), 1, currentLocation) ? "Cowboy_Footstep" : ""); + this.spriteInformation.setRight(this); + this.characterRenderer.Animate(interval,true); + //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); } } @@ -232,7 +305,10 @@ namespace CustomNPCFramework.Framework.NPCS this.position.Y += (float)(this.speed + this.addedSpeed); if (!this.ignoreMovementAnimation) { - this.sprite.AnimateDown(time, (this.speed - 2 + this.addedSpeed) * -25, Utility.isOnScreen(this.getTileLocationPoint(), 1, currentLocation) ? "Cowboy_Footstep" : ""); + this.spriteInformation.setDown(this); + this.characterRenderer.Animate(interval,true); + //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); } } @@ -257,7 +333,10 @@ namespace CustomNPCFramework.Framework.NPCS this.position.X -= (float)(this.speed + this.addedSpeed); if (!this.ignoreMovementAnimation) { - this.sprite.AnimateLeft(time, (this.speed - 2 + this.addedSpeed) * -25, Utility.isOnScreen(this.getTileLocationPoint(), 1, currentLocation) ? "Cowboy_Footstep" : ""); + this.spriteInformation.setLeft(this); + this.characterRenderer.Animate(interval,true); + //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); } } @@ -290,6 +369,12 @@ namespace CustomNPCFramework.Framework.NPCS } } + public override void Halt() + { + this.characterRenderer.setAnimation(AnimationKeys.standingKey); + base.Halt(); + } + public override void update(GameTime time, GameLocation location) { base.update(time, location); @@ -425,7 +510,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, this.drawOnTop ? 0.991f : (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)); } @@ -530,6 +615,11 @@ 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. + /// + /// + /// public override void draw(SpriteBatch b, float alpha = 1f) { if (this.characterRenderer == null) diff --git a/GeneralMods/CustomNPCFramework/Framework/Utilities/NPCTracker.cs b/GeneralMods/CustomNPCFramework/Framework/Utilities/NPCTracker.cs index a3aea34c..5c80adf9 100644 --- a/GeneralMods/CustomNPCFramework/Framework/Utilities/NPCTracker.cs +++ b/GeneralMods/CustomNPCFramework/Framework/Utilities/NPCTracker.cs @@ -1,4 +1,5 @@ using CustomNPCFramework.Framework.NPCS; +using Microsoft.Xna.Framework; using StardewValley; using System; using System.Collections.Generic; @@ -32,6 +33,16 @@ namespace CustomNPCFramework.Framework.Utilities { this.moddedNPCS.Add(npc); npc.defaultLocation = loc; + npc.currentLocation = loc; + loc.addCharacter(npc); + } + + public void addNewNPCToLocation(GameLocation loc, ExtendedNPC npc, Vector2 tilePosition) + { + this.moddedNPCS.Add(npc); + npc.defaultLocation = loc; + npc.currentLocation = loc; + npc.position = tilePosition*Game1.tileSize; loc.addCharacter(npc); } diff --git a/GeneralMods/CustomNPCFramework/ModularNPCGraphics/Bodies/FemaleBodyBase/VanillaFemaleBodyBase.json b/GeneralMods/CustomNPCFramework/ModularNPCGraphics/Bodies/FemaleBodyBase/VanillaFemaleBodyBase.json index a3d9458a..56fc7d20 100644 --- a/GeneralMods/CustomNPCFramework/ModularNPCGraphics/Bodies/FemaleBodyBase/VanillaFemaleBodyBase.json +++ b/GeneralMods/CustomNPCFramework/ModularNPCGraphics/Bodies/FemaleBodyBase/VanillaFemaleBodyBase.json @@ -21,10 +21,10 @@ "downString": "FBodyBaseDown" }, "movingAssetPaths": { - "leftString": "FBodyBaseLeft", - "rightString": "FBodyBaseRight", - "upString": "FBodyBaseUp", - "downString": "FBodyBaseDown" + "leftString": "FBodyBaseMovingLeft", + "rightString": "FBodyBaseMovingRight", + "upString": "FBodyBaseMovingUp", + "downString": "FBodyBaseMovingDown" }, "sittingAssetPaths": { "leftString": "FBodyBaseLeft", From fabef6ba82b03f0036ec1d1c61443a81fe692c3a Mon Sep 17 00:00:00 2001 From: Date: Sun, 18 Mar 2018 19:06:08 -0700 Subject: [PATCH 19/54] Started the great comment update. --- GeneralMods/CustomNPCFramework/Class1.cs | 1 + .../Framework/Enums/AnimationType.cs | 15 ++++++++ .../Framework/Enums/Direction.cs | 20 ++++++++++ .../Framework/Enums/Genders.cs | 10 +++++ .../Framework/Enums/PartType.cs | 37 ++++++++++++++++++- .../Framework/Enums/Seasons.cs | 20 ++++++++++ .../Graphics/TextureGroups/TextureGroup.cs | 30 +++++++++++++++ 7 files changed, 132 insertions(+), 1 deletion(-) diff --git a/GeneralMods/CustomNPCFramework/Class1.cs b/GeneralMods/CustomNPCFramework/Class1.cs index 906b9be0..c1755c9f 100644 --- a/GeneralMods/CustomNPCFramework/Class1.cs +++ b/GeneralMods/CustomNPCFramework/Class1.cs @@ -90,6 +90,7 @@ namespace CustomNPCFramework private void GameEvents_UpdateTick(object sender, EventArgs e) { if (Game1.player.currentLocation == null) return; + if (Game1.activeClickableMenu != null) return; foreach (var v in Game1.player.currentLocation.characters) { v.speed = 1; diff --git a/GeneralMods/CustomNPCFramework/Framework/Enums/AnimationType.cs b/GeneralMods/CustomNPCFramework/Framework/Enums/AnimationType.cs index 1440f1a4..15fa24b8 100644 --- a/GeneralMods/CustomNPCFramework/Framework/Enums/AnimationType.cs +++ b/GeneralMods/CustomNPCFramework/Framework/Enums/AnimationType.cs @@ -6,11 +6,26 @@ using System.Threading.Tasks; namespace CustomNPCFramework.Framework.Enums { + /// + /// 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. + /// standing, + /// + /// 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. + /// swimming, + /// + /// 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 bf31c6bc..e894f068 100644 --- a/GeneralMods/CustomNPCFramework/Framework/Enums/Direction.cs +++ b/GeneralMods/CustomNPCFramework/Framework/Enums/Direction.cs @@ -6,11 +6,31 @@ 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 + /// 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 } } diff --git a/GeneralMods/CustomNPCFramework/Framework/Enums/Genders.cs b/GeneralMods/CustomNPCFramework/Framework/Enums/Genders.cs index acd8d46e..b1299af0 100644 --- a/GeneralMods/CustomNPCFramework/Framework/Enums/Genders.cs +++ b/GeneralMods/CustomNPCFramework/Framework/Enums/Genders.cs @@ -7,12 +7,22 @@ using System.Threading.Tasks; 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. /// 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 } } diff --git a/GeneralMods/CustomNPCFramework/Framework/Enums/PartType.cs b/GeneralMods/CustomNPCFramework/Framework/Enums/PartType.cs index 5f20d719..aab5d3b7 100644 --- a/GeneralMods/CustomNPCFramework/Framework/Enums/PartType.cs +++ b/GeneralMods/CustomNPCFramework/Framework/Enums/PartType.cs @@ -6,15 +6,50 @@ using System.Threading.Tasks; namespace CustomNPCFramework.Framework.Enums { + /// + /// 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. + /// body, + /// + /// 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. + /// hair, + /// + /// 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. + /// pants, + /// + /// 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. + /// accessory, - other + /// + /// 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. + /// + 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. + /// + arms } } diff --git a/GeneralMods/CustomNPCFramework/Framework/Enums/Seasons.cs b/GeneralMods/CustomNPCFramework/Framework/Enums/Seasons.cs index 97404edd..e8e6cd7f 100644 --- a/GeneralMods/CustomNPCFramework/Framework/Enums/Seasons.cs +++ b/GeneralMods/CustomNPCFramework/Framework/Enums/Seasons.cs @@ -4,13 +4,33 @@ 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. + /// 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. + /// 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. + /// 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. + /// 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. + /// winter } } diff --git a/GeneralMods/CustomNPCFramework/Framework/Graphics/TextureGroups/TextureGroup.cs b/GeneralMods/CustomNPCFramework/Framework/Graphics/TextureGroups/TextureGroup.cs index b46103cf..b1da295a 100644 --- a/GeneralMods/CustomNPCFramework/Framework/Graphics/TextureGroups/TextureGroup.cs +++ b/GeneralMods/CustomNPCFramework/Framework/Graphics/TextureGroups/TextureGroup.cs @@ -8,18 +8,48 @@ using System.Threading.Tasks; 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. + /// public class TextureGroup { + /// + /// 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. + /// public DirectionalTexture sittingTexture; + /// + /// 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. + /// 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. + /// 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; public TextureGroup(AssetInfo info, string path,Direction direction ,AnimationType animationType=AnimationType.standing) From a915a06460fcdce27400946ba9605fefa4e00da1 Mon Sep 17 00:00:00 2001 From: Date: Mon, 19 Mar 2018 03:32:00 -0700 Subject: [PATCH 20/54] More comments round 2 --- .../Framework/Graphics/AssetInfo.cs | 39 ++++++- .../Framework/Graphics/AssetManager.cs | 31 ++++++ .../Framework/Graphics/AssetPool.cs | 100 +++++++++++++++++- .../Framework/Graphics/AssetSheet.cs | 51 ++++++++- .../Framework/Graphics/DirectionalTexture.cs | 50 +++++++++ .../Framework/Graphics/ExtendedAssetInfo.cs | 15 +++ .../Graphics/TextureGroups/TextureGroup.cs | 28 +++++ .../CharacterAnimationBase.cs | 33 +++++- 8 files changed, 337 insertions(+), 10 deletions(-) diff --git a/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetInfo.cs b/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetInfo.cs index da3239ca..adc5d387 100644 --- a/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetInfo.cs +++ b/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetInfo.cs @@ -7,21 +7,58 @@ using System.Threading.Tasks; 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. + /// public class AssetInfo { + /// + /// 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. + /// public NamePairings standingAssetPaths; + /// + /// 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. + /// public NamePairings movingAssetPaths; + /// + /// The list of files to be used with the sitting animation. + /// public NamePairings sittingAssetPaths; + /// + /// The size of the asset texture. Width and height. + /// public Vector2 assetSize; + /// + /// Not really used anymore. More of a legacy feature. + /// public bool randomizeUponLoad; - + + /// + /// Empty constructor. + /// public AssetInfo() { } + /// + /// Constructor that assigns values to the class. + /// + /// 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. public AssetInfo(string assetName,NamePairings StandingAssetPaths, NamePairings MovingAssetPaths, NamePairings SwimmingAssetPaths, NamePairings SittingAssetPaths, Vector2 assetSize, bool randomizeUponLoad) { this.assetName = assetName; diff --git a/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetManager.cs b/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetManager.cs index 0e54d56e..1cd90755 100644 --- a/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetManager.cs +++ b/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetManager.cs @@ -8,9 +8,18 @@ using System.Threading.Tasks; namespace CustomNPCFramework.Framework.Graphics { + /// + /// Used to hold assets from specified directories. + /// public class AssetManager { + /// + /// 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; /// @@ -22,6 +31,10 @@ namespace CustomNPCFramework.Framework.Graphics this.paths = new Dictionary(); } + /// + /// Constructor. + /// + /// A list of all directories to be managed by the asset manager. Name, path is the key pair value. public AssetManager(Dictionary assetsPathsToLoadFrom) { this.assets = new List(); @@ -155,6 +168,11 @@ namespace CustomNPCFramework.Framework.Graphics return aSheet; } + /// + /// 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. + /// public List getListOfAssetsThatMatchThisCriteria(PartType type) { List aSheet = new List(); @@ -168,6 +186,12 @@ namespace CustomNPCFramework.Framework.Graphics return aSheet; } + /// + /// 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) { List aSheet = new List(); @@ -225,6 +249,13 @@ namespace CustomNPCFramework.Framework.Graphics return aSheet; } + /// + /// 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. + /// public List getListOfAssetsThatMatchThisCriteria(Genders gender, Seasons season, PartType type) { List aSheet = new List(); diff --git a/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetPool.cs b/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetPool.cs index 01a75a73..6292d001 100644 --- a/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetPool.cs +++ b/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetPool.cs @@ -16,11 +16,10 @@ using System.Threading.Tasks; namespace CustomNPCFramework.Framework.Graphics { - /// - /// Used to contain all of the asset managers. - /// - /// + /// + /// Used to hold a collection of strings. + /// public class NamePairings { public string leftString; @@ -36,37 +35,67 @@ namespace CustomNPCFramework.Framework.Graphics } } + /// + /// Used to contain all of the asset managers. + /// public class AssetPool { + /// + /// A dictionary holding all of the asset managers. (Name, AssetManager) + /// public Dictionary assetPool; + /// + /// Constructor. + /// public AssetPool() { this.assetPool = new Dictionary(); } + /// + /// 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. + /// + /// 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) { this.assetPool.Add(assetManagerName, assetManager); } + /// + /// 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); return asset; } + /// + /// Remove an asset manager from the asset pool. + /// + /// The name of the asset manager to remove. public void removeAssetManager(string key) { assetPool.Remove(key); } + /// + /// Go through all of the asset managers and load assets according to their respective paths. + /// public void loadAllAssets() { foreach (KeyValuePair assetManager in this.assetPool) @@ -88,7 +117,12 @@ namespace CustomNPCFramework.Framework.Graphics } - + /// + /// 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.path.Clone().ToString(),assetSheet.index, (int)assetSheet.assetInfo.assetSize.X, (int)assetSheet.assetInfo.assetSize.Y); @@ -118,11 +152,29 @@ namespace CustomNPCFramework.Framework.Graphics } + /// + /// 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); } + /// + /// 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. + /// The collection of sprites to be used for the shirts of the npc. + /// The collection of sprites to be used for the pants of the npc. + /// 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) { var body = getAnimatedSpriteCollectionFromAssets(BodySprites); @@ -140,6 +192,14 @@ namespace CustomNPCFramework.Framework.Graphics return new StandardCharacterAnimation(body,eyes,hair,shirts,pants,shoes,accessories,DrawColors); } + /// + /// 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) { var parts = this.getAssetManager(assetManagerName).getListOfAssetsThatMatchThisCriteria(gender, season, type); @@ -300,6 +360,18 @@ namespace CustomNPCFramework.Framework.Graphics 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(); @@ -315,6 +387,19 @@ namespace CustomNPCFramework.Framework.Graphics return render; } + /// + /// 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) { var bodySprite = getSpriteCollectionFromSheet(body, animationType); @@ -334,6 +419,11 @@ namespace CustomNPCFramework.Framework.Graphics return standingAnimation; } + /// + /// 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 b67bf0ea..6ac92683 100644 --- a/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetSheet.cs +++ b/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetSheet.cs @@ -16,15 +16,34 @@ namespace CustomNPCFramework.Framework.Graphics /// public class AssetSheet { + /// + /// Used to hold the textures for the AssetSheet. + /// public TextureGroups.TextureGroup textures; + /// + /// Used to hold the info for the paths to these textures. + /// public AssetInfo assetInfo; + + /// + /// The path to this assetinfo.json file + /// public string path; + /// + /// The soruce rectangle for the current texture to draw. + /// + public Rectangle currentAsset; + public int index; - public Rectangle currentAsset; - + /// + /// Constructor. + /// + /// 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) { this.assetInfo = info; @@ -37,9 +56,14 @@ namespace CustomNPCFramework.Framework.Graphics { this.path = path; } + this.index = 0; } + /// + /// Get the path to the current texture. + /// + /// public virtual KeyValuePair getPathTexturePair() { return new KeyValuePair(this.path, this.textures.currentTexture.currentTexture); @@ -55,32 +79,53 @@ namespace CustomNPCFramework.Framework.Graphics return asset; } - + /// + /// 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. + /// public virtual void setUp() { this.textures.setUp(); } + /// + /// 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. + /// public virtual void setRight() { this.textures.setRight(); } + /// + /// Get the current animation texture. + /// + /// public virtual Texture2D getCurrentSpriteTexture() { return this.textures.currentTexture.currentTexture; } + /// + /// Get the specific texture depending on the direction and animation type. + /// + /// + /// + /// public virtual Texture2D 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 8b7d0353..9f46d023 100644 --- a/GeneralMods/CustomNPCFramework/Framework/Graphics/DirectionalTexture.cs +++ b/GeneralMods/CustomNPCFramework/Framework/Graphics/DirectionalTexture.cs @@ -9,15 +9,42 @@ using System.Threading.Tasks; namespace CustomNPCFramework.Framework.Graphics { + /// + /// A class that's used to hold textures for different directions. + /// public class DirectionalTexture { + /// + /// The left texture for this group. + /// public Texture2D leftTexture; + /// + /// The right texture for this group. + /// public Texture2D rightTexture; + + /// + /// The down textiure for this group. + /// public Texture2D downTexture; + /// + /// The up texture for this group. + /// public Texture2D upTexture; + /// + /// The current texture for this group. + /// public Texture2D currentTexture; + /// + /// Constructor. + /// + /// 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(Texture2D left, Texture2D right, Texture2D up, Texture2D down, Direction direction=Direction.down) { this.leftTexture = left; @@ -33,6 +60,12 @@ namespace CustomNPCFramework.Framework.Graphics } + /// + /// Constructor. + /// + /// A list of name pairings to hold the info for the directional texture. + /// The path location of the textures to load. + /// The direction the textures should be facing. public DirectionalTexture(NamePairings info, string path, Direction direction = Direction.down) { this.leftTexture = Class1.ModHelper.Content.Load(Class1.getShortenedDirectory(Path.Combine(path, info.leftString + ".png")).Remove(0, 1)); @@ -46,26 +79,43 @@ namespace CustomNPCFramework.Framework.Graphics if (direction == Direction.down) this.currentTexture = downTexture; } + /// + /// Sets the direction of this current texture to left. + /// public void setLeft() { this.currentTexture = leftTexture; } + /// + /// Sets the direction of this current texture to up. + /// public void setUp() { this.currentTexture = upTexture; } + /// + /// Sets the direction of this current texture to down. + /// public void setDown() { this.currentTexture = downTexture; } + /// + /// Sets the direction of this current texture to right. + /// public void setRight() { this.currentTexture = rightTexture; } + /// + /// Gets the texture from this texture group depending on the direction. + /// + /// + /// public virtual Texture2D getTextureFromDirection(Direction direction) { if (direction == Direction.left) return this.leftTexture; diff --git a/GeneralMods/CustomNPCFramework/Framework/Graphics/ExtendedAssetInfo.cs b/GeneralMods/CustomNPCFramework/Framework/Graphics/ExtendedAssetInfo.cs index 39ab9170..0590fee3 100644 --- a/GeneralMods/CustomNPCFramework/Framework/Graphics/ExtendedAssetInfo.cs +++ b/GeneralMods/CustomNPCFramework/Framework/Graphics/ExtendedAssetInfo.cs @@ -8,12 +8,27 @@ using System.Threading.Tasks; namespace CustomNPCFramework.Framework.Graphics { + /// + /// 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. + /// 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. + /// public PartType type; + /// + /// Constructor. + /// public ExtendedAssetInfo() { this.seasons = new List(); diff --git a/GeneralMods/CustomNPCFramework/Framework/Graphics/TextureGroups/TextureGroup.cs b/GeneralMods/CustomNPCFramework/Framework/Graphics/TextureGroups/TextureGroup.cs index b1da295a..9c8753fa 100644 --- a/GeneralMods/CustomNPCFramework/Framework/Graphics/TextureGroups/TextureGroup.cs +++ b/GeneralMods/CustomNPCFramework/Framework/Graphics/TextureGroups/TextureGroup.cs @@ -52,6 +52,13 @@ namespace CustomNPCFramework.Framework.Graphics.TextureGroups /// private AnimationType type; + /// + /// Constructor. + /// + /// 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) { this.standingTexture = new DirectionalTexture(info.standingAssetPaths, path, direction); @@ -71,12 +78,19 @@ namespace CustomNPCFramework.Framework.Graphics.TextureGroups } + /// + /// 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. + /// public virtual void setLeft() { this.movingTexture.setLeft(); @@ -85,6 +99,9 @@ namespace CustomNPCFramework.Framework.Graphics.TextureGroups this.swimmingTexture.setLeft(); } + /// + /// Sets all of the different animations to use their up facing sprites. + /// public virtual void setUp() { this.movingTexture.setUp(); @@ -93,6 +110,9 @@ namespace CustomNPCFramework.Framework.Graphics.TextureGroups this.swimmingTexture.setUp(); } + /// + /// Sets all of the different animations to use their down facing sprites. + /// public virtual void setDown() { this.movingTexture.setDown(); @@ -101,6 +121,9 @@ namespace CustomNPCFramework.Framework.Graphics.TextureGroups this.swimmingTexture.setDown(); } + /// + /// Sets all of the different animations to use their right facing sprites. + /// public virtual void setRight() { this.movingTexture.setRight(); @@ -109,6 +132,11 @@ namespace CustomNPCFramework.Framework.Graphics.TextureGroups this.swimmingTexture.setRight(); } + /// + /// Get's the appropriate animation texture based on the type of animation key passed in. + /// + /// + /// public virtual DirectionalTexture getTextureFromAnimation(AnimationType type) { if (type == AnimationType.standing) return this.standingTexture; diff --git a/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/CharacterAnimationBases/CharacterAnimationBase.cs b/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/CharacterAnimationBases/CharacterAnimationBase.cs index 47a59d45..2eb3f08b 100644 --- a/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/CharacterAnimationBases/CharacterAnimationBase.cs +++ b/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/CharacterAnimationBases/CharacterAnimationBase.cs @@ -9,39 +9,70 @@ using System.Threading.Tasks; namespace CustomNPCFramework.Framework.ModularNPCS { + /// + /// Used as a base class for character animations. + /// public class CharacterAnimationBase { + /// + /// Constructor. + /// public CharacterAnimationBase() { } + /// + /// Set the character sprites to left. + /// public virtual void setLeft() { } + + /// + /// Set the character sprites to right. + /// public virtual void setRight() { } + + /// + /// 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. + /// + /// How long between animation frames in milliseconds. public virtual void Animate(float animationInterval) { } - + /// + /// Used to animate sprites. + /// + /// How long between animation frames in milliseconds. + /// Loop the animation. public virtual void Animate(float animationInterval, bool loop=true) { From 44d2f4e7e9de61f88afdb06c2c42f1bdbfce3984 Mon Sep 17 00:00:00 2001 From: Date: Mon, 19 Mar 2018 23:01:43 -0700 Subject: [PATCH 21/54] Finished commenting on all functions in the mod. Now just to write up some documentation. --- GeneralMods/CustomNPCFramework/Class1.cs | 56 ++++++++- .../Framework/Graphics/AssetSheet.cs | 2 - .../ModularNPCS/AnimatedSpriteCollection.cs | 55 +++++++-- .../ModularNPCS/AnimatedSpriteExtended.cs | 9 ++ .../StandardCharacterAnimation.cs | 55 +++++++++ .../StandardColorCollection.cs | 24 ++++ .../ModularRenderers/AnimationKeys.cs | 17 ++- .../ModularRenderers/BasicRenderer.cs | 60 ++++++++- .../Framework/ModularNPCS/Portrait.cs | 9 ++ .../Framework/ModularNPCS/Sprite.cs | 9 ++ .../CustomNPCFramework/Framework/NPCNames.cs | 3 + .../Framework/NPCS/ExtendedNPC.cs | 115 +++++++++++++++++- .../Framework/NPCS/MerchantNPC.cs | 26 ++++ .../Framework/Utilities/NPCTracker.cs | 15 ++- 14 files changed, 431 insertions(+), 24 deletions(-) diff --git a/GeneralMods/CustomNPCFramework/Class1.cs b/GeneralMods/CustomNPCFramework/Class1.cs index c1755c9f..4a96a29d 100644 --- a/GeneralMods/CustomNPCFramework/Class1.cs +++ b/GeneralMods/CustomNPCFramework/Class1.cs @@ -42,14 +42,30 @@ namespace CustomNPCFramework /// - public class Class1 : Mod { + /// + /// The mod helper for the mod. + /// public static IModHelper ModHelper; + /// + /// 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. + /// public static AssetPool assetPool; + + /// + /// Ran when loading the SMAPI. Used to initialize data. + /// + /// public override void Entry(IModHelper helper) { ModHelper = this.Helper; @@ -71,24 +87,43 @@ namespace CustomNPCFramework assetPool.loadAllAssets(); } + /// + /// 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. + /// + /// + /// 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. + /// + /// + /// 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. + /// + /// + /// private void GameEvents_UpdateTick(object sender, EventArgs e) { + /* if (Game1.player.currentLocation == null) return; if (Game1.activeClickableMenu != null) return; foreach (var v in Game1.player.currentLocation.characters) @@ -101,8 +136,14 @@ namespace CustomNPCFramework //v.MovePosition(Game1.currentGameTime, Game1.viewport, Game1.player.currentLocation); //ModMonitor.Log(v.sprite.spriteHeight.ToString()); } + */ } + /// + /// Called when the player's location changes. + /// + /// + /// private void LocationEvents_CurrentLocationChanged(object sender, StardewModdingAPI.Events.EventArgsCurrentLocationChanged e) { @@ -124,6 +165,9 @@ namespace CustomNPCFramework npcTracker.addNewNPCToLocation(Game1.getLocationFromName("BusStop", false), merch,new Vector2(2,23)); } + /// + /// Used to initialize examples for other modders to look at as reference. + /// public void initializeExamples() { return; @@ -153,6 +197,11 @@ namespace CustomNPCFramework } } + /// + /// Used to splice the mod directory to get relative paths. + /// + /// + /// public static string getShortenedDirectory(string path) { string lol = (string)path.Clone(); @@ -167,6 +216,11 @@ namespace CustomNPCFramework } } + /// + /// 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/Framework/Graphics/AssetSheet.cs b/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetSheet.cs index 6ac92683..c7119852 100644 --- a/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetSheet.cs +++ b/GeneralMods/CustomNPCFramework/Framework/Graphics/AssetSheet.cs @@ -37,7 +37,6 @@ namespace CustomNPCFramework.Framework.Graphics public Rectangle currentAsset; public int index; - /// /// Constructor. /// @@ -59,7 +58,6 @@ namespace CustomNPCFramework.Framework.Graphics this.index = 0; } - /// /// Get the path to the current texture. /// diff --git a/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/AnimatedSpriteCollection.cs b/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/AnimatedSpriteCollection.cs index 0b31d26c..9144413c 100644 --- a/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/AnimatedSpriteCollection.cs +++ b/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/AnimatedSpriteCollection.cs @@ -16,11 +16,26 @@ namespace CustomNPCFramework.Framework.ModularNPCS /// public class AnimatedSpriteCollection { + /// + /// The left sprite for this sprite asset part. + /// AnimatedSpriteExtended leftSprite; + /// + /// The right sprite for this sprite asset part. + /// AnimatedSpriteExtended rightSprite; + /// + /// The up sprite for this sprite asset part. + /// AnimatedSpriteExtended upSprite; + /// + /// 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. + /// public AnimatedSpriteExtended currentSprite; /// @@ -55,6 +70,9 @@ namespace CustomNPCFramework.Framework.ModularNPCS } } + /// + /// Reloads all of the directional textures for this texture collection. + /// public virtual void reload() { this.leftSprite.reload(); @@ -64,23 +82,32 @@ namespace CustomNPCFramework.Framework.ModularNPCS } /// - /// Sets the current + /// Sets the current sprite direction to face left. /// public void setLeft() { this.currentSprite = leftSprite; } + /// + /// Sets the current sprite direction to face right. + /// public void setRight() { this.currentSprite = rightSprite; } + /// + /// Sets the current sprite direction to face down. + /// public void setDown() { this.currentSprite = downSprite; } + /// + /// Sets the current sprite direction to face up. + /// public void setUp() { this.currentSprite = upSprite; @@ -140,18 +167,22 @@ namespace CustomNPCFramework.Framework.ModularNPCS /// /// Animate the current sprite. Theoreticlly works from index offset to how many frames /// - /// - public void Animate(float intervalFromCharacter,bool loop=true) + /// The delay in milliseconds between frames. + public void Animate(float intervalDelay,bool loop=true) { - //ANIMATE AND UPDATE SOURCE RECTANGLE NOT WORKING!!!! FIGURE THIS OUT!!!! - //Class1.ModMonitor.Log("Current sprite frame:"+this.currentSprite.sprite.currentFrame.ToString()); - //Class1.ModMonitor.Log("Am I ignoring something??: " + this.currentSprite.sprite.ignoreSourceRectUpdates); - //Class1.ModMonitor.Log("Current Sprite Source Rect:" + this.currentSprite.sprite.sourceRect); - //Class1.ModMonitor.Log("Sprite width: " + this.currentSprite.sprite.spriteWidth); - //Class1.ModMonitor.Log("Sprite width: " + this.currentSprite.sprite.spriteHeight); - this.Animate(Game1.currentGameTime, 0,2, intervalFromCharacter,this.currentSprite.sprite,loop); + this.Animate(Game1.currentGameTime, 0,2, intervalDelay,this.currentSprite.sprite,loop); } + /// + /// 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) { if (sprite.CurrentFrame >= startFrame + numberOfFrames + 1 || sprite.CurrentFrame < startFrame) @@ -173,6 +204,10 @@ namespace CustomNPCFramework.Framework.ModularNPCS return false; } + /// + /// Update the source rectangle on the sprite sheet. Needed for animation. + /// + /// public virtual void UpdateSourceRect(AnimatedSprite sprite) { if (sprite.ignoreSourceRectUpdates) diff --git a/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/AnimatedSpriteExtended.cs b/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/AnimatedSpriteExtended.cs index 430c36d8..55731336 100644 --- a/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/AnimatedSpriteExtended.cs +++ b/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/AnimatedSpriteExtended.cs @@ -8,9 +8,18 @@ using System.Threading.Tasks; namespace CustomNPCFramework.Framework.ModularNPCS { + /// + /// Used as a wrapper for the AnimatedSprite class. + /// public class AnimatedSpriteExtended { + /// + /// The actual sprite of the object. + /// public AnimatedSprite sprite; + /// + /// The path to the texture to load the sprite from. + /// public string path; diff --git a/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/CharacterAnimationBases/StandardCharacterAnimation.cs b/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/CharacterAnimationBases/StandardCharacterAnimation.cs index d23aa91b..c563354b 100644 --- a/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/CharacterAnimationBases/StandardCharacterAnimation.cs +++ b/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/CharacterAnimationBases/StandardCharacterAnimation.cs @@ -11,17 +11,52 @@ using System.Threading.Tasks; 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 { + /// + /// 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. + /// public AnimatedSpriteCollection body; + /// + /// 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. + /// public AnimatedSpriteCollection shirt; + /// + /// 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. + /// public AnimatedSpriteCollection shoes; + /// + /// Used to hold all of the information for draw colors for the different parts. + /// public StandardColorCollection drawColors; public List accessories; + /// + /// Constructor. + /// + /// 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. + /// The collection of textures to be used for the shirt part for the npc. + /// The collection of textures to be used for the pants part for the npc. + /// 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() { this.body = bodyAnimation; @@ -34,6 +69,9 @@ namespace CustomNPCFramework.Framework.ModularNPCS.CharacterAnimationBases this.drawColors = DrawColors; } + /// + /// Sets all of the different textures to face left. + /// public override void setLeft() { this.body.setLeft(); @@ -48,6 +86,9 @@ namespace CustomNPCFramework.Framework.ModularNPCS.CharacterAnimationBases accessory.setLeft(); } } + /// + /// Sets all of the different textures to face right. + /// public override void setRight() { this.body.setRight(); @@ -62,6 +103,9 @@ namespace CustomNPCFramework.Framework.ModularNPCS.CharacterAnimationBases accessory.setRight(); } } + /// + /// Sets all of the different textures to face up. + /// public override void setUp() { this.body.setUp(); @@ -76,6 +120,9 @@ namespace CustomNPCFramework.Framework.ModularNPCS.CharacterAnimationBases accessory.setUp(); } } + /// + /// Sets all of the different textures to face down. + /// public override void setDown() { this.body.setDown(); @@ -91,6 +138,9 @@ namespace CustomNPCFramework.Framework.ModularNPCS.CharacterAnimationBases } } + /// + /// Reloads all of the sprite textures. + /// public override void reload() { this.body.reload(); @@ -101,6 +151,11 @@ namespace CustomNPCFramework.Framework.ModularNPCS.CharacterAnimationBases this.shoes.reload(); } + /// + /// 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) { this.body.Animate(animationInterval,loop); diff --git a/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/ColorCollections/StandardColorCollection.cs b/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/ColorCollections/StandardColorCollection.cs index 52d6a073..c27922e7 100644 --- a/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/ColorCollections/StandardColorCollection.cs +++ b/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/ColorCollections/StandardColorCollection.cs @@ -12,11 +12,29 @@ namespace CustomNPCFramework.Framework.ModularNPCS.ColorCollections /// public class StandardColorCollection { + /// + /// 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. + /// public Color eyeColor; + /// + /// 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. + /// public Color shirtColor; + /// + /// 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. + /// public Color shoesColor; /// @@ -67,6 +85,12 @@ namespace CustomNPCFramework.Framework.ModularNPCS.ColorCollections if (color == null) color = Color.White; } + /// + /// 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. public static Color colorMult(Color cBase, Color cMult) { Vector3 color1 = cBase.ToVector3(); diff --git a/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/ModularRenderers/AnimationKeys.cs b/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/ModularRenderers/AnimationKeys.cs index 502b540a..de9249ae 100644 --- a/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/ModularRenderers/AnimationKeys.cs +++ b/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/ModularRenderers/AnimationKeys.cs @@ -6,11 +6,26 @@ using System.Threading.Tasks; namespace CustomNPCFramework.Framework.ModularNPCS.ModularRenderers { - class AnimationKeys + /// + /// 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. + /// public static string standingKey = "standing"; + /// + /// The string that is used for the walking/moving animation. + /// public static string walkingKey = "walking"; + /// + /// The string that is used for the sitting animation. + /// public static string sittingKey = "sitting"; + /// + /// 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 7e69f930..6ea6629b 100644 --- a/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/ModularRenderers/BasicRenderer.cs +++ b/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/ModularRenderers/BasicRenderer.cs @@ -1,4 +1,6 @@ -using CustomNPCFramework.Framework.ModularNPCS.CharacterAnimationBases; +using CustomNPCFramework.Framework.Enums; +using CustomNPCFramework.Framework.Graphics; +using CustomNPCFramework.Framework.ModularNPCS.CharacterAnimationBases; using CustomNPCFramework.Framework.NPCS; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -11,11 +13,26 @@ using System.Threading.Tasks; namespace CustomNPCFramework.Framework.ModularNPCS.ModularRenderers { + /// + /// 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. + /// public Dictionary animationList; + /// + /// Used to keep track of what animation is currently being used. + /// public StandardCharacterAnimation currentAnimation; + /// + /// Constructor. + /// + /// 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) { animationList = new Dictionary(); @@ -28,7 +45,7 @@ namespace CustomNPCFramework.Framework.ModularNPCS.ModularRenderers /// /// 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]; @@ -39,6 +56,10 @@ namespace CustomNPCFramework.Framework.ModularNPCS.ModularRenderers } } + /// + /// 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(); @@ -47,26 +68,54 @@ namespace CustomNPCFramework.Framework.ModularNPCS.ModularRenderers if (facingDirection == 2) setLeft(); } + /// + /// 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(); + } + + + /// + /// Sets the current animated sprite to face left. + /// public virtual void setLeft() { this.currentAnimation.setLeft(); } + /// + /// Sets the current animated sprite to face right. + /// public virtual void setRight() { this.currentAnimation.setRight(); } + /// + /// Sets the current animated sprite to face up. + /// public virtual void setUp() { this.currentAnimation.setUp(); } - + + /// + /// 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. + /// public virtual void reloadSprites() { foreach(var v in this.animationList) @@ -124,6 +173,11 @@ namespace CustomNPCFramework.Framework.ModularNPCS.ModularRenderers } + /// + /// Animates the current animation for the current sprite. + /// + /// + /// public virtual void Animate(float interval, bool loop=true) { this.currentAnimation.Animate(interval,loop); diff --git a/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/Portrait.cs b/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/Portrait.cs index eae4739e..4e6b10aa 100644 --- a/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/Portrait.cs +++ b/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/Portrait.cs @@ -8,9 +8,18 @@ using System.Threading.Tasks; namespace CustomNPCFramework.Framework.ModularNPCS { + /// + /// Used as a wrapper for npc portraits. + /// public class Portrait { + /// + /// Used to display the npc portrait. + /// public Texture2D portrait; + /// + /// Used to hold the path to the texture to use for the npc portrait. + /// public string relativePath; /// diff --git a/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/Sprite.cs b/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/Sprite.cs index a076ca1f..4854c000 100644 --- a/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/Sprite.cs +++ b/GeneralMods/CustomNPCFramework/Framework/ModularNPCS/Sprite.cs @@ -10,9 +10,18 @@ using System.Threading.Tasks; namespace CustomNPCFramework.Framework.ModularNPCS { + /// + /// Used as a wrapper for the npcs to hold sprite information. + /// public class Sprite { + /// + /// The actual sprite to draw for the npc. + /// public AnimatedSprite sprite; + /// + /// The path to the texture to use for the animated sprite. + /// public string relativePath; /// diff --git a/GeneralMods/CustomNPCFramework/Framework/NPCNames.cs b/GeneralMods/CustomNPCFramework/Framework/NPCNames.cs index 38ddfdf2..6ede8e02 100644 --- a/GeneralMods/CustomNPCFramework/Framework/NPCNames.cs +++ b/GeneralMods/CustomNPCFramework/Framework/NPCNames.cs @@ -8,6 +8,9 @@ using System.Threading.Tasks; namespace CustomNPCFramework.Framework { + /// + /// Used as a class to hold all of the possible npc names. + /// public class NPCNames { /// diff --git a/GeneralMods/CustomNPCFramework/Framework/NPCS/ExtendedNPC.cs b/GeneralMods/CustomNPCFramework/Framework/NPCS/ExtendedNPC.cs index 498f4b6b..626c5212 100644 --- a/GeneralMods/CustomNPCFramework/Framework/NPCS/ExtendedNPC.cs +++ b/GeneralMods/CustomNPCFramework/Framework/NPCS/ExtendedNPC.cs @@ -27,6 +27,9 @@ namespace CustomNPCFramework.Framework.NPCS /// public class ExtendedNPC :StardewValley.NPC { + /// + /// The custom character renderer for this npc. + /// public BasicRenderer characterRenderer; public bool hasBeenKissedToday; public Point previousEndPoint; @@ -34,16 +37,35 @@ 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. + /// public Sprite spriteInformation; + /// + /// Used to hold the portrait information for the npc and display it. + /// public Portrait portraitInformation; + /// + /// The default location for this npc to reside in. + /// public GameLocation defaultLocation; + /// + /// Empty Constructor. + /// public ExtendedNPC() :base() { } + /// + /// Non modular npc Constructor. + /// + /// 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) { this.characterRenderer = null; @@ -57,6 +79,14 @@ namespace CustomNPCFramework.Framework.NPCS this.swimming = false; } + /// + /// Non modular npc Constructor. + /// + /// 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) { this.characterRenderer = null; @@ -70,6 +100,15 @@ namespace CustomNPCFramework.Framework.NPCS this.swimming = false; } + /// + /// Modular npc constructor. + /// + /// 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) { this.characterRenderer = renderer; @@ -83,6 +122,15 @@ namespace CustomNPCFramework.Framework.NPCS this.swimming = false; } + /// + /// Modular constructor for the npc. + /// + /// 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) { this.characterRenderer = renderer; @@ -99,7 +147,9 @@ namespace CustomNPCFramework.Framework.NPCS this.swimming = false; } - //ERROR NEED FIXING + /// + /// Used to reload the sprite for the npc. + /// public override void reloadSprite() { if (this.characterRenderer == null) @@ -150,13 +200,24 @@ namespace CustomNPCFramework.Framework.NPCS } + /// + /// Functionality used when interacting with the npc. + /// + /// + /// + /// public override bool checkAction(StardewValley.Farmer who, GameLocation l) { base.checkAction(who, l); return false; } - //ERROR NEED FIXING + /// + /// 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) @@ -188,12 +249,23 @@ namespace CustomNPCFramework.Framework.NPCS this.MovePosition(time, viewport, currentLocation); } + /// + /// 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; } + /// + /// Used to determine if the npc can move past the next location. + /// + /// + /// public virtual bool canMovePastNextLocation(xTile.Dimensions.Rectangle viewport) { //Up @@ -219,9 +291,15 @@ namespace CustomNPCFramework.Framework.NPCS return true; } + /// + /// 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) { - interval /= 2; this.characterRenderer.setAnimation(AnimationKeys.walkingKey); if (this.canMovePastNextLocation(viewport) == false) { @@ -369,17 +447,32 @@ 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. + /// public override void Halt() { - this.characterRenderer.setAnimation(AnimationKeys.standingKey); + if (this.characterRenderer != null) + { + 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) { this.doingEndOfRouteAnimation = false; @@ -397,11 +490,20 @@ namespace CustomNPCFramework.Framework.NPCS this.timeAfterSquare = Game1.timeOfDay; } + /// + /// Pathfinding code. + /// + /// + /// public virtual void doAnimationAtEndOfScheduleRoute(Character c, GameLocation l) { } + /// + /// Pathfinding code. + /// + /// public virtual void startRouteBehavior(string behaviorName) { if (behaviorName.Length > 0 && (int)behaviorName[0] == 34) @@ -429,6 +531,11 @@ namespace CustomNPCFramework.Framework.NPCS } + /// + /// Occurs when the npc gets hit by the player. + /// + /// + /// public new void getHitByPlayer(StardewValley.Farmer who, GameLocation location) { this.doEmote(12, true); diff --git a/GeneralMods/CustomNPCFramework/Framework/NPCS/MerchantNPC.cs b/GeneralMods/CustomNPCFramework/Framework/NPCS/MerchantNPC.cs index 95f9ac3c..406d4fa0 100644 --- a/GeneralMods/CustomNPCFramework/Framework/NPCS/MerchantNPC.cs +++ b/GeneralMods/CustomNPCFramework/Framework/NPCS/MerchantNPC.cs @@ -10,20 +10,46 @@ using System.Threading.Tasks; namespace CustomNPCFramework.Framework.NPCS { + /// + /// Extended merchant npc from ExtendedNPC. + /// class MerchantNPC: ExtendedNPC { + /// + /// Thelist of items this npc has for sale. + /// public List stock; + /// + /// Constructor. + /// + /// The list of items this npc will sell. + /// The sprite for the npc to use. + /// The renderer for the npc to use. + /// The position for the npc to use. + /// The facing direction for the player to face. + /// The name for the npc. public MerchantNPC(List Stock, Sprite sprite, BasicRenderer renderer,Vector2 position,int facingDirection,string name): base(sprite,renderer,position,facingDirection,name) { this.stock = Stock; } + /// + /// Constructor. + /// + /// The list of items for the npc to sell. + /// The npc base for the character to be expanded upon. public MerchantNPC(List Stock, ExtendedNPC npcBase) : base(npcBase.spriteInformation, npcBase.characterRenderer, npcBase.portraitInformation, npcBase.position, npcBase.facingDirection, npcBase.name) { this.stock = Stock; } + /// + /// Used to interact with the npc. When interacting pulls up a shop menu for the npc with their current stock. + /// + /// + /// + /// public override bool checkAction(StardewValley.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 5c80adf9..1ccbbbd7 100644 --- a/GeneralMods/CustomNPCFramework/Framework/Utilities/NPCTracker.cs +++ b/GeneralMods/CustomNPCFramework/Framework/Utilities/NPCTracker.cs @@ -9,6 +9,9 @@ using System.Threading.Tasks; namespace CustomNPCFramework.Framework.Utilities { + /// + /// Used to keep track of all of the custom npcs. + /// public class NPCTracker { /// @@ -27,8 +30,8 @@ namespace CustomNPCFramework.Framework.Utilities /// /// 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) { this.moddedNPCS.Add(npc); @@ -37,6 +40,12 @@ namespace CustomNPCFramework.Framework.Utilities loc.addCharacter(npc); } + /// + /// 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) { this.moddedNPCS.Add(npc); @@ -59,7 +68,7 @@ namespace CustomNPCFramework.Framework.Utilities /// /// 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) { if (npc.currentLocation != null) From 67c110f282ed44258577080215e03f178e3c121a Mon Sep 17 00:00:00 2001 From: Date: Tue, 20 Mar 2018 03:10:02 -0700 Subject: [PATCH 22/54] attempted rough implementation of farmers market. Needs a lot more work before rough prototype would be complete. --- GeneralMods/CustomNPCFramework/Class1.cs | 5 ++ GeneralMods/FarmersMarketStall/Class1.cs | 55 ++++++++++++++++ .../FarmersMarketStall.csproj | 65 +++++++++++++++++++ .../MapEvents/ShopInteractionEvent.cs | 48 ++++++++++++++ .../Framework/MarketStall.cs | 39 +++++++++++ .../Framework/Menus/MarketStallMenu.cs | 25 +++++++ .../Properties/AssemblyInfo.cs | 36 ++++++++++ GeneralMods/FarmersMarketStall/manifest.json | 16 +++++ .../FarmersMarketStall/packages.config | 4 ++ GeneralMods/StardewMods.sln | 10 +++ 10 files changed, 303 insertions(+) create mode 100644 GeneralMods/FarmersMarketStall/Class1.cs create mode 100644 GeneralMods/FarmersMarketStall/FarmersMarketStall.csproj create mode 100644 GeneralMods/FarmersMarketStall/Framework/MapEvents/ShopInteractionEvent.cs create mode 100644 GeneralMods/FarmersMarketStall/Framework/MarketStall.cs create mode 100644 GeneralMods/FarmersMarketStall/Framework/Menus/MarketStallMenu.cs create mode 100644 GeneralMods/FarmersMarketStall/Properties/AssemblyInfo.cs create mode 100644 GeneralMods/FarmersMarketStall/manifest.json create mode 100644 GeneralMods/FarmersMarketStall/packages.config diff --git a/GeneralMods/CustomNPCFramework/Class1.cs b/GeneralMods/CustomNPCFramework/Class1.cs index 4a96a29d..5d57d1e0 100644 --- a/GeneralMods/CustomNPCFramework/Class1.cs +++ b/GeneralMods/CustomNPCFramework/Class1.cs @@ -19,7 +19,10 @@ using System.Threading.Tasks; namespace CustomNPCFramework { /// + /// BETA VERSION 0.1.0: Lots of ways this can be improved upon. /// TODO: + /// + /// /// List all asset managers in use. /// Have all asset managers list what assets they are using. /// @@ -39,6 +42,8 @@ namespace CustomNPCFramework /// -Collect a bunch of assets together to test this thing. /// /// Find way to make sideways shirts render correctly. + /// + ///Get suggestions from modding community on requests and ways to improve the mod. /// diff --git a/GeneralMods/FarmersMarketStall/Class1.cs b/GeneralMods/FarmersMarketStall/Class1.cs new file mode 100644 index 00000000..036a74a5 --- /dev/null +++ b/GeneralMods/FarmersMarketStall/Class1.cs @@ -0,0 +1,55 @@ +using EventSystem.Framework.FunctionEvents; +using FarmersMarketStall.Framework.MapEvents; +using Microsoft.Xna.Framework; +using StardewModdingAPI; +using StardewValley; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FarmersMarketStall +{ + + /// + /// TODO: + /// Make a farmers market menu + /// MAke a way to store items to sell in a sort of inventory + /// Make a map event to call the farmers market stall menu + /// Make way to sell market items at a higher value + /// Make a selling menu + /// Make a minigame event for bonus money to earn. + /// + /// + + public class Class1 :Mod + { + + public static IModHelper ModHelper; + public static IMonitor ModMonitor; + public static FarmersMarketStall.Framework.MarketStall marketStall; + public override void Entry(IModHelper helper) + { + ModHelper = Helper; + ModMonitor = Monitor; + + StardewModdingAPI.Events.SaveEvents.BeforeSave += SaveEvents_BeforeSave; + StardewModdingAPI.Events.SaveEvents.AfterLoad += SaveEvents_AfterLoad; + marketStall = new Framework.MarketStall(); + } + + private void SaveEvents_AfterLoad(object sender, EventArgs e) + { + EventSystem.EventSystem.eventManager.addEvent(Game1.getLocationFromName("BusStop"), new ShopInteractionEvent("FarmersMarketStall", Game1.getLocationFromName("BusStop"), new Vector2(6, 11), new MouseButtonEvents(null, true), new MouseEntryLeaveEvent(null, null))); + } + + private void SaveEvents_BeforeSave(object sender, EventArgs e) + { + if (marketStall.stock.Count > 0) { + // Game1.endOfNightMenus.Push(new StardewValley.Menus.ShippingMenu(marketStall.stock)); + marketStall.sellAllItems(); + } + } + } +} diff --git a/GeneralMods/FarmersMarketStall/FarmersMarketStall.csproj b/GeneralMods/FarmersMarketStall/FarmersMarketStall.csproj new file mode 100644 index 00000000..6f34f346 --- /dev/null +++ b/GeneralMods/FarmersMarketStall/FarmersMarketStall.csproj @@ -0,0 +1,65 @@ + + + + + Debug + AnyCPU + {0E37BE57-6B3C-4C79-A134-D16283D5306D} + Library + Properties + FarmersMarketStall + FarmersMarketStall + v4.6.1 + 512 + + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\MapEvents\bin\Release\EventSystem.dll + + + + + + + + + + + + + + + + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + \ No newline at end of file diff --git a/GeneralMods/FarmersMarketStall/Framework/MapEvents/ShopInteractionEvent.cs b/GeneralMods/FarmersMarketStall/Framework/MapEvents/ShopInteractionEvent.cs new file mode 100644 index 00000000..25fbd4b1 --- /dev/null +++ b/GeneralMods/FarmersMarketStall/Framework/MapEvents/ShopInteractionEvent.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using EventSystem; +using EventSystem.Framework.FunctionEvents; +using Microsoft.Xna.Framework; +using StardewValley; + +namespace FarmersMarketStall.Framework.MapEvents +{ + public class ShopInteractionEvent :EventSystem.Framework.MapEvent + { + public ShopInteractionEvent(string Name, GameLocation Location, Vector2 Position, MouseButtonEvents MouseEvents, MouseEntryLeaveEvent EntryLeave) : base(Name, Location, Position) + { + this.name = Name; + this.location = Location; + this.tilePosition = Position; + this.mouseButtonEvents = MouseEvents; + + this.doesInteractionNeedToRun = true; + + this.mouseEntryLeaveEvents = EntryLeave; + } + + + public override bool OnLeftClick() + { + if (base.OnLeftClick() == false) return false; + if (this.location.isObjectAt((int)this.tilePosition.X * Game1.tileSize, (int)this.tilePosition.Y * Game1.tileSize)) return false; + Game1.activeClickableMenu = Menus.MarketStallMenu.openMenu(Class1.marketStall); + return true; + } + + /// + /// Used to update the event and check for interaction. + /// + public override void update() + { + this.clickEvent(); + //Needed for updating. + this.OnMouseEnter(); + this.OnMouseLeave(); + } + + } +} diff --git a/GeneralMods/FarmersMarketStall/Framework/MarketStall.cs b/GeneralMods/FarmersMarketStall/Framework/MarketStall.cs new file mode 100644 index 00000000..c043bcf6 --- /dev/null +++ b/GeneralMods/FarmersMarketStall/Framework/MarketStall.cs @@ -0,0 +1,39 @@ +using StardewValley; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FarmersMarketStall.Framework +{ + public class MarketStall + { + public List stock; + + public MarketStall() + { + + } + + public void addItemToSell(Item item) + { + this.stock.Add(item); + } + + public void removeItemFromStock(Item item) + { + this.stock.Remove(item); + } + + public void sellAllItems() + { + foreach(var item in stock) + { + Game1.player.money+=(int)(item.salePrice() * 1.10f); //Replace the multiplier with some sort of level. + } + this.stock.Clear(); + } + + } +} diff --git a/GeneralMods/FarmersMarketStall/Framework/Menus/MarketStallMenu.cs b/GeneralMods/FarmersMarketStall/Framework/Menus/MarketStallMenu.cs new file mode 100644 index 00000000..104bd0de --- /dev/null +++ b/GeneralMods/FarmersMarketStall/Framework/Menus/MarketStallMenu.cs @@ -0,0 +1,25 @@ +using StardewValley; +using StardewValley.Menus; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FarmersMarketStall.Framework.Menus +{ + class MarketStallMenu + { + public MarketStallMenu(MarketStall marketStall) + { + openMenu(marketStall); + } + + public static IClickableMenu openMenu(MarketStall marketStall) + { + return null; + //return new StardewValley.Menus.InventoryMenu((int)(Game1.viewport.Width*.25f),(int)(Game1.viewport.Height*.25f),true,marketStall.stock); + } + + } +} diff --git a/GeneralMods/FarmersMarketStall/Properties/AssemblyInfo.cs b/GeneralMods/FarmersMarketStall/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..63738cde --- /dev/null +++ b/GeneralMods/FarmersMarketStall/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("FarmersMarketStall")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("FarmersMarketStall")] +[assembly: AssemblyCopyright("Copyright © 2018")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("0e37be57-6b3c-4c79-a134-d16283d5306d")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/GeneralMods/FarmersMarketStall/manifest.json b/GeneralMods/FarmersMarketStall/manifest.json new file mode 100644 index 00000000..c6ed000c --- /dev/null +++ b/GeneralMods/FarmersMarketStall/manifest.json @@ -0,0 +1,16 @@ +{ + "Name": "FarmersMarketStall", + "Author": "Alpha_Omegasis", + "Version": "0.1.0", + "Description": "A system to add a farmers market stall to Sundrop.", + "UniqueID": "SunDrop.SunDropMapEvents.FarmersMarketStall", + "EntryDll": "FarmersMarketStall.dll", + "MinimumApiVersion": "2.0", + "UpdateKeys": [ ], + "Dependencies": [ + { + "UniqueID": "Omegasis.EventSystem", + "IsRequired": true + } +] +} diff --git a/GeneralMods/FarmersMarketStall/packages.config b/GeneralMods/FarmersMarketStall/packages.config new file mode 100644 index 00000000..33db9a9b --- /dev/null +++ b/GeneralMods/FarmersMarketStall/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/GeneralMods/StardewMods.sln b/GeneralMods/StardewMods.sln index 62058292..9183f418 100644 --- a/GeneralMods/StardewMods.sln +++ b/GeneralMods/StardewMods.sln @@ -79,6 +79,11 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SundropMapEvents", "Sundrop EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CustomNPCFramework", "CustomNPCFramework\CustomNPCFramework.csproj", "{89C7DF45-8AE5-49AC-ADA9-6312E9590829}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FarmersMarketStall", "FarmersMarketStall\FarmersMarketStall.csproj", "{0E37BE57-6B3C-4C79-A134-D16283D5306D}" + ProjectSection(ProjectDependencies) = postProject + {BB737337-2D82-4245-AA46-F3B82FC6F228} = {BB737337-2D82-4245-AA46-F3B82FC6F228} + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -185,6 +190,10 @@ Global {89C7DF45-8AE5-49AC-ADA9-6312E9590829}.Debug|Any CPU.Build.0 = Debug|Any CPU {89C7DF45-8AE5-49AC-ADA9-6312E9590829}.Release|Any CPU.ActiveCfg = Release|Any CPU {89C7DF45-8AE5-49AC-ADA9-6312E9590829}.Release|Any CPU.Build.0 = Release|Any CPU + {0E37BE57-6B3C-4C79-A134-D16283D5306D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0E37BE57-6B3C-4C79-A134-D16283D5306D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0E37BE57-6B3C-4C79-A134-D16283D5306D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0E37BE57-6B3C-4C79-A134-D16283D5306D}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -195,6 +204,7 @@ Global {BAAC8F21-C12F-42B0-A51C-0C5F33B52575} = {3EE26DA0-0337-4991-8B02-BCB8D408008C} {29A68F94-B23C-442B-8867-8B8F3502E64F} = {BAAC8F21-C12F-42B0-A51C-0C5F33B52575} {89C7DF45-8AE5-49AC-ADA9-6312E9590829} = {3EE26DA0-0337-4991-8B02-BCB8D408008C} + {0E37BE57-6B3C-4C79-A134-D16283D5306D} = {3EE26DA0-0337-4991-8B02-BCB8D408008C} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {4135247C-1326-43F4-A762-3916E50635EF} From ed899b49d905c651a9898f64a9c3d441fecb8696 Mon Sep 17 00:00:00 2001 From: Date: Tue, 20 Mar 2018 16:45:07 -0700 Subject: [PATCH 23/54] symphony menu is coming along. --- .../Framework/Menus/MarketStallMenu.cs | 2 +- .../Content/Graphics/MusicMenu/MusicNote.png | Bin 0 -> 242 bytes .../Templates/WAV/MusicPackInformation.json | 8 ++++ .../Content/Music/Templates/WAV/readme.txt | 1 + .../Templates/XACT/MusicPackInformation.json | 8 ++++ .../Content/Music/Templates/XACT/readme.txt | 3 ++ .../Framework/Menus/MusicManagerMenu.cs | 39 +++++++++++++++++- .../Framework/Music/MusicManager.cs | 8 ++++ .../Framework/Music/MusicPack.cs | 5 +++ .../Framework/Music/XACTMusicPack.cs | 14 +++++-- .../StardewSymphony.cs | 2 + .../UIUtilities/MenuComponents/Button.cs | 20 +++++++-- .../Delegates/DelegatePairing.cs | 8 +++- 13 files changed, 106 insertions(+), 12 deletions(-) create mode 100644 GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Content/Graphics/MusicMenu/MusicNote.png create mode 100644 GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Content/Music/Templates/WAV/MusicPackInformation.json create mode 100644 GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Content/Music/Templates/WAV/readme.txt create mode 100644 GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Content/Music/Templates/XACT/MusicPackInformation.json create mode 100644 GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Content/Music/Templates/XACT/readme.txt diff --git a/GeneralMods/FarmersMarketStall/Framework/Menus/MarketStallMenu.cs b/GeneralMods/FarmersMarketStall/Framework/Menus/MarketStallMenu.cs index 104bd0de..466833db 100644 --- a/GeneralMods/FarmersMarketStall/Framework/Menus/MarketStallMenu.cs +++ b/GeneralMods/FarmersMarketStall/Framework/Menus/MarketStallMenu.cs @@ -17,7 +17,7 @@ namespace FarmersMarketStall.Framework.Menus public static IClickableMenu openMenu(MarketStall marketStall) { - return 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/StardewSymphonyRemastered/StardewSymphonyRemastered/Content/Graphics/MusicMenu/MusicNote.png b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Content/Graphics/MusicMenu/MusicNote.png new file mode 100644 index 0000000000000000000000000000000000000000..98ac852f083fa9a58f015ad026fbb5bd7c42e523 GIT binary patch literal 242 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBugD~Uq{1qucLCF%=h?3y^w370~qEv>0#LT=By}Z;C1rt33 zJtM=93Yk-Zijq8C978Pp@Ae!NJfOhAqTBm#wvy0MhPX7BdONYiR_!x2EK?*GocUn7 zRkS2->D0O%!k4-%Z*dhYTIItr?K{hf?2GlMRpM^)cbsT+x?`YX5tei!L#bZzG-H#F g`?9$jMFo`%-)?W%{_`pGHK1(_p00i_>zopr086b<(); this.texturedStrings.Add(StardustCore.UIUtilities.SpriteFonts.SpriteFont.vanillaFont.ParseString("Hello", new Microsoft.Xna.Framework.Vector2(100, 100),StardustCore.IlluminateFramework.Colors.invertColor(StardustCore.IlluminateFramework.LightColorsList.Blue))); this.buttons = new List(); - this.buttons.Add(new Button("myButton", new Rectangle(100, 100, 64, 64), StardewSymphony.textureManager.getTexture("MusicNote").Copy(StardewSymphony.ModHelper), "mynote", new Rectangle(0, 0, 16, 16), 4f, new StardustCore.Animations.Animation(new Rectangle(0, 0, 16, 16)), Color.White, Color.White,new ButtonFunctionality(new DelegatePairing(hello,null),null,null),false)); //A button that does nothing on the left click. + //this.buttons.Add(new Button("myButton", new Rectangle(100, 100, 64, 64), StardewSymphony.textureManager.getTexture("MusicNote").Copy(StardewSymphony.ModHelper), "mynote", new Rectangle(0, 0, 16, 16), 4f, new StardustCore.Animations.Animation(new Rectangle(0, 0, 16, 16)), Color.White, Color.White,new ButtonFunctionality(new DelegatePairing(hello,null),null,null),false)); //A button that does nothing on the left click. + + int numOfButtons = 0; + int rows = 0; + foreach(var v in StardewSymphony.musicManager.musicPacks) + { + this.buttons.Add(new Button(v.Key, new Rectangle(100+(numOfButtons*100), 100+(rows*100), 64, 64), StardewSymphony.textureManager.getTexture("MusicNote").Copy(StardewSymphony.ModHelper), "", new Rectangle(0, 0, 16, 16), 4f, new StardustCore.Animations.Animation(new Rectangle(0, 0, 16, 16)), Color.White, Color.White, new ButtonFunctionality(new DelegatePairing(displayMusicPack, new List + { + (object)v + } + ),null, new DelegatePairing(null,new List(){ + (object)v + } + )), false)); + numOfButtons++; + if (numOfButtons > 8) + { + numOfButtons = 0; + rows++; + } + } } public override void receiveRightClick(int x, int y, bool playSound = true) @@ -38,7 +58,13 @@ namespace StardewSymphonyRemastered.Framework.Menus { foreach(var v in this.buttons) { - if (v.containsPoint(x, y)) v.onHover(); + if (v.containsPoint(x, y)) + { + var pair = (KeyValuePair)v.buttonFunctionality.hover.paramaters[0]; + v.hoverText = pair.Key; + v.onHover(); + StardewSymphony.ModMonitor.Log(pair.Key); + } } } @@ -77,6 +103,15 @@ namespace StardewSymphonyRemastered.Framework.Menus { StardewSymphony.ModMonitor.Log("Hello"); } + + public void displayMusicPack(List param) + { + var info=(KeyValuePair)param[0]; + StardewSymphony.ModMonitor.Log(info.ToString()); + StardewSymphony.musicManager.playRandomSongFromPack(info.Key); + //info.Value.playRandomSong(); + } + #endregion } } diff --git a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Music/MusicManager.cs b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Music/MusicManager.cs index 88897ea4..4d57673f 100644 --- a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Music/MusicManager.cs +++ b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Music/MusicManager.cs @@ -354,5 +354,13 @@ namespace StardewSymphonyRemastered.Framework pack.Value.songInformation.initializeSeasonalMusic(); } } + + public void playRandomSongFromPack(string musicPackName) + { + this.musicPacks.TryGetValue(musicPackName, out MusicPack musicPack); + if (this.currentMusicPack != null) this.currentMusicPack.stopSong(); + musicPack.playRandomSong(); + this.currentMusicPack = musicPack; + } } } diff --git a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Music/MusicPack.cs b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Music/MusicPack.cs index b4f954da..aa2934f5 100644 --- a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Music/MusicPack.cs +++ b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Music/MusicPack.cs @@ -59,6 +59,11 @@ namespace StardewSymphonyRemastered.Framework } + public virtual void playRandomSong() + { + + } + public virtual void writeToJson() { diff --git a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Music/XACTMusicPack.cs b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Music/XACTMusicPack.cs index de56a22e..4060a873 100644 --- a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Music/XACTMusicPack.cs +++ b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Music/XACTMusicPack.cs @@ -64,13 +64,18 @@ namespace StardewSymphonyRemastered.Framework listofSongs.Add(song); } - this.songInformation.listOfSongsWithoutTriggers = listofSongs; - - - + this.songInformation.listOfSongsWithoutTriggers = listofSongs; } + public override void playRandomSong() + { + Random r = new Random(); + int value = r.Next(0,this.songInformation.listOfSongsWithoutTriggers.Count); + Song s = this.songInformation.listOfSongsWithoutTriggers.ElementAt(value); + this.swapSong(s.name); + } + /// /// Get the cue from the list of songs. /// @@ -143,6 +148,7 @@ namespace StardewSymphonyRemastered.Framework /// public override void stopSong() { + if(Game1.currentSong!=null) Game1.currentSong.Stop(AudioStopOptions.Immediate); if (this.currentCue == null) return; else { diff --git a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/StardewSymphony.cs b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/StardewSymphony.cs index edbd4fa8..d8e22620 100644 --- a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/StardewSymphony.cs +++ b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/StardewSymphony.cs @@ -67,6 +67,8 @@ namespace StardewSymphonyRemastered WavMusicDirectory = Path.Combine(MusicPath, "Wav"); XACTMusicDirectory = Path.Combine(MusicPath, "XACT"); TemplateMusicDirectory = Path.Combine(MusicPath, "Templates"); + + textureManager = new TextureManager(); this.createDirectories(); this.createBlankXACTTemplate(); diff --git a/GeneralMods/StardustCore/UIUtilities/MenuComponents/Button.cs b/GeneralMods/StardustCore/UIUtilities/MenuComponents/Button.cs index 064022bc..29e2aa14 100644 --- a/GeneralMods/StardustCore/UIUtilities/MenuComponents/Button.cs +++ b/GeneralMods/StardustCore/UIUtilities/MenuComponents/Button.cs @@ -95,9 +95,23 @@ namespace StardustCore.UIUtilities.MenuComponents Utility.drawWithShadow(b, this.texture, new Vector2((float)this.bounds.X + (float)(this.sourceRect.Width / 2) * this.baseScale, (float)this.bounds.Y + (float)(this.sourceRect.Height / 2) * this.baseScale), this.sourceRect, this.textureColor, 0.0f, new Vector2((float)(this.sourceRect.Width / 2), (float)(this.sourceRect.Height / 2)), this.scale, false, layerDepth, -1, -1, 0.35f); else b.Draw(this.texture, new Vector2((float)this.bounds.X + (float)(this.sourceRect.Width / 2) * this.baseScale, (float)this.bounds.Y + (float)(this.sourceRect.Height / 2) * this.baseScale), new Rectangle?(this.sourceRect), this.textureColor, 0.0f, new Vector2((float)(this.sourceRect.Width / 2), (float)(this.sourceRect.Height / 2)), this.scale, SpriteEffects.None, layerDepth); - if (string.IsNullOrEmpty(this.label)) - return; - b.DrawString(Game1.smallFont, this.label, new Vector2((float)(this.bounds.X + this.bounds.Width), (float)this.bounds.Y + ((float)(this.bounds.Height / 2) - Game1.smallFont.MeasureString(this.label).Y / 2f)), this.textColor); + if (string.IsNullOrEmpty(this.label)) { + + } + else { + b.DrawString(Game1.smallFont, this.label, new Vector2((float)(this.bounds.X + this.bounds.Width), (float)this.bounds.Y + ((float)(this.bounds.Height / 2) - Game1.smallFont.MeasureString(this.label).Y / 2f)), this.textColor); + } + + if (this.hoverText=="") + { + + } + else + { + StardustCore.ModCore.ModMonitor.Log("HOVER???"); + b.DrawString(Game1.smallFont, this.hoverText, new Vector2((float)(this.bounds.X + this.bounds.Width), (float)this.bounds.Y + ((float)(this.bounds.Height / 2) - Game1.smallFont.MeasureString(this.label).Y / 2f)), this.textColor); + } + } /// diff --git a/GeneralMods/StardustCore/UIUtilities/MenuComponents/Delegates/DelegatePairing.cs b/GeneralMods/StardustCore/UIUtilities/MenuComponents/Delegates/DelegatePairing.cs index c245d5a6..edb7883f 100644 --- a/GeneralMods/StardustCore/UIUtilities/MenuComponents/Delegates/DelegatePairing.cs +++ b/GeneralMods/StardustCore/UIUtilities/MenuComponents/Delegates/DelegatePairing.cs @@ -14,7 +14,7 @@ namespace StardustCore.UIUtilities.MenuComponents.Delegates public DelegatePairing(Delegates.paramaterDelegate buttonDelegate,List Paramaters) { this.click = buttonDelegate; - if (this.paramaters == null) + if (Paramaters == null) { this.paramaters = new List(); } @@ -26,7 +26,11 @@ namespace StardustCore.UIUtilities.MenuComponents.Delegates public void run() { - this.click.Invoke(this.paramaters); + if (this.click != null) + { + this.click.Invoke(this.paramaters); + } + else return; } } } From 1bbf3f2503ebfc7c51304b1d2d7ca218b5564d1c Mon Sep 17 00:00:00 2001 From: Date: Tue, 20 Mar 2018 23:24:11 -0700 Subject: [PATCH 24/54] Play some randome music and play wav packs. --- .../Content/Graphics/MusicMenu/MusicDisk.png | Bin 0 -> 270 bytes .../Framework/Menus/MusicManagerMenu.cs | 29 +++++++++++++++--- .../Framework/Music/MusicPackMetaData.cs | 5 +-- .../Framework/Music/WavMusicPack.cs | 9 ++++++ .../StardewSymphony.cs | 3 ++ .../IlluminateFramework/Colors.cs | 17 +++++++--- .../UIUtilities/MenuComponents/Button.cs | 14 +++++++-- 7 files changed, 63 insertions(+), 14 deletions(-) create mode 100644 GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Content/Graphics/MusicMenu/MusicDisk.png diff --git a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Content/Graphics/MusicMenu/MusicDisk.png b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Content/Graphics/MusicMenu/MusicDisk.png new file mode 100644 index 0000000000000000000000000000000000000000..d15119d699fc7042eec0e73a5208373a8da6700d GIT binary patch literal 270 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBugD~Uq{1qucLCF%=h?3y^w370~qEv>0#LT=By}Z;C1rt33 zJtM=93Yk-Zit0RF978Pp_xAR3HYkX&$)3F^b2RYI86&IeeewoPP2Imft-DhFzr~vG zT=pHcU)DDsiWQyX4t!A=kfeF^LF+Vzq_tOF-KI6De-7_Z%41l$wd~;U)eM_@{zy*{ zytkd%h^ffDQDf1?O`HOXDv8hMaGr5&RVti!oms&}X~$zbTiNOL1=AO>9O?nOgu&C* K&t;ucLK6UY7GC@S literal 0 HcmV?d00001 diff --git a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Menus/MusicManagerMenu.cs b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Menus/MusicManagerMenu.cs index 6224111d..17471024 100644 --- a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Menus/MusicManagerMenu.cs +++ b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Menus/MusicManagerMenu.cs @@ -29,14 +29,29 @@ namespace StardewSymphonyRemastered.Framework.Menus int rows = 0; foreach(var v in StardewSymphony.musicManager.musicPacks) { - this.buttons.Add(new Button(v.Key, new Rectangle(100+(numOfButtons*100), 100+(rows*100), 64, 64), StardewSymphony.textureManager.getTexture("MusicNote").Copy(StardewSymphony.ModHelper), "", new Rectangle(0, 0, 16, 16), 4f, new StardustCore.Animations.Animation(new Rectangle(0, 0, 16, 16)), Color.White, Color.White, new ButtonFunctionality(new DelegatePairing(displayMusicPack, new List + if (v.Value.musicPackInformation.Icon == null) { + this.buttons.Add(new Button(v.Key, new Rectangle(100 + (numOfButtons * 100), 125 + (rows * 100), 64, 64), StardewSymphony.textureManager.getTexture("MusicDisk"), "", new Rectangle(0, 0, 16, 16), 4f, new StardustCore.Animations.Animation(new Rectangle(0, 0, 16, 16)), StardustCore.IlluminateFramework.Colors.randomColor(), Color.White, new ButtonFunctionality(new DelegatePairing(displayMusicPack, new List + { + (object)v + } + ), null, new DelegatePairing(null, new List(){ (object)v + } + )), false)); } - ),null, new DelegatePairing(null,new List(){ + else + { + this.buttons.Add(new Button(v.Key, new Rectangle(100 + (numOfButtons * 100), 100 + (rows * 100), 64, 64), v.Value.musicPackInformation.Icon, "", new Rectangle(0, 0, 16, 16), 4f, new StardustCore.Animations.Animation(new Rectangle(0, 0, 16, 16)), StardustCore.IlluminateFramework.LightColorsList.Black, Color.White, new ButtonFunctionality(new DelegatePairing(displayMusicPack, new List + { + (object)v + } + ), null, new DelegatePairing(null, new List(){ (object)v + } + )), false)); } - )), false)); + numOfButtons++; if (numOfButtons > 8) { @@ -61,9 +76,13 @@ namespace StardewSymphonyRemastered.Framework.Menus if (v.containsPoint(x, y)) { var pair = (KeyValuePair)v.buttonFunctionality.hover.paramaters[0]; - v.hoverText = pair.Key; + v.hoverText = (string)pair.Key; v.onHover(); - StardewSymphony.ModMonitor.Log(pair.Key); + //StardewSymphony.ModMonitor.Log(pair.Key); + } + else + { + v.hoverText = ""; } } } diff --git a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Music/MusicPackMetaData.cs b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Music/MusicPackMetaData.cs index 73f0966a..dbea8807 100644 --- a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Music/MusicPackMetaData.cs +++ b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Music/MusicPackMetaData.cs @@ -1,4 +1,5 @@ using Microsoft.Xna.Framework.Graphics; +using StardustCore.UIUtilities; using System; using System.Collections.Generic; using System.Linq; @@ -18,7 +19,7 @@ namespace StardewSymphonyRemastered.Framework public string description; public string versionInfo; public string pathToMusicPackIcon; - public Texture2D Icon; + public Texture2DExtended Icon; /// /// Constrctor /// @@ -35,7 +36,7 @@ namespace StardewSymphonyRemastered.Framework this.pathToMusicPackIcon = PathToMusicPackIcon; try { - this.Icon = StardewSymphony.ModHelper.Content.Load(this.pathToMusicPackIcon); + this.Icon = new Texture2DExtended(StardewSymphony.ModHelper, this.pathToMusicPackIcon); } catch(Exception err) { diff --git a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Music/WavMusicPack.cs b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Music/WavMusicPack.cs index d9449ede..a1f665be 100644 --- a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Music/WavMusicPack.cs +++ b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Music/WavMusicPack.cs @@ -1,5 +1,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Audio; +using StardewValley; using System; using System.Collections.Generic; using System.IO; @@ -174,6 +175,14 @@ namespace StardewSymphonyRemastered.Framework dynamicSound.Play(); } + public override void playRandomSong() + { + Random r = Game1.random; + int value=r.Next(0, this.songInformation.listOfSongsWithoutTriggers.Count); + Song s = this.songInformation.listOfSongsWithoutTriggers.ElementAt(value); + this.swapSong(s.name); + } + /// /// Used to resume the currently playing song. /// diff --git a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/StardewSymphony.cs b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/StardewSymphony.cs index d8e22620..de5e977e 100644 --- a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/StardewSymphony.cs +++ b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/StardewSymphony.cs @@ -131,7 +131,10 @@ namespace StardewSymphonyRemastered string path = Path.Combine(ModHelper.DirectoryPath, "Content", "Graphics", "MusicMenu"); if (!Directory.Exists(path)) Directory.CreateDirectory(path); string musicNote = Path.Combine(path, "MusicNote.png"); + string musicCD = Path.Combine(path, "MusicDisk.png"); textureManager.addTexture("MusicNote",new Texture2DExtended(ModHelper,StardustCore.Utilities.getRelativeDirectory("StardewSymphonyRemastered", musicNote))); + textureManager.addTexture("MusicDisk", new Texture2DExtended(ModHelper, StardustCore.Utilities.getRelativeDirectory("StardewSymphonyRemastered", musicCD))); + textureManager.addTexture("MusicCD", new Texture2DExtended(ModHelper, StardustCore.Utilities.getRelativeDirectory("StardewSymphonyRemastered", musicCD))); if (!Directory.Exists(MusicPath)) Directory.CreateDirectory(MusicPath); if (!Directory.Exists(WavMusicDirectory)) Directory.CreateDirectory(WavMusicDirectory); diff --git a/GeneralMods/StardustCore/IlluminateFramework/Colors.cs b/GeneralMods/StardustCore/IlluminateFramework/Colors.cs index d89f33b0..ae723710 100644 --- a/GeneralMods/StardustCore/IlluminateFramework/Colors.cs +++ b/GeneralMods/StardustCore/IlluminateFramework/Colors.cs @@ -313,6 +313,8 @@ namespace StardustCore.IlluminateFramework { public static Dictionary ColorDictionary; + public static Random colorRandomizer; + public static void initializeColors() { ColorDictionary = new Dictionary(); @@ -609,12 +611,19 @@ namespace StardustCore.IlluminateFramework } + /// + /// Generate a random color! Does not need to be inverted to be properly used. + /// + /// public static Color randomColor() { - Random r = new Random(Game1.player.money + Game1.tileSize + Game1.dayOfMonth+(int)Game1.stats.stepsTaken); - int R = r.Next(0, 255); - int G = r.Next(0, 255); - int B = r.Next(0, 255); + if (colorRandomizer == null) + { + colorRandomizer = new Random(Game1.player.money + Game1.tileSize + Game1.dayOfMonth + (int)Game1.stats.stepsTaken); + } + int R = colorRandomizer.Next(0, 255); + int G = colorRandomizer.Next(0, 255); + int B = colorRandomizer.Next(0, 255); int A = 255; return new Color(R, G, B, A); } diff --git a/GeneralMods/StardustCore/UIUtilities/MenuComponents/Button.cs b/GeneralMods/StardustCore/UIUtilities/MenuComponents/Button.cs index 29e2aa14..781d94d8 100644 --- a/GeneralMods/StardustCore/UIUtilities/MenuComponents/Button.cs +++ b/GeneralMods/StardustCore/UIUtilities/MenuComponents/Button.cs @@ -85,7 +85,7 @@ namespace StardustCore.UIUtilities.MenuComponents /// /// /// - public void draw(SpriteBatch b, float layerDepth) + public void draw(SpriteBatch b,Color color ,float layerDepth) { this.animationManager.tickAnimation(); @@ -108,12 +108,20 @@ namespace StardustCore.UIUtilities.MenuComponents } else { - StardustCore.ModCore.ModMonitor.Log("HOVER???"); - b.DrawString(Game1.smallFont, this.hoverText, new Vector2((float)(this.bounds.X + this.bounds.Width), (float)this.bounds.Y + ((float)(this.bounds.Height / 2) - Game1.smallFont.MeasureString(this.label).Y / 2f)), this.textColor); + //Game1.drawDialogueBox(Game1.getMousePosition().X, Game1.getMousePosition().Y, false, false, this.hoverText); + //StardustCore.ModCore.ModMonitor.Log("HOVER???"); + b.DrawString(Game1.smallFont, this.hoverText, new Vector2((float)(this.bounds.X + this.bounds.Width), (float)this.bounds.Y + ((float)(this.bounds.Height) - Game1.smallFont.MeasureString(this.label).Y / 2f)), this.textColor,0f,Vector2.Zero,1f,SpriteEffects.None,layerDepth-0.5f); } } + public new void draw(SpriteBatch b) + { + if (!this.visible) + return; + this.draw(b, Color.White, (float)(0.860000014305115 + (double)this.bounds.Y / 20000.0)); + } + /// /// Swaps if the button is visible or not. Also toggles the animation manager appropriately. /// From def22386c586027a66568cbe3b935ef90e7a87c4 Mon Sep 17 00:00:00 2001 From: Date: Wed, 21 Mar 2018 00:46:00 -0700 Subject: [PATCH 25/54] Got wav music packs working! Just need to figure out the buffer size for the files now. --- .../Framework/Menus/MusicManagerMenu.cs | 1 + .../Framework/Music/MusicPackMetaData.cs | 11 ++++++++++- .../Framework/Music/WavMusicPack.cs | 15 +++++++++++---- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Menus/MusicManagerMenu.cs b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Menus/MusicManagerMenu.cs index 17471024..d4432779 100644 --- a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Menus/MusicManagerMenu.cs +++ b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Menus/MusicManagerMenu.cs @@ -127,6 +127,7 @@ namespace StardewSymphonyRemastered.Framework.Menus { var info=(KeyValuePair)param[0]; StardewSymphony.ModMonitor.Log(info.ToString()); + StardewSymphony.musicManager.swapMusicPacks(info.Key); StardewSymphony.musicManager.playRandomSongFromPack(info.Key); //info.Value.playRandomSong(); } diff --git a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Music/MusicPackMetaData.cs b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Music/MusicPackMetaData.cs index dbea8807..be44030e 100644 --- a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Music/MusicPackMetaData.cs +++ b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Music/MusicPackMetaData.cs @@ -36,7 +36,7 @@ namespace StardewSymphonyRemastered.Framework this.pathToMusicPackIcon = PathToMusicPackIcon; try { - this.Icon = new Texture2DExtended(StardewSymphony.ModHelper, this.pathToMusicPackIcon); + this.Icon = new Texture2DExtended(StardewSymphony.ModHelper, this.pathToMusicPackIcon+".png"); } catch(Exception err) { @@ -59,6 +59,15 @@ namespace StardewSymphonyRemastered.Framework /// public static MusicPackMetaData readFromJson(string path) { + var meta=StardewSymphony.ModHelper.ReadJsonFile(path); + try + { + meta.Icon = new Texture2DExtended(StardewSymphony.ModHelper, meta.pathToMusicPackIcon + ".png"); + } + catch(Exception err) + { + + } return StardewSymphony.ModHelper.ReadJsonFile(path); } diff --git a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Music/WavMusicPack.cs b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Music/WavMusicPack.cs index a1f665be..07dd897a 100644 --- a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Music/WavMusicPack.cs +++ b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Music/WavMusicPack.cs @@ -112,7 +112,7 @@ namespace StardewSymphonyRemastered.Framework byteArray = reader.ReadBytes(dataSize); dynamicSound = new DynamicSoundEffectInstance(sampleRate, (AudioChannels)channels); - count = dynamicSound.GetSampleSizeInBytes(TimeSpan.FromMilliseconds(100)); + count = dynamicSound.GetSampleSizeInBytes(TimeSpan.FromMilliseconds(10000)); dynamicSound.BufferNeeded += new EventHandler(DynamicSound_BufferNeeded); this.currentSong = new Song(p); @@ -120,8 +120,9 @@ namespace StardewSymphonyRemastered.Framework void DynamicSound_BufferNeeded(object sender, EventArgs e) { - dynamicSound.SubmitBuffer(byteArray, position, count / 2); - dynamicSound.SubmitBuffer(byteArray, position + count / 2, count / 2); + dynamicSound.SubmitBuffer(byteArray, position, count); + //dynamicSound.SubmitBuffer(byteArray); + //dynamicSound.SubmitBuffer(byteArray, position + count / 2, count / 2); position += count; if (position + count > byteArray.Length) @@ -197,11 +198,17 @@ namespace StardewSymphonyRemastered.Framework /// public override void stopSong() { + if (Game1.currentSong != null) Game1.currentSong.Stop(AudioStopOptions.Immediate); + if (this.currentSong == null) return; if (dynamicSound != null) { - dynamicSound.Stop(); + dynamicSound.Stop(true); + dynamicSound.BufferNeeded -= new EventHandler(DynamicSound_BufferNeeded); dynamicSound = null; this.currentSong = null; + position = 0; + count = 0; + byteArray = new byte[0]; } } From fd53797c5f4dd15cc5cf799fa840a8839863b4e0 Mon Sep 17 00:00:00 2001 From: Date: Wed, 21 Mar 2018 02:04:05 -0700 Subject: [PATCH 26/54] Wav music packs now work correctly. WOOT! --- .../Framework/Music/WavMusicPack.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Music/WavMusicPack.cs b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Music/WavMusicPack.cs index 07dd897a..1cddc7b1 100644 --- a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Music/WavMusicPack.cs +++ b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Music/WavMusicPack.cs @@ -111,6 +111,7 @@ namespace StardewSymphonyRemastered.Framework byteArray = reader.ReadBytes(dataSize); + dynamicSound = new DynamicSoundEffectInstance(sampleRate, (AudioChannels)channels); count = dynamicSound.GetSampleSizeInBytes(TimeSpan.FromMilliseconds(10000)); @@ -120,7 +121,18 @@ namespace StardewSymphonyRemastered.Framework void DynamicSound_BufferNeeded(object sender, EventArgs e) { - dynamicSound.SubmitBuffer(byteArray, position, count); + //StardewSymphony.ModMonitor.Log(byteArray.Length.ToString()); + //StardewSymphony.ModMonitor.Log(position.ToString()); + //StardewSymphony.ModMonitor.Log(count.ToString()); + try + { + dynamicSound.SubmitBuffer(byteArray, position, count); + } + catch(Exception err) + { + StardewSymphony.ModMonitor.Log(err.ToString(), StardewModdingAPI.LogLevel.Error); + } + //dynamicSound.SubmitBuffer(byteArray); //dynamicSound.SubmitBuffer(byteArray, position + count / 2, count / 2); From dad514a6d63f5bf27d369f53824d1e23935546fd Mon Sep 17 00:00:00 2001 From: Date: Wed, 21 Mar 2018 13:02:50 -0700 Subject: [PATCH 27/54] Symphony now takes priority over StardewValley music. Can be changed simply by adding in a StardewValley Music Pack. Also Music Album Icons! --- .../Framework/Menus/MusicManagerMenu.cs | 2 +- .../Framework/Music/MusicPackMetaData.cs | 17 ++++++++--- .../Framework/Music/WavMusicPack.cs | 7 +++-- .../Framework/Music/XACTMusicPack.cs | 2 +- .../StardewSymphony.cs | 30 +++++++++++++++++++ 5 files changed, 49 insertions(+), 9 deletions(-) diff --git a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Menus/MusicManagerMenu.cs b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Menus/MusicManagerMenu.cs index d4432779..301b6709 100644 --- a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Menus/MusicManagerMenu.cs +++ b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Menus/MusicManagerMenu.cs @@ -42,7 +42,7 @@ namespace StardewSymphonyRemastered.Framework.Menus } else { - this.buttons.Add(new Button(v.Key, new Rectangle(100 + (numOfButtons * 100), 100 + (rows * 100), 64, 64), v.Value.musicPackInformation.Icon, "", new Rectangle(0, 0, 16, 16), 4f, new StardustCore.Animations.Animation(new Rectangle(0, 0, 16, 16)), StardustCore.IlluminateFramework.LightColorsList.Black, Color.White, new ButtonFunctionality(new DelegatePairing(displayMusicPack, new List + this.buttons.Add(new Button(v.Key, new Rectangle(100 + (numOfButtons * 100), 125 + (rows * 100), 64, 64), v.Value.musicPackInformation.Icon, "", new Rectangle(0, 0, 16, 16), 4f, new StardustCore.Animations.Animation(new Rectangle(0, 0, 16, 16)), StardustCore.IlluminateFramework.LightColorsList.Black, Color.White, new ButtonFunctionality(new DelegatePairing(displayMusicPack, new List { (object)v } diff --git a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Music/MusicPackMetaData.cs b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Music/MusicPackMetaData.cs index be44030e..7eb428e8 100644 --- a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Music/MusicPackMetaData.cs +++ b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Music/MusicPackMetaData.cs @@ -2,6 +2,7 @@ using StardustCore.UIUtilities; using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -59,16 +60,24 @@ namespace StardewSymphonyRemastered.Framework /// public static MusicPackMetaData readFromJson(string path) { - var meta=StardewSymphony.ModHelper.ReadJsonFile(path); + string json = Path.Combine(path, "MusicPackInformation.json"); + var meta=StardewSymphony.ModHelper.ReadJsonFile(json); try { - meta.Icon = new Texture2DExtended(StardewSymphony.ModHelper, meta.pathToMusicPackIcon + ".png"); + try + { + meta.Icon = new Texture2DExtended(StardewSymphony.ModHelper, StardewSymphony.getRelativeDirectory(Path.Combine(path, meta.pathToMusicPackIcon + ".png"))); + } + catch(Exception errr) + { + meta.Icon = new Texture2DExtended(StardewSymphony.ModHelper, StardewSymphony.getRelativeDirectory(Path.Combine(path, meta.pathToMusicPackIcon))); + } } catch(Exception err) { - + //StardewSymphony.ModMonitor.Log(err.ToString()); } - return StardewSymphony.ModHelper.ReadJsonFile(path); + return meta; } /// diff --git a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Music/WavMusicPack.cs b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Music/WavMusicPack.cs index 1cddc7b1..ab22a960 100644 --- a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Music/WavMusicPack.cs +++ b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Music/WavMusicPack.cs @@ -45,13 +45,14 @@ namespace StardewSymphonyRemastered.Framework this.setModDirectoryFromFullDirectory(); this.songsDirectory = Path.Combine(this.directory, "Songs"); this.songInformation = new SongSpecifics(); - this.musicPackInformation = MusicPackMetaData.readFromJson(Path.Combine(directoryToMusicPack, "MusicPackInformation.json")); + this.musicPackInformation = MusicPackMetaData.readFromJson(directoryToMusicPack); if (this.musicPackInformation == null) { - StardewSymphony.ModMonitor.Log("Error: MusicPackInformation.json not found at: " + directoryToMusicPack + ". Blank information will be put in place.", StardewModdingAPI.LogLevel.Warn); - this.musicPackInformation = new MusicPackMetaData("???", "???", "", "0.0.0",""); + //StardewSymphony.ModMonitor.Log("Error: MusicPackInformation.json not found at: " + directoryToMusicPack + ". Blank information will be put in place.", StardewModdingAPI.LogLevel.Warn); + //this.musicPackInformation = new MusicPackMetaData("???", "???", "", "0.0.0",""); } + StardewSymphony.ModMonitor.Log(this.musicPackInformation.name.ToString()); this.loadMusicFiles(); } diff --git a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Music/XACTMusicPack.cs b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Music/XACTMusicPack.cs index 4060a873..b01cb918 100644 --- a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Music/XACTMusicPack.cs +++ b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Music/XACTMusicPack.cs @@ -37,7 +37,7 @@ namespace StardewSymphonyRemastered.Framework this.setModDirectoryFromFullDirectory(); this.songInformation = new SongSpecifics(); this.currentCue = null; - this.musicPackInformation = MusicPackMetaData.readFromJson(Path.Combine(directoryToXwb, "MusicPackInformation.json")); + this.musicPackInformation = MusicPackMetaData.readFromJson(directoryToXwb); if (this.musicPackInformation == null) { StardewSymphony.ModMonitor.Log("Error: MusicPackInformation.json not found at: " + directoryToXwb + ". Blank information will be put in place.",StardewModdingAPI.LogLevel.Warn); diff --git a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/StardewSymphony.cs b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/StardewSymphony.cs index de5e977e..aa3ad050 100644 --- a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/StardewSymphony.cs +++ b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/StardewSymphony.cs @@ -105,6 +105,7 @@ namespace StardewSymphonyRemastered /// private void GameEvents_UpdateTick(object sender, EventArgs e) { + if (Game1.currentSong != null) Game1.currentSong.Stop(AudioStopOptions.Immediate); if (musicPacksInitialized == false) { initializeMusicPacks(); @@ -299,6 +300,35 @@ namespace StardewSymphonyRemastered Game1.soundBank = DefaultSoundBank; } + /// + /// 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); + try + { + return spliter[1]; + } + catch (Exception err) + { + return spliter[0]; + } + } + + /// + /// Used to finish cleaning up absolute asset paths into a shortened relative path. + /// + /// + /// + public static string getRelativeDirectory(string path) + { + string s = getShortenedDirectory(path); + return s.Remove(0, 1); + } } } From 6ef666af6ef84e83d762e5581fcbb3e5a302e8d8 Mon Sep 17 00:00:00 2001 From: Date: Fri, 30 Mar 2018 05:46:24 -0700 Subject: [PATCH 28/54] Colored background menus for UIUtilities, and a fancier menu for Symphony. --- .../Framework/Menus/MusicManagerMenu.cs | 303 ++++++++++-- .../Framework/Music/SongSpecifics.cs | 4 +- .../StardewSymphony.cs | 7 +- GeneralMods/StardustCore/Enums/Directions.cs | 55 +++ GeneralMods/StardustCore/Enums/Weather.cs | 23 + GeneralMods/StardustCore/ModCore.cs | 3 +- GeneralMods/StardustCore/StardustCore.csproj | 2 + GeneralMods/StardustCore/StaticClass.cs | 35 ++ .../UIUtilities/IClickableMenuExtended.cs | 446 +++++++++++++++++- .../UIUtilities/MenuComponents/Button.cs | 46 +- .../Fonts/Components/TexturedString.cs | 4 +- .../SpriteFonts/Fonts/VanillaFont.cs | 4 +- .../UIUtilities/SpriteFonts/SpriteFont.cs | 3 +- GeneralMods/StardustCore/Utilities.cs | 13 + 14 files changed, 901 insertions(+), 47 deletions(-) create mode 100644 GeneralMods/StardustCore/Enums/Directions.cs create mode 100644 GeneralMods/StardustCore/Enums/Weather.cs diff --git a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Menus/MusicManagerMenu.cs b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Menus/MusicManagerMenu.cs index 301b6709..f050ccdd 100644 --- a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Menus/MusicManagerMenu.cs +++ b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/Menus/MusicManagerMenu.cs @@ -10,20 +10,50 @@ using StardustCore.UIUtilities; 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 { + public class MusicManagerMenu : IClickableMenuExtended { + public enum DrawMode + { + AlbumSelection, + SongSelection, + AlbumFancySelection, + } + + public List