Merge pull request #8430 from pchote/editor-cordon

Display and support editing the area outside the map bounds
This commit is contained in:
Pavel Penev
2015-06-12 17:49:10 +03:00
14 changed files with 138 additions and 48 deletions

View File

@@ -86,11 +86,7 @@ namespace OpenRA.Mods.Common.Traits
// so we must also touch all the neighbouring tiles
Dirty.Add(cell);
foreach (var d in CVec.Directions)
{
var c = cell + d;
if (Map.Contains(c))
Dirty.Add(c);
}
Dirty.Add(cell + d);
}
protected virtual string ChooseRandomVariant(ResourceType t)
@@ -103,10 +99,16 @@ namespace OpenRA.Mods.Common.Traits
// Set density based on the number of neighboring resources
var adjacent = 0;
var type = Tiles[c].Type;
var resources = Map.MapResources.Value;
for (var u = -1; u < 2; u++)
{
for (var v = -1; v < 2; v++)
if (Map.MapResources.Value[c + new CVec(u, v)].Type == type.Info.ResourceType)
{
var cell = c + new CVec(u, v);
if (resources.Contains(cell) && resources[cell].Type == type.Info.ResourceType)
adjacent++;
}
}
return Math.Max(int2.Lerp(0, type.Info.MaxDensity, adjacent, 9), 1);
}
@@ -139,7 +141,8 @@ namespace OpenRA.Mods.Common.Traits
return;
foreach (var c in Dirty)
Tiles[c] = UpdateDirtyTile(c);
if (Tiles.Contains(c))
Tiles[c] = UpdateDirtyTile(c);
Dirty.Clear();

View File

@@ -50,9 +50,14 @@ namespace OpenRA.Mods.Common.Traits
{
var sum = 0;
for (var u = -1; u < 2; u++)
{
for (var v = -1; v < 2; v++)
if (content[cell + new CVec(u, v)].Type == t)
{
var c = cell + new CVec(u, v);
if (content.Contains(c) && content[c].Type == t)
++sum;
}
}
return sum;
}

View File

@@ -164,7 +164,13 @@ namespace OpenRA.Mods.Common.Traits
}
DirtyCells(map.AllCells);
visibleUnderShroud = map.Contains;
// All tiles are visible in the editor
if (w.Type == WorldType.Editor)
visibleUnderShroud = _ => true;
else
visibleUnderShroud = map.Contains;
visibleUnderFog = map.Contains;
var shroudSheet = shroudSprites[0].Sheet;