Use Null-Propagation Operator
This commit is contained in:
@@ -65,8 +65,7 @@ namespace OpenRA.Mods.Cnc.Activities
|
||||
t.Infiltrated(targetActor, self, infiltrates.Info.Types);
|
||||
|
||||
var exp = self.Owner.PlayerActor.TraitOrDefault<PlayerExperience>();
|
||||
if (exp != null)
|
||||
exp.GiveExperience(infiltrates.Info.PlayerExperience);
|
||||
exp?.GiveExperience(infiltrates.Info.PlayerExperience);
|
||||
|
||||
if (!string.IsNullOrEmpty(infiltrates.Info.Notification))
|
||||
Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech",
|
||||
|
||||
@@ -97,8 +97,8 @@ namespace OpenRA.Mods.Cnc.Activities
|
||||
}
|
||||
|
||||
// Consume teleport charges if this wasn't triggered via chronosphere
|
||||
if (teleporter == self && pc != null)
|
||||
pc.ResetChargeTime();
|
||||
if (teleporter == self)
|
||||
pc?.ResetChargeTime();
|
||||
|
||||
// Trigger screen desaturate effect
|
||||
if (screenFlash)
|
||||
|
||||
@@ -194,8 +194,7 @@ namespace OpenRA.Mods.Cnc.Graphics
|
||||
|
||||
public void RefreshBuffer()
|
||||
{
|
||||
if (vertexBuffer != null)
|
||||
vertexBuffer.Dispose();
|
||||
vertexBuffer?.Dispose();
|
||||
vertexBuffer = Game.Renderer.CreateVertexBuffer(totalVertexCount);
|
||||
vertexBuffer.SetData(vertices.SelectMany(v => v).ToArray(), totalVertexCount);
|
||||
cachedVertexCount = totalVertexCount;
|
||||
@@ -234,8 +233,7 @@ namespace OpenRA.Mods.Cnc.Graphics
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (vertexBuffer != null)
|
||||
vertexBuffer.Dispose();
|
||||
vertexBuffer?.Dispose();
|
||||
sheetBuilder.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,13 +52,8 @@ namespace OpenRA.Mods.Cnc.Traits
|
||||
if (!IsTraitDisabled && damage != null)
|
||||
{
|
||||
var damageSubTicks = (int)(damage.Value * 100L * Info.DamageMultiplier / Info.DamageDivisor);
|
||||
|
||||
if (spm.Powers.TryGetValue(Info.OrderName, out var spi))
|
||||
{
|
||||
var dspi = spi as GrantPrerequisiteChargeDrainPower.DischargeableSupportPowerInstance;
|
||||
if (dspi != null)
|
||||
dspi.Discharge(damageSubTicks);
|
||||
}
|
||||
(spi as GrantPrerequisiteChargeDrainPower.DischargeableSupportPowerInstance)?.Discharge(damageSubTicks);
|
||||
}
|
||||
|
||||
return 100;
|
||||
|
||||
@@ -240,9 +240,7 @@ namespace OpenRA.Mods.Cnc.Traits
|
||||
new LocationInit(self.Location),
|
||||
new OwnerInit(self.Owner)
|
||||
});
|
||||
var driverMobile = driver.TraitOrDefault<Mobile>();
|
||||
if (driverMobile != null)
|
||||
driverMobile.Nudge(driver);
|
||||
driver.TraitOrDefault<Mobile>()?.Nudge(driver);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,8 +49,7 @@ namespace OpenRA.Mods.Cnc.Traits
|
||||
var external = toActor.TraitsImplementing<ExternalCondition>()
|
||||
.FirstOrDefault(t => t.Info.Condition == info.Condition && t.CanGrantCondition(toActor, this));
|
||||
|
||||
if (external != null)
|
||||
external.GrantCondition(toActor, this, duration, remaining);
|
||||
external?.GrantCondition(toActor, this, duration, remaining);
|
||||
}
|
||||
|
||||
void IConditionTimerWatcher.Update(int duration, int remaining)
|
||||
|
||||
Reference in New Issue
Block a user