query start

This commit is contained in:
harper
2026-10-02 15:07:20 -07:00
parent e75f92ea4b
commit f7c830dcb8
2 changed files with 13 additions and 16 deletions
+2 -8
View File
@@ -11,7 +11,8 @@ App :: struct {
update_systems: [dynamic]proc(), update_systems: [dynamic]proc(),
draw_systems: [dynamic]proc(), draw_systems: [dynamic]proc(),
plugins: [dynamic]proc(app: ^App), plugins: [dynamic]proc(app: ^App),
entities: map[int][dynamic]struct{}, entities: map[u32][dynamic]struct{},
storages: map[typeid]rawptr,
} }
add_system :: proc(app: ^App, schedule: int, system: proc()) { add_system :: proc(app: ^App, schedule: int, system: proc()) {
@@ -29,13 +30,6 @@ add_plugin :: proc(app: ^App, plugin: proc(app: ^App)) {
append(&app.plugins, plugin) append(&app.plugins, plugin)
} }
spawn_entity :: proc(app: ^App, components: [dynamic]struct{}) {
entity_len := len(&app.entities)
app.entities[entity_len] = components
}
run :: proc(app: ^App) { run :: proc(app: ^App) {
rl.InitWindow(800, 600, "shoal window") rl.InitWindow(800, 600, "shoal window")
defer rl.CloseWindow() defer rl.CloseWindow()
+11 -8
View File
@@ -1,18 +1,21 @@
package shoal package shoal
Entity :: struct { Entity :: distinct u32
id: int,
components: [dynamic]struct{}, Storage :: struct($T: typeid) {
data: map[Entity]T,
} }
spawn_entity :: proc(app: ^App) -> Entity { spawn_entity :: proc(app: ^App, $T: typeid) -> Entity {
entity: Entity entity: Entity
entity_len := len(&app.entities)
entity.id = entity_len
return entity return entity
} }
add_collection :: proc(app: ^App, component: $T) { add_collection :: proc(app: ^App, $T: typeid) {
storage: ^Storage(T)
app.storages[T] = storage
}
query :: proc(app: ^App, $T: typeid) {
} }