From deec553b22fd28e3899b29081fdb382e96661ff0 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Thu, 18 Jun 2020 17:24:35 +0200 Subject: [PATCH] code cleanup --- Demos.Android/Properties/AssemblyInfo.cs | 2 - Demos/AutoTilingDemo.cs | 8 +-- Demos/GameImpl.cs | 2 +- Demos/PathfindingDemo.cs | 8 +-- Demos/UiDemo.cs | 17 +++--- MLEM.Data/Json/JsonConverters.cs | 1 - .../Extensions/SpriteBatchExtensions.cs | 2 - MLEM.Extended/Font/GenericBitmapFont.cs | 2 - MLEM.Extended/Tiled/TiledExtensions.cs | 1 - MLEM.Extended/Tiled/TiledMapCollisions.cs | 1 - MLEM.Startup/MlemGame.cs | 1 - MLEM.Ui/Elements/Button.cs | 1 - MLEM.Ui/Elements/Checkbox.cs | 2 - MLEM.Ui/Elements/CustomDrawGroup.cs | 1 - MLEM.Ui/Elements/Element.cs | 2 - MLEM.Ui/Elements/ElementHelper.cs | 5 +- MLEM.Ui/Elements/Panel.cs | 1 - MLEM.Ui/Elements/Paragraph.cs | 7 --- MLEM.Ui/Elements/RadioButton.cs | 1 - MLEM.Ui/Elements/Slider.cs | 2 - MLEM.Ui/Elements/SpriteAnimationImage.cs | 1 - MLEM.Ui/Elements/Tooltip.cs | 2 - MLEM.Ui/Style/UiStyle.cs | 1 - MLEM.Ui/Style/UntexturedStyle.cs | 2 - MLEM.Ui/UiControls.cs | 2 - MLEM.Ui/UiSystem.cs | 2 - MLEM/Animations/SpriteAnimation.cs | 2 +- MLEM/Content/RawContentManager.cs | 1 - MLEM/Content/SoundEffectReader.cs | 1 - MLEM/Extensions/GraphicsExtensions.cs | 3 +- MLEM/Font/GenericFont.cs | 2 - MLEM/Font/GenericSpriteFont.cs | 2 - MLEM/Formatting/Codes/ImageCode.cs | 1 - MLEM/Formatting/TextFormatter.cs | 2 - MLEM/Formatting/Token.cs | 1 - MLEM/Formatting/TokenizedString.cs | 1 - MLEM/Input/GenericInput.cs | 2 +- MLEM/Input/InputHandler.cs | 52 +++++++++++-------- MLEM/Input/Keybind.cs | 2 - MLEM/Misc/Direction2.cs | 1 - MLEM/Pathfinding/AStar3.cs | 1 - MLEM/Textures/UniformTextureAtlas.cs | 1 - Sandbox/GameImpl.cs | 4 -- 43 files changed, 52 insertions(+), 104 deletions(-) diff --git a/Demos.Android/Properties/AssemblyInfo.cs b/Demos.Android/Properties/AssemblyInfo.cs index 7b7db38..828b60f 100644 --- a/Demos.Android/Properties/AssemblyInfo.cs +++ b/Demos.Android/Properties/AssemblyInfo.cs @@ -1,7 +1,5 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -using Android.App; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information diff --git a/Demos/AutoTilingDemo.cs b/Demos/AutoTilingDemo.cs index 711259e..3b44f98 100644 --- a/Demos/AutoTilingDemo.cs +++ b/Demos/AutoTilingDemo.cs @@ -55,17 +55,19 @@ namespace Demos { var x1 = x; var y1 = y; + // the connectsTo function determines for any given tile if it should connect to, that is, auto-tile with the // neighbor in the supplied offset direction. In this example, the layout determines where grass tiles are (X) // and where there are none ( ). - AutoTiling.ConnectsTo connectsTo = (xOff, yOff) => { + bool ConnectsTo(int xOff, int yOff) { // don't auto-tile out of bounds if (x1 + xOff < 0 || y1 + yOff < 0 || x1 + xOff >= 5 || y1 + yOff >= 5) return false; // check if the neighboring tile is also grass (X) return this.layout[y1 + yOff][x1 + xOff] == 'X'; - }; - AutoTiling.DrawAutoTile(this.SpriteBatch, new Vector2(x, y) * tileSize, this.texture, region, connectsTo, Color.White); + } + + AutoTiling.DrawAutoTile(this.SpriteBatch, new Vector2(x, y) * tileSize, this.texture, region, ConnectsTo, Color.White); } } this.SpriteBatch.End(); diff --git a/Demos/GameImpl.cs b/Demos/GameImpl.cs index e6ad5a7..baa3cdf 100644 --- a/Demos/GameImpl.cs +++ b/Demos/GameImpl.cs @@ -40,7 +40,7 @@ namespace Demos { PanelTexture = new NinePatch(new TextureRegion(tex, 0, 8, 24, 24), 8), ButtonTexture = new NinePatch(new TextureRegion(tex, 24, 8, 16, 16), 4), ScrollBarBackground = new NinePatch(new TextureRegion(tex, 12, 0, 4, 8), 1, 1, 2, 2), - ScrollBarScrollerTexture = new NinePatch(new TextureRegion(tex, 8, 0, 4, 8), 1, 1, 2, 2), + ScrollBarScrollerTexture = new NinePatch(new TextureRegion(tex, 8, 0, 4, 8), 1, 1, 2, 2) }; this.UiSystem.AutoScaleReferenceSize = new Point(1280, 720); this.UiSystem.AutoScaleWithScreen = true; diff --git a/Demos/PathfindingDemo.cs b/Demos/PathfindingDemo.cs index 9895532..0b01f09 100644 --- a/Demos/PathfindingDemo.cs +++ b/Demos/PathfindingDemo.cs @@ -8,7 +8,6 @@ using MLEM.Input; using MLEM.Misc; using MLEM.Pathfinding; using MLEM.Startup; -using MLEM.Textures; namespace Demos { public class PathfindingDemo : Demo { @@ -39,14 +38,15 @@ namespace Demos { // If your game contains harder-to-move-on areas like, say, a muddy pit, you can return a higher cost value for those // locations. If you want to scale your cost function differently, you can specify a different default cost in your // pathfinder's constructor - AStar.GetCost cost = (pos, nextPos) => { + float Cost(Point pos, Point nextPos) { if (nextPos.X < 0 || nextPos.Y < 0 || nextPos.X >= 50 || nextPos.Y >= 50) return float.MaxValue; return this.world[nextPos.X, nextPos.Y] ? 1 : float.MaxValue; - }; + } + // Actually initialize the pathfinder with the cost function, as well as specify if moving diagonally between tiles should be // allowed or not (in this case it's not) - this.pathfinder = new AStar2(cost, false); + this.pathfinder = new AStar2(Cost, false); // Now find a path from the top left to the bottom right corner and store it in a variable // If no path can be found after the maximum amount of tries (10000 by default), the pathfinder will abort and return no path (null) diff --git a/Demos/UiDemo.cs b/Demos/UiDemo.cs index dffcb76..1e67f5e 100644 --- a/Demos/UiDemo.cs +++ b/Demos/UiDemo.cs @@ -4,12 +4,9 @@ using System.Linq; using Coroutine; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using MLEM.Animations; using MLEM.Extensions; using MLEM.Font; -using MLEM.Formatting; using MLEM.Formatting.Codes; -using MLEM.Input; using MLEM.Misc; using MLEM.Startup; using MLEM.Textures; @@ -143,7 +140,7 @@ namespace Demos { // Check the WobbleButton method for an explanation of how this button works var group = this.root.AddChild(new CustomDrawGroup(Anchor.AutoLeft, new Vector2(1, 0))); group.AddChild(new Button(Anchor.AutoCenter, new Vector2(0.5F, 10), "Wobble Me", "This button wobbles around visually when clicked, but this doesn't affect its actual size and positioning") { - OnPressed = element => CoroutineHandler.Start(this.WobbleButton(group)), + OnPressed = element => CoroutineHandler.Start(WobbleButton(group)), PositionOffset = new Vector2(0, 1) }); this.root.AddChild(new Button(Anchor.AutoCenter, new Vector2(0.5F, 10), "Transform Ui", "This button causes the entire ui to be transformed (both in positioning, rotation and scale)") { @@ -160,13 +157,13 @@ namespace Demos { this.root.AddChild(new VerticalSpace(3)); this.root.AddChild(new Paragraph(Anchor.AutoLeft, 1, "Progress bars!")); var bar1 = this.root.AddChild(new ProgressBar(Anchor.AutoLeft, new Vector2(1, 8), Direction2.Right, 10) {PositionOffset = new Vector2(0, 1)}); - CoroutineHandler.Start(this.WobbleProgressBar(bar1)); + CoroutineHandler.Start(WobbleProgressBar(bar1)); var bar2 = this.root.AddChild(new ProgressBar(Anchor.AutoLeft, new Vector2(1, 8), Direction2.Left, 10) {PositionOffset = new Vector2(0, 1)}); - CoroutineHandler.Start(this.WobbleProgressBar(bar2)); + CoroutineHandler.Start(WobbleProgressBar(bar2)); var bar3 = this.root.AddChild(new ProgressBar(Anchor.AutoLeft, new Vector2(8, 30), Direction2.Down, 10) {PositionOffset = new Vector2(0, 1)}); - CoroutineHandler.Start(this.WobbleProgressBar(bar3)); + CoroutineHandler.Start(WobbleProgressBar(bar3)); var bar4 = this.root.AddChild(new ProgressBar(Anchor.AutoInline, new Vector2(8, 30), Direction2.Up, 10) {PositionOffset = new Vector2(1, 1)}); - CoroutineHandler.Start(this.WobbleProgressBar(bar4)); + CoroutineHandler.Start(WobbleProgressBar(bar4)); this.root.AddChild(new VerticalSpace(3)); var dropdown = this.root.AddChild(new Dropdown(Anchor.AutoLeft, new Vector2(1, 10), "Dropdown Menu")); @@ -203,7 +200,7 @@ namespace Demos { // This method is used by the wobbling button (see above) // Note that this particular example makes use of the Coroutine package, which is not required but makes demonstration easier - private IEnumerator WobbleButton(CustomDrawGroup group) { + private static IEnumerator WobbleButton(CustomDrawGroup group) { var counter = 0F; while (counter < 4 * Math.PI) { // A custom draw group allows the implementation of any sort of custom rendering for all of its child components @@ -219,7 +216,7 @@ namespace Demos { group.Transform = Matrix.Identity; } - private IEnumerator WobbleProgressBar(ProgressBar bar) { + private static IEnumerator WobbleProgressBar(ProgressBar bar) { var reducing = false; while (bar.Root != null) { if (reducing) { diff --git a/MLEM.Data/Json/JsonConverters.cs b/MLEM.Data/Json/JsonConverters.cs index e4428f5..47e0543 100644 --- a/MLEM.Data/Json/JsonConverters.cs +++ b/MLEM.Data/Json/JsonConverters.cs @@ -1,6 +1,5 @@ using System; using System.Linq; -using System.Reflection; using Newtonsoft.Json; namespace MLEM.Data.Json { diff --git a/MLEM.Extended/Extensions/SpriteBatchExtensions.cs b/MLEM.Extended/Extensions/SpriteBatchExtensions.cs index 4596625..4b9cbc6 100644 --- a/MLEM.Extended/Extensions/SpriteBatchExtensions.cs +++ b/MLEM.Extended/Extensions/SpriteBatchExtensions.cs @@ -1,9 +1,7 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using MLEM.Extensions; -using MLEM.Textures; using MonoGame.Extended; -using MonoGame.Extended.BitmapFonts; namespace MLEM.Extended.Extensions { /// diff --git a/MLEM.Extended/Font/GenericBitmapFont.cs b/MLEM.Extended/Font/GenericBitmapFont.cs index 42ee2f8..7cf14ec 100644 --- a/MLEM.Extended/Font/GenericBitmapFont.cs +++ b/MLEM.Extended/Font/GenericBitmapFont.cs @@ -1,8 +1,6 @@ -using System.Collections.Generic; using System.Text; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using MLEM.Extended.Extensions; using MLEM.Font; using MonoGame.Extended.BitmapFonts; diff --git a/MLEM.Extended/Tiled/TiledExtensions.cs b/MLEM.Extended/Tiled/TiledExtensions.cs index 66b2fc8..38e3f23 100644 --- a/MLEM.Extended/Tiled/TiledExtensions.cs +++ b/MLEM.Extended/Tiled/TiledExtensions.cs @@ -1,4 +1,3 @@ -using System; using System.Collections.Generic; using System.Globalization; using System.Linq; diff --git a/MLEM.Extended/Tiled/TiledMapCollisions.cs b/MLEM.Extended/Tiled/TiledMapCollisions.cs index e59b393..bbf56ba 100644 --- a/MLEM.Extended/Tiled/TiledMapCollisions.cs +++ b/MLEM.Extended/Tiled/TiledMapCollisions.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Collections.ObjectModel; using System.Linq; using Microsoft.Xna.Framework; using MLEM.Extensions; diff --git a/MLEM.Startup/MlemGame.cs b/MLEM.Startup/MlemGame.cs index a8d3116..4d9c2e0 100644 --- a/MLEM.Startup/MlemGame.cs +++ b/MLEM.Startup/MlemGame.cs @@ -2,7 +2,6 @@ using Coroutine; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.Graphics; -using Microsoft.Xna.Framework.Input; using MLEM.Input; using MLEM.Ui; using MLEM.Ui.Style; diff --git a/MLEM.Ui/Elements/Button.cs b/MLEM.Ui/Elements/Button.cs index 00f2fa0..e0a6c76 100644 --- a/MLEM.Ui/Elements/Button.cs +++ b/MLEM.Ui/Elements/Button.cs @@ -1,6 +1,5 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using MLEM.Extensions; using MLEM.Textures; using MLEM.Ui.Style; diff --git a/MLEM.Ui/Elements/Checkbox.cs b/MLEM.Ui/Elements/Checkbox.cs index 42ebabe..35f6687 100644 --- a/MLEM.Ui/Elements/Checkbox.cs +++ b/MLEM.Ui/Elements/Checkbox.cs @@ -1,7 +1,5 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using MLEM.Extensions; -using MLEM.Input; using MLEM.Misc; using MLEM.Textures; using MLEM.Ui.Style; diff --git a/MLEM.Ui/Elements/CustomDrawGroup.cs b/MLEM.Ui/Elements/CustomDrawGroup.cs index 0e56c35..43dd6c7 100644 --- a/MLEM.Ui/Elements/CustomDrawGroup.cs +++ b/MLEM.Ui/Elements/CustomDrawGroup.cs @@ -1,4 +1,3 @@ -using System; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; diff --git a/MLEM.Ui/Elements/Element.cs b/MLEM.Ui/Elements/Element.cs index 2b8c92f..bdce8eb 100644 --- a/MLEM.Ui/Elements/Element.cs +++ b/MLEM.Ui/Elements/Element.cs @@ -1,7 +1,5 @@ using System; using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Audio; using Microsoft.Xna.Framework.Graphics; diff --git a/MLEM.Ui/Elements/ElementHelper.cs b/MLEM.Ui/Elements/ElementHelper.cs index 6830904..5c26c32 100644 --- a/MLEM.Ui/Elements/ElementHelper.cs +++ b/MLEM.Ui/Elements/ElementHelper.cs @@ -1,5 +1,4 @@ using Microsoft.Xna.Framework; -using MLEM.Input; using MLEM.Textures; namespace MLEM.Ui.Elements { @@ -91,7 +90,7 @@ namespace MLEM.Ui.Elements { var upButton = new Button(Anchor.TopRight, Vector2.One, "+") { OnPressed = element => { - var text = field.Text.ToString(); + var text = field.Text; if (int.TryParse(text, out var val)) field.SetText(val + stepPerClick); } @@ -101,7 +100,7 @@ namespace MLEM.Ui.Elements { var downButton = new Button(Anchor.BottomRight, Vector2.One, "-") { OnPressed = element => { - var text = field.Text.ToString(); + var text = field.Text; if (int.TryParse(text, out var val)) field.SetText(val - stepPerClick); } diff --git a/MLEM.Ui/Elements/Panel.cs b/MLEM.Ui/Elements/Panel.cs index f3e16c9..0868887 100644 --- a/MLEM.Ui/Elements/Panel.cs +++ b/MLEM.Ui/Elements/Panel.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Diagnostics; using System.Linq; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; diff --git a/MLEM.Ui/Elements/Paragraph.cs b/MLEM.Ui/Elements/Paragraph.cs index 2eb2ac7..1f62c2b 100644 --- a/MLEM.Ui/Elements/Paragraph.cs +++ b/MLEM.Ui/Elements/Paragraph.cs @@ -1,17 +1,10 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; using System.Linq; -using System.Text.RegularExpressions; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using MLEM.Extensions; using MLEM.Font; using MLEM.Formatting; using MLEM.Formatting.Codes; -using MLEM.Input; using MLEM.Misc; -using MLEM.Textures; using MLEM.Ui.Style; namespace MLEM.Ui.Elements { diff --git a/MLEM.Ui/Elements/RadioButton.cs b/MLEM.Ui/Elements/RadioButton.cs index f7aeb65..71f5412 100644 --- a/MLEM.Ui/Elements/RadioButton.cs +++ b/MLEM.Ui/Elements/RadioButton.cs @@ -1,5 +1,4 @@ using Microsoft.Xna.Framework; -using MLEM.Input; using MLEM.Ui.Style; namespace MLEM.Ui.Elements { diff --git a/MLEM.Ui/Elements/Slider.cs b/MLEM.Ui/Elements/Slider.cs index 8ea92f0..5dfe367 100644 --- a/MLEM.Ui/Elements/Slider.cs +++ b/MLEM.Ui/Elements/Slider.cs @@ -1,6 +1,4 @@ -using System.Linq; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Input; using MLEM.Misc; namespace MLEM.Ui.Elements { diff --git a/MLEM.Ui/Elements/SpriteAnimationImage.cs b/MLEM.Ui/Elements/SpriteAnimationImage.cs index 2ac0ad4..6d23131 100644 --- a/MLEM.Ui/Elements/SpriteAnimationImage.cs +++ b/MLEM.Ui/Elements/SpriteAnimationImage.cs @@ -1,6 +1,5 @@ using Microsoft.Xna.Framework; using MLEM.Animations; -using MLEM.Textures; namespace MLEM.Ui.Elements { /// diff --git a/MLEM.Ui/Elements/Tooltip.cs b/MLEM.Ui/Elements/Tooltip.cs index cc69e4f..618b1f0 100644 --- a/MLEM.Ui/Elements/Tooltip.cs +++ b/MLEM.Ui/Elements/Tooltip.cs @@ -1,7 +1,5 @@ using System; using Microsoft.Xna.Framework; -using MLEM.Extensions; -using MLEM.Font; using MLEM.Ui.Style; namespace MLEM.Ui.Elements { diff --git a/MLEM.Ui/Style/UiStyle.cs b/MLEM.Ui/Style/UiStyle.cs index ad23233..47cee17 100644 --- a/MLEM.Ui/Style/UiStyle.cs +++ b/MLEM.Ui/Style/UiStyle.cs @@ -1,4 +1,3 @@ -using System; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Audio; using MLEM.Font; diff --git a/MLEM.Ui/Style/UntexturedStyle.cs b/MLEM.Ui/Style/UntexturedStyle.cs index a4054ff..bdb80d9 100644 --- a/MLEM.Ui/Style/UntexturedStyle.cs +++ b/MLEM.Ui/Style/UntexturedStyle.cs @@ -1,10 +1,8 @@ -using System.Collections.Generic; using System.Text; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using MLEM.Extensions; using MLEM.Font; -using MLEM.Textures; namespace MLEM.Ui.Style { /// diff --git a/MLEM.Ui/UiControls.cs b/MLEM.Ui/UiControls.cs index 618dda5..efe923c 100644 --- a/MLEM.Ui/UiControls.cs +++ b/MLEM.Ui/UiControls.cs @@ -1,10 +1,8 @@ -using System; using System.Collections.Generic; using System.Linq; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Input; using Microsoft.Xna.Framework.Input.Touch; -using MLEM.Extensions; using MLEM.Input; using MLEM.Misc; using MLEM.Ui.Elements; diff --git a/MLEM.Ui/UiSystem.cs b/MLEM.Ui/UiSystem.cs index e69af66..062bbea 100644 --- a/MLEM.Ui/UiSystem.cs +++ b/MLEM.Ui/UiSystem.cs @@ -5,9 +5,7 @@ using System.Linq; using System.Text.RegularExpressions; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using Microsoft.Xna.Framework.Input; using MLEM.Extensions; -using MLEM.Font; using MLEM.Formatting; using MLEM.Formatting.Codes; using MLEM.Input; diff --git a/MLEM/Animations/SpriteAnimation.cs b/MLEM/Animations/SpriteAnimation.cs index 31c6146..d35b29f 100644 --- a/MLEM/Animations/SpriteAnimation.cs +++ b/MLEM/Animations/SpriteAnimation.cs @@ -10,7 +10,7 @@ namespace MLEM.Animations { /// public class SpriteAnimation : GenericDataHolder { - private AnimationFrame[] frames; + private readonly AnimationFrame[] frames; /// /// Returns the at the given index. /// Index ordering is based on the order that animation frames were added in. diff --git a/MLEM/Content/RawContentManager.cs b/MLEM/Content/RawContentManager.cs index 1e970d1..87148a7 100644 --- a/MLEM/Content/RawContentManager.cs +++ b/MLEM/Content/RawContentManager.cs @@ -2,7 +2,6 @@ using System; using System.Collections.Generic; using System.IO; using System.Linq; -using System.Reflection; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.Graphics; diff --git a/MLEM/Content/SoundEffectReader.cs b/MLEM/Content/SoundEffectReader.cs index fe68f53..021e966 100644 --- a/MLEM/Content/SoundEffectReader.cs +++ b/MLEM/Content/SoundEffectReader.cs @@ -1,4 +1,3 @@ -using System; using System.IO; using Microsoft.Xna.Framework.Audio; diff --git a/MLEM/Extensions/GraphicsExtensions.cs b/MLEM/Extensions/GraphicsExtensions.cs index 53e2b36..47bafeb 100644 --- a/MLEM/Extensions/GraphicsExtensions.cs +++ b/MLEM/Extensions/GraphicsExtensions.cs @@ -1,5 +1,4 @@ using System; -using System.Linq; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -79,7 +78,7 @@ namespace MLEM.Extensions { /// Represents a context in which a is applied. /// This class should be used with . /// - public struct TargetContext : IDisposable { + public readonly struct TargetContext : IDisposable { private readonly GraphicsDevice device; private readonly RenderTargetBinding[] lastTargets; diff --git a/MLEM/Font/GenericFont.cs b/MLEM/Font/GenericFont.cs index 7b6a480..8e51730 100644 --- a/MLEM/Font/GenericFont.cs +++ b/MLEM/Font/GenericFont.cs @@ -1,5 +1,3 @@ -using System; -using System.Collections.Generic; using System.Text; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; diff --git a/MLEM/Font/GenericSpriteFont.cs b/MLEM/Font/GenericSpriteFont.cs index 8a4e766..d25afe1 100644 --- a/MLEM/Font/GenericSpriteFont.cs +++ b/MLEM/Font/GenericSpriteFont.cs @@ -1,8 +1,6 @@ -using System.Collections.Generic; using System.Text; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using MLEM.Extensions; namespace MLEM.Font { /// diff --git a/MLEM/Formatting/Codes/ImageCode.cs b/MLEM/Formatting/Codes/ImageCode.cs index 884c3d6..c6a97cb 100644 --- a/MLEM/Formatting/Codes/ImageCode.cs +++ b/MLEM/Formatting/Codes/ImageCode.cs @@ -1,4 +1,3 @@ -using System; using System.Text.RegularExpressions; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; diff --git a/MLEM/Formatting/TextFormatter.cs b/MLEM/Formatting/TextFormatter.cs index 9faea0c..1441ced 100644 --- a/MLEM/Formatting/TextFormatter.cs +++ b/MLEM/Formatting/TextFormatter.cs @@ -1,6 +1,4 @@ -using System; using System.Collections.Generic; -using System.Collections.ObjectModel; using System.Linq; using System.Text.RegularExpressions; using Microsoft.Xna.Framework; diff --git a/MLEM/Formatting/Token.cs b/MLEM/Formatting/Token.cs index c91bdba..c35ec50 100644 --- a/MLEM/Formatting/Token.cs +++ b/MLEM/Formatting/Token.cs @@ -1,4 +1,3 @@ -using System; using System.Collections.Generic; using System.Linq; using Microsoft.Xna.Framework; diff --git a/MLEM/Formatting/TokenizedString.cs b/MLEM/Formatting/TokenizedString.cs index 36e4ed8..5290811 100644 --- a/MLEM/Formatting/TokenizedString.cs +++ b/MLEM/Formatting/TokenizedString.cs @@ -1,4 +1,3 @@ -using System; using System.Collections.Generic; using System.Linq; using System.Text; diff --git a/MLEM/Input/GenericInput.cs b/MLEM/Input/GenericInput.cs index 0addb76..1809726 100644 --- a/MLEM/Input/GenericInput.cs +++ b/MLEM/Input/GenericInput.cs @@ -10,7 +10,7 @@ namespace MLEM.Input { /// Note that this type is serializable using . /// [DataContract] - public struct GenericInput { + public readonly struct GenericInput { /// /// The of this generic input's current . diff --git a/MLEM/Input/InputHandler.cs b/MLEM/Input/InputHandler.cs index 8a3d6c1..b741989 100644 --- a/MLEM/Input/InputHandler.cs +++ b/MLEM/Input/InputHandler.cs @@ -5,7 +5,6 @@ using System.Linq; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Input; using Microsoft.Xna.Framework.Input.Touch; -using MLEM.Extensions; using MLEM.Misc; namespace MLEM.Input { @@ -433,13 +432,16 @@ namespace MLEM.Input { /// Whether the given control is down /// If the passed control isn't of a supported type public bool IsDown(GenericInput control, int index = -1) { - if (control.Type == GenericInput.InputType.Keyboard) - return this.IsKeyDown(control); - if (control.Type == GenericInput.InputType.Gamepad) - return this.IsGamepadButtonDown(control, index); - if (control.Type == GenericInput.InputType.Mouse) - return this.IsMouseButtonDown(control); - throw new ArgumentException(nameof(control)); + switch (control.Type) { + case GenericInput.InputType.Keyboard: + return this.IsKeyDown(control); + case GenericInput.InputType.Gamepad: + return this.IsGamepadButtonDown(control, index); + case GenericInput.InputType.Mouse: + return this.IsMouseButtonDown(control); + default: + throw new ArgumentException(nameof(control)); + } } /// @@ -451,13 +453,16 @@ namespace MLEM.Input { /// Whether the given control is down /// If the passed control isn't of a supported type public bool IsUp(GenericInput control, int index = -1) { - if (control.Type == GenericInput.InputType.Keyboard) - return this.IsKeyUp(control); - if (control.Type == GenericInput.InputType.Gamepad) - return this.IsGamepadButtonUp(control, index); - if (control.Type == GenericInput.InputType.Mouse) - return this.IsMouseButtonUp(control); - throw new ArgumentException(nameof(control)); + switch (control.Type) { + case GenericInput.InputType.Keyboard: + return this.IsKeyUp(control); + case GenericInput.InputType.Gamepad: + return this.IsGamepadButtonUp(control, index); + case GenericInput.InputType.Mouse: + return this.IsMouseButtonUp(control); + default: + throw new ArgumentException(nameof(control)); + } } /// @@ -469,13 +474,16 @@ namespace MLEM.Input { /// Whether the given control is down /// If the passed control isn't of a supported type public bool IsPressed(GenericInput control, int index = -1) { - if (control.Type == GenericInput.InputType.Keyboard) - return this.IsKeyPressed(control); - if (control.Type == GenericInput.InputType.Gamepad) - return this.IsGamepadButtonPressed(control, index); - if (control.Type == GenericInput.InputType.Mouse) - return this.IsMouseButtonPressed(control); - throw new ArgumentException(nameof(control)); + switch (control.Type) { + case GenericInput.InputType.Keyboard: + return this.IsKeyPressed(control); + case GenericInput.InputType.Gamepad: + return this.IsGamepadButtonPressed(control, index); + case GenericInput.InputType.Mouse: + return this.IsMouseButtonPressed(control); + default: + throw new ArgumentException(nameof(control)); + } } /// diff --git a/MLEM/Input/Keybind.cs b/MLEM/Input/Keybind.cs index 61318e8..2f9a001 100644 --- a/MLEM/Input/Keybind.cs +++ b/MLEM/Input/Keybind.cs @@ -1,8 +1,6 @@ -using System; using System.Collections.Generic; using System.Linq; using System.Runtime.Serialization; -using Microsoft.Xna.Framework.Input; namespace MLEM.Input { /// diff --git a/MLEM/Misc/Direction2.cs b/MLEM/Misc/Direction2.cs index b9d4bb4..b685fc8 100644 --- a/MLEM/Misc/Direction2.cs +++ b/MLEM/Misc/Direction2.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; using System.Linq; using Microsoft.Xna.Framework; diff --git a/MLEM/Pathfinding/AStar3.cs b/MLEM/Pathfinding/AStar3.cs index 66a83a8..ca7e1a4 100644 --- a/MLEM/Pathfinding/AStar3.cs +++ b/MLEM/Pathfinding/AStar3.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using Microsoft.Xna.Framework; namespace MLEM.Pathfinding { diff --git a/MLEM/Textures/UniformTextureAtlas.cs b/MLEM/Textures/UniformTextureAtlas.cs index 34855e6..490365a 100644 --- a/MLEM/Textures/UniformTextureAtlas.cs +++ b/MLEM/Textures/UniformTextureAtlas.cs @@ -1,4 +1,3 @@ -using System; using System.Collections.Generic; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; diff --git a/Sandbox/GameImpl.cs b/Sandbox/GameImpl.cs index f6d27e4..c3b2d47 100644 --- a/Sandbox/GameImpl.cs +++ b/Sandbox/GameImpl.cs @@ -1,6 +1,5 @@ using System; using System.IO; -using System.Linq; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; @@ -11,7 +10,6 @@ using MLEM.Extended.Extensions; using MLEM.Extended.Font; using MLEM.Extended.Tiled; using MLEM.Extensions; -using MLEM.Font; using MLEM.Formatting; using MLEM.Formatting.Codes; using MLEM.Input; @@ -21,10 +19,8 @@ using MLEM.Textures; using MLEM.Ui; using MLEM.Ui.Elements; using MLEM.Ui.Style; -using MonoGame.Extended; using MonoGame.Extended.BitmapFonts; using MonoGame.Extended.Tiled; -using Newtonsoft.Json.Linq; using RectangleF = MonoGame.Extended.RectangleF; namespace Sandbox {