Remove workarounds for querying the PlayerActor in Created

This commit is contained in:
abcdefg30
2020-05-24 19:51:58 +02:00
committed by reaperrr
parent 52a9fcef3c
commit 27d0465891
12 changed files with 20 additions and 78 deletions

View File

@@ -160,13 +160,9 @@ namespace OpenRA.Mods.Common.Traits
protected override void Created(Actor self)
{
// Special case handling is required for the Player actor.
// Created is called before Player.PlayerActor is assigned,
// so we must query player traits from self, which refers
// for bot modules always to the Player actor.
playerPower = self.TraitOrDefault<PowerManager>();
playerResources = self.Trait<PlayerResources>();
positionsUpdatedModules = self.TraitsImplementing<IBotPositionsUpdated>().ToArray();
playerPower = self.Owner.PlayerActor.TraitOrDefault<PowerManager>();
playerResources = self.Owner.PlayerActor.Trait<PlayerResources>();
positionsUpdatedModules = self.Owner.PlayerActor.TraitsImplementing<IBotPositionsUpdated>().ToArray();
}
protected override void TraitEnabled(Actor self)