diff --git a/isometric-park-fna/CellMap.cs b/isometric-park-fna/CellMap.cs --- a/isometric-park-fna/CellMap.cs +++ b/isometric-park-fna/CellMap.cs @@ -13,7 +13,7 @@ public int ZoneWidth = 10; public int ZoneHeight = 10; - + public int MapMultiplier; //Adjusts for larger maps. @@ -46,7 +46,6 @@ } } - public CellMap() { //TileMap(MapWidth, MapHeight); @@ -61,7 +60,6 @@ this.MapMultiplier = (int)(((this.MapWidth / 50) + (this.MapHeight / 50)) / 2); - for (int i = 0; i < height; i++) { List newRow = new List(); @@ -210,7 +208,6 @@ GenericEvergreen, GenericDeciduous, GenericShrub - } public class Cell diff --git a/isometric-park-fna/Engines/SimulationBridgeEngine.cs b/isometric-park-fna/Engines/SimulationBridgeEngine.cs --- a/isometric-park-fna/Engines/SimulationBridgeEngine.cs +++ b/isometric-park-fna/Engines/SimulationBridgeEngine.cs @@ -172,7 +172,7 @@ } else if (delta.deltaTrees.Value > 0) { - var random_type = random_generator.Next(0, 3); + var random_type = random_generator.Next(0, 3); cell.AddTree(this.simulation.DateTime, (CellMap.TreeType)random_type); added++; } diff --git a/isometric-park-fna/Engines/Spawners/ContractSpawner.cs b/isometric-park-fna/Engines/Spawners/ContractSpawner.cs --- a/isometric-park-fna/Engines/Spawners/ContractSpawner.cs +++ b/isometric-park-fna/Engines/Spawners/ContractSpawner.cs @@ -24,7 +24,6 @@ private Random random_generator; public const int DEFAULT_MIN_SQUARES = 75; - // public const int DEFAULT_SQUARES = 25; public const int DEFAULT_SQUARES = 100; public const int CONTRACT_MINIMUM = 50; public const int CONTRACT_MAXIMUM = 400; @@ -32,7 +31,7 @@ private int MapWidth; private int MapHeight; - private int MapMultiplier; //Adjustment factor for larger maps + private int MapMultiplier; //Adjustment factor for larger maps private Simulation simulation; private Grammar grammar; @@ -48,7 +47,8 @@ this.simulation = simulation; this.grammar = grammar; - this.MapMultiplier = this.simulation.map.MapMultiplier; } + this.MapMultiplier = this.simulation.map.MapMultiplier; + } private Vector2 FindStart(HashSet occupied_squares) { @@ -63,7 +63,6 @@ return new_square; } } - // return null; return Vector2.Zero; } @@ -116,8 +115,6 @@ protected override void Spawn(in SpawnContractMessage message) { - - //for now: var occupied = new List(); @@ -146,10 +143,6 @@ var image_index = random_generator.Next(1, 7); - // int max_squares = (message.max_squares == 0) ? DEFAULT_SQUARES : message.max_squares; - // int min_squares = (message.min_squares == null) ? DEFAULT_MIN_SQUARES : (int)message.min_squares; - - int max_squares = (organization_type, message.min_squares) switch { (OrganizationType.Family, null) => random_generator.Next(50, 100 * this.MapMultiplier), (OrganizationType.LargeCorporation, null) => random_generator.Next(90, 250 * this.MapMultiplier), diff --git a/isometric-park-fna/Engines/Spawners/GameSpawner.cs b/isometric-park-fna/Engines/Spawners/GameSpawner.cs --- a/isometric-park-fna/Engines/Spawners/GameSpawner.cs +++ b/isometric-park-fna/Engines/Spawners/GameSpawner.cs @@ -53,7 +53,7 @@ int random_month = random_generator.Next(1, 13); DateTime random_date = new DateTime(random_year, random_month, 1); - int random_type = random_generator.Next(0, 4); + int random_type = random_generator.Next(0, 4); cell.AddTree(random_date, (TreeType)random_type); } 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 @@ -575,20 +575,20 @@ // if (this.cull(x, y)) // { - batch.Draw( - Tile.TileSetTexture, - new Rectangle( - screenx, - screeny, - Tile.TileWidth * scale_factor, Tile.TileHeight * scale_factor), - Tile.GetSourceRectangle(1), - Color.White, - 0.0f, - Vector2.Zero, - SpriteEffects.None, - 0.9f); + batch.Draw( + Tile.TileSetTexture, + new Rectangle( + screenx, + screeny, + Tile.TileWidth * scale_factor, Tile.TileHeight * scale_factor), + Tile.GetSourceRectangle(1), + Color.White, + 0.0f, + Vector2.Zero, + SpriteEffects.None, + 0.9f); - this.tilesDrawn++; + this.tilesDrawn++; // } } } @@ -685,12 +685,12 @@ } */ tileBatch.Begin(SpriteSortMode.BackToFront, - BlendState.AlphaBlend, - null, - null, - null, - null, - camera.get_transformation(GraphicsDevice)); + BlendState.AlphaBlend, + null, + null, + null, + null, + camera.get_transformation(GraphicsDevice)); #if DEBUG drawTileAt(4, 4, 140, 3); @@ -751,7 +751,7 @@ drawTileAt(i, j, 210, 2); } else { - drawTileAt(i, j, 122, 2); //122, 203, 221 + drawTileAt(i, j, 122, 2); //122, 203, 221 } // if ((i + j) % 8 == 0) // { @@ -807,14 +807,14 @@ if (treeStatus != CellStatus.Clear) { status_left = String.Format("{0:},{1:} {2} {3} ({4})", this.mouseGrid.X, this.mouseGrid.Y, - treeStatusAdjective, - treeType, - this.in_active_zone ? "Contracted" : (this.in_zone ? "Proposed Contract": "Unused")); + treeStatusAdjective, + treeType, + this.in_active_zone ? "Contracted" : (this.in_zone ? "Proposed Contract": "Unused")); } else { status_left = String.Format("{0:},{1:} {2} ({3})", this.mouseGrid.X, this.mouseGrid.Y, - treeStatusAdjective, - this.in_active_zone ? "Contracted" : (this.in_zone ? "Proposed Contract": "Unused")); + treeStatusAdjective, + this.in_active_zone ? "Contracted" : (this.in_zone ? "Proposed Contract": "Unused")); } } diff --git a/isometric-park-fna/ImGuiRenderer.cs b/isometric-park-fna/ImGuiRenderer.cs --- a/isometric-park-fna/ImGuiRenderer.cs +++ b/isometric-park-fna/ImGuiRenderer.cs @@ -46,8 +46,8 @@ var context = ImGui.CreateContext(); ImGui.SetCurrentContext(context); var plotContext = ImPlot.CreateContext(); - ImPlot.SetCurrentContext(plotContext); - ImPlot.SetImGuiContext(context); + ImPlot.SetCurrentContext(plotContext); + ImPlot.SetImGuiContext(context); _game = game ?? throw new ArgumentNullException(nameof(game)); _graphicsDevice = game.GraphicsDevice; diff --git a/isometric-park-fna/Messages/ToggleWindowTypeMessage.cs b/isometric-park-fna/Messages/ToggleWindowTypeMessage.cs --- a/isometric-park-fna/Messages/ToggleWindowTypeMessage.cs +++ b/isometric-park-fna/Messages/ToggleWindowTypeMessage.cs @@ -17,7 +17,7 @@ Options, NewGame, Dialog, - Graph, + Graph, } diff --git a/isometric-park-fna/Renderers/ImGuiWindowRenderer.cs b/isometric-park-fna/Renderers/ImGuiWindowRenderer.cs --- a/isometric-park-fna/Renderers/ImGuiWindowRenderer.cs +++ b/isometric-park-fna/Renderers/ImGuiWindowRenderer.cs @@ -147,9 +147,9 @@ break; case Window.NewGame: NewGameWindow.Render(this.BridgeEngine.font, this.BridgeEngine.italicFont, this.BridgeEngine); - break; - case Window.Graph: - GraphWindow.Render(this.BridgeEngine.font, this.simulation, this.BridgeEngine); + break; + case Window.Graph: + GraphWindow.Render(this.BridgeEngine.font, this.simulation, this.BridgeEngine); break; case Window.Dialog: dialog_count++; 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 @@ -39,7 +39,7 @@ public int trees; public int dead_trees; public int crowded_trees; - //Kind of a hack but allos for tracking figures over time without creating a whole new infrastructure + //Kind of a hack but allows for tracking figures over time without creating a whole new infrastructure } @@ -135,10 +135,10 @@ public System.Collections.Generic.IEnumerable allBudgets() { - foreach(var budget in this.budgets) - { - yield return budget; - } + foreach(var budget in this.budgets) + { + yield return budget; + } } private Grammar grammar; 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 @@ -227,10 +227,10 @@ ImGui.Text(string.Format("fps: {0:F3}", debugInfo.fps)); ImGui.Text(string.Format("Draw Time: {0:F3}", debugInfo.drawTime.TotalMilliseconds.ToString())); - ImGui.Text(string.Format("\tTree: {0:F3}; Grid: {1:F3}; Tile: {2:F3}", - debugInfo.treeDrawTime.TotalMilliseconds.ToString(), - debugInfo.gridDrawTime.TotalMilliseconds.ToString(), - debugInfo.tileDrawTime.TotalMilliseconds.ToString())); + ImGui.Text(string.Format("\tTree: {0:F3}; Grid: {1:F3}; Tile: {2:F3}", + debugInfo.treeDrawTime.TotalMilliseconds.ToString(), + debugInfo.gridDrawTime.TotalMilliseconds.ToString(), + debugInfo.tileDrawTime.TotalMilliseconds.ToString())); ImGui.Text(string.Format("Update Time: {0:F3}", debugInfo.updateTime.TotalMilliseconds.ToString())); ImGui.Text(string.Format("Tiles Drawn: {0:F}", debugInfo.tilesDrawn)); @@ -245,9 +245,9 @@ this.show_test_window = !this.show_test_window; } - if (ImGui.Button("Implot Test Window")){ - show_implot_test_window = !show_implot_test_window; - } + if (ImGui.Button("Implot Test Window")) { + show_implot_test_window = !show_implot_test_window; + } if (ImGui.Button("Test Logging")) { Logging.Log(LogLevel.Critical, "Test"); @@ -319,10 +319,10 @@ ImGui.SetNextWindowPos(new Num.Vector2(650, 20), ImGuiCond.FirstUseEver); ImGui.ShowDemoWindow(ref show_test_window); } - if (this.show_implot_test_window) - { - ImPlot.ShowDemoWindow(ref this.show_implot_test_window); - } + if (this.show_implot_test_window) + { + ImPlot.ShowDemoWindow(ref this.show_implot_test_window); + } } } } diff --git a/isometric-park-fna/UI/Graph.cs b/isometric-park-fna/UI/Graph.cs --- a/isometric-park-fna/UI/Graph.cs +++ b/isometric-park-fna/UI/Graph.cs @@ -27,16 +27,17 @@ public static bool show_upkeep = false; private static string[] money_series = { "Total Funds", - "Subsidies", "Upkeep", "Contracts", "Cashflow", "Misc"}; + "Subsidies", "Upkeep", "Contracts", "Cashflow", "Misc" + }; private static string[] tree_series = { "Total trees", "Dead trees", "Crowded trees"}; public static Dictionary> data_sets = new Dictionary>(); public static Dictionary data_sets_show = new List() - .Concat(money_series) - .Concat(tree_series) - .Select(e => (e, false)) - .ToDictionary(t => t.Item1, t=> t.Item2); + .Concat(money_series) + .Concat(tree_series) + .Select(e => (e, false)) + .ToDictionary(t => t.Item1, t=> t.Item2); public static void Render(ImFontPtr font, Simulation sim, ImGuiWindowBridgeEngine engine) @@ -44,128 +45,128 @@ bool newShow = true; - ImGui.PushFont(font); + ImGui.PushFont(font); - ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.None; - StyleSets.defaultSet.push(); + ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.None; + StyleSets.defaultSet.push(); - if(GraphWindow.hadFocus) - { - ImGui.PushStyleColor(ImGuiCol.Text, StyleSets.white); - } - ImGui.SetNextWindowSize(new Num.Vector2(400, 400)); + if(GraphWindow.hadFocus) + { + ImGui.PushStyleColor(ImGuiCol.Text, StyleSets.white); + } + ImGui.SetNextWindowSize(new Num.Vector2(400, 400)); - ImGui.Begin("Graph", ref newShow, ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoSavedSettings); - if (GraphWindow.hadFocus) - { - ImGui.PopStyleColor(); - } - GraphWindow.hadFocus = ImGui.IsWindowFocused(); + ImGui.Begin("Graph", ref newShow, ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoSavedSettings); + if (GraphWindow.hadFocus) + { + ImGui.PopStyleColor(); + } + GraphWindow.hadFocus = ImGui.IsWindowFocused(); - data_sets["Total Funds"] = sim.allBudgets().Select(b => (double)b.money); - data_sets["Subsidies"] = sim.allBudgets().Select(b => (double)b.subsidy); - data_sets["Upkeep"] = sim.allBudgets().Select(b => (double)b.upkeep); - data_sets["Contracts"] = sim.allBudgets().Select(b => (double)b.contracts); - data_sets["Misc"] = sim.allBudgets().Select(b => (double)b.misc); - data_sets["Cashflow"] = sim.allBudgets().Select(b => (double)b.cashflow); + data_sets["Total Funds"] = sim.allBudgets().Select(b => (double)b.money); + data_sets["Subsidies"] = sim.allBudgets().Select(b => (double)b.subsidy); + data_sets["Upkeep"] = sim.allBudgets().Select(b => (double)b.upkeep); + data_sets["Contracts"] = sim.allBudgets().Select(b => (double)b.contracts); + data_sets["Misc"] = sim.allBudgets().Select(b => (double)b.misc); + data_sets["Cashflow"] = sim.allBudgets().Select(b => (double)b.cashflow); + + data_sets["Total trees"] = sim.allBudgets().Select(b => (double)b.trees); + data_sets["Dead trees"] = sim.allBudgets().Select(b => (double)b.dead_trees); + data_sets["Crowded trees"] = sim.allBudgets().Select(b => (double)b.crowded_trees); + + var periods = 12.0d * GraphWindow.year; + var keys = data_sets_show.Keys.ToList(); + + var totals = data_sets["Total Funds"]; - data_sets["Total trees"] = sim.allBudgets().Select(b => (double)b.trees); - data_sets["Dead trees"] = sim.allBudgets().Select(b => (double)b.dead_trees); - data_sets["Crowded trees"] = sim.allBudgets().Select(b => (double)b.crowded_trees); + var max = 0.0d; + var min = 0.0d; - var periods = 12.0d * GraphWindow.year; - var keys = data_sets_show.Keys.ToList(); + foreach( var key in keys) { + if (data_sets_show[key] && totals.Count() > 0) { + var series_max = data_sets[key].Max() * 1.10f; + max = Math.Max(series_max, max); + } + } - var totals = data_sets["Total Funds"]; - - var max = 0.0d; - var min = 0.0d; + foreach( var key in keys) { + if (data_sets_show[key] && totals.Count() > 0) { + var series_min = data_sets[key].Min(); + series_min = series_min >= 0? series_min * 0.90f : series_min *1.10f; + min = Math.Min(series_min, min); + } + } - foreach( var key in keys) { - if (data_sets_show[key] && totals.Count() > 0) { - var series_max = data_sets[key].Max() * 1.10f; - max = Math.Max(series_max, max); - } - } + ImPlot.PushStyleVar(ImPlotStyleVar.LineWeight, 2.0f); + ImPlot.PushStyleVar(ImPlotStyleVar.MinorAlpha, 0.0f); + // ImPlot.PushStyleVar(ImPlotStyleVar.MajorGridSize, new Num.Vector2(0.0f, 0.0f)); + // ImPlot.PushStyleVar(ImPlotStyleVar.MinorGridSize, new Num.Vector2(0.0f, 0.0f)); - foreach( var key in keys) { - if (data_sets_show[key] && totals.Count() > 0) { - var series_min = data_sets[key].Min(); - series_min = series_min >= 0? series_min * 0.90f : series_min *1.10f; - min = Math.Min(series_min, min); + ImPlot.SetNextPlotLimits(totals.Count()-periods, totals.Count(), min, max, ImGuiCond.Always); + if( ImPlot.BeginPlot("My Plot", null, null, new Num.Vector2(-1,0), ImPlotFlags.NoLegend | ImPlotFlags.NoMousePos )) { + // Span totals = new Span(new double[]{0.0, 1.0, 2.0, 9.0}); + foreach (var key in keys) { + var show = data_sets_show[key]; + var data = data_sets[key]; + var data_array = data_sets[key].ToArray(); + if (data_array.Length > 0 && show) + { + ImPlot.PlotLine(key, ref data_array[0], data_array.Length); + ImPlot.AnnotateClamped(data_array.Length-1, data_array[data_array.Length-1], + new Num.Vector2(5, -10), StyleSets.grey, key); } } - ImPlot.PushStyleVar(ImPlotStyleVar.LineWeight, 2.0f); - ImPlot.PushStyleVar(ImPlotStyleVar.MinorAlpha, 0.0f); - // ImPlot.PushStyleVar(ImPlotStyleVar.MajorGridSize, new Num.Vector2(0.0f, 0.0f)); - // ImPlot.PushStyleVar(ImPlotStyleVar.MinorGridSize, new Num.Vector2(0.0f, 0.0f)); + ImPlot.EndPlot(); + } + + ImPlot.PopStyleVar(2); - ImPlot.SetNextPlotLimits(totals.Count()-periods, totals.Count(), min, max , ImGuiCond.Always); - if( ImPlot.BeginPlot("My Plot", null, null, new Num.Vector2(-1,0), ImPlotFlags.NoLegend | ImPlotFlags.NoMousePos )) { - // Span totals = new Span(new double[]{0.0, 1.0, 2.0, 9.0}); - foreach (var key in keys) { - var show = data_sets_show[key]; - var data = data_sets[key]; - var data_array = data_sets[key].ToArray(); - if (data_array.Length > 0 && show) - { - ImPlot.PlotLine(key, ref data_array[0], data_array.Length); - ImPlot.AnnotateClamped(data_array.Length-1, data_array[data_array.Length-1], - new Num.Vector2(5, -10), StyleSets.grey, key); - } - } - - ImPlot.EndPlot(); + ImGui.RadioButton("1 year", ref GraphWindow.year, 1); + ImGui.SameLine(); + ImGui.RadioButton("5 years", ref GraphWindow.year, 5); + ImGui.SameLine(); + ImGui.RadioButton("25 years", ref GraphWindow.year, 25); + ImGui.SameLine(); + ImGui.RadioButton("100 years", ref GraphWindow.year, 100); + + ImGui.Text("Trees:"); + for (int i = 0; i < tree_series.Length; i++) + { + var key = tree_series[i]; + if (Menu.activeButton(key, data_sets_show[key], StyleSets.selected, StyleSets.white)) + { + data_sets_show[key] = !data_sets_show[key]; } - ImPlot.PopStyleVar(2); - - ImGui.RadioButton("1 year", ref GraphWindow.year, 1); - ImGui.SameLine(); - ImGui.RadioButton("5 years", ref GraphWindow.year, 5); - ImGui.SameLine(); - ImGui.RadioButton("25 years", ref GraphWindow.year, 25); - ImGui.SameLine(); - ImGui.RadioButton("100 years", ref GraphWindow.year, 100); - - ImGui.Text("Trees:"); - for (int i = 0; i < tree_series.Length; i++) + if (i != tree_series.Length-1) { - var key = tree_series[i]; - if (Menu.activeButton(key, data_sets_show[key], StyleSets.selected, StyleSets.white)) - { - data_sets_show[key] = !data_sets_show[key]; - } - - if (i != tree_series.Length-1) - { - ImGui.SameLine(); - } - + ImGui.SameLine(); } - ImGui.Text("Money:"); - for (int i = 0; i < money_series.Length; i++) + } + + ImGui.Text("Money:"); + for (int i = 0; i < money_series.Length; i++) + { + var key = money_series[i]; + if (Menu.activeButton(key, data_sets_show[key], StyleSets.selected, StyleSets.white)) { - var key = money_series[i]; - if (Menu.activeButton(key, data_sets_show[key], StyleSets.selected, StyleSets.white)) - { - data_sets_show[key] = !data_sets_show[key]; - } - if ((i % 4 != 3) && (i != money_series.Length-1)) { - ImGui.SameLine(); - } + data_sets_show[key] = !data_sets_show[key]; + } + if ((i % 4 != 3) && (i != money_series.Length-1)) { + ImGui.SameLine(); + } - } + } - ImGui.End(); - ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.Left; - StyleSets.defaultSet.pop(); - ImGui.PopFont(); + ImGui.End(); + ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.Left; + StyleSets.defaultSet.pop(); + ImGui.PopFont(); } } diff --git a/isometric-park-fna/UI/OptionsWindow.cs b/isometric-park-fna/UI/OptionsWindow.cs --- a/isometric-park-fna/UI/OptionsWindow.cs +++ b/isometric-park-fna/UI/OptionsWindow.cs @@ -25,12 +25,12 @@ private static ProfanityLevel profanityLevel = default; - private static bool origFullscreen = OptionsWindow.newFullscreen; - private static Vector2 origResolution = OptionsWindow.newResolution; + private static bool origFullscreen = OptionsWindow.newFullscreen; + private static Vector2 origResolution = OptionsWindow.newResolution; - private static string origFontName = OptionsWindow.fontName; - private static int origFontSize = OptionsWindow.fontSize; - private static ProfanityLevel origProfanityLevel = OptionsWindow.profanityLevel; + private static string origFontName = OptionsWindow.fontName; + private static int origFontSize = OptionsWindow.fontSize; + private static ProfanityLevel origProfanityLevel = OptionsWindow.profanityLevel; public static void Initialize(Vector2 resolution, bool fullscreen, ProfanityLevel profanityLevel) { @@ -72,7 +72,7 @@ ImGui.SameLine(); if (ImGui.BeginCombo("##resolutions", string.Format("{0}x{1}", - newResolution.X, newResolution.Y))) + newResolution.X, newResolution.Y))) { foreach(var (width_option, height_option) in new[] {(1280, 640), @@ -174,12 +174,12 @@ fontName = OptionsWindow.fontName }); - origFullscreen = OptionsWindow.newFullscreen; - origResolution = OptionsWindow.newResolution; + origFullscreen = OptionsWindow.newFullscreen; + origResolution = OptionsWindow.newResolution; - origFontName = OptionsWindow.fontName; - origFontSize = OptionsWindow.fontSize; - origProfanityLevel = OptionsWindow.profanityLevel; + origFontName = OptionsWindow.fontName; + origFontSize = OptionsWindow.fontSize; + origProfanityLevel = OptionsWindow.profanityLevel; } ImGui.SameLine(); @@ -194,26 +194,26 @@ fontName = OptionsWindow.fontName }); - origFullscreen = OptionsWindow.newFullscreen; - origResolution = OptionsWindow.newResolution; + origFullscreen = OptionsWindow.newFullscreen; + origResolution = OptionsWindow.newResolution; - origFontName = OptionsWindow.fontName; - origFontSize = OptionsWindow.fontSize; - origProfanityLevel = OptionsWindow.profanityLevel; + origFontName = OptionsWindow.fontName; + origFontSize = OptionsWindow.fontSize; + origProfanityLevel = OptionsWindow.profanityLevel; } ImGui.SameLine(); - if (ImGui.Button("Cancel")) { + if (ImGui.Button("Cancel")) { bridgeEngine.typeMessages.Add(new ToggleWindowTypeMessage {Window = Window.Options}); - OptionsWindow.newFullscreen = origFullscreen; - OptionsWindow.newResolution = origResolution; + OptionsWindow.newFullscreen = origFullscreen; + OptionsWindow.newResolution = origResolution; - OptionsWindow.fontName = origFontName; - OptionsWindow.fontSize = origFontSize; - OptionsWindow.profanityLevel = origProfanityLevel; - } + OptionsWindow.fontName = origFontName; + OptionsWindow.fontSize = origFontSize; + OptionsWindow.profanityLevel = origProfanityLevel; + } ImGui.End(); diff --git a/isometric-park-fna/Utils/MathUtils.cs b/isometric-park-fna/Utils/MathUtils.cs --- a/isometric-park-fna/Utils/MathUtils.cs +++ b/isometric-park-fna/Utils/MathUtils.cs @@ -2,14 +2,14 @@ using JM.LinqFaster; namespace isometricparkfna { - public class EmptyArrayException : Exception { - public EmptyArrayException() { - } + public class EmptyArrayException : Exception { + public EmptyArrayException() { + } - public EmptyArrayException(string message) : base(message) { - } + public EmptyArrayException(string message) : base(message) { + } - } + } public class MathUtils { public MathUtils() @@ -136,38 +136,38 @@ return integers[index]; } - public static float Percentile(float[] floats, float percentile) { - if (floats.Length > 0) { - Array.Sort(floats); - var raw_position = (floats.Length-1) * percentile; + public static float Percentile(float[] floats, float percentile) { + if (floats.Length > 0) { + Array.Sort(floats); + var raw_position = (floats.Length-1) * percentile; - var lower_position = (int)raw_position; - var higher_position = Math.Min((int)(raw_position+1), floats.Length-1); + var lower_position = (int)raw_position; + var higher_position = Math.Min((int)(raw_position+1), floats.Length-1); - var remainder = (raw_position % 1); + var remainder = (raw_position % 1); - return (floats[lower_position] * (1-remainder)) + (floats[higher_position] * remainder); - } - else { - throw new EmptyArrayException("Array must not be empty"); - } - } + return (floats[lower_position] * (1-remainder)) + (floats[higher_position] * remainder); + } + else { + throw new EmptyArrayException("Array must not be empty"); + } + } - public static double Percentile(double[] doubles, double percentile) { - if (doubles.Length > 0) { - Array.Sort(doubles); - var raw_position = (doubles.Length-1) * percentile; + public static double Percentile(double[] doubles, double percentile) { + if (doubles.Length > 0) { + Array.Sort(doubles); + var raw_position = (doubles.Length-1) * percentile; - var lower_position = (int)raw_position; - var higher_position = Math.Min((int)raw_position + 1, doubles.Length -1); + var lower_position = (int)raw_position; + var higher_position = Math.Min((int)raw_position + 1, doubles.Length -1); - var remainder = (raw_position % 1); + var remainder = (raw_position % 1); - return (doubles[lower_position] * (1-remainder)) + (doubles[higher_position] * remainder); - } - else { - throw new EmptyArrayException("Array must not be empty"); - } - } + return (doubles[lower_position] * (1-remainder)) + (doubles[higher_position] * remainder); + } + else { + throw new EmptyArrayException("Array must not be empty"); + } + } } }