Add Buildable.BuildAtProduction.
This allows actors to be restricted to specific production structures.
This commit is contained in:
@@ -27,6 +27,9 @@ namespace OpenRA.Mods.RA
|
|||||||
[Desc("Production queue(s) that can produce this.")]
|
[Desc("Production queue(s) that can produce this.")]
|
||||||
public readonly string[] Queue = { };
|
public readonly string[] Queue = { };
|
||||||
|
|
||||||
|
[Desc("Override the production structure type (from the Production Produces list) that this unit should be built at.")]
|
||||||
|
public readonly string BuildAtProductionType = null;
|
||||||
|
|
||||||
[Desc("Disable production when there are more than this many of this actor on the battlefield. Set to 0 to disable.")]
|
[Desc("Disable production when there are more than this many of this actor on the battlefield. Set to 0 to disable.")]
|
||||||
public readonly int BuildLimit = 0;
|
public readonly int BuildLimit = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -76,9 +76,15 @@ namespace OpenRA.Mods.RA
|
|||||||
protected override bool BuildUnit(string name)
|
protected override bool BuildUnit(string name)
|
||||||
{
|
{
|
||||||
// Find a production structure to build this actor
|
// Find a production structure to build this actor
|
||||||
|
var info = self.World.Map.Rules.Actors[name];
|
||||||
|
var bi = info.Traits.GetOrDefault<BuildableInfo>();
|
||||||
|
|
||||||
|
// Some units may request a specific production type, which is ignored if the AllTech cheat is enabled
|
||||||
|
var type = bi == null || developerMode.AllTech ? Info.Type : bi.BuildAtProductionType ?? Info.Type;
|
||||||
|
|
||||||
var producers = self.World.ActorsWithTrait<Production>()
|
var producers = self.World.ActorsWithTrait<Production>()
|
||||||
.Where(x => x.Actor.Owner == self.Owner
|
.Where(x => x.Actor.Owner == self.Owner
|
||||||
&& x.Trait.Info.Produces.Contains(Info.Type))
|
&& x.Trait.Info.Produces.Contains(type))
|
||||||
.OrderByDescending(x => x.Actor.IsPrimaryBuilding())
|
.OrderByDescending(x => x.Actor.IsPrimaryBuilding())
|
||||||
.ThenByDescending(x => x.Actor.ActorID);
|
.ThenByDescending(x => x.Actor.ActorID);
|
||||||
|
|
||||||
@@ -90,7 +96,7 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
foreach (var p in producers.Where(p => !p.Actor.IsDisabled()))
|
foreach (var p in producers.Where(p => !p.Actor.IsDisabled()))
|
||||||
{
|
{
|
||||||
if (p.Trait.Produce(p.Actor, self.World.Map.Rules.Actors[name], Race))
|
if (p.Trait.Produce(p.Actor, info, Race))
|
||||||
{
|
{
|
||||||
FinishProduction();
|
FinishProduction();
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ namespace OpenRA.Mods.RA
|
|||||||
// Will change if the owner changes
|
// Will change if the owner changes
|
||||||
PowerManager playerPower;
|
PowerManager playerPower;
|
||||||
PlayerResources playerResources;
|
PlayerResources playerResources;
|
||||||
DeveloperMode developerMode;
|
protected DeveloperMode developerMode;
|
||||||
|
|
||||||
// A list of things we could possibly build
|
// A list of things we could possibly build
|
||||||
Dictionary<ActorInfo, ProductionState> produceable;
|
Dictionary<ActorInfo, ProductionState> produceable;
|
||||||
|
|||||||
Reference in New Issue
Block a user