Rename "Created" to "Initialize" and let it handle adding to the world

This commit is contained in:
abcdefg30
2020-05-25 16:37:23 +02:00
committed by reaperrr
parent 7386816f52
commit 52a9fcef3c
3 changed files with 8 additions and 9 deletions

View File

@@ -169,12 +169,11 @@ namespace OpenRA
// Special case handling is required for the Player actor:
// Since Actor.Created would be called before PlayerActor is assigned here
// querying player traits in INotifyCreated.Created would crash.
// Therefore only call the constructor of Actor and run the Created callbacks ourselves.
// Add the PlayerActor to the world afterwards.
// Therefore assign the uninitialized actor and run the Created callbacks
// by calling Initialize ourselves.
var playerActorType = world.Type == WorldType.Editor ? EditorPlayerActorType : PlayerActorType;
PlayerActor = new Actor(world, playerActorType, new TypeDictionary { new OwnerInit(this) });
PlayerActor.Created();
world.Add(PlayerActor);
PlayerActor.Initialize(true);
Shroud = PlayerActor.Trait<Shroud>();
FrozenActorLayer = PlayerActor.TraitOrDefault<FrozenActorLayer>();