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!)
|
getOwnerBySnapBase = MatchmakingHelper.sharedInstance.getGKPlayerByUsername(displayName: snapBase.ownership!)
|
||||||
}
|
}
|
||||||
if getOwnerBySnapBase != nil {
|
if getOwnerBySnapBase != nil {
|
||||||
|
base.changeOwnership = true
|
||||||
base.ownershipPlayer = getOwnerBySnapBase
|
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)")
|
print("nach updateSnap -> Entity \(base)")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -189,6 +199,10 @@ class EntityManager {
|
|||||||
}
|
}
|
||||||
return nil
|
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?{
|
func getBasebyID(id: Int) -> Base?{
|
||||||
for entity in entities {
|
for entity in entities {
|
||||||
|
Loading…
Reference in New Issue
Block a user