pre-explore a little bit around the mcv at start

This commit is contained in:
Chris Forbes
2010-03-30 18:26:52 +13:00
parent ef761abd94
commit a71ba665a7
2 changed files with 18 additions and 1 deletions

View File

@@ -114,5 +114,15 @@ namespace OpenRA.Traits
if (a.Owner == null || a.Owner != a.Owner.World.LocalPlayer) return;
RemoveActor(a); AddActor(a);
}
public void Explore(World world, int2 center, int range)
{
foreach (var q in world.FindTilesInCircle(center, range))
exploredCells[q.X, q.Y] = true;
var box = new Rectangle(center.X - range, center.Y - range, 2 * range + 1, 2 * range + 1);
exploredBounds = exploredBounds.HasValue ?
Rectangle.Union(exploredBounds.Value, box) : box;
}
}
}

View File

@@ -25,7 +25,10 @@ using OpenRA.FileFormats;
namespace OpenRA.Traits
{
class SpawnDefaultUnitsInfo : StatelessTraitInfo<SpawnDefaultUnits> { }
class SpawnDefaultUnitsInfo : StatelessTraitInfo<SpawnDefaultUnits>
{
public readonly int InitialExploreRange = 5;
}
class SpawnDefaultUnits : IGameStarted
{
@@ -48,6 +51,10 @@ namespace OpenRA.Traits
void SpawnUnitsForPlayer(Player p, int2 sp)
{
p.World.CreateActor("mcv", sp, p);
if (p == p.World.LocalPlayer)
p.World.WorldActor.traits.Get<Shroud>().Explore( p.World, sp,
p.World.WorldActor.Info.Traits.Get<SpawnDefaultUnitsInfo>().InitialExploreRange);
}
static int2 ChooseSpawnPoint(World world, List<int2> available, List<int2> taken)