1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-05-25 01:43:38 +02:00

minor general cleanup

This commit is contained in:
Ell 2021-03-08 15:12:13 +01:00
parent dc514815c3
commit 0b39928334
6 changed files with 12 additions and 12 deletions

View file

@ -6,8 +6,8 @@ namespace Demos.DesktopGL {
public static void Main() {
TextInputWrapper.Current = new TextInputWrapper.DesktopGl<TextInputEventArgs>((w, c) => w.TextInput += c);
using (var game = new GameImpl())
game.Run();
using var game = new GameImpl();
game.Run();
}
}

View file

@ -128,18 +128,19 @@ namespace MLEM.Extended.Tiled {
/// <summary>
/// Returns an enumerable of normals and penetration amounts for each <see cref="TileCollisionInfo"/> that intersects with the given <see cref="RectangleF"/> area.
/// The normals and penetration amounts are based on <see cref="MLEM.Extensions.NumberExtensions.Penetrate"/>.
/// Note that all x penetrations are returned before all y penetrations, which improves collision detection in sidescrolling games with gravity.
/// Note that all x penetrations are returned before all y penetrations, which improves collision detection in sidescrolling games with gravity. Note that this behavior can be inverted using <paramref name="prioritizeX"/>.
/// </summary>
/// <param name="getArea">The area to penetrate</param>
/// <param name="included">A function that determines if a certain info should be included or not</param>
/// <param name="prioritizeX">Whether all x penetrations should be prioritized (returned first). If this is false, all y penetrations are prioritized instead.</param>
/// <returns>A set of normals and penetration amounts</returns>
public IEnumerable<(Vector2, float)> GetPenetrations(Func<RectangleF> getArea, Func<TileCollisionInfo, bool> included = null) {
public IEnumerable<(Vector2, float)> GetPenetrations(Func<RectangleF> getArea, Func<TileCollisionInfo, bool> included = null, bool prioritizeX = true) {
foreach (var col in this.GetCollidingAreas(getArea(), included)) {
if (getArea().Penetrate(col, out var normal, out var penetration) && normal.X != 0)
if (getArea().Penetrate(col, out var normal, out var penetration) && normal.X != 0 == prioritizeX)
yield return (normal, penetration);
}
foreach (var col in this.GetCollidingAreas(getArea(), included)) {
if (getArea().Penetrate(col, out var normal, out var penetration) && normal.Y != 0)
if (getArea().Penetrate(col, out var normal, out var penetration) && normal.X == 0 == prioritizeX)
yield return (normal, penetration);
}
}

View file

@ -6,8 +6,8 @@ namespace TemplateNamespace {
public static void Main() {
TextInputWrapper.Current = new TextInputWrapper.DesktopGl<TextInputEventArgs>((w, c) => w.TextInput += c);
using (var game = new GameImpl())
game.Run();
using var game = new GameImpl();
game.Run();
}
}

View file

@ -6,7 +6,7 @@ namespace MLEM.Misc {
/// This class contains a <see cref="DrawAutoTile"/> method that allows users to easily draw a tile with automatic connections.
/// For auto-tiling in this manner to work, auto-tiled textures have to be laid out in a format described in <see cref="DrawAutoTile"/>.
/// </summary>
public class AutoTiling {
public static class AutoTiling {
/// <summary>
/// This method allows for a tiled texture to be drawn in an auto-tiling mode.

View file

@ -21,7 +21,6 @@ using MLEM.Textures;
using MLEM.Ui;
using MLEM.Ui.Elements;
using MLEM.Ui.Style;
using MonoGame.Extended.BitmapFonts;
using MonoGame.Extended.Tiled;
namespace Sandbox {

View file

@ -6,8 +6,8 @@ namespace Sandbox {
private static void Main() {
TextInputWrapper.Current = new TextInputWrapper.DesktopGl<TextInputEventArgs>((w, c) => w.TextInput += c);
using (var game = new GameImpl())
game.Run();
using var game = new GameImpl();
game.Run();
}
}