Use Null-Propagation Operator
This commit is contained in:
@@ -302,8 +302,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
// If this bridge repair operation connects two pathfinding domains,
|
||||
// update the domain index.
|
||||
var domainIndex = self.World.WorldActor.TraitOrDefault<DomainIndex>();
|
||||
if (domainIndex != null)
|
||||
domainIndex.UpdateCells(self.World, footprint.Keys);
|
||||
domainIndex?.UpdateCells(self.World, footprint.Keys);
|
||||
|
||||
if (LongBridgeSegmentIsDead() && !killedUnits)
|
||||
{
|
||||
|
||||
@@ -70,9 +70,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
foreach (var cell in cells)
|
||||
self.World.Map.CustomTerrain[cell] = terrainIndex;
|
||||
|
||||
var domainIndex = self.World.WorldActor.TraitOrDefault<DomainIndex>();
|
||||
if (domainIndex != null)
|
||||
domainIndex.UpdateCells(self.World, cells);
|
||||
self.World.WorldActor.TraitOrDefault<DomainIndex>()?.UpdateCells(self.World, cells);
|
||||
}
|
||||
|
||||
void INotifyAddedToWorld.AddedToWorld(Actor self)
|
||||
|
||||
@@ -91,10 +91,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
void INotifyLineBuildSegmentsChanged.SegmentRemoved(Actor self, Actor segment)
|
||||
{
|
||||
if (segments == null)
|
||||
return;
|
||||
|
||||
segments.Remove(segment);
|
||||
segments?.Remove(segment);
|
||||
}
|
||||
|
||||
void INotifyAddedToWorld.AddedToWorld(Actor self)
|
||||
|
||||
@@ -172,9 +172,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (r == self.Owner)
|
||||
return;
|
||||
|
||||
var exp = r.PlayerActor.TraitOrDefault<PlayerExperience>();
|
||||
if (exp != null)
|
||||
exp.GiveExperience(Info.PlayerExperience);
|
||||
r.PlayerActor.TraitOrDefault<PlayerExperience>()?.GiveExperience(Info.PlayerExperience);
|
||||
});
|
||||
|
||||
Repairers.Clear();
|
||||
|
||||
@@ -131,8 +131,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
// Manually manage the inner activity queue
|
||||
var activity = currentTransform ?? transform.GetTransformActivity(self);
|
||||
if (!order.Queued && activity.NextActivity != null)
|
||||
activity.NextActivity.Cancel(self);
|
||||
if (!order.Queued)
|
||||
activity.NextActivity?.Cancel(self);
|
||||
|
||||
activity.Queue(new IssueOrderAfterTransform(order.OrderString, order.Target, Color.Green));
|
||||
|
||||
|
||||
@@ -95,8 +95,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
// Manually manage the inner activity queue
|
||||
var activity = currentTransform ?? transform.GetTransformActivity(self);
|
||||
if (!order.Queued && activity.NextActivity != null)
|
||||
activity.NextActivity.Cancel(self);
|
||||
if (!order.Queued)
|
||||
activity.NextActivity?.Cancel(self);
|
||||
|
||||
activity.Queue(new IssueOrderAfterTransform(order.OrderString, order.Target, Color.Green));
|
||||
|
||||
|
||||
@@ -110,8 +110,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
// Manually manage the inner activity queue
|
||||
var activity = currentTransform ?? transform.GetTransformActivity(self);
|
||||
if (!order.Queued && activity.NextActivity != null)
|
||||
activity.NextActivity.Cancel(self);
|
||||
if (!order.Queued)
|
||||
activity.NextActivity?.Cancel(self);
|
||||
|
||||
activity.Queue(new IssueOrderAfterTransform("Move", order.Target, Color.Green));
|
||||
|
||||
|
||||
@@ -129,8 +129,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
// Manually manage the inner activity queue
|
||||
var activity = currentTransform ?? transform.GetTransformActivity(self);
|
||||
if (!order.Queued && activity.NextActivity != null)
|
||||
activity.NextActivity.Cancel(self);
|
||||
if (!order.Queued)
|
||||
activity.NextActivity?.Cancel(self);
|
||||
|
||||
activity.Queue(new IssueOrderAfterTransform(order.OrderString, order.Target, Color.Green));
|
||||
|
||||
|
||||
@@ -123,8 +123,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
// Manually manage the inner activity queue
|
||||
var activity = currentTransform ?? transform.GetTransformActivity(self);
|
||||
if (!order.Queued && activity.NextActivity != null)
|
||||
activity.NextActivity.Cancel(self);
|
||||
if (!order.Queued)
|
||||
activity.NextActivity?.Cancel(self);
|
||||
|
||||
activity.Queue(new IssueOrderAfterTransform(order.OrderString, order.Target, Color.Green));
|
||||
|
||||
|
||||
@@ -41,8 +41,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (!order.Queued || currentTransform == null)
|
||||
return;
|
||||
|
||||
if (!order.Queued && currentTransform.NextActivity != null)
|
||||
currentTransform.NextActivity.Cancel(self);
|
||||
if (!order.Queued)
|
||||
currentTransform.NextActivity?.Cancel(self);
|
||||
|
||||
currentTransform.Queue(new IssueOrderAfterTransform("DeployTransform", order.Target, Color.Green));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user