finish basic storage query

This commit is contained in:
wooshings
2026-10-07 11:16:18 -07:00
parent f7c830dcb8
commit 87345e7248
2 changed files with 10 additions and 12 deletions
+8 -9
View File
@@ -1,21 +1,20 @@
package shoal
import "core:fmt"
Entity :: distinct u32
Storage :: struct($T: typeid) {
data: map[Entity]T,
}
spawn_entity :: proc(app: ^App, $T: typeid) -> Entity {
entity: Entity
spawn_entity :: proc(app: ^App) -> Entity {
entity_num := len(&app.entities)
entity: Entity = Entity(entity_num)
append(&app.entities, entity)
return entity
}
add_collection :: proc(app: ^App, $T: typeid) {
storage: ^Storage(T)
app.storages[T] = storage
}
query :: proc(app: ^App, $T: typeid) {
add_component :: proc(app: ^App, entity: Entity, storage: ^Storage($T)) {
storage.data[entity] = T{}
}