From 7eed99a155996bc554f4e9b115305259339f87cf Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Wed, 21 Dec 2022 22:57:07 +1300 Subject: [PATCH] Use WorldViewortSizes.DefaultScale. --- .../Traits/World/RemasterTerrainRenderer.cs | 20 +++++-------------- mod.config | 2 +- mods/cnc/mod.yaml | 3 +++ 3 files changed, 9 insertions(+), 16 deletions(-) diff --git a/OpenRA.Mods.Mobius/Traits/World/RemasterTerrainRenderer.cs b/OpenRA.Mods.Mobius/Traits/World/RemasterTerrainRenderer.cs index 3319ecc..0959e93 100644 --- a/OpenRA.Mods.Mobius/Traits/World/RemasterTerrainRenderer.cs +++ b/OpenRA.Mods.Mobius/Traits/World/RemasterTerrainRenderer.cs @@ -139,10 +139,7 @@ Rectangle ITiledTerrainRenderer.TemplateBounds(TerrainTemplateInfo template) for (var x = 0; x < template.Size.X; x++) { var tile = new TerrainTile(template.Id, (byte)(i++)); - var tileInfo = terrainInfo.GetTileInfo(tile); - - // Empty tile - if (tileInfo == null) + if (!terrainInfo.TryGetTileInfo(tile, out var tileInfo)) continue; var sprite = tileCache.TileSprite(tile, 0); @@ -163,8 +160,7 @@ Rectangle ITiledTerrainRenderer.TemplateBounds(TerrainTemplateInfo template) IEnumerable ITiledTerrainRenderer.RenderUIPreview(WorldRenderer wr, TerrainTemplateInfo t, int2 origin, float scale) { - var template = t as RemasterTerrainTemplateInfo; - if (template == null) + if (!(t is RemasterTerrainTemplateInfo template)) yield break; var ts = map.Grid.TileSize; @@ -176,10 +172,7 @@ IEnumerable ITiledTerrainRenderer.RenderUIPreview(WorldRenderer wr, for (var x = 0; x < template.Size.X; x++) { var tile = new TerrainTile(template.Id, (byte)i++); - var tileInfo = terrainInfo.GetTileInfo(tile); - - // Empty tile - if (tileInfo == null) + if (!terrainInfo.TryGetTileInfo(tile, out var tileInfo)) continue; var sprite = tileCache.TileSprite(tile, 0); @@ -188,7 +181,7 @@ IEnumerable ITiledTerrainRenderer.RenderUIPreview(WorldRenderer wr, var u = gridType == MapGridType.Rectangular ? x : (x - y) / 2f; var v = gridType == MapGridType.Rectangular ? y : (x + y) / 2f; - var offset = (scale * new float2(u * ts.Width, (v - 0.5f * tileInfo.Height) * ts.Height) - 0.5f * sprite.Size.XY).ToInt2(); + var offset = (scale * new float2(u * ts.Width, (v - 0.5f * tileInfo.Height) * ts.Height) - 0.5f * scale * sprite.Size.XY).ToInt2(); yield return new UISpriteRenderable(sprite, WPos.Zero, origin + offset, 0, null, scale); } @@ -207,10 +200,7 @@ IEnumerable ITiledTerrainRenderer.RenderPreview(WorldRenderer wr, T for (var x = 0; x < template.Size.X; x++) { var tile = new TerrainTile(template.Id, (byte)i++); - var tileInfo = terrainInfo.GetTileInfo(tile); - - // Empty tile - if (tileInfo == null) + if (!terrainInfo.TryGetTileInfo(tile, out var tileInfo)) continue; var sprite = tileCache.TileSprite(tile, 0); diff --git a/mod.config b/mod.config index 2ee67da..23cb558 100644 --- a/mod.config +++ b/mod.config @@ -9,7 +9,7 @@ MOD_ID="cnc" # The OpenRA engine version to use for this project. -ENGINE_VERSION="3cd311e0a3" +ENGINE_VERSION="2aaf0afc5f" ############################################################################## # Packaging diff --git a/mods/cnc/mod.yaml b/mods/cnc/mod.yaml index 28f4b0b..263d039 100644 --- a/mods/cnc/mod.yaml +++ b/mods/cnc/mod.yaml @@ -234,6 +234,9 @@ MapGrid: Type: Rectangular EnableFrameBufferDownscale: true +WorldViewportSizes: + DefaultScale: 0.1875 + DefaultOrderGenerator: UnitOrderGenerator SupportsMapsFrom: cnc