Fix IDE0028, IDE0300, IDE0301, IDE0302, IDE0303, IDE0304.
Silence IDE0305.
This commit is contained in:
committed by
Pavel Penev
parent
0740991c12
commit
79454d8fd2
@@ -73,10 +73,10 @@ namespace OpenRA.Graphics
|
||||
shadow, pos, offset - new WVec(0, 0, height), CurrentSequence.ShadowZOffset + zOffset + height, palette,
|
||||
CurrentSequence.Scale, 1f, float3.Ones, tintModifiers,
|
||||
true, rotation);
|
||||
return new IRenderable[] { shadowRenderable, imageRenderable };
|
||||
return [shadowRenderable, imageRenderable];
|
||||
}
|
||||
|
||||
return new IRenderable[] { imageRenderable };
|
||||
return [imageRenderable];
|
||||
}
|
||||
|
||||
public IRenderable[] RenderUI(WorldRenderer wr, int2 pos, in WVec offset, int zOffset, PaletteReference palette, float scale = 1f, float rotation = 0f)
|
||||
@@ -92,10 +92,10 @@ namespace OpenRA.Graphics
|
||||
{
|
||||
var shadowPos = pos - new int2((int)(scale * shadow.Size.X / 2), (int)(scale * shadow.Size.Y / 2));
|
||||
var shadowRenderable = new UISpriteRenderable(shadow, WPos.Zero + offset, shadowPos, CurrentSequence.ShadowZOffset + zOffset, palette, scale, 1f, rotation);
|
||||
return new IRenderable[] { shadowRenderable, imageRenderable };
|
||||
return [shadowRenderable, imageRenderable];
|
||||
}
|
||||
|
||||
return new IRenderable[] { imageRenderable };
|
||||
return [imageRenderable];
|
||||
}
|
||||
|
||||
public Rectangle ScreenBounds(WorldRenderer wr, WPos pos, in WVec offset)
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace OpenRA.Graphics
|
||||
|
||||
public readonly int[] PanelRegion = null;
|
||||
public readonly PanelSides PanelSides = PanelSides.All;
|
||||
public readonly Dictionary<string, Rectangle> Regions = new();
|
||||
public readonly Dictionary<string, Rectangle> Regions = [];
|
||||
}
|
||||
|
||||
public static IReadOnlyDictionary<string, Collection> Collections => collections;
|
||||
@@ -71,11 +71,11 @@ namespace OpenRA.Graphics
|
||||
dpiScale = Game.Renderer.WindowScale;
|
||||
|
||||
fileSystem = modData.DefaultFileSystem;
|
||||
collections = new Dictionary<string, Collection>();
|
||||
cachedSheets = new Dictionary<string, (Sheet, int)>();
|
||||
cachedSprites = new Dictionary<string, Dictionary<string, Sprite>>();
|
||||
cachedPanelSprites = new Dictionary<string, Sprite[]>();
|
||||
cachedCollectionSheets = new Dictionary<Collection, (Sheet, int)>();
|
||||
collections = [];
|
||||
cachedSheets = [];
|
||||
cachedSprites = [];
|
||||
cachedPanelSprites = [];
|
||||
cachedCollectionSheets = [];
|
||||
|
||||
var stringPool = new HashSet<string>(); // Reuse common strings in YAML
|
||||
var chrome = MiniYaml.Merge(modData.Manifest.Chrome
|
||||
@@ -170,7 +170,7 @@ namespace OpenRA.Graphics
|
||||
var sheetDensity = SheetForCollection(collection);
|
||||
if (cachedCollection == null)
|
||||
{
|
||||
cachedCollection = new Dictionary<string, Sprite>();
|
||||
cachedCollection = [];
|
||||
cachedSprites.Add(collectionName, cachedCollection);
|
||||
}
|
||||
|
||||
@@ -240,11 +240,11 @@ namespace OpenRA.Graphics
|
||||
// PERF: We don't need to search for images if there are no definitions.
|
||||
// PERF: It's more efficient to send an empty array rather than an array of 9 nulls.
|
||||
if (collection.Regions.Count == 0)
|
||||
return Array.Empty<Sprite>();
|
||||
return [];
|
||||
|
||||
// Support manual definitions for unusual dialog layouts
|
||||
sprites = new[]
|
||||
{
|
||||
sprites =
|
||||
[
|
||||
TryGetImage(collectionName, "corner-tl"),
|
||||
TryGetImage(collectionName, "border-t"),
|
||||
TryGetImage(collectionName, "corner-tr"),
|
||||
@@ -254,7 +254,7 @@ namespace OpenRA.Graphics
|
||||
TryGetImage(collectionName, "corner-bl"),
|
||||
TryGetImage(collectionName, "border-b"),
|
||||
TryGetImage(collectionName, "corner-br")
|
||||
};
|
||||
];
|
||||
}
|
||||
|
||||
cachedPanelSprites.Add(collectionName, sprites);
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace OpenRA.Graphics
|
||||
public IHardwareCursor[] Cursors;
|
||||
}
|
||||
|
||||
readonly Dictionary<string, Cursor> cursors = new();
|
||||
readonly Dictionary<string, Cursor> cursors = [];
|
||||
readonly SheetBuilder sheetBuilder;
|
||||
readonly GraphicSettings graphicSettings;
|
||||
|
||||
@@ -233,7 +233,7 @@ namespace OpenRA.Graphics
|
||||
var height = frame.Size.Height;
|
||||
|
||||
if (width == 0 || height == 0)
|
||||
return Array.Empty<byte>();
|
||||
return [];
|
||||
|
||||
var data = new byte[4 * width * height];
|
||||
unsafe
|
||||
|
||||
@@ -21,11 +21,11 @@ namespace OpenRA.Graphics
|
||||
public ITexture ColorShifts { get; }
|
||||
|
||||
public int Height { get; private set; }
|
||||
readonly Dictionary<string, ImmutablePalette> palettes = new();
|
||||
readonly Dictionary<string, MutablePalette> mutablePalettes = new();
|
||||
readonly Dictionary<string, int> indices = new();
|
||||
byte[] buffer = Array.Empty<byte>();
|
||||
float[] colorShiftBuffer = Array.Empty<float>();
|
||||
readonly Dictionary<string, ImmutablePalette> palettes = [];
|
||||
readonly Dictionary<string, MutablePalette> mutablePalettes = [];
|
||||
readonly Dictionary<string, int> indices = [];
|
||||
byte[] buffer = [];
|
||||
float[] colorShiftBuffer = [];
|
||||
|
||||
public HardwarePalette()
|
||||
{
|
||||
|
||||
@@ -43,11 +43,11 @@ namespace OpenRA.Graphics
|
||||
: base("model")
|
||||
{ }
|
||||
|
||||
public override ShaderVertexAttribute[] Attributes { get; } = new[]
|
||||
{
|
||||
public override ShaderVertexAttribute[] Attributes { get; } =
|
||||
[
|
||||
new ShaderVertexAttribute("aVertexPosition", ShaderVertexAttributeType.Float, 3, 0),
|
||||
new ShaderVertexAttribute("aVertexTexCoord", ShaderVertexAttributeType.Float, 4, 12),
|
||||
new ShaderVertexAttribute("aVertexTexMetadata", ShaderVertexAttributeType.Float, 2, 28),
|
||||
};
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,10 +43,10 @@ namespace OpenRA.Graphics
|
||||
public RenderPostProcessPassShaderBindings(string name)
|
||||
: base("postprocess", "postprocess_" + name) { }
|
||||
|
||||
public override ShaderVertexAttribute[] Attributes { get; } = new[]
|
||||
{
|
||||
public override ShaderVertexAttribute[] Attributes { get; } =
|
||||
[
|
||||
new ShaderVertexAttribute("aVertexPosition", ShaderVertexAttributeType.Float, 2, 0)
|
||||
};
|
||||
];
|
||||
}
|
||||
|
||||
public sealed class RenderPostProcessPassTexturedShaderBindings : ShaderBindings
|
||||
@@ -55,10 +55,10 @@ namespace OpenRA.Graphics
|
||||
: base("postprocess_textured", "postprocess_textured_" + name)
|
||||
{ }
|
||||
|
||||
public override ShaderVertexAttribute[] Attributes { get; } = new[]
|
||||
{
|
||||
public override ShaderVertexAttribute[] Attributes { get; } =
|
||||
[
|
||||
new ShaderVertexAttribute("aVertexPosition", ShaderVertexAttributeType.Float, 2, 0),
|
||||
new ShaderVertexAttribute("aVertexTexCoord", ShaderVertexAttributeType.Float, 2, 8),
|
||||
};
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -191,7 +191,7 @@ namespace OpenRA.Graphics
|
||||
{
|
||||
var tr = new float3(br.X, tl.Y, tl.Z);
|
||||
var bl = new float3(tl.X, br.Y, br.Z);
|
||||
DrawPolygon(new[] { tl, tr, br, bl }, width, color, blendMode);
|
||||
DrawPolygon([tl, tr, br, bl], width, color, blendMode);
|
||||
}
|
||||
|
||||
public void FillRect(in float3 tl, in float3 br, Color color, BlendMode blendMode = BlendMode.Alpha)
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace OpenRA.Graphics
|
||||
public sealed class SheetBuilder : IDisposable
|
||||
{
|
||||
public readonly SheetType Type;
|
||||
readonly List<Sheet> sheets = new();
|
||||
readonly List<Sheet> sheets = [];
|
||||
readonly Func<Sheet> allocateSheet;
|
||||
readonly int margin;
|
||||
int rowHeight = 0;
|
||||
|
||||
@@ -27,12 +27,12 @@ namespace OpenRA.Graphics
|
||||
|
||||
readonly Dictionary<
|
||||
int,
|
||||
(int[] Frames, MiniYamlNode.SourceLocation Location, AdjustFrame AdjustFrame, bool Premultiplied)> spriteReservations = new();
|
||||
readonly Dictionary<string, List<int>> reservationsByFilename = new();
|
||||
(int[] Frames, MiniYamlNode.SourceLocation Location, AdjustFrame AdjustFrame, bool Premultiplied)> spriteReservations = [];
|
||||
readonly Dictionary<string, List<int>> reservationsByFilename = [];
|
||||
|
||||
readonly Dictionary<int, Sprite[]> resolvedSprites = new();
|
||||
readonly Dictionary<int, Sprite[]> resolvedSprites = [];
|
||||
|
||||
readonly Dictionary<int, (string Filename, MiniYamlNode.SourceLocation Location)> missingFiles = new();
|
||||
readonly Dictionary<int, (string Filename, MiniYamlNode.SourceLocation Location)> missingFiles = [];
|
||||
|
||||
int nextReservationToken = 1;
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace OpenRA.Graphics
|
||||
{
|
||||
var token = nextReservationToken++;
|
||||
spriteReservations[token] = (frames?.ToArray(), location, adjustFrame, premultiplied);
|
||||
reservationsByFilename.GetOrAdd(filename, _ => new List<int>()).Add(token);
|
||||
reservationsByFilename.GetOrAdd(filename, _ => []).Add(token);
|
||||
return token;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using OpenRA.Primitives;
|
||||
|
||||
@@ -17,7 +16,7 @@ namespace OpenRA.Graphics
|
||||
{
|
||||
public class SpriteRenderable : IPalettedRenderable, IModifyableRenderable, IFinalizedRenderable
|
||||
{
|
||||
public static readonly IEnumerable<IRenderable> None = Array.Empty<IRenderable>();
|
||||
public static readonly IEnumerable<IRenderable> None = [];
|
||||
|
||||
readonly Sprite sprite;
|
||||
readonly WPos pos;
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace OpenRA.Graphics
|
||||
public sealed class TerrainSpriteLayer : IDisposable
|
||||
{
|
||||
// PERF: we can reuse the IndexBuffer as all layers have the same size.
|
||||
static readonly ConditionalWeakTable<World, IndexBufferRc> IndexBuffers = new();
|
||||
static readonly ConditionalWeakTable<World, IndexBufferRc> IndexBuffers = [];
|
||||
readonly IndexBufferRc indexBufferWrapper;
|
||||
|
||||
public readonly BlendMode BlendMode;
|
||||
@@ -30,7 +30,7 @@ namespace OpenRA.Graphics
|
||||
readonly IVertexBuffer<Vertex> vertexBuffer;
|
||||
readonly Vertex[] vertices;
|
||||
readonly bool[] ignoreTint;
|
||||
readonly HashSet<int> dirtyRows = new();
|
||||
readonly HashSet<int> dirtyRows = [];
|
||||
readonly int indexRowStride;
|
||||
readonly int vertexRowStride;
|
||||
readonly bool restrictToBounds;
|
||||
|
||||
@@ -19,12 +19,12 @@ namespace OpenRA.Graphics
|
||||
public static class Util
|
||||
{
|
||||
// yes, our channel order is nuts.
|
||||
static readonly int[] ChannelMasks = { 2, 1, 0, 3 };
|
||||
static readonly int[] ChannelMasks = [2, 1, 0, 3];
|
||||
|
||||
public static uint[] CreateQuadIndices(int quads)
|
||||
{
|
||||
var indices = new uint[quads * 6];
|
||||
ReadOnlySpan<uint> cornerVertexMap = stackalloc uint[] { 0, 1, 2, 2, 3, 0 };
|
||||
ReadOnlySpan<uint> cornerVertexMap = [0, 1, 2, 2, 3, 0];
|
||||
for (var i = 0; i < indices.Length; i++)
|
||||
indices[i] = cornerVertexMap[i % 6] + (uint)(4 * (i / 6));
|
||||
|
||||
@@ -277,13 +277,13 @@ namespace OpenRA.Graphics
|
||||
size.X * angleSin - size.Y * angleCos,
|
||||
(size.X * angleSin - size.Y * angleCos) * size.Z / size.Y);
|
||||
|
||||
return new float3[]
|
||||
{
|
||||
return
|
||||
[
|
||||
center - ra,
|
||||
center + rb,
|
||||
center + ra,
|
||||
center - rb
|
||||
};
|
||||
];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -53,12 +53,12 @@ namespace OpenRA.Graphics
|
||||
: base("combined")
|
||||
{ }
|
||||
|
||||
public override ShaderVertexAttribute[] Attributes { get; } = new[]
|
||||
{
|
||||
public override ShaderVertexAttribute[] Attributes { get; } =
|
||||
[
|
||||
new ShaderVertexAttribute("aVertexPosition", ShaderVertexAttributeType.Float, 3, 0),
|
||||
new ShaderVertexAttribute("aVertexTexCoord", ShaderVertexAttributeType.Float, 4, 12),
|
||||
new ShaderVertexAttribute("aVertexAttributes", ShaderVertexAttributeType.UInt, 1, 28),
|
||||
new ShaderVertexAttribute("aVertexTint", ShaderVertexAttributeType.Float, 4, 32)
|
||||
};
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,19 +31,19 @@ namespace OpenRA.Graphics
|
||||
|
||||
public event Action PaletteInvalidated = null;
|
||||
|
||||
readonly HashSet<Actor> onScreenActors = new();
|
||||
readonly HashSet<Actor> onScreenActors = [];
|
||||
readonly HardwarePalette palette = new();
|
||||
readonly Dictionary<string, PaletteReference> palettes = new();
|
||||
readonly Dictionary<string, PaletteReference> palettes = [];
|
||||
readonly IRenderTerrain terrainRenderer;
|
||||
readonly Lazy<DebugVisualizations> debugVis;
|
||||
readonly Func<string, PaletteReference> createPaletteReference;
|
||||
readonly bool enableDepthBuffer;
|
||||
|
||||
readonly List<IFinalizedRenderable> preparedRenderables = new();
|
||||
readonly List<IFinalizedRenderable> preparedOverlayRenderables = new();
|
||||
readonly List<IFinalizedRenderable> preparedAnnotationRenderables = new();
|
||||
readonly List<IFinalizedRenderable> preparedRenderables = [];
|
||||
readonly List<IFinalizedRenderable> preparedOverlayRenderables = [];
|
||||
readonly List<IFinalizedRenderable> preparedAnnotationRenderables = [];
|
||||
|
||||
readonly List<IRenderable> renderablesBuffer = new();
|
||||
readonly List<IRenderable> renderablesBuffer = [];
|
||||
readonly IRenderer[] renderers;
|
||||
readonly IRenderPostProcessPass[] postProcessPasses;
|
||||
|
||||
@@ -429,7 +429,7 @@ namespace OpenRA.Graphics
|
||||
public float[] ScreenVector(in WVec vec)
|
||||
{
|
||||
var xyz = ScreenVectorComponents(vec);
|
||||
return new[] { xyz.X, xyz.Y, xyz.Z, 1f };
|
||||
return [xyz.X, xyz.Y, xyz.Z, 1f];
|
||||
}
|
||||
|
||||
public int2 ScreenPxOffset(in WVec vec)
|
||||
|
||||
Reference in New Issue
Block a user