diff --git a/OpenRA.Mods.Common/Effects/Beacon.cs b/OpenRA.Mods.Common/Effects/Beacon.cs index c0272ec58d..36c1c31151 100644 --- a/OpenRA.Mods.Common/Effects/Beacon.cs +++ b/OpenRA.Mods.Common/Effects/Beacon.cs @@ -17,6 +17,8 @@ namespace OpenRA.Mods.Common.Effects { public class Beacon : IEffect { + static readonly int MaxArrowHeight = 512; + readonly Player owner; readonly WPos position; readonly string palettePrefix; @@ -26,8 +28,7 @@ namespace OpenRA.Mods.Common.Effects readonly Animation poster; readonly Animation clock; - static readonly int maxArrowHeight = 512; - int arrowHeight = maxArrowHeight; + int arrowHeight = MaxArrowHeight; int arrowSpeed = 50; // Player-placed beacons are removed after a delay @@ -69,7 +70,7 @@ namespace OpenRA.Mods.Common.Effects public void Tick(World world) { arrowHeight += arrowSpeed; - var clamped = arrowHeight.Clamp(0, maxArrowHeight); + var clamped = arrowHeight.Clamp(0, MaxArrowHeight); if (arrowHeight != clamped) { arrowHeight = clamped; diff --git a/OpenRA.Mods.Common/Effects/FloatingText.cs b/OpenRA.Mods.Common/Effects/FloatingText.cs index cf60829954..4d550a4a46 100644 --- a/OpenRA.Mods.Common/Effects/FloatingText.cs +++ b/OpenRA.Mods.Common/Effects/FloatingText.cs @@ -19,6 +19,8 @@ namespace OpenRA.Mods.Common.Effects { public class FloatingText : IEffect { + static readonly WVec Velocity = new WVec(0, 0, 86); + readonly SpriteFont font; readonly string text; Color color; @@ -34,13 +36,12 @@ namespace OpenRA.Mods.Common.Effects this.remaining = duration; } - static readonly WVec velocity = new WVec(0, 0, 86); public void Tick(World world) { if (--remaining <= 0) world.AddFrameEndTask(w => w.Remove(this)); - pos += velocity; + pos += Velocity; } public IEnumerable Render(WorldRenderer wr) diff --git a/OpenRA.Mods.Common/Graphics/ContrailRenderable.cs b/OpenRA.Mods.Common/Graphics/ContrailRenderable.cs index 45195b4e7f..6d8cb2f62a 100644 --- a/OpenRA.Mods.Common/Graphics/ContrailRenderable.cs +++ b/OpenRA.Mods.Common/Graphics/ContrailRenderable.cs @@ -43,7 +43,7 @@ namespace OpenRA.Mods.Common.Graphics this.zOffset = zOffset; } - public WPos Pos { get { return trail[idx(next - 1)]; } } + public WPos Pos { get { return trail[Index(next - 1)]; } } public float Scale { get { return 1f; } } public PaletteReference Palette { get { return null; } } public int ZOffset { get { return zOffset; } } @@ -67,13 +67,13 @@ namespace OpenRA.Mods.Common.Graphics wlr.LineWidth = wr.Viewport.Zoom; // Start of the first line segment is the tail of the list - don't smooth it. - var curPos = trail[idx(next - skip - 1)]; + var curPos = trail[Index(next - skip - 1)]; var curCell = wr.world.Map.CellContaining(curPos); var curColor = color; for (var i = 0; i < length - skip - 4; i++) { var j = next - skip - i - 2; - var nextPos = Average(trail[idx(j)], trail[idx(j - 1)], trail[idx(j - 2)], trail[idx(j - 3)]); + var nextPos = Average(trail[Index(j)], trail[Index(j - 1)], trail[Index(j - 2)], trail[Index(j - 3)]); var nextCell = wr.world.Map.CellContaining(nextPos); var nextColor = Exts.ColorLerp(i * 1f / (length - 4), color, Color.Transparent); @@ -91,7 +91,7 @@ namespace OpenRA.Mods.Common.Graphics public void RenderDebugGeometry(WorldRenderer wr) { } // Array index modulo length - int idx(int i) + int Index(int i) { var j = i % trail.Length; return j < 0 ? j + trail.Length : j; @@ -105,7 +105,7 @@ namespace OpenRA.Mods.Common.Graphics public void Update(WPos pos) { trail[next] = pos; - next = idx(next + 1); + next = Index(next + 1); if (length < trail.Length) length++; diff --git a/OpenRA.Mods.Common/Graphics/VoxelRenderable.cs b/OpenRA.Mods.Common/Graphics/VoxelRenderable.cs index bcc6029b83..698db9ff31 100644 --- a/OpenRA.Mods.Common/Graphics/VoxelRenderable.cs +++ b/OpenRA.Mods.Common/Graphics/VoxelRenderable.cs @@ -87,13 +87,13 @@ namespace OpenRA.Mods.Common.Graphics public IRenderable AsDecoration() { return this; } // This will need generalizing once we support TS/RA2 terrain - static readonly float[] groundNormal = new float[] { 0, 0, 1, 1 }; + static readonly float[] GroundNormal = new float[] { 0, 0, 1, 1 }; public void BeforeRender(WorldRenderer wr) { var draw = voxels.Where(v => v.DisableFunc == null || !v.DisableFunc()); renderProxy = Game.Renderer.WorldVoxelRenderer.RenderAsync( - wr, draw, camera, scale, groundNormal, lightSource, + wr, draw, camera, scale, GroundNormal, lightSource, lightAmbientColor, lightDiffuseColor, palette, normalsPalette, shadowPalette); } @@ -154,15 +154,15 @@ namespace OpenRA.Mods.Common.Graphics } } - static readonly uint[] ix = new uint[] { 0, 0, 0, 0, 3, 3, 3, 3 }; - static readonly uint[] iy = new uint[] { 1, 1, 4, 4, 1, 1, 4, 4 }; - static readonly uint[] iz = new uint[] { 2, 5, 2, 5, 2, 5, 2, 5 }; + static readonly uint[] CornerXIndex = new uint[] { 0, 0, 0, 0, 3, 3, 3, 3 }; + static readonly uint[] CornerYIndex = new uint[] { 1, 1, 4, 4, 1, 1, 4, 4 }; + static readonly uint[] CornerZIndex = new uint[] { 2, 5, 2, 5, 2, 5, 2, 5 }; static void DrawBoundsBox(float2 pxPos, float[] transform, float[] bounds, Color c) { var corners = new float2[8]; for (var i = 0; i < 8; i++) { - var vec = new float[] { bounds[ix[i]], bounds[iy[i]], bounds[iz[i]], 1 }; + var vec = new float[] { bounds[CornerXIndex[i]], bounds[CornerYIndex[i]], bounds[CornerZIndex[i]], 1 }; var screen = Util.MatrixVectorMultiply(transform, vec); corners[i] = pxPos + new float2(screen[0], screen[1]); } diff --git a/OpenRA.Mods.Common/Scripting/Global/TriggerGlobal.cs b/OpenRA.Mods.Common/Scripting/Global/TriggerGlobal.cs index 4233c5604b..8ef9785715 100644 --- a/OpenRA.Mods.Common/Scripting/Global/TriggerGlobal.cs +++ b/OpenRA.Mods.Common/Scripting/Global/TriggerGlobal.cs @@ -79,7 +79,7 @@ namespace OpenRA.Mods.Common.Scripting { var group = actors.ToList(); var copy = (LuaFunction)func.CopyReference(); - Action OnMemberKilled = m => + Action onMemberKilled = m => { try { @@ -97,7 +97,7 @@ namespace OpenRA.Mods.Common.Scripting }; foreach (var a in group) - GetScriptTriggers(a).OnKilledInternal += OnMemberKilled; + GetScriptTriggers(a).OnKilledInternal += onMemberKilled; } [Desc("Call a function when one of the actors in a group is killed. The callback " + @@ -106,7 +106,7 @@ namespace OpenRA.Mods.Common.Scripting { var called = false; var copy = (LuaFunction)func.CopyReference(); - Action OnMemberKilled = m => + Action onMemberKilled = m => { try { @@ -126,7 +126,7 @@ namespace OpenRA.Mods.Common.Scripting }; foreach (var a in actors) - GetScriptTriggers(a).OnKilledInternal += OnMemberKilled; + GetScriptTriggers(a).OnKilledInternal += onMemberKilled; } [Desc("Call a function when this actor produces another actor. " + @@ -192,7 +192,7 @@ namespace OpenRA.Mods.Common.Scripting var group = actors.ToList(); var copy = (LuaFunction)func.CopyReference(); - Action OnMemberRemoved = m => + Action onMemberRemoved = m => { try { @@ -210,7 +210,7 @@ namespace OpenRA.Mods.Common.Scripting }; foreach (var a in group) - GetScriptTriggers(a).OnRemovedInternal += OnMemberRemoved; + GetScriptTriggers(a).OnRemovedInternal += onMemberRemoved; } [Desc("Call a function when this actor is captured. The callback function " + @@ -227,7 +227,7 @@ namespace OpenRA.Mods.Common.Scripting var called = false; var copy = (LuaFunction)func.CopyReference(); - Action OnKilledOrCaptured = m => + Action onKilledOrCaptured = m => { try { @@ -244,8 +244,8 @@ namespace OpenRA.Mods.Common.Scripting } }; - GetScriptTriggers(a).OnCapturedInternal += OnKilledOrCaptured; - GetScriptTriggers(a).OnKilledInternal += OnKilledOrCaptured; + GetScriptTriggers(a).OnCapturedInternal += onKilledOrCaptured; + GetScriptTriggers(a).OnKilledInternal += onKilledOrCaptured; } [Desc("Call a function when all of the actors in a group have been killed or captured. " + @@ -255,7 +255,7 @@ namespace OpenRA.Mods.Common.Scripting var group = actors.ToList(); var copy = (LuaFunction)func.CopyReference(); - Action OnMemberKilledOrCaptured = m => + Action onMemberKilledOrCaptured = m => { try { @@ -277,8 +277,8 @@ namespace OpenRA.Mods.Common.Scripting foreach (var a in group) { - GetScriptTriggers(a).OnCapturedInternal += OnMemberKilledOrCaptured; - GetScriptTriggers(a).OnKilledInternal += OnMemberKilledOrCaptured; + GetScriptTriggers(a).OnCapturedInternal += onMemberKilledOrCaptured; + GetScriptTriggers(a).OnKilledInternal += onMemberKilledOrCaptured; } } diff --git a/OpenRA.Mods.Common/ServerTraits/PlayerPinger.cs b/OpenRA.Mods.Common/ServerTraits/PlayerPinger.cs index ae9ee81bbf..70018dc507 100644 --- a/OpenRA.Mods.Common/ServerTraits/PlayerPinger.cs +++ b/OpenRA.Mods.Common/ServerTraits/PlayerPinger.cs @@ -17,9 +17,9 @@ namespace OpenRA.Mods.Common.Server { public class PlayerPinger : ServerTrait, ITick { - int PingInterval = 5000; // Ping every 5 seconds - int ConnReportInterval = 20000; // Report every 20 seconds - int ConnTimeout = 90000; // Drop unresponsive clients after 90 seconds + static readonly int PingInterval = 5000; // Ping every 5 seconds + static readonly int ConnReportInterval = 20000; // Report every 20 seconds + static readonly int ConnTimeout = 90000; // Drop unresponsive clients after 90 seconds // TickTimeout is in microseconds public int TickTimeout { get { return PingInterval * 100; } } diff --git a/OpenRA.Mods.Common/Traits/PaletteEffects/NukePaletteEffect.cs b/OpenRA.Mods.Common/Traits/PaletteEffects/NukePaletteEffect.cs index e30f476fa7..c6f1d3f0b8 100644 --- a/OpenRA.Mods.Common/Traits/PaletteEffects/NukePaletteEffect.cs +++ b/OpenRA.Mods.Common/Traits/PaletteEffects/NukePaletteEffect.cs @@ -20,12 +20,12 @@ namespace OpenRA.Mods.Common.Traits public class NukePaletteEffect : IPaletteModifier, ITick { - const int nukeEffectLength = 20; + const int NukeEffectLength = 20; int remainingFrames; public void Enable() { - remainingFrames = nukeEffectLength; + remainingFrames = NukeEffectLength; } public void Tick(Actor self) @@ -39,7 +39,7 @@ namespace OpenRA.Mods.Common.Traits if (remainingFrames == 0) return; - var frac = (float)remainingFrames / nukeEffectLength; + var frac = (float)remainingFrames / NukeEffectLength; foreach (var pal in palettes) { diff --git a/OpenRA.Mods.Common/Traits/World/ShroudPalette.cs b/OpenRA.Mods.Common/Traits/World/ShroudPalette.cs index d61639260a..9236852a26 100644 --- a/OpenRA.Mods.Common/Traits/World/ShroudPalette.cs +++ b/OpenRA.Mods.Common/Traits/World/ShroudPalette.cs @@ -39,7 +39,7 @@ namespace OpenRA.Mods.Common.Traits wr.AddPalette(info.Name, new ImmutablePalette(Enumerable.Range(0, Palette.Size).Select(i => (uint)c[i % 8].ToArgb()))); } - static Color[] Fog = new[] + static readonly Color[] Fog = new[] { Color.Transparent, Color.Green, Color.Blue, Color.Yellow, @@ -49,7 +49,7 @@ namespace OpenRA.Mods.Common.Traits Color.FromArgb(32, 0, 0, 0) }; - static Color[] Shroud = new[] + static readonly Color[] Shroud = new[] { Color.Transparent, Color.Green, Color.Blue, Color.Yellow, diff --git a/OpenRA.Mods.Common/Widgets/ColorMixerWidget.cs b/OpenRA.Mods.Common/Widgets/ColorMixerWidget.cs index 0994ec9bb6..4aa9155676 100644 --- a/OpenRA.Mods.Common/Widgets/ColorMixerWidget.cs +++ b/OpenRA.Mods.Common/Widgets/ColorMixerWidget.cs @@ -22,7 +22,10 @@ namespace OpenRA.Mods.Common.Widgets public float[] VRange = { 0.2f, 1.0f }; public event Action OnChange = () => { }; - float H, S, V; + public float H { get; private set; } + public float S { get; private set; } + public float V { get; private set; } + byte[] front, back; Sprite mixerSprite; bool isMoving;