lyra-wasm-scripting-test/witguest/wit/world.wit

50 lines
962 B
Plaintext

package component:witguest;
interface math {
record vec3 {
x: f32,
y: f32,
z: f32,
}
}
interface ecs {
//use math.{vec3};
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-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>) -> list<u8>;
}
}
/// An example world for the component to target.
world example {
import math;
import ecs;
import host-print: func(msg: string);
export on-init: func() -> result<u8>;
}