Add ActorInfo.TraitInfo[OrDefault]<T>() requiring ITraitIfo types
This commit is contained in:
@@ -28,12 +28,12 @@ namespace OpenRA.Mods.Common.Activities
|
||||
{
|
||||
this.dest = dest;
|
||||
plane = self.Trait<Plane>();
|
||||
planeInfo = self.Info.Traits.Get<PlaneInfo>();
|
||||
planeInfo = self.Info.TraitInfo<PlaneInfo>();
|
||||
}
|
||||
|
||||
public static Actor ChooseAirfield(Actor self, bool unreservedOnly)
|
||||
{
|
||||
var rearmBuildings = self.Info.Traits.Get<PlaneInfo>().RearmBuildings;
|
||||
var rearmBuildings = self.Info.TraitInfo<PlaneInfo>().RearmBuildings;
|
||||
return self.World.ActorsWithTrait<Reservable>()
|
||||
.Where(a => a.Actor.Owner == self.Owner)
|
||||
.Where(a => rearmBuildings.Contains(a.Actor.Info.Name)
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
{
|
||||
actor = target;
|
||||
building = actor.TraitOrDefault<Building>();
|
||||
capturesInfo = self.Info.Traits.Get<CapturesInfo>();
|
||||
capturesInfo = self.Info.TraitInfo<CapturesInfo>();
|
||||
capturable = target.Trait<Capturable>();
|
||||
health = actor.Trait<Health>();
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
{
|
||||
this.target = target;
|
||||
capturable = target.Actor.Trait<ExternalCapturable>();
|
||||
capturesInfo = self.Info.Traits.Get<ExternalCapturesInfo>();
|
||||
capturesInfo = self.Info.TraitInfo<ExternalCapturesInfo>();
|
||||
mobile = self.Trait<Mobile>();
|
||||
}
|
||||
|
||||
|
||||
@@ -34,9 +34,9 @@ namespace OpenRA.Mods.Common.Activities
|
||||
public FindResources(Actor self)
|
||||
{
|
||||
harv = self.Trait<Harvester>();
|
||||
harvInfo = self.Info.Traits.Get<HarvesterInfo>();
|
||||
harvInfo = self.Info.TraitInfo<HarvesterInfo>();
|
||||
mobile = self.Trait<Mobile>();
|
||||
mobileInfo = self.Info.Traits.Get<MobileInfo>();
|
||||
mobileInfo = self.Info.TraitInfo<MobileInfo>();
|
||||
resLayer = self.World.WorldActor.Trait<ResourceLayer>();
|
||||
territory = self.World.WorldActor.TraitOrDefault<ResourceClaimLayer>();
|
||||
pathFinder = self.World.WorldActor.Trait<IPathFinder>();
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
public HarvestResource(Actor self)
|
||||
{
|
||||
harv = self.Trait<Harvester>();
|
||||
harvInfo = self.Info.Traits.Get<HarvesterInfo>();
|
||||
harvInfo = self.Info.TraitInfo<HarvesterInfo>();
|
||||
facing = self.Trait<IFacing>();
|
||||
territory = self.World.WorldActor.TraitOrDefault<ResourceClaimLayer>();
|
||||
resLayer = self.World.WorldActor.Trait<ResourceLayer>();
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
pos = self.TraitOrDefault<IPositionable>();
|
||||
|
||||
// Parachutable trait is a prerequisite for running this activity
|
||||
para = self.Info.Traits.Get<ParachutableInfo>();
|
||||
para = self.Info.TraitInfo<ParachutableInfo>();
|
||||
fallVector = new WVec(0, 0, para.FallRate);
|
||||
this.dropPosition = dropPosition;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
public Repair(Actor host)
|
||||
{
|
||||
this.host = host;
|
||||
repairsUnits = host.Info.Traits.Get<RepairsUnitsInfo>();
|
||||
repairsUnits = host.Info.TraitInfo<RepairsUnitsInfo>();
|
||||
}
|
||||
|
||||
public override Activity Tick(Actor self)
|
||||
@@ -45,7 +45,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
|
||||
if (remainingTicks == 0)
|
||||
{
|
||||
var unitCost = self.Info.Traits.Get<ValuedInfo>().Cost;
|
||||
var unitCost = self.Info.TraitInfo<ValuedInfo>().Cost;
|
||||
var hpToRepair = repairsUnits.HpPerStep;
|
||||
var cost = Math.Max(1, (hpToRepair * unitCost * repairsUnits.ValuePercentage) / (health.MaxHP * 100));
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
public Sell(Actor self)
|
||||
{
|
||||
health = self.TraitOrDefault<Health>();
|
||||
sellableInfo = self.Info.Traits.Get<SellableInfo>();
|
||||
sellableInfo = self.Info.TraitInfo<SellableInfo>();
|
||||
playerResources = self.Owner.PlayerActor.Trait<PlayerResources>();
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
: base(self, refinery, dockAngle, isDragRequired, dragOffset, dragLength)
|
||||
{
|
||||
wsb = self.Trait<WithSpriteBody>();
|
||||
wda = self.Info.Traits.Get<WithDockingAnimationInfo>();
|
||||
wda = self.Info.TraitInfo<WithDockingAnimationInfo>();
|
||||
}
|
||||
|
||||
public override Activity OnStateDock(Actor self)
|
||||
|
||||
Reference in New Issue
Block a user