Keyboard shortcuts

Press ← or → to navigate between chapters

Press ? to show this help

Press Esc to hide this help

data/archetypes/

An archetype: a kind of entity, such as the player, a boar or a pet, with the components every instance carries and their default values. Spawning names an archetype (/entity spawn mymod:boar). An archetype may inherit from a parent, list components an instance may gain later, and choose among variants when it spawns. Component values are written in each component’s own schema; the components themselves are declared in code. The gameplay, AI and navigation registries are reached from here through components that name their entries (a brain, a locomotion profile, a loot table).

Registrymanifold:archetype
Filesdata/archetypes/*.ron, *.update.ron, *.final.ron
Sidesboth: the server and every client load it, and the handshake’s data hash covers it
Readsmanifold:component, manifold:spatial-layer
ContractArchetypes, data stage

Entry

A record, written Archetype(..); the name before the parentheses is optional.

FieldTypeRequiredDefaultDescription
idstringyesThe archetype’s key, <mod-id>:<name>, in the declaring mod’s namespace.
parentstring or NonenononeThe archetype this one inherits from. The child merges over its parent: records by field and maps by key, while lists and scalars replace. optional lists are joined, and a parent’s abstract, remove and (when the child has its own) variants are not inherited.
abstractboolnofalsetrue for a parent that never spawns. Not inherited.
copyableboolnofalseWhether the clipboard and blueprints may copy instances. Inherited.
persistencePersistencenoSessionWhere instances are saved. A spawn may override it.
spatial_layerslist of stringnononeThe spatial index layers instances occupy: manifold:spatial-layer keys, or a bare name for the engine’s (player, creature, item, projectile, prop).
bounds_radiusf32no0.5The radius, in metres, the spatial index gives each instance.
tagslist of stringnononeTags (manifold:tag keys) every instance starts with.
componentsmap of string to component-valuenononeThe components every instance carries, by component key, each with its value; () takes the component’s defaults. A child’s value merges into its parent’s; Replace(value) replaces it instead. Components that a listed component requires are added with their defaults.
optionallist of stringnononeComponents an instance may gain while it lives, by key. Joined with the parent’s list.
removelist of stringnononeInherited components this archetype drops, by key.
variantslist of Variantnoone variant, the archetype itselfSpawn-time variants. Exactly one has no when: the fallback.

Example

From game/flagship-game/data/archetypes/pet.ron:

Archetype(
    id: "flagship-game:pet",
    persistence: Saved,
    spatial_layers: ["creature"],
    bounds_radius: 0.45,
    components: {
        "manifold-sim:position": (),
        "manifold-sim:velocity": (),
        "manifold-sim:yaw": (),
        "manifold-sim:pitch": (),
        "manifold-sim:motion-mode": (),
        "manifold-model:model": (asset: "flagship:creatures/pet"),
        "manifold-anim:anim-setup": (bindings: "flagship:animations/pet"),
        "manifold-anim:hit-eval": (mode: Lazy),
        "manifold-model:event-cues": (events: ["footstep"], sounds: ["flagship:block/place"],
                                      effects: [""], threshold: 0.5),
        "manifold-nav:locomotion": (profile: "flagship-game:pet"),
        "manifold-gameplay:stats": (base: { "manifold:max_health": 16.0 }),
        "manifold-gameplay:damage-receiver": (death: (corpse: Linger(ticks: 40), despawn: AfterCorpse)),
        "manifold-gameplay:faction": (inherit_owner_faction: true),
        "manifold-ai:brain": (def: "flagship-game:pet"),
        "manifold-ai:ai-presentation": (),
    },
)

Types

Persistence

Where an archetype’s instances are saved.

VariantWrittenDescription
SavedSavedSaved with the world.
ExternalExternalSaved by another system, such as a player’s own record.
SessionSessionNever saved: gone after a restart.

Variant

A spawn-time variant of an archetype. Variants are tried in descending priority, ties in the order written, and the first whose when holds is chosen.

A record: Variant(..) or (..).

FieldTypeRequiredDefaultDescription
idstringyesThe variant’s name within its archetype (tusker). A spawn may name it (/entity spawn flagship-game:boar#tusker).
whencondition or NonenoNoneWhen the variant applies: Some(Chance(0.1)), or any condition the spawn context can read (the spawn position, the biome). None is the fallback, which always holds.
priorityi32no0Higher priorities are tried first.
patchmap of string to component-valuenononeComponent values that override or add to the archetype’s, merged in the same way as a child’s.

Value forms used here: component-value, condition.