Made Valued optional for traits who do not require it.

This commit is contained in:
Andre Mohren
2018-07-22 12:25:10 +02:00
committed by Paul Chote
parent ec15acbc80
commit a86f41cd5c
4 changed files with 22 additions and 7 deletions

View File

@@ -69,7 +69,15 @@ namespace OpenRA.Mods.Common.Traits
var buildingInfo = self.Info.TraitInfoOrDefault<BuildingInfo>();
var eligibleLocations = buildingInfo != null ? buildingInfo.Tiles(self.Location).ToList() : new List<CPos>();
var actorTypes = Info.ActorTypes.Select(a => new { Name = a, Cost = self.World.Map.Rules.Actors[a].TraitInfo<ValuedInfo>().Cost }).ToList();
var actorTypes = Info.ActorTypes.Select(a =>
{
var av = self.World.Map.Rules.Actors[a].TraitInfoOrDefault<ValuedInfo>();
return new
{
Name = a,
Cost = av != null ? av.Cost : 0
};
}).ToList();
while (eligibleLocations.Count > 0 && actorTypes.Any(a => a.Cost <= dudesValue))
{