Change renderables to class to avoid boxing

This commit is contained in:
teinarss
2021-01-28 18:46:49 +01:00
committed by abcdefg30
parent 0d8ef1a1dd
commit 58313520f0
20 changed files with 22 additions and 24 deletions

View File

@@ -14,7 +14,7 @@ using OpenRA.Primitives;
namespace OpenRA.Graphics namespace OpenRA.Graphics
{ {
public struct SpriteRenderable : IPalettedRenderable, IModifyableRenderable, IFinalizedRenderable public class SpriteRenderable : IPalettedRenderable, IModifyableRenderable, IFinalizedRenderable
{ {
public static readonly IEnumerable<IRenderable> None = new IRenderable[0]; public static readonly IEnumerable<IRenderable> None = new IRenderable[0];

View File

@@ -15,7 +15,7 @@ using OpenRA.Primitives;
namespace OpenRA.Graphics namespace OpenRA.Graphics
{ {
public struct TargetLineRenderable : IRenderable, IFinalizedRenderable public class TargetLineRenderable : IRenderable, IFinalizedRenderable
{ {
readonly IEnumerable<WPos> waypoints; readonly IEnumerable<WPos> waypoints;
readonly Color color; readonly Color color;

View File

@@ -13,7 +13,7 @@ using OpenRA.Primitives;
namespace OpenRA.Graphics namespace OpenRA.Graphics
{ {
public struct UISpriteRenderable : IRenderable, IPalettedRenderable, IFinalizedRenderable public class UISpriteRenderable : IRenderable, IPalettedRenderable, IFinalizedRenderable
{ {
readonly Sprite sprite; readonly Sprite sprite;
readonly WPos effectiveWorldPos; readonly WPos effectiveWorldPos;

View File

@@ -17,7 +17,7 @@ using OpenRA.Primitives;
namespace OpenRA.Mods.Cnc.Graphics namespace OpenRA.Mods.Cnc.Graphics
{ {
struct TeslaZapRenderable : IPalettedRenderable, IFinalizedRenderable class TeslaZapRenderable : IPalettedRenderable, IFinalizedRenderable
{ {
static int[][] steps = new[] static int[][] steps = new[]
{ {

View File

@@ -15,7 +15,7 @@ using OpenRA.Primitives;
namespace OpenRA.Mods.Common.Graphics namespace OpenRA.Mods.Common.Graphics
{ {
public enum BeamRenderableShape { Cylindrical, Flat } public enum BeamRenderableShape { Cylindrical, Flat }
public struct BeamRenderable : IRenderable, IFinalizedRenderable public class BeamRenderable : IRenderable, IFinalizedRenderable
{ {
readonly WPos pos; readonly WPos pos;
readonly int zOffset; readonly int zOffset;

View File

@@ -14,7 +14,7 @@ using OpenRA.Primitives;
namespace OpenRA.Mods.Common.Graphics namespace OpenRA.Mods.Common.Graphics
{ {
public struct CircleAnnotationRenderable : IRenderable, IFinalizedRenderable public class CircleAnnotationRenderable : IRenderable, IFinalizedRenderable
{ {
const int CircleSegments = 32; const int CircleSegments = 32;
static readonly WVec[] FacingOffsets = Exts.MakeArray(CircleSegments, i => new WVec(1024, 0, 0).Rotate(WRot.FromFacing(i * 256 / CircleSegments))); static readonly WVec[] FacingOffsets = Exts.MakeArray(CircleSegments, i => new WVec(1024, 0, 0).Rotate(WRot.FromFacing(i * 256 / CircleSegments)));

View File

@@ -15,7 +15,7 @@ using OpenRA.Primitives;
namespace OpenRA.Mods.Common.Graphics namespace OpenRA.Mods.Common.Graphics
{ {
public struct ContrailRenderable : IRenderable, IFinalizedRenderable public class ContrailRenderable : IRenderable, IFinalizedRenderable
{ {
public int Length { get { return trail.Length; } } public int Length { get { return trail.Length; } }

View File

@@ -14,7 +14,7 @@ using OpenRA.Primitives;
namespace OpenRA.Mods.Common.Graphics namespace OpenRA.Mods.Common.Graphics
{ {
public struct DetectionCircleAnnotationRenderable : IRenderable, IFinalizedRenderable public class DetectionCircleAnnotationRenderable : IRenderable, IFinalizedRenderable
{ {
readonly WPos centerPosition; readonly WPos centerPosition;
readonly WDist radius; readonly WDist radius;

View File

@@ -15,7 +15,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Graphics namespace OpenRA.Mods.Common.Graphics
{ {
public struct IsometricSelectionBarsAnnotationRenderable : IRenderable, IFinalizedRenderable public class IsometricSelectionBarsAnnotationRenderable : IRenderable, IFinalizedRenderable
{ {
const int BarWidth = 3; const int BarWidth = 3;
const int BarHeight = 4; const int BarHeight = 4;
@@ -40,7 +40,6 @@ namespace OpenRA.Mods.Common.Graphics
} }
public IsometricSelectionBarsAnnotationRenderable(WPos pos, Actor actor, Polygon bounds) public IsometricSelectionBarsAnnotationRenderable(WPos pos, Actor actor, Polygon bounds)
: this()
{ {
this.pos = pos; this.pos = pos;
this.actor = actor; this.actor = actor;

View File

@@ -15,7 +15,7 @@ using OpenRA.Primitives;
namespace OpenRA.Mods.Common.Graphics namespace OpenRA.Mods.Common.Graphics
{ {
public struct IsometricSelectionBoxAnnotationRenderable : IRenderable, IFinalizedRenderable public class IsometricSelectionBoxAnnotationRenderable : IRenderable, IFinalizedRenderable
{ {
static readonly float2 TLOffset = new float2(-12, -6); static readonly float2 TLOffset = new float2(-12, -6);
static readonly float2 TROffset = new float2(12, -6); static readonly float2 TROffset = new float2(12, -6);

View File

@@ -14,7 +14,7 @@ using OpenRA.Primitives;
namespace OpenRA.Mods.Common.Graphics namespace OpenRA.Mods.Common.Graphics
{ {
public struct LineAnnotationRenderable : IRenderable, IFinalizedRenderable public class LineAnnotationRenderable : IRenderable, IFinalizedRenderable
{ {
readonly WPos start; readonly WPos start;
readonly WPos end; readonly WPos end;

View File

@@ -17,7 +17,7 @@ using OpenRA.Primitives;
namespace OpenRA.Mods.Common.Graphics namespace OpenRA.Mods.Common.Graphics
{ {
public struct ModelRenderable : IPalettedRenderable, IModifyableRenderable public class ModelRenderable : IPalettedRenderable, IModifyableRenderable
{ {
readonly IEnumerable<ModelAnimation> models; readonly IEnumerable<ModelAnimation> models;
readonly WPos pos; readonly WPos pos;
@@ -123,7 +123,7 @@ namespace OpenRA.Mods.Common.Graphics
return new FinalizedModelRenderable(wr, this); return new FinalizedModelRenderable(wr, this);
} }
struct FinalizedModelRenderable : IFinalizedRenderable class FinalizedModelRenderable : IFinalizedRenderable
{ {
readonly ModelRenderable model; readonly ModelRenderable model;
readonly ModelRenderProxy renderProxy; readonly ModelRenderProxy renderProxy;

View File

@@ -15,7 +15,7 @@ using OpenRA.Primitives;
namespace OpenRA.Mods.Common.Graphics namespace OpenRA.Mods.Common.Graphics
{ {
public struct PolygonAnnotationRenderable : IRenderable, IFinalizedRenderable public class PolygonAnnotationRenderable : IRenderable, IFinalizedRenderable
{ {
readonly WPos[] vertices; readonly WPos[] vertices;
readonly WPos effectivePos; readonly WPos effectivePos;

View File

@@ -15,7 +15,7 @@ using OpenRA.Primitives;
namespace OpenRA.Mods.Common.Graphics namespace OpenRA.Mods.Common.Graphics
{ {
public struct RailgunHelixRenderable : IRenderable, IFinalizedRenderable public class RailgunHelixRenderable : IRenderable, IFinalizedRenderable
{ {
readonly WPos pos; readonly WPos pos;
readonly int zOffset; readonly int zOffset;

View File

@@ -14,7 +14,7 @@ using OpenRA.Primitives;
namespace OpenRA.Mods.Common.Graphics namespace OpenRA.Mods.Common.Graphics
{ {
public struct RangeCircleAnnotationRenderable : IRenderable, IFinalizedRenderable public class RangeCircleAnnotationRenderable : IRenderable, IFinalizedRenderable
{ {
const int RangeCircleSegments = 32; const int RangeCircleSegments = 32;
static readonly Int32Matrix4x4[] RangeCircleStartRotations = Exts.MakeArray(RangeCircleSegments, i => WRot.FromFacing(8 * i).AsMatrix()); static readonly Int32Matrix4x4[] RangeCircleStartRotations = Exts.MakeArray(RangeCircleSegments, i => WRot.FromFacing(8 * i).AsMatrix());

View File

@@ -15,7 +15,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Graphics namespace OpenRA.Mods.Common.Graphics
{ {
public struct SelectionBarsAnnotationRenderable : IRenderable, IFinalizedRenderable public class SelectionBarsAnnotationRenderable : IRenderable, IFinalizedRenderable
{ {
readonly WPos pos; readonly WPos pos;
readonly Actor actor; readonly Actor actor;
@@ -31,7 +31,6 @@ namespace OpenRA.Mods.Common.Graphics
} }
public SelectionBarsAnnotationRenderable(WPos pos, Actor actor, Rectangle decorationBounds) public SelectionBarsAnnotationRenderable(WPos pos, Actor actor, Rectangle decorationBounds)
: this()
{ {
this.pos = pos; this.pos = pos;
this.actor = actor; this.actor = actor;

View File

@@ -14,7 +14,7 @@ using OpenRA.Primitives;
namespace OpenRA.Mods.Common.Graphics namespace OpenRA.Mods.Common.Graphics
{ {
public struct SelectionBoxAnnotationRenderable : IRenderable, IFinalizedRenderable public class SelectionBoxAnnotationRenderable : IRenderable, IFinalizedRenderable
{ {
readonly WPos pos; readonly WPos pos;
readonly Rectangle decorationBounds; readonly Rectangle decorationBounds;

View File

@@ -15,7 +15,7 @@ using OpenRA.Widgets;
namespace OpenRA.Mods.Common.Graphics namespace OpenRA.Mods.Common.Graphics
{ {
public struct TextAnnotationRenderable : IRenderable, IFinalizedRenderable public class TextAnnotationRenderable : IRenderable, IFinalizedRenderable
{ {
readonly SpriteFont font; readonly SpriteFont font;
readonly WPos pos; readonly WPos pos;

View File

@@ -17,7 +17,7 @@ using OpenRA.Primitives;
namespace OpenRA.Mods.Common.Graphics namespace OpenRA.Mods.Common.Graphics
{ {
public struct UIModelRenderable : IRenderable, IPalettedRenderable public class UIModelRenderable : IRenderable, IPalettedRenderable
{ {
readonly IEnumerable<ModelAnimation> models; readonly IEnumerable<ModelAnimation> models;
readonly WPos effectiveWorldPos; readonly WPos effectiveWorldPos;
@@ -74,7 +74,7 @@ namespace OpenRA.Mods.Common.Graphics
return new FinalizedUIModelRenderable(wr, this); return new FinalizedUIModelRenderable(wr, this);
} }
struct FinalizedUIModelRenderable : IFinalizedRenderable class FinalizedUIModelRenderable : IFinalizedRenderable
{ {
readonly UIModelRenderable model; readonly UIModelRenderable model;
readonly ModelRenderProxy renderProxy; readonly ModelRenderProxy renderProxy;

View File

@@ -15,7 +15,7 @@ using OpenRA.Widgets;
namespace OpenRA.Mods.Common.Graphics namespace OpenRA.Mods.Common.Graphics
{ {
public struct UITextRenderable : IRenderable, IFinalizedRenderable public class UITextRenderable : IRenderable, IFinalizedRenderable
{ {
readonly SpriteFont font; readonly SpriteFont font;
readonly WPos effectiveWorldPos; readonly WPos effectiveWorldPos;