package lyra:api; interface ecs { record entity-id { id: u64, } record entity { id: entity-id, generation: u64, } record wasm-type-id { // represents a u128, can be converted into that with mem::transmute inner: tuple, } record component-info { /// The size of the component in memory. size: u64, /// The alignment of the component in memory. alignment: u64, /// The type id of the component. /// /// This must be unique between component types since its used to identify the components /// in spawning and querying. type-id: wasm-type-id, // a u128 } resource ecs-dynamic-view { constructor(wrld: borrow, component-infos: list); /// Get the bytes of the next row in the view. /// /// A row contains multiple component serialized as bytes. The buffer is tighly packed. next: func() -> option>; } resource ecs-world { constructor(); /// Spawn an entity. /// /// Parameters: /// * `components`: A tightly packed byte buffer containing the components to spawn /// with the entity. This expects the components in the same order of `component-infos`. /// * `component-infos`: A list of `component-infos` uses to identify the components /// and specify the layouts of them. spawn: func(components: list, component-infos: list) -> entity; /// Query for a list of entities and their components. /// /// Parameters: /// * `component-infos`: The `component-info`'s of the components that you are querying. /// /// Returns: an iterator that returns the byte buffers of each row. view: func(component-infos: list) -> ecs-dynamic-view; } }