Add ActorInfo.TraitInfo[OrDefault]<T>() requiring ITraitIfo types

This commit is contained in:
atlimit8
2015-08-03 16:07:33 -05:00
parent 6970959ef1
commit 09984683a7
115 changed files with 195 additions and 193 deletions

View File

@@ -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)

View File

@@ -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>();
}

View File

@@ -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>();
}

View File

@@ -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>();

View File

@@ -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>();

View File

@@ -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;
}

View File

@@ -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));

View File

@@ -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>();
}

View File

@@ -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)