Test: trying to add the TeamComponent to the new captured base [unsafe-state]
This commit is contained in:
parent
4a1b43a70d
commit
0db2be8625
@ -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)")
|
||||
}
|
||||
}
|
||||
@ -190,6 +200,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 {
|
||||
if entity is Base && (entity as! Base).baseID == id {
|
||||
|
Loading…
Reference in New Issue
Block a user