Skip to content

Commit 9b8d540

Browse files
committed
Add entity ref and loadLevels
1 parent dfa4085 commit 9b8d540

File tree

26 files changed

+551
-293
lines changed

26 files changed

+551
-293
lines changed

LDtk.Codegen/Converter.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ static string TypeConversion(string input)
3838
"Multilines" => "string",
3939
"Float" => "float",
4040
"Bool" => "bool",
41+
"Tile" => "TilesetRectangle",
4142
_ => input,
4243
};
4344
}

LDtk.Codegen/Generators/ClassGenerator.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ void GenClass(string identifier, FieldDefinition[] fields, string folder)
5151
foreach (FieldDefinition value in fields)
5252
{
5353
string type = Converter.ConvertFieldDefinitionTypes(value._Type, options.PointAsVector2);
54+
55+
if (value.CanBeNull)
56+
{
57+
type += "?";
58+
}
59+
5460
Line($"public {type} {value.Identifier} {{ get; set; }}");
5561
}
5662
}

LDtk.Codegen/LDtk.Codegen.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
</ItemGroup>
1414

1515
<PropertyGroup>
16-
<Version>0.5.1</Version>
16+
<Version>0.6.0</Version>
1717
<Authors>Ethan Conneely</Authors>
1818
<Product>LDtk Monogame</Product>
1919
<PackageId>LDtkMonogame.Codegen</PackageId>

LDtk.ContentPipeline/LDtk.ContentPipeline.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
</ItemGroup>
1616

1717
<PropertyGroup>
18-
<Version>0.5.1</Version>
18+
<Version>0.6.0</Version>
1919
<Authors>Ethan Conneely</Authors>
2020
<Product>LDtk Monogame</Product>
2121
<PackageId>LDtkMonogame.ContentPipeline</PackageId>

LDtk.Documentation/book.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ title = "LDtkMonogame"
77
description = "The LDtkMonogame nuget documentation"
88

99
[build]
10-
build-dir = "docs/docs/next"
10+
build-dir = "docs/"
1111

1212
[output.html]
1313
theme = "theme"

LDtk.Documentation/csharpHighlight.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,12 @@ const keywords = [
1212
"class ",
1313
"get;",
1414
"set;",
15+
"foreach"
1516
]
1617

1718
const classes = [
19+
"LDtkLevelData",
20+
1821
"LDtkRenderer",
1922
"LDtkFile",
2023
"LDtkWorld",
@@ -23,7 +26,6 @@ const classes = [
2326
"ILDtkEntity",
2427
"Gun_Pickup",
2528

26-
"LDtkLevelData",
2729

2830
"Vector2",
2931
" Color",

LDtk.Documentation/src/Changelog/0.5.0.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Version 0.4.0
1+
# Version 0.5.0
22

33
## Added
44
- Support for ldtk 1.1.3

LDtk.Documentation/src/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
----
1515

1616
- [Changelog](changelog.md)
17+
- [0.5.0](Changelog/0.5.0.md)
1718
- [0.4.0](Changelog/0.4.0.md)
1819
- [0.3.1](Changelog/0.3.1.md)
1920
- [0.3.0](Changelog/0.3.0.md)

LDtk.Documentation/src/Tutorials/codegen.md

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ First you need to install the tool which is easy open up cmd/terminal and run
1212

1313
```shell
1414
dotnet tool install --global LDtkMonogame.Codegen
15+
dotnet tool update LDtkMonogame.Codegen --global
1516
```
1617

17-
With that now installed globally you can run it by typing
18+
With that now installed globally you can run it by typing
1819

1920
```shell
2021
ldtkgen
@@ -24,7 +25,7 @@ It will print a help message to the screen telling you how you can configure ldt
2425

2526
## Automation
2627

27-
So running the tool on every `.ldtk` file you have and remembering the arguments to pass every time would get abit out of hand so you can automate that
28+
So running the tool on every `.ldtk` file you have and remembering the arguments to pass every time would get abit out of hand so you can automate that
2829
put this in your `.csproj` file and set the path to point to your ldtk file(be careful with paths that have a space you will have to escape those in the string).
2930

3031
```xml
@@ -35,18 +36,20 @@ put this in your `.csproj` file and set the path to point to your ldtk file(be c
3536

3637
## ldtkgen flags
3738

38-
- -i, --input **Required**. Input LDtk world file.
39-
40-
- -o, --output **(Default: LDtkTypes/)** The output folder/file depending on if single file is set.
41-
42-
- -n, --namespace **(Default: LDtkTypes)** Namespace to put the generated files into.
43-
44-
- --LevelClassName **(Default: LDtkLevelData)** The name to give the custom level file.
45-
46-
- --SingleFile **(Default: false)** Output all the LDtk files into a single file.
47-
48-
- --PointAsVector2 **(Default: false)** Convert any Point fields or Point[] to Vector2 or Vector2[]
49-
50-
- --help Display the help screen.
51-
52-
- --version Display version information.
39+
- -i, --input **Required**. Input LDtk world file.
40+
41+
- -o, --output **(Default: LDtkTypes/)** The output folder/file depending on if single file is set.
42+
43+
- -n, --namespace **(Default: LDtkTypes)** Namespace to put the generated files into.
44+
45+
- --LevelClassName **(Default: LDtkLevelData)** The name to give the custom level file.
46+
47+
- --SingleFile **(Default: false)** Output all the LDtk files into a single file.
48+
49+
- --PointAsVector2 **(Default: false)** Convert any Point fields or Point[] to Vector2 or Vector2[]
50+
51+
- --FileNameInNamespace Adds the file name of the world to the namespace eg 'Example.ldtk' will become 'namespace LDtkTypes.Example;'
52+
53+
- --help Display the help screen.
54+
55+
- --version Display version information.

LDtk.Documentation/src/Tutorials/level.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@ Level's hold all the data for each individual level and include the tiles and al
44

55
If you are using external levels with ldtk. You will need to load the level otherwise ignore this next step.
66

7-
```
8-
Level myLevel = world.LoadLevel("Level1");
7+
```cs
8+
LDtkLevel level0 = world.LoadLevel("Level_0"); // Identifier
9+
LDtkLevel level1 = world.LoadLevel(Worlds.World.Level_1);// Guid/Iid
910
```
1011

11-
Now with `myLevel` you can access all the ldtk layers inside of it.
12-
If your level has custom fields you will need to load the data using `GetCustomFields()`.
12+
Now with `myLevel` you can access all the ldtk layers inside of it.
13+
If your level has custom fields you will need to load the data using `GetCustomFields()`.
1314

14-
If you are using the [Codegen](codegen.md) tool the `LDtkLevelData` file will be created for you automatically.
15+
If you are using the [Codegen](codegen.md) tool the `LDtkLevelData` file will be created for you automatically.
1516

1617
```cs
1718
public class LDtkLevelData
@@ -22,3 +23,4 @@ public class LDtkLevelData
2223
```
2324

2425
For more information on the level refer to the ldtk documentation [ldtk-LevelJson](https://ldtk.io/json/#ldtk-LevelJson)
26+
cd

0 commit comments

Comments
 (0)