Skip to content

Commit

Permalink
Fix styling warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
IrishBruse committed May 28, 2024
1 parent c1fdf81 commit d156679
Show file tree
Hide file tree
Showing 12 changed files with 25 additions and 18 deletions.
2 changes: 2 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ dotnet_style_coalesce_expression = true:suggestion
dotnet_style_null_propagation = true:suggestion
dotnet_style_explicit_tuple_names = true:suggestion

dotnet_style_prefer_collection_expression = false

# CSharp code style settings:

# IDE0040: Add accessibility modifiers
Expand Down
4 changes: 1 addition & 3 deletions LDtk.Codegen/Generators/ClassGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ namespace LDtk.Codegen.Generators;

using LDtk.Codegen;

public class ClassGenerator : BaseGenerator
public class ClassGenerator(LDtkFile ldtkFile, Options options) : BaseGenerator(ldtkFile, options)
{
public ClassGenerator(LDtkFile ldtkFile, Options options) : base(ldtkFile, options) { }

public void Generate()
{
// Level Classes
Expand Down
4 changes: 1 addition & 3 deletions LDtk.Codegen/Generators/EnumGenerator.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
namespace LDtk.Codegen.Generators;

public class EnumGenerator : BaseGenerator
public class EnumGenerator(LDtkFile ldtkFile, Options options) : BaseGenerator(ldtkFile, options)
{
public EnumGenerator(LDtkFile ldtkFile, Options options) : base(ldtkFile, options) { }

public void Generate()
{
foreach (EnumDefinition e in LDtkFile.Defs.Enums)
Expand Down
4 changes: 1 addition & 3 deletions LDtk.Codegen/Generators/IidGenerator.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
namespace LDtk.Codegen.Generators;

public class IidGenerator : BaseGenerator
public class IidGenerator(LDtkFile ldtkFile, Options options) : BaseGenerator(ldtkFile, options)
{
public IidGenerator(LDtkFile ldtkFile, Options options) : base(ldtkFile, options) { }

public void Generate()
{
Line($"namespace {Options.Namespace};");
Expand Down
1 change: 1 addition & 0 deletions LDtk.Example/LDtkTypes/World/CustomLevelDataName.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ namespace LDtkTypes;
#pragma warning disable

using LDtk;

using Microsoft.Xna.Framework;

public partial class CustomLevelDataName
Expand Down
1 change: 1 addition & 0 deletions LDtk.Example/LDtkTypes/World/Entities/Enemy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ namespace LDtkTypes;
#pragma warning disable

using LDtk;

using Microsoft.Xna.Framework;

public partial class Enemy : ILDtkEntity
Expand Down
1 change: 1 addition & 0 deletions LDtk.Example/LDtkTypes/World/Entities/Gun_Pickup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ namespace LDtkTypes;
#pragma warning disable

using LDtk;

using Microsoft.Xna.Framework;

public partial class Gun_Pickup : ILDtkEntity
Expand Down
1 change: 1 addition & 0 deletions LDtk.Example/LDtkTypes/World/Entities/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ namespace LDtkTypes;
#pragma warning disable

using LDtk;

using Microsoft.Xna.Framework;

public partial class Player : ILDtkEntity
Expand Down
1 change: 1 addition & 0 deletions LDtk.Example/LDtkTypes/World/Entities/RefTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ namespace LDtkTypes;
#pragma warning disable

using LDtk;

using Microsoft.Xna.Framework;

public partial class RefTest : ILDtkEntity
Expand Down
1 change: 1 addition & 0 deletions LDtk.Example/LDtkTypes/World/LDtkLevelData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ namespace LDtkTypes;
#pragma warning disable

using LDtk;

using Microsoft.Xna.Framework;

public partial class LDtkLevelData
Expand Down
16 changes: 8 additions & 8 deletions LDtk.Tests/IntGridTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ public class IntGridTests
[InlineData(15.00f, 15.00f, 1, 1)]
public void FromWorldToGridSpaceVector2(float worldX, float worldY, int expectedGridSpaceX = 0, int expectedGridSpaceY = 0)
{
var intGrid = new LDtkIntGrid()
LDtkIntGrid intGrid = new()
{
WorldPosition = new Point(-1, -1),
TileSize = 16
};

Vector2 positionInWorld = new Vector2(worldX, worldY);
Point expectedPositionInGridSpace = new Point(expectedGridSpaceX, expectedGridSpaceY);
Vector2 positionInWorld = new(worldX, worldY);
Point expectedPositionInGridSpace = new(expectedGridSpaceX, expectedGridSpaceY);
Assert.Equal(intGrid.FromWorldToGridSpace(positionInWorld), expectedPositionInGridSpace);
}

Expand All @@ -33,14 +33,14 @@ public void FromWorldToGridSpaceVector2(float worldX, float worldY, int expected
[InlineData(15, 15, 1, 1)]
public void FromWorldToGridSpacePoint(int worldX, int worldY, int expectedGridSpaceX = 0, int expectedGridSpaceY = 0)
{
var intGrid = new LDtkIntGrid()
LDtkIntGrid intGrid = new()
{
WorldPosition = new Point(-1, -1),
TileSize = 16
};

Point positionInWorld = new Point(worldX, worldY);
Point expectedPositionInGridSpace = new Point(expectedGridSpaceX, expectedGridSpaceY);
Point positionInWorld = new(worldX, worldY);
Point expectedPositionInGridSpace = new(expectedGridSpaceX, expectedGridSpaceY);
Assert.Equal(intGrid.FromWorldToGridSpace(positionInWorld), expectedPositionInGridSpace);
}

Expand All @@ -51,7 +51,7 @@ public void FromWorldToGridSpacePoint(int worldX, int worldY, int expectedGridSp
[InlineData(-1, -1, false)]
public void ContainsPoint(int x, int y, bool isPointInGrid)
{
var intGrid = new LDtkIntGrid()
LDtkIntGrid intGrid = new()
{
GridSize = new Point(2, 2)
};
Expand All @@ -66,7 +66,7 @@ public void ContainsPoint(int x, int y, bool isPointInGrid)
[InlineData(-.01f, -.01f, false)]
public void ContainsVector2(float x, float y, bool isPointInGrid)
{
var intGrid = new LDtkIntGrid()
LDtkIntGrid intGrid = new()
{
GridSize = new Point(2, 2)
};
Expand Down
7 changes: 6 additions & 1 deletion LDtk/JsonPartials/LDtkFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public LDtkFile() { }

/// <summary> An array containing various advanced flags (ie. options or other states). </summary>
[JsonPropertyName("flags")]
public string[] Flags { get; set; }
public string[]? Flags { get; set; }

/// <summary> Loads the ldtk world file from disk directly using json source generator. </summary>
/// <param name="filePath"> Path to the .ldtk file. </param>
Expand Down Expand Up @@ -77,6 +77,11 @@ static void ValidateFile(LDtkFile file)
throw new LDtkException("LDtk file version is not supported. Please update your LDtk version.");
}

if (file.Flags == null)
{
throw new LDtkException("LDtk file is missing required flags. Please enable them in the ldtk file flags in the UI.");
}

if (!file.Flags.Contains("MultiWorlds"))
{
throw new LDtkException("LDtk file is not a multiworld file. Please enable MultiWorlds in the ldtk file flags.");
Expand Down

0 comments on commit d156679

Please sign in to comment.