From 49090c98fcdc11ca536de42875f50b763e83ce63 Mon Sep 17 00:00:00 2001 From: ClxS Date: Sun, 6 Mar 2016 23:28:32 +0000 Subject: Fixed mod content path not being set correctly. Fixed object draw code. Custom objects can now be placed and show up correctly. --- StardewModdingAPI/Entities/SCharacter.cs | 12 ++++++++++ StardewModdingAPI/Entities/SFarm.cs | 12 ++++++++++ StardewModdingAPI/Entities/SFarmAnimal.cs | 12 ++++++++++ StardewModdingAPI/Entities/SNpc.cs | 12 ++++++++++ StardewModdingAPI/Entities/SPlayer.cs | 37 ++++++++++++++++++++++++++++++ StardewModdingAPI/Inheritance/SObject.cs | 13 ++++++----- StardewModdingAPI/Program.cs | 28 +++++++++++----------- StardewModdingAPI/StardewModdingAPI.csproj | 8 +++++++ 8 files changed, 114 insertions(+), 20 deletions(-) create mode 100644 StardewModdingAPI/Entities/SCharacter.cs create mode 100644 StardewModdingAPI/Entities/SFarm.cs create mode 100644 StardewModdingAPI/Entities/SFarmAnimal.cs create mode 100644 StardewModdingAPI/Entities/SNpc.cs create mode 100644 StardewModdingAPI/Entities/SPlayer.cs (limited to 'StardewModdingAPI') diff --git a/StardewModdingAPI/Entities/SCharacter.cs b/StardewModdingAPI/Entities/SCharacter.cs new file mode 100644 index 00000000..740a6d7f --- /dev/null +++ b/StardewModdingAPI/Entities/SCharacter.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StardewModdingAPI.Entities +{ + class SCharacter + { + } +} diff --git a/StardewModdingAPI/Entities/SFarm.cs b/StardewModdingAPI/Entities/SFarm.cs new file mode 100644 index 00000000..5d1647a8 --- /dev/null +++ b/StardewModdingAPI/Entities/SFarm.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StardewModdingAPI.Entities +{ + class SFarm + { + } +} diff --git a/StardewModdingAPI/Entities/SFarmAnimal.cs b/StardewModdingAPI/Entities/SFarmAnimal.cs new file mode 100644 index 00000000..0f768f6a --- /dev/null +++ b/StardewModdingAPI/Entities/SFarmAnimal.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StardewModdingAPI.Entities +{ + class SFarmAnimal + { + } +} diff --git a/StardewModdingAPI/Entities/SNpc.cs b/StardewModdingAPI/Entities/SNpc.cs new file mode 100644 index 00000000..02242d20 --- /dev/null +++ b/StardewModdingAPI/Entities/SNpc.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StardewModdingAPI.Entities +{ + class SNpc + { + } +} diff --git a/StardewModdingAPI/Entities/SPlayer.cs b/StardewModdingAPI/Entities/SPlayer.cs new file mode 100644 index 00000000..ae4e9472 --- /dev/null +++ b/StardewModdingAPI/Entities/SPlayer.cs @@ -0,0 +1,37 @@ +using StardewModdingAPI.Inheritance; +using StardewValley; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StardewModdingAPI.Entities +{ + public static class SPlayer + { + public static List AllFarmers + { + get + { + return SGame.getAllFarmers(); + } + } + + public static Farmer CurrentFarmer + { + get + { + return SGame.player; + } + } + + public static GameLocation CurrentFarmerLocation + { + get + { + return SGame.player.currentLocation; + } + } + } +} diff --git a/StardewModdingAPI/Inheritance/SObject.cs b/StardewModdingAPI/Inheritance/SObject.cs index 28254c24..3dcddb9e 100644 --- a/StardewModdingAPI/Inheritance/SObject.cs +++ b/StardewModdingAPI/Inheritance/SObject.cs @@ -65,17 +65,18 @@ namespace StardewModdingAPI.Inheritance } public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1) - { + { if (Texture != null) { - int targSize = Game1.tileSize; - - Vector2 local = Game1.GlobalToLocal(Game1.viewport, new Vector2(x,y)); - Rectangle targ = new Rectangle((int)local.X, (int)local.Y, targSize, targSize); - spriteBatch.Draw(Texture, targ, null, new Color(255, 255, 255, 255f * alpha)); + spriteBatch.Draw(Texture, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(((x * Game1.tileSize) + (Game1.tileSize / 2)) + ((this.shakeTimer > 0) ? Game1.random.Next(-1, 2) : 0)), (float)(((y * Game1.tileSize) + (Game1.tileSize / 2)) + ((this.shakeTimer > 0) ? Game1.random.Next(-1, 2) : 0)))), new Rectangle?(Game1.currentLocation.getSourceRectForObject(this.ParentSheetIndex)), (Color)(Color.White * alpha), 0f, new Vector2(8f, 8f), (this.scale.Y > 1f) ? this.getScale().Y : ((float)Game1.pixelZoom), this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, (this.isPassable() ? ((float)this.getBoundingBox(new Vector2((float)x, (float)y)).Top) : ((float)this.getBoundingBox(new Vector2((float)x, (float)y)).Bottom)) / 10000f); } } + public void drawAsProp(SpriteBatch b) + { + + } + public override void draw(SpriteBatch spriteBatch, int xNonTile, int yNonTile, float layerDepth, float alpha = 1) { Log.Debug("THIS DRAW FUNCTION IS NOT IMPLEMENTED I WANT TO KNOW WHERE IT IS CALLED"); diff --git a/StardewModdingAPI/Program.cs b/StardewModdingAPI/Program.cs index f1ccd936..61770f8e 100644 --- a/StardewModdingAPI/Program.cs +++ b/StardewModdingAPI/Program.cs @@ -89,7 +89,7 @@ namespace StardewModdingAPI //TODO: Have an app.config and put the paths inside it so users can define locations to load mods from _modPaths.Add(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "StardewValley", "Mods")); _modPaths.Add(Path.Combine(Constants.ExecutionPath, "Mods")); - _modPaths.Add(Path.Combine(Constants.ExecutionPath, "Mods", "Content")); + _modContentPaths.Add(Path.Combine(Constants.ExecutionPath, "Mods", "Content")); _modContentPaths.Add(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "StardewValley", "Mods", "Content")); //Checks that all defined modpaths exist as directories @@ -359,25 +359,25 @@ namespace StardewModdingAPI DebugPixel.SetData(new Color[] { Color.White }); #if DEBUG - Log.Verbose("REGISTERING BASE CUSTOM ITEM"); + StardewModdingAPI.Log.Verbose("REGISTERING BASE CUSTOM ITEM"); SObject so = new SObject(); so.Name = "Mario Block"; so.CategoryName = "SMAPI Test Mod"; so.Description = "It's a block from Mario!\nLoaded in realtime by SMAPI."; - so.Texture = Texture2D.FromStream(Game1.graphics.GraphicsDevice, new FileStream(ModContentPaths[0] + "\\Test.png", FileMode.Open)); + so.Texture = Texture2D.FromStream(Game1.graphics.GraphicsDevice, new FileStream(_modContentPaths[0] + "\\Test.png", FileMode.Open)); so.IsPassable = true; so.IsPlaceable = true; - Log.Verbose("REGISTERED WITH ID OF: " + SGame.RegisterModItem(so)); - - Log.Verbose("REGISTERING SECOND CUSTOM ITEM"); - SObject so2 = new SObject(); - so2.Name = "Mario Painting"; - so2.CategoryName = "SMAPI Test Mod"; - so2.Description = "It's a painting of a creature from Mario!\nLoaded in realtime by SMAPI."; - so2.Texture = Texture2D.FromStream(Game1.graphics.GraphicsDevice, new FileStream(ModContentPaths[0] + "\\PaintingTest.png", FileMode.Open)); - so2.IsPassable = true; - so2.IsPlaceable = true; - Log.Verbose("REGISTERED WITH ID OF: " + SGame.RegisterModItem(so2)); + StardewModdingAPI.Log.Verbose("REGISTERED WITH ID OF: " + SGame.RegisterModItem(so)); + + //StardewModdingAPI.Log.Verbose("REGISTERING SECOND CUSTOM ITEM"); + //SObject so2 = new SObject(); + //so2.Name = "Mario Painting"; + //so2.CategoryName = "SMAPI Test Mod"; + //so2.Description = "It's a painting of a creature from Mario!\nLoaded in realtime by SMAPI."; + //so2.Texture = Texture2D.FromStream(Game1.graphics.GraphicsDevice, new FileStream(_modContentPaths[0] + "\\PaintingTest.png", FileMode.Open)); + //so2.IsPassable = true; + //so2.IsPlaceable = true; + //StardewModdingAPI.Log.Verbose("REGISTERED WITH ID OF: " + SGame.RegisterModItem(so2)); Command.CallCommand("load"); #endif diff --git a/StardewModdingAPI/StardewModdingAPI.csproj b/StardewModdingAPI/StardewModdingAPI.csproj index 6d70b1c5..5b962d44 100644 --- a/StardewModdingAPI/StardewModdingAPI.csproj +++ b/StardewModdingAPI/StardewModdingAPI.csproj @@ -61,6 +61,9 @@ x86 bin\x86\Debug\ false + + + true x86 @@ -99,6 +102,11 @@ + + + + + -- cgit