moving Map, TileSet from Rules to World

This commit is contained in:
Bob
2010-01-17 12:18:26 +13:00
parent fa421410fe
commit 1ec3ee60eb
19 changed files with 135 additions and 130 deletions

View File

@@ -36,8 +36,8 @@ namespace OpenRa.Traits.Activities
var renderUnit = self.traits.Get<RenderUnit>(); /* better have one of these! */
var isGem = false;
if (!Rules.Map.ContainsResource(self.Location) ||
!Rules.Map.Harvest(self.Location, out isGem))
if (!Game.world.Map.ContainsResource(self.Location) ||
!Game.world.Map.Harvest(self.Location, out isGem))
return false;
var harvestAnim = "harvest" + Util.QuantizeFacing(unit.Facing, 8);
@@ -58,7 +58,7 @@ namespace OpenRa.Traits.Activities
{
var search = new PathSearch
{
heuristic = loc => (Rules.Map.ContainsResource(loc) ? 0 : 1),
heuristic = loc => (Game.world.Map.ContainsResource(loc) ? 0 : 1),
umt = UnitMovementType.Wheel,
checkForBlocked = true
};

View File

@@ -66,9 +66,9 @@ namespace OpenRa.Traits
if (!crushable) return false;
return Rules.Map.IsInMap(a.X, a.Y) &&
return Game.world.Map.IsInMap(a.X, a.Y) &&
TerrainCosts.Cost(GetMovementType(),
Rules.TileSet.GetWalkability(Rules.Map.MapTiles[a.X, a.Y])) < double.PositiveInfinity;
Game.world.TileSet.GetWalkability(Game.world.Map.MapTiles[a.X, a.Y])) < double.PositiveInfinity;
}
}
}

View File

@@ -41,7 +41,7 @@ namespace OpenRa.Traits
&& underCursor.traits.Contains<AcceptsOre>() && !IsEmpty)
return new Order("Deliver", self, underCursor, int2.Zero, null);
if (underCursor == null && Rules.Map.ContainsResource(xy))
if (underCursor == null && Game.world.Map.ContainsResource(xy))
return new Order("Harvest", self, null, xy, null);
return null;

View File

@@ -106,9 +106,9 @@ namespace OpenRa.Traits
if (!crushable) return false;
return Rules.Map.IsInMap(a.X, a.Y) &&
return Game.world.Map.IsInMap(a.X, a.Y) &&
TerrainCosts.Cost(GetMovementType(),
Rules.TileSet.GetWalkability(Rules.Map.MapTiles[a.X, a.Y])) < double.PositiveInfinity;
Game.world.TileSet.GetWalkability(Game.world.Map.MapTiles[a.X, a.Y])) < double.PositiveInfinity;
}
public IEnumerable<int2> GetCurrentPath()

View File

@@ -45,11 +45,11 @@ namespace OpenRa.Traits
var p = self.Location + new int2(i % size, i / size + bibOffset);
if (isRemove)
{
if (Rules.Map.MapTiles[p.X, p.Y].smudge == (byte)(i + startIndex))
Rules.Map.MapTiles[ p.X, p.Y ].smudge = 0;
if (Game.world.Map.MapTiles[p.X, p.Y].smudge == (byte)(i + startIndex))
Game.world.Map.MapTiles[ p.X, p.Y ].smudge = 0;
}
else
Rules.Map.MapTiles[p.X, p.Y].smudge = (byte)(i + startIndex);
Game.world.Map.MapTiles[p.X, p.Y].smudge = (byte)(i + startIndex);
}
}
}

View File

@@ -23,7 +23,7 @@ namespace OpenRa.Traits
for (var i = -1; i < 2; i++)
if (Game.SharedRandom.NextDouble() < info.Chance)
if (Ore.CanSpreadInto(self.Location.X + i, self.Location.Y + j))
Rules.Map.AddOre(self.Location.X + i, self.Location.Y + j);
Game.world.Map.AddOre(self.Location.X + i, self.Location.Y + j);
ticks = info.Interval;
}