Add ActorsHavingTrait<TTrait>([Func<TTrait, bool])
This commit is contained in:
@@ -133,10 +133,10 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
var type = bi.BuildAtProductionType ?? info.Type;
|
||||
|
||||
var selfsameBuildingsCount = self.World.ActorsWithTrait<Production>()
|
||||
var selfsameProductionsCount = self.World.ActorsWithTrait<Production>()
|
||||
.Count(p => p.Actor.Owner == self.Owner && p.Trait.Info.Produces.Contains(type));
|
||||
|
||||
var speedModifier = selfsameBuildingsCount.Clamp(1, info.BuildTimeSpeedReduction.Length) - 1;
|
||||
var speedModifier = selfsameProductionsCount.Clamp(1, info.BuildTimeSpeedReduction.Length) - 1;
|
||||
time = (time * info.BuildTimeSpeedReduction[speedModifier]) / 100;
|
||||
}
|
||||
|
||||
|
||||
@@ -266,7 +266,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (!developerMode.AllTech && bi.BuildLimit > 0)
|
||||
{
|
||||
var inQueue = queue.Count(pi => pi.Item == order.TargetString);
|
||||
var owned = self.Owner.World.ActorsWithTrait<Buildable>().Count(a => a.Actor.Info.Name == order.TargetString && a.Actor.Owner == self.Owner);
|
||||
var owned = self.Owner.World.ActorsHavingTrait<Buildable>().Count(a => a.Info.Name == order.TargetString && a.Owner == self.Owner);
|
||||
fromLimit = bi.BuildLimit - (inQueue + owned);
|
||||
|
||||
if (fromLimit <= 0)
|
||||
|
||||
@@ -56,13 +56,13 @@ namespace OpenRA.Mods.Common.Traits
|
||||
mo = self.Trait<MissionObjectives>();
|
||||
}
|
||||
|
||||
public IEnumerable<TraitPair<StrategicPoint>> AllPoints
|
||||
public IEnumerable<Actor> AllPoints
|
||||
{
|
||||
get { return player.World.ActorsWithTrait<StrategicPoint>(); }
|
||||
get { return player.World.ActorsHavingTrait<StrategicPoint>(); }
|
||||
}
|
||||
|
||||
public int Total { get { return AllPoints.Count(); } }
|
||||
int Owned { get { return AllPoints.Count(a => WorldUtils.AreMutualAllies(player, a.Actor.Owner)); } }
|
||||
int Owned { get { return AllPoints.Count(a => WorldUtils.AreMutualAllies(player, a.Owner)); } }
|
||||
|
||||
public bool Holding { get { return Owned >= info.RatioRequired * Total; } }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user