2024-04-11 23:03:39 +00:00
|
|
|
package component:witguest;
|
|
|
|
|
2024-04-12 06:05:10 +00:00
|
|
|
interface math {
|
|
|
|
record vec3 {
|
|
|
|
x: f32,
|
|
|
|
y: f32,
|
|
|
|
z: f32,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-04-13 03:59:10 +00:00
|
|
|
interface ecs {
|
2024-04-12 06:05:10 +00:00
|
|
|
//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
|
|
|
|
}
|
|
|
|
|
2024-04-13 06:12:30 +00:00
|
|
|
resource ecs-dynamic-view {
|
|
|
|
constructor(wrld: borrow<ecs-world>, component-infos: list<component-info>);
|
|
|
|
|
|
|
|
next: func() -> option<list<u8>>;
|
|
|
|
}
|
|
|
|
|
2024-04-13 03:59:10 +00:00
|
|
|
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;
|
2024-04-13 06:12:30 +00:00
|
|
|
view: func(component-infos: list<component-info>) -> ecs-dynamic-view;
|
2024-04-13 03:59:10 +00:00
|
|
|
}
|
2024-04-12 06:05:10 +00:00
|
|
|
}
|
|
|
|
|
2024-04-11 23:03:39 +00:00
|
|
|
/// An example world for the component to target.
|
|
|
|
world example {
|
2024-04-12 06:05:10 +00:00
|
|
|
import math;
|
2024-04-13 03:59:10 +00:00
|
|
|
import ecs;
|
2024-04-12 06:05:10 +00:00
|
|
|
|
|
|
|
import host-print: func(msg: string);
|
|
|
|
export on-init: func() -> result<u8>;
|
2024-04-11 23:03:39 +00:00
|
|
|
}
|