Remove enum tostring call for tile color fetch

lighten road colors on higher elevation

0.5->0.6 for 20% darker cliff edges
This commit is contained in:
Kurt
2020-04-28 19:17:05 -07:00
parent 6bb54264e8
commit 8808eadb20
2 changed files with 15 additions and 10 deletions

View File

@@ -1,4 +1,6 @@
namespace NHSE.Core
using static NHSE.Core.TerrainUnitModel;
namespace NHSE.Core
{
public enum TerrainUnitModel : ushort
{
@@ -252,7 +254,9 @@ public enum TerrainUnitModel : ushort
public static class TerrainUnitModelExtensions
{
public static bool IsRoad(this TerrainUnitModel t) =>
t >= TerrainUnitModel.RoadBrick0A || (TerrainUnitModel.RoadSoil0A <= t && t <= TerrainUnitModel.RoadStone8A);
public static bool IsRoad(this TerrainUnitModel t) => t >= RoadBrick0A || (RoadSoil0A <= t && t <= RoadStone8A);
public static bool IsFall(this TerrainUnitModel t) => (Fall101 <= t && t <= Fall404) || (Fall103 <= t && t <= Fall424);
public static bool IsCliff(this TerrainUnitModel t) => (Cliff0A <= t && t <= Cliff8) || (t == Cliff2B);
public static bool IsRiver(this TerrainUnitModel t) => (River0A <= t && t <= River8A);
}
}

View File

@@ -11,22 +11,23 @@ public static Color GetTileColor(TerrainTile tile)
{
if (tile.UnitModelRoad.IsRoad())
return Color.RosyBrown;
var name = tile.UnitModel.ToString();
var baseColor = GetTileColor(name);
var baseColor = GetTileDefaultColor(tile.UnitModel);
if (tile.Elevation == 0)
return baseColor;
return ColorUtil.Blend(baseColor, Color.White, 1d / (tile.Elevation + 1));
}
private static Color GetTileColor(string name)
private static readonly Color CliffBase = ColorUtil.Blend(Color.ForestGreen, Color.Black, 0.6d);
private static Color GetTileDefaultColor(TerrainUnitModel mdl)
{
if (name.StartsWith("River")) // River
if (mdl.IsRiver())
return Color.DeepSkyBlue;
if (name.StartsWith("Fall")) // Waterfall
if (mdl.IsFall())
return Color.DarkBlue;
if (name.Contains("Cliff"))
return ColorUtil.Blend(Color.ForestGreen, Color.Black, 0.5d);
if (mdl.IsCliff())
return CliffBase;
return Color.ForestGreen;
}