Add ActorInfo.HasTraitInfo<T>() requiring ITraitInfo types
This commit is contained in:
@@ -50,7 +50,7 @@ namespace OpenRA.Mods.RA.Activities
|
||||
|
||||
self.Dispose();
|
||||
|
||||
if (target.Info.Traits.Contains<BuildingInfo>())
|
||||
if (target.Info.HasTraitInfo<BuildingInfo>())
|
||||
Sound.PlayToPlayer(self.Owner, "bldginf1.aud");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace OpenRA.Mods.RA.Traits
|
||||
public void UnitProducedByOther(Actor self, Actor producer, Actor produced)
|
||||
{
|
||||
// No recursive cloning!
|
||||
if (producer.Owner != self.Owner || producer.Info.Traits.Contains<ClonesProducedUnitsInfo>())
|
||||
if (producer.Owner != self.Owner || producer.Info.HasTraitInfo<ClonesProducedUnitsInfo>())
|
||||
return;
|
||||
|
||||
var ci = produced.Info.Traits.GetOrDefault<CloneableInfo>();
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace OpenRA.Mods.RA.Traits
|
||||
public virtual bool CanChronoshiftTo(Actor self, CPos targetLocation)
|
||||
{
|
||||
// TODO: Allow enemy units to be chronoshifted into bad terrain to kill them
|
||||
return self.Info.Traits.Contains<IPositionableInfo>() && self.Trait<IPositionable>().CanEnterCell(targetLocation);
|
||||
return self.Info.HasTraitInfo<IPositionableInfo>() && self.Trait<IPositionable>().CanEnterCell(targetLocation);
|
||||
}
|
||||
|
||||
public virtual bool Teleport(Actor self, CPos targetLocation, int duration, bool killCargo, Actor chronosphere)
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace OpenRA.Mods.RA.Traits
|
||||
|
||||
public void OnCrush(Actor crusher)
|
||||
{
|
||||
if (crusher.Info.Traits.Contains<MineImmuneInfo>() || (self.Owner.Stances[crusher.Owner] == Stance.Ally && info.AvoidFriendly))
|
||||
if (crusher.Info.HasTraitInfo<MineImmuneInfo>() || (self.Owner.Stances[crusher.Owner] == Stance.Ally && info.AvoidFriendly))
|
||||
return;
|
||||
|
||||
var mobile = crusher.TraitOrDefault<Mobile>();
|
||||
|
||||
@@ -154,7 +154,7 @@ namespace OpenRA.Mods.RA.Traits
|
||||
|
||||
var underCursor = world.ScreenMap.ActorsAt(mi)
|
||||
.Where(a => !world.FogObscures(a))
|
||||
.MaxByOrDefault(a => a.Info.Traits.Contains<SelectableInfo>()
|
||||
.MaxByOrDefault(a => a.Info.HasTraitInfo<SelectableInfo>()
|
||||
? a.Info.Traits.Get<SelectableInfo>().Priority : int.MinValue);
|
||||
|
||||
if (mi.Button == Game.Settings.Game.MouseButtonPreference.Action && underCursor == null)
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace OpenRA.Mods.RA.Traits
|
||||
foreach (var t in tiles)
|
||||
units.UnionWith(Self.World.ActorMap.GetUnitsAt(t));
|
||||
|
||||
return units.Where(a => a.Info.Traits.Contains<ChronoshiftableInfo>() &&
|
||||
return units.Where(a => a.Info.HasTraitInfo<ChronoshiftableInfo>() &&
|
||||
!a.TraitsImplementing<IPreventsTeleport>().Any(condition => condition.PreventsTeleport(a)));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user