Remove StateBase.AverageUnitsPosition.

This commit is contained in:
Paul Chote
2013-08-24 10:57:57 +12:00
parent 7ab0e00948
commit f6730a6740
3 changed files with 5 additions and 20 deletions

View File

@@ -11,6 +11,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using OpenRA.FileFormats;
using OpenRA.Traits;
using XRandom = OpenRA.Thirdparty.Random;
@@ -78,5 +79,7 @@ namespace OpenRA.Mods.RA.AI
get { return (target != null && !target.IsDead() && !target.Destroyed
&& target.IsInWorld && !target.HasTrait<Husk>()); }
}
public WPos CenterPosition { get { return units.Select(u => u.CenterPosition).Average(); } }
}
}

View File

@@ -32,9 +32,7 @@ namespace OpenRA.Mods.RA.AI
if (!owner.TargetIsValid)
{
var circaPostion = AverageUnitsPosition(owner.units);
if (circaPostion == null) return;
owner.Target = owner.bot.FindClosestEnemy(circaPostion.Value.CenterPosition, WRange.FromCells(8));
owner.Target = owner.bot.FindClosestEnemy(owner.CenterPosition, WRange.FromCells(8));
if (owner.Target == null)
{
@@ -42,6 +40,7 @@ namespace OpenRA.Mods.RA.AI
return;
}
}
foreach (var a in owner.units)
owner.world.IssueOrder(new Order("AttackMove", a, false) { TargetLocation = owner.Target.Location });
}

View File

@@ -21,23 +21,6 @@ namespace OpenRA.Mods.RA.AI
{
protected const int DangerRadius = 10;
protected static CPos? AverageUnitsPosition(List<Actor> units)
{
int x = 0;
int y = 0;
int countUnits = 0;
foreach (var u in units)
{
x += u.Location.X;
y += u.Location.Y;
countUnits++;
}
x = x / countUnits;
y = y / countUnits;
return (x != 0 && y != 0) ? new CPos?(new CPos(x, y)) : null;
}
protected static void GoToRandomOwnBuilding(Squad squad)
{
var loc = RandomBuildingLocation(squad);