Use out var syntax
This commit is contained in:
@@ -377,8 +377,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
var layer = c.Cell.Layer == 0 ? influence : customInfluence[c.Cell.Layer];
|
||||
layer[uv] = new InfluenceNode { Next = layer[uv], SubCell = c.SubCell, Actor = self };
|
||||
|
||||
List<CellTrigger> triggers;
|
||||
if (cellTriggerInfluence.TryGetValue(c.Cell, out triggers))
|
||||
if (cellTriggerInfluence.TryGetValue(c.Cell, out var triggers))
|
||||
foreach (var t in triggers)
|
||||
t.Dirty = true;
|
||||
|
||||
@@ -400,8 +399,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
RemoveInfluenceInner(ref temp, self);
|
||||
layer[uv] = temp;
|
||||
|
||||
List<CellTrigger> triggers;
|
||||
if (cellTriggerInfluence.TryGetValue(c.Cell, out triggers))
|
||||
if (cellTriggerInfluence.TryGetValue(c.Cell, out var triggers))
|
||||
foreach (var t in triggers)
|
||||
t.Dirty = true;
|
||||
|
||||
@@ -487,8 +485,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public void RemoveCellTrigger(int id)
|
||||
{
|
||||
CellTrigger trigger;
|
||||
if (!cellTriggers.TryGetValue(id, out trigger))
|
||||
if (!cellTriggers.TryGetValue(id, out var trigger))
|
||||
return;
|
||||
|
||||
foreach (var c in trigger.Footprint)
|
||||
@@ -514,8 +511,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public void RemoveProximityTrigger(int id)
|
||||
{
|
||||
ProximityTrigger t;
|
||||
if (!proximityTriggers.TryGetValue(id, out t))
|
||||
if (!proximityTriggers.TryGetValue(id, out var t))
|
||||
return;
|
||||
|
||||
foreach (var bin in BinsInBox(t.TopLeft, t.BottomRight))
|
||||
@@ -526,8 +522,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public void UpdateProximityTrigger(int id, WPos newPos, WDist newRange, WDist newVRange)
|
||||
{
|
||||
ProximityTrigger t;
|
||||
if (!proximityTriggers.TryGetValue(id, out t))
|
||||
if (!proximityTriggers.TryGetValue(id, out var t))
|
||||
return;
|
||||
|
||||
foreach (var bin in BinsInBox(t.TopLeft, t.BottomRight))
|
||||
|
||||
@@ -163,8 +163,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
foreach (var cell in footprint)
|
||||
{
|
||||
List<EditorActorPreview> list;
|
||||
if (!cellMap.TryGetValue(cell, out list))
|
||||
if (!cellMap.TryGetValue(cell, out var list))
|
||||
continue;
|
||||
|
||||
list.Remove(preview);
|
||||
@@ -228,8 +227,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
void AddPreviewLocation(EditorActorPreview preview, CPos location)
|
||||
{
|
||||
List<EditorActorPreview> list;
|
||||
if (!cellMap.TryGetValue(location, out list))
|
||||
if (!cellMap.TryGetValue(location, out var list))
|
||||
{
|
||||
list = new List<EditorActorPreview>();
|
||||
cellMap.Add(location, list);
|
||||
@@ -256,8 +254,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public IEnumerable<EditorActorPreview> PreviewsAt(CPos cell)
|
||||
{
|
||||
List<EditorActorPreview> list;
|
||||
if (cellMap.TryGetValue(cell, out list))
|
||||
if (cellMap.TryGetValue(cell, out var list))
|
||||
return list;
|
||||
|
||||
return Enumerable.Empty<EditorActorPreview>();
|
||||
@@ -274,8 +271,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
var blocked = previews.Any(p =>
|
||||
{
|
||||
SubCell s;
|
||||
return p.Footprint.TryGetValue(cell, out s) && s == (SubCell)i;
|
||||
return p.Footprint.TryGetValue(cell, out var s) && s == (SubCell)i;
|
||||
});
|
||||
|
||||
if (!blocked)
|
||||
|
||||
@@ -71,11 +71,10 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
var tile = Map.Resources[uv];
|
||||
var t = Tiles[uv];
|
||||
ResourceType type;
|
||||
|
||||
var newTile = ResourceLayerContents.Empty;
|
||||
var newTerrain = byte.MaxValue;
|
||||
if (Resources.TryGetValue(tile.Type, out type))
|
||||
if (Resources.TryGetValue(tile.Type, out var type))
|
||||
{
|
||||
newTile = new ResourceLayerContents
|
||||
{
|
||||
|
||||
@@ -83,8 +83,7 @@ namespace OpenRA.Mods.Common
|
||||
|
||||
public Color GetRemappedColor(Color original, int index)
|
||||
{
|
||||
int c;
|
||||
return replacements.TryGetValue(index, out c)
|
||||
return replacements.TryGetValue(index, out var c)
|
||||
? basePalette.GetColor(c) : original;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,9 +58,8 @@ namespace OpenRA.Mods.Common
|
||||
{
|
||||
var basePalette = wr.Palette(info.BasePalette).Palette;
|
||||
ImmutablePalette pal;
|
||||
int[] remap;
|
||||
|
||||
if (info.PlayerIndex.TryGetValue(playerName, out remap))
|
||||
if (info.PlayerIndex.TryGetValue(playerName, out var remap))
|
||||
pal = new ImmutablePalette(basePalette, new IndexedColorRemap(basePalette, info.RemapIndex, remap));
|
||||
else
|
||||
pal = new ImmutablePalette(basePalette);
|
||||
|
||||
@@ -107,8 +107,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
foreach (var kvp in TerrainSpeeds)
|
||||
{
|
||||
byte index;
|
||||
if (tileSet.TryGetTerrainIndex(kvp.Key, out index))
|
||||
if (tileSet.TryGetTerrainIndex(kvp.Key, out var index))
|
||||
info[index] = kvp.Value;
|
||||
}
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (!lines.MoveNext() || (lines.Current != "GIMP Palette" && lines.Current != "JASC-PAL"))
|
||||
throw new InvalidDataException("File `{0}` is not a valid GIMP or JASC palette.".F(Filename));
|
||||
|
||||
byte r, g, b, a;
|
||||
byte a;
|
||||
a = 255;
|
||||
var i = 0;
|
||||
|
||||
@@ -77,13 +77,13 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (rgba.Length < 3)
|
||||
throw new InvalidDataException("Invalid RGB(A) triplet/quartet: ({0})".F(string.Join(" ", rgba)));
|
||||
|
||||
if (!byte.TryParse(rgba[0], out r))
|
||||
if (!byte.TryParse(rgba[0], out var r))
|
||||
throw new InvalidDataException("Invalid R value: {0}".F(rgba[0]));
|
||||
|
||||
if (!byte.TryParse(rgba[1], out g))
|
||||
if (!byte.TryParse(rgba[1], out var g))
|
||||
throw new InvalidDataException("Invalid G value: {0}".F(rgba[1]));
|
||||
|
||||
if (!byte.TryParse(rgba[2], out b))
|
||||
if (!byte.TryParse(rgba[2], out var b))
|
||||
throw new InvalidDataException("Invalid B value: {0}".F(rgba[2]));
|
||||
|
||||
// Check if color has a (valid) alpha value.
|
||||
|
||||
@@ -38,8 +38,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return false;
|
||||
|
||||
// Remove the actor's last claim, if it has one
|
||||
CPos lastClaim;
|
||||
if (claimByActor.TryGetValue(claimer, out lastClaim))
|
||||
if (claimByActor.TryGetValue(claimer, out var lastClaim))
|
||||
claimByCell.GetOrAdd(lastClaim).Remove(claimer);
|
||||
|
||||
claimers.Add(claimer);
|
||||
@@ -61,8 +60,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
/// </summary>
|
||||
public void RemoveClaim(Actor claimer)
|
||||
{
|
||||
CPos lastClaim;
|
||||
if (claimByActor.TryGetValue(claimer, out lastClaim))
|
||||
if (claimByActor.TryGetValue(claimer, out var lastClaim))
|
||||
claimByCell.GetOrAdd(lastClaim).Remove(claimer);
|
||||
|
||||
claimByActor.Remove(claimer);
|
||||
|
||||
@@ -82,8 +82,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
foreach (var cell in w.Map.AllCells)
|
||||
{
|
||||
ResourceType t;
|
||||
if (!resources.TryGetValue(w.Map.Resources[cell].Type, out t))
|
||||
if (!resources.TryGetValue(w.Map.Resources[cell].Type, out var t))
|
||||
continue;
|
||||
|
||||
if (!AllowResourceAt(t, cell))
|
||||
|
||||
@@ -51,10 +51,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public static object LoadInitialSmudges(MiniYaml yaml)
|
||||
{
|
||||
MiniYaml smudgeYaml;
|
||||
var nd = yaml.ToDictionary();
|
||||
var smudges = new Dictionary<CPos, MapSmudge>();
|
||||
if (nd.TryGetValue("InitialSmudges", out smudgeYaml))
|
||||
if (nd.TryGetValue("InitialSmudges", out var smudgeYaml))
|
||||
{
|
||||
foreach (var node in smudgeYaml.Nodes)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user