feat(stdlib): Tiled P4 — objects, custom props/types, templates, opt-in spawn (#72)
All checks were successful
bootstrap / cfree-fixpoint (push) Successful in 21s
ci / build-and-test (push) Successful in 1m57s
commit-lint / conventional-commits (push) Successful in 3s
docs / build-and-deploy (push) Successful in 27s

- Object layers: all shapes (rectangle/ellipse/point/polygon/polyline/text) and
  custom properties parse and are queryable — Tiled.object_count / Tiled.object /
  Tiled.object_shape, and Tiled.prop / prop_int / prop_type over any object /
  tile / layer / map.
- Custom types: Tiled.load_types reads an objecttypes.xml project custom-type
  table so a class property resolves its default; enum values resolve as strings.
- Templates: Tiled.template reads a .tx/.tj, and Tiled.load merges each object's
  `template` reference under the instance's overrides (field inheritance).
- Opt-in spawning: Tiled.spawn / Tiled.spawn_layer map an object's class +
  properties onto Ludic components through the reflection ABI (Position from x/y,
  each property to a like-named field). Off by default — no gameplay coupling in
  the core load. Split into tiled_spawn.ludic, spliced only for a Tiled *game*
  (the world table exists only under has_ecs), so a plain map-reading tool never
  links against the reflection ABI.

Proven by library/tiled_p4.ludic (18 assertions) incl. the design's named
orthogonal-outside.tmx object shapes. x test: 95 passed.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-01 15:08:06 +03:00
parent 58e1105f2d
commit b8c71d2a8e
22 changed files with 18278 additions and 17081 deletions

View file

@ -0,0 +1,14 @@
---
id: tiled-load_types
name: Tiled.load_types
category: tiled
kind: namespace-method
tokens: Tiled.load_types
sig: Tiled.load_types(path: string) -> int
tip: Load a project custom-type table.
order: 26
ns: Tiled
member: load_types
---
Loads an <code>objecttypes.xml</code> custom-type table so class/enum properties resolve their defaults; returns the number of types loaded. Each <code>&lt;objecttype&gt;</code> maps to its default <code>&lt;property&gt;</code> list.

View file

@ -0,0 +1,14 @@
---
id: tiled-object
name: Tiled.object
category: tiled
kind: namespace-method
tokens: Tiled.object
sig: Tiled.object(map, layer: int, index: int) -> value
tip: An object on an object layer by index.
order: 21
ns: Tiled
member: object
---
Returns the object <a href="value"><code>Value</code></a> at <code>index</code> on object <code>layer</code> — its <code>x</code>/<code>y</code>/<code>width</code>/<code>height</code>, shape, <code>gid</code>, <code>type</code> (class) and <code>properties</code>.

View file

@ -0,0 +1,14 @@
---
id: tiled-object_count
name: Tiled.object_count
category: tiled
kind: namespace-method
tokens: Tiled.object_count
sig: Tiled.object_count(map, layer: int) -> int
tip: How many objects an object layer holds.
order: 20
ns: Tiled
member: object_count
---
Returns the number of objects on object <code>layer</code> (0 for a non-object layer).

View file

@ -0,0 +1,14 @@
---
id: tiled-object_shape
name: Tiled.object_shape
category: tiled
kind: namespace-method
tokens: Tiled.object_shape
sig: Tiled.object_shape(object) -> string
tip: Classify an object's shape.
order: 22
ns: Tiled
member: object_shape
---
Returns an object's shape: <code>tile</code> (a gid object), <code>point</code>, <code>ellipse</code>, <code>polygon</code>, <code>polyline</code>, <code>text</code>, or <code>rectangle</code> (the default).

View file

@ -0,0 +1,14 @@
---
id: tiled-prop
name: Tiled.prop
category: tiled
kind: namespace-method
tokens: Tiled.prop
sig: Tiled.prop(container, name: string) -> string
tip: A custom property's value, with class-default fallback.
order: 23
ns: Tiled
member: prop
---
Returns the string value of custom property <code>name</code> on <code>container</code> (an object / tile / layer / map), falling back to the container class's default from the project custom-type table (<a href="tiled-load_types"><code>Tiled.load_types</code></a>). <code>""</code> when absent everywhere.

View file

@ -0,0 +1,14 @@
---
id: tiled-prop_int
name: Tiled.prop_int
category: tiled
kind: namespace-method
tokens: Tiled.prop_int
sig: Tiled.prop_int(container, name: string) -> int
tip: A custom property parsed as an integer.
order: 24
ns: Tiled
member: prop_int
---
Like <a href="tiled-prop"><code>Tiled.prop</code></a> but parsed as an integer (<code>true</code>/<code>false</code> → 1/0), with the same class-default fallback.

View file

@ -0,0 +1,14 @@
---
id: tiled-prop_type
name: Tiled.prop_type
category: tiled
kind: namespace-method
tokens: Tiled.prop_type
sig: Tiled.prop_type(container, name: string) -> string
tip: A custom property's declared type.
order: 25
ns: Tiled
member: prop_type
---
Returns the declared type of custom property <code>name</code> (<code>string</code>/<code>int</code>/<code>float</code>/<code>bool</code>/<code>color</code>/<code>file</code>/<code>object</code>/<code>class</code>/an enum), with the class-default fallback.

View file

@ -0,0 +1,14 @@
---
id: tiled-spawn
name: Tiled.spawn
category: tiled
kind: namespace-method
tokens: Tiled.spawn
sig: Tiled.spawn(map, object, model: string) -> int
tip: Spawn a Ludic entity from an object.
order: 28
ns: Tiled
member: spawn
---
Opt-in: spawns an entity of <code>model</code> from an <code>object</code> — its <code>Position</code> (if the model has one) takes the object's x/y, and each object custom property sets a like-named int/bool component field through the reflection ABI. Returns the entity, or -1 if the model is unknown. The core load never calls this.

View file

@ -0,0 +1,14 @@
---
id: tiled-spawn_layer
name: Tiled.spawn_layer
category: tiled
kind: namespace-method
tokens: Tiled.spawn_layer
sig: Tiled.spawn_layer(map, layer: int, model: string) -> int
tip: Spawn every object on a layer.
order: 29
ns: Tiled
member: spawn_layer
---
Spawns every object on object <code>layer</code> as <code>model</code> (see <a href="tiled-spawn"><code>Tiled.spawn</code></a>); returns how many were spawned.

View file

@ -0,0 +1,14 @@
---
id: tiled-template
name: Tiled.template
category: tiled
kind: namespace-method
tokens: Tiled.template
sig: Tiled.template(path: string) -> value
tip: Read a template file into an object value.
order: 27
ns: Tiled
member: template
---
Reads a <code>.tx</code>/<code>.tj</code> template file and returns its object <a href="value"><code>Value</code></a> — the reusable object definition an instance inherits. <a href="tiled-load"><code>Tiled.load</code></a> resolves each object's <code>template</code> reference automatically, merging the template's fields under the instance's overrides.