duplication, in my game?

This commit is contained in:
Chris Forbes
2010-03-17 14:57:21 +13:00
parent 5d4d5b0f4f
commit 128fe48592
2 changed files with 45 additions and 68 deletions

View File

@@ -21,7 +21,6 @@
using System.Collections.Generic;
using OpenRA.GameRules;
using OpenRA.Traits;
using System.Linq;
namespace OpenRA.Orders
{
@@ -63,37 +62,8 @@ namespace OpenRA.Orders
// Linebuild for walls.
// Assumes a 1x1 footprint; weird things will happen for other footprints
if (Rules.Info[ Building ].Traits.Contains<LineBuildInfo>())
{
int range = Rules.Info[ Building ].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, BuildingInfo.WaterBound ? UnitMovementType.Float : UnitMovementType.Wheel,null))
continue; // Cell is empty; continue search
// Cell contains an actor. Is it the type we want?
if (world.Queries.WithTrait<LineBuild>().Any(a => (a.Actor.Info.Name == Building && 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++)
yield return new Order("PlaceBuilding", Producer.Owner.PlayerActor, world.OffsetCell(topLeft,i,d), Building);
}
}
foreach( var t in LineBuildUtils.GetLineBuildCells( world, topLeft, Building, BuildingInfo ))
yield return new Order("PlaceBuilding", Producer.Owner.PlayerActor, t, Building);
}
}