finish basic storage query
This commit is contained in:
@@ -11,8 +11,7 @@ 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[u32][dynamic]struct{},
|
entities: [dynamic]Entity,
|
||||||
storages: map[typeid]rawptr,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
add_system :: proc(app: ^App, schedule: int, system: proc()) {
|
add_system :: proc(app: ^App, schedule: int, system: proc()) {
|
||||||
@@ -30,7 +29,7 @@ add_plugin :: proc(app: ^App, plugin: proc(app: ^App)) {
|
|||||||
append(&app.plugins, plugin)
|
append(&app.plugins, plugin)
|
||||||
}
|
}
|
||||||
|
|
||||||
run :: proc(app: ^App) {
|
run :: proc(app: ^App, entity_limit: int = 1000) {
|
||||||
rl.InitWindow(800, 600, "shoal window")
|
rl.InitWindow(800, 600, "shoal window")
|
||||||
defer rl.CloseWindow()
|
defer rl.CloseWindow()
|
||||||
|
|
||||||
|
|||||||
+8
-9
@@ -1,21 +1,20 @@
|
|||||||
package shoal
|
package shoal
|
||||||
|
|
||||||
|
import "core:fmt"
|
||||||
|
|
||||||
Entity :: distinct u32
|
Entity :: distinct u32
|
||||||
|
|
||||||
Storage :: struct($T: typeid) {
|
Storage :: struct($T: typeid) {
|
||||||
data: map[Entity]T,
|
data: map[Entity]T,
|
||||||
}
|
}
|
||||||
|
|
||||||
spawn_entity :: proc(app: ^App, $T: typeid) -> Entity {
|
spawn_entity :: proc(app: ^App) -> Entity {
|
||||||
entity: Entity
|
entity_num := len(&app.entities)
|
||||||
|
entity: Entity = Entity(entity_num)
|
||||||
|
append(&app.entities, entity)
|
||||||
return entity
|
return entity
|
||||||
}
|
}
|
||||||
|
|
||||||
add_collection :: proc(app: ^App, $T: typeid) {
|
add_component :: proc(app: ^App, entity: Entity, storage: ^Storage($T)) {
|
||||||
storage: ^Storage(T)
|
storage.data[entity] = T{}
|
||||||
app.storages[T] = storage
|
|
||||||
}
|
|
||||||
|
|
||||||
query :: proc(app: ^App, $T: typeid) {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user