diff --git a/OpenRA.Game/Graphics/TerrainRenderer.cs b/OpenRA.Game/Graphics/TerrainRenderer.cs index 612052ed20..3ea9204a74 100644 --- a/OpenRA.Game/Graphics/TerrainRenderer.cs +++ b/OpenRA.Game/Graphics/TerrainRenderer.cs @@ -17,7 +17,7 @@ namespace OpenRA.Graphics { sealed class TerrainRenderer : IDisposable { - readonly World world; + readonly Map map; readonly Dictionary spriteLayers = new Dictionary(); readonly Theater theater; readonly CellLayer mapTiles; @@ -25,19 +25,19 @@ namespace OpenRA.Graphics public TerrainRenderer(World world, WorldRenderer wr) { - this.world = world; + map = world.Map; theater = wr.Theater; - mapTiles = world.Map.MapTiles.Value; - mapHeight = world.Map.MapHeight.Value; + mapTiles = map.MapTiles.Value; + mapHeight = map.MapHeight.Value; - foreach (var template in world.TileSet.Templates) + foreach (var template in map.Rules.TileSet.Templates) { var palette = template.Value.Palette ?? TileSet.TerrainPaletteInternalName; spriteLayers.GetOrAdd(palette, pal => - new TerrainSpriteLayer(world, wr, theater.Sheet, BlendMode.Alpha, wr.Palette(palette), wr.World.Type != WorldType.Editor)); + new TerrainSpriteLayer(world, wr, theater.Sheet, BlendMode.Alpha, wr.Palette(palette), world.Type != WorldType.Editor)); } - foreach (var cell in world.Map.AllCells) + foreach (var cell in map.AllCells) UpdateCell(cell); mapTiles.CellEntryChanged += UpdateCell; @@ -47,7 +47,7 @@ namespace OpenRA.Graphics public void UpdateCell(CPos cell) { var tile = mapTiles[cell]; - var palette = world.TileSet.Templates[tile.Type].Palette ?? TileSet.TerrainPaletteInternalName; + var palette = map.Rules.TileSet.Templates[tile.Type].Palette ?? TileSet.TerrainPaletteInternalName; var sprite = theater.TileSprite(tile); foreach (var kv in spriteLayers) kv.Value.Update(cell, palette == kv.Key ? sprite : null); diff --git a/OpenRA.Game/Graphics/Viewport.cs b/OpenRA.Game/Graphics/Viewport.cs index 217fcb8127..9e53dba07b 100644 --- a/OpenRA.Game/Graphics/Viewport.cs +++ b/OpenRA.Game/Graphics/Viewport.cs @@ -149,7 +149,7 @@ namespace OpenRA.Graphics var world = worldRenderer.Viewport.ViewToWorldPx(view); var map = worldRenderer.World.Map; var candidates = CandidateMouseoverCells(world).ToList(); - var tileSet = worldRenderer.World.TileSet; + var tileSet = worldRenderer.World.Map.Rules.TileSet; foreach (var uv in candidates) { diff --git a/OpenRA.Game/Graphics/WorldRenderer.cs b/OpenRA.Game/Graphics/WorldRenderer.cs index b3f5da0102..45cee3134c 100644 --- a/OpenRA.Game/Graphics/WorldRenderer.cs +++ b/OpenRA.Game/Graphics/WorldRenderer.cs @@ -51,7 +51,7 @@ namespace OpenRA.Graphics palette.Initialize(); - Theater = new Theater(world.TileSet); + Theater = new Theater(world.Map.Rules.TileSet); terrainRenderer = new TerrainRenderer(world, this); devTrait = Exts.Lazy(() => world.LocalPlayer != null ? world.LocalPlayer.PlayerActor.Trait() : null); diff --git a/OpenRA.Game/World.cs b/OpenRA.Game/World.cs index 23ef101885..f8075d122e 100644 --- a/OpenRA.Game/World.cs +++ b/OpenRA.Game/World.cs @@ -109,8 +109,6 @@ namespace OpenRA public readonly Map Map; - public readonly TileSet TileSet; - public readonly ActorMap ActorMap; public readonly ScreenMap ScreenMap; public readonly WorldType Type; @@ -159,8 +157,6 @@ namespace OpenRA orderGenerator = new UnitOrderGenerator(); Map = map; Timestep = orderManager.LobbyInfo.GlobalSettings.Timestep; - - TileSet = map.Rules.TileSet; SharedRandom = new MersenneTwister(orderManager.LobbyInfo.GlobalSettings.RandomSeed); var worldActorType = type == WorldType.Editor ? "EditorWorld" : "World"; diff --git a/OpenRA.Mods.Common/AI/HackyAI.cs b/OpenRA.Mods.Common/AI/HackyAI.cs index d0210c657e..2694e9276f 100644 --- a/OpenRA.Mods.Common/AI/HackyAI.cs +++ b/OpenRA.Mods.Common/AI/HackyAI.cs @@ -308,9 +308,10 @@ namespace OpenRA.Mods.Common.AI attackForceTicks = Random.Next(0, Info.AttackForceInterval); minAttackForceDelayTicks = Random.Next(0, Info.MinimumAttackForceDelay); - resourceTypeIndices = new BitArray(World.TileSet.TerrainInfo.Length); // Big enough + var tileset = World.Map.Rules.TileSet; + resourceTypeIndices = new BitArray(tileset.TerrainInfo.Length); // Big enough foreach (var t in Map.Rules.Actors["world"].TraitInfos()) - resourceTypeIndices.Set(World.TileSet.GetTerrainIndex(t.TerrainType), true); + resourceTypeIndices.Set(tileset.GetTerrainIndex(t.TerrainType), true); } // TODO: Possibly give this a more generic name when terrain type is unhardcoded @@ -672,7 +673,7 @@ namespace OpenRA.Mods.Common.AI { var harvInfo = harvester.Info.TraitInfo(); var mobileInfo = harvester.Info.TraitInfo(); - var passable = (uint)mobileInfo.GetMovementClass(World.TileSet); + var passable = (uint)mobileInfo.GetMovementClass(World.Map.Rules.TileSet); var path = pathfinder.FindPath( PathSearch.Search(World, mobileInfo, harvester, true, diff --git a/OpenRA.Mods.Common/Activities/FindResources.cs b/OpenRA.Mods.Common/Activities/FindResources.cs index 5957144e22..f7fbb06763 100644 --- a/OpenRA.Mods.Common/Activities/FindResources.cs +++ b/OpenRA.Mods.Common/Activities/FindResources.cs @@ -117,7 +117,7 @@ namespace OpenRA.Mods.Common.Activities var searchRadiusSquared = searchRadius * searchRadius; // Find any harvestable resources: - var passable = (uint)mobileInfo.GetMovementClass(self.World.TileSet); + var passable = (uint)mobileInfo.GetMovementClass(self.World.Map.Rules.TileSet); List path; using (var search = PathSearch.Search(self.World, mobileInfo, self, true, loc => domainIndex.IsPassable(self.Location, loc, passable) && self.CanHarvestAt(loc, resLayer, harvInfo, territory)) diff --git a/OpenRA.Mods.Common/Activities/Move/MoveAdjacentTo.cs b/OpenRA.Mods.Common/Activities/Move/MoveAdjacentTo.cs index 5ab4c29699..9c434f2a9c 100644 --- a/OpenRA.Mods.Common/Activities/Move/MoveAdjacentTo.cs +++ b/OpenRA.Mods.Common/Activities/Move/MoveAdjacentTo.cs @@ -56,7 +56,7 @@ namespace OpenRA.Mods.Common.Activities mobile = self.Trait(); pathFinder = self.World.WorldActor.Trait(); domainIndex = self.World.WorldActor.Trait(); - movementClass = (uint)mobile.Info.GetMovementClass(self.World.TileSet); + movementClass = (uint)mobile.Info.GetMovementClass(self.World.Map.Rules.TileSet); if (target.IsValidFor(self)) targetPosition = self.World.Map.CellContaining(target.CenterPosition); diff --git a/OpenRA.Mods.Common/EditorBrushes/EditorResourceBrush.cs b/OpenRA.Mods.Common/EditorBrushes/EditorResourceBrush.cs index 85f9a92f72..99300343fc 100644 --- a/OpenRA.Mods.Common/EditorBrushes/EditorResourceBrush.cs +++ b/OpenRA.Mods.Common/EditorBrushes/EditorResourceBrush.cs @@ -37,8 +37,7 @@ namespace OpenRA.Mods.Common.Widgets preview.IsVisible = () => editorWidget.CurrentBrush == this; var variant = resource.Variants.FirstOrDefault(); - var sequenceProvider = wr.World.Map.Rules.Sequences; - var sequence = sequenceProvider.GetSequence("resources", variant); + var sequence = wr.World.Map.Rules.Sequences.GetSequence("resources", variant); var sprite = sequence.GetSprite(resource.MaxDensity - 1); preview.GetSprite = () => sprite; @@ -83,11 +82,11 @@ namespace OpenRA.Mods.Common.Widgets return false; var tile = world.Map.MapTiles.Value[cell]; - var tileInfo = world.TileSet.GetTileInfo(tile); + var tileInfo = world.Map.Rules.TileSet.GetTileInfo(tile); if (tileInfo == null) return false; - var terrainType = world.TileSet.TerrainInfo[tileInfo.TerrainType]; + var terrainType = world.Map.Rules.TileSet.TerrainInfo[tileInfo.TerrainType]; if (mapResources[cell].Type == ResourceType.ResourceType) return false; diff --git a/OpenRA.Mods.Common/EditorBrushes/EditorTileBrush.cs b/OpenRA.Mods.Common/EditorBrushes/EditorTileBrush.cs index 5c2ab6f272..28577bf154 100644 --- a/OpenRA.Mods.Common/EditorBrushes/EditorTileBrush.cs +++ b/OpenRA.Mods.Common/EditorBrushes/EditorTileBrush.cs @@ -40,7 +40,7 @@ namespace OpenRA.Mods.Common.Widgets preview.GetScale = () => worldRenderer.Viewport.Zoom; preview.IsVisible = () => editorWidget.CurrentBrush == this; - preview.Template = world.TileSet.Templates.First(t => t.Value.Id == template).Value; + preview.Template = world.Map.Rules.TileSet.Templates.First(t => t.Value.Id == template).Value; var grid = world.Map.Grid; bounds = worldRenderer.Theater.TemplateBounds(preview.Template, grid.TileSize, grid.Type); diff --git a/OpenRA.Mods.Common/Orders/PlaceBuildingOrderGenerator.cs b/OpenRA.Mods.Common/Orders/PlaceBuildingOrderGenerator.cs index f7cc81a6a8..c13f360850 100644 --- a/OpenRA.Mods.Common/Orders/PlaceBuildingOrderGenerator.cs +++ b/OpenRA.Mods.Common/Orders/PlaceBuildingOrderGenerator.cs @@ -46,7 +46,7 @@ namespace OpenRA.Mods.Common.Orders world.Selection.Clear(); var map = world.Map; - var tileset = world.TileSet.Id.ToLowerInvariant(); + var tileset = world.Map.Tileset.ToLowerInvariant(); var info = map.Rules.Actors[building]; buildingInfo = info.TraitInfo(); diff --git a/OpenRA.Mods.Common/Traits/Buildings/Bridge.cs b/OpenRA.Mods.Common/Traits/Buildings/Bridge.cs index c76f9c62c1..46cbdfa0a6 100644 --- a/OpenRA.Mods.Common/Traits/Buildings/Bridge.cs +++ b/OpenRA.Mods.Common/Traits/Buildings/Bridge.cs @@ -130,8 +130,9 @@ namespace OpenRA.Mods.Common.Traits byte GetTerrainType(CPos cell) { var dx = cell - self.Location; - var index = dx.X + self.World.TileSet.Templates[template].Size.X * dx.Y; - return self.World.TileSet.GetTerrainIndex(new TerrainTile(template, (byte)index)); + var tileSet = self.World.Map.Rules.TileSet; + var index = dx.X + tileSet.Templates[template].Size.X * dx.Y; + return tileSet.GetTerrainIndex(new TerrainTile(template, (byte)index)); } public void LinkNeighbouringBridges(World world, BridgeLayer bridges) diff --git a/OpenRA.Mods.Common/Traits/Buildings/BuildingUtils.cs b/OpenRA.Mods.Common/Traits/Buildings/BuildingUtils.cs index 3df4e56e5d..6ffbc634d2 100644 --- a/OpenRA.Mods.Common/Traits/Buildings/BuildingUtils.cs +++ b/OpenRA.Mods.Common/Traits/Buildings/BuildingUtils.cs @@ -28,7 +28,7 @@ namespace OpenRA.Mods.Common.Traits return false; var tile = world.Map.MapTiles.Value[cell]; - var tileInfo = world.TileSet.GetTileInfo(tile); + var tileInfo = world.Map.Rules.TileSet.GetTileInfo(tile); // TODO: This is bandaiding over bogus tilesets. if (tileInfo != null && tileInfo.RampType > 0) diff --git a/OpenRA.Mods.Common/Traits/Infantry/TerrainModifiesDamage.cs b/OpenRA.Mods.Common/Traits/Infantry/TerrainModifiesDamage.cs index 6b6ae14046..536dc64739 100644 --- a/OpenRA.Mods.Common/Traits/Infantry/TerrainModifiesDamage.cs +++ b/OpenRA.Mods.Common/Traits/Infantry/TerrainModifiesDamage.cs @@ -48,11 +48,10 @@ namespace OpenRA.Mods.Common.Traits var world = self.World; var map = world.Map; - var tileSet = world.TileSet; var tiles = map.MapTiles.Value; var pos = map.CellContaining(self.CenterPosition); - var terrainType = tileSet[tileSet.GetTerrainIndex(tiles[pos])].Type; + var terrainType = map.GetTerrainInfo(pos).Type; if (!Info.TerrainModifier.ContainsKey(terrainType)) return FullDamage; diff --git a/OpenRA.Mods.Common/Traits/Mobile.cs b/OpenRA.Mods.Common/Traits/Mobile.cs index 551086f881..f4d0140740 100644 --- a/OpenRA.Mods.Common/Traits/Mobile.cs +++ b/OpenRA.Mods.Common/Traits/Mobile.cs @@ -136,7 +136,7 @@ namespace OpenRA.Mods.Common.Traits // PERF: This struct allows us to cache the terrain info for the tileset used by the world. // This allows us to speed up some performance-sensitive pathfinding calculations. World = world; - TerrainInfos = info.TilesetTerrainInfo[world.TileSet]; + TerrainInfos = info.TilesetTerrainInfo[world.Map.Rules.TileSet]; } } @@ -151,7 +151,7 @@ namespace OpenRA.Mods.Common.Traits public int MovementCostForCell(World world, CPos cell) { - return MovementCostForCell(world.Map, TilesetTerrainInfo[world.TileSet], cell); + return MovementCostForCell(world.Map, TilesetTerrainInfo[world.Map.Rules.TileSet], cell); } int MovementCostForCell(Map map, TerrainInfo[] terrainInfos, CPos cell) @@ -630,7 +630,7 @@ namespace OpenRA.Mods.Common.Traits if (index == byte.MaxValue) return 0; - var terrainSpeed = Info.TilesetTerrainInfo[self.World.TileSet][index].Speed; + var terrainSpeed = Info.TilesetTerrainInfo[self.World.Map.Rules.TileSet][index].Speed; if (terrainSpeed == 0) return 0; diff --git a/OpenRA.Mods.Common/Traits/PaletteEffects/RotationPaletteEffect.cs b/OpenRA.Mods.Common/Traits/PaletteEffects/RotationPaletteEffect.cs index eb321866ab..c5bcb3ec81 100644 --- a/OpenRA.Mods.Common/Traits/PaletteEffects/RotationPaletteEffect.cs +++ b/OpenRA.Mods.Common/Traits/PaletteEffects/RotationPaletteEffect.cs @@ -57,7 +57,7 @@ namespace OpenRA.Mods.Common.Traits { this.info = info; rotationBuffer = new uint[info.RotationRange]; - tilesetId = world.TileSet.Id; + tilesetId = world.Map.Rules.TileSet.Id; validTileset = IsValidTileset(); } diff --git a/OpenRA.Mods.Common/Traits/RadarColorFromTerrain.cs b/OpenRA.Mods.Common/Traits/RadarColorFromTerrain.cs index 70243702a7..b0a55b0af3 100644 --- a/OpenRA.Mods.Common/Traits/RadarColorFromTerrain.cs +++ b/OpenRA.Mods.Common/Traits/RadarColorFromTerrain.cs @@ -26,7 +26,8 @@ namespace OpenRA.Mods.Common.Traits public RadarColorFromTerrain(Actor self, string terrain) { - c = self.World.TileSet[self.World.TileSet.GetTerrainIndex(terrain)].Color; + var tileSet = self.World.Map.Rules.TileSet; + c = tileSet[tileSet.GetTerrainIndex(terrain)].Color; } public bool VisibleOnRadar(Actor self) { return true; } diff --git a/OpenRA.Mods.Common/Traits/Upgrades/DeployToUpgrade.cs b/OpenRA.Mods.Common/Traits/Upgrades/DeployToUpgrade.cs index 932168b11a..700b9cc31d 100644 --- a/OpenRA.Mods.Common/Traits/Upgrades/DeployToUpgrade.cs +++ b/OpenRA.Mods.Common/Traits/Upgrades/DeployToUpgrade.cs @@ -158,9 +158,8 @@ namespace OpenRA.Mods.Common.Traits if (!checkTerrainType) return true; - var tileSet = self.World.TileSet; var tiles = self.World.Map.MapTiles.Value; - var terrainType = tileSet[tileSet.GetTerrainIndex(tiles[self.Location])].Type; + var terrainType = self.World.Map.GetTerrainInfo(self.Location).Type; return info.AllowedTerrainTypes.Contains(terrainType); } @@ -174,7 +173,7 @@ namespace OpenRA.Mods.Common.Traits if (self.World.Map.Contains(self.Location)) { var tile = self.World.Map.MapTiles.Value[self.Location]; - var ti = self.World.TileSet.GetTileInfo(tile); + var ti = self.World.Map.Rules.TileSet.GetTileInfo(tile); if (ti != null) ramp = ti.RampType; } diff --git a/OpenRA.Mods.Common/Traits/World/BridgeLayer.cs b/OpenRA.Mods.Common/Traits/World/BridgeLayer.cs index 6e3981eb9d..805f11a1f2 100644 --- a/OpenRA.Mods.Common/Traits/World/BridgeLayer.cs +++ b/OpenRA.Mods.Common/Traits/World/BridgeLayer.cs @@ -67,7 +67,7 @@ namespace OpenRA.Mods.Common.Traits // Correlate the tile "image" aka subtile with its position to find the template origin var tile = w.Map.MapTiles.Value[cell].Type; var index = w.Map.MapTiles.Value[cell].Index; - var template = w.TileSet.Templates[tile]; + var template = w.Map.Rules.TileSet.Templates[tile]; var ni = cell.X - index % template.Size.X; var nj = cell.Y - index / template.Size.X; diff --git a/OpenRA.Mods.Common/Traits/World/DomainIndex.cs b/OpenRA.Mods.Common/Traits/World/DomainIndex.cs index 2e73504116..5fbcaa0f77 100644 --- a/OpenRA.Mods.Common/Traits/World/DomainIndex.cs +++ b/OpenRA.Mods.Common/Traits/World/DomainIndex.cs @@ -28,9 +28,10 @@ namespace OpenRA.Mods.Common.Traits public void WorldLoaded(World world, WorldRenderer wr) { domainIndexes = new Dictionary(); + var tileSet = world.Map.Rules.TileSet; var movementClasses = world.Map.Rules.Actors.Where(ai => ai.Value.HasTraitInfo()) - .Select(ai => (uint)ai.Value.TraitInfo().GetMovementClass(world.TileSet)).Distinct(); + .Select(ai => (uint)ai.Value.TraitInfo().GetMovementClass(tileSet)).Distinct(); foreach (var mc in movementClasses) domainIndexes[mc] = new MovementClassDomainIndex(world, mc); diff --git a/OpenRA.Mods.Common/Traits/World/EditorResourceLayer.cs b/OpenRA.Mods.Common/Traits/World/EditorResourceLayer.cs index b8627da9a7..12f0c71e45 100644 --- a/OpenRA.Mods.Common/Traits/World/EditorResourceLayer.cs +++ b/OpenRA.Mods.Common/Traits/World/EditorResourceLayer.cs @@ -44,7 +44,7 @@ namespace OpenRA.Mods.Common.Traits return; Map = self.World.Map; - Tileset = self.World.TileSet; + Tileset = self.World.Map.Rules.TileSet; Tiles = new CellLayer(Map); Resources = self.TraitsImplementing() diff --git a/OpenRA.Mods.Common/Traits/World/PaletteFromCurrentTileset.cs b/OpenRA.Mods.Common/Traits/World/PaletteFromCurrentTileset.cs index ef88aac15f..7ae53e7c1e 100644 --- a/OpenRA.Mods.Common/Traits/World/PaletteFromCurrentTileset.cs +++ b/OpenRA.Mods.Common/Traits/World/PaletteFromCurrentTileset.cs @@ -43,7 +43,7 @@ namespace OpenRA.Mods.Common.Traits public void LoadPalettes(WorldRenderer wr) { - wr.AddPalette(info.Name, new ImmutablePalette(wr.World.Map.Open(world.TileSet.Palette), info.ShadowIndex), info.AllowModifiers); + wr.AddPalette(info.Name, new ImmutablePalette(wr.World.Map.Open(world.Map.Rules.TileSet.Palette), info.ShadowIndex), info.AllowModifiers); } public IEnumerable PaletteNames { get { yield return info.Name; } } diff --git a/OpenRA.Mods.Common/Traits/World/PaletteFromFile.cs b/OpenRA.Mods.Common/Traits/World/PaletteFromFile.cs index fdc9f0b590..a1ae045d6d 100644 --- a/OpenRA.Mods.Common/Traits/World/PaletteFromFile.cs +++ b/OpenRA.Mods.Common/Traits/World/PaletteFromFile.cs @@ -57,7 +57,7 @@ namespace OpenRA.Mods.Common.Traits get { // Only expose the palette if it is available for the shellmap's tileset (which is a requirement for its use). - if (info.Tileset == null || info.Tileset == world.TileSet.Id) + if (info.Tileset == null || info.Tileset == world.Map.Rules.TileSet.Id) yield return info.Name; } } diff --git a/OpenRA.Mods.Common/Traits/World/PathFinder.cs b/OpenRA.Mods.Common/Traits/World/PathFinder.cs index 5905f137b8..32e102c1d8 100644 --- a/OpenRA.Mods.Common/Traits/World/PathFinder.cs +++ b/OpenRA.Mods.Common/Traits/World/PathFinder.cs @@ -68,7 +68,7 @@ namespace OpenRA.Mods.Common.Traits var domainIndex = world.WorldActor.TraitOrDefault(); if (domainIndex != null) { - var passable = mi.GetMovementClass(world.TileSet); + var passable = mi.GetMovementClass(world.Map.Rules.TileSet); if (!domainIndex.IsPassable(source, target, (uint)passable)) return EmptyPath; } @@ -102,7 +102,7 @@ namespace OpenRA.Mods.Common.Traits var domainIndex = world.WorldActor.TraitOrDefault(); if (domainIndex != null) { - var passable = mi.GetMovementClass(world.TileSet); + var passable = mi.GetMovementClass(world.Map.Rules.TileSet); tilesInRange = new List(tilesInRange.Where(t => domainIndex.IsPassable(source, t, (uint)passable))); if (!tilesInRange.Any()) return EmptyPath; diff --git a/OpenRA.Mods.Common/Traits/World/PlayerPaletteFromCurrentTileset.cs b/OpenRA.Mods.Common/Traits/World/PlayerPaletteFromCurrentTileset.cs index c89c2b1838..a373408873 100644 --- a/OpenRA.Mods.Common/Traits/World/PlayerPaletteFromCurrentTileset.cs +++ b/OpenRA.Mods.Common/Traits/World/PlayerPaletteFromCurrentTileset.cs @@ -40,7 +40,7 @@ namespace OpenRA.Mods.Common.Traits public void LoadPalettes(WorldRenderer wr) { - var filename = world.TileSet.PlayerPalette ?? world.TileSet.Palette; + var filename = world.Map.Rules.TileSet.PlayerPalette ?? world.Map.Rules.TileSet.Palette; wr.AddPalette(info.Name, new ImmutablePalette(wr.World.Map.Open(filename), info.ShadowIndex), info.AllowModifiers); } } diff --git a/OpenRA.Mods.Common/Traits/World/ResourceLayer.cs b/OpenRA.Mods.Common/Traits/World/ResourceLayer.cs index ad118a01d1..6eefc23035 100644 --- a/OpenRA.Mods.Common/Traits/World/ResourceLayer.cs +++ b/OpenRA.Mods.Common/Traits/World/ResourceLayer.cs @@ -194,7 +194,7 @@ namespace OpenRA.Mods.Common.Traits if (!rt.Info.AllowOnRamps) { var tile = world.Map.MapTiles.Value[cell]; - var tileInfo = world.TileSet.GetTileInfo(tile); + var tileInfo = world.Map.Rules.TileSet.GetTileInfo(tile); if (tileInfo != null && tileInfo.RampType > 0) return false; } @@ -214,7 +214,7 @@ namespace OpenRA.Mods.Common.Traits CellContents CreateResourceCell(ResourceType t, CPos cell) { - world.Map.CustomTerrain[cell] = world.TileSet.GetTerrainIndex(t.Info.TerrainType); + world.Map.CustomTerrain[cell] = world.Map.Rules.TileSet.GetTerrainIndex(t.Info.TerrainType); return new CellContents { diff --git a/OpenRA.Mods.Common/Traits/World/TerrainGeometryOverlay.cs b/OpenRA.Mods.Common/Traits/World/TerrainGeometryOverlay.cs index 4b304ade07..03c6cdfe92 100644 --- a/OpenRA.Mods.Common/Traits/World/TerrainGeometryOverlay.cs +++ b/OpenRA.Mods.Common/Traits/World/TerrainGeometryOverlay.cs @@ -50,9 +50,9 @@ namespace OpenRA.Mods.Common.Traits return; var map = wr.World.Map; - var tileSet = wr.World.TileSet; + var tileSet = wr.World.Map.Rules.TileSet; var wcr = Game.Renderer.WorldRgbaColorRenderer; - var colors = wr.World.TileSet.HeightDebugColors; + var colors = tileSet.HeightDebugColors; var mouseCell = wr.Viewport.ViewToWorld(Viewport.LastMousePos).ToMPos(wr.World.Map); foreach (var uv in wr.Viewport.AllVisibleCells.CandidateMapCoords) diff --git a/OpenRA.Mods.Common/Widgets/Logic/Editor/ActorSelectorLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Editor/ActorSelectorLogic.cs index 0edbdd57f8..a6551e8d80 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Editor/ActorSelectorLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Editor/ActorSelectorLogic.cs @@ -97,9 +97,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic var filter = actor.TraitInfoOrDefault(); if (filter != null) { - if (filter.ExcludeTilesets != null && filter.ExcludeTilesets.Contains(world.TileSet.Id)) + if (filter.ExcludeTilesets != null && filter.ExcludeTilesets.Contains(world.Map.Rules.TileSet.Id)) continue; - if (filter.RequireTilesets != null && !filter.RequireTilesets.Contains(world.TileSet.Id)) + if (filter.RequireTilesets != null && !filter.RequireTilesets.Contains(world.Map.Rules.TileSet.Id)) continue; } @@ -140,7 +140,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic catch { Log.Write("debug", "Map editor ignoring actor {0}, because of missing sprites for tileset {1}.", - actor.Name, world.TileSet.Id); + actor.Name, world.Map.Rules.TileSet.Id); continue; } } diff --git a/OpenRA.Mods.Common/Widgets/Logic/Editor/LayerSelectorLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Editor/LayerSelectorLogic.cs index 985eb1fa77..c007e87519 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Editor/LayerSelectorLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Editor/LayerSelectorLogic.cs @@ -57,8 +57,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic layerPreview.GetPalette = () => resource.Palette; var variant = resource.Variants.FirstOrDefault(); - var sequenceProvider = rules.Sequences; - var sequence = sequenceProvider.GetSequence("resources", variant); + var sequence = rules.Sequences.GetSequence("resources", variant); var frame = sequence.Frames != null ? sequence.Frames.Last() : resource.MaxDensity - 1; layerPreview.GetSprite = () => sequence.GetSprite(frame); diff --git a/OpenRA.Mods.Common/Widgets/RadarWidget.cs b/OpenRA.Mods.Common/Widgets/RadarWidget.cs index 00c5322cd3..7d7b028431 100644 --- a/OpenRA.Mods.Common/Widgets/RadarWidget.cs +++ b/OpenRA.Mods.Common/Widgets/RadarWidget.cs @@ -140,12 +140,12 @@ namespace OpenRA.Mods.Common.Widgets int leftColor, rightColor; if (custom == byte.MaxValue) { - var type = world.TileSet.GetTileInfo(world.Map.MapTiles.Value[uv]); + var type = world.Map.Rules.TileSet.GetTileInfo(world.Map.MapTiles.Value[uv]); leftColor = type != null ? type.LeftColor.ToArgb() : Color.Black.ToArgb(); rightColor = type != null ? type.RightColor.ToArgb() : Color.Black.ToArgb(); } else - leftColor = rightColor = world.TileSet[custom].Color.ToArgb(); + leftColor = rightColor = world.Map.Rules.TileSet[custom].Color.ToArgb(); var stride = radarSheet.Size.Width; diff --git a/OpenRA.Mods.D2k/Traits/Buildings/LaysTerrain.cs b/OpenRA.Mods.D2k/Traits/Buildings/LaysTerrain.cs index 9b6f69b1d5..81e02ce895 100644 --- a/OpenRA.Mods.D2k/Traits/Buildings/LaysTerrain.cs +++ b/OpenRA.Mods.D2k/Traits/Buildings/LaysTerrain.cs @@ -43,7 +43,7 @@ namespace OpenRA.Mods.D2k.Traits this.info = info; layer = self.World.WorldActor.Trait(); bi = self.World.WorldActor.Trait(); - template = self.World.TileSet.Templates[info.Template]; + template = self.World.Map.Rules.TileSet.Templates[info.Template]; } public void AddedToWorld(Actor self) diff --git a/OpenRA.Mods.D2k/Traits/Buildings/ProductionFromMapEdge.cs b/OpenRA.Mods.D2k/Traits/Buildings/ProductionFromMapEdge.cs index d86dabcd85..ea59ecdbd8 100644 --- a/OpenRA.Mods.D2k/Traits/Buildings/ProductionFromMapEdge.cs +++ b/OpenRA.Mods.D2k/Traits/Buildings/ProductionFromMapEdge.cs @@ -47,7 +47,7 @@ namespace OpenRA.Mods.D2k.Traits var aircraftInfo = producee.TraitInfoOrDefault(); var mobileInfo = producee.TraitInfoOrDefault(); - var passable = mobileInfo != null ? (uint)mobileInfo.GetMovementClass(self.World.TileSet) : 0; + var passable = mobileInfo != null ? (uint)mobileInfo.GetMovementClass(self.World.Map.Rules.TileSet) : 0; var destination = rp != null ? rp.Location : self.Location; var location = spawnLocation; diff --git a/OpenRA.Mods.D2k/Traits/World/BuildableTerrainLayer.cs b/OpenRA.Mods.D2k/Traits/World/BuildableTerrainLayer.cs index ffb368154f..98f15fd80c 100644 --- a/OpenRA.Mods.D2k/Traits/World/BuildableTerrainLayer.cs +++ b/OpenRA.Mods.D2k/Traits/World/BuildableTerrainLayer.cs @@ -28,7 +28,6 @@ namespace OpenRA.Mods.D2k.Traits { readonly BuildableTerrainLayerInfo info; readonly Dictionary dirty = new Dictionary(); - readonly TileSet tileset; readonly Map map; TerrainSpriteLayer render; @@ -37,7 +36,6 @@ namespace OpenRA.Mods.D2k.Traits public BuildableTerrainLayer(Actor self, BuildableTerrainLayerInfo info) { this.info = info; - tileset = self.World.TileSet; map = self.World.Map; } @@ -49,7 +47,7 @@ namespace OpenRA.Mods.D2k.Traits public void AddTile(CPos cell, TerrainTile tile) { - map.CustomTerrain[cell] = tileset.GetTerrainIndex(tile); + map.CustomTerrain[cell] = map.Rules.TileSet.GetTerrainIndex(tile); // Terrain tiles define their origin at the topleft var s = theater.TileSprite(tile); diff --git a/OpenRA.Mods.RA/Traits/Minelayer.cs b/OpenRA.Mods.RA/Traits/Minelayer.cs index 5ee24a3ad9..799266fe00 100644 --- a/OpenRA.Mods.RA/Traits/Minelayer.cs +++ b/OpenRA.Mods.RA/Traits/Minelayer.cs @@ -43,7 +43,7 @@ namespace OpenRA.Mods.RA.Traits { this.self = self; - var tileset = self.World.TileSet.Id.ToLowerInvariant(); + var tileset = self.World.Map.Tileset.ToLowerInvariant(); tile = self.World.Map.Rules.Sequences.GetSequence("overlay", "build-valid-{0}".F(tileset)).GetSprite(0); } @@ -140,7 +140,7 @@ namespace OpenRA.Mods.RA.Traits minelayer = self; minefieldStart = xy; - var tileset = self.World.TileSet.Id.ToLowerInvariant(); + var tileset = self.World.Map.Tileset.ToLowerInvariant(); tileOk = self.World.Map.Rules.Sequences.GetSequence("overlay", "build-valid-{0}".F(tileset)).GetSprite(0); tileBlocked = self.World.Map.Rules.Sequences.GetSequence("overlay", "build-invalid").GetSprite(0); } diff --git a/OpenRA.Mods.RA/Traits/SupportPowers/ChronoshiftPower.cs b/OpenRA.Mods.RA/Traits/SupportPowers/ChronoshiftPower.cs index 5b237319de..e3ddbb2372 100644 --- a/OpenRA.Mods.RA/Traits/SupportPowers/ChronoshiftPower.cs +++ b/OpenRA.Mods.RA/Traits/SupportPowers/ChronoshiftPower.cs @@ -195,7 +195,7 @@ namespace OpenRA.Mods.RA.Traits var info = (ChronoshiftPowerInfo)power.Info; range = info.Range; - var tileset = manager.Self.World.TileSet.Id.ToLowerInvariant(); + var tileset = world.Map.Tileset.ToLowerInvariant(); validTile = world.Map.Rules.Sequences.GetSequence(info.OverlaySpriteGroup, info.ValidTileSequencePrefix + tileset).GetSprite(0); invalidTile = world.Map.Rules.Sequences.GetSequence(info.OverlaySpriteGroup, info.InvalidTileSequence).GetSprite(0); sourceTile = world.Map.Rules.Sequences.GetSequence(info.OverlaySpriteGroup, info.SourceTileSequence).GetSprite(0);