Remove workarounds for querying the PlayerActor in Created
This commit is contained in:
@@ -52,12 +52,7 @@ namespace OpenRA.Mods.Cnc.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 other player traits from self, knowing that
|
||||
// it refers to the same actor as self.Owner.PlayerActor
|
||||
var playerActor = self.Info.Name == "player" ? self : self.Owner.PlayerActor;
|
||||
playerResources = playerActor.Trait<PlayerResources>();
|
||||
playerResources = self.Owner.PlayerActor.Trait<PlayerResources>();
|
||||
|
||||
base.Created(self);
|
||||
}
|
||||
|
||||
@@ -56,13 +56,7 @@ namespace OpenRA.Mods.Cnc.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 other player traits from self, knowing that
|
||||
// it refers to the same actor as self.Owner.PlayerActor
|
||||
var playerActor = self.Info.Name == "player" ? self : self.Owner.PlayerActor;
|
||||
|
||||
techTree = playerActor.Trait<TechTree>();
|
||||
techTree = self.Owner.PlayerActor.Trait<TechTree>();
|
||||
|
||||
base.Created(self);
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -42,12 +42,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
void INotifyCreated.Created(Actor self)
|
||||
{
|
||||
// Special case handling is required for the Player actor.
|
||||
// Created is called before Player.PlayerActor is assigned,
|
||||
// so we must query other player traits from self, knowing that
|
||||
// it refers to the same actor as self.Owner.PlayerActor
|
||||
var playerActor = self.Info.Name == "player" ? self : self.Owner.PlayerActor;
|
||||
playerResources = playerActor.Trait<PlayerResources>();
|
||||
playerResources = self.Owner.PlayerActor.Trait<PlayerResources>();
|
||||
}
|
||||
|
||||
void INotifyOwnerChanged.OnOwnerChanged(Actor self, Player oldOwner, Player newOwner)
|
||||
|
||||
@@ -44,13 +44,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
void INotifyCreated.Created(Actor self)
|
||||
{
|
||||
// Special case handling is required for the Player actor.
|
||||
// Created is called before Player.PlayerActor is assigned,
|
||||
// so we must query other player traits from self, knowing that
|
||||
// it refers to the same actor as self.Owner.PlayerActor
|
||||
var playerActor = self.Info.Name == "player" ? self : self.Owner.PlayerActor;
|
||||
|
||||
globalManager = playerActor.Trait<GrantConditionOnPrerequisiteManager>();
|
||||
globalManager = self.Owner.PlayerActor.Trait<GrantConditionOnPrerequisiteManager>();
|
||||
}
|
||||
|
||||
void INotifyAddedToWorld.AddedToWorld(Actor self)
|
||||
|
||||
@@ -141,19 +141,13 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
void INotifyCreated.Created(Actor self)
|
||||
{
|
||||
// Special case handling is required for the Player actor.
|
||||
// Created is called before Player.PlayerActor is assigned,
|
||||
// so we must query other player traits from self, knowing that
|
||||
// it refers to the same actor as self.Owner.PlayerActor
|
||||
var playerActor = self.Info.Name == "player" ? self : self.Owner.PlayerActor;
|
||||
|
||||
playerPower = playerActor.TraitOrDefault<PowerManager>();
|
||||
playerResources = playerActor.Trait<PlayerResources>();
|
||||
developerMode = playerActor.Trait<DeveloperMode>();
|
||||
techTree = playerActor.Trait<TechTree>();
|
||||
playerPower = self.Owner.PlayerActor.TraitOrDefault<PowerManager>();
|
||||
playerResources = self.Owner.PlayerActor.Trait<PlayerResources>();
|
||||
developerMode = self.Owner.PlayerActor.Trait<DeveloperMode>();
|
||||
techTree = self.Owner.PlayerActor.Trait<TechTree>();
|
||||
|
||||
productionTraits = self.TraitsImplementing<Production>().Where(p => p.Info.Produces.Contains(Info.Type)).ToArray();
|
||||
CacheProducibles(playerActor);
|
||||
CacheProducibles(self.Owner.PlayerActor);
|
||||
}
|
||||
|
||||
protected void ClearQueue()
|
||||
|
||||
@@ -69,13 +69,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 other player traits from self, knowing that
|
||||
// it refers to the same actor as self.Owner.PlayerActor
|
||||
var playerActor = self.Info.Name == "player" ? self : self.Owner.PlayerActor;
|
||||
|
||||
techTree = playerActor.Trait<TechTree>();
|
||||
techTree = self.Owner.PlayerActor.Trait<TechTree>();
|
||||
|
||||
Update();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user