34 Trace
#todo
The trace system is defined as a two-fold data structure:
stateis required and records the current condition of a spacehistoryis optional and preserves past events
interface Trace {
history?: Story[] //optional
state: Mark[] //required
}
History
The history records a list of Story entries with the following data structure:
interface Story {
time: number // required, when the action happened
subject: string // required, the entity that performed the action
verb: InteractionIndex // required, the action performed
object: string // optional, the entity that received the action
modifiers: StoryModifier[] // optional StoryModifier is empty by default, StoryModifier extand by other module.
}
Each entry describes that at time, the subject performed the verb on the object, and modifiers is used to store any additional information.
Without the Interaction system, verb is a Boolean value: true for visiting and false for leaving,
and object can only be the address of the space.
In Exterior Space, time uses a timestamp in milliseconds since January 1, 1970 UTC, consistent with the result of Date.now() in TypeScript.
Both subject and object are addresses of users or assets, and verb corresponds to interaction functions defined in the Interaction system.
State
A state is a list of Mark entries with the following data structure:
interface Mark {
entity: EntityIndex // required, the entity that has a state
phase: Enum // optional, the state
data: MarkData // optional, additional information
}
interface EntityIndex {
kind: EntityKind // required
id: string // required
}
type EntityKind = "artifact" | "avatar" // ...
interface MardData {
localLayout: Embedding[] //optional, when use with local scene for artifact
localForm: Partial<Form> // optional, when use with local scene for artifact
// ... extand by other module
}
Each entry describes that entity has a state defined by phase, and extra is used to store any additional information.
phase is an Enum object that uses numbers to represent different states.
These states can be processed as input or output by interaction functions.
If the Interaction system is not used,
the implementation is required to process the built-in phase states directly.
In Exterior Space, entity is the address of a user or an asset, and phase is an enum value.
Exterior Space does not use extra for Trace state.
Run-time State: Module
interface RuntimeTrace {
history?: Story[] //optional
state: Mark[] //optional
}
overwrite the Trace. not stored.
Subtrace is a Trace object that stores run-time trace data in the implementation.
It is used to separate long-term history and state information from short-term history and state information.
For example, recording the on/off state of a lamp or a record player (for background music setting) can be handled directly by the trace system.
However, recording the run-time state of a mini-game inside a space is typically more suitable for the subtrace module,
especially when the cost of frequently updating the main Trace object is considerable.
Exterior Space uses the subtract module, and extra is used in the state for the subtract module.