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

@@ -81,7 +81,7 @@ namespace OpenRA.Mods.D2k.Traits
var initialFacing = self.World.Map.FacingBetween(location, self.Location, 0);
// If aircraft, spawn at cruise altitude
var aircraftInfo = self.World.Map.Rules.Actors[deliveringActorName.ToLower()].Traits.GetOrDefault<AircraftInfo>();
var aircraftInfo = self.World.Map.Rules.Actors[deliveringActorName.ToLower()].TraitInfoOrDefault<AircraftInfo>();
if (aircraftInfo != null)
spawn += new WVec(0, 0, aircraftInfo.CruiseAltitude.Length);

View File

@@ -33,7 +33,7 @@ namespace OpenRA.Mods.D2k.Traits
var pos = self.World.Map.CenterOfCell(location);
// If aircraft, spawn at cruise altitude
var aircraftInfo = producee.Traits.GetOrDefault<AircraftInfo>();
var aircraftInfo = producee.TraitInfoOrDefault<AircraftInfo>();
if (aircraftInfo != null)
pos += new WVec(0, 0, aircraftInfo.CruiseAltitude.Length);

View File

@@ -50,7 +50,7 @@ namespace OpenRA.Mods.D2k.Traits
IsBusy = false;
IsCarrying = false;
var helicopter = self.Info.Traits.GetOrDefault<HelicopterInfo>();
var helicopter = self.Info.TraitInfoOrDefault<HelicopterInfo>();
carryHeight = helicopter != null ? helicopter.LandAltitude : WDist.Zero;
}