add a total resource cash counter to the map editor

This commit is contained in:
Matthias Mailänder
2015-08-23 09:55:46 +02:00
parent d77839bb3d
commit fea59346a5
4 changed files with 33 additions and 0 deletions

View File

@@ -38,6 +38,8 @@ namespace OpenRA.Mods.Common.Traits
readonly Dictionary<PaletteReference, TerrainSpriteLayer> spriteLayers = new Dictionary<PaletteReference, TerrainSpriteLayer>();
public int NetWorth { get; private set; }
public EditorResourceLayer(Actor self)
{
if (self.World.Type != WorldType.Editor)
@@ -89,6 +91,10 @@ namespace OpenRA.Mods.Common.Traits
var uv = cell.ToMPos(Map);
var tile = Map.MapResources.Value[uv];
var t = Tiles[cell];
if (t.Density > 0)
NetWorth -= t.Density * t.Type.Info.ValuePerUnit;
ResourceType type;
if (Resources.TryGetValue(tile.Type, out type))
{
@@ -149,9 +155,13 @@ namespace OpenRA.Mods.Common.Traits
return t;
}
NetWorth -= t.Density * type.Info.ValuePerUnit;
// Set density based on the number of neighboring resources
t.Density = ResourceDensityAt(c);
NetWorth += t.Density * type.Info.ValuePerUnit;
var sprites = type.Variants[t.Variant];
var frame = int2.Lerp(0, sprites.Length - 1, t.Density - 1, type.Info.MaxDensity);
t.Sprite = sprites[frame];