Fix CA1854

This commit is contained in:
RoosterDragon
2023-03-12 17:38:38 +00:00
committed by abcdefg30
parent 56fe08cb00
commit 231bf01f18
26 changed files with 93 additions and 86 deletions

View File

@@ -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

View File

@@ -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);

View File

@@ -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));