Skip to content

Commit

Permalink
Fixed .editorconfig code style rule violations
Browse files Browse the repository at this point in the history
  • Loading branch information
penev92 committed Dec 18, 2024
1 parent c8d3bbc commit c62e914
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
22 changes: 15 additions & 7 deletions OpenRA.Mods.Mobius/RemasterSpriteSequence.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#endregion

using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using OpenRA.Graphics;
Expand Down Expand Up @@ -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.")]
Expand Down Expand Up @@ -112,7 +114,9 @@ IEnumerable<ReservationInfo> 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);
Expand All @@ -122,11 +126,13 @@ IEnumerable<ReservationInfo> 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);
Expand All @@ -138,14 +144,16 @@ IEnumerable<ReservationInfo> 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));
}
}
Expand Down
10 changes: 7 additions & 3 deletions OpenRA.Mods.Mobius/Traits/World/RemasterTerrainRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ public void UpdateCell(CPos cell)
int t;
void ITick.Tick(Actor self)
{
t += 1;
if (t > 2)
if (++t > 2)
{
t = 0;
frame = (frame + 1) % 8;
Expand Down Expand Up @@ -160,7 +159,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;
}
}
Expand Down

0 comments on commit c62e914

Please sign in to comment.