# HG changeset patch # User alys # Date 2021-04-18 03:12:25 # Node ID f687e82000f059e7f08b8e53e02733fa7ea897b9 # Parent ccc3fe5b98d31b5322281227aceb9ef2968ce31c Add culling toggle and more logging. diff --git a/README.mkd b/README.mkd --- a/README.mkd +++ b/README.mkd @@ -22,6 +22,10 @@ You can build and run the project using VSCode actions. +Two debug commands: +* `\` enables the debug window +* `]` turns on culling (now debug-only) + ## Acknowledgements ## Art: [Isometric 64x64 Outside Tileset by Yar](https://opengameart.org/content/isometric-64x64-outside-tileset), various images from the Library of Congress and USDA Forest Service diff --git a/isometric-park-fna/Engines/GameBridgeEngine.cs b/isometric-park-fna/Engines/GameBridgeEngine.cs --- a/isometric-park-fna/Engines/GameBridgeEngine.cs +++ b/isometric-park-fna/Engines/GameBridgeEngine.cs @@ -50,6 +50,9 @@ case Element.Trees: game.showTrees = !game.showTrees; break; + case Element.Culling: + FNAGame.enableCulling = !FNAGame.enableCulling; + break; } } diff --git a/isometric-park-fna/Engines/InputEngine.cs b/isometric-park-fna/Engines/InputEngine.cs --- a/isometric-park-fna/Engines/InputEngine.cs +++ b/isometric-park-fna/Engines/InputEngine.cs @@ -159,6 +159,11 @@ SendMessage(new ToggleVisibilityMessage{Element = Element.Trees}); } + if (keyboardCur.IsKeyDown(Keys.OemCloseBrackets) && keyboardPrev.IsKeyUp(Keys.OemCloseBrackets)) + { + SendMessage(new ToggleVisibilityMessage{Element = Element.Culling}); + + } #endif if (keyboardCur.IsKeyDown(Keys.Q) && keyboardPrev.IsKeyUp(Keys.Q)) diff --git a/isometric-park-fna/FNAGame.cs b/isometric-park-fna/FNAGame.cs --- a/isometric-park-fna/FNAGame.cs +++ b/isometric-park-fna/FNAGame.cs @@ -48,6 +48,7 @@ Queue past_fps = new Queue(100); int tilesDrawn = 0; + private int treesDrawn = 0; private const int width = 1280; private const int height = 640; @@ -74,7 +75,7 @@ int messageIndex; //buggy - private static bool enableCulling = false; + public static bool enableCulling = false; private Node currentNode; private Queue> remainingDialog; @@ -707,11 +708,11 @@ Quad.FillSquare2(batch, 8, 5, Color.Teal, .5f, 0.79f); Quad.FillSquare2(batch, 8, 6, Color.Teal, .25f, 0.79f); Quad.FillSquare2(batch, 8, 7, Color.Teal, .125f, 0.79f); -#endif +#endif -#endregion draw_cursor + #endregion draw_cursor /* for (int i = 0; i< 80; i++) @@ -733,7 +734,9 @@ } }//*/ -#region draw_trees + #region draw_trees + + this.treesDrawn = 0; if (this.showTrees) { for (int i = 0; i < this.simulation.map.MapHeight; i++) { @@ -751,11 +754,12 @@ // { // drawTileAt(i, j, 142, 2); // } + this.treesDrawn++; } else if (this.simulation.map.cells[i][j].status == CellStatus.DeadTree) { drawTileAt(i, j, 141, 2); // System.Console.WriteLine(String.Format("Drew Dead Tree at {0},{1}", i, j)); - + this.treesDrawn++; } } } @@ -853,7 +857,8 @@ treeCount = this.simulation.map.tree_count, mouseGrid = this.mouseGrid, hasTree = has_tree, - tilesDrawn = this.tilesDrawn + tilesDrawn = this.tilesDrawn, + treesDrawn = this.treesDrawn }; //Finally, draw the debug window @@ -865,6 +870,8 @@ var state = Mouse.GetState(); Vector2 delta = this.camera.position - this.original_point; + additionalInfo.Add("culling", FNAGame.enableCulling.ToString()); + additionalInfo.Add("cameraMiddle", cameraMiddle.ToString()); additionalInfo.Add("mouse ", String.Format("{0}, {1}", state.X, state.Y)); additionalInfo.Add("mouse delta", delta.ToString()); diff --git a/isometric-park-fna/Messages/ToggleVisibilityMessage.cs b/isometric-park-fna/Messages/ToggleVisibilityMessage.cs --- a/isometric-park-fna/Messages/ToggleVisibilityMessage.cs +++ b/isometric-park-fna/Messages/ToggleVisibilityMessage.cs @@ -5,8 +5,10 @@ public enum Element { Grid, - Trees - } + Trees, + + Culling //Debug only + } public struct ToggleVisibilityMessage : IMessage//, IHasEntity { diff --git a/isometric-park-fna/Simulation.cs b/isometric-park-fna/Simulation.cs --- a/isometric-park-fna/Simulation.cs +++ b/isometric-park-fna/Simulation.cs @@ -58,7 +58,7 @@ public const int MAX_TREES_TO_PLANT = 25; public const int MAX_TREES_TO_CLEAR = 25; - private const int SUBSIDY_AMOUNT = 2000; + private const int SUBSIDY_AMOUNT = 3000; public int Tick { diff --git a/isometric-park-fna/UI/DebugWindow.cs b/isometric-park-fna/UI/DebugWindow.cs --- a/isometric-park-fna/UI/DebugWindow.cs +++ b/isometric-park-fna/UI/DebugWindow.cs @@ -22,6 +22,7 @@ public Boolean hasTree; public int tilesDrawn; public TimeSpan updateTime; + public int treesDrawn; } public class DebugWindow @@ -134,6 +135,7 @@ ImGui.Text(string.Format("Draw Time: {0:F3}", debugInfo.drawTime.TotalMilliseconds.ToString())); ImGui.Text(string.Format("Update Time: {0:F3}", debugInfo.updateTime.TotalMilliseconds.ToString())); ImGui.Text(string.Format("Tiles Drawn: {0:F}", debugInfo.tilesDrawn)); + ImGui.Text(string.Format("Trees Drawn: {0:F}", debugInfo.treesDrawn)); ImGui.Text(string.Format("\nCamera Position: {0}", debugInfo.cameraPosition.ToString()));