Replace terniary null checks with coalescing.
This commit is contained in:
@@ -82,7 +82,7 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
{
|
||||
body = self.Trait<BodyOrientation>();
|
||||
facing = self.TraitOrDefault<IFacing>();
|
||||
cachedFacing = facing != null ? facing.Facing : WAngle.Zero;
|
||||
cachedFacing = facing?.Facing ?? WAngle.Zero;
|
||||
cachedPosition = self.CenterPosition;
|
||||
|
||||
base.Created(self);
|
||||
@@ -126,14 +126,14 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
var pos = Info.Type == TrailType.CenterPosition ? spawnPosition + body.LocalToWorld(offsetRotation) :
|
||||
self.World.Map.CenterOfCell(spawnCell);
|
||||
|
||||
var spawnFacing = Info.SpawnAtLastPosition ? cachedFacing : (facing != null ? facing.Facing : WAngle.Zero);
|
||||
var spawnFacing = Info.SpawnAtLastPosition ? cachedFacing : facing?.Facing ?? WAngle.Zero;
|
||||
|
||||
if ((Info.TerrainTypes.Count == 0 || Info.TerrainTypes.Contains(type)) && !string.IsNullOrEmpty(Info.Image))
|
||||
self.World.AddFrameEndTask(w => w.Add(new SpriteEffect(pos, spawnFacing, self.World, Info.Image,
|
||||
Info.Sequences.Random(Game.CosmeticRandom), Info.Palette, Info.VisibleThroughFog)));
|
||||
|
||||
cachedPosition = self.CenterPosition;
|
||||
cachedFacing = facing != null ? facing.Facing : WAngle.Zero;
|
||||
cachedFacing = facing?.Facing ?? WAngle.Zero;
|
||||
ticks = 0;
|
||||
|
||||
cachedInterval = isMoving ? Info.MovingInterval : Info.StationaryInterval;
|
||||
|
||||
Reference in New Issue
Block a user