Add ActorInfo.TraitInfo[OrDefault]<T>() requiring ITraitIfo types

This commit is contained in:
atlimit8
2015-08-03 16:07:33 -05:00
parent 6970959ef1
commit 09984683a7
115 changed files with 195 additions and 193 deletions

View File

@@ -100,7 +100,7 @@ namespace OpenRA.Mods.Common.Traits
var collector = landedOn.FirstOrDefault(a =>
{
// Mobile is (currently) the only trait that supports crushing
var mi = a.Info.Traits.GetOrDefault<MobileInfo>();
var mi = a.Info.TraitInfoOrDefault<MobileInfo>();
if (mi == null)
return false;

View File

@@ -90,7 +90,7 @@ namespace OpenRA.Mods.Common.Traits
// Restrict duplicate count to a maximum value
if (info.MaxDuplicateValue > 0)
{
var vi = collector.Info.Traits.GetOrDefault<ValuedInfo>();
var vi = collector.Info.TraitInfoOrDefault<ValuedInfo>();
if (vi != null && vi.Cost > 0)
duplicates = Math.Min(duplicates, info.MaxDuplicateValue / vi.Cost);
}

View File

@@ -93,7 +93,7 @@ namespace OpenRA.Mods.Common.Traits
IEnumerable<CPos> GetSuitableCells(CPos near, string unitName)
{
var mi = self.World.Map.Rules.Actors[unitName].Traits.Get<MobileInfo>();
var mi = self.World.Map.Rules.Actors[unitName].TraitInfo<MobileInfo>();
for (var i = -1; i < 2; i++)
for (var j = -1; j < 2; j++)