Add ActorInfo.HasTraitInfo<T>() requiring ITraitInfo types

This commit is contained in:
atlimit8
2015-08-02 12:44:46 -05:00
parent 85fab45451
commit 8162fa27ab
77 changed files with 138 additions and 136 deletions

View File

@@ -37,7 +37,7 @@ namespace OpenRA.Mods.Common.Activities
{
target = value;
if (target.Type == TargetType.Actor)
canHideUnderFog = target.Actor.Info.Traits.Contains<HiddenUnderFogInfo>();
canHideUnderFog = target.Actor.Info.HasTraitInfo<HiddenUnderFogInfo>();
}
}

View File

@@ -61,7 +61,7 @@ namespace OpenRA.Mods.Common.Activities
// HACK: This would otherwise break targeting frozen actors
// The problem is that Shroud.IsTargetable returns false (as it should) for
// frozen actors, but we do want to explicitly target the underlying actor here.
if (!attack.Info.IgnoresVisibility && type == TargetType.Actor && !Target.Actor.Info.Traits.Contains<FrozenUnderFogInfo>() && !self.Owner.CanTargetActor(Target.Actor))
if (!attack.Info.IgnoresVisibility && type == TargetType.Actor && !Target.Actor.Info.HasTraitInfo<FrozenUnderFogInfo>() && !self.Owner.CanTargetActor(Target.Actor))
return NextActivity;
// Try to move within range

View File

@@ -24,7 +24,7 @@ namespace OpenRA.Mods.Common.Activities
{
var attack = self.Trait<AttackBase>();
targets = self.World.Actors.Where(a => self != a && !a.IsDead && a.IsInWorld && a.AppearsHostileTo(self)
&& a.Info.Traits.Contains<HuntableInfo>() && IsTargetable(a, self) && attack.HasAnyValidWeapons(Target.FromActor(a)));
&& a.Info.HasTraitInfo<HuntableInfo>() && IsTargetable(a, self) && attack.HasAnyValidWeapons(Target.FromActor(a)));
}
bool IsTargetable(Actor self, Actor viewer)

View File

@@ -41,7 +41,7 @@ namespace OpenRA.Mods.Common.Activities
{
target = value;
if (target.Type == TargetType.Actor)
canHideUnderFog = target.Actor.Info.Traits.Contains<HiddenUnderFogInfo>();
canHideUnderFog = target.Actor.Info.HasTraitInfo<HiddenUnderFogInfo>();
}
}

View File

@@ -49,7 +49,7 @@ namespace OpenRA.Mods.Common.Activities
// HACK to check if we are on the helipad/airfield/etc.
var hostBuilding = self.World.ActorMap.GetUnitsAt(self.Location)
.FirstOrDefault(a => a.Info.Traits.Contains<BuildingInfo>());
.FirstOrDefault(a => a.Info.HasTraitInfo<BuildingInfo>());
if (hostBuilding == null || !hostBuilding.IsInWorld)
return NextActivity;