Skip to content

Commit

Permalink
Add component if needed
Browse files Browse the repository at this point in the history
  • Loading branch information
STREGA committed Sep 2, 2023
1 parent 6f6d70e commit 0ba41eb
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Sources/GateEngine/ECS/Base/Entity.swift
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ extension Entity {
_ type: T.Type,
_ config: @escaping (_ component: inout T) async -> ResultType
) async -> ResultType {
if self.hasComponent(type) == false {
self.insert(type.init())
}
return await config(&self[T.self])
}

Expand Down

0 comments on commit 0ba41eb

Please sign in to comment.