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)
|
protected override void Created(Actor self)
|
||||||
{
|
{
|
||||||
// Special case handling is required for the Player actor.
|
playerResources = self.Owner.PlayerActor.Trait<PlayerResources>();
|
||||||
// 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>();
|
|
||||||
|
|
||||||
base.Created(self);
|
base.Created(self);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,13 +56,7 @@ namespace OpenRA.Mods.Cnc.Traits
|
|||||||
|
|
||||||
protected override void Created(Actor self)
|
protected override void Created(Actor self)
|
||||||
{
|
{
|
||||||
// Special case handling is required for the Player actor.
|
techTree = self.Owner.PlayerActor.Trait<TechTree>();
|
||||||
// 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>();
|
|
||||||
|
|
||||||
base.Created(self);
|
base.Created(self);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -160,13 +160,9 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
protected override void Created(Actor self)
|
protected override void Created(Actor self)
|
||||||
{
|
{
|
||||||
// Special case handling is required for the Player actor.
|
playerPower = self.Owner.PlayerActor.TraitOrDefault<PowerManager>();
|
||||||
// Created is called before Player.PlayerActor is assigned,
|
playerResources = self.Owner.PlayerActor.Trait<PlayerResources>();
|
||||||
// so we must query player traits from self, which refers
|
positionsUpdatedModules = self.Owner.PlayerActor.TraitsImplementing<IBotPositionsUpdated>().ToArray();
|
||||||
// for bot modules always to the Player actor.
|
|
||||||
playerPower = self.TraitOrDefault<PowerManager>();
|
|
||||||
playerResources = self.Trait<PlayerResources>();
|
|
||||||
positionsUpdatedModules = self.TraitsImplementing<IBotPositionsUpdated>().ToArray();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void TraitEnabled(Actor self)
|
protected override void TraitEnabled(Actor self)
|
||||||
|
|||||||
@@ -78,11 +78,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
protected override void Created(Actor self)
|
protected override void Created(Actor self)
|
||||||
{
|
{
|
||||||
// Special case handling is required for the Player actor.
|
requestUnitProduction = self.Owner.PlayerActor.TraitsImplementing<IBotRequestUnitProduction>().ToArray();
|
||||||
// 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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void TraitEnabled(Actor self)
|
protected override void TraitEnabled(Actor self)
|
||||||
|
|||||||
@@ -82,12 +82,8 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
protected override void Created(Actor self)
|
protected override void Created(Actor self)
|
||||||
{
|
{
|
||||||
// Special case handling is required for the Player actor.
|
notifyPositionsUpdated = self.Owner.PlayerActor.TraitsImplementing<IBotPositionsUpdated>().ToArray();
|
||||||
// Created is called before Player.PlayerActor is assigned,
|
requestUnitProduction = self.Owner.PlayerActor.TraitsImplementing<IBotRequestUnitProduction>().ToArray();
|
||||||
// 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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void TraitEnabled(Actor self)
|
protected override void TraitEnabled(Actor self)
|
||||||
|
|||||||
@@ -150,12 +150,8 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
protected override void Created(Actor self)
|
protected override void Created(Actor self)
|
||||||
{
|
{
|
||||||
// Special case handling is required for the Player actor.
|
notifyPositionsUpdated = self.Owner.PlayerActor.TraitsImplementing<IBotPositionsUpdated>().ToArray();
|
||||||
// Created is called before Player.PlayerActor is assigned,
|
notifyIdleBaseUnits = self.Owner.PlayerActor.TraitsImplementing<IBotNotifyIdleBaseUnits>().ToArray();
|
||||||
// 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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void TraitEnabled(Actor self)
|
protected override void TraitEnabled(Actor self)
|
||||||
|
|||||||
@@ -54,11 +54,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
protected override void Created(Actor self)
|
protected override void Created(Actor self)
|
||||||
{
|
{
|
||||||
// Special case handling is required for the Player actor.
|
supportPowerManager = self.Owner.PlayerActor.Trait<SupportPowerManager>();
|
||||||
// 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>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void TraitEnabled(Actor self)
|
protected override void TraitEnabled(Actor self)
|
||||||
|
|||||||
@@ -62,11 +62,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
protected override void Created(Actor self)
|
protected override void Created(Actor self)
|
||||||
{
|
{
|
||||||
// Special case handling is required for the Player actor.
|
requestPause = self.Owner.PlayerActor.TraitsImplementing<IBotRequestPauseUnitProduction>().ToArray();
|
||||||
// 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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void IBotNotifyIdleBaseUnits.UpdatedIdleBaseUnits(List<Actor> idleUnits)
|
void IBotNotifyIdleBaseUnits.UpdatedIdleBaseUnits(List<Actor> idleUnits)
|
||||||
|
|||||||
@@ -42,12 +42,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
void INotifyCreated.Created(Actor self)
|
void INotifyCreated.Created(Actor self)
|
||||||
{
|
{
|
||||||
// Special case handling is required for the Player actor.
|
playerResources = self.Owner.PlayerActor.Trait<PlayerResources>();
|
||||||
// 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>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void INotifyOwnerChanged.OnOwnerChanged(Actor self, Player oldOwner, Player newOwner)
|
void INotifyOwnerChanged.OnOwnerChanged(Actor self, Player oldOwner, Player newOwner)
|
||||||
|
|||||||
@@ -44,13 +44,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
void INotifyCreated.Created(Actor self)
|
void INotifyCreated.Created(Actor self)
|
||||||
{
|
{
|
||||||
// Special case handling is required for the Player actor.
|
globalManager = self.Owner.PlayerActor.Trait<GrantConditionOnPrerequisiteManager>();
|
||||||
// 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>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void INotifyAddedToWorld.AddedToWorld(Actor self)
|
void INotifyAddedToWorld.AddedToWorld(Actor self)
|
||||||
|
|||||||
@@ -141,19 +141,13 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
void INotifyCreated.Created(Actor self)
|
void INotifyCreated.Created(Actor self)
|
||||||
{
|
{
|
||||||
// Special case handling is required for the Player actor.
|
playerPower = self.Owner.PlayerActor.TraitOrDefault<PowerManager>();
|
||||||
// Created is called before Player.PlayerActor is assigned,
|
playerResources = self.Owner.PlayerActor.Trait<PlayerResources>();
|
||||||
// so we must query other player traits from self, knowing that
|
developerMode = self.Owner.PlayerActor.Trait<DeveloperMode>();
|
||||||
// it refers to the same actor as self.Owner.PlayerActor
|
techTree = self.Owner.PlayerActor.Trait<TechTree>();
|
||||||
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>();
|
|
||||||
|
|
||||||
productionTraits = self.TraitsImplementing<Production>().Where(p => p.Info.Produces.Contains(Info.Type)).ToArray();
|
productionTraits = self.TraitsImplementing<Production>().Where(p => p.Info.Produces.Contains(Info.Type)).ToArray();
|
||||||
CacheProducibles(playerActor);
|
CacheProducibles(self.Owner.PlayerActor);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void ClearQueue()
|
protected void ClearQueue()
|
||||||
|
|||||||
@@ -69,13 +69,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
protected override void Created(Actor self)
|
protected override void Created(Actor self)
|
||||||
{
|
{
|
||||||
// Special case handling is required for the Player actor.
|
techTree = self.Owner.PlayerActor.Trait<TechTree>();
|
||||||
// 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>();
|
|
||||||
|
|
||||||
Update();
|
Update();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user