Add ActorInfo.HasTraitInfo<T>() requiring ITraitInfo types
This commit is contained in:
@@ -79,7 +79,7 @@ namespace OpenRA.Mods.D2k.Activities
|
||||
actor1.Dispose();
|
||||
|
||||
// Harvester insurance
|
||||
if (!actor1.Info.Traits.Contains<HarvesterInfo>())
|
||||
if (!actor1.Info.HasTraitInfo<HarvesterInfo>())
|
||||
return;
|
||||
|
||||
var insurance = actor1.Owner.PlayerActor.TraitOrDefault<HarvesterInsurance>();
|
||||
|
||||
@@ -117,7 +117,7 @@ namespace OpenRA.Mods.D2k.Traits
|
||||
{
|
||||
// HACK: Harvesters need special treatment to avoid getting stuck on resource fields,
|
||||
// so if a Harvester's afterLandActivity is not DeliverResources, queue a new FindResources activity
|
||||
var findResources = self.Info.Traits.Contains<HarvesterInfo>() && !(afterLandActivity is DeliverResources);
|
||||
var findResources = self.Info.HasTraitInfo<HarvesterInfo>() && !(afterLandActivity is DeliverResources);
|
||||
if (findResources)
|
||||
self.QueueActivity(new FindResources(self));
|
||||
else
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace OpenRA.Mods.D2k.Traits
|
||||
var body = self.Trait<BodyOrientation>();
|
||||
|
||||
// always render instantly for units
|
||||
buildComplete = !self.Info.Traits.Contains<BuildingInfo>();
|
||||
buildComplete = !self.Info.HasTraitInfo<BuildingInfo>();
|
||||
|
||||
var overlay = new Animation(self.World, rs.GetImage(self));
|
||||
overlay.Play(info.Sequence);
|
||||
|
||||
@@ -99,7 +99,7 @@ namespace OpenRA.Mods.D2k.Traits
|
||||
targetCountdown = Info.TargetRescanInterval;
|
||||
|
||||
// If close enough, we don't care about other actors.
|
||||
var target = self.World.FindActorsInCircle(self.CenterPosition, Info.IgnoreNoiseAttackRange).FirstOrDefault(x => x.Info.Traits.Contains<AttractsWormsInfo>());
|
||||
var target = self.World.FindActorsInCircle(self.CenterPosition, Info.IgnoreNoiseAttackRange).FirstOrDefault(x => x.Info.HasTraitInfo<AttractsWormsInfo>());
|
||||
if (target != null)
|
||||
{
|
||||
self.CancelActivity();
|
||||
@@ -109,7 +109,7 @@ namespace OpenRA.Mods.D2k.Traits
|
||||
|
||||
Func<Actor, bool> isValidTarget = a =>
|
||||
{
|
||||
if (!a.Info.Traits.Contains<AttractsWormsInfo>())
|
||||
if (!a.Info.HasTraitInfo<AttractsWormsInfo>())
|
||||
return false;
|
||||
|
||||
return mobile.CanEnterCell(a.Location, null, false);
|
||||
|
||||
Reference in New Issue
Block a user