Remove workarounds for querying the PlayerActor in Created
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -78,11 +78,7 @@ 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.
|
||||
requestUnitProduction = self.TraitsImplementing<IBotRequestUnitProduction>().ToArray();
|
||||
requestUnitProduction = self.Owner.PlayerActor.TraitsImplementing<IBotRequestUnitProduction>().ToArray();
|
||||
}
|
||||
|
||||
protected override void TraitEnabled(Actor self)
|
||||
|
||||
@@ -82,12 +82,8 @@ 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.
|
||||
notifyPositionsUpdated = self.TraitsImplementing<IBotPositionsUpdated>().ToArray();
|
||||
requestUnitProduction = self.TraitsImplementing<IBotRequestUnitProduction>().ToArray();
|
||||
notifyPositionsUpdated = self.Owner.PlayerActor.TraitsImplementing<IBotPositionsUpdated>().ToArray();
|
||||
requestUnitProduction = self.Owner.PlayerActor.TraitsImplementing<IBotRequestUnitProduction>().ToArray();
|
||||
}
|
||||
|
||||
protected override void TraitEnabled(Actor self)
|
||||
|
||||
@@ -150,12 +150,8 @@ 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.
|
||||
notifyPositionsUpdated = self.TraitsImplementing<IBotPositionsUpdated>().ToArray();
|
||||
notifyIdleBaseUnits = self.TraitsImplementing<IBotNotifyIdleBaseUnits>().ToArray();
|
||||
notifyPositionsUpdated = self.Owner.PlayerActor.TraitsImplementing<IBotPositionsUpdated>().ToArray();
|
||||
notifyIdleBaseUnits = self.Owner.PlayerActor.TraitsImplementing<IBotNotifyIdleBaseUnits>().ToArray();
|
||||
}
|
||||
|
||||
protected override void TraitEnabled(Actor self)
|
||||
|
||||
@@ -54,11 +54,7 @@ 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.
|
||||
supportPowerManager = self.Trait<SupportPowerManager>();
|
||||
supportPowerManager = self.Owner.PlayerActor.Trait<SupportPowerManager>();
|
||||
}
|
||||
|
||||
protected override void TraitEnabled(Actor self)
|
||||
|
||||
@@ -62,11 +62,7 @@ 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.
|
||||
requestPause = self.TraitsImplementing<IBotRequestPauseUnitProduction>().ToArray();
|
||||
requestPause = self.Owner.PlayerActor.TraitsImplementing<IBotRequestPauseUnitProduction>().ToArray();
|
||||
}
|
||||
|
||||
void IBotNotifyIdleBaseUnits.UpdatedIdleBaseUnits(List<Actor> idleUnits)
|
||||
|
||||
Reference in New Issue
Block a user