Skip to content

Commit 80e63d6

Browse files
committed
Fix codegen default enums
1 parent b8faf5e commit 80e63d6

File tree

4 files changed

+24
-8
lines changed

4 files changed

+24
-8
lines changed

LDtk.Codegen/Generators/ClassGenerator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ void GenCustomFieldDefData(FieldDefinition[] fieldDefs)
144144
string value = defaultValue.GetString();
145145
string enumValue = $"{enumName}.{value}";
146146

147-
Line($"entity.{field.Identifier} = {enumValue};");
147+
Line($"{field.Identifier} = {enumValue},");
148148
}
149149

150150
switch (field._Type)

LDtk.Example/LDtkTypes/LDtkMonogameExample/Entities/Crate.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public partial class Crate : ILDtkEntity
2828
boolean = true,
2929
name = "test",
3030
multilines = "test",
31+
alphabet = Alphabet.B,
3132
};
3233

3334
public string Identifier { get; set; }
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace LDtkTypes.Platformer;
2+
3+
// This file was automatically generated, any modifications will be lost!
4+
5+
#pragma warning disable
6+
public enum Enum
7+
{
8+
}
9+
#pragma warning restore

LDtk.Example/Platformer/Content/LDtkMonogameExample.ldtk

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"iid": "0108f3a0-1030-11f0-9e8b-833b93033522",
1212
"jsonVersion": "1.5.3",
1313
"appBuildId": 473703,
14-
"nextUid": 183,
14+
"nextUid": 184,
1515
"identifierStyle": "Capitalize",
1616
"toc": [],
1717
"worldLayout": null,
@@ -2259,7 +2259,10 @@
22592259
"max": null,
22602260
"regex": null,
22612261
"acceptFileTypes": null,
2262-
"defaultOverride": null,
2262+
"defaultOverride": {
2263+
"id": "V_String",
2264+
"params": ["B"]
2265+
},
22632266
"textLanguageMode": null,
22642267
"symmetricalRef": false,
22652268
"autoChainRef": true,
@@ -2557,11 +2560,14 @@
25572560
"savedSelections": [],
25582561
"cachedPixelData": { "opaqueTiles": "000000000000", "averageColors": "958a958a958a958a958a958a969a969a968a958a4eef2eee" }
25592562
}
2560-
], "enums": [{ "identifier": "Alphabet", "uid": 81, "values": [
2561-
{ "id": "A", "tileRect": null, "color": 0 },
2562-
{ "id": "B", "tileRect": null, "color": 0 },
2563-
{ "id": "C", "tileRect": null, "color": 0 }
2564-
], "iconTilesetUid": null, "externalRelPath": null, "externalFileChecksum": null, "tags": [] }], "externalEnums": [], "levelFields": [
2563+
], "enums": [
2564+
{ "identifier": "Alphabet", "uid": 81, "values": [
2565+
{ "id": "A", "tileRect": null, "color": 0 },
2566+
{ "id": "B", "tileRect": null, "color": 0 },
2567+
{ "id": "C", "tileRect": null, "color": 0 }
2568+
], "iconTilesetUid": null, "externalRelPath": null, "externalFileChecksum": null, "tags": [] },
2569+
{ "identifier": "Enum", "uid": 183, "values": [], "iconTilesetUid": null, "externalRelPath": null, "externalFileChecksum": null, "tags": [] }
2570+
], "externalEnums": [], "levelFields": [
25652571
{
25662572
"identifier": "Biome",
25672573
"doc": null,

0 commit comments

Comments
 (0)