-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ark-ecs-kit] feat: consolidate entity removal
- Loading branch information
Showing
7 changed files
with
34 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
ArkKit/ark-state-kit/ark-ecs-kit/InternalSystems/ArkRemovalSystem.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import Foundation | ||
|
||
class ArkEntityRemovalSystem: UpdateSystem { | ||
var active: Bool | ||
|
||
init(active: Bool = true) { | ||
self.active = active | ||
} | ||
|
||
func update(deltaTime: TimeInterval, arkECS: ArkECS) { | ||
let toRemoveEntities = arkECS.getEntities(with: [ToRemoveComponent.self]) | ||
for entity in toRemoveEntities { | ||
guard let toRemoveComponent = arkECS.getComponent(ofType: ToRemoveComponent.self, | ||
for: entity), | ||
toRemoveComponent.toBeRemoved else { | ||
continue | ||
} | ||
arkECS.removeEntity(entity) | ||
} | ||
} | ||
} |