From 1ec3ee60eb883d9f3cb3786d37ac06b00bf43fac Mon Sep 17 00:00:00 2001 From: Bob Date: Sun, 17 Jan 2010 12:18:26 +1300 Subject: [PATCH] moving Map, TileSet from Rules to World --- OpenRa.Game/Actor.cs | 2 +- OpenRa.Game/Game.cs | 21 ++-- OpenRa.Game/GameRules/Rules.cs | 5 - OpenRa.Game/Graphics/Minimap.cs | 22 ++-- OpenRa.Game/Graphics/TerrainRenderer.cs | 148 +++++++++++------------ OpenRa.Game/Graphics/WorldRenderer.cs | 2 +- OpenRa.Game/Ore.cs | 8 +- OpenRa.Game/PathFinder.cs | 4 +- OpenRa.Game/PathSearch.cs | 6 +- OpenRa.Game/Smudge.cs | 6 +- OpenRa.Game/Traits/Activities/Harvest.cs | 6 +- OpenRa.Game/Traits/ConstructionYard.cs | 4 +- OpenRa.Game/Traits/Harvester.cs | 2 +- OpenRa.Game/Traits/Mobile.cs | 4 +- OpenRa.Game/Traits/RenderBuilding.cs | 6 +- OpenRa.Game/Traits/SeedsOre.cs | 2 +- OpenRa.Game/UiOverlay.cs | 2 +- OpenRa.Game/World.cs | 11 ++ OpenRa.sln | 4 +- 19 files changed, 135 insertions(+), 130 deletions(-) diff --git a/OpenRa.Game/Actor.cs b/OpenRa.Game/Actor.cs index 31fbf5bf7c..03a6b689ad 100755 --- a/OpenRa.Game/Actor.cs +++ b/OpenRa.Game/Actor.cs @@ -85,7 +85,7 @@ namespace OpenRa if (Owner != Game.LocalPlayer) return null; - if (!Rules.Map.IsInMap(xy.X, xy.Y)) + if (!Game.world.Map.IsInMap(xy.X, xy.Y)) return null; var loc = mi.Location + Game.viewport.Location; diff --git a/OpenRa.Game/Game.cs b/OpenRa.Game/Game.cs index 430b755e2b..c9c6e3d920 100644 --- a/OpenRa.Game/Game.cs +++ b/OpenRa.Game/Game.cs @@ -64,7 +64,6 @@ namespace OpenRa SpriteSheetBuilder.Initialize(); FileSystem.UnmountTemporaryPackages(); Rules.LoadRules(mapName, usingAftermath); - palette = new HardwarePalette(renderer, Rules.Map); world = new World(); Game.world.ActorAdded += a => @@ -73,6 +72,8 @@ namespace OpenRa a.Owner.Shroud.Explore(a); }; + palette = new HardwarePalette(renderer, world.Map); + var worldActor = new Actor("World", new int2(int.MaxValue, int.MaxValue), null); Game.world.Add(worldActor); @@ -83,11 +84,11 @@ namespace OpenRa players[i] = new Player(i, LobbyInfo.Clients.FirstOrDefault(a => a.Index == i)); } - Rules.Map.InitOreDensity(); + Game.world.Map.InitOreDensity(); worldRenderer = new WorldRenderer(renderer); SequenceProvider.Initialize(usingAftermath); - viewport = new Viewport(clientSize, Rules.Map.Offset, Rules.Map.Offset + Rules.Map.Size, renderer); + viewport = new Viewport(clientSize, Game.world.Map.Offset, Game.world.Map.Offset + Game.world.Map.Size, renderer); minimap = new Minimap(renderer); @@ -95,7 +96,7 @@ namespace OpenRa UnitInfluence = new UnitInfluenceMap(); skipMakeAnims = true; - foreach (var treeReference in Rules.Map.Trees) + foreach (var treeReference in Game.world.Map.Trees) world.Add(new Actor(treeReference.Image, new int2(treeReference.Location), null)); LoadMapActors(Rules.AllRules); @@ -202,7 +203,7 @@ namespace OpenRa if (--oreTicks == 0) using (new PerfSample("ore")) { - Rules.Map.GrowOre(SharedRandom); + Game.world.Map.GrowOre(SharedRandom); minimap.InvalidateOre(); oreTicks = oreFrequency; } @@ -250,9 +251,9 @@ namespace OpenRa if (BuildingInfluence.GetBuildingAt(a) != null) return false; if (UnitInfluence.GetUnitsAt(a).Any(b => b != toIgnore)) return false; - return Rules.Map.IsInMap(a.X, a.Y) && + return Game.world.Map.IsInMap(a.X, a.Y) && TerrainCosts.Cost(umt, - 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 static bool IsActorCrushableByActor(Actor a, Actor b) @@ -276,9 +277,9 @@ namespace OpenRa public static bool IsWater(int2 a) { - return Rules.Map.IsInMap(a.X, a.Y) && + return Game.world.Map.IsInMap(a.X, a.Y) && TerrainCosts.Cost(UnitMovementType.Float, - 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 static IEnumerable FindUnits(float2 a, float2 b) @@ -336,7 +337,7 @@ namespace OpenRa public static bool CanPlaceBuilding(string name, BuildingInfo building, int2 xy, Actor toIgnore, bool adjust) { return !Footprint.Tiles(name, building, xy, adjust).Any( - t => !Rules.Map.IsInMap(t.X, t.Y) || Rules.Map.ContainsResource(t) || !Game.IsCellBuildable(t, + t => !Game.world.Map.IsInMap(t.X, t.Y) || Game.world.Map.ContainsResource(t) || !Game.IsCellBuildable(t, building.WaterBound ? UnitMovementType.Float : UnitMovementType.Wheel, toIgnore)); } diff --git a/OpenRa.Game/GameRules/Rules.cs b/OpenRa.Game/GameRules/Rules.cs index f69e58c1e8..a682475293 100755 --- a/OpenRa.Game/GameRules/Rules.cs +++ b/OpenRa.Game/GameRules/Rules.cs @@ -19,8 +19,6 @@ namespace OpenRa public static GeneralInfo General; public static AftermathInfo Aftermath; public static TechTree TechTree; - public static Map Map; - public static TileSet TileSet; public static Dictionary ActorInfo; @@ -75,9 +73,6 @@ namespace OpenRa ActorInfo.Add(kv.Key.ToLowerInvariant(), new ActorInfo(kv.Key.ToLowerInvariant(), kv.Value, yamlRules)); TechTree = new TechTree(); - Map = new Map( AllRules ); - FileSystem.MountTemporary( new Package( Rules.Map.Theater + ".mix" ) ); - TileSet = new TileSet( Map.TileSuffix ); } static void LoadCategories(params string[] types) diff --git a/OpenRa.Game/Graphics/Minimap.cs b/OpenRa.Game/Graphics/Minimap.cs index 5aa0828398..a4b7501b9d 100644 --- a/OpenRa.Game/Graphics/Minimap.cs +++ b/OpenRa.Game/Graphics/Minimap.cs @@ -23,12 +23,12 @@ namespace OpenRa.Graphics mapOnlySheet = new Sheet(r, new Size(128, 128)); rgbaRenderer = new SpriteRenderer(r, true, r.RgbaSpriteShader); - var size = Math.Max(Rules.Map.Width, Rules.Map.Height); - var dw = (size - Rules.Map.Width) / 2; - var dh = (size - Rules.Map.Height) / 2; + var size = Math.Max(Game.world.Map.Width, Game.world.Map.Height); + var dw = (size - Game.world.Map.Width) / 2; + var dh = (size - Game.world.Map.Height) / 2; - sprite = new Sprite(sheet, new Rectangle(Rules.Map.Offset.X+dw, Rules.Map.Offset.Y+dh, size, size), TextureChannel.Alpha); - mapOnlySprite = new Sprite(mapOnlySheet, new Rectangle(Rules.Map.Offset.X + dw, Rules.Map.Offset.Y + dh, size, size), TextureChannel.Alpha); + sprite = new Sprite(sheet, new Rectangle(Game.world.Map.Offset.X+dw, Game.world.Map.Offset.Y+dh, size, size), TextureChannel.Alpha); + mapOnlySprite = new Sprite(mapOnlySheet, new Rectangle(Game.world.Map.Offset.X + dw, Game.world.Map.Offset.Y + dh, size, size), TextureChannel.Alpha); } Color[] terrainTypeColors; @@ -40,15 +40,15 @@ namespace OpenRa.Graphics public void Update() { - if (Rules.Map.Theater != theater) + if (Game.world.Map.Theater != theater) { terrainTypeColors = null; - theater = Rules.Map.Theater; + theater = Game.world.Map.Theater; } if (terrainTypeColors == null) { - var pal = new Palette(FileSystem.Open(Rules.Map.Theater + ".pal")); + var pal = new Palette(FileSystem.Open(Game.world.Map.Theater + ".pal")); terrainTypeColors = new[] { Color.FromArgb(alpha, pal.GetColor(theater.ToLowerInvariant() == "snow" ? 0xe3 :0x1a)), Color.FromArgb(alpha, pal.GetColor(0x63)), @@ -71,8 +71,8 @@ namespace OpenRa.Graphics terrain = new Bitmap(128, 128); for (var y = 0; y < 128; y++) for (var x = 0; x < 128; x++) - terrain.SetPixel(x, y, Rules.Map.IsInMap(x, y) - ? terrainTypeColors[Rules.TileSet.GetWalkability(Rules.Map.MapTiles[x, y])] + terrain.SetPixel(x, y, Game.world.Map.IsInMap(x, y) + ? terrainTypeColors[Game.world.TileSet.GetWalkability(Game.world.Map.MapTiles[x, y])] : shroudColor); } @@ -81,7 +81,7 @@ namespace OpenRa.Graphics oreLayer = new Bitmap(terrain); for (var y = 0; y < 128; y++) for (var x = 0; x < 128; x++) - if (Rules.Map.ContainsResource(new int2(x, y))) + if (Game.world.Map.ContainsResource(new int2(x, y))) oreLayer.SetPixel(x, y, terrainTypeColors[(int)TerrainMovementType.Ore]); } diff --git a/OpenRa.Game/Graphics/TerrainRenderer.cs b/OpenRa.Game/Graphics/TerrainRenderer.cs index 1a3e4d68a2..abce3020dc 100644 --- a/OpenRa.Game/Graphics/TerrainRenderer.cs +++ b/OpenRa.Game/Graphics/TerrainRenderer.cs @@ -1,79 +1,79 @@ using System.Drawing; -using Ijw.DirectX; -using IjwFramework.Collections; -using OpenRa.FileFormats; - -namespace OpenRa.Graphics -{ - class TerrainRenderer - { - FvfVertexBuffer vertexBuffer; - IndexBuffer indexBuffer; - Sheet terrainSheet; - - Renderer renderer; - Map map; - OverlayRenderer overlayRenderer; - - public TerrainRenderer(Renderer renderer, Map map) - { - this.renderer = renderer; - this.map = map; - +using Ijw.DirectX; +using IjwFramework.Collections; +using OpenRa.FileFormats; + +namespace OpenRa.Graphics +{ + class TerrainRenderer + { + FvfVertexBuffer vertexBuffer; + IndexBuffer indexBuffer; + Sheet terrainSheet; + + Renderer renderer; + Map map; + OverlayRenderer overlayRenderer; + + public TerrainRenderer(Renderer renderer, Map map) + { + this.renderer = renderer; + this.map = map; + Size tileSize = new Size( Game.CellSize, Game.CellSize ); - - var tileMapping = new Cache( - x => SheetBuilder.Add(Rules.TileSet.GetBytes(x), tileSize)); - - Vertex[] vertices = new Vertex[4 * map.Height * map.Width]; - ushort[] indices = new ushort[6 * map.Height * map.Width]; - - int nv = 0; - int ni = 0; - for( int j = map.YOffset ; j < map.YOffset + map.Height ; j++ ) - for( int i = map.XOffset ; i < map.XOffset + map.Width; i++ ) - { - Sprite tile = tileMapping[map.MapTiles[i, j]]; - Util.FastCreateQuad(vertices, indices, Game.CellSize * new float2(i, j), tile, 0, nv, ni, tile.size); - nv += 4; - ni += 6; - } - - terrainSheet = tileMapping[map.MapTiles[map.XOffset, map.YOffset]].sheet; - - vertexBuffer = new FvfVertexBuffer( renderer.Device, vertices.Length, Vertex.Format ); - vertexBuffer.SetData( vertices ); - - indexBuffer = new IndexBuffer( renderer.Device, indices.Length ); + + var tileMapping = new Cache( + x => SheetBuilder.Add(Game.world.TileSet.GetBytes(x), tileSize)); + + Vertex[] vertices = new Vertex[4 * map.Height * map.Width]; + ushort[] indices = new ushort[6 * map.Height * map.Width]; + + int nv = 0; + int ni = 0; + for( int j = map.YOffset ; j < map.YOffset + map.Height ; j++ ) + for( int i = map.XOffset ; i < map.XOffset + map.Width; i++ ) + { + Sprite tile = tileMapping[map.MapTiles[i, j]]; + Util.FastCreateQuad(vertices, indices, Game.CellSize * new float2(i, j), tile, 0, nv, ni, tile.size); + nv += 4; + ni += 6; + } + + terrainSheet = tileMapping[map.MapTiles[map.XOffset, map.YOffset]].sheet; + + vertexBuffer = new FvfVertexBuffer( renderer.Device, vertices.Length, Vertex.Format ); + vertexBuffer.SetData( vertices ); + + indexBuffer = new IndexBuffer( renderer.Device, indices.Length ); indexBuffer.SetData( indices ); overlayRenderer = new OverlayRenderer( renderer, map ); - } - - public void Draw( Viewport viewport ) - { - int indicesPerRow = map.Width * 6; - int verticesPerRow = map.Width * 4; - - int visibleRows = (int)(viewport.Width / 24.0f + 2); - - int firstRow = (int)((viewport.Location.Y) / 24.0f - map.YOffset); - int lastRow = firstRow + visibleRows; - - if (lastRow < 0 || firstRow > map.Height) - return; - - if (firstRow < 0) firstRow = 0; - if (lastRow > map.Height) lastRow = map.Height; - - renderer.SpriteShader.Quality = ShaderQuality.Low; - renderer.SpriteShader.Render(() => - renderer.DrawBatch(vertexBuffer, indexBuffer, - new Range(verticesPerRow * firstRow, verticesPerRow * lastRow), - new Range(indicesPerRow * firstRow, indicesPerRow * lastRow), - terrainSheet.Texture, PrimitiveType.TriangleList, renderer.SpriteShader)); - - overlayRenderer.Draw(); - } - } -} + } + + public void Draw( Viewport viewport ) + { + int indicesPerRow = map.Width * 6; + int verticesPerRow = map.Width * 4; + + int visibleRows = (int)(viewport.Width / 24.0f + 2); + + int firstRow = (int)((viewport.Location.Y) / 24.0f - map.YOffset); + int lastRow = firstRow + visibleRows; + + if (lastRow < 0 || firstRow > map.Height) + return; + + if (firstRow < 0) firstRow = 0; + if (lastRow > map.Height) lastRow = map.Height; + + renderer.SpriteShader.Quality = ShaderQuality.Low; + renderer.SpriteShader.Render(() => + renderer.DrawBatch(vertexBuffer, indexBuffer, + new Range(verticesPerRow * firstRow, verticesPerRow * lastRow), + new Range(indicesPerRow * firstRow, indicesPerRow * lastRow), + terrainSheet.Texture, PrimitiveType.TriangleList, renderer.SpriteShader)); + + overlayRenderer.Draw(); + } + } +} diff --git a/OpenRa.Game/Graphics/WorldRenderer.cs b/OpenRa.Game/Graphics/WorldRenderer.cs index 0dd480911c..1e41308107 100644 --- a/OpenRa.Game/Graphics/WorldRenderer.cs +++ b/OpenRa.Game/Graphics/WorldRenderer.cs @@ -17,7 +17,7 @@ namespace OpenRa.Graphics internal WorldRenderer(Renderer renderer) { - terrainRenderer = new TerrainRenderer(renderer, Rules.Map); + terrainRenderer = new TerrainRenderer(renderer, Game.world.Map); this.renderer = renderer; spriteRenderer = new SpriteRenderer(renderer, true); diff --git a/OpenRa.Game/Ore.cs b/OpenRa.Game/Ore.cs index 7fb2db8efd..5e406308c3 100644 --- a/OpenRa.Game/Ore.cs +++ b/OpenRa.Game/Ore.cs @@ -19,10 +19,10 @@ namespace OpenRa public static void Destroy(int i, int j) { - if (Rules.Map.ContainsResource(new int2(i, j))) + if (Game.world.Map.ContainsResource(new int2(i, j))) { - Rules.Map.MapTiles[i, j].density = 0; - Rules.Map.MapTiles[i, j].overlay = 0xff; + Game.world.Map.MapTiles[i, j].density = 0; + Game.world.Map.MapTiles[i, j].overlay = 0xff; } } @@ -32,7 +32,7 @@ namespace OpenRa return false; return TerrainCosts.Cost(UnitMovementType.Wheel, - Rules.TileSet.GetWalkability(Rules.Map.MapTiles[i, j])) + Game.world.TileSet.GetWalkability(Game.world.Map.MapTiles[i, j])) < double.PositiveInfinity; } diff --git a/OpenRa.Game/PathFinder.cs b/OpenRa.Game/PathFinder.cs index d4e71fb2f1..427f56f392 100644 --- a/OpenRa.Game/PathFinder.cs +++ b/OpenRa.Game/PathFinder.cs @@ -18,8 +18,8 @@ namespace OpenRa for( int x = 0 ; x < 128 ; x++ ) for( int y = 0 ; y < 128 ; y++ ) for (var umt = UnitMovementType.Foot; umt <= UnitMovementType.Float; umt++ ) - passableCost[(int)umt][ x, y ] = ( Rules.Map.IsInMap( x, y ) ) - ? (float)TerrainCosts.Cost( umt, Rules.TileSet.GetWalkability( Rules.Map.MapTiles[ x, y ] ) ) + passableCost[(int)umt][ x, y ] = ( Game.world.Map.IsInMap( x, y ) ) + ? (float)TerrainCosts.Cost( umt, Game.world.TileSet.GetWalkability( Game.world.Map.MapTiles[ x, y ] ) ) : float.PositiveInfinity; } diff --git a/OpenRa.Game/PathSearch.cs b/OpenRa.Game/PathSearch.cs index 5c9ee59f94..fc1055e1bc 100755 --- a/OpenRa.Game/PathSearch.cs +++ b/OpenRa.Game/PathSearch.cs @@ -48,7 +48,7 @@ namespace OpenRa { int2 newHere = p.Location + d; - if (!Rules.Map.IsInMap(newHere.X, newHere.Y)) continue; + if (!Game.world.Map.IsInMap(newHere.X, newHere.Y)) continue; if( cellInfo[ newHere.X, newHere.Y ].Seen ) continue; @@ -59,7 +59,7 @@ namespace OpenRa if (!Game.BuildingInfluence.CanMoveHere(newHere) && Game.BuildingInfluence.GetBuildingAt(newHere) != ignoreBuilding) continue; - if (Rules.Map.IsOverlaySolid(newHere)) + if (Game.world.Map.IsOverlaySolid(newHere)) continue; } @@ -93,7 +93,7 @@ namespace OpenRa public void AddInitialCell( int2 location ) { - if (!Rules.Map.IsInMap(location.X, location.Y)) + if (!Game.world.Map.IsInMap(location.X, location.Y)) return; cellInfo[ location.X, location.Y ] = new CellInfo( 0, location, false ); diff --git a/OpenRa.Game/Smudge.cs b/OpenRa.Game/Smudge.cs index c7b9e1ddd2..24fa29b0fe 100644 --- a/OpenRa.Game/Smudge.cs +++ b/OpenRa.Game/Smudge.cs @@ -10,9 +10,9 @@ namespace OpenRa public static void AddSmudge(bool isCrater, int x, int y) { - var smudge = Rules.Map.MapTiles[x, y].smudge; + var smudge = Game.world.Map.MapTiles[x, y].smudge; if (smudge == 0) - Rules.Map.MapTiles[x, y].smudge = (byte) (isCrater + Game.world.Map.MapTiles[x, y].smudge = (byte) (isCrater ? (firstCrater + framesPerCrater * ChooseSmudge()) : (firstScorch + ChooseSmudge())); @@ -21,7 +21,7 @@ namespace OpenRa /* deepen the crater */ var amount = (smudge - firstCrater) % framesPerCrater; if (amount < framesPerCrater - 1) - Rules.Map.MapTiles[x, y].smudge++; + Game.world.Map.MapTiles[x, y].smudge++; } public static void AddSmudge(int2 targetTile, WarheadInfo warhead) diff --git a/OpenRa.Game/Traits/Activities/Harvest.cs b/OpenRa.Game/Traits/Activities/Harvest.cs index 0dd6adfcb3..894d9a658b 100644 --- a/OpenRa.Game/Traits/Activities/Harvest.cs +++ b/OpenRa.Game/Traits/Activities/Harvest.cs @@ -36,8 +36,8 @@ namespace OpenRa.Traits.Activities var renderUnit = self.traits.Get(); /* 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 }; diff --git a/OpenRa.Game/Traits/ConstructionYard.cs b/OpenRa.Game/Traits/ConstructionYard.cs index be1fb1d5c7..23ad56f515 100644 --- a/OpenRa.Game/Traits/ConstructionYard.cs +++ b/OpenRa.Game/Traits/ConstructionYard.cs @@ -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; } } } diff --git a/OpenRa.Game/Traits/Harvester.cs b/OpenRa.Game/Traits/Harvester.cs index 2c2273f7f2..904defe75c 100644 --- a/OpenRa.Game/Traits/Harvester.cs +++ b/OpenRa.Game/Traits/Harvester.cs @@ -41,7 +41,7 @@ namespace OpenRa.Traits && underCursor.traits.Contains() && !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; diff --git a/OpenRa.Game/Traits/Mobile.cs b/OpenRa.Game/Traits/Mobile.cs index b5a456cac4..e062c99c87 100644 --- a/OpenRa.Game/Traits/Mobile.cs +++ b/OpenRa.Game/Traits/Mobile.cs @@ -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 GetCurrentPath() diff --git a/OpenRa.Game/Traits/RenderBuilding.cs b/OpenRa.Game/Traits/RenderBuilding.cs index 92ff37e575..fa02d7cb14 100644 --- a/OpenRa.Game/Traits/RenderBuilding.cs +++ b/OpenRa.Game/Traits/RenderBuilding.cs @@ -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); } } } diff --git a/OpenRa.Game/Traits/SeedsOre.cs b/OpenRa.Game/Traits/SeedsOre.cs index 71292c2d98..f8150ba2b0 100644 --- a/OpenRa.Game/Traits/SeedsOre.cs +++ b/OpenRa.Game/Traits/SeedsOre.cs @@ -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; } diff --git a/OpenRa.Game/UiOverlay.cs b/OpenRa.Game/UiOverlay.cs index f5491e383d..b9b6fb3ed6 100644 --- a/OpenRa.Game/UiOverlay.cs +++ b/OpenRa.Game/UiOverlay.cs @@ -50,7 +50,7 @@ namespace OpenRa foreach( var t in Footprint.Tiles( name, bi, position ) ) spriteRenderer.DrawSprite( ( isCloseEnough && Game.IsCellBuildable( t, bi.WaterBound - ? UnitMovementType.Float : UnitMovementType.Wheel ) && !Rules.Map.ContainsResource( t ) ) + ? UnitMovementType.Float : UnitMovementType.Wheel ) && !Game.world.Map.ContainsResource( t ) ) ? buildOk : buildBlocked, Game.CellSize * t, 0 ); spriteRenderer.Flush(); diff --git a/OpenRa.Game/World.cs b/OpenRa.Game/World.cs index a785b8a544..f69fc254be 100644 --- a/OpenRa.Game/World.cs +++ b/OpenRa.Game/World.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using OpenRa.Effects; using OpenRa.Support; +using OpenRa.FileFormats; namespace OpenRa { @@ -11,6 +12,16 @@ namespace OpenRa List effects = new List(); List> frameEndActions = new List>(); + public readonly Map Map; + public readonly TileSet TileSet; + + public World() + { + Map = new Map( Rules.AllRules ); + FileSystem.MountTemporary( new Package( Map.Theater + ".mix" ) ); + TileSet = new TileSet( Map.TileSuffix ); + } + public void Add(Actor a) { a.IsInWorld = true; diff --git a/OpenRa.sln b/OpenRa.sln index 53d44a4f14..8f1efb4c27 100644 --- a/OpenRa.sln +++ b/OpenRa.sln @@ -1,6 +1,6 @@  Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 +# Visual C# Express 2008 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenRa.FileFormats", "OpenRa.FileFormats\OpenRa.FileFormats.csproj", "{BDAEAB25-991E-46A7-AF1E-4F0E03358DAA}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenRa.Game", "OpenRa.Game\OpenRa.Game.csproj", "{0DFB103F-2962-400F-8C6D-E2C28CCBA633}" @@ -17,8 +17,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RulesConverter", "RulesConv EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenRa.Mods.RA", "OpenRa.Mods.RA\OpenRa.Mods.RA.csproj", "{4A8A43B5-A9EF-4ED0-99DD-4BAB10A0DB6E}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Mods", "Mods", "{F80861C1-DD5C-40A4-94B4-02D96318AE95}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenRa.Mods.Aftermath", "OpenRa.Mods.Aftermath\OpenRa.Mods.Aftermath.csproj", "{2E1F8D8B-AEF5-4BCE-A95C-50223A0C7331}" EndProject Global