diff --git a/Release/StardewModdingAPI.exe b/Release/StardewModdingAPI.exe index 620cc96d..f804204f 100644 Binary files a/Release/StardewModdingAPI.exe and b/Release/StardewModdingAPI.exe differ diff --git a/StardewModdingAPI/Inheritance/SGame.cs b/StardewModdingAPI/Inheritance/SGame.cs index b549aaf4..9f30e05e 100644 --- a/StardewModdingAPI/Inheritance/SGame.cs +++ b/StardewModdingAPI/Inheritance/SGame.cs @@ -107,9 +107,13 @@ namespace StardewModdingAPI.Inheritance { base.Draw(gameTime); Events.InvokeDrawTick(); - spriteBatch.Begin(SpriteSortMode.FrontToBack, BlendState.AlphaBlend, SamplerState.PointClamp, (DepthStencilState)null, (RasterizerState)null); + spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Opaque, SamplerState.PointClamp, DepthStencilState.DepthRead, RasterizerState.CullNone); if (CurrentLocation != null) CurrentLocation.draw(Game1.spriteBatch); + + if (player != null && player.position != null) + spriteBatch.DrawString(Game1.dialogueFont, Game1.player.position.ToString(), new Vector2(0, 180), Color.Orange); + spriteBatch.End(); } diff --git a/StardewModdingAPI/Inheritance/SGameLocation.cs b/StardewModdingAPI/Inheritance/SGameLocation.cs index f4523c21..82caab40 100644 --- a/StardewModdingAPI/Inheritance/SGameLocation.cs +++ b/StardewModdingAPI/Inheritance/SGameLocation.cs @@ -83,7 +83,7 @@ namespace StardewModdingAPI.Inheritance { foreach (var v in ModObjects) { - v.Value.draw(b, (int)v.Key.X, (int)v.Key.Y, -999999, 1); + v.Value.draw(b, (int)v.Key.X, (int)v.Key.Y, 0.999f, 1); } } } diff --git a/StardewModdingAPI/Inheritance/SObject.cs b/StardewModdingAPI/Inheritance/SObject.cs index e05b4f20..79edcb34 100644 --- a/StardewModdingAPI/Inheritance/SObject.cs +++ b/StardewModdingAPI/Inheritance/SObject.cs @@ -48,16 +48,38 @@ namespace StardewModdingAPI.Inheritance public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1) { + if (Texture != null) spriteBatch.Draw(Texture, new Vector2(x, y), new Color(255, 255, 255, 255f * alpha)); } public override void draw(SpriteBatch spriteBatch, int xNonTile, int yNonTile, float layerDepth, float alpha = 1) { - if (Texture != null) + try { - spriteBatch.Draw(Texture, new Vector2(xNonTile, yNonTile), null, new Color(255, 255, 255, 255f * alpha), 0, Vector2.Zero, 1, SpriteEffects.None, layerDepth); - spriteBatch.DrawString(Game1.dialogueFont, "TARG: " + new Vector2(xNonTile, yNonTile), new Vector2(128, 0), Color.Red); + if (Texture != null) + { + int targSize = 64; + int midX = (int) ((xNonTile) + 32); + int midY = (int) ((yNonTile) + 32); + + int targX = midX - targSize / 2; + int targY = midY - targSize / 2; + + Rectangle targ = new Rectangle(targX, targY, targSize, targSize); + spriteBatch.Draw(Texture, targ, null, new Color(255, 255, 255, 255f * alpha), 0, Vector2.Zero, SpriteEffects.None, layerDepth); + spriteBatch.Draw(Program.DebugPixel, targ, null, Color.Red, 0, Vector2.Zero, SpriteEffects.None, layerDepth); + spriteBatch.DrawString(Game1.dialogueFont, "TARG: " + targ, new Vector2(128, 0), Color.Red); + spriteBatch.DrawString(Game1.dialogueFont, ".", new Vector2(targX * 0.5f, targY), Color.Orange); + spriteBatch.DrawString(Game1.dialogueFont, ".", new Vector2(targX, targY), Color.Red); + spriteBatch.DrawString(Game1.dialogueFont, ".", new Vector2(targX * 1.5f, targY), Color.Yellow); + spriteBatch.DrawString(Game1.dialogueFont, ".", new Vector2(targX * 2f, targY), Color.Green); + } + } + catch (Exception ex) + { + Program.LogError(ex.ToString()); + Console.ReadKey(); } } @@ -170,10 +192,11 @@ namespace StardewModdingAPI.Inheritance if (s != null) { - Vector2 index1 = new Vector2((float)(x / Game1.tileSize), (float)(y / Game1.tileSize)); + Vector2 index1 = new Vector2(x - (Game1.tileSize / 2), y - (Game1.tileSize / 2)); if (!s.ModObjects.ContainsKey(index1)) { s.ModObjects.Add(index1, this); + Game1.player.position = index1; return true; } } diff --git a/StardewModdingAPI/Program.cs b/StardewModdingAPI/Program.cs index 8109d99f..b0c30f91 100644 --- a/StardewModdingAPI/Program.cs +++ b/StardewModdingAPI/Program.cs @@ -34,6 +34,8 @@ namespace StardewModdingAPI public static string CurrentLog { get; private set; } public static StreamWriter LogStream { get; private set; } + public static Texture2D DebugPixel { get; private set; } + public static SGame gamePtr; public static bool ready; @@ -256,6 +258,10 @@ namespace StardewModdingAPI static void Events_LoadContent() { + LogInfo("Initializing Debug Assets..."); + DebugPixel = new Texture2D(Game1.graphics.GraphicsDevice, 1, 1); + DebugPixel.SetData(new Color[] { Color.White }); + LogColour(ConsoleColor.Magenta, "REGISTERING BASE CUSTOM ITEM"); SObject so = new SObject(); so.Name = "Mario Block"; diff --git a/StardewModdingAPI/StardewModdingAPI.csproj b/StardewModdingAPI/StardewModdingAPI.csproj index 42c604a2..40435f9c 100644 --- a/StardewModdingAPI/StardewModdingAPI.csproj +++ b/StardewModdingAPI/StardewModdingAPI.csproj @@ -59,6 +59,7 @@ + diff --git a/StardewModdingAPI/obj/x86/Debug/StardewModdingAPI.csproj.FileListAbsolute.txt b/StardewModdingAPI/obj/x86/Debug/StardewModdingAPI.csproj.FileListAbsolute.txt index 83b3576c..946fda5a 100644 --- a/StardewModdingAPI/obj/x86/Debug/StardewModdingAPI.csproj.FileListAbsolute.txt +++ b/StardewModdingAPI/obj/x86/Debug/StardewModdingAPI.csproj.FileListAbsolute.txt @@ -26,11 +26,10 @@ C:\Users\zoryn\Desktop\SDV\StardewModdingAPI\StardewModdingAPI\obj\x86\Debug\Sta C:\TFSource\Master-Collection\StardewModdingAPI\StardewModdingAPI\bin\x86\Debug\StardewModdingAPI.exe.config C:\TFSource\Master-Collection\StardewModdingAPI\StardewModdingAPI\bin\x86\Debug\StardewModdingAPI.exe C:\TFSource\Master-Collection\StardewModdingAPI\StardewModdingAPI\bin\x86\Debug\StardewModdingAPI.pdb +C:\TFSource\Master-Collection\StardewModdingAPI\StardewModdingAPI\bin\x86\Debug\Microsoft.QualityTools.Testing.Fakes.dll C:\TFSource\Master-Collection\StardewModdingAPI\StardewModdingAPI\bin\x86\Debug\Stardew Valley.exe C:\TFSource\Master-Collection\StardewModdingAPI\StardewModdingAPI\bin\x86\Debug\xTile.dll C:\TFSource\Master-Collection\StardewModdingAPI\StardewModdingAPI\bin\x86\Debug\Lidgren.Network.dll C:\TFSource\Master-Collection\StardewModdingAPI\StardewModdingAPI\bin\x86\Debug\Steamworks.NET.dll C:\TFSource\Master-Collection\StardewModdingAPI\StardewModdingAPI\obj\x86\Debug\StardewModdingAPI.exe C:\TFSource\Master-Collection\StardewModdingAPI\StardewModdingAPI\obj\x86\Debug\StardewModdingAPI.pdb -C:\TFSource\Master-Collection\StardewModdingAPI\StardewModdingAPI\obj\x86\Debug\StardewModdingAPI.csprojResolveAssemblyReference.cache -C:\TFSource\Master-Collection\StardewModdingAPI\StardewModdingAPI\bin\x86\Debug\Microsoft.QualityTools.Testing.Fakes.dll