Use null propagation
This commit is contained in:
@@ -37,11 +37,8 @@ namespace OpenRA.Mods.Common.Activities
|
||||
{
|
||||
if (self.World.Map.DistanceAboveTerrain(self.CenterPosition).Length <= 0)
|
||||
{
|
||||
if (info.ExplosionWeapon != null)
|
||||
{
|
||||
// Use .FromPos since this actor is killed. Cannot use Target.FromActor
|
||||
info.ExplosionWeapon.Impact(Target.FromPos(self.CenterPosition), self);
|
||||
}
|
||||
// Use .FromPos since this actor is killed. Cannot use Target.FromActor
|
||||
info.ExplosionWeapon?.Impact(Target.FromPos(self.CenterPosition), self);
|
||||
|
||||
self.Kill(self);
|
||||
Cancel(self);
|
||||
|
||||
@@ -74,8 +74,8 @@ namespace OpenRA.Mods.Common.Activities
|
||||
|
||||
if (enterLegacyHut != null)
|
||||
enterLegacyHut.Repair(self);
|
||||
else if (enterHut != null)
|
||||
enterHut.Repair(self);
|
||||
else
|
||||
enterHut?.Repair(self);
|
||||
|
||||
Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", speechNotification, self.Owner.Faction.InternalName);
|
||||
TextNotificationsManager.AddTransientLine(textNotification, self.Owner);
|
||||
|
||||
@@ -53,9 +53,9 @@ namespace OpenRA.Mods.Common
|
||||
|
||||
public void Initialize(int value)
|
||||
{
|
||||
var field = GetType().GetField(nameof(value), BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
if (field != null)
|
||||
field.SetValue(this, value);
|
||||
GetType()
|
||||
.GetField(nameof(value), BindingFlags.NonPublic | BindingFlags.Instance)
|
||||
?.SetValue(this, value);
|
||||
}
|
||||
|
||||
public override MiniYaml Save()
|
||||
|
||||
@@ -74,8 +74,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
self.World.Add(playerBeacon);
|
||||
|
||||
if (self.Owner.IsAlliedWith(self.World.RenderPlayer))
|
||||
Game.Sound.PlayNotification(self.World.Map.Rules, null, info.NotificationType, info.Notification,
|
||||
self.World.RenderPlayer != null ? self.World.RenderPlayer.Faction.InternalName : null);
|
||||
Game.Sound.PlayNotification(self.World.Map.Rules, null, info.NotificationType, info.Notification, self.World.RenderPlayer?.Faction.InternalName);
|
||||
|
||||
if (radarPings != null)
|
||||
{
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
if (!world.IsLoadingGameSave)
|
||||
{
|
||||
Game.Sound.PlayNotification(world.Map.Rules, null, "Speech", info.Notification, world.RenderPlayer == null ? null : world.RenderPlayer.Faction.InternalName);
|
||||
Game.Sound.PlayNotification(world.Map.Rules, null, "Speech", info.Notification, world.RenderPlayer?.Faction.InternalName);
|
||||
TextNotificationsManager.AddTransientLine(info.TextNotification, null);
|
||||
}
|
||||
}
|
||||
@@ -56,7 +56,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
if (!world.IsReplay)
|
||||
{
|
||||
Game.Sound.PlayNotification(world.Map.Rules, null, "Speech", info.LoadedNotification, world.RenderPlayer == null ? null : world.RenderPlayer.Faction.InternalName);
|
||||
Game.Sound.PlayNotification(world.Map.Rules, null, "Speech", info.LoadedNotification, world.RenderPlayer?.Faction.InternalName);
|
||||
TextNotificationsManager.AddTransientLine(info.LoadedTextNotification, null);
|
||||
}
|
||||
}
|
||||
@@ -65,7 +65,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
if (!world.IsReplay)
|
||||
{
|
||||
Game.Sound.PlayNotification(world.Map.Rules, null, "Speech", info.SavedNotification, world.RenderPlayer == null ? null : world.RenderPlayer.Faction.InternalName);
|
||||
Game.Sound.PlayNotification(world.Map.Rules, null, "Speech", info.SavedNotification, world.RenderPlayer?.Faction.InternalName);
|
||||
TextNotificationsManager.AddTransientLine(info.SavedTextNotification, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,8 +117,7 @@ namespace OpenRA.Mods.Common.UpdateRules
|
||||
if (namedType != null && namedType.IsSubclassOf(typeof(UpdateRule)))
|
||||
return new[] { (UpdateRule)objectCreator.CreateBasic(namedType) };
|
||||
|
||||
var namedPath = Paths.FirstOrDefault(p => p.source == source);
|
||||
return namedPath != null ? namedPath.Rules(chain) : null;
|
||||
return Paths.FirstOrDefault(p => p.source == source)?.Rules(chain);
|
||||
}
|
||||
|
||||
public static IEnumerable<string> KnownPaths { get { return Paths.Select(p => p.source); } }
|
||||
|
||||
@@ -171,7 +171,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
set
|
||||
{
|
||||
paletteWidget.Value.CurrentQueue = value;
|
||||
queueGroup = value != null ? value.Info.Group : null;
|
||||
queueGroup = value?.Info.Group;
|
||||
|
||||
// TODO: Scroll tabs so selected queue is visible
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
{
|
||||
currentPlayer = player;
|
||||
|
||||
var newShroud = player != null ? player.Shroud : null;
|
||||
var newShroud = player?.Shroud;
|
||||
|
||||
if (newShroud != shroud)
|
||||
{
|
||||
@@ -146,8 +146,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
shroud = newShroud;
|
||||
}
|
||||
|
||||
var newPlayerRadarTerrain =
|
||||
currentPlayer != null ? currentPlayer.PlayerActor.TraitOrDefault<PlayerRadarTerrain>() : null;
|
||||
var newPlayerRadarTerrain = currentPlayer?.PlayerActor.TraitOrDefault<PlayerRadarTerrain>();
|
||||
|
||||
if (forceUpdate || newPlayerRadarTerrain != playerRadarTerrain)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user