diff --git a/OpenRA.Mods.Mobius/RemasterSpriteSequence.cs b/OpenRA.Mods.Mobius/RemasterSpriteSequence.cs index c4099ef..37dca86 100644 --- a/OpenRA.Mods.Mobius/RemasterSpriteSequence.cs +++ b/OpenRA.Mods.Mobius/RemasterSpriteSequence.cs @@ -10,6 +10,7 @@ #endregion using System.Collections.Generic; +using System.Globalization; using System.IO; using System.Linq; using OpenRA.Graphics; @@ -63,14 +64,15 @@ public class RemasterSpriteSequenceLoader : ClassicTilesetSpecificSpriteSequence public RemasterSpriteSequenceLoader(ModData modData) : base(modData) { } - public override ISpriteSequence CreateSequence(ModData modData, string tileset, SpriteCache cache, string image, string sequence, MiniYaml data, MiniYaml defaults) + public override ISpriteSequence CreateSequence(ModData modData, string tileset, SpriteCache cache, + string image, string sequence, MiniYaml data, MiniYaml defaults) { return new RemasterSpriteSequence(cache, this, image, sequence, data, defaults); } } [Desc("A sprite sequence that can have tileset-specific variants and has the oddities " + - "that come with first-generation Westwood titles.")] + "that come with first-generation Westwood titles.")] public class RemasterSpriteSequence : ClassicTilesetSpecificSpriteSequence { [Desc("File name of the remastered sprite to use for this sequence.")] @@ -112,7 +114,9 @@ IEnumerable ParseRemasterFilenames(ModData modData, string tile { string filename = null; MiniYamlNode.SourceLocation location = default; - var remasteredTilesetFilenamesPatternNode = data.Nodes.FirstOrDefault(n => n.Key == RemasteredTilesetFilenamesPattern.Key) ?? defaults.Nodes.FirstOrDefault(n => n.Key == RemasteredTilesetFilenamesPattern.Key); + var remasteredTilesetFilenamesPatternNode = data.Nodes.FirstOrDefault(n => n.Key == RemasteredTilesetFilenamesPattern.Key) + ?? defaults.Nodes.FirstOrDefault(n => n.Key == RemasteredTilesetFilenamesPattern.Key); + if (remasteredTilesetFilenamesPatternNode != null) { var tilesetNode = remasteredTilesetFilenamesPatternNode.Value.Nodes.FirstOrDefault(n => n.Key == tileset); @@ -122,11 +126,13 @@ IEnumerable ParseRemasterFilenames(ModData modData, string tile var patternCount = LoadField("Count", 1, tilesetNode.Value); return Enumerable.Range(patternStart, patternCount).Select(i => - new ReservationInfo(string.Format(tilesetNode.Value.Value, i), FirstFrame, FirstFrame, tilesetNode.Location)); + new ReservationInfo(string.Format(CultureInfo.InvariantCulture, tilesetNode.Value.Value, i), FirstFrame, FirstFrame, tilesetNode.Location)); } } - var remasteredTilesetFilenamesNode = data.Nodes.FirstOrDefault(n => n.Key == RemasteredTilesetFilenames.Key) ?? defaults.Nodes.FirstOrDefault(n => n.Key == RemasteredTilesetFilenames.Key); + var remasteredTilesetFilenamesNode = data.Nodes.FirstOrDefault(n => n.Key == RemasteredTilesetFilenames.Key) + ?? defaults.Nodes.FirstOrDefault(n => n.Key == RemasteredTilesetFilenames.Key); + if (!string.IsNullOrEmpty(remasteredTilesetFilenamesNode?.Value.Value)) { var tilesetNode = remasteredTilesetFilenamesNode.Value.Nodes.FirstOrDefault(n => n.Key == tileset); @@ -138,14 +144,16 @@ IEnumerable ParseRemasterFilenames(ModData modData, string tile } else { - var remasteredFilenamePatternNode = data.Nodes.FirstOrDefault(n => n.Key == RemasteredFilenamePattern.Key) ?? defaults.Nodes.FirstOrDefault(n => n.Key == RemasteredFilenamePattern.Key); + var remasteredFilenamePatternNode = data.Nodes.FirstOrDefault(n => n.Key == RemasteredFilenamePattern.Key) + ?? defaults.Nodes.FirstOrDefault(n => n.Key == RemasteredFilenamePattern.Key); + if (!string.IsNullOrEmpty(remasteredFilenamePatternNode?.Value.Value)) { var patternStart = LoadField("Start", 0, remasteredFilenamePatternNode.Value); var patternCount = LoadField("Count", 1, remasteredFilenamePatternNode.Value); return Enumerable.Range(patternStart, patternCount).Select(i => - new ReservationInfo(string.Format(remasteredFilenamePatternNode.Value.Value, i), + new ReservationInfo(string.Format(CultureInfo.InvariantCulture, remasteredFilenamePatternNode.Value.Value, i), FirstFrame, FirstFrame, remasteredFilenamePatternNode.Location)); } } diff --git a/OpenRA.Mods.Mobius/Traits/World/RemasterTerrainRenderer.cs b/OpenRA.Mods.Mobius/Traits/World/RemasterTerrainRenderer.cs index 7b2acb8..80327d1 100644 --- a/OpenRA.Mods.Mobius/Traits/World/RemasterTerrainRenderer.cs +++ b/OpenRA.Mods.Mobius/Traits/World/RemasterTerrainRenderer.cs @@ -100,7 +100,7 @@ public void UpdateCell(CPos cell) int t; void ITick.Tick(Actor self) { - t += 1; + t++; if (t > 2) { t = 0; @@ -160,7 +160,12 @@ Rectangle ITiledTerrainRenderer.TemplateBounds(TerrainTemplateInfo template) var v = map.Grid.Type == MapGridType.Rectangular ? y : (x + y) / 2f; var tl = new float2(u * tileSize.Width, (v - 0.5f * tileInfo.Height) * tileSize.Height) - 0.5f * scale * sprite.Size; - var rect = new Rectangle((int)(tl.X + scale * sprite.Offset.X), (int)(tl.Y + scale * sprite.Offset.Y), (int)(scale * sprite.Size.X), (int)(scale * sprite.Size.Y)); + var rect = new Rectangle( + (int)(tl.X + scale * sprite.Offset.X), + (int)(tl.Y + scale * sprite.Offset.Y), + (int)(scale * sprite.Size.X), + (int)(scale * sprite.Size.Y)); + templateRect = templateRect.HasValue ? Rectangle.Union(templateRect.Value, rect) : rect; } }