Test: trying to add the TeamComponent to the new captured base [unsafe-state]

This commit is contained in:
Aldin Duraki 2020-05-18 02:00:13 +02:00
parent 4a1b43a70d
commit 0db2be8625

View File

@ -135,8 +135,18 @@ class EntityManager {
getOwnerBySnapBase = MatchmakingHelper.sharedInstance.getGKPlayerByUsername(displayName: snapBase.ownership!)
}
if getOwnerBySnapBase != nil {
base.changeOwnership = true
base.ownershipPlayer = getOwnerBySnapBase
entity.addComponent(TeamComponent(
team: getTeamByPlayer(playerName: snapBase.ownership!),
player: getOwnerBySnapBase!,
position: (entity.component(ofType: DefaultBaseComponent.self)?.spriteNode.position)!
)
)
print(entity)
print(getTeamByBase(base: base))
}
print("nach updateSnap -> Entity \(base)")
}
}
@ -189,6 +199,10 @@ class EntityManager {
}
return nil
}
func getTeamByPlayer(playerName: String) -> Team {
return entities.filter { $0 is Base && ($0 as! Base).component(ofType: TeamComponent.self)?.player.displayName == playerName }[0].component(ofType: TeamComponent.self)!.team
}
func getBasebyID(id: Int) -> Base?{
for entity in entities {