Allow actors to force a specific race variant.
This commit is contained in:
@@ -34,7 +34,6 @@ namespace OpenRA.Mods.Common.Orders
|
|||||||
{
|
{
|
||||||
producer = queue.Actor;
|
producer = queue.Actor;
|
||||||
building = name;
|
building = name;
|
||||||
race = queue.MostLikelyProducer().Trait.Race;
|
|
||||||
|
|
||||||
// Clear selection if using Left-Click Orders
|
// Clear selection if using Left-Click Orders
|
||||||
if (Game.Settings.Game.UseClassicMouseStyle)
|
if (Game.Settings.Game.UseClassicMouseStyle)
|
||||||
@@ -42,7 +41,12 @@ namespace OpenRA.Mods.Common.Orders
|
|||||||
|
|
||||||
var map = producer.World.Map;
|
var map = producer.World.Map;
|
||||||
var tileset = producer.World.TileSet.Id.ToLowerInvariant();
|
var tileset = producer.World.TileSet.Id.ToLowerInvariant();
|
||||||
buildingInfo = map.Rules.Actors[building].Traits.Get<BuildingInfo>();
|
|
||||||
|
var info = map.Rules.Actors[building];
|
||||||
|
buildingInfo = info.Traits.Get<BuildingInfo>();
|
||||||
|
|
||||||
|
var buildableInfo = info.Traits.Get<BuildableInfo>();
|
||||||
|
race = buildableInfo.ForceRace ?? queue.MostLikelyProducer().Trait.Race;
|
||||||
|
|
||||||
buildOk = map.SequenceProvider.GetSequence("overlay", "build-valid-{0}".F(tileset)).GetSprite(0);
|
buildOk = map.SequenceProvider.GetSequence("overlay", "build-valid-{0}".F(tileset)).GetSprite(0);
|
||||||
buildBlocked = map.SequenceProvider.GetSequence("overlay", "build-invalid").GetSprite(0);
|
buildBlocked = map.SequenceProvider.GetSequence("overlay", "build-invalid").GetSprite(0);
|
||||||
|
|||||||
@@ -36,6 +36,9 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
[Desc("What the unit should start doing. Warning: If this is not a harvester", "it will break if you use FindResources.")]
|
[Desc("What the unit should start doing. Warning: If this is not a harvester", "it will break if you use FindResources.")]
|
||||||
public readonly string InitialActivity = null;
|
public readonly string InitialActivity = null;
|
||||||
|
|
||||||
|
[Desc("Force a specific race variant, overriding the race of the producing actor.")]
|
||||||
|
public readonly string ForceRace = null;
|
||||||
|
|
||||||
// TODO: UI fluff; doesn't belong here
|
// TODO: UI fluff; doesn't belong here
|
||||||
public readonly int BuildPaletteOrder = 9999;
|
public readonly int BuildPaletteOrder = 9999;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,6 +42,10 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
var race = producer.Trait != null ? producer.Trait.Race : self.Owner.Country.Race;
|
var race = producer.Trait != null ? producer.Trait.Race : self.Owner.Country.Race;
|
||||||
var buildingInfo = unit.Traits.Get<BuildingInfo>();
|
var buildingInfo = unit.Traits.Get<BuildingInfo>();
|
||||||
|
|
||||||
|
var buildableInfo = unit.Traits.GetOrDefault<BuildableInfo>();
|
||||||
|
if (buildableInfo != null && buildableInfo.ForceRace != null)
|
||||||
|
race = buildableInfo.ForceRace;
|
||||||
|
|
||||||
if (order.OrderString == "LineBuild")
|
if (order.OrderString == "LineBuild")
|
||||||
{
|
{
|
||||||
var playSounds = true;
|
var playSounds = true;
|
||||||
|
|||||||
@@ -53,6 +53,10 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
var exitLocation = rp.Value != null ? rp.Value.Location : exit;
|
var exitLocation = rp.Value != null ? rp.Value.Location : exit;
|
||||||
var target = Target.FromCell(self.World, exitLocation);
|
var target = Target.FromCell(self.World, exitLocation);
|
||||||
|
|
||||||
|
var bi = producee.Traits.GetOrDefault<BuildableInfo>();
|
||||||
|
if (bi != null && bi.ForceRace != null)
|
||||||
|
raceVariant = bi.ForceRace;
|
||||||
|
|
||||||
self.World.AddFrameEndTask(w =>
|
self.World.AddFrameEndTask(w =>
|
||||||
{
|
{
|
||||||
var td = new TypeDictionary
|
var td = new TypeDictionary
|
||||||
@@ -89,7 +93,6 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
foreach (var notify in notifyOthers)
|
foreach (var notify in notifyOthers)
|
||||||
notify.Trait.UnitProducedByOther(notify.Actor, self, newUnit);
|
notify.Trait.UnitProducedByOther(notify.Actor, self, newUnit);
|
||||||
|
|
||||||
var bi = newUnit.Info.Traits.GetOrDefault<BuildableInfo>();
|
|
||||||
if (bi != null && bi.InitialActivity != null)
|
if (bi != null && bi.InitialActivity != null)
|
||||||
newUnit.QueueActivity(Game.CreateObject<Activity>(bi.InitialActivity));
|
newUnit.QueueActivity(Game.CreateObject<Activity>(bi.InitialActivity));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user