A list no longer says what its items are. ListDef.items, ListDef.fields,
ListFieldDef.items and SetListItemsCommand are gone; the single seam is
src/core/properties/listItems.ts. JSON already tells number, text, boolean
and struct apart, so only two kinds need a tag: {"$color": n} and the new
{"$texture": id}. Field names cannot start with "$", so a tag never
collides with a struct field. On a data link a texture item arrives as
its bare id; the graph has no images.
List tab: the mark in front of each row is the kind picker, "+ Item"
asks for the kind, both are ordinary value edits (one undo step). A list
inside a struct field only offers the flat kinds because the depth rule
forbids a struct item there (ListAccess.kinds); the menu used to offer
it and silently do nothing.
Legacy lists that declared items: 'color' are tagged on load.
Actor demo: the four walk animations and four standing frames live in
two list variables of texture items indexed by facing (Item at), so the
graph can be rebuilt in the editor. The stand frames get their grid ids
back; 44 nodes instead of 46.
Also: the user's edits to on-start-during-play.md and the new note
reseed-because-of-list.md.
Verified: check.sh 794 tests, full e2e 631 checks, smokes 24/19/20.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
77 lines
2.6 KiB
JavaScript
77 lines
2.6 KiB
JavaScript
/**
|
||
* Small factories for writing project documents by hand (the seed scripts). They produce the
|
||
* exact shape `src/core/store/serialize.ts` reads; optional fields get their defaults.
|
||
*/
|
||
|
||
/** A scene object (also a container template entry). Position defaults to the origin. */
|
||
export const sceneObject = (
|
||
id,
|
||
assetId,
|
||
{ name = '', x = 0, y = 0, z = 0, overrides = {}, parentId = '', instanceEdits, editorOffset } = {},
|
||
) => ({
|
||
id,
|
||
assetId,
|
||
name,
|
||
position: { x, y, z },
|
||
overrides,
|
||
parentId,
|
||
...(instanceEdits ? { instanceEdits } : {}),
|
||
...(editorOffset ? { editorOffset } : {}),
|
||
});
|
||
|
||
/**
|
||
* The id an object of a placed container resolves to: `<instance>~<template ids>`. A placed
|
||
* container stores nothing but itself, so this is how its content is addressed – in the editor,
|
||
* in a running game and in the check scripts alike (see `src/core/model/instance.ts`).
|
||
*/
|
||
export const instanceChild = (instanceId, ...templatePath) => `${instanceId}~${templatePath.join('/')}`;
|
||
|
||
export const edge = (id, from, fromPort, to, toPort) => ({
|
||
id,
|
||
from: { node: from, port: fromPort },
|
||
to: { node: to, port: toPort },
|
||
});
|
||
|
||
/** A graph node; `params` holds settings and inline input values alike. `ports` only on the types that declare them. */
|
||
export const node = (id, type, x, y, params = {}, ports) => ({
|
||
id,
|
||
type,
|
||
x,
|
||
y,
|
||
params,
|
||
...(ports ? { ports } : {}),
|
||
});
|
||
|
||
/** A port a node declares: an input of a start node, a field of a struct, a variable read by `Variables`. */
|
||
export const port = (key, kind) => ({ key, kind });
|
||
|
||
/** A variable a `Variables` node writes as well as reads. */
|
||
export const written = (key, kind) => ({ key, kind, write: true });
|
||
|
||
/** The settings of a `Properties` node: the object type it offers ports from, and for `behavior` which one. */
|
||
export const propertiesOf = (objectType, objectBehavior) => ({
|
||
objectType,
|
||
...(objectBehavior ? { objectBehavior } : {}),
|
||
});
|
||
|
||
/**
|
||
* A behavior variable declaration. `fields` is the shape of a `struct`; a `list` declares nothing,
|
||
* its items each carry their own kind (a colour as `colorItem`).
|
||
*/
|
||
export const variable = (key, kind, value, fields) => ({
|
||
key,
|
||
label: key,
|
||
kind,
|
||
default: value,
|
||
...(fields ? { fields } : {}),
|
||
});
|
||
|
||
/** A struct field declaration. */
|
||
export const field = (key, kind = 'number') => ({ key, kind });
|
||
|
||
/** A colour as a list item: inside a list, 0xRRGGBB would otherwise be a plain number. */
|
||
export const colorItem = (color) => ({ $color: color });
|
||
|
||
/** A picture as a list item – a texture, one of its frames or an animation, all one id. */
|
||
export const textureItem = (id) => ({ $texture: id });
|