mirror of
https://github.com/kwsch/NHSE.git
synced 2026-09-08 03:05:18 -05:00
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:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user