Propagate race to produced actors.
This commit is contained in:
@@ -90,7 +90,7 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
foreach (var p in producers.Where(p => !p.Actor.IsDisabled()))
|
||||
{
|
||||
if (p.Trait.Produce(p.Actor, self.World.Map.Rules.Actors[name]))
|
||||
if (p.Trait.Produce(p.Actor, self.World.Map.Rules.Actors[name], Race))
|
||||
{
|
||||
FinishProduction();
|
||||
return true;
|
||||
|
||||
@@ -28,19 +28,17 @@ namespace OpenRA.Mods.RA
|
||||
{
|
||||
var prevItems = GetNumBuildables(self.Owner);
|
||||
|
||||
// Find the queue with the target actor
|
||||
var queue = w.ActorsWithTrait<ProductionQueue>()
|
||||
.Where(p => p.Actor.Owner == self.Owner &&
|
||||
p.Trait.CurrentItem() != null &&
|
||||
p.Trait.CurrentItem().Item == order.TargetString &&
|
||||
p.Trait.CurrentItem().RemainingTime == 0)
|
||||
.Select(p => p.Trait)
|
||||
.FirstOrDefault();
|
||||
if (order.TargetActor.IsDead())
|
||||
return;
|
||||
|
||||
var unit = self.World.Map.Rules.Actors[order.TargetString];
|
||||
var queue = order.TargetActor.TraitsImplementing<ProductionQueue>()
|
||||
.FirstOrDefault(q => q.CanBuild(unit));
|
||||
|
||||
if (queue == null)
|
||||
return;
|
||||
|
||||
var unit = self.World.Map.Rules.Actors[order.TargetString];
|
||||
|
||||
var buildingInfo = unit.Traits.Get<BuildingInfo>();
|
||||
|
||||
if (order.OrderString == "LineBuild")
|
||||
@@ -52,11 +50,13 @@ namespace OpenRA.Mods.RA
|
||||
{
|
||||
new LocationInit(t),
|
||||
new OwnerInit(order.Player),
|
||||
new RaceInit(queue.Race)
|
||||
});
|
||||
|
||||
if (playSounds)
|
||||
foreach (var s in buildingInfo.BuildSounds)
|
||||
Sound.PlayToPlayer(order.Player, s, building.CenterPosition);
|
||||
|
||||
playSounds = false;
|
||||
}
|
||||
}
|
||||
@@ -72,7 +72,9 @@ namespace OpenRA.Mods.RA
|
||||
{
|
||||
new LocationInit(order.TargetLocation),
|
||||
new OwnerInit(order.Player),
|
||||
new RaceInit(queue.Race),
|
||||
});
|
||||
|
||||
foreach (var s in buildingInfo.BuildSounds)
|
||||
Sound.PlayToPlayer(order.Player, s, building.CenterPosition);
|
||||
}
|
||||
|
||||
@@ -75,7 +75,6 @@ namespace OpenRA.Mods.RA
|
||||
PowerManager playerPower;
|
||||
PlayerResources playerResources;
|
||||
DeveloperMode developerMode;
|
||||
string race;
|
||||
|
||||
// A list of things we could possibly build
|
||||
Dictionary<ActorInfo, ProductionState> produceable;
|
||||
@@ -92,6 +91,8 @@ namespace OpenRA.Mods.RA
|
||||
[Sync] public bool CurrentDone { get { return QueueLength != 0 && queue[0].Done; } }
|
||||
[Sync] public bool Enabled { get; private set; }
|
||||
|
||||
public string Race { get; private set; }
|
||||
|
||||
public ProductionQueue(ActorInitializer init, Actor playerActor, ProductionQueueInfo info)
|
||||
{
|
||||
self = init.self;
|
||||
@@ -100,8 +101,8 @@ namespace OpenRA.Mods.RA
|
||||
playerPower = playerActor.Trait<PowerManager>();
|
||||
developerMode = playerActor.Trait<DeveloperMode>();
|
||||
|
||||
race = init.Contains<RaceInit>() ? init.Get<RaceInit, string>() : self.Owner.Country.Race;
|
||||
Enabled = !info.Race.Any() || info.Race.Contains(race);
|
||||
Race = init.Contains<RaceInit>() ? init.Get<RaceInit, string>() : self.Owner.Country.Race;
|
||||
Enabled = !info.Race.Any() || info.Race.Contains(Race);
|
||||
|
||||
CacheProduceables(playerActor);
|
||||
}
|
||||
@@ -125,8 +126,8 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
if (!Info.Sticky)
|
||||
{
|
||||
race = self.Owner.Country.Race;
|
||||
Enabled = !Info.Race.Any() || Info.Race.Contains(race);
|
||||
Race = self.Owner.Country.Race;
|
||||
Enabled = !Info.Race.Any() || Info.Race.Contains(Race);
|
||||
}
|
||||
|
||||
// Regenerate the produceables and tech tree state
|
||||
@@ -153,7 +154,7 @@ namespace OpenRA.Mods.RA
|
||||
var bi = a.Traits.Get<BuildableInfo>();
|
||||
|
||||
// Can our race build this by satisfying normal prerequisites?
|
||||
var buildable = !Info.RequireOwner || bi.Owner.Contains(race);
|
||||
var buildable = !Info.RequireOwner || bi.Owner.Contains(Race);
|
||||
|
||||
// Checks if Prerequisites want to hide the Actor from buildQueue if they are false
|
||||
produceable.Add(a, new ProductionState { Visible = buildable });
|
||||
@@ -370,7 +371,7 @@ namespace OpenRA.Mods.RA
|
||||
}
|
||||
|
||||
var sp = self.TraitsImplementing<Production>().FirstOrDefault(p => p.Info.Produces.Contains(Info.Type));
|
||||
if (sp != null && !self.IsDisabled() && sp.Produce(self, self.World.Map.Rules.Actors[name]))
|
||||
if (sp != null && !self.IsDisabled() && sp.Produce(self, self.World.Map.Rules.Actors[name], Race))
|
||||
{
|
||||
FinishProduction();
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user