Remove StateBase.AverageUnitsPosition.
This commit is contained in:
@@ -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(); } }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 });
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user