Remove Actor.HasTrait<T>()
This commit is contained in:
@@ -19,7 +19,7 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
public class AircraftInfo : ITraitInfo, IFacingInfo, IOccupySpaceInfo, ICruiseAltitudeInfo, UsesInit<LocationInit>, UsesInit<FacingInit>
|
||||
public class AircraftInfo : IPositionableInfo, IFacingInfo, IOccupySpaceInfo, ICruiseAltitudeInfo, UsesInit<LocationInit>, UsesInit<FacingInit>
|
||||
{
|
||||
public readonly WDist CruiseAltitude = new WDist(1280);
|
||||
public readonly WDist IdealSeparation = new WDist(1706);
|
||||
@@ -120,7 +120,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
firstTick = false;
|
||||
|
||||
// TODO: Aircraft husks don't properly unreserve.
|
||||
if (self.HasTrait<FallsToEarth>())
|
||||
if (self.Info.Traits.Contains<FallsToEarthInfo>())
|
||||
return;
|
||||
|
||||
ReserveSpawnBuilding();
|
||||
@@ -158,7 +158,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return WVec.Zero;
|
||||
|
||||
return self.World.FindActorsInCircle(self.CenterPosition, info.IdealSeparation)
|
||||
.Where(a => !a.IsDead && a.HasTrait<Aircraft>() && a.Info.Traits.Get<AircraftInfo>().CruiseAltitude == info.CruiseAltitude)
|
||||
.Where(a => !a.IsDead && a.Info.Traits.Contains<AircraftInfo>() && a.Info.Traits.Get<AircraftInfo>().CruiseAltitude == info.CruiseAltitude)
|
||||
.Select(GetRepulsionForce)
|
||||
.Aggregate(WVec.Zero, (a, b) => a + b);
|
||||
}
|
||||
@@ -191,7 +191,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return null; // not on the ground.
|
||||
|
||||
return self.World.ActorMap.GetUnitsAt(self.Location)
|
||||
.FirstOrDefault(a => a.HasTrait<Reservable>());
|
||||
.FirstOrDefault(a => a.Info.Traits.Contains<ReservableInfo>());
|
||||
}
|
||||
|
||||
protected void ReserveSpawnBuilding()
|
||||
@@ -341,7 +341,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
get
|
||||
{
|
||||
yield return new EnterAlliedActorTargeter<Building>("Enter", 5,
|
||||
yield return new EnterAlliedActorTargeter<BuildingInfo>("Enter", 5,
|
||||
target => AircraftCanEnter(target), target => !Reservable.IsReserved(target));
|
||||
|
||||
yield return new AircraftMoveOrderTargeter(info);
|
||||
|
||||
@@ -202,7 +202,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public bool IsReachableTarget(Target target, bool allowMove)
|
||||
{
|
||||
return HasAnyValidWeapons(target)
|
||||
&& (target.IsInRange(self.CenterPosition, GetMaximumRange()) || (allowMove && self.HasTrait<IMove>()));
|
||||
&& (target.IsInRange(self.CenterPosition, GetMaximumRange()) || (allowMove && self.Info.Traits.Contains<IMoveInfo>()));
|
||||
}
|
||||
|
||||
class AttackOrderTargeter : IOrderTargeter
|
||||
|
||||
@@ -81,8 +81,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
var weapon = attack.ChooseArmamentForTarget(target);
|
||||
if (weapon != null)
|
||||
{
|
||||
var targetIsMobile = (target.Type == TargetType.Actor && target.Actor.HasTrait<IMove>())
|
||||
|| (target.Type == TargetType.FrozenActor && target.FrozenActor.Info.Traits.Contains<IMove>());
|
||||
var targetIsMobile = (target.Type == TargetType.Actor && target.Actor.Info.Traits.Contains<IMoveInfo>())
|
||||
|| (target.Type == TargetType.FrozenActor && target.FrozenActor.Info.Traits.Contains<IMoveInfo>());
|
||||
|
||||
// Try and sit at least one cell closer than the max range to give some leeway if the target starts moving.
|
||||
var maxRange = targetIsMobile ? new WDist(Math.Max(weapon.Weapon.MinRange.Length, weapon.Weapon.Range.Length - 1024))
|
||||
|
||||
@@ -154,7 +154,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return inRange
|
||||
.Where(a =>
|
||||
a.AppearsHostileTo(self) &&
|
||||
!a.HasTrait<AutoTargetIgnore>() &&
|
||||
!a.Info.Traits.Contains<AutoTargetIgnoreInfo>() &&
|
||||
attack.HasAnyValidWeapons(Target.FromActor(a)) &&
|
||||
self.Owner.CanTargetActor(a))
|
||||
.ClosestTo(self);
|
||||
|
||||
@@ -15,6 +15,6 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
// TODO: Add functionality like a customizable Height that is compared to projectile altitude
|
||||
[Desc("This actor blocks bullets and missiles with 'Blockable' property.")]
|
||||
public class BlocksProjectilesInfo : TraitInfo<BlocksProjectiles> { }
|
||||
public class BlocksProjectilesInfo : TraitInfo<BlocksProjectiles>, IBlocksProjectilesInfo { }
|
||||
public class BlocksProjectiles : IBlocksProjectiles { }
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
// If a sprite actor has neither custom QuantizedFacings nor a trait implementing IQuantizeBodyOrientationInfo, throw
|
||||
if (qboi == null)
|
||||
{
|
||||
if (self.HasTrait<ISpriteBody>())
|
||||
if (self.Info.Traits.Contains<ISpriteBodyInfo>())
|
||||
throw new InvalidOperationException("Actor '" + self.Info.Name + "' has a sprite body but no facing quantization."
|
||||
+ " Either add the QuantizeFacingsFromSequence trait or set custom QuantizedFacings on BodyOrientation.");
|
||||
else
|
||||
|
||||
@@ -201,7 +201,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
foreach (var c in footprint.Keys)
|
||||
foreach (var a in self.World.ActorMap.GetUnitsAt(c))
|
||||
if (a.HasTrait<IPositionable>() && !a.Trait<IPositionable>().CanEnterCell(c))
|
||||
if (a.Info.Traits.Contains<IPositionableInfo>() && !a.Trait<IPositionable>().CanEnterCell(c))
|
||||
a.Kill(self);
|
||||
}
|
||||
|
||||
|
||||
@@ -87,12 +87,12 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
var unitsAtPos = world.ActorMap.GetUnitsAt(pos).Where(a => a.IsInWorld
|
||||
&& (a.Owner == p || (allyBuildRadius && a.Owner.Stances[p] == Stance.Ally))
|
||||
&& a.HasTrait<GivesBuildableArea>());
|
||||
&& a.Info.Traits.Contains<GivesBuildableAreaInfo>());
|
||||
|
||||
if (unitsAtPos.Any())
|
||||
nearnessCandidates.Add(pos);
|
||||
}
|
||||
else if (buildingAtPos.IsInWorld && buildingAtPos.HasTrait<GivesBuildableArea>()
|
||||
else if (buildingAtPos.IsInWorld && buildingAtPos.Info.Traits.Contains<GivesBuildableAreaInfo>()
|
||||
&& (buildingAtPos.Owner == p || (allyBuildRadius && buildingAtPos.Owner.Stances[p] == Stance.Ally)))
|
||||
nearnessCandidates.Add(pos);
|
||||
}
|
||||
@@ -164,7 +164,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public void Created(Actor self)
|
||||
{
|
||||
if (SkipMakeAnimation || !self.HasTrait<WithMakeAnimation>())
|
||||
if (SkipMakeAnimation || !self.Info.Traits.Contains<WithMakeAnimationInfo>())
|
||||
NotifyBuildingComplete(self);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
public class RefineryInfo : ITraitInfo, Requires<WithSpriteBodyInfo>
|
||||
public class RefineryInfo : IAcceptResourcesInfo, Requires<WithSpriteBodyInfo>
|
||||
{
|
||||
[Desc("Actual harvester facing when docking, 0-255 counter-clock-wise.")]
|
||||
public readonly int DockAngle = 0;
|
||||
|
||||
@@ -15,7 +15,7 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
class CrateInfo : ITraitInfo, IOccupySpaceInfo, Requires<RenderSpritesInfo>
|
||||
class CrateInfo : IPositionableInfo, IOccupySpaceInfo, Requires<RenderSpritesInfo>
|
||||
{
|
||||
[Desc("Length of time (in seconds) until the crate gets removed automatically. " +
|
||||
"A value of zero disables auto-removal.")]
|
||||
|
||||
@@ -101,7 +101,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public override bool CanTargetActor(Actor self, Actor target, TargetModifiers modifiers, ref string cursor)
|
||||
{
|
||||
if (!target.HasTrait<EngineerRepairable>())
|
||||
if (!target.Info.Traits.Contains<EngineerRepairableInfo>())
|
||||
return false;
|
||||
|
||||
if (self.Owner.Stances[target.Owner] != Stance.Ally)
|
||||
@@ -115,7 +115,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public override bool CanTargetFrozenActor(Actor self, FrozenActor target, TargetModifiers modifiers, ref string cursor)
|
||||
{
|
||||
if (!target.Info.Traits.Contains<EngineerRepairable>())
|
||||
if (!target.Info.Traits.Contains<EngineerRepairableInfo>())
|
||||
return false;
|
||||
|
||||
if (self.Owner.Stances[target.Owner] != Stance.Ally)
|
||||
|
||||
@@ -88,7 +88,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public void Tick(World world)
|
||||
{
|
||||
if (subjects.All(s => s.IsDead || !s.HasTrait<Guard>()))
|
||||
if (subjects.All(s => s.IsDead || !s.Info.Traits.Contains<GuardInfo>()))
|
||||
world.CancelInputMode();
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return world.ScreenMap.ActorsAt(mi)
|
||||
.Where(a => !world.FogObscures(a) && !a.IsDead &&
|
||||
a.AppearsFriendlyTo(world.LocalPlayer.PlayerActor) &&
|
||||
a.HasTrait<Guardable>());
|
||||
a.Info.Traits.Contains<GuardableInfo>());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -297,7 +297,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
get
|
||||
{
|
||||
yield return new EnterAlliedActorTargeter<IAcceptResources>("Deliver", 5,
|
||||
yield return new EnterAlliedActorTargeter<IAcceptResourcesInfo>("Deliver", 5,
|
||||
proc => IsAcceptableProcType(proc),
|
||||
proc => !IsEmpty && proc.Trait<IAcceptResources>().AllowDocking);
|
||||
yield return new HarvestOrderTargeter();
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (self.IsDead)
|
||||
return;
|
||||
|
||||
if (Info.RemoveInstead || !self.HasTrait<Health>())
|
||||
if (Info.RemoveInstead || !self.Info.Traits.Contains<HealthInfo>())
|
||||
self.Dispose();
|
||||
else
|
||||
self.Kill(self);
|
||||
|
||||
@@ -38,7 +38,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
|
||||
[Desc("Unit is able to move.")]
|
||||
public class MobileInfo : IMoveInfo, IOccupySpaceInfo, IFacingInfo, UsesInit<FacingInit>, UsesInit<LocationInit>, UsesInit<SubCellInit>
|
||||
public class MobileInfo : IMoveInfo, IPositionableInfo, IOccupySpaceInfo, IFacingInfo,
|
||||
UsesInit<FacingInit>, UsesInit<LocationInit>, UsesInit<SubCellInit>
|
||||
{
|
||||
[FieldLoader.LoadUsing("LoadSpeeds", true)]
|
||||
[Desc("Set Water: 0 for ground units and lower the value on rough terrain.")]
|
||||
@@ -664,7 +665,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
var cellInfo = notStupidCells
|
||||
.SelectMany(c => self.World.ActorMap.GetUnitsAt(c)
|
||||
.Where(a => a.IsIdle && a.HasTrait<Mobile>()),
|
||||
.Where(a => a.IsIdle && a.Info.Traits.Contains<MobileInfo>()),
|
||||
(c, a) => new { Cell = c, Actor = a })
|
||||
.RandomOrDefault(self.World.SharedRandom);
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
readonly bool startsRevealed;
|
||||
readonly PPos[] footprint;
|
||||
|
||||
readonly Lazy<IToolTip> tooltip;
|
||||
readonly Lazy<ITooltip> tooltip;
|
||||
readonly Lazy<Health> health;
|
||||
|
||||
readonly Dictionary<Player, bool> visible;
|
||||
@@ -53,7 +53,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
startsRevealed = info.StartsRevealed && !init.Contains<ParentActorInit>();
|
||||
var footprintCells = FootprintUtils.Tiles(init.Self).ToList();
|
||||
footprint = footprintCells.SelectMany(c => map.ProjectedCellsCovering(c.ToMPos(map))).ToArray();
|
||||
tooltip = Exts.Lazy(() => init.Self.TraitsImplementing<IToolTip>().FirstOrDefault());
|
||||
tooltip = Exts.Lazy(() => init.Self.TraitsImplementing<ITooltip>().FirstOrDefault());
|
||||
health = Exts.Lazy(() => init.Self.TraitOrDefault<Health>());
|
||||
|
||||
frozen = new Dictionary<Player, FrozenActor>();
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
public enum AlternateTransportsMode { None, Force, Default, Always }
|
||||
|
||||
public class EnterTransportTargeter : EnterAlliedActorTargeter<Cargo>
|
||||
public class EnterTransportTargeter : EnterAlliedActorTargeter<CargoInfo>
|
||||
{
|
||||
readonly AlternateTransportsMode mode;
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
}
|
||||
|
||||
public class EnterTransportsTargeter : EnterAlliedActorTargeter<Cargo>
|
||||
public class EnterTransportsTargeter : EnterAlliedActorTargeter<CargoInfo>
|
||||
{
|
||||
readonly AlternateTransportsMode mode;
|
||||
|
||||
@@ -116,7 +116,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
Info = info;
|
||||
Func<Actor, bool> canTarget = IsCorrectCargoType;
|
||||
Func<Actor, bool> useEnterCursor = CanEnter;
|
||||
Orders = new EnterAlliedActorTargeter<Cargo>[]
|
||||
Orders = new EnterAlliedActorTargeter<CargoInfo>[]
|
||||
{
|
||||
new EnterTransportTargeter("EnterTransport", 5, canTarget, useEnterCursor, Info.AlternateTransportsMode),
|
||||
new EnterTransportsTargeter("EnterTransports", 5, canTarget, useEnterCursor, Info.AlternateTransportsMode)
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
var building = order.TargetActor;
|
||||
|
||||
if (building.HasTrait<RepairableBuilding>())
|
||||
if (building.Info.Traits.Contains<RepairableBuildingInfo>())
|
||||
if (building.AppearsFriendlyTo(self))
|
||||
building.Trait<RepairableBuilding>().RepairBuilding(building, self.Owner);
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public void Damaged(Actor self, AttackInfo e)
|
||||
{
|
||||
// only track last hit against our base
|
||||
if (!self.HasTrait<Building>())
|
||||
if (!self.Info.Traits.Contains<BuildingInfo>())
|
||||
return;
|
||||
|
||||
if (e.Attacker == null)
|
||||
|
||||
@@ -47,8 +47,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public void Damaged(Actor self, AttackInfo e)
|
||||
{
|
||||
// only track last hit against our base
|
||||
if (!self.HasTrait<Harvester>())
|
||||
// only track last hit against our harvesters
|
||||
if (!self.Info.Traits.Contains<HarvesterInfo>())
|
||||
return;
|
||||
|
||||
// don't track self-damage
|
||||
|
||||
@@ -107,18 +107,18 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
var attackerStats = e.Attacker.Owner.PlayerActor.Trait<PlayerStatistics>();
|
||||
var defenderStats = self.Owner.PlayerActor.Trait<PlayerStatistics>();
|
||||
if (self.HasTrait<Building>())
|
||||
if (self.Info.Traits.Contains<BuildingInfo>())
|
||||
{
|
||||
attackerStats.BuildingsKilled++;
|
||||
defenderStats.BuildingsDead++;
|
||||
}
|
||||
else if (self.HasTrait<IPositionable>())
|
||||
else if (self.Info.Traits.Contains<IPositionableInfo>())
|
||||
{
|
||||
attackerStats.UnitsKilled++;
|
||||
defenderStats.UnitsDead++;
|
||||
}
|
||||
|
||||
if (self.HasTrait<Valued>())
|
||||
if (self.Info.Traits.Contains<ValuedInfo>())
|
||||
{
|
||||
var cost = self.Info.Traits.Get<ValuedInfo>().Cost;
|
||||
attackerStats.KillsCost += cost;
|
||||
|
||||
@@ -14,7 +14,7 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
public class ProvidesPrerequisiteInfo : ITraitInfo
|
||||
public class ProvidesPrerequisiteInfo : ITechTreePrerequisiteInfo
|
||||
{
|
||||
[Desc("The prerequisite type that this provides. If left empty it defaults to the actor's name.")]
|
||||
public readonly string Prerequisite = null;
|
||||
|
||||
@@ -13,7 +13,7 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
public class ProvidesTechPrerequisiteInfo : ITraitInfo
|
||||
public class ProvidesTechPrerequisiteInfo : ITechTreePrerequisiteInfo
|
||||
{
|
||||
public readonly string Name;
|
||||
public readonly string[] Prerequisites = { };
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public void ActorChanged(Actor a)
|
||||
{
|
||||
var bi = a.Info.Traits.GetOrDefault<BuildableInfo>();
|
||||
if (a.Owner == player && (a.HasTrait<ITechTreePrerequisite>() || (bi != null && bi.BuildLimit > 0)))
|
||||
if (a.Owner == player && (a.Info.Traits.Contains<ITechTreePrerequisiteInfo>() || (bi != null && bi.BuildLimit > 0)))
|
||||
Update();
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public Hovers(HoversInfo info, Actor self)
|
||||
{
|
||||
this.info = info;
|
||||
aircraft = self.HasTrait<Aircraft>();
|
||||
aircraft = self.Info.Traits.Contains<AircraftInfo>();
|
||||
}
|
||||
|
||||
public IEnumerable<IRenderable> ModifyRender(Actor self, WorldRenderer wr, IEnumerable<IRenderable> r)
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
this.info = info;
|
||||
wsb = self.Trait<WithSpriteBody>();
|
||||
buildComplete = !self.HasTrait<Building>();
|
||||
buildComplete = !self.Info.Traits.Contains<BuildingInfo>();
|
||||
}
|
||||
|
||||
public void BuildingComplete(Actor self)
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
var rs = self.Trait<RenderSprites>();
|
||||
var body = self.Trait<BodyOrientation>();
|
||||
|
||||
buildComplete = !self.HasTrait<Building>(); // always render instantly for units
|
||||
buildComplete = !self.Info.Traits.Contains<BuildingInfo>(); // always render instantly for units
|
||||
|
||||
overlay = new Animation(self.World, rs.GetImage(self));
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
var rs = self.Trait<RenderSprites>();
|
||||
var body = self.Trait<BodyOrientation>();
|
||||
|
||||
buildComplete = !self.HasTrait<Building>(); // always render instantly for units
|
||||
buildComplete = !self.Info.Traits.Contains<BuildingInfo>(); // always render instantly for units
|
||||
|
||||
var overlay = new Animation(self.World, rs.GetImage(self));
|
||||
overlay.Play(info.Sequence);
|
||||
|
||||
@@ -68,7 +68,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
var rs = self.Trait<RenderSprites>();
|
||||
var body = self.Trait<BodyOrientation>();
|
||||
|
||||
buildComplete = !self.HasTrait<Building>(); // always render instantly for units
|
||||
buildComplete = !self.Info.Traits.Contains<BuildingInfo>(); // always render instantly for units
|
||||
overlay = new Animation(self.World, rs.GetImage(self));
|
||||
if (info.StartSequence != null)
|
||||
overlay.PlayThen(RenderSprites.NormalizeSequence(overlay, self.GetDamageState(), info.StartSequence),
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
var rs = self.Trait<RenderSprites>();
|
||||
var body = self.Trait<BodyOrientation>();
|
||||
|
||||
buildComplete = !self.HasTrait<Building>(); // always render instantly for units
|
||||
buildComplete = !self.Info.Traits.Contains<BuildingInfo>(); // always render instantly for units
|
||||
overlay = new Animation(self.World, rs.GetImage(self));
|
||||
overlay.Play(info.Sequence);
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ using OpenRA.Traits;
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[Desc("Default trait for rendering sprite-based actors.")]
|
||||
public class WithSpriteBodyInfo : UpgradableTraitInfo, IRenderActorPreviewSpritesInfo, Requires<RenderSpritesInfo>
|
||||
public class WithSpriteBodyInfo : UpgradableTraitInfo, ISpriteBodyInfo, IRenderActorPreviewSpritesInfo, Requires<RenderSpritesInfo>
|
||||
{
|
||||
[Desc("Animation to play when the actor is created."), SequenceReference]
|
||||
public readonly string StartSequence = null;
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
get
|
||||
{
|
||||
yield return new EnterAlliedActorTargeter<Building>("Repair", 5, CanRepairAt, _ => CanRepair() || CanRearm());
|
||||
yield return new EnterAlliedActorTargeter<BuildingInfo>("Repair", 5, CanRepairAt, _ => CanRepair() || CanRearm());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
get
|
||||
{
|
||||
yield return new EnterAlliedActorTargeter<Building>("RepairNear", 5,
|
||||
yield return new EnterAlliedActorTargeter<BuildingInfo>("RepairNear", 5,
|
||||
target => CanRepairAt(target), _ => ShouldRepair());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
public AmbientSound(Actor self, AmbientSoundInfo info)
|
||||
{
|
||||
if (self.HasTrait<IOccupySpace>())
|
||||
if (self.Info.Traits.Contains<IOccupySpaceInfo>())
|
||||
Sound.PlayLooped(info.SoundFile, self.CenterPosition);
|
||||
else
|
||||
Sound.PlayLooped(info.SoundFile);
|
||||
|
||||
@@ -82,7 +82,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public override bool CanTargetActor(Actor self, Actor target, TargetModifiers modifiers, ref string cursor)
|
||||
{
|
||||
return target.HasTrait<AcceptsSupplies>();
|
||||
return target.Info.Traits.Contains<AcceptsSuppliesInfo>();
|
||||
}
|
||||
|
||||
public override bool CanTargetFrozenActor(Actor self, FrozenActor target, TargetModifiers modifiers, ref string cursor)
|
||||
|
||||
@@ -78,7 +78,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
void ActorRemoved(Actor a)
|
||||
{
|
||||
if (a.Owner != Self.Owner || !a.HasTrait<SupportPower>())
|
||||
if (a.Owner != Self.Owner || !a.Info.Traits.Contains<SupportPowerInfo>())
|
||||
return;
|
||||
|
||||
foreach (var t in a.TraitsImplementing<SupportPower>())
|
||||
@@ -119,7 +119,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public IEnumerable<SupportPowerInstance> GetPowersForActor(Actor a)
|
||||
{
|
||||
if (a.Owner != Self.Owner || !a.HasTrait<SupportPower>())
|
||||
if (a.Owner != Self.Owner || !a.Info.Traits.Contains<SupportPowerInfo>())
|
||||
return NoInstances;
|
||||
|
||||
return a.TraitsImplementing<SupportPower>()
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
if (IsTraitDisabled)
|
||||
return false;
|
||||
if (cloak == null || (!viewer.IsDead && viewer.HasTrait<IgnoresCloak>()))
|
||||
if (cloak == null || (!viewer.IsDead && viewer.Info.Traits.Contains<IgnoresCloakInfo>()))
|
||||
return true;
|
||||
|
||||
return cloak.IsVisible(self, viewer.Owner);
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public bool IsOwnerRowVisible { get { return ShowOwnerRow; } }
|
||||
}
|
||||
|
||||
public class Tooltip : IToolTip
|
||||
public class Tooltip : ITooltip
|
||||
{
|
||||
readonly Actor self;
|
||||
readonly TooltipInfo info;
|
||||
|
||||
@@ -109,10 +109,10 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (!queued)
|
||||
self.CancelActivity();
|
||||
|
||||
if (self.HasTrait<IFacing>())
|
||||
if (self.Info.Traits.Contains<IFacingInfo>())
|
||||
self.QueueActivity(new Turn(self, info.Facing));
|
||||
|
||||
if (self.HasTrait<Helicopter>())
|
||||
if (self.Info.Traits.Contains<HelicopterInfo>())
|
||||
self.QueueActivity(new HeliLand(self, true));
|
||||
|
||||
foreach (var nt in self.TraitsImplementing<INotifyTransform>())
|
||||
|
||||
Reference in New Issue
Block a user