Skip to content

Engine Play Data Archetype ​

Engine play data archetype is used by level to populate entities in play mode.

Syntax ​

ts
type EnginePlayDataArchetype = {
    name: EngineArchetypeName | (string & {})
    hasInput: boolean
    preprocess?: EnginePlayDataArchetypeCallback
    spawnOrder?: EnginePlayDataArchetypeCallback
    shouldSpawn?: EnginePlayDataArchetypeCallback
    initialize?: EnginePlayDataArchetypeCallback
    updateSequential?: EnginePlayDataArchetypeCallback
    touch?: EnginePlayDataArchetypeCallback
    updateParallel?: EnginePlayDataArchetypeCallback
    terminate?: EnginePlayDataArchetypeCallback
    imports: {
        name: EngineArchetypeDataName | (string & {})
        index: number
        def?: number
    }[]
    exports: (EngineArchetypeDataName | (string & {}))[]
}

type EnginePlayDataArchetypeCallback = {
    index: number
    order?: number
}

name ​

Name of this archetype, which will be referenced by entities in level data.

Special archetype names will have its effect applied automatically:

  • #BPM_CHANGE: Signals a BPM change and will affect BPM change related functions. Entity with this archetype must also provide data named #BEAT and #BPM.

  • #TIMESCALE_CHANGE: Signals a time scale change and will affect time scale change related functions. Entity with this archetype must also provide data named #BEAT and #TIMESCALE.

hasInput ​

If true, Sonolus will treat entities with this archetype to be playable entities, and will contribute to judgment, combo, life, score, etc.

imports ​

Imported data to be inject into Entity Data block.

Imported data with matching name will be injected at index of Entity Data block.

exports ​

Exported data to be written into replay.

EnginePlayDataArchetypeCallback.index ​

Index of entry node in nodes array.

Example ​

json
{
    "name": "TapNote",
    "hasInput": true,
    "preprocess": {
        "index": 0,
        "order": 0
    },
    "imports": [
        {
            "name": "#BEAT",
            "index": 0
        }
    ],
    "exports": ["hitTime"]
}