Allow actors to exist in multiple building queues.
This commit is contained in:
@@ -17,7 +17,7 @@ namespace OpenRA.Mods.RA
|
|||||||
public readonly string[] Prerequisites = { };
|
public readonly string[] Prerequisites = { };
|
||||||
public readonly string[] Owner = { };
|
public readonly string[] Owner = { };
|
||||||
|
|
||||||
public readonly string Queue;
|
public readonly string[] Queue = { };
|
||||||
public readonly int BuildLimit = 0;
|
public readonly int BuildLimit = 0;
|
||||||
|
|
||||||
// TODO: UI fluff; doesn't belong here
|
// TODO: UI fluff; doesn't belong here
|
||||||
|
|||||||
@@ -105,9 +105,10 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
if (Info.SpeedUp)
|
if (Info.SpeedUp)
|
||||||
{
|
{
|
||||||
|
var queues = unit.Traits.Get<BuildableInfo>().Queue;
|
||||||
var selfsameBuildings = self.World.ActorsWithTrait<Production>()
|
var selfsameBuildings = self.World.ActorsWithTrait<Production>()
|
||||||
.Where(p => p.Trait.Info.Produces.Contains(unit.Traits.Get<BuildableInfo>().Queue))
|
.Where(p => p.Actor.Owner == self.Owner && p.Trait.Info.Produces.Intersect(queues).Any())
|
||||||
.Where(p => p.Actor.Owner == self.Owner).ToArray();
|
.ToArray();
|
||||||
|
|
||||||
var speedModifier = selfsameBuildings.Count().Clamp(1, Info.BuildTimeSpeedReduction.Length) - 1;
|
var speedModifier = selfsameBuildings.Count().Clamp(1, Info.BuildTimeSpeedReduction.Length) - 1;
|
||||||
time = (time * Info.BuildTimeSpeedReduction[speedModifier]) / 100;
|
time = (time * Info.BuildTimeSpeedReduction[speedModifier]) / 100;
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
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.Actor.Info.Traits.Get<ProductionInfo>().Produces.Contains(bi.Queue))
|
&& x.Actor.Info.Traits.Get<ProductionInfo>().Produces.Intersect(bi.Queue).Any())
|
||||||
.ToList();
|
.ToList();
|
||||||
var producer = producers.Where(x => x.Actor.IsPrimaryBuilding()).Concat(producers)
|
var producer = producers.Where(x => x.Actor.IsPrimaryBuilding()).Concat(producers)
|
||||||
.FirstOrDefault();
|
.FirstOrDefault();
|
||||||
|
|||||||
@@ -136,9 +136,10 @@ namespace OpenRA.Mods.RA
|
|||||||
IEnumerable<ActorInfo> AllBuildables(string category)
|
IEnumerable<ActorInfo> AllBuildables(string category)
|
||||||
{
|
{
|
||||||
return self.World.Map.Rules.Actors.Values
|
return self.World.Map.Rules.Actors.Values
|
||||||
.Where( x => x.Name[ 0 ] != '^' )
|
.Where(x =>
|
||||||
.Where( x => x.Traits.Contains<BuildableInfo>() )
|
x.Name[ 0 ] != '^' &&
|
||||||
.Where( x => x.Traits.Get<BuildableInfo>().Queue == category );
|
x.Traits.Contains<BuildableInfo>() &&
|
||||||
|
x.Traits.Get<BuildableInfo>().Queue.Contains(category));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OverrideProduction(ActorInfo type, bool buildable)
|
public void OverrideProduction(ActorInfo type, bool buildable)
|
||||||
@@ -221,7 +222,7 @@ namespace OpenRA.Mods.RA
|
|||||||
{
|
{
|
||||||
var unit = self.World.Map.Rules.Actors[order.TargetString];
|
var unit = self.World.Map.Rules.Actors[order.TargetString];
|
||||||
var bi = unit.Traits.Get<BuildableInfo>();
|
var bi = unit.Traits.Get<BuildableInfo>();
|
||||||
if (bi.Queue != Info.Type)
|
if (!bi.Queue.Contains(Info.Type))
|
||||||
return; /* Not built by this queue */
|
return; /* Not built by this queue */
|
||||||
|
|
||||||
var cost = unit.Traits.Contains<ValuedInfo>() ? unit.Traits.Get<ValuedInfo>().Cost : 0;
|
var cost = unit.Traits.Contains<ValuedInfo>() ? unit.Traits.Get<ValuedInfo>().Cost : 0;
|
||||||
|
|||||||
@@ -393,7 +393,7 @@ namespace OpenRA.Mods.RA.Scripting
|
|||||||
if (bi == null)
|
if (bi == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
return GetSharedQueueForCategory(player, bi.Queue);
|
return bi.Queue.Select(q => GetSharedQueueForCategory(player, q)).FirstOrDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
[LuaGlobal]
|
[LuaGlobal]
|
||||||
|
|||||||
Reference in New Issue
Block a user