single returns nil when empty
This commit is contained in:
+1
-6
@@ -44,7 +44,7 @@ single :: proc(storage: ^Storage($T)) -> (Entity, ^T) {
|
|||||||
for i, &v in slice(storage) {
|
for i, &v in slice(storage) {
|
||||||
return i, &v
|
return i, &v
|
||||||
}
|
}
|
||||||
return Entity{}, new(T)
|
return 0, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// get component of type from entity
|
// get component of type from entity
|
||||||
@@ -54,8 +54,3 @@ get_component :: proc(entity: Entity, storage: ^Storage($T)) -> ^T {
|
|||||||
}
|
}
|
||||||
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)
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user