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,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<template>
<object type="Enemy" width="16" height="16">
<properties>
<property name="hp" type="int" value="25"/>
</properties>
</object>
</template>

View file

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Hand-authored P4 fixture: object shapes, custom types, templates (issue #72). CC0. -->
<map version="1.10" tiledversion="1.10.2" orientation="orthogonal" renderorder="right-down" width="16" height="16" tilewidth="16" tileheight="16" infinite="0" nextlayerid="3" nextobjectid="13">
<objectgroup id="1" name="shapes">
<object id="1" x="10" y="10" width="20" height="30"/>
<object id="2" x="40" y="10" width="20" height="20"><ellipse/></object>
<object id="3" x="70" y="10"><point/></object>
<object id="4" x="90" y="10"><polygon points="0,0 16,0 16,16 0,16"/></object>
<object id="5" x="120" y="10"><polyline points="0,0 10,10 20,0"/></object>
<object id="6" x="10" y="60" width="80" height="20"><text pixelsize="12" halign="center">Hello</text></object>
</objectgroup>
<objectgroup id="2" name="spawns">
<object id="10" type="Enemy" x="32" y="48" width="16" height="16">
<properties><property name="hp" type="int" value="99"/></properties>
</object>
<object id="11" type="Enemy" x="64" y="48" width="16" height="16"/>
<object id="12" template="p4_enemy.tx" x="80" y="48"/>
</objectgroup>
</map>

View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<objecttypes>
<objecttype name="Enemy" color="#ff0000">
<property name="hp" type="int" default="10"/>
<property name="speed" type="int" default="3"/>
<property name="boss" type="bool" default="false"/>
</objecttype>
</objecttypes>