Minor cosmetic cleanups for Harvester and BasePathSearch
This commit is contained in:
@@ -105,7 +105,7 @@ namespace OpenRA.Mods.Common.Pathfinder
|
|||||||
|
|
||||||
public abstract IEnumerable<Pair<CPos, int>> Considered { get; }
|
public abstract IEnumerable<Pair<CPos, int>> Considered { get; }
|
||||||
|
|
||||||
public Player Owner { get { return this.Graph.Actor.Owner; } }
|
public Player Owner { get { return Graph.Actor.Owner; } }
|
||||||
public int MaxCost { get; protected set; }
|
public int MaxCost { get; protected set; }
|
||||||
public bool Debug { get; set; }
|
public bool Debug { get; set; }
|
||||||
string id;
|
string id;
|
||||||
@@ -184,7 +184,7 @@ namespace OpenRA.Mods.Common.Pathfinder
|
|||||||
|
|
||||||
public IPathSearch FromPoint(CPos from)
|
public IPathSearch FromPoint(CPos from)
|
||||||
{
|
{
|
||||||
if (this.Graph.World.Map.Contains(from))
|
if (Graph.World.Map.Contains(from))
|
||||||
AddInitialCell(from);
|
AddInitialCell(from);
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
info.DeliveryBuildings.Contains(proc.Info.Name);
|
info.DeliveryBuildings.Contains(proc.Info.Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
Actor ClosestProc(Actor self, Actor ignore)
|
public Actor ClosestProc(Actor self, Actor ignore)
|
||||||
{
|
{
|
||||||
// Find all refineries and their occupancy count:
|
// Find all refineries and their occupancy count:
|
||||||
var refs = (
|
var refs = (
|
||||||
@@ -155,14 +155,16 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
var mi = self.Info.Traits.Get<MobileInfo>();
|
var mi = self.Info.Traits.Get<MobileInfo>();
|
||||||
var path = self.World.WorldActor.Trait<IPathFinder>().FindPath(
|
var path = self.World.WorldActor.Trait<IPathFinder>().FindPath(
|
||||||
PathSearch.FromPoints(self.World, mi, self, refs.Values.Select(r => r.Location), self.Location, false)
|
PathSearch.FromPoints(self.World, mi, self, refs.Values.Select(r => r.Location), self.Location, false)
|
||||||
.WithCustomCost((loc) =>
|
.WithCustomCost(loc =>
|
||||||
{
|
{
|
||||||
if (!refs.ContainsKey(loc)) return 0;
|
if (!refs.ContainsKey(loc))
|
||||||
|
return 0;
|
||||||
|
|
||||||
var occupancy = refs[loc].Occupancy;
|
var occupancy = refs[loc].Occupancy;
|
||||||
|
|
||||||
// 4 harvesters clogs up the refinery's delivery location:
|
// 4 harvesters clogs up the refinery's delivery location:
|
||||||
if (occupancy >= 3) return int.MaxValue;
|
if (occupancy >= 3)
|
||||||
|
return int.MaxValue;
|
||||||
|
|
||||||
// Prefer refineries with less occupancy (multiplier is to offset distance cost):
|
// Prefer refineries with less occupancy (multiplier is to offset distance cost):
|
||||||
return occupancy * 12;
|
return occupancy * 12;
|
||||||
@@ -199,7 +201,8 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
self.SetTargetLine(Target.FromCell(self.World, moveTo), Color.Gray, false);
|
self.SetTargetLine(Target.FromCell(self.World, moveTo), Color.Gray, false);
|
||||||
|
|
||||||
var territory = self.World.WorldActor.TraitOrDefault<ResourceClaimLayer>();
|
var territory = self.World.WorldActor.TraitOrDefault<ResourceClaimLayer>();
|
||||||
if (territory != null) territory.ClaimResource(self, moveTo);
|
if (territory != null)
|
||||||
|
territory.ClaimResource(self, moveTo);
|
||||||
|
|
||||||
var notify = self.TraitsImplementing<INotifyHarvesterAction>();
|
var notify = self.TraitsImplementing<INotifyHarvesterAction>();
|
||||||
var next = new FindResources(self);
|
var next = new FindResources(self);
|
||||||
@@ -422,9 +425,9 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
if (!harvInfo.Resources.Contains(resType.Info.Name))
|
if (!harvInfo.Resources.Contains(resType.Info.Name))
|
||||||
return Constants.CellCost;
|
return Constants.CellCost;
|
||||||
|
|
||||||
// Another harvester has claimed this resource:
|
|
||||||
if (territory != null)
|
if (territory != null)
|
||||||
{
|
{
|
||||||
|
// Another harvester has claimed this resource:
|
||||||
ResourceClaim claim;
|
ResourceClaim claim;
|
||||||
if (territory.IsClaimedByAnyoneElse(self, loc, out claim))
|
if (territory.IsClaimedByAnyoneElse(self, loc, out claim))
|
||||||
return Constants.CellCost;
|
return Constants.CellCost;
|
||||||
|
|||||||
Reference in New Issue
Block a user