Move GetTerrainIndex/Info from WorldUtils to Map
This commit is contained in:
@@ -44,6 +44,7 @@ namespace OpenRA.Mods.RA.Buildings
|
||||
var centerOffset = FootprintUtils.CenterOffset(bi);
|
||||
var location = self.Location;
|
||||
var rows = info.HasMinibib ? 1 : 2;
|
||||
var map = self.World.Map;
|
||||
|
||||
for (var i = 0; i < rows * width; i++)
|
||||
{
|
||||
@@ -52,7 +53,7 @@ namespace OpenRA.Mods.RA.Buildings
|
||||
var cellOffset = new CVec(i % width, i / width + bibOffset);
|
||||
|
||||
// Some mods may define terrain-specific bibs
|
||||
var terrain = self.World.GetTerrainInfo(location + cellOffset).Type;
|
||||
var terrain = map.GetTerrainInfo(location + cellOffset).Type;
|
||||
var testSequence = info.Sequence + "-" + terrain;
|
||||
var sequence = anim.HasSequence(testSequence) ? testSequence : info.Sequence;
|
||||
anim.PlayFetchIndex(sequence, () => index);
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace OpenRA.Mods.RA.Buildings
|
||||
if (world.WorldActor.Trait<BuildingInfluence>().GetBuildingAt(a) != null) return false;
|
||||
if (world.ActorMap.GetUnitsAt(a).Any(b => b != toIgnore)) return false;
|
||||
|
||||
return world.Map.IsInMap(a) && bi.TerrainTypes.Contains(world.GetTerrainInfo(a).Type);
|
||||
return world.Map.IsInMap(a) && bi.TerrainTypes.Contains(world.Map.GetTerrainInfo(a).Type);
|
||||
}
|
||||
|
||||
public static bool CanPlaceBuilding(this World world, string name, BuildingInfo building, CPos topLeft, Actor toIgnore)
|
||||
|
||||
Reference in New Issue
Block a user