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

@@ -98,7 +98,8 @@ namespace OpenRA.Mods.Common.Activities
if (remainingTicks == 0)
{
var unitCost = self.Info.TraitInfo<ValuedInfo>().Cost;
var valued = self.Info.TraitInfoOrDefault<ValuedInfo>();
var unitCost = valued != null ? valued.Cost : 0;
var hpToRepair = repairable != null && repairable.Info.HpPerStep > 0 ? repairable.Info.HpPerStep : repairsUnits.Info.HpPerStep;
// Cast to long to avoid overflow when multiplying by the health