add method getBaseByPlayer to entityManager
This commit is contained in:
parent
276d2cfa2e
commit
5b11dacbaa
@ -8,6 +8,7 @@
|
||||
|
||||
import SpriteKit
|
||||
import GameplayKit
|
||||
import GameKit
|
||||
|
||||
class EntityManager {
|
||||
|
||||
@ -92,13 +93,22 @@ class EntityManager {
|
||||
let base = (entity as! Base)
|
||||
|
||||
if base.changeOwnerShip {
|
||||
base.addComponent(TeamComponent(team: (entities[0] as! Base).component(ofType: TeamComponent.self)!.team, position: (base.component(ofType: DefaultBaseComponent.self)?.spriteNode.position)!))
|
||||
base.addComponent(
|
||||
TeamComponent(
|
||||
team: (entities[0] as! Base).component(ofType: TeamComponent.self)!.team,
|
||||
position: (base.component(ofType: DefaultBaseComponent.self)?.spriteNode.position)!,
|
||||
player: (entities[0] as! Base).component(ofType: TeamComponent.self)!.player))
|
||||
base.changeOwnerShip = false
|
||||
scene.addChild(base.component(ofType: TeamComponent.self)!.fire)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func getBaseByPlayer(for player: GKPlayer) -> Set<Base> {
|
||||
return entities.filter{$0 is Base && ($0 as! Base).component(ofType: TeamComponent.self)?.player == player } as! Set<Base>
|
||||
}
|
||||
|
||||
func getBaseByTeam(for team: Team) -> GKEntity? {
|
||||
for entity in entities {
|
||||
if let teamComponent = entity.component(ofType: TeamComponent.self),
|
||||
|
Loading…
Reference in New Issue
Block a user