-
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, ark-physics-kit, ark-animation-kit] feat: consolidate e…
…ntity removal system
- Loading branch information
Showing
10 changed files
with
49 additions
and
20 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
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
5 changes: 5 additions & 0 deletions
5
ArkKit/ark-state-kit/ark-ecs-kit/InternalComponents/ToRemoveComponent.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,5 @@ | ||
import Foundation | ||
|
||
struct ToRemoveComponent: Component { | ||
var toBeRemoved: Bool | ||
} |
21 changes: 21 additions & 0 deletions
21
ArkKit/ark-state-kit/ark-ecs-kit/InternalSystems/ArkEntityRemovalSystem.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) | ||
} | ||
} | ||
} |