Ore.cs is dead. Long live ResourceLayer.cs.

This commit is contained in:
Chris Forbes
2010-03-03 21:15:44 +13:00
parent 6c229f3273
commit 15b82830a2
8 changed files with 14 additions and 74 deletions

View File

@@ -64,12 +64,14 @@ namespace OpenRA.Traits.Activities
void FindMoreOre(Actor self)
{
var res = self.World.WorldActor.traits.Get<ResourceLayer>();
self.QueueActivity(new Move(
() =>
{
var search = new PathSearch
{
heuristic = loc => (self.World.Map.ContainsResource(loc) ? 0 : 1),
heuristic = loc => (res.GetResource(loc) != null ? 0 : 1),
umt = UnitMovementType.Wheel,
checkForBlocked = true
};

View File

@@ -71,7 +71,7 @@ namespace OpenRA.Traits
&& underCursor.traits.Contains<IAcceptOre>() && !IsEmpty)
return new Order("Deliver", self, underCursor);
if (underCursor == null && self.World.Map.ContainsResource(xy))
if (underCursor == null && self.World.WorldActor.traits.Get<ResourceLayer>().GetResource(xy) != null)
return new Order("Harvest", self, xy);
return null;

View File

@@ -35,7 +35,7 @@ namespace OpenRA.Traits
World w;
public ResourceTypeInfo[] resourceTypes;
public CellContents[,] content = new CellContents[128, 128];
CellContents[,] content = new CellContents[128, 128];
public ResourceLayer(Actor self)
{
@@ -185,6 +185,8 @@ namespace OpenRA.Traits
}
}
public ResourceTypeInfo GetResource(int2 p) { return content[p.X, p.Y].type; }
public struct CellContents
{
public ResourceTypeInfo type;