Change GetField calls to use nameof

This commit is contained in:
teinarss
2021-02-28 18:07:35 +01:00
committed by abcdefg30
parent ed295ae315
commit c2279d3071
5 changed files with 13 additions and 13 deletions

View File

@@ -75,15 +75,15 @@ namespace OpenRA.Mods.Common.Terrain
FieldLoader.Load(tile, my);
// Terrain type must be converted from a string to an index
tile.GetType().GetField("TerrainType").SetValue(tile, terrainInfo.GetTerrainIndex(my.Value));
tile.GetType().GetField(nameof(tile.TerrainType)).SetValue(tile, terrainInfo.GetTerrainIndex(my.Value));
// Fall back to the terrain-type color if necessary
var overrideColor = terrainInfo.TerrainTypes[tile.TerrainType].Color;
if (tile.MinColor == default)
tile.GetType().GetField("MinColor").SetValue(tile, overrideColor);
tile.GetType().GetField(nameof(tile.MinColor)).SetValue(tile, overrideColor);
if (tile.MaxColor == default)
tile.GetType().GetField("MaxColor").SetValue(tile, overrideColor);
tile.GetType().GetField(nameof(tile.MaxColor)).SetValue(tile, overrideColor);
return tile;
}