Linebuild walls
This commit is contained in:
@@ -72,7 +72,46 @@ namespace OpenRA
|
||||
spriteRenderer.DrawSprite( ( isCloseEnough && world.IsCellBuildable( t, bi.WaterBound
|
||||
? UnitMovementType.Float : UnitMovementType.Wheel ) && !world.Map.ContainsResource( t ) )
|
||||
? buildOk : buildBlocked, Game.CellSize * t, "terrain" );
|
||||
|
||||
// Linebuild for walls.
|
||||
// Assumes a 1x1 footprint; weird things will happen for other footprints
|
||||
if (Rules.Info[ name ].Traits.Contains<LineBuildInfo>())
|
||||
{
|
||||
int range = Rules.Info[ name ].Traits.Get<LineBuildInfo>().Range;
|
||||
|
||||
// Start at place location, search outwards
|
||||
// TODO: First make it work, then make it nice
|
||||
int[] dirs = {0,0,0,0};
|
||||
for (int d = 0; d < 4; d++)
|
||||
{
|
||||
for (int i = 1; i < range; i++)
|
||||
{
|
||||
if (dirs[d] != 0)
|
||||
continue;
|
||||
|
||||
int2 cell = world.OffsetCell(topLeft,i,d);
|
||||
|
||||
if (world.IsCellBuildable(cell, bi.WaterBound ? UnitMovementType.Float : UnitMovementType.Wheel,null))
|
||||
continue; // Cell is empty; continue search
|
||||
|
||||
// Cell contains an actor. Is it the type we want?
|
||||
if (Game.world.Queries.WithTrait<LineBuild>().Any(a => (a.Actor.Info.Name == name && a.Actor.Location.X == cell.X && a.Actor.Location.Y == cell.Y)))
|
||||
dirs[d] = i; // Cell contains actor of correct type
|
||||
else
|
||||
dirs[d] = -1; // Cell is blocked by another actor type
|
||||
}
|
||||
|
||||
// Place intermediate-line sections
|
||||
if (dirs[d] > 0)
|
||||
{
|
||||
for (int i = 1; i < dirs[d]; i++)
|
||||
{
|
||||
int2 cell = world.OffsetCell(topLeft,i,d);
|
||||
spriteRenderer.DrawSprite( world.IsCloseEnoughToBase(world.LocalPlayer, name, bi, cell) ? buildOk : buildBlocked, Game.CellSize * cell, "terrain" );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
spriteRenderer.Flush();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user