From 7b820460d571fb0b80ad62e071302223807a0699 Mon Sep 17 00:00:00 2001 From: Louis Pearson Date: Tue, 2 Aug 2022 18:43:42 -0600 Subject: [PATCH] Add FieldInstance --- src/LDtk.zig | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/src/LDtk.zig b/src/LDtk.zig index b93c1d8..be6c62a 100644 --- a/src/LDtk.zig +++ b/src/LDtk.zig @@ -103,7 +103,10 @@ const LayerInstance = struct { }; const __Type = struct { - IntGrid, Entities, Tiles, AutoLayer, + IntGrid, + Entities, + Tiles, + AutoLayer, }; /// 2.2. Tile instance @@ -138,9 +141,38 @@ const EntityInstance = struct { }; /// 2.4. Field Instance -const FieldInstance = struct {}; +const FieldInstance = struct { + __identifier: []const u8, + __tile: ?TilesetRectangle, + // TODO: type and value have many possible values and are not always strings. + // Figure out if we can use JSON.parse for this + __type: FieldType, + __value: anytype, + defUid: u64, +}; + +const FieldType = union(enum) { + Int, + Float, + String, + Enum: []const u8, + Bool, +}; + /// 2.4.2 Field instance entity reference +const FieldInstanceRef = struct { + entityIid: []const u8, + layerIid: []const u8, + levelIid: []const u8, + worldIid: []const u8, +}; + /// 2.4.3 Field instance grid point +const FiledInstanceGridPoint = struct { + cx: i64, + cy: i64, +}; + /// 3. Definitions const Defs = struct { layers: []Layer,