removed "adjust" param to Tiles; position is now top-left always.
This commit is contained in:
@@ -24,7 +24,7 @@ namespace OpenRa
|
|||||||
if( IsValid( u ) )
|
if( IsValid( u ) )
|
||||||
blocked[ u.X, u.Y ] = isAdd;
|
blocked[ u.X, u.Y ] = isAdd;
|
||||||
|
|
||||||
foreach( var u in Footprint.Tiles( a.Info.Name, a.Info.Traits.Get<BuildingInfo>(), a.Location, false ) )
|
foreach( var u in Footprint.Tiles( a.Info.Name, a.Info.Traits.Get<BuildingInfo>(), a.Location ) )
|
||||||
if( IsValid( u ) )
|
if( IsValid( u ) )
|
||||||
influence[ u.X, u.Y ] = isAdd ? a : null;
|
influence[ u.X, u.Y ] = isAdd ? a : null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ namespace OpenRa.GameRules
|
|||||||
{
|
{
|
||||||
static class Footprint
|
static class Footprint
|
||||||
{
|
{
|
||||||
public static IEnumerable<int2> Tiles( string name, BuildingInfo buildingInfo, int2 position, bool adjustForPlacement )
|
public static IEnumerable<int2> Tiles( string name, BuildingInfo buildingInfo, int2 position )
|
||||||
{
|
{
|
||||||
var dim = buildingInfo.Dimensions;
|
var dim = buildingInfo.Dimensions;
|
||||||
|
|
||||||
@@ -18,15 +18,12 @@ namespace OpenRa.GameRules
|
|||||||
footprint = footprint.Concat(new char[dim.X]);
|
footprint = footprint.Concat(new char[dim.X]);
|
||||||
}
|
}
|
||||||
|
|
||||||
var adjustment = adjustForPlacement ? AdjustForBuildingSize(buildingInfo) : int2.Zero;
|
return TilesWhere( name, dim, footprint.ToArray(), a => a != '_' ).Select( t => t + position );
|
||||||
|
|
||||||
var tiles = TilesWhere(name, dim, footprint.ToArray(), a => a != '_');
|
|
||||||
return tiles.Select(t => t + position - adjustment);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IEnumerable<int2> Tiles(Actor a, Traits.Building building)
|
public static IEnumerable<int2> Tiles(Actor a, Traits.Building building)
|
||||||
{
|
{
|
||||||
return Tiles( a.Info.Name, a.Info.Traits.Get<BuildingInfo>(), a.Location, false );
|
return Tiles( a.Info.Name, a.Info.Traits.Get<BuildingInfo>(), a.Location );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IEnumerable<int2> UnpathableTiles( string name, BuildingInfo buildingInfo, int2 position )
|
public static IEnumerable<int2> UnpathableTiles( string name, BuildingInfo buildingInfo, int2 position )
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ namespace OpenRa
|
|||||||
var topLeft = position - Footprint.AdjustForBuildingSize( bi );
|
var topLeft = position - Footprint.AdjustForBuildingSize( bi );
|
||||||
var isCloseEnough = Game.world.IsCloseEnoughToBase(Game.LocalPlayer, name, bi, position);
|
var isCloseEnough = Game.world.IsCloseEnoughToBase(Game.LocalPlayer, name, bi, position);
|
||||||
|
|
||||||
foreach( var t in Footprint.Tiles( name, bi, topLeft, false ) )
|
foreach( var t in Footprint.Tiles( name, bi, topLeft ) )
|
||||||
spriteRenderer.DrawSprite( ( isCloseEnough && Game.world.IsCellBuildable( t, bi.WaterBound
|
spriteRenderer.DrawSprite( ( isCloseEnough && Game.world.IsCellBuildable( t, bi.WaterBound
|
||||||
? UnitMovementType.Float : UnitMovementType.Wheel ) && !Game.world.Map.ContainsResource( t ) )
|
? UnitMovementType.Float : UnitMovementType.Wheel ) && !Game.world.Map.ContainsResource( t ) )
|
||||||
? buildOk : buildBlocked, Game.CellSize * t, 0 );
|
? buildOk : buildBlocked, Game.CellSize * t, 0 );
|
||||||
|
|||||||
@@ -101,7 +101,8 @@ namespace OpenRa
|
|||||||
|
|
||||||
public static bool CanPlaceBuilding(this World world, string name, BuildingInfo building, int2 xy, Actor toIgnore, bool adjust)
|
public static bool CanPlaceBuilding(this World world, string name, BuildingInfo building, int2 xy, Actor toIgnore, bool adjust)
|
||||||
{
|
{
|
||||||
return !Footprint.Tiles(name, building, xy, adjust).Any(
|
var topLeft = adjust ? xy - Footprint.AdjustForBuildingSize( building ) : xy;
|
||||||
|
return !Footprint.Tiles(name, building, topLeft).Any(
|
||||||
t => !world.Map.IsInMap(t.X, t.Y) || world.Map.ContainsResource(t) || !world.IsCellBuildable(t,
|
t => !world.Map.IsInMap(t.X, t.Y) || world.Map.ContainsResource(t) || !world.IsCellBuildable(t,
|
||||||
building.WaterBound ? UnitMovementType.Float : UnitMovementType.Wheel,
|
building.WaterBound ? UnitMovementType.Float : UnitMovementType.Wheel,
|
||||||
toIgnore));
|
toIgnore));
|
||||||
@@ -126,7 +127,7 @@ namespace OpenRa
|
|||||||
};
|
};
|
||||||
|
|
||||||
var topLeft = position - Footprint.AdjustForBuildingSize( bi );
|
var topLeft = position - Footprint.AdjustForBuildingSize( bi );
|
||||||
foreach (var t in Footprint.Tiles(buildingName, bi, topLeft, false)) search.AddInitialCell(t);
|
foreach (var t in Footprint.Tiles(buildingName, bi, topLeft)) search.AddInitialCell(t);
|
||||||
|
|
||||||
return world.PathFinder.FindPath(search).Count != 0;
|
return world.PathFinder.FindPath(search).Count != 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user