fix seg fault

This commit is contained in:
wooshings
2026-10-09 23:09:10 -07:00
parent 99720dbcd7
commit 8edae62e10
2 changed files with 10 additions and 2 deletions
+3
View File
@@ -15,6 +15,9 @@ App :: struct {
// add a new system to the app that will run based on the provided schedule // add a new system to the app that will run based on the provided schedule
add_system :: proc(app: ^App, schedule: int, system: proc()) { add_system :: proc(app: ^App, schedule: int, system: proc()) {
if _, ok := app.systems[schedule]; !ok {
app.systems[schedule] = [dynamic]proc(){}
}
append(&app.systems[schedule], system) append(&app.systems[schedule], system)
} }
+7 -2
View File
@@ -49,8 +49,13 @@ single :: proc(storage: ^Storage($T)) -> (Entity, ^T) {
// get component of type from entity // get component of type from entity
get_component :: proc(entity: Entity, storage: ^Storage($T)) -> ^T { get_component :: proc(entity: Entity, storage: ^Storage($T)) -> ^T {
if c, exists := &storage.data[entity]; exists { if _, exists := storage.data[entity]; exists {
return c return &storage.data[entity]
} }
return new(T) return new(T)
} }
// alias for direct mutation access
get_component_with_ref :: proc(entity: Entity, storage: ^Storage($T)) -> ^T {
return get_component(entity, storage)
}