Category dies in a fire
This commit is contained in:
@@ -85,8 +85,12 @@ namespace OpenRA.Traits
|
||||
// finds a construction yard (or equivalent) and runs its "build" animation.
|
||||
static void PlayBuildAnim( Actor self, ActorInfo unit )
|
||||
{
|
||||
var bi = unit.Traits.GetOrDefault<BuildableInfo>();
|
||||
if (bi == null)
|
||||
return;
|
||||
|
||||
var producers = self.World.Queries.OwnedBy[ self.Owner ].WithTrait<Production>()
|
||||
.Where( x => x.Actor.Info.Traits.Get<ProductionInfo>().Produces.Contains( unit.Category ) )
|
||||
.Where( x => x.Actor.Info.Traits.Get<ProductionInfo>().Produces.Contains( bi.Queue ) )
|
||||
.ToList();
|
||||
var producer = producers.Where( x => x.Actor.IsPrimaryBuilding() ).Concat( producers )
|
||||
.FirstOrDefault();
|
||||
@@ -98,7 +102,11 @@ namespace OpenRA.Traits
|
||||
static int GetNumBuildables(Player p)
|
||||
{
|
||||
if (p != p.World.LocalPlayer) return 0; // this only matters for local players.
|
||||
return Rules.TechTree.BuildableItems(p, Rules.Categories().ToArray()).Count();
|
||||
|
||||
// todo: this will simplify once queues know about what they can build
|
||||
var queues = p.World.Queries.WithTraitMultiple<ProductionQueue>().Where(a => a.Actor.Owner == p)
|
||||
.Select(a => a.Trait.Info.Type).Distinct().ToArray();
|
||||
return Rules.TechTree.BuildableItems(p, queues).Count();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace OpenRA.Traits
|
||||
return Producing.ElementAtOrDefault(0);
|
||||
}
|
||||
|
||||
public IEnumerable<ProductionItem> AllItems()
|
||||
public IEnumerable<ProductionItem> AllQueued()
|
||||
{
|
||||
return Producing;
|
||||
}
|
||||
@@ -64,13 +64,14 @@ namespace OpenRA.Traits
|
||||
case "StartProduction":
|
||||
{
|
||||
var unit = Rules.Info[order.TargetString];
|
||||
if (unit.Category != Info.Type)
|
||||
var bi = unit.Traits.Get<BuildableInfo>();
|
||||
if (bi.Queue != Info.Type)
|
||||
return; /* Not built by this queue */
|
||||
|
||||
var cost = unit.Traits.Contains<ValuedInfo>() ? unit.Traits.Get<ValuedInfo>().Cost : 0;
|
||||
var time = GetBuildTime(order.TargetString);
|
||||
|
||||
if (!Rules.TechTree.BuildableItems(order.Player, unit.Category).Contains(order.TargetString))
|
||||
if (!Rules.TechTree.BuildableItems(order.Player, bi.Queue).Contains(order.TargetString))
|
||||
return; /* you can't build that!! */
|
||||
|
||||
bool hasPlayedSound = false;
|
||||
@@ -96,9 +97,6 @@ namespace OpenRA.Traits
|
||||
}
|
||||
case "PauseProduction":
|
||||
{
|
||||
if (Rules.Info[ order.TargetString ].Category != Info.Type)
|
||||
return; /* Not built by this queue */
|
||||
|
||||
if( Producing.Count > 0 && Producing[0].Item == order.TargetString )
|
||||
Producing[0].Paused = ( order.TargetLocation.X != 0 );
|
||||
break;
|
||||
@@ -127,10 +125,8 @@ namespace OpenRA.Traits
|
||||
}
|
||||
|
||||
void CancelProduction( string itemName )
|
||||
{
|
||||
var category = Rules.Info[itemName].Category;
|
||||
|
||||
if (category != Info.Type || Producing.Count == 0)
|
||||
{
|
||||
if (Producing.Count == 0)
|
||||
return; // Nothing to do here
|
||||
|
||||
var lastIndex = Producing.FindLastIndex( a => a.Item == itemName );
|
||||
|
||||
Reference in New Issue
Block a user