diff --git a/OpenRA.Game/Network/Handshake.cs b/OpenRA.Game/Network/Handshake.cs index a06a5c1d8a..295956d680 100644 --- a/OpenRA.Game/Network/Handshake.cs +++ b/OpenRA.Game/Network/Handshake.cs @@ -29,8 +29,7 @@ namespace OpenRA.Network public string Serialize() { - var data = new List(); - data.Add(new MiniYamlNode("Handshake", FieldSaver.Save(this))); + var data = new List { new MiniYamlNode("Handshake", FieldSaver.Save(this)) }; return data.WriteToString(); } } @@ -54,8 +53,10 @@ namespace OpenRA.Network public static HandshakeResponse Deserialize(string data) { - var handshake = new HandshakeResponse(); - handshake.Client = new Session.Client(); + var handshake = new HandshakeResponse + { + Client = new Session.Client() + }; var ys = MiniYaml.FromString(data); foreach (var y in ys) diff --git a/OpenRA.Game/Platform.cs b/OpenRA.Game/Platform.cs index ebf58e2b99..7d1bfacfb6 100644 --- a/OpenRA.Game/Platform.cs +++ b/OpenRA.Game/Platform.cs @@ -43,9 +43,12 @@ namespace OpenRA try { - var psi = new ProcessStartInfo("uname", "-s"); - psi.UseShellExecute = false; - psi.RedirectStandardOutput = true; + var psi = new ProcessStartInfo("uname", "-s") + { + UseShellExecute = false, + RedirectStandardOutput = true + }; + var p = Process.Start(psi); var kernelName = p.StandardOutput.ReadToEnd(); if (kernelName.Contains("Darwin")) diff --git a/OpenRA.Mods.Cnc/FileFormats/VxlReader.cs b/OpenRA.Mods.Cnc/FileFormats/VxlReader.cs index 62bb46e58e..afda1007d5 100644 --- a/OpenRA.Mods.Cnc/FileFormats/VxlReader.cs +++ b/OpenRA.Mods.Cnc/FileFormats/VxlReader.cs @@ -90,9 +90,11 @@ namespace OpenRA.Mods.Cnc.FileFormats var count = s.ReadUInt8(); for (var j = 0; j < count; j++) { - var v = new VxlElement(); - v.Color = s.ReadUInt8(); - v.Normal = s.ReadUInt8(); + var v = new VxlElement + { + Color = s.ReadUInt8(), + Normal = s.ReadUInt8() + }; l.VoxelMap[x, y].Add(z, v); z++; @@ -120,8 +122,11 @@ namespace OpenRA.Mods.Cnc.FileFormats Limbs = new VxlLimb[LimbCount]; for (var i = 0; i < LimbCount; i++) { - Limbs[i] = new VxlLimb(); - Limbs[i].Name = s.ReadASCII(16); + Limbs[i] = new VxlLimb + { + Name = s.ReadASCII(16) + }; + s.Seek(12, SeekOrigin.Current); } diff --git a/OpenRA.Mods.Common/Pathfinder/PathSearch.cs b/OpenRA.Mods.Common/Pathfinder/PathSearch.cs index 575b6d9282..fb66eed67a 100644 --- a/OpenRA.Mods.Common/Pathfinder/PathSearch.cs +++ b/OpenRA.Mods.Common/Pathfinder/PathSearch.cs @@ -37,10 +37,11 @@ namespace OpenRA.Mods.Common.Pathfinder public static IPathSearch Search(World world, Locomotor locomotor, Actor self, BlockedByActor check, Func goalCondition) { var graph = new PathGraph(LayerPoolForWorld(world), locomotor, self, world, check); - var search = new PathSearch(graph); - search.isGoal = goalCondition; - search.heuristic = loc => 0; - return search; + return new PathSearch(graph) + { + isGoal = goalCondition, + heuristic = loc => 0 + }; } public static IPathSearch FromPoint(World world, Locomotor locomotor, Actor self, CPos @from, CPos target, BlockedByActor check) diff --git a/OpenRA.Mods.Common/Traits/Render/WithHarvestOverlay.cs b/OpenRA.Mods.Common/Traits/Render/WithHarvestOverlay.cs index 672745298c..e7bf5b434d 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithHarvestOverlay.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithHarvestOverlay.cs @@ -42,8 +42,11 @@ namespace OpenRA.Mods.Common.Traits.Render var rs = self.Trait(); var body = self.Trait(); - anim = new Animation(self.World, rs.GetImage(self), RenderSprites.MakeFacingFunc(self)); - anim.IsDecoration = true; + anim = new Animation(self.World, rs.GetImage(self), RenderSprites.MakeFacingFunc(self)) + { + IsDecoration = true + }; + anim.Play(info.Sequence); rs.Add(new AnimationWithOffset(anim, () => body.LocalToWorld(info.LocalOffset.Rotate(body.QuantizeOrientation(self, self.Orientation))), diff --git a/OpenRA.Mods.Common/Traits/Render/WithIdleOverlay.cs b/OpenRA.Mods.Common/Traits/Render/WithIdleOverlay.cs index 9de858d2c1..ba3b1d783d 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithIdleOverlay.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithIdleOverlay.cs @@ -66,8 +66,11 @@ namespace OpenRA.Mods.Common.Traits.Render facing = () => f; } - var anim = new Animation(init.World, Image ?? image, facing); - anim.IsDecoration = IsDecoration; + var anim = new Animation(init.World, Image ?? image, facing) + { + IsDecoration = IsDecoration + }; + anim.PlayRepeating(RenderSprites.NormalizeSequence(anim, init.GetDamageState(), Sequence)); var body = init.Actor.TraitInfo(); @@ -94,8 +97,11 @@ namespace OpenRA.Mods.Common.Traits.Render var body = self.Trait(); var image = info.Image ?? rs.GetImage(self); - overlay = new Animation(self.World, image, () => IsTraitPaused); - overlay.IsDecoration = info.IsDecoration; + overlay = new Animation(self.World, image, () => IsTraitPaused) + { + IsDecoration = info.IsDecoration + }; + if (info.StartSequence != null) overlay.PlayThen(RenderSprites.NormalizeSequence(overlay, self.GetDamageState(), info.StartSequence), () => overlay.PlayRepeating(RenderSprites.NormalizeSequence(overlay, self.GetDamageState(), info.Sequence))); diff --git a/OpenRA.Mods.Common/Traits/World/MapStartingLocations.cs b/OpenRA.Mods.Common/Traits/World/MapStartingLocations.cs index 251fc8302f..d42dd7f696 100644 --- a/OpenRA.Mods.Common/Traits/World/MapStartingLocations.cs +++ b/OpenRA.Mods.Common/Traits/World/MapStartingLocations.cs @@ -66,11 +66,13 @@ namespace OpenRA.Mods.Common.Traits object IAssignSpawnPointsInfo.InitializeState(MapPreview map, Session lobbyInfo) { - var state = new AssignSpawnLocationsState(); + var state = new AssignSpawnLocationsState + { + // Initialize the list of unoccupied spawn points for AssignSpawnLocations to pick from + SpawnLocations = map.SpawnPoints, + AvailableSpawnPoints = LobbyUtils.AvailableSpawnPoints(map.SpawnPoints.Length, lobbyInfo) + }; - // Initialize the list of unoccupied spawn points for AssignSpawnLocations to pick from - state.SpawnLocations = map.SpawnPoints; - state.AvailableSpawnPoints = LobbyUtils.AvailableSpawnPoints(map.SpawnPoints.Length, lobbyInfo); foreach (var kv in lobbyInfo.Slots) { var client = lobbyInfo.ClientInSlot(kv.Key); diff --git a/OpenRA.Mods.Common/Widgets/DropDownButtonWidget.cs b/OpenRA.Mods.Common/Widgets/DropDownButtonWidget.cs index a28f92af81..2586bdbe1f 100644 --- a/OpenRA.Mods.Common/Widgets/DropDownButtonWidget.cs +++ b/OpenRA.Mods.Common/Widgets/DropDownButtonWidget.cs @@ -107,8 +107,11 @@ namespace OpenRA.Mods.Common.Widgets panel = p; // Mask to prevent any clicks from being sent to other widgets - fullscreenMask = new MaskWidget(); - fullscreenMask.Bounds = new Rectangle(0, 0, Game.Renderer.Resolution.Width, Game.Renderer.Resolution.Height); + fullscreenMask = new MaskWidget + { + Bounds = new Rectangle(0, 0, Game.Renderer.Resolution.Width, Game.Renderer.Resolution.Height) + }; + fullscreenMask.OnMouseDown += mi => { Game.Sound.PlayNotification(ModRules, null, "Sounds", ClickSound, null); RemovePanel(); }; if (onCancel != null) fullscreenMask.OnMouseDown += _ => onCancel(); diff --git a/OpenRA.Platforms.Default/Sdl2PlatformWindow.cs b/OpenRA.Platforms.Default/Sdl2PlatformWindow.cs index da316de02b..c3e25f8fde 100644 --- a/OpenRA.Platforms.Default/Sdl2PlatformWindow.cs +++ b/OpenRA.Platforms.Default/Sdl2PlatformWindow.cs @@ -193,9 +193,12 @@ namespace OpenRA.Platforms.Default // Attempt to automatically detect DPI try { - var psi = new ProcessStartInfo("/usr/bin/xrdb", "-query"); - psi.UseShellExecute = false; - psi.RedirectStandardOutput = true; + var psi = new ProcessStartInfo("/usr/bin/xrdb", "-query") + { + UseShellExecute = false, + RedirectStandardOutput = true + }; + var p = Process.Start(psi); var lines = p.StandardOutput.ReadToEnd().Split('\n');