lyra-wasm-scripting-test/common-api/wit/ecs.wit

36 lines
823 B
Plaintext
Raw Normal View History

package lyra:api;
interface ecs {
record entity-id {
id: u64,
}
record entity {
id: entity-id,
generation: u64,
}
record wasm-type-id {
inner: tuple<u64, u64>,
}
record component-info {
size: u64,
alignment: u64,
type-id: wasm-type-id, // a u128
}
resource ecs-dynamic-view {
constructor(wrld: borrow<ecs-world>, component-infos: list<component-info>);
next: func() -> option<list<u8>>;
}
resource ecs-world {
constructor();
// expects components to be tightly packed in the same order of component-infos
spawn: func(components: list<u8>, component-infos: list<component-info>) -> entity;
view: func(component-infos: list<component-info>) -> ecs-dynamic-view;
}
}