Move GetTerrainIndex/Info from WorldUtils to Map

This commit is contained in:
Pavlos Touboulidis
2014-06-13 13:57:32 +03:00
parent 0cf2d608e4
commit c282fa1077
20 changed files with 43 additions and 39 deletions

View File

@@ -48,17 +48,19 @@ namespace OpenRA.Mods.RA.Buildings
public void AddedToWorld(Actor self)
{
var map = self.World.Map;
if (template.PickAny)
{
// Fill the footprint with random variants
foreach (var c in FootprintUtils.Tiles(self))
{
// Only place on allowed terrain types
if (!info.TerrainTypes.Contains(self.World.GetTerrainInfo(c).Type))
if (!info.TerrainTypes.Contains(map.GetTerrainInfo(c).Type))
continue;
// Don't place under other buildings or custom terrain
if (bi.GetBuildingAt(c) != self || self.World.Map.CustomTerrain[c.X, c.Y] != -1)
if (bi.GetBuildingAt(c) != self || map.CustomTerrain[c.X, c.Y] != -1)
continue;
var index = Game.CosmeticRandom.Next(template.TilesCount);
@@ -74,11 +76,11 @@ namespace OpenRA.Mods.RA.Buildings
var c = origin + new CVec(i % template.Size.X, i / template.Size.X);
// Only place on allowed terrain types
if (!info.TerrainTypes.Contains(self.World.GetTerrainInfo(c).Type))
if (!info.TerrainTypes.Contains(map.GetTerrainInfo(c).Type))
continue;
// Don't place under other buildings or custom terrain
if (bi.GetBuildingAt(c) != self || self.World.Map.CustomTerrain[c.X, c.Y] != -1)
if (bi.GetBuildingAt(c) != self || map.CustomTerrain[c.X, c.Y] != -1)
continue;
layer.AddTile(c, new TileReference<ushort, byte>(template.Id, (byte)i));