Fix CA1854
This commit is contained in:
@@ -322,8 +322,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
// Does this building have initial delay, if so have we passed it?
|
||||
if (baseBuilder.Info.BuildingDelays != null &&
|
||||
baseBuilder.Info.BuildingDelays.ContainsKey(name) &&
|
||||
baseBuilder.Info.BuildingDelays[name] > world.WorldTick)
|
||||
baseBuilder.Info.BuildingDelays.TryGetValue(name, out var delay) &&
|
||||
delay > world.WorldTick)
|
||||
continue;
|
||||
|
||||
// Can we build this structure?
|
||||
@@ -341,7 +341,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (count * 100 > frac.Value * playerBuildings.Length)
|
||||
continue;
|
||||
|
||||
if (baseBuilder.Info.BuildingLimits.ContainsKey(name) && baseBuilder.Info.BuildingLimits[name] <= count)
|
||||
if (baseBuilder.Info.BuildingLimits.TryGetValue(name, out var limit) && limit <= count)
|
||||
continue;
|
||||
|
||||
// If we're considering to build a naval structure, check whether there is enough water inside the base perimeter
|
||||
|
||||
@@ -79,9 +79,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
// If we have recently tried and failed to find a use location for a power, then do not try again until later
|
||||
var isDelayed = waitingPowers[sp] > 0;
|
||||
if (sp.Ready && !isDelayed && powerDecisions.ContainsKey(sp.Info.OrderName))
|
||||
if (sp.Ready && !isDelayed && powerDecisions.TryGetValue(sp.Info.OrderName, out var powerDecision))
|
||||
{
|
||||
var powerDecision = powerDecisions[sp.Info.OrderName];
|
||||
if (powerDecision == null)
|
||||
{
|
||||
AIUtils.BotDebug("{0} couldn't find powerDecision for {1}", player.PlayerName, sp.Info.OrderName);
|
||||
|
||||
@@ -121,13 +121,13 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return;
|
||||
|
||||
if (Info.UnitDelays != null &&
|
||||
Info.UnitDelays.ContainsKey(name) &&
|
||||
Info.UnitDelays[name] > world.WorldTick)
|
||||
Info.UnitDelays.TryGetValue(name, out var delay) &&
|
||||
delay > world.WorldTick)
|
||||
return;
|
||||
|
||||
if (Info.UnitLimits != null &&
|
||||
Info.UnitLimits.ContainsKey(name) &&
|
||||
world.Actors.Count(a => a.Owner == player && a.Info.Name == name) >= Info.UnitLimits[name])
|
||||
Info.UnitLimits.TryGetValue(name, out var limit) &&
|
||||
world.Actors.Count(a => a.Owner == player && a.Info.Name == name) >= limit)
|
||||
return;
|
||||
|
||||
bot.QueueOrder(Order.StartProduction(queue.Actor, name, 1));
|
||||
|
||||
@@ -102,8 +102,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public void ResolveOrder(Actor self, Order order)
|
||||
{
|
||||
// order.OrderString is the key of the support power
|
||||
if (Powers.ContainsKey(order.OrderString))
|
||||
Powers[order.OrderString].Activate(order);
|
||||
if (Powers.TryGetValue(order.OrderString, out var sp))
|
||||
sp.Activate(order);
|
||||
}
|
||||
|
||||
static readonly SupportPowerInstance[] NoInstances = Array.Empty<SupportPowerInstance>();
|
||||
|
||||
@@ -91,8 +91,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (speed > 0)
|
||||
{
|
||||
var nodesDict = t.Value.ToDictionary();
|
||||
var cost = nodesDict.ContainsKey("PathingCost")
|
||||
? FieldLoader.GetValue<short>("cost", nodesDict["PathingCost"].Value)
|
||||
var cost = nodesDict.TryGetValue("PathingCost", out var entry)
|
||||
? FieldLoader.GetValue<short>("cost", entry.Value)
|
||||
: 10000 / speed;
|
||||
ret.Add(t.Key, new TerrainInfo(speed, (short)cost));
|
||||
}
|
||||
|
||||
@@ -166,7 +166,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
// Existing smudge; make it deeper
|
||||
// A null Sequence indicates a deleted smudge.
|
||||
var tile = dirty.ContainsKey(loc) && dirty[loc].Sequence != null ? dirty[loc] : tiles[loc];
|
||||
var tile = dirty.TryGetValue(loc, out var d) && d.Sequence != null ? d : tiles[loc];
|
||||
var maxDepth = smudges[tile.Type].Length;
|
||||
if (tile.Depth < maxDepth - 1)
|
||||
tile.Depth++;
|
||||
@@ -180,7 +180,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (!world.Map.Contains(loc))
|
||||
return;
|
||||
|
||||
var tile = dirty.ContainsKey(loc) ? dirty[loc] : default;
|
||||
var tile = dirty.TryGetValue(loc, out var d) ? d : default;
|
||||
|
||||
// Setting Sequence to null to indicate a deleted smudge.
|
||||
tile.Sequence = null;
|
||||
|
||||
Reference in New Issue
Block a user