Add "Build off Ally ConYards" option. Fixes #2464.

This commit is contained in:
Paul Chote
2013-08-17 12:28:40 +12:00
parent 059c88ca1b
commit ce41eb2361
25 changed files with 81 additions and 6 deletions

View File

@@ -56,11 +56,17 @@ namespace OpenRA.Mods.RA.Buildings
return devMode.FastBuild || progress == 0;
}
bool ValidRenderPlayer()
{
var allyBuildRadius = self.World.LobbyInfo.GlobalSettings.AllyBuildRadius;
return self.Owner == self.World.RenderPlayer || (allyBuildRadius && self.Owner.IsAlliedWith(self.World.RenderPlayer));
}
// Range circle
public void RenderAfterWorld(WorldRenderer wr)
{
// Visible to player and allies
if (!self.Owner.IsAlliedWith(self.World.RenderPlayer))
if (!ValidRenderPlayer())
return;
wr.DrawRangeCircleWithContrast(
@@ -73,7 +79,7 @@ namespace OpenRA.Mods.RA.Buildings
public float GetValue()
{
// Visible to player and allies
if (!self.Owner.IsAlliedWith(self.World.RenderPlayer))
if (!ValidRenderPlayer())
return 0f;
// Ready or delay disabled

View File

@@ -43,7 +43,8 @@ namespace OpenRA.Mods.RA.Buildings
var center = topLeft.CenterPosition + FootprintUtils.CenterOffset(this);
foreach (var bp in world.ActorsWithTrait<BaseProvider>())
{
if (bp.Actor.Owner.Stances[p] != Stance.Ally || !bp.Trait.Ready())
var validOwner = bp.Actor.Owner == p || (world.LobbyInfo.GlobalSettings.AllyBuildRadius && bp.Actor.Owner.Stances[p] == Stance.Ally);
if (!validOwner || !bp.Trait.Ready())
continue;
// Range is counted from the center of the actor, not from each cell.
@@ -72,14 +73,21 @@ namespace OpenRA.Mods.RA.Buildings
var nearnessCandidates = new List<CPos>();
var bi = world.WorldActor.Trait<BuildingInfluence>();
var allyBuildRadius = world.LobbyInfo.GlobalSettings.AllyBuildRadius;
for (var y = scanStart.Y; y < scanEnd.Y; y++)
{
for (var x = scanStart.X; x < scanEnd.X; x++)
{
var at = bi.GetBuildingAt(new CPos(x, y));
if (at != null && at.Owner.Stances[p] == Stance.Ally && at.HasTrait<GivesBuildableArea>())
nearnessCandidates.Add(new CPos(x, y));
var pos = new CPos(x, y);
var at = bi.GetBuildingAt(pos);
if (at == null || !at.HasTrait<GivesBuildableArea>())
continue;
if (at.Owner == p || (allyBuildRadius && at.Owner.Stances[p] == Stance.Ally))
nearnessCandidates.Add(pos);
}
}
var buildingTiles = FootprintUtils.Tiles(buildingName, this, topLeft).ToList();
return nearnessCandidates