Refactor int -> TerrainType. This had a bigger footprint than i initially intended.
This commit is contained in:
@@ -23,6 +23,7 @@ using System.Linq;
|
||||
using OpenRA.Effects;
|
||||
using OpenRA.GameRules;
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.FileFormats;
|
||||
|
||||
namespace OpenRA
|
||||
{
|
||||
@@ -41,7 +42,7 @@ namespace OpenRA
|
||||
|
||||
var targetTile = ((1f / Game.CellSize) * loc.ToFloat2()).ToInt2();
|
||||
|
||||
var isWater = (Game.world.GetTerrainType(targetTile) == TerrainMovementType.Water);
|
||||
var isWater = (Game.world.GetTerrainType(targetTile) == TerrainType.Water);
|
||||
|
||||
if (warhead.Explosion != 0)
|
||||
world.AddFrameEndTask(
|
||||
|
||||
@@ -120,7 +120,7 @@ namespace OpenRA.Graphics
|
||||
for (var y = world.Map.YOffset; y < world.Map.YOffset + world.Map.Height; y++)
|
||||
for (var x = world.Map.XOffset; x < world.Map.XOffset + world.Map.Width; x++)
|
||||
if (res.GetResource(new int2(x,y)) != null)
|
||||
oreLayer.SetPixel(x, y, Color.FromArgb(alpha, terrainTypeColors[world.Map.Theater].ColorForTerrainType((int)TerrainMovementType.Ore)));
|
||||
oreLayer.SetPixel(x, y, Color.FromArgb(alpha, terrainTypeColors[world.Map.Theater].ColorForTerrainType(TerrainType.Ore)));
|
||||
}
|
||||
|
||||
mapOnlySheet.Texture.SetData(oreLayer);
|
||||
@@ -151,7 +151,7 @@ namespace OpenRA.Graphics
|
||||
var b = world.WorldActor.traits.Get<BuildingInfluence>().GetBuildingAt(new int2(x, y));
|
||||
if (b != null)
|
||||
*(c + (y * bitmapData.Stride >> 2) + x) =
|
||||
(b.Owner != null ? Color.FromArgb(alpha, b.Owner.Color) : Color.FromArgb(alpha, terrainTypeColors[world.Map.Theater].ColorForTerrainType(4))).ToArgb();
|
||||
(b.Owner != null ? Color.FromArgb(alpha, b.Owner.Color) : Color.FromArgb(alpha, terrainTypeColors[world.Map.Theater].ColorForTerrainType(TerrainType.Tree))).ToArgb();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#endregion
|
||||
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.FileFormats;
|
||||
|
||||
namespace OpenRA
|
||||
{
|
||||
@@ -31,21 +32,6 @@ namespace OpenRA
|
||||
Fly = 4,
|
||||
}
|
||||
|
||||
public enum TerrainMovementType : byte
|
||||
{
|
||||
Clear = 0,
|
||||
Water = 1,
|
||||
Road = 2,
|
||||
Rock = 3,
|
||||
//Tree = 4,
|
||||
River = 5,
|
||||
Rough = 6,
|
||||
Wall = 7,
|
||||
Beach = 8,
|
||||
Ore = 9,
|
||||
Special = 10,
|
||||
}
|
||||
|
||||
static class TerrainCosts
|
||||
{
|
||||
static float[][] costs = Util.MakeArray<float[]>(4,
|
||||
@@ -57,7 +43,7 @@ namespace OpenRA
|
||||
for( int i = 0 ; i < 11 ; i++ )
|
||||
{
|
||||
if( i == 4 ) continue;
|
||||
var section = Rules.AllRules.GetSection( ( (TerrainMovementType)i ).ToString() );
|
||||
var section = Rules.AllRules.GetSection( ( (TerrainType)i ).ToString() );
|
||||
for( int j = 0 ; j < 4 ; j++ )
|
||||
{
|
||||
string val = section.GetValue( ( (UnitMovementType)j ).ToString(), "0%" );
|
||||
@@ -67,14 +53,14 @@ namespace OpenRA
|
||||
}
|
||||
}
|
||||
|
||||
public static bool Buildable(int r)
|
||||
public static bool Buildable(TerrainType r)
|
||||
{
|
||||
return buildable[r];
|
||||
return buildable[(int)r];
|
||||
}
|
||||
|
||||
public static float Cost( UnitMovementType unitMovementType, int r )
|
||||
public static float Cost( UnitMovementType unitMovementType, TerrainType r )
|
||||
{
|
||||
return costs[ (byte)unitMovementType ][ r ];
|
||||
return costs[ (byte)unitMovementType ][ (int)r ];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace OpenRA.Traits
|
||||
this.self = self;
|
||||
self.World.WorldActor.traits.Get<UnitInfluence>().Add(self, this);
|
||||
|
||||
if (self.World.GetTerrainType(self.Location) == TerrainMovementType.Water)
|
||||
if (self.World.GetTerrainType(self.Location) == TerrainType.Water)
|
||||
self.traits.Get<RenderSimple>().anim.PlayRepeating("water");
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace OpenRA
|
||||
if (world.WorldActor.traits.Get<UnitInfluence>().GetUnitsAt(a).Any(b => b != toIgnore)) return false;
|
||||
|
||||
if (waterBound)
|
||||
return world.Map.IsInMap(a.X,a.Y) && GetTerrainType(world,a) == TerrainMovementType.Water;
|
||||
return world.Map.IsInMap(a.X,a.Y) && GetTerrainType(world,a) == TerrainType.Water;
|
||||
|
||||
return world.Map.IsInMap(a.X, a.Y) && TerrainCosts.Buildable(world.TileSet.GetTerrainType(world.Map.MapTiles[a.X, a.Y]));
|
||||
}
|
||||
@@ -129,9 +129,9 @@ namespace OpenRA
|
||||
.FirstOrDefault();
|
||||
}
|
||||
|
||||
public static TerrainMovementType GetTerrainType(this World world, int2 cell)
|
||||
public static TerrainType GetTerrainType(this World world, int2 cell)
|
||||
{
|
||||
return (TerrainMovementType)world.TileSet.GetTerrainType(world.Map.MapTiles[cell.X, cell.Y]);
|
||||
return (TerrainType)world.TileSet.GetTerrainType(world.Map.MapTiles[cell.X, cell.Y]);
|
||||
}
|
||||
|
||||
public static bool CanPlaceBuilding(this World world, string name, BuildingInfo building, int2 topLeft, Actor toIgnore)
|
||||
|
||||
Reference in New Issue
Block a user