Merge pull request #9139 from Mailaender/editor-cash-counter
Added a total resource cash counter to the map editor
This commit is contained in:
@@ -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];
|
||||
|
||||
Reference in New Issue
Block a user