From bc6af1841b4d024cb64bde679f2b98aec385cfd5 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Tue, 18 Oct 2011 15:10:17 +1300 Subject: [PATCH] fix indents everywhere --- OpenRA.Editor/Form1.Designer.cs | 52 +- OpenRA.Editor/Form1.cs | 4 +- OpenRA.Editor/LegacyMapImporter.cs | 8 +- OpenRA.Editor/MapSelect.Designer.cs | 102 +- OpenRA.Editor/MapSelect.cs | 86 +- OpenRA.Editor/NewMapDialog.Designer.cs | 112 +-- OpenRA.Editor/Program.cs | 14 +- OpenRA.Editor/PropertiesDialog.Designer.cs | 252 ++--- OpenRA.Editor/RenderUtils.cs | 4 +- OpenRA.Editor/ResizeDialog.Designer.cs | 64 +- OpenRA.FileFormats/ColorRamp.cs | 36 +- OpenRA.FileFormats/Exts.cs | 60 +- OpenRA.FileFormats/FieldLoader.cs | 100 +- OpenRA.FileFormats/FileFormats/Blast.cs | 4 +- .../FileFormats/BlowfishKeyProvider.cs | 902 +++++++++--------- OpenRA.FileFormats/FileFormats/Format40.cs | 16 +- OpenRA.FileFormats/FileFormats/Format80.cs | 58 +- OpenRA.FileFormats/Filesystem/FileSystem.cs | 52 +- OpenRA.FileFormats/Filesystem/Folder.cs | 2 +- .../Graphics/IGraphicsDevice.cs | 12 +- OpenRA.FileFormats/Manifest.cs | 2 +- OpenRA.FileFormats/Map/PlayerReference.cs | 2 +- OpenRA.FileFormats/MiniYaml.cs | 70 +- OpenRA.FileFormats/PlayerColorRemap.cs | 4 +- OpenRA.FileFormats/Primitives/Pair.cs | 6 +- OpenRA.FileFormats/Primitives/float2.cs | 24 +- OpenRA.FileFormats/Primitives/int2.cs | 4 +- OpenRA.FileFormats/Support/Log.cs | 48 +- OpenRA.Game/Actor.cs | 4 +- OpenRA.Game/GameRules/ActorInfo.cs | 60 +- OpenRA.Game/GameRules/Settings.cs | 8 +- OpenRA.Game/Graphics/Sprite.cs | 8 +- OpenRA.Game/Graphics/SpriteFont.cs | 22 +- OpenRA.Game/Graphics/SpriteLoader.cs | 2 +- OpenRA.Game/Graphics/Viewport.cs | 20 +- OpenRA.Game/Map.cs | 22 +- OpenRA.Game/ModData.cs | 20 +- OpenRA.Game/Network/Connection.cs | 4 +- OpenRA.Game/Network/FrameData.cs | 20 +- OpenRA.Game/Network/Order.cs | 4 +- OpenRA.Game/Network/OrderManager.cs | 24 +- OpenRA.Game/Network/Session.cs | 2 +- OpenRA.Game/Network/SyncReport.cs | 4 +- OpenRA.Game/Network/UnitOrders.cs | 4 +- OpenRA.Game/Orders/UnitOrderGenerator.cs | 30 +- OpenRA.Game/Player.cs | 2 +- OpenRA.Game/Server/Server.cs | 30 +- OpenRA.Game/Sound.cs | 2 +- OpenRA.Game/Sync.cs | 2 +- OpenRA.Game/Traits/Health.cs | 14 +- OpenRA.Game/Traits/Player/DeveloperMode.cs | 16 +- OpenRA.Game/Traits/Player/PlayerResources.cs | 2 +- OpenRA.Game/Traits/TraitsInterfaces.cs | 318 +++--- OpenRA.Game/Traits/Util.cs | 22 +- OpenRA.Game/Traits/ValidateOrder.cs | 22 +- .../Traits/World/PlayerColorPalette.cs | 2 +- OpenRA.Game/Traits/World/ResourceLayer.cs | 22 +- OpenRA.Game/Traits/World/ResourceType.cs | 4 +- OpenRA.Game/Traits/World/ScreenShaker.cs | 2 +- OpenRA.Game/Traits/World/Shroud.cs | 4 +- OpenRA.Game/Widgets/ButtonWidget.cs | 4 +- OpenRA.Game/Widgets/ChatDisplayWidget.cs | 8 +- OpenRA.Game/Widgets/ChatEntryWidget.cs | 2 +- OpenRA.Game/Widgets/DropDownButtonWidget.cs | 20 +- OpenRA.Game/Widgets/MapPreviewWidget.cs | 8 +- OpenRA.Game/Widgets/PerfGraphWidget.cs | 22 +- .../Widgets/ViewportScrollControllerWidget.cs | 20 +- OpenRA.Game/Widgets/Widget.cs | 496 +++++----- .../WorldInteractionControllerWidget.cs | 18 +- OpenRA.Game/World.cs | 8 +- OpenRA.Mods.Cnc/Missions/Gdi01Script.cs | 40 +- .../ProductionQueueFromSelection.cs | 4 +- .../CncWorldInteractionControllerWidget.cs | 26 +- .../Widgets/Logic/ButtonTooltipLogic.cs | 2 +- .../Widgets/Logic/CncCheatsLogic.cs | 4 +- .../Widgets/Logic/CncColorPickerLogic.cs | 14 +- .../Widgets/Logic/CncConnectionLogic.cs | 26 +- .../Logic/CncConquestObjectivesLogic.cs | 2 +- .../Widgets/Logic/CncDirectConnectLogic.cs | 4 +- .../Widgets/Logic/CncDownloadPackagesLogic.cs | 4 +- .../Widgets/Logic/CncIngameChromeLogic.cs | 2 +- .../Widgets/Logic/CncIngameMenuLogic.cs | 8 +- .../Widgets/Logic/CncInstallFromCDLogic.cs | 2 +- .../Widgets/Logic/CncInstallLogic.cs | 8 +- .../Widgets/Logic/CncLobbyLogic.cs | 24 +- OpenRA.Mods.Cnc/Widgets/Logic/CncMenuLogic.cs | 22 +- .../Widgets/Logic/CncModBrowserLogic.cs | 4 +- .../Widgets/Logic/CncMusicPlayerLogic.cs | 4 +- .../Widgets/Logic/CncServerBrowserLogic.cs | 10 +- .../Widgets/Logic/CncSettingsLogic.cs | 4 +- .../Widgets/Logic/ProductionTooltipLogic.cs | 6 +- .../Widgets/Logic/SimpleTooltipLogic.cs | 4 +- .../Widgets/Logic/SupportPowerTooltipLogic.cs | 6 +- .../Widgets/Logic/WorldTooltipLogic.cs | 4 +- OpenRA.Mods.Cnc/Widgets/PowerBarWidget.cs | 8 +- .../Widgets/ProductionPaletteWidget.cs | 20 +- OpenRA.Mods.Cnc/Widgets/SiloBarWidget.cs | 6 +- .../Widgets/SupportPowersWidget.cs | 14 +- .../Widgets/TooltipContainerWidget.cs | 4 +- OpenRA.Mods.RA/AcceptsSupplies.cs | 4 +- OpenRA.Mods.RA/Activities/Attack.cs | 22 +- OpenRA.Mods.RA/Activities/DonateSupplies.cs | 40 +- OpenRA.Mods.RA/Activities/Follow.cs | 14 +- OpenRA.Mods.RA/Activities/Rearm.cs | 14 +- OpenRA.Mods.RA/Activities/Sell.cs | 4 +- OpenRA.Mods.RA/Air/EjectOnDeath.cs | 2 +- OpenRA.Mods.RA/Air/FlyCircle.cs | 32 +- OpenRA.Mods.RA/Air/ReturnOnIdle.cs | 38 +- OpenRA.Mods.RA/Air/TargetableAircraft.cs | 38 +- OpenRA.Mods.RA/Attack/AttackBase.cs | 2 +- OpenRA.Mods.RA/Bridge.cs | 2 +- OpenRA.Mods.RA/Buildable.cs | 2 +- OpenRA.Mods.RA/Buildings/Building.cs | 4 +- OpenRA.Mods.RA/Buildings/TechTree.cs | 4 +- OpenRA.Mods.RA/Chronoshiftable.cs | 14 +- OpenRA.Mods.RA/ConquestVictoryConditions.cs | 8 +- OpenRA.Mods.RA/CrateDrop.cs | 2 +- OpenRA.Mods.RA/CrateSpawner.cs | 2 +- OpenRA.Mods.RA/Crates/GiveMcvCrateAction.cs | 4 +- OpenRA.Mods.RA/Crates/GiveUnitCrateAction.cs | 2 +- .../Crates/SupportPowerCrateAction.cs | 2 +- OpenRA.Mods.RA/Effects/Bullet.cs | 74 +- OpenRA.Mods.RA/Effects/Contrail.cs | 96 +- OpenRA.Mods.RA/Effects/Missile.cs | 66 +- OpenRA.Mods.RA/EngineerRepair.cs | 4 +- OpenRA.Mods.RA/FreeActor.cs | 2 +- OpenRA.Mods.RA/GainsExperience.cs | 2 +- OpenRA.Mods.RA/HackyAI.cs | 16 +- OpenRA.Mods.RA/Harvester.cs | 10 +- OpenRA.Mods.RA/Husk.cs | 4 +- OpenRA.Mods.RA/InfiltrateForSupportPower.cs | 2 +- OpenRA.Mods.RA/IronCurtainable.cs | 2 +- OpenRA.Mods.RA/LimitedAmmo.cs | 8 +- OpenRA.Mods.RA/Lint/CheckAutotargetWiring.cs | 8 +- .../Lint/LintBuildablePrerequisites.cs | 16 +- OpenRA.Mods.RA/Move/Mobile.cs | 574 +++++------ OpenRA.Mods.RA/Move/PathFinder.cs | 10 +- OpenRA.Mods.RA/Move/PathSearch.cs | 2 +- OpenRA.Mods.RA/Orders/DeployOrderTargeter.cs | 2 +- .../Orders/PlaceBuildingOrderGenerator.cs | 4 +- OpenRA.Mods.RA/Orders/SellOrderGenerator.cs | 2 +- OpenRA.Mods.RA/Orders/UnitOrderTargeter.cs | 4 +- OpenRA.Mods.RA/OreRefinery.cs | 20 +- OpenRA.Mods.RA/Passenger.cs | 2 +- .../Player/ClassicProductionQueue.cs | 8 +- OpenRA.Mods.RA/Player/PlaceBuilding.cs | 8 +- OpenRA.Mods.RA/PrimaryBuilding.cs | 4 +- OpenRA.Mods.RA/Production.cs | 102 +- OpenRA.Mods.RA/ProximityCaptor.cs | 2 +- OpenRA.Mods.RA/ProximityCapturable.cs | 4 +- OpenRA.Mods.RA/Render/RenderBuilding.cs | 4 +- .../Render/RenderBuildingWarFactory.cs | 12 +- OpenRA.Mods.RA/RenderRangeCircle.cs | 6 +- OpenRA.Mods.RA/Reservable.cs | 2 +- OpenRA.Mods.RA/Scripting/RASpecialPowers.cs | 8 +- .../ServerTraits/MasterServerPinger.cs | 2 +- OpenRA.Mods.RA/SupplyTruck.cs | 104 +- .../SupportPowers/AirstrikePower.cs | 4 +- .../SupportPowers/ChronoshiftPower.cs | 22 +- OpenRA.Mods.RA/SupportPowers/SpyPlanePower.cs | 2 +- OpenRA.Mods.RA/TargetableSubmarine.cs | 4 +- OpenRA.Mods.RA/Widgets/BuildPaletteWidget.cs | 22 +- .../Widgets/Logic/ConnectionDialogsLogic.cs | 4 +- .../Widgets/Logic/DiplomacyLogic.cs | 4 +- .../Widgets/Logic/DirectConnectLogic.cs | 28 +- OpenRA.Mods.RA/Widgets/Logic/LobbyLogic.cs | 10 +- .../Widgets/Logic/RADownloadPackagesLogic.cs | 4 +- .../Widgets/Logic/RAInstallFromCDLogic.cs | 4 +- .../Widgets/Logic/RAInstallLogic.cs | 6 +- .../Widgets/Logic/ReplayBrowserLogic.cs | 4 +- .../Widgets/Logic/ServerBrowserLogic.cs | 12 +- .../Widgets/Logic/SettingsMenuLogic.cs | 6 +- OpenRA.Mods.RA/Widgets/RadarBinWidget.cs | 6 +- OpenRA.Mods.RA/Widgets/WorldCommandWidget.cs | 36 +- OpenRA.Mods.RA/Widgets/WorldTooltipWidget.cs | 2 +- OpenRA.Mods.RA/World/PlayMusicOnMapLoad.cs | 2 +- OpenRA.Mods.RA/World/SmudgeLayer.cs | 2 +- OpenRA.TilesetBuilder/Form1.Designer.cs | 30 +- OpenRA.Utility/Program.cs | 20 +- RALint/RALint.cs | 14 +- 180 files changed, 2707 insertions(+), 2707 deletions(-) diff --git a/OpenRA.Editor/Form1.Designer.cs b/OpenRA.Editor/Form1.Designer.cs index 1fae5a3154..1a238498a2 100755 --- a/OpenRA.Editor/Form1.Designer.cs +++ b/OpenRA.Editor/Form1.Designer.cs @@ -266,10 +266,10 @@ namespace OpenRA.Editor // menuStrip1 // this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.fileToolStripMenuItem, - this.mapToolStripMenuItem, - this.toolStripComboBox1, - this.toolStripLabel1}); + this.fileToolStripMenuItem, + this.mapToolStripMenuItem, + this.toolStripComboBox1, + this.toolStripLabel1}); this.menuStrip1.Location = new System.Drawing.Point(0, 0); this.menuStrip1.Name = "menuStrip1"; this.menuStrip1.Size = new System.Drawing.Size(985, 27); @@ -279,16 +279,16 @@ namespace OpenRA.Editor // fileToolStripMenuItem // this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.newToolStripMenuItem, - this.toolStripSeparator1, - this.openToolStripMenuItem, - this.saveToolStripMenuItem, - this.saveAsToolStripMenuItem, - this.toolStripSeparator2, - this.toolStripMenuItem1, - this.mnuExport, - this.toolStripSeparator3, - this.exitToolStripMenuItem}); + this.newToolStripMenuItem, + this.toolStripSeparator1, + this.openToolStripMenuItem, + this.saveToolStripMenuItem, + this.saveAsToolStripMenuItem, + this.toolStripSeparator2, + this.toolStripMenuItem1, + this.mnuExport, + this.toolStripSeparator3, + this.exitToolStripMenuItem}); this.fileToolStripMenuItem.Name = "fileToolStripMenuItem"; this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 23); this.fileToolStripMenuItem.Text = "&File"; @@ -340,8 +340,8 @@ namespace OpenRA.Editor // toolStripMenuItem1 // this.toolStripMenuItem1.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.cCRedAlertMapToolStripMenuItem, - this.bitmapToolStripMenuItem}); + this.cCRedAlertMapToolStripMenuItem, + this.bitmapToolStripMenuItem}); this.toolStripMenuItem1.Name = "toolStripMenuItem1"; this.toolStripMenuItem1.Size = new System.Drawing.Size(123, 22); this.toolStripMenuItem1.Text = "&Import"; @@ -365,7 +365,7 @@ namespace OpenRA.Editor // mnuExport // this.mnuExport.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.mnuMinimapToPNG}); + this.mnuMinimapToPNG}); this.mnuExport.Name = "mnuExport"; this.mnuExport.Size = new System.Drawing.Size(123, 22); this.mnuExport.Text = "&Export"; @@ -394,11 +394,11 @@ namespace OpenRA.Editor // mapToolStripMenuItem // this.mapToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.propertiesToolStripMenuItem, - this.resizeToolStripMenuItem, - this.showActorNamesToolStripMenuItem, - this.showGridToolStripMenuItem, - this.fixOpenAreasToolStripMenuItem, + this.propertiesToolStripMenuItem, + this.resizeToolStripMenuItem, + this.showActorNamesToolStripMenuItem, + this.showGridToolStripMenuItem, + this.fixOpenAreasToolStripMenuItem, this.setupDefaultPlayersMenuItem}); this.mapToolStripMenuItem.Name = "mapToolStripMenuItem"; this.mapToolStripMenuItem.Size = new System.Drawing.Size(43, 23); @@ -453,8 +453,8 @@ namespace OpenRA.Editor // statusStrip1 // this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.toolStripStatusLabelFiller, - this.toolStripStatusLabelMousePosition}); + this.toolStripStatusLabelFiller, + this.toolStripStatusLabelMousePosition}); this.statusStrip1.Location = new System.Drawing.Point(0, 751); this.statusStrip1.Name = "statusStrip1"; this.statusStrip1.Size = new System.Drawing.Size(985, 22); @@ -538,9 +538,9 @@ namespace OpenRA.Editor private System.Windows.Forms.TabPage tabPage2; private System.Windows.Forms.FlowLayoutPanel actorPalette; private System.Windows.Forms.TabPage tabPage3; - private System.Windows.Forms.FlowLayoutPanel resourcePalette; + private System.Windows.Forms.FlowLayoutPanel resourcePalette; private Surface surface1; - private System.Windows.Forms.PictureBox pmMiniMap; + private System.Windows.Forms.PictureBox pmMiniMap; private System.Windows.Forms.SplitContainer splitContainer2; private System.Windows.Forms.SaveFileDialog saveFileDialog; private System.Windows.Forms.SplitContainer splitContainer3; diff --git a/OpenRA.Editor/Form1.cs b/OpenRA.Editor/Form1.cs index cb807e0626..9aa4242a41 100755 --- a/OpenRA.Editor/Form1.cs +++ b/OpenRA.Editor/Form1.cs @@ -157,9 +157,9 @@ namespace OpenRA.Editor var etf = info.Traits.GetOrDefault(); if (etf != null && etf.ExcludeTilesets != null - && etf.ExcludeTilesets.Contains(tileset.Id)) continue; + && etf.ExcludeTilesets.Contains(tileset.Id)) continue; if (etf != null && etf.RequireTilesets != null - && !etf.RequireTilesets.Contains(tileset.Id)) continue; + && !etf.RequireTilesets.Contains(tileset.Id)) continue; var template = RenderUtils.RenderActor(info, tileset, palette); var ibox = new PictureBox diff --git a/OpenRA.Editor/LegacyMapImporter.cs b/OpenRA.Editor/LegacyMapImporter.cs index 698c9b126c..6c22f78ea7 100644 --- a/OpenRA.Editor/LegacyMapImporter.cs +++ b/OpenRA.Editor/LegacyMapImporter.cs @@ -427,10 +427,10 @@ namespace OpenRA.Editor NonCombatant = section == "Neutral", Race = isRA ? (section == "BadGuy" ? "soviet" : "allies") : (section == "BadGuy" ? "nod" : "gdi"), ColorRamp = new ColorRamp( - (byte)((color.First.GetHue() / 360.0f) * 255), - (byte)(color.First.GetSaturation() * 255), - (byte)(color.First.GetBrightness() * 255), - (byte)(color.Second.GetBrightness() * 255)) + (byte)((color.First.GetHue() / 360.0f) * 255), + (byte)(color.First.GetSaturation() * 255), + (byte)(color.First.GetBrightness() * 255), + (byte)(color.Second.GetBrightness() * 255)) }; var Neutral = new [] {"Neutral"}; diff --git a/OpenRA.Editor/MapSelect.Designer.cs b/OpenRA.Editor/MapSelect.Designer.cs index 32d930df6b..f5c0c585c1 100644 --- a/OpenRA.Editor/MapSelect.Designer.cs +++ b/OpenRA.Editor/MapSelect.Designer.cs @@ -10,33 +10,33 @@ namespace OpenRA.Editor { - partial class MapSelect - { - /// - /// TODO - /// - private System.ComponentModel.IContainer components = null; + partial class MapSelect + { + /// + /// TODO + /// + private System.ComponentModel.IContainer components = null; - /// - /// TODO - /// - /// TODO - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } + /// + /// TODO + /// + /// TODO + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } - #region Код, автоматически созданный конструктором форм Windows + #region Код, автоматически созданный конструктором форм Windows - /// - /// TODO - /// - private void InitializeComponent() - { + /// + /// TODO + /// + private void InitializeComponent() + { this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MapSelect)); this.MapList = new System.Windows.Forms.ListView(); @@ -75,7 +75,7 @@ namespace OpenRA.Editor // this.MapList.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.MapList.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.colMapName}); + this.colMapName}); this.MapList.FullRowSelect = true; this.MapList.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None; this.MapList.LargeImageList = this.MapIconsList; @@ -353,33 +353,33 @@ namespace OpenRA.Editor ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); this.ResumeLayout(false); - } + } - #endregion + #endregion - public System.Windows.Forms.ListView MapList; - public System.Windows.Forms.Button btnCancel; - public System.Windows.Forms.Button btnOk; - public System.Windows.Forms.Label lblNew; - public System.Windows.Forms.TextBox txtNew; - public System.Windows.Forms.ColumnHeader colMapName; - public System.Windows.Forms.ImageList MapIconsList; - public System.Windows.Forms.PictureBox pbMinimap; - public System.Windows.Forms.Panel pnlBottom; - public System.Windows.Forms.SplitContainer splitContainer1; - public System.Windows.Forms.Label lblMinimap; - public System.Windows.Forms.TextBox txtTheater; - public System.Windows.Forms.Label lblTheater; - public System.Windows.Forms.TextBox txtAuthor; - public System.Windows.Forms.Label lblAuthor; - public System.Windows.Forms.TextBox txtTitle; - public System.Windows.Forms.Label lblMapName; - public System.Windows.Forms.TextBox txtDesc; - public System.Windows.Forms.Label lblDesc; - public System.Windows.Forms.Label lblMapList; - public System.Windows.Forms.Label lblPathOut; - public System.Windows.Forms.Label lblPath; - public System.Windows.Forms.TextBox txtPathOut; + public System.Windows.Forms.ListView MapList; + public System.Windows.Forms.Button btnCancel; + public System.Windows.Forms.Button btnOk; + public System.Windows.Forms.Label lblNew; + public System.Windows.Forms.TextBox txtNew; + public System.Windows.Forms.ColumnHeader colMapName; + public System.Windows.Forms.ImageList MapIconsList; + public System.Windows.Forms.PictureBox pbMinimap; + public System.Windows.Forms.Panel pnlBottom; + public System.Windows.Forms.SplitContainer splitContainer1; + public System.Windows.Forms.Label lblMinimap; + public System.Windows.Forms.TextBox txtTheater; + public System.Windows.Forms.Label lblTheater; + public System.Windows.Forms.TextBox txtAuthor; + public System.Windows.Forms.Label lblAuthor; + public System.Windows.Forms.TextBox txtTitle; + public System.Windows.Forms.Label lblMapName; + public System.Windows.Forms.TextBox txtDesc; + public System.Windows.Forms.Label lblDesc; + public System.Windows.Forms.Label lblMapList; + public System.Windows.Forms.Label lblPathOut; + public System.Windows.Forms.Label lblPath; + public System.Windows.Forms.TextBox txtPathOut; private System.Windows.Forms.PictureBox pictureBox1; - } + } } \ No newline at end of file diff --git a/OpenRA.Editor/MapSelect.cs b/OpenRA.Editor/MapSelect.cs index 1c09892264..a732a4e07b 100644 --- a/OpenRA.Editor/MapSelect.cs +++ b/OpenRA.Editor/MapSelect.cs @@ -17,68 +17,68 @@ using System.Linq; namespace OpenRA.Editor { - public partial class MapSelect : Form - { - public string MapFolderPath; + public partial class MapSelect : Form + { + public string MapFolderPath; - public MapSelect(string currentMod) - { - MapFolderPath = new string[] { Environment.CurrentDirectory, "mods", currentMod, "maps" } + public MapSelect(string currentMod) + { + MapFolderPath = new string[] { Environment.CurrentDirectory, "mods", currentMod, "maps" } .Aggregate(Path.Combine); InitializeComponent(); MapIconsList.Images.Add(pictureBox1.Image); - } + } - void MapSelect_Load(object sender, EventArgs e) - { - MapList.Items.Clear(); - txtPathOut.Text = MapFolderPath; + void MapSelect_Load(object sender, EventArgs e) + { + MapList.Items.Clear(); + txtPathOut.Text = MapFolderPath; - foreach (var map in ModData.FindMapsIn(MapFolderPath)) - { - ListViewItem map1 = new ListViewItem(); + foreach (var map in ModData.FindMapsIn(MapFolderPath)) + { + ListViewItem map1 = new ListViewItem(); map1.Tag = map; map1.Text = Path.GetFileNameWithoutExtension(map); - map1.ImageIndex = 0; - MapList.Items.Add(map1); - } + map1.ImageIndex = 0; + MapList.Items.Add(map1); + } // hack if (txtNew.Text != "unnamed") - MapList.Items[0].Selected = true; - } + MapList.Items[0].Selected = true; + } - void MapList_SelectedIndexChanged(object sender, EventArgs e) - { - if (MapList.SelectedItems.Count == 1) - { - txtNew.Text = MapList.SelectedItems[0].Text; + void MapList_SelectedIndexChanged(object sender, EventArgs e) + { + if (MapList.SelectedItems.Count == 1) + { + txtNew.Text = MapList.SelectedItems[0].Text; txtNew.Tag = MapList.SelectedItems[0].Tag; var map = new Map(txtNew.Tag as string); - txtTitle.Text = map.Title; - txtAuthor.Text = map.Author; - txtTheater.Text = map.Tileset; - txtDesc.Text = map.Description; + txtTitle.Text = map.Title; + txtAuthor.Text = map.Author; + txtTheater.Text = map.Tileset; + txtDesc.Text = map.Description; pbMinimap.Image = null; - try - { + try + { pbMinimap.Image = Minimap.AddStaticResources(map, Minimap.TerrainBitmap(map, true)); - } - catch (Exception ed) - { - Console.WriteLine("No map preview image found: {0}", ed.ToString()); - } - finally { } - } - } + } + catch (Exception ed) + { + Console.WriteLine("No map preview image found: {0}", ed.ToString()); + } + finally { } + } + } - void txtPathOut_TextChanged(object sender, EventArgs e) - { - MapFolderPath = txtPathOut.Text; - } + void txtPathOut_TextChanged(object sender, EventArgs e) + { + MapFolderPath = txtPathOut.Text; + } - } + } } diff --git a/OpenRA.Editor/NewMapDialog.Designer.cs b/OpenRA.Editor/NewMapDialog.Designer.cs index 00407886fa..a7b8168bd2 100755 --- a/OpenRA.Editor/NewMapDialog.Designer.cs +++ b/OpenRA.Editor/NewMapDialog.Designer.cs @@ -110,118 +110,118 @@ namespace OpenRA.Editor // this.cordonBottom.Location = new System.Drawing.Point(280, 75); this.cordonBottom.Maximum = new decimal(new int[] { - 2048, - 0, - 0, - 0}); + 2048, + 0, + 0, + 0}); this.cordonBottom.Name = "cordonBottom"; this.cordonBottom.Size = new System.Drawing.Size(105, 20); this.cordonBottom.TabIndex = 5; this.cordonBottom.Value = new decimal(new int[] { - 112, - 0, - 0, - 0}); + 112, + 0, + 0, + 0}); this.cordonBottom.Enter += new System.EventHandler(this.SelectText); // // cordonTop // this.cordonTop.Location = new System.Drawing.Point(280, 49); this.cordonTop.Maximum = new decimal(new int[] { - 2048, - 0, - 0, - 0}); + 2048, + 0, + 0, + 0}); this.cordonTop.Name = "cordonTop"; this.cordonTop.Size = new System.Drawing.Size(105, 20); this.cordonTop.TabIndex = 3; this.cordonTop.Value = new decimal(new int[] { - 16, - 0, - 0, - 0}); + 16, + 0, + 0, + 0}); this.cordonTop.Enter += new System.EventHandler(this.SelectText); // // cordonRight // this.cordonRight.Location = new System.Drawing.Point(169, 75); this.cordonRight.Maximum = new decimal(new int[] { - 2048, - 0, - 0, - 0}); + 2048, + 0, + 0, + 0}); this.cordonRight.Name = "cordonRight"; this.cordonRight.Size = new System.Drawing.Size(105, 20); this.cordonRight.TabIndex = 4; this.cordonRight.Value = new decimal(new int[] { - 112, - 0, - 0, - 0}); + 112, + 0, + 0, + 0}); this.cordonRight.Enter += new System.EventHandler(this.SelectText); // // cordonLeft // this.cordonLeft.Location = new System.Drawing.Point(169, 49); this.cordonLeft.Maximum = new decimal(new int[] { - 2048, - 0, - 0, - 0}); + 2048, + 0, + 0, + 0}); this.cordonLeft.Name = "cordonLeft"; this.cordonLeft.Size = new System.Drawing.Size(105, 20); this.cordonLeft.TabIndex = 2; this.cordonLeft.Value = new decimal(new int[] { - 16, - 0, - 0, - 0}); + 16, + 0, + 0, + 0}); this.cordonLeft.Enter += new System.EventHandler(this.SelectText); // // height // this.height.Increment = new decimal(new int[] { - 8, - 0, - 0, - 0}); + 8, + 0, + 0, + 0}); this.height.Location = new System.Drawing.Point(280, 23); this.height.Maximum = new decimal(new int[] { - 2048, - 0, - 0, - 0}); + 2048, + 0, + 0, + 0}); this.height.Name = "height"; this.height.Size = new System.Drawing.Size(105, 20); this.height.TabIndex = 1; this.height.Value = new decimal(new int[] { - 128, - 0, - 0, - 0}); + 128, + 0, + 0, + 0}); this.height.Enter += new System.EventHandler(this.SelectText); // // width // this.width.Increment = new decimal(new int[] { - 8, - 0, - 0, - 0}); + 8, + 0, + 0, + 0}); this.width.Location = new System.Drawing.Point(169, 23); this.width.Maximum = new decimal(new int[] { - 2048, - 0, - 0, - 0}); + 2048, + 0, + 0, + 0}); this.width.Name = "width"; this.width.Size = new System.Drawing.Size(105, 20); this.width.TabIndex = 0; this.width.Value = new decimal(new int[] { - 128, - 0, - 0, - 0}); + 128, + 0, + 0, + 0}); this.width.Enter += new System.EventHandler(this.SelectText); // // label4 diff --git a/OpenRA.Editor/Program.cs b/OpenRA.Editor/Program.cs index 2e44ff1f13..a3bdf2c24a 100644 --- a/OpenRA.Editor/Program.cs +++ b/OpenRA.Editor/Program.cs @@ -44,15 +44,15 @@ namespace OpenRA.Editor .Aggregate(Path.Combine); foreach (var path in ModData.FindMapsIn(MapFolderPath)) - { - var map = new Map(path); + { + var map = new Map(path); // Touch the lazy bits to initialize them - map.Actors.Force(); - map.Smudges.Force(); - map.MapTiles.Force(); - map.MapResources.Force(); + map.Actors.Force(); + map.Smudges.Force(); + map.MapTiles.Force(); + map.MapResources.Force(); map.Save(path); - } + } } } diff --git a/OpenRA.Editor/PropertiesDialog.Designer.cs b/OpenRA.Editor/PropertiesDialog.Designer.cs index 57c72ff325..a1bbe31d03 100644 --- a/OpenRA.Editor/PropertiesDialog.Designer.cs +++ b/OpenRA.Editor/PropertiesDialog.Designer.cs @@ -38,131 +38,131 @@ namespace OpenRA.Editor /// private void InitializeComponent() { - this.button2 = new System.Windows.Forms.Button(); - this.button1 = new System.Windows.Forms.Button(); - this.label1 = new System.Windows.Forms.Label(); - this.title = new System.Windows.Forms.TextBox(); - this.label2 = new System.Windows.Forms.Label(); - this.desc = new System.Windows.Forms.TextBox(); - this.selectable = new System.Windows.Forms.CheckBox(); - this.label3 = new System.Windows.Forms.Label(); - this.author = new System.Windows.Forms.TextBox(); - this.useAsShellmap = new System.Windows.Forms.CheckBox(); - this.SuspendLayout(); - // - // button2 - // - this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.button2.DialogResult = System.Windows.Forms.DialogResult.OK; - this.button2.Location = new System.Drawing.Point(196, 193); - this.button2.Name = "button2"; - this.button2.Size = new System.Drawing.Size(75, 23); - this.button2.TabIndex = 14; - this.button2.Text = "OK"; - this.button2.UseVisualStyleBackColor = true; - // - // button1 - // - this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.button1.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.button1.Location = new System.Drawing.Point(277, 193); - this.button1.Name = "button1"; - this.button1.Size = new System.Drawing.Size(75, 23); - this.button1.TabIndex = 15; - this.button1.Text = "Cancel"; - this.button1.UseVisualStyleBackColor = true; - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(12, 50); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(27, 13); - this.label1.TabIndex = 16; - this.label1.Text = "Title"; - // - // title - // - this.title.Location = new System.Drawing.Point(66, 47); - this.title.Name = "title"; - this.title.Size = new System.Drawing.Size(286, 20); - this.title.TabIndex = 17; - // - // label2 - // - this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(12, 76); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(32, 13); - this.label2.TabIndex = 16; - this.label2.Text = "Desc"; - // - // desc - // - this.desc.Location = new System.Drawing.Point(66, 73); - this.desc.Name = "desc"; - this.desc.Size = new System.Drawing.Size(286, 20); - this.desc.TabIndex = 17; - // - // selectable - // - this.selectable.AutoSize = true; - this.selectable.Location = new System.Drawing.Point(118, 138); - this.selectable.Name = "selectable"; - this.selectable.Size = new System.Drawing.Size(130, 17); - this.selectable.TabIndex = 18; - this.selectable.Text = "Show in Map Chooser"; - this.selectable.UseVisualStyleBackColor = true; - // - // label3 - // - this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(12, 102); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(38, 13); - this.label3.TabIndex = 16; - this.label3.Text = "Author"; - // - // author - // - this.author.Location = new System.Drawing.Point(66, 99); - this.author.Name = "author"; - this.author.Size = new System.Drawing.Size(286, 20); - this.author.TabIndex = 17; - // - // checkBox1 - // - this.useAsShellmap.AutoSize = true; - this.useAsShellmap.Location = new System.Drawing.Point(118, 161); - this.useAsShellmap.Name = "checkBox1"; - this.useAsShellmap.Size = new System.Drawing.Size(105, 17); - this.useAsShellmap.TabIndex = 18; - this.useAsShellmap.Text = "Use as Shellmap"; - this.useAsShellmap.UseVisualStyleBackColor = true; - // - // PropertiesDialog - // - this.AcceptButton = this.button2; - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.CancelButton = this.button1; - this.ClientSize = new System.Drawing.Size(370, 228); - this.Controls.Add(this.useAsShellmap); - this.Controls.Add(this.selectable); - this.Controls.Add(this.author); - this.Controls.Add(this.label3); - this.Controls.Add(this.desc); - this.Controls.Add(this.label2); - this.Controls.Add(this.title); - this.Controls.Add(this.label1); - this.Controls.Add(this.button2); - this.Controls.Add(this.button1); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.Name = "PropertiesDialog"; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "PropertiesDialog"; - this.ResumeLayout(false); - this.PerformLayout(); + this.button2 = new System.Windows.Forms.Button(); + this.button1 = new System.Windows.Forms.Button(); + this.label1 = new System.Windows.Forms.Label(); + this.title = new System.Windows.Forms.TextBox(); + this.label2 = new System.Windows.Forms.Label(); + this.desc = new System.Windows.Forms.TextBox(); + this.selectable = new System.Windows.Forms.CheckBox(); + this.label3 = new System.Windows.Forms.Label(); + this.author = new System.Windows.Forms.TextBox(); + this.useAsShellmap = new System.Windows.Forms.CheckBox(); + this.SuspendLayout(); + // + // button2 + // + this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.button2.DialogResult = System.Windows.Forms.DialogResult.OK; + this.button2.Location = new System.Drawing.Point(196, 193); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(75, 23); + this.button2.TabIndex = 14; + this.button2.Text = "OK"; + this.button2.UseVisualStyleBackColor = true; + // + // button1 + // + this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.button1.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.button1.Location = new System.Drawing.Point(277, 193); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(75, 23); + this.button1.TabIndex = 15; + this.button1.Text = "Cancel"; + this.button1.UseVisualStyleBackColor = true; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(12, 50); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(27, 13); + this.label1.TabIndex = 16; + this.label1.Text = "Title"; + // + // title + // + this.title.Location = new System.Drawing.Point(66, 47); + this.title.Name = "title"; + this.title.Size = new System.Drawing.Size(286, 20); + this.title.TabIndex = 17; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(12, 76); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(32, 13); + this.label2.TabIndex = 16; + this.label2.Text = "Desc"; + // + // desc + // + this.desc.Location = new System.Drawing.Point(66, 73); + this.desc.Name = "desc"; + this.desc.Size = new System.Drawing.Size(286, 20); + this.desc.TabIndex = 17; + // + // selectable + // + this.selectable.AutoSize = true; + this.selectable.Location = new System.Drawing.Point(118, 138); + this.selectable.Name = "selectable"; + this.selectable.Size = new System.Drawing.Size(130, 17); + this.selectable.TabIndex = 18; + this.selectable.Text = "Show in Map Chooser"; + this.selectable.UseVisualStyleBackColor = true; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(12, 102); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(38, 13); + this.label3.TabIndex = 16; + this.label3.Text = "Author"; + // + // author + // + this.author.Location = new System.Drawing.Point(66, 99); + this.author.Name = "author"; + this.author.Size = new System.Drawing.Size(286, 20); + this.author.TabIndex = 17; + // + // checkBox1 + // + this.useAsShellmap.AutoSize = true; + this.useAsShellmap.Location = new System.Drawing.Point(118, 161); + this.useAsShellmap.Name = "checkBox1"; + this.useAsShellmap.Size = new System.Drawing.Size(105, 17); + this.useAsShellmap.TabIndex = 18; + this.useAsShellmap.Text = "Use as Shellmap"; + this.useAsShellmap.UseVisualStyleBackColor = true; + // + // PropertiesDialog + // + this.AcceptButton = this.button2; + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.CancelButton = this.button1; + this.ClientSize = new System.Drawing.Size(370, 228); + this.Controls.Add(this.useAsShellmap); + this.Controls.Add(this.selectable); + this.Controls.Add(this.author); + this.Controls.Add(this.label3); + this.Controls.Add(this.desc); + this.Controls.Add(this.label2); + this.Controls.Add(this.title); + this.Controls.Add(this.label1); + this.Controls.Add(this.button2); + this.Controls.Add(this.button1); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.Name = "PropertiesDialog"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "PropertiesDialog"; + this.ResumeLayout(false); + this.PerformLayout(); } @@ -177,6 +177,6 @@ namespace OpenRA.Editor public System.Windows.Forms.CheckBox selectable; private System.Windows.Forms.Label label3; public System.Windows.Forms.TextBox author; - public System.Windows.Forms.CheckBox useAsShellmap; + public System.Windows.Forms.CheckBox useAsShellmap; } } \ No newline at end of file diff --git a/OpenRA.Editor/RenderUtils.cs b/OpenRA.Editor/RenderUtils.cs index 8dcf4543a8..df62f0730f 100644 --- a/OpenRA.Editor/RenderUtils.cs +++ b/OpenRA.Editor/RenderUtils.cs @@ -45,9 +45,9 @@ namespace OpenRA.Editor public static ActorTemplate RenderActor(ActorInfo info, TileSet tileset, Palette p) { - var image = RenderSimple.GetImage(info); + var image = RenderSimple.GetImage(info); - using (var s = FileSystem.OpenWithExts(image, tileset.Extensions)) + using (var s = FileSystem.OpenWithExts(image, tileset.Extensions)) { var shp = new ShpReader(s); var bitmap = RenderShp(shp, p); diff --git a/OpenRA.Editor/ResizeDialog.Designer.cs b/OpenRA.Editor/ResizeDialog.Designer.cs index 8be0f50a06..1d2e7233c7 100644 --- a/OpenRA.Editor/ResizeDialog.Designer.cs +++ b/OpenRA.Editor/ResizeDialog.Designer.cs @@ -60,16 +60,16 @@ namespace OpenRA.Editor // width // this.width.Increment = new decimal(new int[] { - 8, - 0, - 0, - 0}); + 8, + 0, + 0, + 0}); this.width.Location = new System.Drawing.Point(161, 18); this.width.Maximum = new decimal(new int[] { - 2048, - 0, - 0, - 0}); + 2048, + 0, + 0, + 0}); this.width.Name = "width"; this.width.Size = new System.Drawing.Size(105, 20); this.width.TabIndex = 0; @@ -96,10 +96,10 @@ namespace OpenRA.Editor // this.cordonLeft.Location = new System.Drawing.Point(161, 44); this.cordonLeft.Maximum = new decimal(new int[] { - 2048, - 0, - 0, - 0}); + 2048, + 0, + 0, + 0}); this.cordonLeft.Name = "cordonLeft"; this.cordonLeft.Size = new System.Drawing.Size(105, 20); this.cordonLeft.TabIndex = 0; @@ -108,10 +108,10 @@ namespace OpenRA.Editor // this.cordonTop.Location = new System.Drawing.Point(272, 44); this.cordonTop.Maximum = new decimal(new int[] { - 2048, - 0, - 0, - 0}); + 2048, + 0, + 0, + 0}); this.cordonTop.Name = "cordonTop"; this.cordonTop.Size = new System.Drawing.Size(105, 20); this.cordonTop.TabIndex = 0; @@ -120,10 +120,10 @@ namespace OpenRA.Editor // this.cordonRight.Location = new System.Drawing.Point(161, 70); this.cordonRight.Maximum = new decimal(new int[] { - 2048, - 0, - 0, - 0}); + 2048, + 0, + 0, + 0}); this.cordonRight.Name = "cordonRight"; this.cordonRight.Size = new System.Drawing.Size(105, 20); this.cordonRight.TabIndex = 0; @@ -132,10 +132,10 @@ namespace OpenRA.Editor // this.cordonBottom.Location = new System.Drawing.Point(272, 70); this.cordonBottom.Maximum = new decimal(new int[] { - 2048, - 0, - 0, - 0}); + 2048, + 0, + 0, + 0}); this.cordonBottom.Name = "cordonBottom"; this.cordonBottom.Size = new System.Drawing.Size(105, 20); this.cordonBottom.TabIndex = 0; @@ -172,16 +172,16 @@ namespace OpenRA.Editor // height // this.height.Increment = new decimal(new int[] { - 8, - 0, - 0, - 0}); + 8, + 0, + 0, + 0}); this.height.Location = new System.Drawing.Point(272, 18); this.height.Maximum = new decimal(new int[] { - 2048, - 0, - 0, - 0}); + 2048, + 0, + 0, + 0}); this.height.Name = "height"; this.height.Size = new System.Drawing.Size(105, 20); this.height.TabIndex = 0; diff --git a/OpenRA.FileFormats/ColorRamp.cs b/OpenRA.FileFormats/ColorRamp.cs index 67e94b3754..982b3e2489 100644 --- a/OpenRA.FileFormats/ColorRamp.cs +++ b/OpenRA.FileFormats/ColorRamp.cs @@ -12,27 +12,27 @@ using System.Drawing; namespace OpenRA.FileFormats { - public struct ColorRamp - { - public byte H,S,L,R; + public struct ColorRamp + { + public byte H,S,L,R; - public ColorRamp(byte h, byte s, byte l, byte r) - { - H = h; S = s; L = l; R = r; - } + public ColorRamp(byte h, byte s, byte l, byte r) + { + H = h; S = s; L = l; R = r; + } - /* returns a color along the Lum ramp */ - public Color GetColor( float t ) - { - return ColorFromHSL( H / 255f, S / 255f, float2.Lerp( L / 255f, L*R / (255f * 255f), t ) ); - } + /* returns a color along the Lum ramp */ + public Color GetColor( float t ) + { + return ColorFromHSL( H / 255f, S / 255f, float2.Lerp( L / 255f, L*R / (255f * 255f), t ) ); + } - public override string ToString() - { - return "{0},{1},{2},{3}".F(H, S, L, R); - } + public override string ToString() + { + return "{0},{1},{2},{3}".F(H, S, L, R); + } - // hk is hue in the range [0,1] instead of [0,360] + // hk is hue in the range [0,1] instead of [0,360] public static Color ColorFromHSL(float hk, float s, float l) { // Convert from HSL to RGB @@ -60,5 +60,5 @@ namespace OpenRA.FileFormats return Color.FromArgb((int)(rgb[0] * 255), (int)(rgb[1] * 255), (int)(rgb[2] * 255)); } - } + } } diff --git a/OpenRA.FileFormats/Exts.cs b/OpenRA.FileFormats/Exts.cs index 7a379663d5..117a6c61a2 100755 --- a/OpenRA.FileFormats/Exts.cs +++ b/OpenRA.FileFormats/Exts.cs @@ -113,10 +113,10 @@ namespace OpenRA return r.Contains(p.ToPointF()); } - public static bool HasModifier(this Modifiers k, Modifiers mod) - { - return (k & mod) == mod; - } + public static bool HasModifier(this Modifiers k, Modifiers mod) + { + return (k & mod) == mod; + } public static bool IsValidInput(this KeyInput key) { @@ -125,36 +125,36 @@ namespace OpenRA char.IsPunctuation(key.UnicodeChar); } - public static V GetOrAdd(this Dictionary d, K k) - where V : new() - { - return d.GetOrAdd(k, _ => new V()); - } + public static V GetOrAdd(this Dictionary d, K k) + where V : new() + { + return d.GetOrAdd(k, _ => new V()); + } - public static V GetOrAdd(this Dictionary d, K k, Func createFn) - { - V ret; - if (!d.TryGetValue(k, out ret)) - d.Add(k, ret = createFn(k)); - return ret; - } + public static V GetOrAdd(this Dictionary d, K k, Func createFn) + { + V ret; + if (!d.TryGetValue(k, out ret)) + d.Add(k, ret = createFn(k)); + return ret; + } - public static T Random(this IEnumerable ts, Thirdparty.Random r) - { - var xs = ts.ToArray(); - return xs[r.Next(xs.Length)]; - } + public static T Random(this IEnumerable ts, Thirdparty.Random r) + { + var xs = ts.ToArray(); + return xs[r.Next(xs.Length)]; + } - public static float Product(this IEnumerable xs) - { - return xs.Aggregate(1f, (a, x) => a * x); - } + public static float Product(this IEnumerable xs) + { + return xs.Aggregate(1f, (a, x) => a * x); + } - public static IEnumerable SymmetricDifference(this IEnumerable xs, IEnumerable ys) - { - // this is probably a shockingly-slow way to do this, but it's concise. - return xs.Except(ys).Concat(ys.Except(xs)); - } + public static IEnumerable SymmetricDifference(this IEnumerable xs, IEnumerable ys) + { + // this is probably a shockingly-slow way to do this, but it's concise. + return xs.Except(ys).Concat(ys.Except(xs)); + } public static IEnumerable Iterate( this T t, Func f ) { diff --git a/OpenRA.FileFormats/FieldLoader.cs b/OpenRA.FileFormats/FieldLoader.cs index 482300f101..ba2f182bf2 100755 --- a/OpenRA.FileFormats/FieldLoader.cs +++ b/OpenRA.FileFormats/FieldLoader.cs @@ -143,63 +143,63 @@ namespace OpenRA.FileFormats return InvalidValueAction(x,fieldType, field); } - else if (fieldType == typeof(ColorRamp)) - { - var parts = x.Split(','); - if (parts.Length == 4) - return new ColorRamp( - (byte)int.Parse(parts[0]).Clamp(0, 255), - (byte)int.Parse(parts[1]).Clamp(0, 255), - (byte)int.Parse(parts[2]).Clamp(0, 255), - (byte)int.Parse(parts[3]).Clamp(0, 255)); + else if (fieldType == typeof(ColorRamp)) + { + var parts = x.Split(','); + if (parts.Length == 4) + return new ColorRamp( + (byte)int.Parse(parts[0]).Clamp(0, 255), + (byte)int.Parse(parts[1]).Clamp(0, 255), + (byte)int.Parse(parts[2]).Clamp(0, 255), + (byte)int.Parse(parts[3]).Clamp(0, 255)); - return InvalidValueAction(x, fieldType, field); - } + return InvalidValueAction(x, fieldType, field); + } - else if (fieldType.IsEnum) - { - if (!Enum.GetNames(fieldType).Select(a => a.ToLower()).Contains(x.ToLower())) - return InvalidValueAction(x, fieldType, field); - return Enum.Parse(fieldType, x, true); - } + else if (fieldType.IsEnum) + { + if (!Enum.GetNames(fieldType).Select(a => a.ToLower()).Contains(x.ToLower())) + return InvalidValueAction(x, fieldType, field); + return Enum.Parse(fieldType, x, true); + } - else if (fieldType == typeof(bool)) - return ParseYesNo(x, fieldType, field); + else if (fieldType == typeof(bool)) + return ParseYesNo(x, fieldType, field); - else if (fieldType.IsArray) - { - if (x == null) - return Array.CreateInstance(fieldType.GetElementType(), 0); + else if (fieldType.IsArray) + { + if (x == null) + return Array.CreateInstance(fieldType.GetElementType(), 0); - var parts = x.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); + var parts = x.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); - var ret = Array.CreateInstance(fieldType.GetElementType(), parts.Length); - for (int i = 0; i < parts.Length; i++) - ret.SetValue(GetValue(field, fieldType.GetElementType(), parts[i].Trim()), i); - return ret; - } - else if (fieldType == typeof(int2)) - { - var parts = x.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); - return new int2(int.Parse(parts[0]), int.Parse(parts[1])); - } - else if (fieldType == typeof(float2)) - { - var parts = x.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); - float xx = 0; - float yy = 0; - float res; - if (float.TryParse(parts[0].Replace("%", ""), out res)) - xx = res * (parts[0].Contains('%') ? 0.01f : 1f); - if (float.TryParse(parts[1].Replace("%", ""), out res)) - yy = res * (parts[1].Contains('%') ? 0.01f : 1f); - return new float2(xx, yy); - } + var ret = Array.CreateInstance(fieldType.GetElementType(), parts.Length); + for (int i = 0; i < parts.Length; i++) + ret.SetValue(GetValue(field, fieldType.GetElementType(), parts[i].Trim()), i); + return ret; + } + else if (fieldType == typeof(int2)) + { + var parts = x.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); + return new int2(int.Parse(parts[0]), int.Parse(parts[1])); + } + else if (fieldType == typeof(float2)) + { + var parts = x.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); + float xx = 0; + float yy = 0; + float res; + if (float.TryParse(parts[0].Replace("%", ""), out res)) + xx = res * (parts[0].Contains('%') ? 0.01f : 1f); + if (float.TryParse(parts[1].Replace("%", ""), out res)) + yy = res * (parts[1].Contains('%') ? 0.01f : 1f); + return new float2(xx, yy); + } else if (fieldType == typeof(Rectangle)) - { - var parts = x.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); - return new Rectangle(int.Parse(parts[0]), int.Parse(parts[1]), int.Parse(parts[2]), int.Parse(parts[3])); - } + { + var parts = x.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); + return new Rectangle(int.Parse(parts[0]), int.Parse(parts[1]), int.Parse(parts[2]), int.Parse(parts[3])); + } else if (fieldType.IsGenericType && fieldType.GetGenericTypeDefinition() == typeof(Bits<>)) { var parts = x.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); diff --git a/OpenRA.FileFormats/FileFormats/Blast.cs b/OpenRA.FileFormats/FileFormats/Blast.cs index a3049b0225..7f7518602d 100644 --- a/OpenRA.FileFormats/FileFormats/Blast.cs +++ b/OpenRA.FileFormats/FileFormats/Blast.cs @@ -182,13 +182,13 @@ namespace OpenRA.FileFormats class BitReader { readonly byte[] src; - int offset = 0; + int offset = 0; int bitBuffer = 0; int bitCount = 0; public BitReader(byte[] src) { - this.src = src; + this.src = src; } public int ReadBits(int count) diff --git a/OpenRA.FileFormats/FileFormats/BlowfishKeyProvider.cs b/OpenRA.FileFormats/FileFormats/BlowfishKeyProvider.cs index ad3d7e355f..301da73330 100644 --- a/OpenRA.FileFormats/FileFormats/BlowfishKeyProvider.cs +++ b/OpenRA.FileFormats/FileFormats/BlowfishKeyProvider.cs @@ -13,516 +13,516 @@ using System.Linq; namespace OpenRA.FileFormats { - /* possibly the fugliest C# i've ever seen. */ + /* possibly the fugliest C# i've ever seen. */ - class BlowfishKeyProvider - { - const string pubkeyStr = "AihRvNoIbTn85FZRYNZRcT+i6KpU+maCsEqr3Q5q+LDB5tH7Tz2qQ38V"; + class BlowfishKeyProvider + { + const string pubkeyStr = "AihRvNoIbTn85FZRYNZRcT+i6KpU+maCsEqr3Q5q+LDB5tH7Tz2qQ38V"; - static sbyte[] char2num = { - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63, - 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1, - -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, - -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, - 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}; + static sbyte[] char2num = { + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63, + 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1, + -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, + -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, + 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}; - class PublicKey - { - public uint[] key1 = new uint[64]; - public uint[] key2 = new uint[64]; - public uint len; - } - PublicKey pubkey = new PublicKey(); + class PublicKey + { + public uint[] key1 = new uint[64]; + public uint[] key2 = new uint[64]; + public uint len; + } + PublicKey pubkey = new PublicKey(); - uint[] glob1 = new uint[64]; - uint glob1_bitlen, glob1_len_x2; - uint[] glob2 = new uint[130]; - uint[] glob1_hi = new uint[4]; - uint[] glob1_hi_inv = new uint[4]; - uint glob1_hi_bitlen; - uint glob1_hi_inv_lo, glob1_hi_inv_hi; + uint[] glob1 = new uint[64]; + uint glob1_bitlen, glob1_len_x2; + uint[] glob2 = new uint[130]; + uint[] glob1_hi = new uint[4]; + uint[] glob1_hi_inv = new uint[4]; + uint glob1_hi_bitlen; + uint glob1_hi_inv_lo, glob1_hi_inv_hi; - void init_bignum(uint[] n, uint val, uint len) - { - for (int i = 0; i < len; i++) n[i] = 0; - n[0] = val; - } + void init_bignum(uint[] n, uint val, uint len) + { + for (int i = 0; i < len; i++) n[i] = 0; + n[0] = val; + } - void move_key_to_big(uint[] n, byte[] key, uint klen, uint blen) - { - byte sign; + void move_key_to_big(uint[] n, byte[] key, uint klen, uint blen) + { + byte sign; - if ((key[0] & 0x80) != 0) sign = 0xff; - else sign = 0; + if ((key[0] & 0x80) != 0) sign = 0xff; + else sign = 0; - unsafe - { - fixed (uint* _pn = &n[0]) - { - byte* pn = (byte*)_pn; - uint i = blen * 4; - for (; i > klen; i--) pn[i - 1] = (byte)sign; - for (; i > 0; i--) pn[i - 1] = key[klen - i]; - } - } - } + unsafe + { + fixed (uint* _pn = &n[0]) + { + byte* pn = (byte*)_pn; + uint i = blen * 4; + for (; i > klen; i--) pn[i - 1] = (byte)sign; + for (; i > 0; i--) pn[i - 1] = key[klen - i]; + } + } + } - void key_to_bignum(uint[] n, byte[] key, uint len) - { - uint keylen; - int i; + void key_to_bignum(uint[] n, byte[] key, uint len) + { + uint keylen; + int i; - int j = 0; + int j = 0; - if (key[j] != 2) return; - j++; + if (key[j] != 2) return; + j++; - if ((key[j] & 0x80) != 0) - { - keylen = 0; - for (i = 0; i < (key[j] & 0x7f); i++) keylen = (keylen << 8) | key[j + i + 1]; - j += (key[j] & 0x7f) + 1; - } - else - { - keylen = key[j]; - j++; - } - if (keylen <= len * 4) - move_key_to_big(n, key.Skip(j).ToArray(), keylen, len); - } + if ((key[j] & 0x80) != 0) + { + keylen = 0; + for (i = 0; i < (key[j] & 0x7f); i++) keylen = (keylen << 8) | key[j + i + 1]; + j += (key[j] & 0x7f) + 1; + } + else + { + keylen = key[j]; + j++; + } + if (keylen <= len * 4) + move_key_to_big(n, key.Skip(j).ToArray(), keylen, len); + } - uint len_bignum(uint[] n, uint len) - { - uint i; - i = len - 1; - while ((i >= 0) && (n[i] == 0)) i--; - return i + 1; - } + uint len_bignum(uint[] n, uint len) + { + uint i; + i = len - 1; + while ((i >= 0) && (n[i] == 0)) i--; + return i + 1; + } - uint bitlen_bignum(uint[] n, uint len) - { - uint ddlen, bitlen, mask; - ddlen = len_bignum(n, len); - if (ddlen == 0) return 0; - bitlen = ddlen * 32; - mask = 0x80000000; - while ((mask & n[ddlen - 1]) == 0) - { - mask >>= 1; - bitlen--; - } - return bitlen; - } + uint bitlen_bignum(uint[] n, uint len) + { + uint ddlen, bitlen, mask; + ddlen = len_bignum(n, len); + if (ddlen == 0) return 0; + bitlen = ddlen * 32; + mask = 0x80000000; + while ((mask & n[ddlen - 1]) == 0) + { + mask >>= 1; + bitlen--; + } + return bitlen; + } - void init_pubkey() - { - int i = 0; - uint i2, tmp; - byte[] keytmp = new byte[256]; + void init_pubkey() + { + int i = 0; + uint i2, tmp; + byte[] keytmp = new byte[256]; - init_bignum(pubkey.key2, 0x10001, 64); + init_bignum(pubkey.key2, 0x10001, 64); - i2 = 0; - while (i < pubkeyStr.Length) - { - tmp = (uint)char2num[pubkeyStr[i++]]; - tmp <<= 6; tmp |= (uint)(byte)char2num[pubkeyStr[i++]]; - tmp <<= 6; tmp |= (uint)(byte)char2num[pubkeyStr[i++]]; - tmp <<= 6; tmp |= (uint)(byte)char2num[pubkeyStr[i++]]; - keytmp[i2++] = (byte)((tmp >> 16) & 0xff); - keytmp[i2++] = (byte)((tmp >> 8) & 0xff); - keytmp[i2++] = (byte)(tmp & 0xff); - } + i2 = 0; + while (i < pubkeyStr.Length) + { + tmp = (uint)char2num[pubkeyStr[i++]]; + tmp <<= 6; tmp |= (uint)(byte)char2num[pubkeyStr[i++]]; + tmp <<= 6; tmp |= (uint)(byte)char2num[pubkeyStr[i++]]; + tmp <<= 6; tmp |= (uint)(byte)char2num[pubkeyStr[i++]]; + keytmp[i2++] = (byte)((tmp >> 16) & 0xff); + keytmp[i2++] = (byte)((tmp >> 8) & 0xff); + keytmp[i2++] = (byte)(tmp & 0xff); + } - key_to_bignum(pubkey.key1, keytmp, 64); - pubkey.len = bitlen_bignum(pubkey.key1, 64) - 1; - } + key_to_bignum(pubkey.key1, keytmp, 64); + pubkey.len = bitlen_bignum(pubkey.key1, 64) - 1; + } - uint len_predata() - { - uint a = (pubkey.len - 1) / 8; - return (55 / a + 1) * (a + 1); - } + uint len_predata() + { + uint a = (pubkey.len - 1) / 8; + return (55 / a + 1) * (a + 1); + } - int cmp_bignum(uint[] n1, uint[] n2, uint len) - { + int cmp_bignum(uint[] n1, uint[] n2, uint len) + { - while (len > 0) - { - --len; - if (n1[len] < n2[len]) return -1; - if (n1[len] > n2[len]) return 1; - } - return 0; - } + while (len > 0) + { + --len; + if (n1[len] < n2[len]) return -1; + if (n1[len] > n2[len]) return 1; + } + return 0; + } - void mov_bignum(uint[] dest, uint[] src, uint len) - { - Array.Copy(src, dest, len); - } + void mov_bignum(uint[] dest, uint[] src, uint len) + { + Array.Copy(src, dest, len); + } - void shr_bignum(uint[] n, int bits, int len) - { - int i; int i2 = bits / 32; + void shr_bignum(uint[] n, int bits, int len) + { + int i; int i2 = bits / 32; - if (i2 > 0) - { - for (i = 0; i < len - i2; i++) n[i] = n[i + i2]; - for (; i < len; i++) n[i] = 0; - bits = bits % 32; - } - if (bits == 0) return; - for (i = 0; i < len - 1; i++) n[i] = (n[i] >> bits) | (n[i + 1] << (32 - - bits)); - n[i] = n[i] >> bits; - } + if (i2 > 0) + { + for (i = 0; i < len - i2; i++) n[i] = n[i + i2]; + for (; i < len; i++) n[i] = 0; + bits = bits % 32; + } + if (bits == 0) return; + for (i = 0; i < len - 1; i++) n[i] = (n[i] >> bits) | (n[i + 1] << (32 - + bits)); + n[i] = n[i] >> bits; + } - void shl_bignum(uint[] n, int bits, int len) - { - int i, i2; + void shl_bignum(uint[] n, int bits, int len) + { + int i, i2; - i2 = bits / 32; - if (i2 > 0) - { - for (i = len - 1; i > i2; i--) n[i] = n[i - i2]; - for (; i > 0; i--) n[i] = 0; - bits = bits % 32; - } - if (bits == 0) return; - for (i = len - 1; i > 0; i--) n[i] = (n[i] << bits) | (n[i - 1] >> (32 - - bits)); - n[0] <<= bits; - } + i2 = bits / 32; + if (i2 > 0) + { + for (i = len - 1; i > i2; i--) n[i] = n[i - i2]; + for (; i > 0; i--) n[i] = 0; + bits = bits % 32; + } + if (bits == 0) return; + for (i = len - 1; i > 0; i--) n[i] = (n[i] << bits) | (n[i - 1] >> (32 - + bits)); + n[0] <<= bits; + } - uint sub_bignum(uint[] dest, uint[] src1, uint[] src2, uint carry, int len) - { - uint i1, i2; + uint sub_bignum(uint[] dest, uint[] src1, uint[] src2, uint carry, int len) + { + uint i1, i2; - len += len; - unsafe - { - fixed (uint* _ps1 = &src1[0]) - fixed (uint* _ps2 = &src2[0]) - fixed (uint* _pd = &dest[0]) - { - ushort* ps1 = (ushort*)_ps1; - ushort* ps2 = (ushort*)_ps2; - ushort* pd = (ushort*)_pd; + len += len; + unsafe + { + fixed (uint* _ps1 = &src1[0]) + fixed (uint* _ps2 = &src2[0]) + fixed (uint* _pd = &dest[0]) + { + ushort* ps1 = (ushort*)_ps1; + ushort* ps2 = (ushort*)_ps2; + ushort* pd = (ushort*)_pd; - while (--len != -1) - { - i1 = *ps1++; - i2 = *ps2++; - *pd++ = (ushort)(i1 - i2 - carry); - if (((i1 - i2 - carry) & 0x10000) != 0) carry = 1; else carry = 0; - } - } - } - return carry; - } + while (--len != -1) + { + i1 = *ps1++; + i2 = *ps2++; + *pd++ = (ushort)(i1 - i2 - carry); + if (((i1 - i2 - carry) & 0x10000) != 0) carry = 1; else carry = 0; + } + } + } + return carry; + } - unsafe uint sub_bignum(uint* dest, uint* src1, uint* src2, uint carry, int len) - { - uint i1, i2; + unsafe uint sub_bignum(uint* dest, uint* src1, uint* src2, uint carry, int len) + { + uint i1, i2; - len += len; + len += len; - ushort* ps1 = (ushort*)src1; - ushort* ps2 = (ushort*)src2; - ushort* pd = (ushort*)dest; + ushort* ps1 = (ushort*)src1; + ushort* ps2 = (ushort*)src2; + ushort* pd = (ushort*)dest; - while (--len != -1) - { - i1 = *ps1++; - i2 = *ps2++; - *pd++ = (ushort)(i1 - i2 - carry); - if (((i1 - i2 - carry) & 0x10000) != 0) carry = 1; else carry = 0; + while (--len != -1) + { + i1 = *ps1++; + i2 = *ps2++; + *pd++ = (ushort)(i1 - i2 - carry); + if (((i1 - i2 - carry) & 0x10000) != 0) carry = 1; else carry = 0; - } - return carry; - } + } + return carry; + } - void inv_bignum(uint[] n1, uint[] n2, uint len) - { - uint[] n_tmp = new uint[64]; - uint n2_bytelen, bit; - int n2_bitlen; + void inv_bignum(uint[] n1, uint[] n2, uint len) + { + uint[] n_tmp = new uint[64]; + uint n2_bytelen, bit; + int n2_bitlen; - int j = 0; + int j = 0; - init_bignum(n_tmp, 0, len); - init_bignum(n1, 0, len); - n2_bitlen = (int)bitlen_bignum(n2, len); - bit = ((uint)1) << (n2_bitlen % 32); - j = ((n2_bitlen + 32) / 32) - 1; - n2_bytelen = (uint)((n2_bitlen - 1) / 32) * 4; - n_tmp[n2_bytelen / 4] |= ((uint)1) << ((n2_bitlen - 1) & 0x1f); + init_bignum(n_tmp, 0, len); + init_bignum(n1, 0, len); + n2_bitlen = (int)bitlen_bignum(n2, len); + bit = ((uint)1) << (n2_bitlen % 32); + j = ((n2_bitlen + 32) / 32) - 1; + n2_bytelen = (uint)((n2_bitlen - 1) / 32) * 4; + n_tmp[n2_bytelen / 4] |= ((uint)1) << ((n2_bitlen - 1) & 0x1f); - while (n2_bitlen > 0) - { - n2_bitlen--; - shl_bignum(n_tmp, 1, (int)len); - if (cmp_bignum(n_tmp, n2, len) != -1) - { - sub_bignum(n_tmp, n_tmp, n2, 0, (int)len); - n1[j] |= bit; - } - bit >>= 1; - if (bit == 0) - { - j--; - bit = 0x80000000; - } - } - init_bignum(n_tmp, 0, len); - } + while (n2_bitlen > 0) + { + n2_bitlen--; + shl_bignum(n_tmp, 1, (int)len); + if (cmp_bignum(n_tmp, n2, len) != -1) + { + sub_bignum(n_tmp, n_tmp, n2, 0, (int)len); + n1[j] |= bit; + } + bit >>= 1; + if (bit == 0) + { + j--; + bit = 0x80000000; + } + } + init_bignum(n_tmp, 0, len); + } - void inc_bignum(uint[] n, uint len) - { - int i = 0; - while ((++n[i] == 0) && (--len > 0)) i++; - } + void inc_bignum(uint[] n, uint len) + { + int i = 0; + while ((++n[i] == 0) && (--len > 0)) i++; + } - void init_two_dw(uint[] n, uint len) - { - mov_bignum(glob1, n, len); - glob1_bitlen = bitlen_bignum(glob1, len); - glob1_len_x2 = (glob1_bitlen + 15) / 16; - mov_bignum(glob1_hi, glob1.Skip((int)len_bignum(glob1, len) - 2).ToArray(), 2); - glob1_hi_bitlen = bitlen_bignum(glob1_hi, 2) - 32; - shr_bignum(glob1_hi, (int)glob1_hi_bitlen, 2); - inv_bignum(glob1_hi_inv, glob1_hi, 2); - shr_bignum(glob1_hi_inv, 1, 2); - glob1_hi_bitlen = (glob1_hi_bitlen + 15) % 16 + 1; - inc_bignum(glob1_hi_inv, 2); - if (bitlen_bignum(glob1_hi_inv, 2) > 32) - { - shr_bignum(glob1_hi_inv, 1, 2); - glob1_hi_bitlen--; - } - glob1_hi_inv_lo = (ushort)glob1_hi_inv[0]; - glob1_hi_inv_hi = (ushort)(glob1_hi_inv[0] >> 16); - } + void init_two_dw(uint[] n, uint len) + { + mov_bignum(glob1, n, len); + glob1_bitlen = bitlen_bignum(glob1, len); + glob1_len_x2 = (glob1_bitlen + 15) / 16; + mov_bignum(glob1_hi, glob1.Skip((int)len_bignum(glob1, len) - 2).ToArray(), 2); + glob1_hi_bitlen = bitlen_bignum(glob1_hi, 2) - 32; + shr_bignum(glob1_hi, (int)glob1_hi_bitlen, 2); + inv_bignum(glob1_hi_inv, glob1_hi, 2); + shr_bignum(glob1_hi_inv, 1, 2); + glob1_hi_bitlen = (glob1_hi_bitlen + 15) % 16 + 1; + inc_bignum(glob1_hi_inv, 2); + if (bitlen_bignum(glob1_hi_inv, 2) > 32) + { + shr_bignum(glob1_hi_inv, 1, 2); + glob1_hi_bitlen--; + } + glob1_hi_inv_lo = (ushort)glob1_hi_inv[0]; + glob1_hi_inv_hi = (ushort)(glob1_hi_inv[0] >> 16); + } - unsafe void mul_bignum_word(ushort *pn1, uint[] n2, uint mul, uint len) - { - uint i, tmp; - unsafe - { - fixed (uint* _pn2 = &n2[0]) - { - ushort* pn2 = (ushort*)_pn2; + unsafe void mul_bignum_word(ushort *pn1, uint[] n2, uint mul, uint len) + { + uint i, tmp; + unsafe + { + fixed (uint* _pn2 = &n2[0]) + { + ushort* pn2 = (ushort*)_pn2; - tmp = 0; - for (i = 0; i < len; i++) - { - tmp = mul * (*pn2) + (*pn1) + tmp; - *pn1 = (ushort)tmp; - pn1++; - pn2++; - tmp >>= 16; - } - *pn1 += (ushort)tmp; - } - } - } + tmp = 0; + for (i = 0; i < len; i++) + { + tmp = mul * (*pn2) + (*pn1) + tmp; + *pn1 = (ushort)tmp; + pn1++; + pn2++; + tmp >>= 16; + } + *pn1 += (ushort)tmp; + } + } + } - void mul_bignum(uint[] dest, uint[] src1, uint[] src2, uint len) - { - uint i; + void mul_bignum(uint[] dest, uint[] src1, uint[] src2, uint len) + { + uint i; - unsafe - { - fixed( uint * _psrc2 = &src2[0] ) - fixed(uint* _pdest = &dest[0]) - { - ushort* psrc2 = (ushort*)_psrc2; - ushort* pdest = (ushort*)_pdest; + unsafe + { + fixed( uint * _psrc2 = &src2[0] ) + fixed(uint* _pdest = &dest[0]) + { + ushort* psrc2 = (ushort*)_psrc2; + ushort* pdest = (ushort*)_pdest; - init_bignum(dest, 0, len * 2); - for (i = 0; i < len * 2; i++) - mul_bignum_word(pdest++, src1, *psrc2++, len * 2); - } - } - } + init_bignum(dest, 0, len * 2); + for (i = 0; i < len * 2; i++) + mul_bignum_word(pdest++, src1, *psrc2++, len * 2); + } + } + } - void not_bignum(uint[] n, uint len) - { - uint i; - for (i = 0; i < len; i++) n[i] = ~n[i]; - } + void not_bignum(uint[] n, uint len) + { + uint i; + for (i = 0; i < len; i++) n[i] = ~n[i]; + } - void neg_bignum(uint[] n, uint len) - { - not_bignum(n, len); - inc_bignum(n, len); - } + void neg_bignum(uint[] n, uint len) + { + not_bignum(n, len); + inc_bignum(n, len); + } - unsafe uint get_mulword(uint* n) - { - ushort* wn = (ushort*)n; - uint i = (uint)((((((((((*(wn - 1) ^ 0xffff) & 0xffff) * glob1_hi_inv_lo + 0x10000) >> 1) - + (((*(wn - 2) ^ 0xffff) * glob1_hi_inv_hi + glob1_hi_inv_hi) >> 1) + 1) - >> 16) + ((((*(wn - 1) ^ 0xffff) & 0xffff) * glob1_hi_inv_hi) >> 1) + - (((*wn ^ 0xffff) * glob1_hi_inv_lo) >> 1) + 1) >> 14) + glob1_hi_inv_hi - * (*wn ^ 0xffff) * 2) >> (int)glob1_hi_bitlen); - if (i > 0xffff) i = 0xffff; - return i & 0xffff; - } + unsafe uint get_mulword(uint* n) + { + ushort* wn = (ushort*)n; + uint i = (uint)((((((((((*(wn - 1) ^ 0xffff) & 0xffff) * glob1_hi_inv_lo + 0x10000) >> 1) + + (((*(wn - 2) ^ 0xffff) * glob1_hi_inv_hi + glob1_hi_inv_hi) >> 1) + 1) + >> 16) + ((((*(wn - 1) ^ 0xffff) & 0xffff) * glob1_hi_inv_hi) >> 1) + + (((*wn ^ 0xffff) * glob1_hi_inv_lo) >> 1) + 1) >> 14) + glob1_hi_inv_hi + * (*wn ^ 0xffff) * 2) >> (int)glob1_hi_bitlen); + if (i > 0xffff) i = 0xffff; + return i & 0xffff; + } - void dec_bignum(uint[] n, uint len) - { - int i = 0; - while ((--n[i] == 0xffffffff) && (--len > 0)) - i++; - } + void dec_bignum(uint[] n, uint len) + { + int i = 0; + while ((--n[i] == 0xffffffff) && (--len > 0)) + i++; + } - void calc_a_bignum(uint[] n1, uint[] n2, uint[] n3, uint len) - { - uint g2_len_x2, len_diff; - unsafe - { - fixed( uint* g1 = &glob1[0]) - fixed (uint* g2 = &glob2[0]) - { - mul_bignum(glob2, n2, n3, len); - glob2[len * 2] = 0; - g2_len_x2 = len_bignum(glob2, len * 2 + 1) * 2; - if (g2_len_x2 >= glob1_len_x2) - { - inc_bignum(glob2, len * 2 + 1); - neg_bignum(glob2, len * 2 + 1); - len_diff = g2_len_x2 + 1 - glob1_len_x2; - ushort* esi = ((ushort*)g2) + (1 + g2_len_x2 - glob1_len_x2); - ushort* edi = ((ushort*)g2) + (g2_len_x2 + 1); - for (; len_diff != 0; len_diff--) - { - edi--; - uint tmp = get_mulword((uint*)edi); - esi--; - if (tmp > 0) - { - mul_bignum_word(esi, glob1, tmp, 2 * len); - if ((*edi & 0x8000) == 0) - { - if (0 != sub_bignum((uint*)esi, (uint*)esi, g1, 0, (int)len)) (*edi)--; - } - } - } - neg_bignum(glob2, len); - dec_bignum(glob2, len); - } - mov_bignum(n1, glob2, len); - } - } - } + void calc_a_bignum(uint[] n1, uint[] n2, uint[] n3, uint len) + { + uint g2_len_x2, len_diff; + unsafe + { + fixed( uint* g1 = &glob1[0]) + fixed (uint* g2 = &glob2[0]) + { + mul_bignum(glob2, n2, n3, len); + glob2[len * 2] = 0; + g2_len_x2 = len_bignum(glob2, len * 2 + 1) * 2; + if (g2_len_x2 >= glob1_len_x2) + { + inc_bignum(glob2, len * 2 + 1); + neg_bignum(glob2, len * 2 + 1); + len_diff = g2_len_x2 + 1 - glob1_len_x2; + ushort* esi = ((ushort*)g2) + (1 + g2_len_x2 - glob1_len_x2); + ushort* edi = ((ushort*)g2) + (g2_len_x2 + 1); + for (; len_diff != 0; len_diff--) + { + edi--; + uint tmp = get_mulword((uint*)edi); + esi--; + if (tmp > 0) + { + mul_bignum_word(esi, glob1, tmp, 2 * len); + if ((*edi & 0x8000) == 0) + { + if (0 != sub_bignum((uint*)esi, (uint*)esi, g1, 0, (int)len)) (*edi)--; + } + } + } + neg_bignum(glob2, len); + dec_bignum(glob2, len); + } + mov_bignum(n1, glob2, len); + } + } + } - void clear_tmp_vars(uint len) - { - init_bignum(glob1, 0, len); - init_bignum(glob2, 0, len); - init_bignum(glob1_hi_inv, 0, 4); - init_bignum(glob1_hi, 0, 4); - glob1_bitlen = 0; - glob1_hi_bitlen = 0; - glob1_len_x2 = 0; - glob1_hi_inv_lo = 0; - glob1_hi_inv_hi = 0; - } + void clear_tmp_vars(uint len) + { + init_bignum(glob1, 0, len); + init_bignum(glob2, 0, len); + init_bignum(glob1_hi_inv, 0, 4); + init_bignum(glob1_hi, 0, 4); + glob1_bitlen = 0; + glob1_hi_bitlen = 0; + glob1_len_x2 = 0; + glob1_hi_inv_lo = 0; + glob1_hi_inv_hi = 0; + } - void calc_a_key(uint[] n1, uint[] n2, uint[] n3, uint[] n4, uint len) - { - uint[] n_tmp = new uint[64]; - uint n3_len, n4_len; - int n3_bitlen; - uint bit_mask; + void calc_a_key(uint[] n1, uint[] n2, uint[] n3, uint[] n4, uint len) + { + uint[] n_tmp = new uint[64]; + uint n3_len, n4_len; + int n3_bitlen; + uint bit_mask; - unsafe - { - fixed (uint* _pn3 = &n3[0]) - { - uint* pn3 = _pn3; + unsafe + { + fixed (uint* _pn3 = &n3[0]) + { + uint* pn3 = _pn3; - init_bignum(n1, 1, len); - n4_len = len_bignum(n4, len); - init_two_dw(n4, n4_len); - n3_bitlen = (int)bitlen_bignum(n3, n4_len); - n3_len = (uint)((n3_bitlen + 31) / 32); - bit_mask = (((uint)1) << ((n3_bitlen - 1) % 32)) >> 1; - pn3 += n3_len - 1; - n3_bitlen--; - mov_bignum(n1, n2, n4_len); - while (--n3_bitlen != -1) - { - if (bit_mask == 0) - { - bit_mask = 0x80000000; - pn3--; - } - calc_a_bignum(n_tmp, n1, n1, n4_len); - if ((*pn3 & bit_mask) != 0) - calc_a_bignum(n1, n_tmp, n2, n4_len); - else - mov_bignum(n1, n_tmp, n4_len); - bit_mask >>= 1; - } - init_bignum(n_tmp, 0, n4_len); - clear_tmp_vars(len); - } - } - } + init_bignum(n1, 1, len); + n4_len = len_bignum(n4, len); + init_two_dw(n4, n4_len); + n3_bitlen = (int)bitlen_bignum(n3, n4_len); + n3_len = (uint)((n3_bitlen + 31) / 32); + bit_mask = (((uint)1) << ((n3_bitlen - 1) % 32)) >> 1; + pn3 += n3_len - 1; + n3_bitlen--; + mov_bignum(n1, n2, n4_len); + while (--n3_bitlen != -1) + { + if (bit_mask == 0) + { + bit_mask = 0x80000000; + pn3--; + } + calc_a_bignum(n_tmp, n1, n1, n4_len); + if ((*pn3 & bit_mask) != 0) + calc_a_bignum(n1, n_tmp, n2, n4_len); + else + mov_bignum(n1, n_tmp, n4_len); + bit_mask >>= 1; + } + init_bignum(n_tmp, 0, n4_len); + clear_tmp_vars(len); + } + } + } - unsafe void memcpy(byte* dest, byte* src, int len) - { - while (len-- != 0) *dest++ = *src++; - } + unsafe void memcpy(byte* dest, byte* src, int len) + { + while (len-- != 0) *dest++ = *src++; + } - unsafe void process_predata(byte* pre, uint pre_len, byte *buf) - { - uint[] n2 = new uint[64]; - uint[] n3 = new uint[64]; + unsafe void process_predata(byte* pre, uint pre_len, byte *buf) + { + uint[] n2 = new uint[64]; + uint[] n3 = new uint[64]; - uint a = (pubkey.len - 1) / 8; - while (a + 1 <= pre_len) - { - init_bignum(n2, 0, 64); - fixed( uint * pn2 = &n2[0] ) - memcpy((byte *)pn2, pre, (int)a + 1); - calc_a_key(n3, n2, pubkey.key2, pubkey.key1, 64); + uint a = (pubkey.len - 1) / 8; + while (a + 1 <= pre_len) + { + init_bignum(n2, 0, 64); + fixed( uint * pn2 = &n2[0] ) + memcpy((byte *)pn2, pre, (int)a + 1); + calc_a_key(n3, n2, pubkey.key2, pubkey.key1, 64); - fixed( uint * pn3 = &n3[0] ) - memcpy(buf, (byte *)pn3, (int)a); + fixed( uint * pn3 = &n3[0] ) + memcpy(buf, (byte *)pn3, (int)a); - pre_len -= a + 1; - pre += a + 1; - buf += a; - } - } + pre_len -= a + 1; + pre += a + 1; + buf += a; + } + } - public byte[] DecryptKey(byte[] src) - { - init_pubkey(); - byte[] dest = new byte[256]; + public byte[] DecryptKey(byte[] src) + { + init_pubkey(); + byte[] dest = new byte[256]; - unsafe - { - fixed (byte* pdest = &dest[0]) - fixed (byte* psrc = &src[0]) - process_predata(psrc, len_predata(), pdest); - } - return dest.Take(56).ToArray(); - } - } + unsafe + { + fixed (byte* pdest = &dest[0]) + fixed (byte* psrc = &src[0]) + process_predata(psrc, len_predata(), pdest); + } + return dest.Take(56).ToArray(); + } + } } diff --git a/OpenRA.FileFormats/FileFormats/Format40.cs b/OpenRA.FileFormats/FileFormats/Format40.cs index 5d78918ec5..7ffbadadd2 100644 --- a/OpenRA.FileFormats/FileFormats/Format40.cs +++ b/OpenRA.FileFormats/FileFormats/Format40.cs @@ -14,20 +14,20 @@ namespace OpenRA.FileFormats { public static int DecodeInto( byte[] src, byte[] dest ) { - var ctx = new FastByteReader(src); + var ctx = new FastByteReader(src); int destIndex = 0; while( true ) { - byte i = ctx.ReadByte(); + byte i = ctx.ReadByte(); if( ( i & 0x80 ) == 0 ) { int count = i & 0x7F; if( count == 0 ) { // case 6 - count = ctx.ReadByte(); - byte value = ctx.ReadByte(); + count = ctx.ReadByte(); + byte value = ctx.ReadByte(); for( int end = destIndex + count ; destIndex < end ; destIndex++ ) dest[ destIndex ] ^= value; } @@ -35,7 +35,7 @@ namespace OpenRA.FileFormats { // case 5 for( int end = destIndex + count ; destIndex < end ; destIndex++ ) - dest[destIndex] ^= ctx.ReadByte(); + dest[destIndex] ^= ctx.ReadByte(); } } else @@ -43,7 +43,7 @@ namespace OpenRA.FileFormats int count = i & 0x7F; if( count == 0 ) { - count = ctx.ReadWord(); + count = ctx.ReadWord(); if( count == 0 ) return destIndex; @@ -56,12 +56,12 @@ namespace OpenRA.FileFormats { // case 3 for( int end = destIndex + ( count & 0x3FFF ) ; destIndex < end ; destIndex++ ) - dest[destIndex] ^= ctx.ReadByte(); + dest[destIndex] ^= ctx.ReadByte(); } else { // case 4 - byte value = ctx.ReadByte(); + byte value = ctx.ReadByte(); for( int end = destIndex + ( count & 0x3FFF ) ; destIndex < end ; destIndex++ ) dest[ destIndex ] ^= value; } diff --git a/OpenRA.FileFormats/FileFormats/Format80.cs b/OpenRA.FileFormats/FileFormats/Format80.cs index 344de87ca2..c21c70499c 100644 --- a/OpenRA.FileFormats/FileFormats/Format80.cs +++ b/OpenRA.FileFormats/FileFormats/Format80.cs @@ -13,32 +13,32 @@ using System.IO; namespace OpenRA.FileFormats { - class FastByteReader - { - readonly byte[] src; - int offset = 0; + class FastByteReader + { + readonly byte[] src; + int offset = 0; - public FastByteReader(byte[] src) - { - this.src = src; - } + public FastByteReader(byte[] src) + { + this.src = src; + } - public bool Done() { return offset >= src.Length; } - public byte ReadByte() { return src[offset++]; } - public int ReadWord() - { - int x = ReadByte(); - return x | (ReadByte() << 8); - } + public bool Done() { return offset >= src.Length; } + public byte ReadByte() { return src[offset++]; } + public int ReadWord() + { + int x = ReadByte(); + return x | (ReadByte() << 8); + } - public void CopyTo(byte[] dest, int offset, int count) - { - Array.Copy(src, this.offset, dest, offset, count); - this.offset += count; - } + public void CopyTo(byte[] dest, int offset, int count) + { + Array.Copy(src, this.offset, dest, offset, count); + this.offset += count; + } public int Remaining() { return src.Length - offset; } - } + } public static class Format80 { @@ -61,16 +61,16 @@ namespace OpenRA.FileFormats public static int DecodeInto( byte[] src, byte[] dest ) { - var ctx = new FastByteReader(src); + var ctx = new FastByteReader(src); int destIndex = 0; while( true ) { - byte i = ctx.ReadByte(); + byte i = ctx.ReadByte(); if( ( i & 0x80 ) == 0 ) { // case 2 - byte secondByte = ctx.ReadByte(); + byte secondByte = ctx.ReadByte(); int count = ( ( i & 0x70 ) >> 4 ) + 3; int rpos = ( ( i & 0xf ) << 8 ) + secondByte; @@ -93,8 +93,8 @@ namespace OpenRA.FileFormats if( count3 == 0x3E ) { // case 4 - int count = ctx.ReadWord(); - byte color = ctx.ReadByte(); + int count = ctx.ReadWord(); + byte color = ctx.ReadByte(); for( int end = destIndex + count ; destIndex < end ; destIndex++ ) dest[ destIndex ] = color; @@ -102,8 +102,8 @@ namespace OpenRA.FileFormats else if( count3 == 0x3F ) { // case 5 - int count = ctx.ReadWord(); - int srcIndex = ctx.ReadWord(); + int count = ctx.ReadWord(); + int srcIndex = ctx.ReadWord(); if( srcIndex >= destIndex ) throw new NotImplementedException( string.Format( "srcIndex >= destIndex {0} {1}", srcIndex, destIndex ) ); @@ -114,7 +114,7 @@ namespace OpenRA.FileFormats { // case 3 int count = count3 + 3; - int srcIndex = ctx.ReadWord(); + int srcIndex = ctx.ReadWord(); if( srcIndex >= destIndex ) throw new NotImplementedException( string.Format( "srcIndex >= destIndex {0} {1}", srcIndex, destIndex ) ); diff --git a/OpenRA.FileFormats/Filesystem/FileSystem.cs b/OpenRA.FileFormats/Filesystem/FileSystem.cs index 878be96b56..0c74155875 100644 --- a/OpenRA.FileFormats/Filesystem/FileSystem.cs +++ b/OpenRA.FileFormats/Filesystem/FileSystem.cs @@ -38,36 +38,36 @@ namespace OpenRA.FileFormats static IFolder OpenPackage(string filename) { - return OpenPackage(filename, order++); + return OpenPackage(filename, order++); } public static IFolder CreatePackage(string filename, int order, Dictionary content) - { + { if (filename.EndsWith(".mix", StringComparison.InvariantCultureIgnoreCase)) - return new MixFile(filename, order, content); - else if (filename.EndsWith(".zip", StringComparison.InvariantCultureIgnoreCase)) - return new ZipFile(filename, order, content); - else if (filename.EndsWith(".oramap", StringComparison.InvariantCultureIgnoreCase)) - return new ZipFile(filename, order, content); - else if (filename.EndsWith(".Z", StringComparison.InvariantCultureIgnoreCase)) - throw new NotImplementedException("Creating .Z archives is unsupported"); - else - return new Folder(filename, order, content); - } + return new MixFile(filename, order, content); + else if (filename.EndsWith(".zip", StringComparison.InvariantCultureIgnoreCase)) + return new ZipFile(filename, order, content); + else if (filename.EndsWith(".oramap", StringComparison.InvariantCultureIgnoreCase)) + return new ZipFile(filename, order, content); + else if (filename.EndsWith(".Z", StringComparison.InvariantCultureIgnoreCase)) + throw new NotImplementedException("Creating .Z archives is unsupported"); + else + return new Folder(filename, order, content); + } - public static IFolder OpenPackage(string filename, int order) - { - if (filename.EndsWith(".mix", StringComparison.InvariantCultureIgnoreCase)) - return new MixFile(filename, order); - else if (filename.EndsWith(".zip", StringComparison.InvariantCultureIgnoreCase)) - return new ZipFile(filename, order); - else if (filename.EndsWith(".oramap", StringComparison.InvariantCultureIgnoreCase)) - return new ZipFile(filename, order); - else if (filename.EndsWith(".Z", StringComparison.InvariantCultureIgnoreCase)) - return new InstallShieldPackage(filename, order); - else - return new Folder(filename, order); - } + public static IFolder OpenPackage(string filename, int order) + { + if (filename.EndsWith(".mix", StringComparison.InvariantCultureIgnoreCase)) + return new MixFile(filename, order); + else if (filename.EndsWith(".zip", StringComparison.InvariantCultureIgnoreCase)) + return new ZipFile(filename, order); + else if (filename.EndsWith(".oramap", StringComparison.InvariantCultureIgnoreCase)) + return new ZipFile(filename, order); + else if (filename.EndsWith(".Z", StringComparison.InvariantCultureIgnoreCase)) + return new InstallShieldPackage(filename, order); + else + return new Folder(filename, order); + } public static void Mount(string name) { @@ -169,7 +169,7 @@ namespace OpenRA.FileFormats { foreach (var folder in mountedFolders) if (folder.Exists(filename)) - return true; + return true; return false; } diff --git a/OpenRA.FileFormats/Filesystem/Folder.cs b/OpenRA.FileFormats/Filesystem/Folder.cs index 210bcf2235..ad4c8dbf2f 100644 --- a/OpenRA.FileFormats/Filesystem/Folder.cs +++ b/OpenRA.FileFormats/Filesystem/Folder.cs @@ -70,7 +70,7 @@ namespace OpenRA.FileFormats foreach (var file in contents) using (var dataStream = File.Create(Path.Combine(path, file.Key))) using (var writer = new BinaryWriter(dataStream)) - writer.Write(file.Value); + writer.Write(file.Value); } } } diff --git a/OpenRA.FileFormats/Graphics/IGraphicsDevice.cs b/OpenRA.FileFormats/Graphics/IGraphicsDevice.cs index 78a5b78247..36b228b58f 100755 --- a/OpenRA.FileFormats/Graphics/IGraphicsDevice.cs +++ b/OpenRA.FileFormats/Graphics/IGraphicsDevice.cs @@ -73,13 +73,13 @@ namespace OpenRA.FileFormats.Graphics void SetData(byte[] colors, int width, int height); } - public enum PrimitiveType - { - PointList, - LineList, - TriangleList, + public enum PrimitiveType + { + PointList, + LineList, + TriangleList, QuadList, - } + } public struct Range { diff --git a/OpenRA.FileFormats/Manifest.cs b/OpenRA.FileFormats/Manifest.cs index aa1b0eeb45..ec2d346f91 100644 --- a/OpenRA.FileFormats/Manifest.cs +++ b/OpenRA.FileFormats/Manifest.cs @@ -51,7 +51,7 @@ namespace OpenRA.FileFormats LoadScreen = yaml["LoadScreen"]; Fonts = yaml["Fonts"].NodesDict.ToDictionary(x => x.Key, x => Pair.New(x.Value.NodesDict["Font"].Value, - int.Parse(x.Value.NodesDict["Size"].Value))); + int.Parse(x.Value.NodesDict["Size"].Value))); if (yaml.ContainsKey("TileSize")) TileSize = int.Parse(yaml["TileSize"].Value); } diff --git a/OpenRA.FileFormats/Map/PlayerReference.cs b/OpenRA.FileFormats/Map/PlayerReference.cs index 199741e248..915fa0869b 100644 --- a/OpenRA.FileFormats/Map/PlayerReference.cs +++ b/OpenRA.FileFormats/Map/PlayerReference.cs @@ -28,7 +28,7 @@ namespace OpenRA.FileFormats public string Race; public bool LockColor = false; - public ColorRamp ColorRamp = new ColorRamp(0,0,238,34); + public ColorRamp ColorRamp = new ColorRamp(0,0,238,34); public bool LockSpawn = false; public int Spawn = 0; diff --git a/OpenRA.FileFormats/MiniYaml.cs b/OpenRA.FileFormats/MiniYaml.cs index f2f8081ee1..6ffa667060 100755 --- a/OpenRA.FileFormats/MiniYaml.cs +++ b/OpenRA.FileFormats/MiniYaml.cs @@ -22,7 +22,7 @@ namespace OpenRA.FileFormats public struct SourceLocation { public string Filename; public int Line; - public override string ToString() { return "{0}:{1}".F(Filename, Line); } + public override string ToString() { return "{0}:{1}".F(Filename, Line); } } public SourceLocation Location; @@ -55,10 +55,10 @@ namespace OpenRA.FileFormats { } - public override string ToString() - { - return "{{YamlNode: {0} @ {1}}}".F(Key, Location); - } + public override string ToString() + { + return "{{YamlNode: {0} @ {1}}}".F(Key, Location); + } } public class MiniYaml @@ -177,15 +177,15 @@ namespace OpenRA.FileFormats return FromLines(text.Split(new[] { "\r\n", "\n" }, StringSplitOptions.RemoveEmptyEntries), ""); } - public static List MergeLiberal(List a, List b) - { - return Merge(a, b, false); - } + public static List MergeLiberal(List a, List b) + { + return Merge(a, b, false); + } - public static List MergeStrict(List a, List b) - { - return Merge(a, b, true); - } + public static List MergeStrict(List a, List b) + { + return Merge(a, b, true); + } static List Merge( List a, List b, bool throwErrors ) { @@ -200,8 +200,8 @@ namespace OpenRA.FileFormats var bDict = b.ToDictionary( x => x.Key ); var keys = aDict.Keys.Union( bDict.Keys ).ToList(); - var noInherit = keys.Where(x => x.Length > 0 && x[0] == '-') - .ToDictionary(x => x.Substring(1), x => false); + var noInherit = keys.Where(x => x.Length > 0 && x[0] == '-') + .ToDictionary(x => x.Substring(1), x => false); foreach( var key in keys ) { @@ -211,11 +211,11 @@ namespace OpenRA.FileFormats if( noInherit.ContainsKey( key ) ) { - if (!throwErrors) - if (aa != null) - ret.Add(aa); + if (!throwErrors) + if (aa != null) + ret.Add(aa); - noInherit[key] = true; + noInherit[key] = true; } else { @@ -225,23 +225,23 @@ namespace OpenRA.FileFormats } } - if (throwErrors) - if (noInherit.ContainsValue(false)) - throw new YamlException("Bogus yaml removals: {0}".F( - string.Join(", ", noInherit.Where(x => !x.Value).Select(x => x.Key).ToArray()))); + if (throwErrors) + if (noInherit.ContainsValue(false)) + throw new YamlException("Bogus yaml removals: {0}".F( + string.Join(", ", noInherit.Where(x => !x.Value).Select(x => x.Key).ToArray()))); return ret; } - public static MiniYaml MergeLiberal(MiniYaml a, MiniYaml b) - { - return Merge(a, b, false); - } + public static MiniYaml MergeLiberal(MiniYaml a, MiniYaml b) + { + return Merge(a, b, false); + } - public static MiniYaml MergeStrict(MiniYaml a, MiniYaml b) - { - return Merge(a, b, true); - } + public static MiniYaml MergeStrict(MiniYaml a, MiniYaml b) + { + return Merge(a, b, true); + } static MiniYaml Merge( MiniYaml a, MiniYaml b, bool throwErrors ) { @@ -286,8 +286,8 @@ namespace OpenRA.FileFormats } } - public class YamlException : Exception - { - public YamlException(string s) : base(s) { } - } + public class YamlException : Exception + { + public YamlException(string s) : base(s) { } + } } diff --git a/OpenRA.FileFormats/PlayerColorRemap.cs b/OpenRA.FileFormats/PlayerColorRemap.cs index a866fadac4..17cc611597 100755 --- a/OpenRA.FileFormats/PlayerColorRemap.cs +++ b/OpenRA.FileFormats/PlayerColorRemap.cs @@ -23,8 +23,8 @@ namespace OpenRA.FileFormats public PlayerColorRemap(ColorRamp c, PaletteFormat fmt) { - var c1 = c.GetColor(0); - var c2 = c.GetColor(1); /* temptemp: this can be expressed better */ + var c1 = c.GetColor(0); + var c2 = c.GetColor(1); /* temptemp: this can be expressed better */ var baseIndex = (fmt == PaletteFormat.cnc) ? 0xb0 : (fmt == PaletteFormat.d2k) ? 240 : 80; var ramp = (fmt == PaletteFormat.cnc) diff --git a/OpenRA.FileFormats/Primitives/Pair.cs b/OpenRA.FileFormats/Primitives/Pair.cs index db84ada1cc..33dd09e806 100644 --- a/OpenRA.FileFormats/Primitives/Pair.cs +++ b/OpenRA.FileFormats/Primitives/Pair.cs @@ -71,8 +71,8 @@ namespace OpenRA.FileFormats public static IEqualityComparer> EqualityComparer { get { return new PairEqualityComparer(); } } } - public static class Pair - { + public static class Pair + { public static Pair New(T t, U u) { return new Pair(t, u); } static Pair() @@ -86,5 +86,5 @@ namespace OpenRA.FileFormats public bool Equals(Color x, Color y) { return x.ToArgb() == y.ToArgb(); } public int GetHashCode(Color obj) { return obj.GetHashCode(); } } - } + } } diff --git a/OpenRA.FileFormats/Primitives/float2.cs b/OpenRA.FileFormats/Primitives/float2.cs index bfebde60b0..ac9e5000cb 100644 --- a/OpenRA.FileFormats/Primitives/float2.cs +++ b/OpenRA.FileFormats/Primitives/float2.cs @@ -62,23 +62,23 @@ namespace OpenRA Constrain(Y, min.Y, max.Y)); } - public static float2 operator *(float a, float2 b) { return new float2(a * b.X, a * b.Y); } - public static float2 operator *(float2 b, float a) { return new float2(a * b.X, a * b.Y); } + public static float2 operator *(float a, float2 b) { return new float2(a * b.X, a * b.Y); } + public static float2 operator *(float2 b, float a) { return new float2(a * b.X, a * b.Y); } public static float2 operator *( float2 a, float2 b ) { return new float2( a.X * b.X, a.Y * b.Y ); } public static float2 operator /( float2 a, float2 b ) { return new float2( a.X / b.X, a.Y / b.Y ); } - public static bool operator ==(float2 me, float2 other) { return (me.X == other.X && me.Y == other.Y); } - public static bool operator !=(float2 me, float2 other) { return !(me == other); } - public override int GetHashCode() { return X.GetHashCode() ^ Y.GetHashCode(); } + public static bool operator ==(float2 me, float2 other) { return (me.X == other.X && me.Y == other.Y); } + public static bool operator !=(float2 me, float2 other) { return !(me == other); } + public override int GetHashCode() { return X.GetHashCode() ^ Y.GetHashCode(); } - public override bool Equals(object obj) - { - if (obj == null) - return false; + public override bool Equals(object obj) + { + if (obj == null) + return false; - float2 o = (float2)obj; - return o == this; - } + float2 o = (float2)obj; + return o == this; + } public static readonly float2 Zero = new float2(0, 0); diff --git a/OpenRA.FileFormats/Primitives/int2.cs b/OpenRA.FileFormats/Primitives/int2.cs index 567b41b611..6b6575be55 100644 --- a/OpenRA.FileFormats/Primitives/int2.cs +++ b/OpenRA.FileFormats/Primitives/int2.cs @@ -52,7 +52,7 @@ namespace OpenRA public static readonly int2 Zero = new int2(0, 0); public Point ToPoint() { return new Point(X, Y); } - public PointF ToPointF() { return new PointF(X, Y); } + public PointF ToPointF() { return new PointF(X, Y); } public float2 ToFloat2() { return new float2(X, Y); } public override string ToString() { return string.Format("{0},{1}", X, Y); } @@ -76,7 +76,7 @@ namespace OpenRA public int2 Clamp(Rectangle r) { return new int2(Math.Min(r.Right, Math.Max(X, r.Left)), - Math.Min(r.Bottom, Math.Max(Y, r.Top))); + Math.Min(r.Bottom, Math.Max(Y, r.Top))); } public static int Dot(int2 a, int2 b) { return a.X * b.X + a.Y * b.Y; } diff --git a/OpenRA.FileFormats/Support/Log.cs b/OpenRA.FileFormats/Support/Log.cs index acf6010bfa..d1be337801 100755 --- a/OpenRA.FileFormats/Support/Log.cs +++ b/OpenRA.FileFormats/Support/Log.cs @@ -38,34 +38,34 @@ namespace OpenRA } } - static IEnumerable FilenamesForChannel(string channelName, string baseFilename) - { - for(var i = 0;; i++ ) - yield return Path.Combine(LogPathPrefix, - i > 0 ? "{0}.{1}".F(baseFilename, i) : baseFilename); - } + static IEnumerable FilenamesForChannel(string channelName, string baseFilename) + { + for(var i = 0;; i++ ) + yield return Path.Combine(LogPathPrefix, + i > 0 ? "{0}.{1}".F(baseFilename, i) : baseFilename); + } - public static void AddChannel(string channelName, string baseFilename) - { - if (channels.ContainsKey(channelName)) return; + public static void AddChannel(string channelName, string baseFilename) + { + if (channels.ContainsKey(channelName)) return; - foreach (var filename in FilenamesForChannel(channelName, baseFilename)) - try - { - var writer = File.CreateText(filename); - writer.AutoFlush = true; + foreach (var filename in FilenamesForChannel(channelName, baseFilename)) + try + { + var writer = File.CreateText(filename); + writer.AutoFlush = true; - channels.Add(channelName, - new ChannelInfo() - { - Filename = filename, - Writer = writer - }); + channels.Add(channelName, + new ChannelInfo() + { + Filename = filename, + Writer = writer + }); - return; - } - catch (IOException) { } - } + return; + } + catch (IOException) { } + } public static void Write(string channel, string format, params object[] args) { diff --git a/OpenRA.Game/Actor.cs b/OpenRA.Game/Actor.cs index e118c2b62e..7956ba978e 100755 --- a/OpenRA.Game/Actor.cs +++ b/OpenRA.Game/Actor.cs @@ -82,7 +82,7 @@ namespace OpenRA // auto size from render var firstSprite = TraitsImplementing().SelectMany(ApplyIRender).FirstOrDefault(); if (firstSprite.Sprite == null) return int2.Zero; - return (firstSprite.Sprite.size * firstSprite.Scale).ToInt2(); + return (firstSprite.Sprite.size * firstSprite.Scale).ToInt2(); }); ApplyIRender = x => x.Render(this); @@ -105,7 +105,7 @@ namespace OpenRA get { return currentActivity == null; } } - OpenRA.FileFormats.Lazy Size; + OpenRA.FileFormats.Lazy Size; // note: these delegates are cached to avoid massive allocation. Func> ApplyIRender; diff --git a/OpenRA.Game/GameRules/ActorInfo.cs b/OpenRA.Game/GameRules/ActorInfo.cs index 2f0e382594..8e39d30bbd 100644 --- a/OpenRA.Game/GameRules/ActorInfo.cs +++ b/OpenRA.Game/GameRules/ActorInfo.cs @@ -23,29 +23,29 @@ namespace OpenRA public ActorInfo( string name, MiniYaml node, Dictionary allUnits ) { - try - { - var mergedNode = MergeWithParent(node, allUnits).NodesDict; + try + { + var mergedNode = MergeWithParent(node, allUnits).NodesDict; - Name = name; - foreach (var t in mergedNode) - if (t.Key != "Inherits" && !t.Key.StartsWith("-")) - Traits.Add(LoadTraitInfo(t.Key.Split('@')[0], t.Value)); - } - catch (YamlException e) - { - throw new YamlException("Actor type {0}: {1}".F(name, e.Message)); - } + Name = name; + foreach (var t in mergedNode) + if (t.Key != "Inherits" && !t.Key.StartsWith("-")) + Traits.Add(LoadTraitInfo(t.Key.Split('@')[0], t.Value)); + } + catch (YamlException e) + { + throw new YamlException("Actor type {0}: {1}".F(name, e.Message)); + } } - static IEnumerable GetInheritanceChain(MiniYaml node, Dictionary allUnits) - { - while (node != null) - { - yield return node; - node = GetParent(node, allUnits); - } - } + static IEnumerable GetInheritanceChain(MiniYaml node, Dictionary allUnits) + { + while (node != null) + { + yield return node; + node = GetParent(node, allUnits); + } + } static MiniYaml GetParent( MiniYaml node, Dictionary allUnits ) { @@ -56,9 +56,9 @@ namespace OpenRA MiniYaml parent; allUnits.TryGetValue( inherits.Value, out parent ); - if (parent == null) - throw new InvalidOperationException( - "Bogus inheritance -- actor type {0} does not exist".F(inherits.Value)); + if (parent == null) + throw new InvalidOperationException( + "Bogus inheritance -- actor type {0} does not exist".F(inherits.Value)); return parent; } @@ -66,14 +66,14 @@ namespace OpenRA static MiniYaml MergeWithParent( MiniYaml node, Dictionary allUnits ) { var parent = GetParent( node, allUnits ); - if (parent != null) - { - var result = MiniYaml.MergeStrict(node, MergeWithParent(parent, allUnits)); + if (parent != null) + { + var result = MiniYaml.MergeStrict(node, MergeWithParent(parent, allUnits)); - // strip the '-' - result.Nodes.RemoveAll(a => a.Key.StartsWith("-")); - return result; - } + // strip the '-' + result.Nodes.RemoveAll(a => a.Key.StartsWith("-")); + return result; + } return node; } diff --git a/OpenRA.Game/GameRules/Settings.cs b/OpenRA.Game/GameRules/Settings.cs index a29d0a224f..d536d607e8 100755 --- a/OpenRA.Game/GameRules/Settings.cs +++ b/OpenRA.Game/GameRules/Settings.cs @@ -49,7 +49,7 @@ namespace OpenRA.GameRules public bool PerfText = false; public bool PerfGraph = false; public float LongTickThreshold = 0.001f; - public bool SanityCheckUnsyncedCode = false; + public bool SanityCheckUnsyncedCode = false; public int Samples = 25; } @@ -79,7 +79,7 @@ namespace OpenRA.GameRules public class PlayerSettings { public string Name = "Newbie"; - public ColorRamp ColorRamp = new ColorRamp(75, 255, 180, 25); + public ColorRamp ColorRamp = new ColorRamp(75, 255, 180, 25); public string LastServer = "localhost:1234"; } @@ -91,8 +91,8 @@ namespace OpenRA.GameRules public bool TeamChatToggle = false; - public bool ViewportEdgeScroll = true; - public MouseScrollType MouseScroll = MouseScrollType.Standard; + public bool ViewportEdgeScroll = true; + public MouseScrollType MouseScroll = MouseScrollType.Standard; public float ViewportEdgeScrollStep = 10f; // Internal game settings diff --git a/OpenRA.Game/Graphics/Sprite.cs b/OpenRA.Game/Graphics/Sprite.cs index cb0aa400c8..e62359f828 100644 --- a/OpenRA.Game/Graphics/Sprite.cs +++ b/OpenRA.Game/Graphics/Sprite.cs @@ -60,10 +60,10 @@ namespace OpenRA.Graphics Game.Renderer.WorldSpriteRenderer.DrawSprite( this, location, paletteIndex, this.size ); } - public void DrawAt(float2 location, int paletteIndex, float scale) - { - Game.Renderer.WorldSpriteRenderer.DrawSprite(this, location, paletteIndex, this.size * scale); - } + public void DrawAt(float2 location, int paletteIndex, float scale) + { + Game.Renderer.WorldSpriteRenderer.DrawSprite(this, location, paletteIndex, this.size * scale); + } public void DrawAt( float2 location, int paletteIndex, float2 size ) { diff --git a/OpenRA.Game/Graphics/SpriteFont.cs b/OpenRA.Game/Graphics/SpriteFont.cs index c5f2572506..60b8655963 100644 --- a/OpenRA.Game/Graphics/SpriteFont.cs +++ b/OpenRA.Game/Graphics/SpriteFont.cs @@ -70,18 +70,18 @@ namespace OpenRA.Graphics } } - public void DrawTextWithContrast(string text, float2 location, Color fg, Color bg, int offset) - { - if (offset > 0) - { - DrawText(text, location + new float2(-offset, 0), bg); - DrawText(text, location + new float2(offset, 0), bg); - DrawText(text, location + new float2(0, -offset), bg); - DrawText(text, location + new float2(0, offset), bg); - } + public void DrawTextWithContrast(string text, float2 location, Color fg, Color bg, int offset) + { + if (offset > 0) + { + DrawText(text, location + new float2(-offset, 0), bg); + DrawText(text, location + new float2(offset, 0), bg); + DrawText(text, location + new float2(0, -offset), bg); + DrawText(text, location + new float2(0, offset), bg); + } - DrawText(text, location, fg); - } + DrawText(text, location, fg); + } public int2 Measure(string text) { diff --git a/OpenRA.Game/Graphics/SpriteLoader.cs b/OpenRA.Game/Graphics/SpriteLoader.cs index 842232d06b..ecc69faab3 100644 --- a/OpenRA.Game/Graphics/SpriteLoader.cs +++ b/OpenRA.Game/Graphics/SpriteLoader.cs @@ -22,7 +22,7 @@ namespace OpenRA.Graphics sprites = new Cache( LoadSprites ); } - readonly SheetBuilder SheetBuilder; + readonly SheetBuilder SheetBuilder; readonly Cache sprites; readonly string[] exts; diff --git a/OpenRA.Game/Graphics/Viewport.cs b/OpenRA.Game/Graphics/Viewport.cs index b49388ff35..38a56e8535 100755 --- a/OpenRA.Game/Graphics/Viewport.cs +++ b/OpenRA.Game/Graphics/Viewport.cs @@ -44,9 +44,9 @@ namespace OpenRA.Graphics get { return new Rectangle(scrollPosition.X / Game.CellSize, - scrollPosition.Y / Game.CellSize, - (int)(screenSize.X / Zoom / Game.CellSize), - (int)(screenSize.Y / Zoom / Game.CellSize)); + scrollPosition.Y / Game.CellSize, + (int)(screenSize.X / Zoom / Game.CellSize), + (int)(screenSize.Y / Zoom / Game.CellSize)); } } @@ -70,9 +70,9 @@ namespace OpenRA.Graphics var viewBR = (Game.CellSize*new float2(mapBounds.Right, mapBounds.Bottom)).ToInt2(); var border = (.5f/Zoom * screenSize.ToFloat2()).ToInt2(); scrollLimits = Rectangle.FromLTRB(viewTL.X - border.X, - viewTL.Y - border.Y, - viewBR.X - border.X, - viewBR.Y - border.Y); + viewTL.Y - border.Y, + viewBR.X - border.X, + viewBR.Y - border.Y); // Re-center viewport scrollPosition = NormalizeScrollPosition((oldCenter - 0.5f / Zoom * screenSize.ToFloat2()).ToInt2()); } @@ -135,13 +135,13 @@ namespace OpenRA.Graphics { Widget.DoDraw(); var cursorName = Widget.RootWidget.GetCursorOuter(Viewport.LastMousePos) ?? "default"; - var cursorSequence = CursorProvider.GetCursorSequence(cursorName); + var cursorSequence = CursorProvider.GetCursorSequence(cursorName); var cursorSprite = cursorSequence.GetSprite((int)cursorFrame); renderer.SpriteRenderer.DrawSprite(cursorSprite, - Viewport.LastMousePos - cursorSequence.Hotspot, - Game.modData.Palette.GetPaletteIndex(cursorSequence.Palette), - cursorSprite.size); + Viewport.LastMousePos - cursorSequence.Hotspot, + Game.modData.Palette.GetPaletteIndex(cursorSequence.Palette), + cursorSprite.size); } using( new PerfSample("render_flip") ) diff --git a/OpenRA.Game/Map.cs b/OpenRA.Game/Map.cs index 2f944ede06..50fe1c084e 100644 --- a/OpenRA.Game/Map.cs +++ b/OpenRA.Game/Map.cs @@ -29,7 +29,7 @@ namespace OpenRA public string Uid { get; protected set; } public int MapFormat; public bool Selectable; - public bool UseAsShellmap; + public bool UseAsShellmap; public string RequiresMod; public string Title; @@ -120,7 +120,7 @@ namespace OpenRA var yaml = new MiniYaml( null, MiniYaml.FromStream(Container.GetContent("map.yaml")) ); FieldLoader.Load(this, yaml); - Uid = ComputeHash(); + Uid = ComputeHash(); // 'Simple' metadata FieldLoader.Load( this, yaml ); @@ -394,16 +394,16 @@ namespace OpenRA } string ComputeHash() - { - // UID is calculated by taking an SHA1 of the yaml and binary data - // Read the relevant data into a buffer - var data = Container.GetContent("map.yaml").ReadAllBytes() - .Concat(Container.GetContent("map.bin").ReadAllBytes()).ToArray(); + { + // UID is calculated by taking an SHA1 of the yaml and binary data + // Read the relevant data into a buffer + var data = Container.GetContent("map.yaml").ReadAllBytes() + .Concat(Container.GetContent("map.bin").ReadAllBytes()).ToArray(); - // Take the SHA1 - using (var csp = SHA1.Create()) - return new string(csp.ComputeHash(data).SelectMany(a => a.ToString("x2")).ToArray()); - } + // Take the SHA1 + using (var csp = SHA1.Create()) + return new string(csp.ComputeHash(data).SelectMany(a => a.ToString("x2")).ToArray()); + } public void MakeDefaultPlayers() { diff --git a/OpenRA.Game/ModData.cs b/OpenRA.Game/ModData.cs index efbbf63259..04e088b8b1 100755 --- a/OpenRA.Game/ModData.cs +++ b/OpenRA.Game/ModData.cs @@ -82,21 +82,21 @@ namespace OpenRA return map; } - public static IEnumerable FindMapsIn(string dir) - { - string[] NoMaps = { }; + public static IEnumerable FindMapsIn(string dir) + { + string[] NoMaps = { }; - if (!Directory.Exists(dir)) - return NoMaps; + if (!Directory.Exists(dir)) + return NoMaps; - return Directory.GetDirectories(dir) - .Concat(Directory.GetFiles(dir, "*.zip")) - .Concat(Directory.GetFiles(dir, "*.oramap")); - } + return Directory.GetDirectories(dir) + .Concat(Directory.GetFiles(dir, "*.zip")) + .Concat(Directory.GetFiles(dir, "*.oramap")); + } Dictionary FindMaps(string[] mods) { - var paths = mods.SelectMany(p => FindMapsIn("mods{0}{1}{0}maps{0}".F(Path.DirectorySeparatorChar, p))) + var paths = mods.SelectMany(p => FindMapsIn("mods{0}{1}{0}maps{0}".F(Path.DirectorySeparatorChar, p))) .Concat(mods.SelectMany(p => FindMapsIn("{1}maps{0}{2}{0}".F(Path.DirectorySeparatorChar, Platform.SupportDir, p)))); var ret = new Dictionary(); diff --git a/OpenRA.Game/Network/Connection.cs b/OpenRA.Game/Network/Connection.cs index 503793deef..19718c9e3c 100755 --- a/OpenRA.Game/Network/Connection.cs +++ b/OpenRA.Game/Network/Connection.cs @@ -18,7 +18,7 @@ using OpenRA.Support; namespace OpenRA.Network { - public enum ConnectionState + public enum ConnectionState { PreConnecting, NotConnected, @@ -26,7 +26,7 @@ namespace OpenRA.Network Connected, } - public interface IConnection : IDisposable + public interface IConnection : IDisposable { int LocalClientId { get; } ConnectionState ConnectionState { get; } diff --git a/OpenRA.Game/Network/FrameData.cs b/OpenRA.Game/Network/FrameData.cs index f29f95ce69..abb891ae64 100755 --- a/OpenRA.Game/Network/FrameData.cs +++ b/OpenRA.Game/Network/FrameData.cs @@ -44,17 +44,17 @@ namespace OpenRA.Network frameData.Add( clientId, orders ); } - public bool IsReadyForFrame(int frame) - { - return !ClientsNotReadyForFrame(frame).Any(); - } + public bool IsReadyForFrame(int frame) + { + return !ClientsNotReadyForFrame(frame).Any(); + } - public IEnumerable ClientsNotReadyForFrame(int frame) - { - var frameData = framePackets.GetOrAdd(frame); - return ClientsPlayingInFrame(frame) - .Where(client => !frameData.ContainsKey(client)); - } + public IEnumerable ClientsNotReadyForFrame(int frame) + { + var frameData = framePackets.GetOrAdd(frame); + return ClientsPlayingInFrame(frame) + .Where(client => !frameData.ContainsKey(client)); + } public IEnumerable OrdersForFrame( World world, int frame ) { diff --git a/OpenRA.Game/Network/Order.cs b/OpenRA.Game/Network/Order.cs index 00443640c0..b81a9f2731 100755 --- a/OpenRA.Game/Network/Order.cs +++ b/OpenRA.Game/Network/Order.cs @@ -67,7 +67,7 @@ namespace OpenRA public Order(string orderstring, Order order) : this(orderstring, order.Subject, order.TargetActor, order.TargetLocation, - order.TargetString, order.Queued, order.ExtraLocation) {} + order.TargetString, order.Queued, order.ExtraLocation) {} public byte[] Serialize() { @@ -85,7 +85,7 @@ namespace OpenRA { // Format: // u8 : orderID. - // 0xFF: Full serialized order. + // 0xFF: Full serialized order. // varies: rest of order. default: // TODO: specific serializers for specific orders. diff --git a/OpenRA.Game/Network/OrderManager.cs b/OpenRA.Game/Network/OrderManager.cs index 6bffea0ab2..708caf08fd 100755 --- a/OpenRA.Game/Network/OrderManager.cs +++ b/OpenRA.Game/Network/OrderManager.cs @@ -16,7 +16,7 @@ using OpenRA.FileFormats; namespace OpenRA.Network { - public class OrderManager : IDisposable + public class OrderManager : IDisposable { readonly SyncReport syncReport; readonly FrameData frameData = new FrameData(); @@ -157,17 +157,17 @@ namespace OpenRA.Network get { return NetFrameNumber >= 1 && frameData.IsReadyForFrame( NetFrameNumber ); } } - static readonly IEnumerable NoClients = new Session.Client[] {}; - public IEnumerable GetClientsNotReadyForNextFrame - { - get - { - return NetFrameNumber >= 1 - ? frameData.ClientsNotReadyForFrame(NetFrameNumber) - .Select(a => LobbyInfo.ClientWithIndex(a)) - : NoClients; - } - } + static readonly IEnumerable NoClients = new Session.Client[] {}; + public IEnumerable GetClientsNotReadyForNextFrame + { + get + { + return NetFrameNumber >= 1 + ? frameData.ClientsNotReadyForFrame(NetFrameNumber) + .Select(a => LobbyInfo.ClientWithIndex(a)) + : NoClients; + } + } public void Tick() { diff --git a/OpenRA.Game/Network/Session.cs b/OpenRA.Game/Network/Session.cs index e7a2611ddb..d45b456704 100644 --- a/OpenRA.Game/Network/Session.cs +++ b/OpenRA.Game/Network/Session.cs @@ -47,7 +47,7 @@ namespace OpenRA.Network public class Client { public int Index; - public ColorRamp ColorRamp; + public ColorRamp ColorRamp; public string Country; public int SpawnPoint; public string Name; diff --git a/OpenRA.Game/Network/SyncReport.cs b/OpenRA.Game/Network/SyncReport.cs index ca9f0eb37c..f060b8ccf6 100755 --- a/OpenRA.Game/Network/SyncReport.cs +++ b/OpenRA.Game/Network/SyncReport.cs @@ -65,8 +65,8 @@ namespace OpenRA.Network a.ActorID, a.Type, a.Owner, - a.Trait, - a.Hash + a.Trait, + a.Hash )); return; } diff --git a/OpenRA.Game/Network/UnitOrders.cs b/OpenRA.Game/Network/UnitOrders.cs index 15b03bdd63..bb197a33af 100755 --- a/OpenRA.Game/Network/UnitOrders.cs +++ b/OpenRA.Game/Network/UnitOrders.cs @@ -68,7 +68,7 @@ namespace OpenRA.Network if (world == null) { if (client.Team == orderManager.LocalClient.Team) - Game.AddChatLine(client.ColorRamp.GetColor(0), client.Name + " (Team)", + Game.AddChatLine(client.ColorRamp.GetColor(0), client.Name + " (Team)", order.TargetString); } else @@ -85,7 +85,7 @@ namespace OpenRA.Network var suffix = (player != null && player.WinState == WinState.Lost) ? " (Dead)" : " (Team)"; - Game.AddChatLine(client.ColorRamp.GetColor(0), client.Name + suffix, order.TargetString); + Game.AddChatLine(client.ColorRamp.GetColor(0), client.Name + suffix, order.TargetString); } } } diff --git a/OpenRA.Game/Orders/UnitOrderGenerator.cs b/OpenRA.Game/Orders/UnitOrderGenerator.cs index 6705051c06..69216a1de3 100644 --- a/OpenRA.Game/Orders/UnitOrderGenerator.cs +++ b/OpenRA.Game/Orders/UnitOrderGenerator.cs @@ -19,21 +19,21 @@ namespace OpenRA.Orders { public IEnumerable Order( World world, int2 xy, MouseInput mi ) { - var underCursor = world.FindUnitsAtMouse(mi.Location) - .Where(a => a.HasTrait()) - .OrderByDescending( - a => - a.Info.Traits.Contains() - ? a.Info.Traits.Get().Priority - : int.MinValue) - .FirstOrDefault(); + var underCursor = world.FindUnitsAtMouse(mi.Location) + .Where(a => a.HasTrait()) + .OrderByDescending( + a => + a.Info.Traits.Contains() + ? a.Info.Traits.Get().Priority + : int.MinValue) + .FirstOrDefault(); - var orders = world.Selection.Actors - .Select(a => OrderForUnit(a, xy, mi, underCursor)) - .Where(o => o != null) - .ToArray(); + var orders = world.Selection.Actors + .Select(a => OrderForUnit(a, xy, mi, underCursor)) + .Where(o => o != null) + .ToArray(); - var actorsInvolved = orders.Select(o => o.self).Distinct(); + var actorsInvolved = orders.Select(o => o.self).Distinct(); if (actorsInvolved.Any()) yield return new Order("CreateGroup", actorsInvolved.First().Owner.PlayerActor, false) { @@ -41,8 +41,8 @@ namespace OpenRA.Orders }; - foreach (var o in orders) - yield return CheckSameOrder(o.iot, o.trait.IssueOrder(o.self, o.iot, o.target, mi.Modifiers.HasModifier(Modifiers.Shift))); + foreach (var o in orders) + yield return CheckSameOrder(o.iot, o.trait.IssueOrder(o.self, o.iot, o.target, mi.Modifiers.HasModifier(Modifiers.Shift))); } public void Tick( World world ) { } diff --git a/OpenRA.Game/Player.cs b/OpenRA.Game/Player.cs index c928b0b3eb..4eed1b1ade 100644 --- a/OpenRA.Game/Player.cs +++ b/OpenRA.Game/Player.cs @@ -60,7 +60,7 @@ namespace OpenRA if (client != null) { ClientIndex = client.Index; - ColorRamp = client.ColorRamp; + ColorRamp = client.ColorRamp; PlayerName = client.Name; botType = client.Bot; Country = ChooseCountry(world, client.Country); diff --git a/OpenRA.Game/Server/Server.cs b/OpenRA.Game/Server/Server.cs index 2622d33a8b..b42d05fc6f 100644 --- a/OpenRA.Game/Server/Server.cs +++ b/OpenRA.Game/Server/Server.cs @@ -133,7 +133,7 @@ namespace OpenRA.Server { for (var i = 0; i < 256; i++) if (conns.All(c => c.PlayerIndex != i) && preConns.All(c => c.PlayerIndex != i) - && lobbyInfo.Clients.All(c => c.Index != i)) + && lobbyInfo.Clients.All(c => c.Index != i)) return i; throw new InvalidOperationException("Already got 256 players"); @@ -198,9 +198,9 @@ namespace OpenRA.Server // Check that the client has compatable mods var valid = mods.All( m => m.Contains('@')) && //valid format - mods.Count() == Game.CurrentMods.Count() && //same number - mods.Select( m => Pair.New(m.Split('@')[0], m.Split('@')[1])).All(kv => Game.CurrentMods.ContainsKey(kv.First) && - (kv.Second == "{DEV_VERSION}" || Game.CurrentMods[kv.First].Version == "{DEV_VERSION}" || kv.Second == Game.CurrentMods[kv.First].Version)); + mods.Count() == Game.CurrentMods.Count() && //same number + mods.Select( m => Pair.New(m.Split('@')[0], m.Split('@')[1])).All(kv => Game.CurrentMods.ContainsKey(kv.First) && + (kv.Second == "{DEV_VERSION}" || Game.CurrentMods[kv.First].Version == "{DEV_VERSION}" || kv.Second == Game.CurrentMods[kv.First].Version)); if (!valid) { Log.Write("server", "Rejected connection from {0}; mods do not match.", @@ -241,7 +241,7 @@ namespace OpenRA.Server if (pr == null) return; if (pr.LockColor) - c.ColorRamp = pr.ColorRamp; + c.ColorRamp = pr.ColorRamp; if (pr.LockRace) c.Country = pr.Race; if (pr.LockSpawn) @@ -319,15 +319,15 @@ namespace OpenRA.Server new ServerOrder(order, data).Serialize()); } - public void SendChat(Connection asConn, string text) - { - DispatchOrders(asConn, 0, new ServerOrder("Chat", text).Serialize()); - } + public void SendChat(Connection asConn, string text) + { + DispatchOrders(asConn, 0, new ServerOrder("Chat", text).Serialize()); + } - public void SendDisconnected(Connection asConn) - { - DispatchOrders(asConn, 0, new ServerOrder("Disconnected", "").Serialize()); - } + public void SendDisconnected(Connection asConn) + { + DispatchOrders(asConn, 0, new ServerOrder("Disconnected", "").Serialize()); + } void InterpretServerOrder(Connection conn, ServerOrder so) { @@ -374,8 +374,8 @@ namespace OpenRA.Server conns.Remove(toDrop); SendChat(toDrop, "Connection Dropped"); - if (GameStarted) - SendDisconnected(toDrop); /* Report disconnection */ + if (GameStarted) + SendDisconnected(toDrop); /* Report disconnection */ lobbyInfo.Clients.RemoveAll(c => c.Index == toDrop.PlayerIndex); diff --git a/OpenRA.Game/Sound.cs b/OpenRA.Game/Sound.cs index fbdbf1c892..bba92f2646 100644 --- a/OpenRA.Game/Sound.cs +++ b/OpenRA.Game/Sound.cs @@ -29,7 +29,7 @@ namespace OpenRA static ISoundSource LoadSound(string filename) { - return LoadSoundRaw(AudLoader.LoadSound(FileSystem.Open(filename))); + return LoadSoundRaw(AudLoader.LoadSound(FileSystem.Open(filename))); } static ISoundSource LoadSoundRaw(byte[] rawData) diff --git a/OpenRA.Game/Sync.cs b/OpenRA.Game/Sync.cs index 783e9d2b7b..63c1e02ea0 100755 --- a/OpenRA.Game/Sync.cs +++ b/OpenRA.Game/Sync.cs @@ -142,7 +142,7 @@ namespace OpenRA public static T CheckSyncUnchanged( World world, Func fn ) { if( world == null ) return fn(); - var shouldCheckSync = Game.Settings.Debug.SanityCheckUnsyncedCode; + var shouldCheckSync = Game.Settings.Debug.SanityCheckUnsyncedCode; int sync = shouldCheckSync ? world.SyncHash() : 0; bool prevInUnsyncedCode = inUnsyncedCode; inUnsyncedCode = true; diff --git a/OpenRA.Game/Traits/Health.cs b/OpenRA.Game/Traits/Health.cs index 875e4cb158..b66a5a0dff 100755 --- a/OpenRA.Game/Traits/Health.cs +++ b/OpenRA.Game/Traits/Health.cs @@ -36,8 +36,8 @@ namespace OpenRA.Traits Info = info; MaxHP = info.HP; - hp = init.Contains() ? (int)(init.Get() * MaxHP) : MaxHP; - DisplayHp = hp; + hp = init.Contains() ? (int)(init.Get() * MaxHP) : MaxHP; + DisplayHp = hp; } public int HP { get { return hp; } } @@ -75,7 +75,7 @@ namespace OpenRA.Traits var oldState = this.DamageState; /* apply the damage modifiers, if we have any. */ - var modifier = (float)self.TraitsImplementing() + var modifier = (float)self.TraitsImplementing() .Concat(self.Owner.PlayerActor.TraitsImplementing()) .Select(t => t.GetDamageModifier(attacker, warhead)).Product(); @@ -93,8 +93,8 @@ namespace OpenRA.Traits Warhead = warhead, }; - foreach (var nd in self.TraitsImplementing() - .Concat(self.Owner.PlayerActor.TraitsImplementing())) + foreach (var nd in self.TraitsImplementing() + .Concat(self.Owner.PlayerActor.TraitsImplementing())) nd.Damaged(self, ai); if (DamageState != oldState) @@ -103,7 +103,7 @@ namespace OpenRA.Traits if (attacker != null && attacker.IsInWorld && !attacker.IsDead()) foreach (var nd in attacker.TraitsImplementing() - .Concat(attacker.Owner.PlayerActor.TraitsImplementing())) + .Concat(attacker.Owner.PlayerActor.TraitsImplementing())) nd.AppliedDamage(attacker, self, ai); if (hp == 0) @@ -112,7 +112,7 @@ namespace OpenRA.Traits self.Owner.Deaths++; foreach (var nd in self.TraitsImplementing() - .Concat(self.Owner.PlayerActor.TraitsImplementing())) + .Concat(self.Owner.PlayerActor.TraitsImplementing())) nd.Killed(self, ai); if( RemoveOnDeath ) diff --git a/OpenRA.Game/Traits/Player/DeveloperMode.cs b/OpenRA.Game/Traits/Player/DeveloperMode.cs index daa6820caf..7d844842af 100644 --- a/OpenRA.Game/Traits/Player/DeveloperMode.cs +++ b/OpenRA.Game/Traits/Player/DeveloperMode.cs @@ -20,7 +20,7 @@ namespace OpenRA.Traits public bool DisableShroud = false; public bool PathDebug = false; public bool UnlimitedPower; - public bool BuildAnywhere; + public bool BuildAnywhere; public object Create (ActorInitializer init) { return new DeveloperMode(this); } } @@ -34,7 +34,7 @@ namespace OpenRA.Traits [Sync] public bool DisableShroud; [Sync] public bool PathDebug; [Sync] public bool UnlimitedPower; - [Sync] public bool BuildAnywhere; + [Sync] public bool BuildAnywhere; public DeveloperMode(DeveloperModeInfo info) { @@ -44,7 +44,7 @@ namespace OpenRA.Traits DisableShroud = info.DisableShroud; PathDebug = info.PathDebug; UnlimitedPower = info.UnlimitedPower; - BuildAnywhere = info.BuildAnywhere; + BuildAnywhere = info.BuildAnywhere; } public void ResolveOrder (Actor self, Order order) @@ -96,11 +96,11 @@ namespace OpenRA.Traits UnlimitedPower ^= true; break; } - case "DevBuildAnywhere": - { - BuildAnywhere ^= true; - break; - } + case "DevBuildAnywhere": + { + BuildAnywhere ^= true; + break; + } default: return; } diff --git a/OpenRA.Game/Traits/Player/PlayerResources.cs b/OpenRA.Game/Traits/Player/PlayerResources.cs index 031cdc2fca..4aa24f15ea 100644 --- a/OpenRA.Game/Traits/Player/PlayerResources.cs +++ b/OpenRA.Game/Traits/Player/PlayerResources.cs @@ -136,7 +136,7 @@ namespace OpenRA.Traits var eva = self.World.WorldActor.Info.Traits.Get(); OreCapacity = self.World.ActorsWithTrait() - .Where(a => a.Actor.Owner == Owner) + .Where(a => a.Actor.Owner == Owner) .Sum(a => a.Trait.Capacity); if (Ore > OreCapacity) diff --git a/OpenRA.Game/Traits/TraitsInterfaces.cs b/OpenRA.Game/Traits/TraitsInterfaces.cs index a652fbed8c..3761ed2f25 100755 --- a/OpenRA.Game/Traits/TraitsInterfaces.cs +++ b/OpenRA.Game/Traits/TraitsInterfaces.cs @@ -18,117 +18,117 @@ using OpenRA.Network; namespace OpenRA.Traits { - // depends on the order of pips in WorldRenderer.cs! - public enum PipType { Transparent, Green, Yellow, Red, Gray, Blue }; - public enum TagType { None, Fake, Primary }; - public enum Stance { Enemy, Neutral, Ally }; + // depends on the order of pips in WorldRenderer.cs! + public enum PipType { Transparent, Green, Yellow, Red, Gray, Blue }; + public enum TagType { None, Fake, Primary }; + public enum Stance { Enemy, Neutral, Ally }; - public class AttackInfo - { - public Actor Attacker; - public WarheadInfo Warhead; - public int Damage; - public DamageState DamageState; - public DamageState PreviousDamageState; - } + public class AttackInfo + { + public Actor Attacker; + public WarheadInfo Warhead; + public int Damage; + public DamageState DamageState; + public DamageState PreviousDamageState; + } - public interface ITick { void Tick(Actor self); } - public interface IRender { IEnumerable Render(Actor self); } + public interface ITick { void Tick(Actor self); } + public interface IRender { IEnumerable Render(Actor self); } - public interface IIssueOrder - { - IEnumerable Orders { get; } - Order IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued); - } + public interface IIssueOrder + { + IEnumerable Orders { get; } + Order IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued); + } - public interface IOrderTargeter - { - string OrderID { get; } - int OrderPriority { get; } - bool CanTargetActor(Actor self, Actor target, bool forceAttack, bool forceQueue, ref string cursor); - bool CanTargetLocation(Actor self, int2 location, List actorsAtLocation, bool forceAttack, bool forceQueue, ref string cursor); - bool IsQueued { get; } - } + public interface IOrderTargeter + { + string OrderID { get; } + int OrderPriority { get; } + bool CanTargetActor(Actor self, Actor target, bool forceAttack, bool forceQueue, ref string cursor); + bool CanTargetLocation(Actor self, int2 location, List actorsAtLocation, bool forceAttack, bool forceQueue, ref string cursor); + bool IsQueued { get; } + } - public interface IResolveOrder { void ResolveOrder(Actor self, Order order); } - public interface IValidateOrder { bool OrderValidation(OrderManager orderManager, World world, int clientId, Order order); } - public interface IOrderVoice { string VoicePhraseForOrder(Actor self, Order order); } - public interface INotifySold { void Selling(Actor self); void Sold(Actor self); } - public interface INotifyDamage { void Damaged(Actor self, AttackInfo e); } - public interface INotifyDamageStateChanged { void DamageStateChanged(Actor self, AttackInfo e); } - public interface INotifyKilled { void Killed(Actor self, AttackInfo e); } - public interface INotifyAppliedDamage { void AppliedDamage(Actor self, Actor damaged, AttackInfo e); } - public interface INotifyBuildComplete { void BuildingComplete(Actor self); } - public interface INotifyProduction { void UnitProduced(Actor self, Actor other, int2 exit); } - public interface INotifyCapture { void OnCapture(Actor self, Actor captor, Player oldOwner, Player newOwner); } - public interface INotifyOtherCaptured { void OnActorCaptured(Actor self, Actor captured, Actor captor, Player oldOwner, Player newOwner); } - public interface IAcceptSpy { void OnInfiltrate(Actor self, Actor spy); } - public interface IStoreOre { int Capacity { get; } } - public interface IToolTip - { - string Name(); - Player Owner(); - Stance Stance(); - } + public interface IResolveOrder { void ResolveOrder(Actor self, Order order); } + public interface IValidateOrder { bool OrderValidation(OrderManager orderManager, World world, int clientId, Order order); } + public interface IOrderVoice { string VoicePhraseForOrder(Actor self, Order order); } + public interface INotifySold { void Selling(Actor self); void Sold(Actor self); } + public interface INotifyDamage { void Damaged(Actor self, AttackInfo e); } + public interface INotifyDamageStateChanged { void DamageStateChanged(Actor self, AttackInfo e); } + public interface INotifyKilled { void Killed(Actor self, AttackInfo e); } + public interface INotifyAppliedDamage { void AppliedDamage(Actor self, Actor damaged, AttackInfo e); } + public interface INotifyBuildComplete { void BuildingComplete(Actor self); } + public interface INotifyProduction { void UnitProduced(Actor self, Actor other, int2 exit); } + public interface INotifyCapture { void OnCapture(Actor self, Actor captor, Player oldOwner, Player newOwner); } + public interface INotifyOtherCaptured { void OnActorCaptured(Actor self, Actor captured, Actor captor, Player oldOwner, Player newOwner); } + public interface IAcceptSpy { void OnInfiltrate(Actor self, Actor spy); } + public interface IStoreOre { int Capacity { get; } } + public interface IToolTip + { + string Name(); + Player Owner(); + Stance Stance(); + } - public interface IDisable { bool Disabled { get; } } - public interface IExplodeModifier { bool ShouldExplode(Actor self); } - public interface IHuskModifier { string HuskActor(Actor self); } - public interface INudge { void OnNudge(Actor self, Actor nudger, bool force); } + public interface IDisable { bool Disabled { get; } } + public interface IExplodeModifier { bool ShouldExplode(Actor self); } + public interface IHuskModifier { string HuskActor(Actor self); } + public interface INudge { void OnNudge(Actor self, Actor nudger, bool force); } - public interface IRadarSignature - { - IEnumerable RadarSignatureCells(Actor self); - Color RadarSignatureColor(Actor self); - } + public interface IRadarSignature + { + IEnumerable RadarSignatureCells(Actor self); + Color RadarSignatureColor(Actor self); + } - public interface IVisibilityModifier { bool IsVisible(Actor self); } - public interface IRadarColorModifier { Color RadarColorOverride(Actor self); } + public interface IVisibilityModifier { bool IsVisible(Actor self); } + public interface IRadarColorModifier { Color RadarColorOverride(Actor self); } public interface IHasLocation { int2 PxPosition { get; } } - public interface IOccupySpace : IHasLocation - { - int2 TopLeft { get; } - IEnumerable> OccupiedCells(); - } + public interface IOccupySpace : IHasLocation + { + int2 TopLeft { get; } + IEnumerable> OccupiedCells(); + } - public static class IOccupySpaceExts - { - public static int2 NearestCellTo(this IOccupySpace ios, int2 other) - { - var nearest = ios.TopLeft; - var nearestDistance = int.MaxValue; - foreach (var cell in ios.OccupiedCells()) - { - var dist = (other - cell.First).LengthSquared; - if (dist < nearestDistance) - { - nearest = cell.First; - nearestDistance = dist; - } - } - return nearest; - } - } + public static class IOccupySpaceExts + { + public static int2 NearestCellTo(this IOccupySpace ios, int2 other) + { + var nearest = ios.TopLeft; + var nearestDistance = int.MaxValue; + foreach (var cell in ios.OccupiedCells()) + { + var dist = (other - cell.First).LengthSquared; + if (dist < nearestDistance) + { + nearest = cell.First; + nearestDistance = dist; + } + } + return nearest; + } + } - public interface INotifyAttack { void Attacking(Actor self, Target target); } - public interface IRenderModifier { IEnumerable ModifyRender(Actor self, IEnumerable r); } - public interface IDamageModifier { float GetDamageModifier(Actor attacker, WarheadInfo warhead); } - public interface ISpeedModifier { decimal GetSpeedModifier(); } - public interface IFirepowerModifier { float GetFirepowerModifier(); } - public interface IPalette { void InitPalette(WorldRenderer wr); } - public interface IPaletteModifier { void AdjustPalette(Dictionary b); } - public interface IPips { IEnumerable GetPips(Actor self); } - public interface ITags { IEnumerable GetTags(); } - public interface ISelectionBar { float GetValue(); Color GetColor(); } + public interface INotifyAttack { void Attacking(Actor self, Target target); } + public interface IRenderModifier { IEnumerable ModifyRender(Actor self, IEnumerable r); } + public interface IDamageModifier { float GetDamageModifier(Actor attacker, WarheadInfo warhead); } + public interface ISpeedModifier { decimal GetSpeedModifier(); } + public interface IFirepowerModifier { float GetFirepowerModifier(); } + public interface IPalette { void InitPalette(WorldRenderer wr); } + public interface IPaletteModifier { void AdjustPalette(Dictionary b); } + public interface IPips { IEnumerable GetPips(Actor self); } + public interface ITags { IEnumerable GetTags(); } + public interface ISelectionBar { float GetValue(); Color GetColor(); } - public interface ITeleportable : IHasLocation /* crap name! */ - { - bool CanEnterCell(int2 location); - void SetPosition(Actor self, int2 cell); - void SetPxPosition(Actor self, int2 px); - void AdjustPxPosition(Actor self, int2 px); /* works like SetPxPosition, but visual only */ - } + public interface ITeleportable : IHasLocation /* crap name! */ + { + bool CanEnterCell(int2 location); + void SetPosition(Actor self, int2 cell); + void SetPxPosition(Actor self, int2 px); + void AdjustPxPosition(Actor self, int2 px); /* works like SetPxPosition, but visual only */ + } public interface IMove : ITeleportable { int Altitude { get; set; } } @@ -141,86 +141,86 @@ namespace OpenRA.Traits public interface IFacingInfo {} /* tag interface for infoclasses whose corresponding trait has IFacing */ - public interface ICrushable - { - void OnCrush(Actor crusher); + public interface ICrushable + { + void OnCrush(Actor crusher); void WarnCrush(Actor crusher); bool CrushableBy(string[] crushClasses, Player owner); - } + } - public struct Renderable - { - public readonly Sprite Sprite; - public readonly float2 Pos; - public readonly string Palette; - public readonly int Z; - public readonly int ZOffset; - public float Scale; + public struct Renderable + { + public readonly Sprite Sprite; + public readonly float2 Pos; + public readonly string Palette; + public readonly int Z; + public readonly int ZOffset; + public float Scale; - public Renderable(Sprite sprite, float2 pos, string palette, int z, int zOffset, float scale) - { - Sprite = sprite; - Pos = pos; - Palette = palette; - Z = z; - ZOffset = zOffset; - Scale = scale; /* default */ - } + public Renderable(Sprite sprite, float2 pos, string palette, int z, int zOffset, float scale) + { + Sprite = sprite; + Pos = pos; + Palette = palette; + Z = z; + ZOffset = zOffset; + Scale = scale; /* default */ + } - public Renderable(Sprite sprite, float2 pos, string palette, int z) - : this(sprite, pos, palette, z, 0, 1f) { } + public Renderable(Sprite sprite, float2 pos, string palette, int z) + : this(sprite, pos, palette, z, 0, 1f) { } - public Renderable(Sprite sprite, float2 pos, string palette, int z, float scale) - : this(sprite, pos, palette, z, 0, scale) { } + public Renderable(Sprite sprite, float2 pos, string palette, int z, float scale) + : this(sprite, pos, palette, z, 0, scale) { } - public Renderable WithScale(float newScale) { return new Renderable(Sprite, Pos, Palette, Z, ZOffset, newScale); } - public Renderable WithPalette(string newPalette) { return new Renderable(Sprite, Pos, newPalette, Z, ZOffset, Scale); } - public Renderable WithZOffset(int newOffset) { return new Renderable(Sprite, Pos, Palette, Z, newOffset, Scale); } - public Renderable WithPos(float2 newPos) { return new Renderable(Sprite, newPos, Palette, Z, ZOffset, Scale); } - } + public Renderable WithScale(float newScale) { return new Renderable(Sprite, Pos, Palette, Z, ZOffset, newScale); } + public Renderable WithPalette(string newPalette) { return new Renderable(Sprite, Pos, newPalette, Z, ZOffset, Scale); } + public Renderable WithZOffset(int newOffset) { return new Renderable(Sprite, Pos, Palette, Z, newOffset, Scale); } + public Renderable WithPos(float2 newPos) { return new Renderable(Sprite, newPos, Palette, Z, ZOffset, Scale); } + } - public interface ITraitInfo { object Create(ActorInitializer init); } + public interface ITraitInfo { object Create(ActorInitializer init); } - public class TraitInfo : ITraitInfo where T : new() { public virtual object Create(ActorInitializer init) { return new T(); } } + public class TraitInfo : ITraitInfo where T : new() { public virtual object Create(ActorInitializer init) { return new T(); } } - public interface Requires where T : class { } + public interface Requires where T : class { } - public interface INotifySelection { void SelectionChanged(); } - public interface IWorldLoaded { void WorldLoaded(World w); } - public interface ICreatePlayers { void CreatePlayers(World w); } + public interface INotifySelection { void SelectionChanged(); } + public interface IWorldLoaded { void WorldLoaded(World w); } + public interface ICreatePlayers { void CreatePlayers(World w); } - public interface IBotInfo { string Name { get; } } - public interface IBot - { - void Activate(Player p); - IBotInfo Info { get; } - } + public interface IBotInfo { string Name { get; } } + public interface IBot + { + void Activate(Player p); + IBotInfo Info { get; } + } - public interface IRenderOverlay { void Render(WorldRenderer wr); } - public interface INotifyIdle { void TickIdle(Actor self); } + public interface IRenderOverlay { void Render(WorldRenderer wr); } + public interface INotifyIdle { void TickIdle(Actor self); } - public interface IBlocksBullets { } + public interface IBlocksBullets { } - public interface IPostRender { void RenderAfterWorld(WorldRenderer wr, Actor self); } + public interface IPostRender { void RenderAfterWorld(WorldRenderer wr, Actor self); } - public interface IPostRenderSelection { void RenderAfterWorld(WorldRenderer wr, Actor self); } - public interface IPreRenderSelection { void RenderBeforeWorld(WorldRenderer wr, Actor self); } - public interface IRenderAsTerrain { IEnumerable RenderAsTerrain(Actor self); } + public interface IPostRenderSelection { void RenderAfterWorld(WorldRenderer wr, Actor self); } + public interface IPreRenderSelection { void RenderBeforeWorld(WorldRenderer wr, Actor self); } + public interface IRenderAsTerrain { IEnumerable RenderAsTerrain(Actor self); } - public interface ITargetable - { - string[] TargetTypes { get; } - IEnumerable TargetableCells(Actor self); - bool TargetableBy(Actor self, Actor byActor); - } + public interface ITargetable + { + string[] TargetTypes { get; } + IEnumerable TargetableCells(Actor self); + bool TargetableBy(Actor self, Actor byActor); + } - public interface INotifyStanceChanged - { - void StanceChanged(Actor self, Player a, Player b, - Stance oldStance, Stance newStance); - } + public interface INotifyStanceChanged + { + void StanceChanged(Actor self, Player a, Player b, + Stance oldStance, Stance newStance); + } - public interface ILintPass { void Run(Action emitError, Action emitWarning); } + public interface ILintPass { void Run(Action emitError, Action emitWarning); } public interface IObjectivesPanel { string ObjectivesPanel { get; } } } diff --git a/OpenRA.Game/Traits/Util.cs b/OpenRA.Game/Traits/Util.cs index 5c65ba6024..956c587c95 100755 --- a/OpenRA.Game/Traits/Util.cs +++ b/OpenRA.Game/Traits/Util.cs @@ -122,17 +122,17 @@ namespace OpenRA.Traits public static int2 CellContaining(float2 pos) { return (1f / Game.CellSize * pos).ToInt2(); } - /* pretty crap */ - public static IEnumerable Shuffle(this IEnumerable ts, Thirdparty.Random random) - { - var items = ts.ToList(); - while (items.Count > 0) - { - var t = items.Random(random); - yield return t; - items.Remove(t); - } - } + /* pretty crap */ + public static IEnumerable Shuffle(this IEnumerable ts, Thirdparty.Random random) + { + var items = ts.ToList(); + while (items.Count > 0) + { + var t = items.Random(random); + yield return t; + items.Remove(t); + } + } static IEnumerable Neighbours(int2 c, bool allowDiagonal) { diff --git a/OpenRA.Game/Traits/ValidateOrder.cs b/OpenRA.Game/Traits/ValidateOrder.cs index 595a3a22d0..b284c98716 100644 --- a/OpenRA.Game/Traits/ValidateOrder.cs +++ b/OpenRA.Game/Traits/ValidateOrder.cs @@ -15,10 +15,10 @@ namespace OpenRA.Traits { public class ValidateOrderInfo : TraitInfo { } - public class ValidateOrder : IValidateOrder - { - public bool OrderValidation(OrderManager orderManager, World world, int clientId, Order order) - { + public class ValidateOrder : IValidateOrder + { + public bool OrderValidation(OrderManager orderManager, World world, int clientId, Order order) + { if (order.Subject == null || order.Subject.Owner == null) return true; @@ -36,12 +36,12 @@ namespace OpenRA.Traits // Drop exploiting orders if (subjectClientId != clientId && !isBotOrder) - { - Game.Debug("Detected exploit order from client {0}: {1}", clientId, order.OrderString); - return false; - } + { + Game.Debug("Detected exploit order from client {0}: {1}", clientId, order.OrderString); + return false; + } - return true; - } - } + return true; + } + } } diff --git a/OpenRA.Game/Traits/World/PlayerColorPalette.cs b/OpenRA.Game/Traits/World/PlayerColorPalette.cs index 8ac20d4daf..0d925324e6 100644 --- a/OpenRA.Game/Traits/World/PlayerColorPalette.cs +++ b/OpenRA.Game/Traits/World/PlayerColorPalette.cs @@ -37,7 +37,7 @@ namespace OpenRA.Traits { var paletteName = "{0}{1}".F( info.BaseName, owner.InternalName ); var newpal = new Palette(wr.GetPalette(info.BasePalette), - new PlayerColorRemap(owner.ColorRamp, info.PaletteFormat)); + new PlayerColorRemap(owner.ColorRamp, info.PaletteFormat)); wr.AddPalette(paletteName, newpal); } } diff --git a/OpenRA.Game/Traits/World/ResourceLayer.cs b/OpenRA.Game/Traits/World/ResourceLayer.cs index 1d57707eb3..7bf1f78c96 100644 --- a/OpenRA.Game/Traits/World/ResourceLayer.cs +++ b/OpenRA.Game/Traits/World/ResourceLayer.cs @@ -64,16 +64,16 @@ namespace OpenRA.Traits for (int x = map.Bounds.Left; x < map.Bounds.Right; x++) for (int y = map.Bounds.Top; y < map.Bounds.Bottom; y++) { - var type = resourceTypes.FirstOrDefault( + var type = resourceTypes.FirstOrDefault( r => r.info.ResourceType == w.Map.MapResources.Value[x, y].type); - if (type == null) - continue; + if (type == null) + continue; if (!AllowResourceAt(type, new int2(x,y))) continue; - content[x, y].type = type; + content[x, y].type = type; content[x, y].image = ChooseContent(type); } @@ -86,13 +86,13 @@ namespace OpenRA.Traits } } - public bool AllowResourceAt(ResourceType rt, int2 a) - { - if (!world.Map.IsInMap(a.X, a.Y)) return false; - if (!rt.info.AllowedTerrainTypes.Contains(world.GetTerrainInfo(a).Type)) return false; - if (!rt.info.AllowUnderActors && world.ActorMap.AnyUnitsAt(a)) return false; - return true; - } + public bool AllowResourceAt(ResourceType rt, int2 a) + { + if (!world.Map.IsInMap(a.X, a.Y)) return false; + if (!rt.info.AllowedTerrainTypes.Contains(world.GetTerrainInfo(a).Type)) return false; + if (!rt.info.AllowUnderActors && world.ActorMap.AnyUnitsAt(a)) return false; + return true; + } Sprite[] ChooseContent(ResourceType t) { diff --git a/OpenRA.Game/Traits/World/ResourceType.cs b/OpenRA.Game/Traits/World/ResourceType.cs index 499d7fa064..c181fdcbcf 100644 --- a/OpenRA.Game/Traits/World/ResourceType.cs +++ b/OpenRA.Game/Traits/World/ResourceType.cs @@ -22,8 +22,8 @@ namespace OpenRA.Traits public readonly string Name = null; public readonly string TerrainType = "Ore"; - public readonly string[] AllowedTerrainTypes = { }; - public readonly bool AllowUnderActors = false; + public readonly string[] AllowedTerrainTypes = { }; + public readonly bool AllowUnderActors = false; public Sprite[][] Sprites; public int PaletteIndex; diff --git a/OpenRA.Game/Traits/World/ScreenShaker.cs b/OpenRA.Game/Traits/World/ScreenShaker.cs index 7b9b463a86..d09b510a24 100644 --- a/OpenRA.Game/Traits/World/ScreenShaker.cs +++ b/OpenRA.Game/Traits/World/ScreenShaker.cs @@ -19,7 +19,7 @@ namespace OpenRA.Traits public class ScreenShaker : ITick { int ticks = 0; - List shakeEffects = new List(); + List shakeEffects = new List(); public void Tick (Actor self) { diff --git a/OpenRA.Game/Traits/World/Shroud.cs b/OpenRA.Game/Traits/World/Shroud.cs index b6cda0c869..abdf5844d9 100644 --- a/OpenRA.Game/Traits/World/Shroud.cs +++ b/OpenRA.Game/Traits/World/Shroud.cs @@ -78,7 +78,7 @@ namespace OpenRA.Traits return; if (a.Owner == null || a.Owner.World.LocalPlayer == null - || a.Owner.Stances[a.Owner.World.LocalPlayer] != Stance.Ally) return; + || a.Owner.Stances[a.Owner.World.LocalPlayer] != Stance.Ally) return; if (vis.ContainsKey(a)) { @@ -160,7 +160,7 @@ namespace OpenRA.Traits public void UpdateActor(Actor a) { if (a.Owner == null || a.Owner.World.LocalPlayer == null - || a.Owner.Stances[a.Owner.World.LocalPlayer] != Stance.Ally) return; + || a.Owner.Stances[a.Owner.World.LocalPlayer] != Stance.Ally) return; RemoveActor(a); AddActor(a); } diff --git a/OpenRA.Game/Widgets/ButtonWidget.cs b/OpenRA.Game/Widgets/ButtonWidget.cs index 5afec343ae..2012a19103 100644 --- a/OpenRA.Game/Widgets/ButtonWidget.cs +++ b/OpenRA.Game/Widgets/ButtonWidget.cs @@ -27,7 +27,7 @@ namespace OpenRA.Widgets public Func GetText; public Func IsDisabled = () => false; public Action OnMouseDown = _ => {}; - public Action OnMouseUp = _ => {}; + public Action OnMouseUp = _ => {}; // Equivalent to OnMouseUp, but without an input arg public Action OnClick = () => {}; @@ -130,7 +130,7 @@ namespace OpenRA.Widgets DrawBackground(rb, disabled, Depressed, Widget.MouseOverWidget == this); font.DrawText(text, new int2(rb.X + (UsableWidth - s.X)/ 2, rb.Y + (Bounds.Height - s.Y) / 2) + stateOffset, - disabled ? Color.Gray : Color.White); + disabled ? Color.Gray : Color.White); } public override Widget Clone() { return new ButtonWidget(this); } diff --git a/OpenRA.Game/Widgets/ChatDisplayWidget.cs b/OpenRA.Game/Widgets/ChatDisplayWidget.cs index bf9984a4a0..d44eae8305 100644 --- a/OpenRA.Game/Widgets/ChatDisplayWidget.cs +++ b/OpenRA.Game/Widgets/ChatDisplayWidget.cs @@ -17,7 +17,7 @@ namespace OpenRA.Widgets public class ChatDisplayWidget : Widget { public readonly int RemoveTime = 0; - public readonly bool UseContrast = false; + public readonly bool UseContrast = false; const int logLength = 9; public string Notification = ""; @@ -55,11 +55,11 @@ namespace OpenRA.Widgets inset = font.Measure(owner).X + 10; font.DrawTextWithContrast(owner, chatpos, - line.Color, Color.Black, UseContrast ? 1 : 0); + line.Color, Color.Black, UseContrast ? 1 : 0); } - font.DrawTextWithContrast(line.Text, chatpos + new int2(inset, 0), - Color.White, Color.Black, UseContrast ? 1 : 0); + font.DrawTextWithContrast(line.Text, chatpos + new int2(inset, 0), + Color.White, Color.Black, UseContrast ? 1 : 0); } Game.Renderer.DisableScissor(); diff --git a/OpenRA.Game/Widgets/ChatEntryWidget.cs b/OpenRA.Game/Widgets/ChatEntryWidget.cs index a6b986df10..b4cac67d85 100755 --- a/OpenRA.Game/Widgets/ChatEntryWidget.cs +++ b/OpenRA.Game/Widgets/ChatEntryWidget.cs @@ -21,7 +21,7 @@ namespace OpenRA.Widgets string content = ""; bool composing = false; bool teamChat = false; - public readonly bool UseContrast = false; + public readonly bool UseContrast = false; readonly OrderManager orderManager; diff --git a/OpenRA.Game/Widgets/DropDownButtonWidget.cs b/OpenRA.Game/Widgets/DropDownButtonWidget.cs index 053dec2b23..2cf3cff1a8 100644 --- a/OpenRA.Game/Widgets/DropDownButtonWidget.cs +++ b/OpenRA.Game/Widgets/DropDownButtonWidget.cs @@ -104,27 +104,27 @@ namespace OpenRA.Widgets } public class MaskWidget : Widget - { - public Action OnMouseDown = _ => {}; + { + public Action OnMouseDown = _ => {}; public MaskWidget() : base() { } - public MaskWidget(MaskWidget other) - : base(other) + public MaskWidget(MaskWidget other) + : base(other) { OnMouseDown = other.OnMouseDown; } public override bool HandleMouseInput(MouseInput mi) - { - if (mi.Event != MouseInputEvent.Down && mi.Event != MouseInputEvent.Up) + { + if (mi.Event != MouseInputEvent.Down && mi.Event != MouseInputEvent.Up) return false; if (mi.Event == MouseInputEvent.Down) OnMouseDown(mi); return true; - } + } - public override string GetCursor(int2 pos) { return null; } - public override Widget Clone() { return new MaskWidget(this); } - } + public override string GetCursor(int2 pos) { return null; } + public override Widget Clone() { return new MaskWidget(this); } + } } \ No newline at end of file diff --git a/OpenRA.Game/Widgets/MapPreviewWidget.cs b/OpenRA.Game/Widgets/MapPreviewWidget.cs index aab4d9330f..5e46989ffa 100644 --- a/OpenRA.Game/Widgets/MapPreviewWidget.cs +++ b/OpenRA.Game/Widgets/MapPreviewWidget.cs @@ -38,16 +38,16 @@ namespace OpenRA.Widgets public override Widget Clone() { return new MapPreviewWidget(this); } public override bool HandleMouseInput(MouseInput mi) - { + { if (IgnoreMouseInput) return base.HandleMouseInput(mi); if (mi.Event != MouseInputEvent.Down) return false; - OnMouseDown(mi); - return true; - } + OnMouseDown(mi); + return true; + } public int2 ConvertToPreview(Map map, int2 point) { diff --git a/OpenRA.Game/Widgets/PerfGraphWidget.cs b/OpenRA.Game/Widgets/PerfGraphWidget.cs index 248c4c92a4..e72fe4c5e0 100644 --- a/OpenRA.Game/Widgets/PerfGraphWidget.cs +++ b/OpenRA.Game/Widgets/PerfGraphWidget.cs @@ -27,7 +27,7 @@ namespace OpenRA.Widgets Game.Renderer.LineRenderer.DrawLine(origin, origin + new float2(100, 0) * basis, Color.White, Color.White); Game.Renderer.LineRenderer.DrawLine(origin + new float2(100, 0) * basis, origin + new float2(100, 100) * basis, Color.White, Color.White); - int k = 0; + int k = 0; foreach (var item in PerfHistory.items.Values.ToArray()) { int n = 0; @@ -41,19 +41,19 @@ namespace OpenRA.Widgets return b; }); - var u = new float2(rect.Left, rect.Top); + var u = new float2(rect.Left, rect.Top); - Game.Renderer.LineRenderer.DrawLine( - u + new float2(10, 10 * k + 5), - u + new float2(12, 10 * k + 5), - item.c, item.c); + Game.Renderer.LineRenderer.DrawLine( + u + new float2(10, 10 * k + 5), + u + new float2(12, 10 * k + 5), + item.c, item.c); - Game.Renderer.LineRenderer.DrawLine( - u + new float2(10, 10 * k + 4), - u + new float2(12, 10 * k + 4), - item.c, item.c); + Game.Renderer.LineRenderer.DrawLine( + u + new float2(10, 10 * k + 4), + u + new float2(12, 10 * k + 4), + item.c, item.c); - ++k; + ++k; } k = 0; diff --git a/OpenRA.Game/Widgets/ViewportScrollControllerWidget.cs b/OpenRA.Game/Widgets/ViewportScrollControllerWidget.cs index 8abd92bd32..f9021d1738 100755 --- a/OpenRA.Game/Widgets/ViewportScrollControllerWidget.cs +++ b/OpenRA.Game/Widgets/ViewportScrollControllerWidget.cs @@ -105,17 +105,17 @@ namespace OpenRA.Widgets if(Keyboard != ScrollDirection.None || Edge != ScrollDirection.None) { - var scroll = new float2(0, 0); + var scroll = new float2(0, 0); - // Modified to use the ViewportEdgeScrollStep setting - Gecko - if (Keyboard.Includes(ScrollDirection.Up) || Edge.Includes(ScrollDirection.Up)) - scroll += new float2(0, -1); - if (Keyboard.Includes(ScrollDirection.Right) || Edge.Includes(ScrollDirection.Right)) - scroll += new float2(1, 0); - if (Keyboard.Includes(ScrollDirection.Down) || Edge.Includes(ScrollDirection.Down)) - scroll += new float2(0, 1); - if (Keyboard.Includes(ScrollDirection.Left) || Edge.Includes(ScrollDirection.Left)) - scroll += new float2(-1, 0); + // Modified to use the ViewportEdgeScrollStep setting - Gecko + if (Keyboard.Includes(ScrollDirection.Up) || Edge.Includes(ScrollDirection.Up)) + scroll += new float2(0, -1); + if (Keyboard.Includes(ScrollDirection.Right) || Edge.Includes(ScrollDirection.Right)) + scroll += new float2(1, 0); + if (Keyboard.Includes(ScrollDirection.Down) || Edge.Includes(ScrollDirection.Down)) + scroll += new float2(0, 1); + if (Keyboard.Includes(ScrollDirection.Left) || Edge.Includes(ScrollDirection.Left)) + scroll += new float2(-1, 0); float length = Math.Max(1, scroll.Length); scroll.X = (scroll.X / length) * Game.Settings.Game.ViewportEdgeScrollStep; diff --git a/OpenRA.Game/Widgets/Widget.cs b/OpenRA.Game/Widgets/Widget.cs index 4b0b1794c2..16db233caf 100644 --- a/OpenRA.Game/Widgets/Widget.cs +++ b/OpenRA.Game/Widgets/Widget.cs @@ -17,75 +17,75 @@ using OpenRA.Graphics; namespace OpenRA.Widgets { - public abstract class Widget - { - public static Widget RootWidget - { - get { return rootWidget; } - set { rootWidget = value; } - } + public abstract class Widget + { + public static Widget RootWidget + { + get { return rootWidget; } + set { rootWidget = value; } + } - static Widget rootWidget = new ContainerWidget(); + static Widget rootWidget = new ContainerWidget(); static Stack WindowList = new Stack(); - public static Widget SelectedWidget; + public static Widget SelectedWidget; public static Widget MouseOverWidget; public static void CloseWindow() - { - if (WindowList.Count > 0) + { + if (WindowList.Count > 0) RootWidget.RemoveChild(WindowList.Pop()); - if (WindowList.Count > 0) - rootWidget.AddChild(WindowList.Peek()); - } + if (WindowList.Count > 0) + rootWidget.AddChild(WindowList.Peek()); + } - public static Widget OpenWindow(string id) - { - return OpenWindow(id, new WidgetArgs()); - } + public static Widget OpenWindow(string id) + { + return OpenWindow(id, new WidgetArgs()); + } - public static Widget OpenWindow(string id, WidgetArgs args) - { - var window = Game.modData.WidgetLoader.LoadWidget(args, rootWidget, id); - if (WindowList.Count > 0) - rootWidget.RemoveChild(WindowList.Peek()); - WindowList.Push(window); - return window; - } + public static Widget OpenWindow(string id, WidgetArgs args) + { + var window = Game.modData.WidgetLoader.LoadWidget(args, rootWidget, id); + if (WindowList.Count > 0) + rootWidget.RemoveChild(WindowList.Peek()); + WindowList.Push(window); + return window; + } public static Widget LoadWidget(string id, Widget parent, WidgetArgs args) - { - return Game.modData.WidgetLoader.LoadWidget(args, parent, id); - } + { + return Game.modData.WidgetLoader.LoadWidget(args, parent, id); + } - public static void DoTick() - { - RootWidget.TickOuter(); - } + public static void DoTick() + { + RootWidget.TickOuter(); + } - public static void DoDraw() - { - RootWidget.DrawOuter(); - } + public static void DoDraw() + { + RootWidget.DrawOuter(); + } public static bool DoHandleInput(MouseInput mi) - { - var wasMouseOver = MouseOverWidget; + { + var wasMouseOver = MouseOverWidget; if (mi.Event == MouseInputEvent.Move) MouseOverWidget = null; bool handled = false; - if (SelectedWidget != null && SelectedWidget.HandleMouseInputOuter(mi)) - handled = true; + if (SelectedWidget != null && SelectedWidget.HandleMouseInputOuter(mi)) + handled = true; - if (!handled && RootWidget.HandleMouseInputOuter(mi)) - handled = true; + if (!handled && RootWidget.HandleMouseInputOuter(mi)) + handled = true; - if (mi.Event == MouseInputEvent.Move) - { - Viewport.LastMousePos = mi.Location; - Viewport.TicksSinceLastMove = 0; - } + if (mi.Event == MouseInputEvent.Move) + { + Viewport.LastMousePos = mi.Location; + Viewport.TicksSinceLastMove = 0; + } if (wasMouseOver != MouseOverWidget) { @@ -96,18 +96,18 @@ namespace OpenRA.Widgets MouseOverWidget.MouseEntered(); } - return handled; - } + return handled; + } public static bool DoHandleKeyPress(KeyInput e) - { - if (SelectedWidget != null) - return SelectedWidget.HandleKeyPressOuter(e); + { + if (SelectedWidget != null) + return SelectedWidget.HandleKeyPressOuter(e); - if (RootWidget.HandleKeyPressOuter(e)) - return true; - return false; - } + if (RootWidget.HandleKeyPressOuter(e)) + return true; + return false; + } public static void ResetAll() { @@ -118,59 +118,59 @@ namespace OpenRA.Widgets } // Info defined in YAML - public string Id = null; - public string X = "0"; - public string Y = "0"; - public string Width = "0"; - public string Height = "0"; - public string Logic = null; + public string Id = null; + public string X = "0"; + public string Y = "0"; + public string Width = "0"; + public string Height = "0"; + public string Logic = null; public object LogicObject { get; private set; } - public bool Visible = true; + public bool Visible = true; public bool IgnoreMouseOver; public bool IgnoreChildMouseOver; - // Calculated internally - public Rectangle Bounds; - public Widget Parent = null; + // Calculated internally + public Rectangle Bounds; + public Widget Parent = null; public Func IsVisible; - public Widget() { IsVisible = () => Visible; } - public readonly List Children = new List(); + public Widget() { IsVisible = () => Visible; } + public readonly List Children = new List(); - public Widget(Widget widget) - { - Id = widget.Id; - X = widget.X; - Y = widget.Y; - Width = widget.Width; - Height = widget.Height; - Logic = widget.Logic; - Visible = widget.Visible; + public Widget(Widget widget) + { + Id = widget.Id; + X = widget.X; + Y = widget.Y; + Width = widget.Width; + Height = widget.Height; + Logic = widget.Logic; + Visible = widget.Visible; - Bounds = widget.Bounds; - Parent = widget.Parent; + Bounds = widget.Bounds; + Parent = widget.Parent; - IsVisible = widget.IsVisible; + IsVisible = widget.IsVisible; IgnoreChildMouseOver = widget.IgnoreChildMouseOver; - foreach (var child in widget.Children) - AddChild(child.Clone()); - } + foreach (var child in widget.Children) + AddChild(child.Clone()); + } - public virtual Widget Clone() - { - throw new InvalidOperationException("Widget type `{0}` is not cloneable.".F(GetType().Name)); - } + public virtual Widget Clone() + { + throw new InvalidOperationException("Widget type `{0}` is not cloneable.".F(GetType().Name)); + } - public virtual int2 RenderOrigin - { - get - { - var offset = (Parent == null) ? int2.Zero : Parent.ChildOrigin; - return new int2(Bounds.X, Bounds.Y) + offset; - } - } + public virtual int2 RenderOrigin + { + get + { + var offset = (Parent == null) ? int2.Zero : Parent.ChildOrigin; + return new int2(Bounds.X, Bounds.Y) + offset; + } + } - public virtual int2 ChildOrigin { get { return RenderOrigin; } } + public virtual int2 ChildOrigin { get { return RenderOrigin; } } public virtual Rectangle RenderBounds { @@ -181,120 +181,120 @@ namespace OpenRA.Widgets } } - public virtual void Initialize(WidgetArgs args) - { - // Parse the YAML equations to find the widget bounds - var parentBounds = (Parent == null) - ? new Rectangle(0, 0, Game.viewport.Width, Game.viewport.Height) - : Parent.Bounds; + public virtual void Initialize(WidgetArgs args) + { + // Parse the YAML equations to find the widget bounds + var parentBounds = (Parent == null) + ? new Rectangle(0, 0, Game.viewport.Width, Game.viewport.Height) + : Parent.Bounds; var substitutions = args.ContainsKey("substitutions") ? new Dictionary((Dictionary)args["substitutions"]) : new Dictionary(); - substitutions.Add("WINDOW_RIGHT", Game.viewport.Width); - substitutions.Add("WINDOW_BOTTOM", Game.viewport.Height); - substitutions.Add("PARENT_RIGHT", parentBounds.Width); - substitutions.Add("PARENT_LEFT", parentBounds.Left); - substitutions.Add("PARENT_TOP", parentBounds.Top); - substitutions.Add("PARENT_BOTTOM", parentBounds.Height); - int width = Evaluator.Evaluate(Width, substitutions); - int height = Evaluator.Evaluate(Height, substitutions); + substitutions.Add("WINDOW_RIGHT", Game.viewport.Width); + substitutions.Add("WINDOW_BOTTOM", Game.viewport.Height); + substitutions.Add("PARENT_RIGHT", parentBounds.Width); + substitutions.Add("PARENT_LEFT", parentBounds.Left); + substitutions.Add("PARENT_TOP", parentBounds.Top); + substitutions.Add("PARENT_BOTTOM", parentBounds.Height); + int width = Evaluator.Evaluate(Width, substitutions); + int height = Evaluator.Evaluate(Height, substitutions); - substitutions.Add("WIDTH", width); - substitutions.Add("HEIGHT", height); + substitutions.Add("WIDTH", width); + substitutions.Add("HEIGHT", height); - Bounds = new Rectangle(Evaluator.Evaluate(X, substitutions), - Evaluator.Evaluate(Y, substitutions), - width, - height); - } + Bounds = new Rectangle(Evaluator.Evaluate(X, substitutions), + Evaluator.Evaluate(Y, substitutions), + width, + height); + } - public void PostInit(WidgetArgs args) - { - if (Logic == null) - return; + public void PostInit(WidgetArgs args) + { + if (Logic == null) + return; - args["widget"] = this; + args["widget"] = this; - LogicObject = Game.modData.ObjectCreator.CreateObject(Logic, args); - var iwd = LogicObject as ILogicWithInit; - if (iwd != null) - iwd.Init(); + LogicObject = Game.modData.ObjectCreator.CreateObject(Logic, args); + var iwd = LogicObject as ILogicWithInit; + if (iwd != null) + iwd.Init(); - args.Remove("widget"); - } + args.Remove("widget"); + } - public virtual Rectangle EventBounds { get { return RenderBounds; } } - public virtual Rectangle GetEventBounds() - { - return Children - .Where(c => c.IsVisible()) - .Select(c => c.GetEventBounds()) - .Aggregate(EventBounds, Rectangle.Union); - } + public virtual Rectangle EventBounds { get { return RenderBounds; } } + public virtual Rectangle GetEventBounds() + { + return Children + .Where(c => c.IsVisible()) + .Select(c => c.GetEventBounds()) + .Aggregate(EventBounds, Rectangle.Union); + } - public bool Focused { get { return SelectedWidget == this; } } - public virtual bool TakeFocus(MouseInput mi) - { - if (Focused) - return true; + public bool Focused { get { return SelectedWidget == this; } } + public virtual bool TakeFocus(MouseInput mi) + { + if (Focused) + return true; - if (SelectedWidget != null && !SelectedWidget.LoseFocus(mi)) - return false; + if (SelectedWidget != null && !SelectedWidget.LoseFocus(mi)) + return false; - SelectedWidget = this; - return true; - } + SelectedWidget = this; + return true; + } - // Remove focus from this widget; return false if you don't want to give it up - public virtual bool LoseFocus(MouseInput mi) - { - // Some widgets may need to override focus depending on mouse click - return LoseFocus(); - } + // Remove focus from this widget; return false if you don't want to give it up + public virtual bool LoseFocus(MouseInput mi) + { + // Some widgets may need to override focus depending on mouse click + return LoseFocus(); + } - public virtual bool LoseFocus() - { - if (SelectedWidget == this) - SelectedWidget = null; + public virtual bool LoseFocus() + { + if (SelectedWidget == this) + SelectedWidget = null; - return true; - } + return true; + } - public virtual string GetCursor(int2 pos) { return "default"; } - public string GetCursorOuter(int2 pos) - { - // Is the cursor on top of us? - if (!(IsVisible() && GetEventBounds().Contains(pos))) - return null; + public virtual string GetCursor(int2 pos) { return "default"; } + public string GetCursorOuter(int2 pos) + { + // Is the cursor on top of us? + if (!(IsVisible() && GetEventBounds().Contains(pos))) + return null; - // Do any of our children specify a cursor? - foreach (var child in Children.OfType().Reverse()) - { - var cc = child.GetCursorOuter(pos); - if (cc != null) - return cc; - } + // Do any of our children specify a cursor? + foreach (var child in Children.OfType().Reverse()) + { + var cc = child.GetCursorOuter(pos); + if (cc != null) + return cc; + } - return EventBounds.Contains(pos) ? GetCursor(pos) : null; - } + return EventBounds.Contains(pos) ? GetCursor(pos) : null; + } public virtual void MouseEntered() {} public virtual void MouseExited() {} public virtual bool HandleMouseInput(MouseInput mi) { return false; } - public bool HandleMouseInputOuter(MouseInput mi) - { + public bool HandleMouseInputOuter(MouseInput mi) + { // Are we able to handle this event? - if (!(Focused || (IsVisible() && GetEventBounds().Contains(mi.Location)))) - return false; + if (!(Focused || (IsVisible() && GetEventBounds().Contains(mi.Location)))) + return false; var oldMouseOver = MouseOverWidget; - // Send the event to the deepest children first and bubble up if unhandled - foreach (var child in Children.OfType().Reverse()) - if (child.HandleMouseInputOuter(mi)) - return true; + // Send the event to the deepest children first and bubble up if unhandled + foreach (var child in Children.OfType().Reverse()) + if (child.HandleMouseInputOuter(mi)) + return true; if (IgnoreChildMouseOver) MouseOverWidget = oldMouseOver; @@ -302,58 +302,58 @@ namespace OpenRA.Widgets if (mi.Event == MouseInputEvent.Move && MouseOverWidget == null && !IgnoreMouseOver) MouseOverWidget = this; - return HandleMouseInput(mi); - } + return HandleMouseInput(mi); + } - public virtual bool HandleKeyPress(KeyInput e) { return false; } + public virtual bool HandleKeyPress(KeyInput e) { return false; } - public virtual bool HandleKeyPressOuter(KeyInput e) - { - if (!IsVisible()) - return false; + public virtual bool HandleKeyPressOuter(KeyInput e) + { + if (!IsVisible()) + return false; - // Can any of our children handle this? + // Can any of our children handle this? foreach (var child in Children.OfType().Reverse()) - if (child.HandleKeyPressOuter(e)) - return true; + if (child.HandleKeyPressOuter(e)) + return true; - // Do any widgety behavior (enter text etc) - var handled = HandleKeyPress(e); + // Do any widgety behavior (enter text etc) + var handled = HandleKeyPress(e); - return handled; - } + return handled; + } - public virtual void Draw() {} + public virtual void Draw() {} - public virtual void DrawOuter() - { - if (IsVisible()) - { - Draw(); - foreach (var child in Children) - child.DrawOuter(); - } - } + public virtual void DrawOuter() + { + if (IsVisible()) + { + Draw(); + foreach (var child in Children) + child.DrawOuter(); + } + } public virtual void Tick() {} - public virtual void TickOuter() - { - if (IsVisible()) + public virtual void TickOuter() + { + if (IsVisible()) { Tick(); - foreach (var child in Children) - child.TickOuter(); + foreach (var child in Children) + child.TickOuter(); } - } + } - public virtual void AddChild(Widget child) - { - child.Parent = this; - Children.Add(child); - } + public virtual void AddChild(Widget child) + { + child.Parent = this; + Children.Add(child); + } - public virtual void RemoveChild(Widget child) + public virtual void RemoveChild(Widget child) { Children.Remove(child); child.Removed(); @@ -371,36 +371,36 @@ namespace OpenRA.Widgets c.Removed(); } - public Widget GetWidget(string id) - { - if (this.Id == id) - return this; + public Widget GetWidget(string id) + { + if (this.Id == id) + return this; - foreach (var child in Children) - { - var w = child.GetWidget(id); - if (w != null) - return w; - } - return null; - } + foreach (var child in Children) + { + var w = child.GetWidget(id); + if (w != null) + return w; + } + return null; + } - public T GetWidget(string id) where T : Widget - { - var widget = GetWidget(id); - return (widget != null) ? (T)widget : null; - } - } + public T GetWidget(string id) where T : Widget + { + var widget = GetWidget(id); + return (widget != null) ? (T)widget : null; + } + } - public class ContainerWidget : Widget - { - public ContainerWidget() : base() { IgnoreMouseOver = true; } - public ContainerWidget(ContainerWidget other) - : base(other) { IgnoreMouseOver = true; } + public class ContainerWidget : Widget + { + public ContainerWidget() : base() { IgnoreMouseOver = true; } + public ContainerWidget(ContainerWidget other) + : base(other) { IgnoreMouseOver = true; } - public override string GetCursor(int2 pos) { return null; } - public override Widget Clone() { return new ContainerWidget(this); } - } + public override string GetCursor(int2 pos) { return null; } + public override Widget Clone() { return new ContainerWidget(this); } + } public class WidgetArgs : Dictionary { @@ -411,8 +411,8 @@ namespace OpenRA.Widgets // TODO: you should use this anywhere you want to do // something in a logic ctor, but retain debuggability. - public interface ILogicWithInit - { - void Init(); - } + public interface ILogicWithInit + { + void Init(); + } } diff --git a/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs b/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs index e3c3331cf1..7e7710086a 100644 --- a/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs +++ b/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs @@ -34,17 +34,17 @@ namespace OpenRA.Widgets public override void Draw() { var selbox = SelectionBox; - if (selbox == null) - { - foreach (var u in SelectActorsInBox(world, dragStart, dragStart)) - worldRenderer.DrawRollover(u); + if (selbox == null) + { + foreach (var u in SelectActorsInBox(world, dragStart, dragStart)) + worldRenderer.DrawRollover(u); - return; - } + return; + } Game.Renderer.WorldLineRenderer.DrawRect( selbox.Value.First, selbox.Value.Second, Color.White ); - foreach (var u in SelectActorsInBox(world, selbox.Value.First, selbox.Value.Second)) - worldRenderer.DrawRollover(u); + foreach (var u in SelectActorsInBox(world, selbox.Value.First, selbox.Value.Second)) + worldRenderer.DrawRollover(u); } int2 dragStart, dragEnd; @@ -159,7 +159,7 @@ namespace OpenRA.Widgets return false; } - static readonly Actor[] NoActors = {}; + static readonly Actor[] NoActors = {}; IEnumerable SelectActorsInBox(World world, int2 a, int2 b) { return world.FindUnits(a, b) diff --git a/OpenRA.Game/World.cs b/OpenRA.Game/World.cs index 80db56f0a7..17db8b2631 100644 --- a/OpenRA.Game/World.cs +++ b/OpenRA.Game/World.cs @@ -209,10 +209,10 @@ namespace OpenRA } } - public IEnumerable> ActorsWithTrait() - { - return traitDict.ActorsWithTraitMultiple(this); - } + public IEnumerable> ActorsWithTrait() + { + return traitDict.ActorsWithTraitMultiple(this); + } } public struct TraitPair diff --git a/OpenRA.Mods.Cnc/Missions/Gdi01Script.cs b/OpenRA.Mods.Cnc/Missions/Gdi01Script.cs index 5b88c9fd97..6dc66e9e52 100644 --- a/OpenRA.Mods.Cnc/Missions/Gdi01Script.cs +++ b/OpenRA.Mods.Cnc/Missions/Gdi01Script.cs @@ -35,7 +35,7 @@ namespace OpenRA.Mods.Cnc Game.MoveViewport(new int2(b.Left + b.Width/2, b.Top + b.Height/2)); Scripting.Media.PlayFMVFullscreen(w, "gdi1.vqa", - () => Scripting.Media.PlayFMVFullscreen(w, "landing.vqa", () => + () => Scripting.Media.PlayFMVFullscreen(w, "landing.vqa", () => { Sound.PlayMusic(Rules.Music["aoi"]); started = true; @@ -107,8 +107,8 @@ namespace OpenRA.Mods.Cnc } // GoodGuy win conditions // BadGuy is dead - var badcount = self.World.Actors.Count(a => a != a.Owner.PlayerActor && - a.Owner == Players["BadGuy"] && !a.IsDead()); + var badcount = self.World.Actors.Count(a => a != a.Owner.PlayerActor && + a.Owner == Players["BadGuy"] && !a.IsDead()); if (badcount != lastBadCount) { Game.Debug("{0} badguys remain".F(badcount)); @@ -120,7 +120,7 @@ namespace OpenRA.Mods.Cnc //GoodGuy lose conditions: MCV/cyard must survive var hasAnything = self.World.ActorsWithTrait() - .Any( a => a.Actor.Owner == Players["GoodGuy"] ); + .Any( a => a.Actor.Owner == Players["GoodGuy"] ); if (!hasAnything) OnLose(self.World); @@ -128,40 +128,40 @@ namespace OpenRA.Mods.Cnc if (ticks == 25*5) { ReinforceFromSea(self.World, - Actors["lstStart"].Location, - Actors["lstEnd"].Location, - new int2(53,53), - new string[] {"e1","e1","e1"}, + Actors["lstStart"].Location, + Actors["lstEnd"].Location, + new int2(53,53), + new string[] {"e1","e1","e1"}, Players["GoodGuy"]); } if (ticks == 25*15) { ReinforceFromSea(self.World, - Actors["lstStart"].Location, - Actors["lstEnd"].Location, - new int2(53,53), - new string[] {"e1","e1","e1"}, + Actors["lstStart"].Location, + Actors["lstEnd"].Location, + new int2(53,53), + new string[] {"e1","e1","e1"}, Players["GoodGuy"]); } if (ticks == 25*30) { ReinforceFromSea(self.World, - Actors["lstStart"].Location, - Actors["lstEnd"].Location, - new int2(53,53), - new string[] {"jeep"}, + Actors["lstStart"].Location, + Actors["lstEnd"].Location, + new int2(53,53), + new string[] {"jeep"}, Players["GoodGuy"]); } if (ticks == 25*60) { ReinforceFromSea(self.World, - Actors["lstStart"].Location, - Actors["lstEnd"].Location, - new int2(53,53), - new string[] {"jeep"}, + Actors["lstStart"].Location, + Actors["lstEnd"].Location, + new int2(53,53), + new string[] {"jeep"}, Players["GoodGuy"]); } diff --git a/OpenRA.Mods.Cnc/ProductionQueueFromSelection.cs b/OpenRA.Mods.Cnc/ProductionQueueFromSelection.cs index fe3db5197b..9c786e0627 100644 --- a/OpenRA.Mods.Cnc/ProductionQueueFromSelection.cs +++ b/OpenRA.Mods.Cnc/ProductionQueueFromSelection.cs @@ -39,8 +39,8 @@ namespace OpenRA.Mods.Cnc.Widgets { // Find an actor with a queue var producer = world.Selection.Actors.FirstOrDefault(a => a.IsInWorld - && a.World.LocalPlayer == a.Owner - && a.HasTrait()); + && a.World.LocalPlayer == a.Owner + && a.HasTrait()); if (producer != null) tabsWidget.Value.CurrentQueue = producer.TraitsImplementing().First(); } diff --git a/OpenRA.Mods.Cnc/Widgets/CncWorldInteractionControllerWidget.cs b/OpenRA.Mods.Cnc/Widgets/CncWorldInteractionControllerWidget.cs index 05a3dbd101..751e645185 100644 --- a/OpenRA.Mods.Cnc/Widgets/CncWorldInteractionControllerWidget.cs +++ b/OpenRA.Mods.Cnc/Widgets/CncWorldInteractionControllerWidget.cs @@ -33,7 +33,7 @@ namespace OpenRA.Mods.Cnc.Widgets [ObjectCreator.UseCtor] public CncWorldInteractionControllerWidget([ObjectCreator.Param] World world, - [ObjectCreator.Param] WorldRenderer worldRenderer) + [ObjectCreator.Param] WorldRenderer worldRenderer) : base(world, worldRenderer) { tooltipContainer = new Lazy(() => @@ -86,8 +86,8 @@ namespace OpenRA.Mods.Cnc.Widgets if (scrolltype != OpenRA.GameRules.MouseScrollType.Disabled && mi.Event == MouseInputEvent.Move && (mi.Button == MouseButton.Middle || mi.Button == (MouseButton.Left | MouseButton.Right))) { - var d = scrolltype == OpenRA.GameRules.MouseScrollType.Inverted ? -1 : 1; - Game.viewport.Scroll((Viewport.LastMousePos - mi.Location) * d); + var d = scrolltype == OpenRA.GameRules.MouseScrollType.Inverted ? -1 : 1; + Game.viewport.Scroll((Viewport.LastMousePos - mi.Location) * d); } return base.HandleMouseInput(mi); @@ -187,17 +187,17 @@ namespace OpenRA.Mods.Cnc.Widgets if(Keyboard != ScrollDirection.None || Edge != ScrollDirection.None) { - var scroll = new float2(0, 0); + var scroll = new float2(0, 0); - // Modified to use the ViewportEdgeScrollStep setting - Gecko - if (Keyboard.Includes(ScrollDirection.Up) || Edge.Includes(ScrollDirection.Up)) - scroll += new float2(0, -1); - if (Keyboard.Includes(ScrollDirection.Right) || Edge.Includes(ScrollDirection.Right)) - scroll += new float2(1, 0); - if (Keyboard.Includes(ScrollDirection.Down) || Edge.Includes(ScrollDirection.Down)) - scroll += new float2(0, 1); - if (Keyboard.Includes(ScrollDirection.Left) || Edge.Includes(ScrollDirection.Left)) - scroll += new float2(-1, 0); + // Modified to use the ViewportEdgeScrollStep setting - Gecko + if (Keyboard.Includes(ScrollDirection.Up) || Edge.Includes(ScrollDirection.Up)) + scroll += new float2(0, -1); + if (Keyboard.Includes(ScrollDirection.Right) || Edge.Includes(ScrollDirection.Right)) + scroll += new float2(1, 0); + if (Keyboard.Includes(ScrollDirection.Down) || Edge.Includes(ScrollDirection.Down)) + scroll += new float2(0, 1); + if (Keyboard.Includes(ScrollDirection.Left) || Edge.Includes(ScrollDirection.Left)) + scroll += new float2(-1, 0); float length = Math.Max(1, scroll.Length); scroll.X = (scroll.X / length) * Game.Settings.Game.ViewportEdgeScrollStep; diff --git a/OpenRA.Mods.Cnc/Widgets/Logic/ButtonTooltipLogic.cs b/OpenRA.Mods.Cnc/Widgets/Logic/ButtonTooltipLogic.cs index a8c3b0cc3a..1852f3af5f 100644 --- a/OpenRA.Mods.Cnc/Widgets/Logic/ButtonTooltipLogic.cs +++ b/OpenRA.Mods.Cnc/Widgets/Logic/ButtonTooltipLogic.cs @@ -17,7 +17,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic { [ObjectCreator.UseCtor] public ButtonTooltipLogic([ObjectCreator.Param] Widget widget, - [ObjectCreator.Param] ToggleButtonWidget button) + [ObjectCreator.Param] ToggleButtonWidget button) { var label = widget.GetWidget("LABEL"); var hotkey = widget.GetWidget("HOTKEY"); diff --git a/OpenRA.Mods.Cnc/Widgets/Logic/CncCheatsLogic.cs b/OpenRA.Mods.Cnc/Widgets/Logic/CncCheatsLogic.cs index 365b1c22c4..d77258ef25 100644 --- a/OpenRA.Mods.Cnc/Widgets/Logic/CncCheatsLogic.cs +++ b/OpenRA.Mods.Cnc/Widgets/Logic/CncCheatsLogic.cs @@ -28,8 +28,8 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic { [ObjectCreator.UseCtor] public CncCheatsLogic([ObjectCreator.Param] Widget widget, - [ObjectCreator.Param] Action onExit, - [ObjectCreator.Param] World world) + [ObjectCreator.Param] Action onExit, + [ObjectCreator.Param] World world) { var panel = widget.GetWidget("CHEATS_PANEL"); diff --git a/OpenRA.Mods.Cnc/Widgets/Logic/CncColorPickerLogic.cs b/OpenRA.Mods.Cnc/Widgets/Logic/CncColorPickerLogic.cs index ae5a69cb3a..0a2fc7aeb5 100644 --- a/OpenRA.Mods.Cnc/Widgets/Logic/CncColorPickerLogic.cs +++ b/OpenRA.Mods.Cnc/Widgets/Logic/CncColorPickerLogic.cs @@ -20,10 +20,10 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic ColorRamp ramp; [ObjectCreator.UseCtor] public CncColorPickerLogic([ObjectCreator.Param] Widget widget, - [ObjectCreator.Param] ColorRamp initialRamp, - [ObjectCreator.Param] Action onChange, - [ObjectCreator.Param] Action onSelect, - [ObjectCreator.Param] WorldRenderer worldRenderer) + [ObjectCreator.Param] ColorRamp initialRamp, + [ObjectCreator.Param] Action onChange, + [ObjectCreator.Param] Action onSelect, + [ObjectCreator.Param] WorldRenderer worldRenderer) { var panel = widget.GetWidget("COLOR_CHOOSER"); ramp = initialRamp; @@ -34,9 +34,9 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic Action sliderChanged = () => { ramp = new ColorRamp((byte)(255*hueSlider.Value), - (byte)(255*satSlider.Value), - (byte)(255*lumSlider.Value), - 10); + (byte)(255*satSlider.Value), + (byte)(255*lumSlider.Value), + 10); onChange(ramp); }; diff --git a/OpenRA.Mods.Cnc/Widgets/Logic/CncConnectionLogic.cs b/OpenRA.Mods.Cnc/Widgets/Logic/CncConnectionLogic.cs index da537d651e..4181f90b86 100644 --- a/OpenRA.Mods.Cnc/Widgets/Logic/CncConnectionLogic.cs +++ b/OpenRA.Mods.Cnc/Widgets/Logic/CncConnectionLogic.cs @@ -32,7 +32,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic // Show connection failed dialog CloseWindow(); Widget.OpenWindow("CONNECTIONFAILED_PANEL", new WidgetArgs() - { + { { "onAbort", onAbort }, { "onRetry", onRetry }, { "host", host }, @@ -49,11 +49,11 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic [ObjectCreator.UseCtor] public CncConnectingLogic([ObjectCreator.Param] Widget widget, - [ObjectCreator.Param] string host, - [ObjectCreator.Param] int port, - [ObjectCreator.Param] Action onConnect, - [ObjectCreator.Param] Action onRetry, - [ObjectCreator.Param] Action onAbort) + [ObjectCreator.Param] string host, + [ObjectCreator.Param] int port, + [ObjectCreator.Param] Action onConnect, + [ObjectCreator.Param] Action onRetry, + [ObjectCreator.Param] Action onAbort) { this.host = host; this.port = port; @@ -74,7 +74,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic { Game.JoinServer(host, port); Widget.OpenWindow("CONNECTING_PANEL", new WidgetArgs() - { + { { "host", host }, { "port", port }, { "onConnect", onConnect }, @@ -82,16 +82,16 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic { "onRetry", () => Connect(host, port, onConnect, onAbort) } }); } - } + } public class CncConnectionFailedLogic { [ObjectCreator.UseCtor] public CncConnectionFailedLogic([ObjectCreator.Param] Widget widget, - [ObjectCreator.Param] string host, - [ObjectCreator.Param] int port, - [ObjectCreator.Param] Action onRetry, - [ObjectCreator.Param] Action onAbort) + [ObjectCreator.Param] string host, + [ObjectCreator.Param] int port, + [ObjectCreator.Param] Action onRetry, + [ObjectCreator.Param] Action onAbort) { var panel = widget.GetWidget("CONNECTIONFAILED_PANEL"); panel.GetWidget("ABORT_BUTTON").OnClick = () => { Widget.CloseWindow(); onAbort(); }; @@ -100,4 +100,4 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic widget.GetWidget("CONNECTING_DESC").GetText = () => "Could not connect to {0}:{1}".F(host, port); } - }} + }} diff --git a/OpenRA.Mods.Cnc/Widgets/Logic/CncConquestObjectivesLogic.cs b/OpenRA.Mods.Cnc/Widgets/Logic/CncConquestObjectivesLogic.cs index 4c2f6b392e..cccc45d308 100644 --- a/OpenRA.Mods.Cnc/Widgets/Logic/CncConquestObjectivesLogic.cs +++ b/OpenRA.Mods.Cnc/Widgets/Logic/CncConquestObjectivesLogic.cs @@ -20,7 +20,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic { [ObjectCreator.UseCtor] public CncConquestObjectivesLogic([ObjectCreator.Param] Widget widget, - [ObjectCreator.Param] World world) + [ObjectCreator.Param] World world) { var panel = widget.GetWidget("CONQUEST_OBJECTIVES"); panel.GetWidget("TITLE").GetText = () => "Conquest: " + world.Map.Title; diff --git a/OpenRA.Mods.Cnc/Widgets/Logic/CncDirectConnectLogic.cs b/OpenRA.Mods.Cnc/Widgets/Logic/CncDirectConnectLogic.cs index d4f5a3859a..3265913258 100644 --- a/OpenRA.Mods.Cnc/Widgets/Logic/CncDirectConnectLogic.cs +++ b/OpenRA.Mods.Cnc/Widgets/Logic/CncDirectConnectLogic.cs @@ -18,8 +18,8 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic { [ObjectCreator.UseCtor] public CncDirectConnectLogic([ObjectCreator.Param] Widget widget, - [ObjectCreator.Param] Action onExit, - [ObjectCreator.Param] Action openLobby) + [ObjectCreator.Param] Action onExit, + [ObjectCreator.Param] Action openLobby) { var panel = widget.GetWidget("DIRECTCONNECT_PANEL"); var ipField = panel.GetWidget("IP"); diff --git a/OpenRA.Mods.Cnc/Widgets/Logic/CncDownloadPackagesLogic.cs b/OpenRA.Mods.Cnc/Widgets/Logic/CncDownloadPackagesLogic.cs index b528960a1e..2927722afe 100644 --- a/OpenRA.Mods.Cnc/Widgets/Logic/CncDownloadPackagesLogic.cs +++ b/OpenRA.Mods.Cnc/Widgets/Logic/CncDownloadPackagesLogic.cs @@ -29,8 +29,8 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic [ObjectCreator.UseCtor] public CncDownloadPackagesLogic([ObjectCreator.Param] Widget widget, - [ObjectCreator.Param] Dictionary installData, - [ObjectCreator.Param] Action afterInstall) + [ObjectCreator.Param] Dictionary installData, + [ObjectCreator.Param] Action afterInstall) { this.installData = installData; this.afterInstall = afterInstall; diff --git a/OpenRA.Mods.Cnc/Widgets/Logic/CncIngameChromeLogic.cs b/OpenRA.Mods.Cnc/Widgets/Logic/CncIngameChromeLogic.cs index 05bf347b20..f53bc569a6 100644 --- a/OpenRA.Mods.Cnc/Widgets/Logic/CncIngameChromeLogic.cs +++ b/OpenRA.Mods.Cnc/Widgets/Logic/CncIngameChromeLogic.cs @@ -66,7 +66,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic [ObjectCreator.UseCtor] public CncIngameChromeLogic([ObjectCreator.Param] Widget widget, - [ObjectCreator.Param] World world ) + [ObjectCreator.Param] World world ) { this.world = world; world.WorldActor.Trait() diff --git a/OpenRA.Mods.Cnc/Widgets/Logic/CncIngameMenuLogic.cs b/OpenRA.Mods.Cnc/Widgets/Logic/CncIngameMenuLogic.cs index 121eab0d70..1fa66fd337 100644 --- a/OpenRA.Mods.Cnc/Widgets/Logic/CncIngameMenuLogic.cs +++ b/OpenRA.Mods.Cnc/Widgets/Logic/CncIngameMenuLogic.cs @@ -21,8 +21,8 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic [ObjectCreator.UseCtor] public CncIngameMenuLogic([ObjectCreator.Param] Widget widget, - [ObjectCreator.Param] World world, - [ObjectCreator.Param] Action onExit) + [ObjectCreator.Param] World world, + [ObjectCreator.Param] Action onExit) { var resumeDisabled = false; menu = widget.GetWidget("INGAME_MENU"); @@ -63,7 +63,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic { hideButtons = true; Widget.OpenWindow("MUSIC_PANEL", new WidgetArgs() - { + { { "onExit", () => hideButtons = false }, }); }; @@ -72,7 +72,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic { hideButtons = true; Widget.OpenWindow("SETTINGS_PANEL", new WidgetArgs() - { + { { "world", world }, { "onExit", () => hideButtons = false }, }); diff --git a/OpenRA.Mods.Cnc/Widgets/Logic/CncInstallFromCDLogic.cs b/OpenRA.Mods.Cnc/Widgets/Logic/CncInstallFromCDLogic.cs index 15e3fab742..7c58dda988 100644 --- a/OpenRA.Mods.Cnc/Widgets/Logic/CncInstallFromCDLogic.cs +++ b/OpenRA.Mods.Cnc/Widgets/Logic/CncInstallFromCDLogic.cs @@ -112,7 +112,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic return; if (!InstallUtils.ExtractFromPackage(source, extractPackage, filesToExtract, dest, onProgress, onError)) - return; + return; Game.RunAfterTick(() => { diff --git a/OpenRA.Mods.Cnc/Widgets/Logic/CncInstallLogic.cs b/OpenRA.Mods.Cnc/Widgets/Logic/CncInstallLogic.cs index 87866f698a..af17fdcadb 100644 --- a/OpenRA.Mods.Cnc/Widgets/Logic/CncInstallLogic.cs +++ b/OpenRA.Mods.Cnc/Widgets/Logic/CncInstallLogic.cs @@ -18,12 +18,12 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic { [ObjectCreator.UseCtor] public CncInstallLogic([ObjectCreator.Param] Widget widget, - [ObjectCreator.Param] Dictionary installData, - [ObjectCreator.Param] Action continueLoading) + [ObjectCreator.Param] Dictionary installData, + [ObjectCreator.Param] Action continueLoading) { var panel = widget.GetWidget("INSTALL_PANEL"); var args = new WidgetArgs() - { + { { "afterInstall", () => { Widget.CloseWindow(); continueLoading(); } }, { "installData", installData } }; @@ -44,7 +44,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic panel.GetWidget("MODS_BUTTON").OnClick = () => { Widget.OpenWindow("MODS_PANEL", new WidgetArgs() - { + { { "onExit", () => {} }, // Close this panel { "onSwitch", Widget.CloseWindow }, diff --git a/OpenRA.Mods.Cnc/Widgets/Logic/CncLobbyLogic.cs b/OpenRA.Mods.Cnc/Widgets/Logic/CncLobbyLogic.cs index f8914dfc60..9b9bce2dfa 100644 --- a/OpenRA.Mods.Cnc/Widgets/Logic/CncLobbyLogic.cs +++ b/OpenRA.Mods.Cnc/Widgets/Logic/CncLobbyLogic.cs @@ -63,7 +63,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic }; Widget.OpenWindow("CONNECTIONFAILED_PANEL", new WidgetArgs() - { + { { "onAbort", onExit }, { "onRetry", onRetry }, { "host", om.Host }, @@ -85,11 +85,11 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic [ObjectCreator.UseCtor] internal CncLobbyLogic([ObjectCreator.Param( "widget" )] Widget lobby, - [ObjectCreator.Param] World world, // Shellmap world - [ObjectCreator.Param] OrderManager orderManager, - [ObjectCreator.Param] Action onExit, - [ObjectCreator.Param] Action onStart, - [ObjectCreator.Param] bool addBots) + [ObjectCreator.Param] World world, // Shellmap world + [ObjectCreator.Param] OrderManager orderManager, + [ObjectCreator.Param] Action onExit, + [ObjectCreator.Param] Action onStart, + [ObjectCreator.Param] bool addBots) { this.orderManager = orderManager; this.OnGameStart = () => { CloseWindow(); onStart(); }; @@ -119,7 +119,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic { var map = mapPreview.Map(); if (map == null || mi.Button != MouseButton.Left - || orderManager.LocalClient.State == Session.ClientState.Ready) + || orderManager.LocalClient.State == Session.ClientState.Ready) return; var p = map.SpawnPoints @@ -225,7 +225,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic lobby.GetWidget("MUSIC_BUTTON").OnClick = () => { Widget.OpenWindow("MUSIC_PANEL", new WidgetArgs() - { + { { "onExit", () => {} }, }); }; @@ -290,8 +290,8 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic Func setupItem = (ii, itemTemplate) => { var item = ScrollItemWidget.Setup(itemTemplate, - () => client.SpawnPoint == ii, - () => orderManager.IssueOrder(Order.Command("spawn {0} {1}".F(client.Index, ii)))); + () => client.SpawnPoint == ii, + () => orderManager.IssueOrder(Order.Command("spawn {0} {1}".F(client.Index, ii)))); item.GetWidget("LABEL").GetText = () => ii == 0 ? "-" : ii.ToString(); return item; }; @@ -372,11 +372,11 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic } // Editable player in slot else if ((client.Index == orderManager.LocalClient.Index) || - (client.Bot != null && Game.IsHost)) + (client.Bot != null && Game.IsHost)) { template = EditablePlayerTemplate.Clone(); var botReady = (client.Bot != null && Game.IsHost - && orderManager.LocalClient.State == Session.ClientState.Ready); + && orderManager.LocalClient.State == Session.ClientState.Ready); var ready = botReady || client.State == Session.ClientState.Ready; if (client.Bot != null) diff --git a/OpenRA.Mods.Cnc/Widgets/Logic/CncMenuLogic.cs b/OpenRA.Mods.Cnc/Widgets/Logic/CncMenuLogic.cs index 2567f6a4c3..8e488c1943 100644 --- a/OpenRA.Mods.Cnc/Widgets/Logic/CncMenuLogic.cs +++ b/OpenRA.Mods.Cnc/Widgets/Logic/CncMenuLogic.cs @@ -24,7 +24,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic [ObjectCreator.UseCtor] public CncMenuLogic([ObjectCreator.Param] Widget widget, - [ObjectCreator.Param] World world) + [ObjectCreator.Param] World world) { world.WorldActor.Trait() .Fade(CncMenuPaletteEffect.EffectType.Desaturated); @@ -43,7 +43,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic { Menu = MenuType.None; Widget.OpenWindow("MODS_PANEL", new WidgetArgs() - { + { { "onExit", () => Menu = MenuType.Main }, { "onSwitch", RemoveShellmapUI } }); @@ -61,7 +61,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic { Menu = MenuType.None; Widget.OpenWindow("SERVERBROWSER_PANEL", new WidgetArgs() - { + { { "onExit", () => Menu = MenuType.Multiplayer }, { "openLobby", () => OpenLobbyPanel(MenuType.Multiplayer, false) } }); @@ -71,7 +71,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic { Menu = MenuType.None; Widget.OpenWindow("CREATESERVER_PANEL", new WidgetArgs() - { + { { "onExit", () => Menu = MenuType.Multiplayer }, { "openLobby", () => OpenLobbyPanel(MenuType.Multiplayer, false) } }); @@ -81,7 +81,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic { Menu = MenuType.None; Widget.OpenWindow("DIRECTCONNECT_PANEL", new WidgetArgs() - { + { { "onExit", () => Menu = MenuType.Multiplayer }, { "openLobby", () => OpenLobbyPanel(MenuType.Multiplayer, false) } }); @@ -95,7 +95,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic { Menu = MenuType.None; Widget.OpenWindow("REPLAYBROWSER_PANEL", new WidgetArgs() - { + { { "onExit", () => Menu = MenuType.Settings }, { "onStart", RemoveShellmapUI } }); @@ -105,7 +105,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic { Menu = MenuType.None; Widget.OpenWindow("MUSIC_PANEL", new WidgetArgs() - { + { { "onExit", () => Menu = MenuType.Settings }, }); }; @@ -114,7 +114,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic { Menu = MenuType.None; Widget.OpenWindow("SETTINGS_PANEL", new WidgetArgs() - { + { { "world", world }, { "onExit", () => Menu = MenuType.Settings }, }); @@ -146,9 +146,9 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic var map = WidgetUtils.ChooseInitialMap(Game.Settings.Server.Map); CncConnectingLogic.Connect(IPAddress.Loopback.ToString(), - Game.CreateLocalServer(map), - () => OpenLobbyPanel(MenuType.Main, true), - () => { Game.CloseServer(); Menu = MenuType.Main; }); + Game.CreateLocalServer(map), + () => OpenLobbyPanel(MenuType.Main, true), + () => { Game.CloseServer(); Menu = MenuType.Main; }); } } } diff --git a/OpenRA.Mods.Cnc/Widgets/Logic/CncModBrowserLogic.cs b/OpenRA.Mods.Cnc/Widgets/Logic/CncModBrowserLogic.cs index af8a5429fd..cd76582b22 100644 --- a/OpenRA.Mods.Cnc/Widgets/Logic/CncModBrowserLogic.cs +++ b/OpenRA.Mods.Cnc/Widgets/Logic/CncModBrowserLogic.cs @@ -22,8 +22,8 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic [ObjectCreator.UseCtor] public CncModBrowserLogic([ObjectCreator.Param] Widget widget, - [ObjectCreator.Param] Action onSwitch, - [ObjectCreator.Param] Action onExit) + [ObjectCreator.Param] Action onSwitch, + [ObjectCreator.Param] Action onExit) { var panel = widget.GetWidget("MODS_PANEL"); var modList = panel.GetWidget("MOD_LIST"); diff --git a/OpenRA.Mods.Cnc/Widgets/Logic/CncMusicPlayerLogic.cs b/OpenRA.Mods.Cnc/Widgets/Logic/CncMusicPlayerLogic.cs index ec366c6a1e..0dfa7c44ee 100644 --- a/OpenRA.Mods.Cnc/Widgets/Logic/CncMusicPlayerLogic.cs +++ b/OpenRA.Mods.Cnc/Widgets/Logic/CncMusicPlayerLogic.cs @@ -31,7 +31,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic [ObjectCreator.UseCtor] public CncMusicPlayerLogic([ObjectCreator.Param] Widget widget, - [ObjectCreator.Param] Action onExit) + [ObjectCreator.Param] Action onExit) { panel = widget.GetWidget("MUSIC_PANEL"); @@ -103,7 +103,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic panel.GetWidget("TIME_LABEL").GetText = () => (currentSong == null) ? "" : "{0:D2}:{1:D2} / {2:D2}:{3:D2}".F((int)Sound.MusicSeekPosition / 60, (int)Sound.MusicSeekPosition % 60, - currentSong.Length / 60, currentSong.Length % 60); + currentSong.Length / 60, currentSong.Length % 60); panel.GetWidget("TITLE_LABEL").GetText = () => (currentSong == null) ? "" : currentSong.Title; var musicSlider = panel.GetWidget("MUSIC_SLIDER"); diff --git a/OpenRA.Mods.Cnc/Widgets/Logic/CncServerBrowserLogic.cs b/OpenRA.Mods.Cnc/Widgets/Logic/CncServerBrowserLogic.cs index bbb7bc4b7f..df6fa85b40 100644 --- a/OpenRA.Mods.Cnc/Widgets/Logic/CncServerBrowserLogic.cs +++ b/OpenRA.Mods.Cnc/Widgets/Logic/CncServerBrowserLogic.cs @@ -42,8 +42,8 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic [ObjectCreator.UseCtor] public CncServerBrowserLogic([ObjectCreator.Param] Widget widget, - [ObjectCreator.Param] Action openLobby, - [ObjectCreator.Param] Action onExit) + [ObjectCreator.Param] Action openLobby, + [ObjectCreator.Param] Action onExit) { var panel = widget.GetWidget("SERVERBROWSER_PANEL"); var sl = panel.GetWidget("SERVER_LIST"); @@ -127,9 +127,9 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic return; } - var gamesWaiting = games.Where(g => g.CanJoin()); + var gamesWaiting = games.Where(g => g.CanJoin()); - if (gamesWaiting.Count() == 0) + if (gamesWaiting.Count() == 0) { searchStatus = SearchStatus.NoGames; return; @@ -138,7 +138,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic searchStatus = SearchStatus.Hidden; currentServer = gamesWaiting.FirstOrDefault(); - foreach (var loop in gamesWaiting) + foreach (var loop in gamesWaiting) { var game = loop; diff --git a/OpenRA.Mods.Cnc/Widgets/Logic/CncSettingsLogic.cs b/OpenRA.Mods.Cnc/Widgets/Logic/CncSettingsLogic.cs index 946b224926..8e8009b3c6 100644 --- a/OpenRA.Mods.Cnc/Widgets/Logic/CncSettingsLogic.cs +++ b/OpenRA.Mods.Cnc/Widgets/Logic/CncSettingsLogic.cs @@ -29,8 +29,8 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic [ObjectCreator.UseCtor] public CncSettingsLogic([ObjectCreator.Param] Widget widget, - [ObjectCreator.Param] World world, - [ObjectCreator.Param] Action onExit) + [ObjectCreator.Param] World world, + [ObjectCreator.Param] Action onExit) { this.world = world; var panel = widget.GetWidget("SETTINGS_PANEL"); diff --git a/OpenRA.Mods.Cnc/Widgets/Logic/ProductionTooltipLogic.cs b/OpenRA.Mods.Cnc/Widgets/Logic/ProductionTooltipLogic.cs index a5a8597871..ea72a0435c 100644 --- a/OpenRA.Mods.Cnc/Widgets/Logic/ProductionTooltipLogic.cs +++ b/OpenRA.Mods.Cnc/Widgets/Logic/ProductionTooltipLogic.cs @@ -23,8 +23,8 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic { [ObjectCreator.UseCtor] public ProductionTooltipLogic([ObjectCreator.Param] Widget widget, - [ObjectCreator.Param] TooltipContainerWidget tooltipContainer, - [ObjectCreator.Param] ProductionPaletteWidget palette) + [ObjectCreator.Param] TooltipContainerWidget tooltipContainer, + [ObjectCreator.Param] ProductionPaletteWidget palette) { var pm = palette.world.LocalPlayer.PlayerActor.Trait(); var pr = palette.world.LocalPlayer.PlayerActor.Trait(); @@ -71,7 +71,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic var costString = "$: {0}".F(cost); costLabel.GetText = () => costString; costLabel.GetColor = () => pr.DisplayCash + pr.DisplayOre >= cost - ? Color.White : Color.Red; + ? Color.White : Color.Red; var leftWidth = Math.Max(font.Measure(tooltip.Name).X, requiresFont.Measure(requiresString).X); var rightWidth = new [] {font.Measure(powerString).X, font.Measure(timeString).X, font.Measure(costString).X}.Aggregate(Math.Max); diff --git a/OpenRA.Mods.Cnc/Widgets/Logic/SimpleTooltipLogic.cs b/OpenRA.Mods.Cnc/Widgets/Logic/SimpleTooltipLogic.cs index 93ce65a9a4..d92556ccda 100644 --- a/OpenRA.Mods.Cnc/Widgets/Logic/SimpleTooltipLogic.cs +++ b/OpenRA.Mods.Cnc/Widgets/Logic/SimpleTooltipLogic.cs @@ -18,8 +18,8 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic { [ObjectCreator.UseCtor] public SimpleTooltipLogic([ObjectCreator.Param] Widget widget, - [ObjectCreator.Param] TooltipContainerWidget tooltipContainer, - [ObjectCreator.Param] Func getText) + [ObjectCreator.Param] TooltipContainerWidget tooltipContainer, + [ObjectCreator.Param] Func getText) { var label = widget.GetWidget("LABEL"); diff --git a/OpenRA.Mods.Cnc/Widgets/Logic/SupportPowerTooltipLogic.cs b/OpenRA.Mods.Cnc/Widgets/Logic/SupportPowerTooltipLogic.cs index 27fa1c2617..cf7b360066 100644 --- a/OpenRA.Mods.Cnc/Widgets/Logic/SupportPowerTooltipLogic.cs +++ b/OpenRA.Mods.Cnc/Widgets/Logic/SupportPowerTooltipLogic.cs @@ -19,8 +19,8 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic { [ObjectCreator.UseCtor] public SupportPowerTooltipLogic([ObjectCreator.Param] Widget widget, - [ObjectCreator.Param] TooltipContainerWidget tooltipContainer, - [ObjectCreator.Param] SupportPowersWidget palette) + [ObjectCreator.Param] TooltipContainerWidget tooltipContainer, + [ObjectCreator.Param] SupportPowersWidget palette) { widget.IsVisible = () => palette.TooltipPower != null; var nameLabel = widget.GetWidget("NAME"); @@ -43,7 +43,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic return; time = "{0} / {1}".F(WidgetUtils.FormatTime(sp.RemainingTime), - WidgetUtils.FormatTime(sp.Info.ChargeTime*25)); + WidgetUtils.FormatTime(sp.Info.ChargeTime*25)); if (sp == lastPower) return; diff --git a/OpenRA.Mods.Cnc/Widgets/Logic/WorldTooltipLogic.cs b/OpenRA.Mods.Cnc/Widgets/Logic/WorldTooltipLogic.cs index 606909e4e7..58e70cdc2b 100644 --- a/OpenRA.Mods.Cnc/Widgets/Logic/WorldTooltipLogic.cs +++ b/OpenRA.Mods.Cnc/Widgets/Logic/WorldTooltipLogic.cs @@ -20,8 +20,8 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic { [ObjectCreator.UseCtor] public WorldTooltipLogic([ObjectCreator.Param] Widget widget, - [ObjectCreator.Param] TooltipContainerWidget tooltipContainer, - [ObjectCreator.Param] CncWorldInteractionControllerWidget wic) + [ObjectCreator.Param] TooltipContainerWidget tooltipContainer, + [ObjectCreator.Param] CncWorldInteractionControllerWidget wic) { widget.IsVisible = () => wic.TooltipType != Type.None; var label = widget.GetWidget("LABEL"); diff --git a/OpenRA.Mods.Cnc/Widgets/PowerBarWidget.cs b/OpenRA.Mods.Cnc/Widgets/PowerBarWidget.cs index 69edb27b9a..3a2ab0b3ae 100755 --- a/OpenRA.Mods.Cnc/Widgets/PowerBarWidget.cs +++ b/OpenRA.Mods.Cnc/Widgets/PowerBarWidget.cs @@ -66,9 +66,9 @@ namespace OpenRA.Mods.Cnc.Widgets var b = RenderBounds; var rect = new RectangleF(b.X, - b.Y + (1-providedFrac)*b.Height, - (float)b.Width, - providedFrac*b.Height); + b.Y + (1-providedFrac)*b.Height, + (float)b.Width, + providedFrac*b.Height); Game.Renderer.LineRenderer.FillRect(rect, color); var indicator = ChromeProvider.GetImage("sidebar-bits", "left-indicator"); @@ -77,7 +77,7 @@ namespace OpenRA.Mods.Cnc.Widgets lastDrainedFrac = drainedFrac = float2.Lerp(lastDrainedFrac.GetValueOrDefault(drainedFrac), drainedFrac, .3f); float2 pos = new float2(b.X + b.Width - indicator.size.X, - b.Y + (1-drainedFrac)*b.Height - indicator.size.Y / 2); + b.Y + (1-drainedFrac)*b.Height - indicator.size.Y / 2); Game.Renderer.RgbaSpriteRenderer.DrawSprite(indicator, pos); } diff --git a/OpenRA.Mods.Cnc/Widgets/ProductionPaletteWidget.cs b/OpenRA.Mods.Cnc/Widgets/ProductionPaletteWidget.cs index aaef0f59c9..d89871deba 100755 --- a/OpenRA.Mods.Cnc/Widgets/ProductionPaletteWidget.cs +++ b/OpenRA.Mods.Cnc/Widgets/ProductionPaletteWidget.cs @@ -67,7 +67,7 @@ namespace OpenRA.Mods.Cnc.Widgets [ObjectCreator.UseCtor] public ProductionPaletteWidget([ObjectCreator.Param] World world, - [ObjectCreator.Param] WorldRenderer worldRenderer) + [ObjectCreator.Param] WorldRenderer worldRenderer) { this.world = world; this.worldRenderer = worldRenderer; @@ -83,7 +83,7 @@ namespace OpenRA.Mods.Cnc.Widgets .ToDictionary( u => u.Name, u => Game.modData.SpriteLoader.LoadAllSprites( - u.Traits.Get().Icon ?? (u.Name + "icon"))[0]); + u.Traits.Get().Icon ?? (u.Name + "icon"))[0]); overlayFont = Game.Renderer.Fonts["TinyBold"]; holdOffset = new float2(32,24) - overlayFont.Measure("On Hold") / 2; @@ -257,21 +257,21 @@ namespace OpenRA.Mods.Cnc.Widgets var waiting = first != CurrentQueue.CurrentItem() && !first.Done; if (first.Done) overlayFont.DrawTextWithContrast("Ready", - icon.Pos + readyOffset, - Color.White, Color.Black, 1); + icon.Pos + readyOffset, + Color.White, Color.Black, 1); else if (first.Paused) overlayFont.DrawTextWithContrast("On Hold", - icon.Pos + holdOffset, - Color.White, Color.Black, 1); + icon.Pos + holdOffset, + Color.White, Color.Black, 1); else if (!waiting) overlayFont.DrawTextWithContrast(WidgetUtils.FormatTime(first.RemainingTimeActual), - icon.Pos + timeOffset, - Color.White, Color.Black, 1); + icon.Pos + timeOffset, + Color.White, Color.Black, 1); if (total > 1 || waiting) overlayFont.DrawTextWithContrast(total.ToString(), - icon.Pos + queuedOffset, - Color.White, Color.Black, 1); + icon.Pos + queuedOffset, + Color.White, Color.Black, 1); } } } diff --git a/OpenRA.Mods.Cnc/Widgets/SiloBarWidget.cs b/OpenRA.Mods.Cnc/Widgets/SiloBarWidget.cs index 1c4de76b11..ab665dd943 100755 --- a/OpenRA.Mods.Cnc/Widgets/SiloBarWidget.cs +++ b/OpenRA.Mods.Cnc/Widgets/SiloBarWidget.cs @@ -67,9 +67,9 @@ namespace OpenRA.Mods.Cnc.Widgets var b = RenderBounds; var rect = new RectangleF(b.X, - b.Y + (1-capacityFrac)*b.Height, - (float)b.Width, - capacityFrac*b.Height); + b.Y + (1-capacityFrac)*b.Height, + (float)b.Width, + capacityFrac*b.Height); Game.Renderer.LineRenderer.FillRect(rect, color); var indicator = ChromeProvider.GetImage("sidebar-bits", "right-indicator"); diff --git a/OpenRA.Mods.Cnc/Widgets/SupportPowersWidget.cs b/OpenRA.Mods.Cnc/Widgets/SupportPowersWidget.cs index 1dec1075a4..4dd2fea7b0 100755 --- a/OpenRA.Mods.Cnc/Widgets/SupportPowersWidget.cs +++ b/OpenRA.Mods.Cnc/Widgets/SupportPowersWidget.cs @@ -41,7 +41,7 @@ namespace OpenRA.Mods.Cnc.Widgets [ObjectCreator.UseCtor] public SupportPowersWidget([ObjectCreator.Param] World world, - [ObjectCreator.Param] WorldRenderer worldRenderer) + [ObjectCreator.Param] WorldRenderer worldRenderer) { this.worldRenderer = worldRenderer; spm = world.LocalPlayer.PlayerActor.Trait(); @@ -117,16 +117,16 @@ namespace OpenRA.Mods.Cnc.Widgets { if (p.Power.Ready) overlayFont.DrawTextWithContrast("Ready", - p.Pos + readyOffset, - Color.White, Color.Black, 1); + p.Pos + readyOffset, + Color.White, Color.Black, 1); else if (!p.Power.Active) overlayFont.DrawTextWithContrast("On Hold", - p.Pos + holdOffset, - Color.White, Color.Black, 1); + p.Pos + holdOffset, + Color.White, Color.Black, 1); else overlayFont.DrawTextWithContrast(WidgetUtils.FormatTime(p.Power.RemainingTime), - p.Pos + timeOffset, - Color.White, Color.Black, 1); + p.Pos + timeOffset, + Color.White, Color.Black, 1); } } diff --git a/OpenRA.Mods.Cnc/Widgets/TooltipContainerWidget.cs b/OpenRA.Mods.Cnc/Widgets/TooltipContainerWidget.cs index d51f7279e1..1cc4d04edd 100755 --- a/OpenRA.Mods.Cnc/Widgets/TooltipContainerWidget.cs +++ b/OpenRA.Mods.Cnc/Widgets/TooltipContainerWidget.cs @@ -61,7 +61,7 @@ namespace OpenRA.Mods.Cnc.Widgets } } - public override string GetCursor(int2 pos) { return null; } - public override Widget Clone() { throw new NotImplementedException(); } + public override string GetCursor(int2 pos) { return null; } + public override Widget Clone() { throw new NotImplementedException(); } } } diff --git a/OpenRA.Mods.RA/AcceptsSupplies.cs b/OpenRA.Mods.RA/AcceptsSupplies.cs index dcdc1d8e51..e37d908008 100644 --- a/OpenRA.Mods.RA/AcceptsSupplies.cs +++ b/OpenRA.Mods.RA/AcceptsSupplies.cs @@ -12,7 +12,7 @@ using OpenRA.Traits; namespace OpenRA.Mods.RA { - class AcceptsSuppliesInfo : TraitInfo {} + class AcceptsSuppliesInfo : TraitInfo {} - class AcceptsSupplies {} + class AcceptsSupplies {} } diff --git a/OpenRA.Mods.RA/Activities/Attack.cs b/OpenRA.Mods.RA/Activities/Attack.cs index fbd081c2bb..e290444337 100755 --- a/OpenRA.Mods.RA/Activities/Attack.cs +++ b/OpenRA.Mods.RA/Activities/Attack.cs @@ -22,10 +22,10 @@ namespace OpenRA.Mods.RA.Activities int Range; bool AllowMovement; - int nextPathTime; + int nextPathTime; - const int delayBetweenPathingAttempts = 20; - const int delaySpread = 5; + const int delayBetweenPathingAttempts = 20; + const int delaySpread = 5; public Attack(Target target, int range, bool allowMovement) { @@ -58,16 +58,16 @@ namespace OpenRA.Mods.RA.Activities if (targetable != null && !targetable.TargetableBy(Target.Actor, self)) return NextActivity; - if (!Combat.IsInRange(self.CenterLocation, Range, Target)) - { - if (--nextPathTime > 0) - return this; + if (!Combat.IsInRange(self.CenterLocation, Range, Target)) + { + if (--nextPathTime > 0) + return this; - nextPathTime = self.World.SharedRandom.Next(delayBetweenPathingAttempts - delaySpread, - delayBetweenPathingAttempts + delaySpread); + nextPathTime = self.World.SharedRandom.Next(delayBetweenPathingAttempts - delaySpread, + delayBetweenPathingAttempts + delaySpread); - return (AllowMovement) ? Util.SequenceActivities(self.Trait().MoveWithinRange(Target, Range), this) : NextActivity; - } + return (AllowMovement) ? Util.SequenceActivities(self.Trait().MoveWithinRange(Target, Range), this) : NextActivity; + } var desiredFacing = Util.GetFacing(Target.CenterLocation - self.CenterLocation, 0); if (facing.Facing != desiredFacing) diff --git a/OpenRA.Mods.RA/Activities/DonateSupplies.cs b/OpenRA.Mods.RA/Activities/DonateSupplies.cs index 4e68edbea5..135376c5c2 100644 --- a/OpenRA.Mods.RA/Activities/DonateSupplies.cs +++ b/OpenRA.Mods.RA/Activities/DonateSupplies.cs @@ -14,30 +14,30 @@ using OpenRA.Mods.RA.Effects; namespace OpenRA.Mods.RA.Activities { - class DonateSupplies : Activity - { - Actor target; - int payload; + class DonateSupplies : Activity + { + Actor target; + int payload; - public DonateSupplies(Actor target, int payload) - { - this.target = target; - this.payload = payload; - } + public DonateSupplies(Actor target, int payload) + { + this.target = target; + this.payload = payload; + } - public override Activity Tick(Actor self) - { - if (IsCanceled) return NextActivity; - if (target == null || !target.IsInWorld || target.IsDead()) return NextActivity; - if (!target.OccupiesSpace.OccupiedCells().Any(x => x.First == self.Location)) - return NextActivity; + public override Activity Tick(Actor self) + { + if (IsCanceled) return NextActivity; + if (target == null || !target.IsInWorld || target.IsDead()) return NextActivity; + if (!target.OccupiesSpace.OccupiedCells().Any(x => x.First == self.Location)) + return NextActivity; - target.Owner.PlayerActor.Trait().GiveCash(payload); - self.Destroy(); + target.Owner.PlayerActor.Trait().GiveCash(payload); + self.Destroy(); if (self.World.LocalPlayer != null && self.Owner.Stances[self.World.LocalPlayer] == Stance.Ally) self.World.AddFrameEndTask(w => w.Add(new CashTick(payload, 30, 2, target.CenterLocation, target.Owner.ColorRamp.GetColor(0)))); - return this; - } - } + return this; + } + } } diff --git a/OpenRA.Mods.RA/Activities/Follow.cs b/OpenRA.Mods.RA/Activities/Follow.cs index b9140b7102..a534d036b2 100644 --- a/OpenRA.Mods.RA/Activities/Follow.cs +++ b/OpenRA.Mods.RA/Activities/Follow.cs @@ -17,10 +17,10 @@ namespace OpenRA.Mods.RA.Activities { Target Target; int Range; - int nextPathTime; + int nextPathTime; - const int delayBetweenPathingAttempts = 20; - const int delaySpread = 5; + const int delayBetweenPathingAttempts = 20; + const int delaySpread = 5; public Follow(Target target, int range) { @@ -36,12 +36,12 @@ namespace OpenRA.Mods.RA.Activities var inRange = ( Util.CellContaining( Target.CenterLocation ) - self.Location ).LengthSquared < Range * Range; if( inRange ) return this; - if (--nextPathTime > 0) return this; + if (--nextPathTime > 0) return this; - nextPathTime = self.World.SharedRandom.Next(delayBetweenPathingAttempts - delaySpread, - delayBetweenPathingAttempts + delaySpread); + nextPathTime = self.World.SharedRandom.Next(delayBetweenPathingAttempts - delaySpread, + delayBetweenPathingAttempts + delaySpread); - var mobile = self.Trait(); + var mobile = self.Trait(); return Util.SequenceActivities( mobile.MoveWithinRange( Target, Range ), this ); } } diff --git a/OpenRA.Mods.RA/Activities/Rearm.cs b/OpenRA.Mods.RA/Activities/Rearm.cs index 6f32eb3c1f..dfca5d2d51 100644 --- a/OpenRA.Mods.RA/Activities/Rearm.cs +++ b/OpenRA.Mods.RA/Activities/Rearm.cs @@ -17,16 +17,16 @@ namespace OpenRA.Mods.RA.Activities public class Rearm : Activity { readonly LimitedAmmo limitedAmmo; - int ticksPerPip = 25 * 2; - int remainingTicks = 25 * 2; + int ticksPerPip = 25 * 2; + int remainingTicks = 25 * 2; - public Rearm(Actor self) - { + public Rearm(Actor self) + { limitedAmmo = self.TraitOrDefault(); if (limitedAmmo != null) - ticksPerPip = limitedAmmo.ReloadTimePerAmmo(); - remainingTicks = ticksPerPip; - } + ticksPerPip = limitedAmmo.ReloadTimePerAmmo(); + remainingTicks = ticksPerPip; + } public override Activity Tick(Actor self) { diff --git a/OpenRA.Mods.RA/Activities/Sell.cs b/OpenRA.Mods.RA/Activities/Sell.cs index 5d859f99af..9a245177db 100755 --- a/OpenRA.Mods.RA/Activities/Sell.cs +++ b/OpenRA.Mods.RA/Activities/Sell.cs @@ -31,8 +31,8 @@ namespace OpenRA.Mods.RA.Activities foreach (var ns in self.TraitsImplementing()) ns.Sold(self); - if (refund > 0 && self.World.LocalPlayer != null && self.Owner.Stances[self.World.LocalPlayer] == Stance.Ally) - self.World.AddFrameEndTask( + if (refund > 0 && self.World.LocalPlayer != null && self.Owner.Stances[self.World.LocalPlayer] == Stance.Ally) + self.World.AddFrameEndTask( w => w.Add(new CashTick(refund, 30, 2, self.CenterLocation, self.Owner.ColorRamp.GetColor(0)))); diff --git a/OpenRA.Mods.RA/Air/EjectOnDeath.cs b/OpenRA.Mods.RA/Air/EjectOnDeath.cs index 4091deacfe..fa2676fdd8 100644 --- a/OpenRA.Mods.RA/Air/EjectOnDeath.cs +++ b/OpenRA.Mods.RA/Air/EjectOnDeath.cs @@ -33,7 +33,7 @@ namespace OpenRA.Mods.RA var aircraft = self.Trait(); if (IsSuitableCell(pilot, self.Location) && r > 100 - info.SuccessRate && aircraft.Altitude > 10 - && self.Owner.WinState != WinState.Lost) + && self.Owner.WinState != WinState.Lost) { self.World.AddFrameEndTask(w => w.Add( new Parachute(pilot.Owner, diff --git a/OpenRA.Mods.RA/Air/FlyCircle.cs b/OpenRA.Mods.RA/Air/FlyCircle.cs index 9b3a889440..24c92d2ad1 100644 --- a/OpenRA.Mods.RA/Air/FlyCircle.cs +++ b/OpenRA.Mods.RA/Air/FlyCircle.cs @@ -13,25 +13,25 @@ using OpenRA.Traits; namespace OpenRA.Mods.RA.Air { - public class FlyCircle : Activity - { - public override Activity Tick(Actor self) - { - var cruiseAltitude = self.Info.Traits.Get().CruiseAltitude; + public class FlyCircle : Activity + { + public override Activity Tick(Actor self) + { + var cruiseAltitude = self.Info.Traits.Get().CruiseAltitude; - if (IsCanceled) return NextActivity; + if (IsCanceled) return NextActivity; - var aircraft = self.Trait(); + var aircraft = self.Trait(); - var desiredFacing = aircraft.Facing + 64; // we can't possibly turn this fast. - if (aircraft.Altitude == cruiseAltitude) - aircraft.Facing = Util.TickFacing(aircraft.Facing, desiredFacing, aircraft.ROT); + var desiredFacing = aircraft.Facing + 64; // we can't possibly turn this fast. + if (aircraft.Altitude == cruiseAltitude) + aircraft.Facing = Util.TickFacing(aircraft.Facing, desiredFacing, aircraft.ROT); - if (aircraft.Altitude < cruiseAltitude) - ++aircraft.Altitude; + if (aircraft.Altitude < cruiseAltitude) + ++aircraft.Altitude; - FlyUtil.Fly(self, cruiseAltitude); - return this; - } - } + FlyUtil.Fly(self, cruiseAltitude); + return this; + } + } } diff --git a/OpenRA.Mods.RA/Air/ReturnOnIdle.cs b/OpenRA.Mods.RA/Air/ReturnOnIdle.cs index 75a953738d..f042f1d3ed 100755 --- a/OpenRA.Mods.RA/Air/ReturnOnIdle.cs +++ b/OpenRA.Mods.RA/Air/ReturnOnIdle.cs @@ -34,29 +34,29 @@ namespace OpenRA.Mods.RA.Air } else { - // nowhere to land, pick something friendly and circle over it. + // nowhere to land, pick something friendly and circle over it. - // i'd prefer something we own - var someBuilding = self.World.ActorsWithTrait() - .Select( a => a.Actor ) - .FirstOrDefault(a => a.Owner == self.Owner); + // i'd prefer something we own + var someBuilding = self.World.ActorsWithTrait() + .Select( a => a.Actor ) + .FirstOrDefault(a => a.Owner == self.Owner); - // failing that, something unlikely to shoot at us - if (someBuilding == null) - someBuilding = self.World.ActorsWithTrait() - .Select( a => a.Actor ) - .FirstOrDefault(a => self.Owner.Stances[a.Owner] == Stance.Ally); + // failing that, something unlikely to shoot at us + if (someBuilding == null) + someBuilding = self.World.ActorsWithTrait() + .Select( a => a.Actor ) + .FirstOrDefault(a => self.Owner.Stances[a.Owner] == Stance.Ally); - if (someBuilding == null) - { - // ... going down the garden to eat worms ... - self.QueueActivity(new FlyOffMap()); - self.QueueActivity(new RemoveSelf()); - return; - } + if (someBuilding == null) + { + // ... going down the garden to eat worms ... + self.QueueActivity(new FlyOffMap()); + self.QueueActivity(new RemoveSelf()); + return; + } - self.QueueActivity(Fly.ToCell(someBuilding.Location)); - self.QueueActivity(new FlyCircle()); + self.QueueActivity(Fly.ToCell(someBuilding.Location)); + self.QueueActivity(new FlyCircle()); } } } diff --git a/OpenRA.Mods.RA/Air/TargetableAircraft.cs b/OpenRA.Mods.RA/Air/TargetableAircraft.cs index dabda19e44..9dff2197fe 100755 --- a/OpenRA.Mods.RA/Air/TargetableAircraft.cs +++ b/OpenRA.Mods.RA/Air/TargetableAircraft.cs @@ -15,25 +15,25 @@ using OpenRA.Traits; namespace OpenRA.Mods.RA.Air { - public class TargetableAircraftInfo : TargetableUnitInfo, Requires - { - public readonly string[] GroundedTargetTypes = { }; - public override object Create(ActorInitializer init) { return new TargetableAircraft(init.self, this); } - } + public class TargetableAircraftInfo : TargetableUnitInfo, Requires + { + public readonly string[] GroundedTargetTypes = { }; + public override object Create(ActorInitializer init) { return new TargetableAircraft(init.self, this); } + } - public class TargetableAircraft : TargetableUnit - { - Aircraft Aircraft; - public TargetableAircraft(Actor self, TargetableAircraftInfo info) - : base(self, info) - { - Aircraft = self.Trait(); - } + public class TargetableAircraft : TargetableUnit + { + Aircraft Aircraft; + public TargetableAircraft(Actor self, TargetableAircraftInfo info) + : base(self, info) + { + Aircraft = self.Trait(); + } - public override string[] TargetTypes - { - get { return (Aircraft.Altitude > 0) ? info.TargetTypes - : info.GroundedTargetTypes; } - } - } + public override string[] TargetTypes + { + get { return (Aircraft.Altitude > 0) ? info.TargetTypes + : info.GroundedTargetTypes; } + } + } } diff --git a/OpenRA.Mods.RA/Attack/AttackBase.cs b/OpenRA.Mods.RA/Attack/AttackBase.cs index 3c7d7eff02..e23924f3ad 100644 --- a/OpenRA.Mods.RA/Attack/AttackBase.cs +++ b/OpenRA.Mods.RA/Attack/AttackBase.cs @@ -84,7 +84,7 @@ namespace OpenRA.Mods.RA if (self.TraitsImplementing().Any(d => d.Disabled)) return false; if (target.IsActor && target.Actor.HasTrait() && - !target.Actor.Trait().TargetableBy(target.Actor,self)) + !target.Actor.Trait().TargetableBy(target.Actor,self)) return false; return true; diff --git a/OpenRA.Mods.RA/Bridge.cs b/OpenRA.Mods.RA/Bridge.cs index d6d5e94139..612e908791 100644 --- a/OpenRA.Mods.RA/Bridge.cs +++ b/OpenRA.Mods.RA/Bridge.cs @@ -159,7 +159,7 @@ namespace OpenRA.Mods.RA { // If this is a long bridge next to a destroyed shore piece, we need die to give clean edges to the break if (Info.Long && Health.DamageState != DamageState.Dead && - ((southNeighbour != null && Info.ShorePieces.Contains(southNeighbour.Type) && !IsIntact(southNeighbour)) || + ((southNeighbour != null && Info.ShorePieces.Contains(southNeighbour.Type) && !IsIntact(southNeighbour)) || (northNeighbour != null && Info.ShorePieces.Contains(northNeighbour.Type) && !IsIntact(northNeighbour)))) { self.Kill(self); // this changes the damagestate diff --git a/OpenRA.Mods.RA/Buildable.cs b/OpenRA.Mods.RA/Buildable.cs index 9a8bca0c3d..2692286f69 100755 --- a/OpenRA.Mods.RA/Buildable.cs +++ b/OpenRA.Mods.RA/Buildable.cs @@ -25,7 +25,7 @@ namespace OpenRA.Mods.RA // todo: UI fluff; doesn't belong here public readonly int BuildPaletteOrder = 9999; - public readonly string Hotkey = null; + public readonly string Hotkey = null; } public class Buildable { } diff --git a/OpenRA.Mods.RA/Buildings/Building.cs b/OpenRA.Mods.RA/Buildings/Building.cs index 46e578b167..46bcae9291 100755 --- a/OpenRA.Mods.RA/Buildings/Building.cs +++ b/OpenRA.Mods.RA/Buildings/Building.cs @@ -34,8 +34,8 @@ namespace OpenRA.Mods.RA.Buildings public bool IsCloseEnoughToBase(World world, Player p, string buildingName, int2 topLeft) { - if (p.PlayerActor.Trait().BuildAnywhere) - return true; + if (p.PlayerActor.Trait().BuildAnywhere) + return true; var buildingMaxBounds = Dimensions; if( Rules.Info[ buildingName ].Traits.Contains() ) diff --git a/OpenRA.Mods.RA/Buildings/TechTree.cs b/OpenRA.Mods.RA/Buildings/TechTree.cs index b35254d5f3..d4624a7a0b 100755 --- a/OpenRA.Mods.RA/Buildings/TechTree.cs +++ b/OpenRA.Mods.RA/Buildings/TechTree.cs @@ -61,8 +61,8 @@ namespace OpenRA.Mods.RA.Buildings return ret; - foreach (var b in player.World.ActorsWithTrait() - .Where(a => a.Actor.IsInWorld && !a.Actor.IsDead() && a.Actor.Owner == player)) + foreach (var b in player.World.ActorsWithTrait() + .Where(a => a.Actor.IsInWorld && !a.Actor.IsDead() && a.Actor.Owner == player)) foreach (var p in b.Trait.ProvidesPrerequisites) ret[ p ].Add( b.Actor ); diff --git a/OpenRA.Mods.RA/Chronoshiftable.cs b/OpenRA.Mods.RA/Chronoshiftable.cs index 15f50d1e6e..6f20385360 100755 --- a/OpenRA.Mods.RA/Chronoshiftable.cs +++ b/OpenRA.Mods.RA/Chronoshiftable.cs @@ -41,13 +41,13 @@ namespace OpenRA.Mods.RA } // Can't be used in synced code, except with ignoreVis. - public virtual bool CanChronoshiftTo(Actor self, int2 targetLocation, bool ignoreVis) - { - // Todo: Allow enemy units to be chronoshifted into bad terrain to kill them - return self.HasTrait() && - self.Trait().CanEnterCell(targetLocation) && - (ignoreVis || self.World.LocalShroud.IsExplored(targetLocation)); - } + public virtual bool CanChronoshiftTo(Actor self, int2 targetLocation, bool ignoreVis) + { + // Todo: Allow enemy units to be chronoshifted into bad terrain to kill them + return self.HasTrait() && + self.Trait().CanEnterCell(targetLocation) && + (ignoreVis || self.World.LocalShroud.IsExplored(targetLocation)); + } public virtual bool Teleport(Actor self, int2 targetLocation, int duration, bool killCargo, Actor chronosphere) { diff --git a/OpenRA.Mods.RA/ConquestVictoryConditions.cs b/OpenRA.Mods.RA/ConquestVictoryConditions.cs index 5940de756f..7e57c7effd 100644 --- a/OpenRA.Mods.RA/ConquestVictoryConditions.cs +++ b/OpenRA.Mods.RA/ConquestVictoryConditions.cs @@ -31,13 +31,13 @@ namespace OpenRA.Mods.RA if (self.Owner.WinState != WinState.Undefined || self.Owner.NonCombatant) return; var hasAnything = self.World.ActorsWithTrait() - .Any( a => a.Actor.Owner == self.Owner ); + .Any( a => a.Actor.Owner == self.Owner ); if (!hasAnything && !self.Owner.NonCombatant) Lose(self); var others = self.World.Players.Where( p => !p.NonCombatant - && p != self.Owner && p.Stances[self.Owner] != Stance.Ally ); + && p != self.Owner && p.Stances[self.Owner] != Stance.Ally ); if (others.Count() == 0) return; @@ -58,8 +58,8 @@ namespace OpenRA.Mods.RA Game.Debug("{0} is defeated.".F(self.Owner.PlayerName)); - foreach (var a in self.World.Actors.Where(a => a.Owner == self.Owner)) - a.Kill(a); + foreach (var a in self.World.Actors.Where(a => a.Owner == self.Owner)) + a.Kill(a); if (self.Owner == self.World.LocalPlayer) { diff --git a/OpenRA.Mods.RA/CrateDrop.cs b/OpenRA.Mods.RA/CrateDrop.cs index fd7a0c945d..afa1fa93bd 100644 --- a/OpenRA.Mods.RA/CrateDrop.cs +++ b/OpenRA.Mods.RA/CrateDrop.cs @@ -88,7 +88,7 @@ namespace OpenRA.Mods.RA var startPos = w.ChooseRandomEdgeCell(); var plane = w.CreateActor("badr", new TypeDictionary - { + { new LocationInit( startPos ), new OwnerInit( w.WorldActor.Owner), new FacingInit( Util.GetFacing(p - startPos, 0) ), diff --git a/OpenRA.Mods.RA/CrateSpawner.cs b/OpenRA.Mods.RA/CrateSpawner.cs index 59d6dd5e57..a10d826229 100644 --- a/OpenRA.Mods.RA/CrateSpawner.cs +++ b/OpenRA.Mods.RA/CrateSpawner.cs @@ -68,7 +68,7 @@ namespace OpenRA.Mods.RA self.World.AddFrameEndTask( w => crates.Add(w.CreateActor("crate", new TypeDictionary - { + { new LocationInit( p ), new OwnerInit( self.World.WorldActor.Owner ), }))); diff --git a/OpenRA.Mods.RA/Crates/GiveMcvCrateAction.cs b/OpenRA.Mods.RA/Crates/GiveMcvCrateAction.cs index a03b9fa79b..164580ed83 100644 --- a/OpenRA.Mods.RA/Crates/GiveMcvCrateAction.cs +++ b/OpenRA.Mods.RA/Crates/GiveMcvCrateAction.cs @@ -30,10 +30,10 @@ namespace OpenRA.Mods.RA.Crates return 0; // there's some other really good reason why we shouldn't give this. var hasBase = self.World.ActorsWithTrait() - .Any(a => a.Actor.Owner == collector.Owner); + .Any(a => a.Actor.Owner == collector.Owner); return hasBase ? info.SelectionShares : - (info as GiveMcvCrateActionInfo).NoBaseSelectionShares; + (info as GiveMcvCrateActionInfo).NoBaseSelectionShares; } } } diff --git a/OpenRA.Mods.RA/Crates/GiveUnitCrateAction.cs b/OpenRA.Mods.RA/Crates/GiveUnitCrateAction.cs index 997e8dbfa1..386416874f 100644 --- a/OpenRA.Mods.RA/Crates/GiveUnitCrateAction.cs +++ b/OpenRA.Mods.RA/Crates/GiveUnitCrateAction.cs @@ -51,7 +51,7 @@ namespace OpenRA.Mods.RA.Crates if (location != null) collector.World.AddFrameEndTask( w => w.CreateActor(Info.Unit, new TypeDictionary - { + { new LocationInit( location.Value ), new OwnerInit( Info.Owner ?? collector.Owner.InternalName ) })); diff --git a/OpenRA.Mods.RA/Crates/SupportPowerCrateAction.cs b/OpenRA.Mods.RA/Crates/SupportPowerCrateAction.cs index 92580d1ce3..5d09aec7ad 100644 --- a/OpenRA.Mods.RA/Crates/SupportPowerCrateAction.cs +++ b/OpenRA.Mods.RA/Crates/SupportPowerCrateAction.cs @@ -32,7 +32,7 @@ namespace OpenRA.Mods.RA.Crates public override void Activate(Actor collector) { collector.World.AddFrameEndTask(w => w.CreateActor(Info.Proxy, new TypeDictionary - { + { new OwnerInit( collector.Owner ) })); } diff --git a/OpenRA.Mods.RA/Effects/Bullet.cs b/OpenRA.Mods.RA/Effects/Bullet.cs index 298062187b..b44e238f72 100755 --- a/OpenRA.Mods.RA/Effects/Bullet.cs +++ b/OpenRA.Mods.RA/Effects/Bullet.cs @@ -31,10 +31,10 @@ namespace OpenRA.Mods.RA.Effects public readonly bool Proximity = false; public readonly float Angle = 0; public readonly int TrailInterval = 2; - public readonly int ContrailLength = 0; - public readonly Color ContrailColor = Color.White; - public readonly bool ContrailUsePlayerColor = false; - public readonly int ContrailDelay = 1; + public readonly int ContrailLength = 0; + public readonly Color ContrailColor = Color.White; + public readonly bool ContrailUsePlayerColor = false; + public readonly int ContrailDelay = 1; public IEffect Create(ProjectileArgs args) { return new Bullet( this, args ); } } @@ -48,7 +48,7 @@ namespace OpenRA.Mods.RA.Effects Animation anim; const int BaseBulletSpeed = 100; /* pixels / 40ms frame */ - ContrailHistory Trail; + ContrailHistory Trail; public Bullet(BulletInfo info, ProjectileArgs args) { @@ -67,12 +67,12 @@ namespace OpenRA.Mods.RA.Effects anim.PlayRepeating("idle"); } - if (Info.ContrailLength > 0) - { - Trail = new ContrailHistory(Info.ContrailLength, - Info.ContrailUsePlayerColor ? ContrailHistory.ChooseColor(args.firedBy) : Info.ContrailColor, - Info.ContrailDelay); - } + if (Info.ContrailLength > 0) + { + Trail = new ContrailHistory(Info.ContrailLength, + Info.ContrailUsePlayerColor ? ContrailHistory.ChooseColor(args.firedBy) : Info.ContrailColor, + Info.ContrailDelay); + } } int TotalTime() { return (Args.dest - Args.src).Length * BaseBulletSpeed / Info.Speed; } @@ -123,8 +123,8 @@ namespace OpenRA.Mods.RA.Effects ticksToNextSmoke = Info.TrailInterval; } - if (Trail != null) - Trail.Tick(highPos); + if (Trail != null) + Trail.Tick(highPos); } if (!Info.High) // check for hitting a wall @@ -144,35 +144,35 @@ namespace OpenRA.Mods.RA.Effects const float height = .1f; - public IEnumerable Render() - { - if (anim != null) - { - var at = (float)t / TotalTime(); + public IEnumerable Render() + { + if (anim != null) + { + var at = (float)t / TotalTime(); - var altitude = float2.Lerp(Args.srcAltitude, Args.destAltitude, at); - var pos = float2.Lerp(Args.src, Args.dest, at) - new float2(0, altitude); + var altitude = float2.Lerp(Args.srcAltitude, Args.destAltitude, at); + var pos = float2.Lerp(Args.src, Args.dest, at) - new float2(0, altitude); - if (Args.firedBy.World.LocalShroud.IsVisible(OpenRA.Traits.Util.CellContaining(pos))) - { - if (Info.High || Info.Angle > 0) - { - if (Info.Shadow) - yield return new Renderable(anim.Image, pos - .5f * anim.Image.size, "shadow", (int)pos.Y); + if (Args.firedBy.World.LocalShroud.IsVisible(OpenRA.Traits.Util.CellContaining(pos))) + { + if (Info.High || Info.Angle > 0) + { + if (Info.Shadow) + yield return new Renderable(anim.Image, pos - .5f * anim.Image.size, "shadow", (int)pos.Y); - var highPos = pos - new float2(0, GetAltitude()); + var highPos = pos - new float2(0, GetAltitude()); - yield return new Renderable(anim.Image, highPos - .5f * anim.Image.size, "effect", (int)pos.Y); - } - else - yield return new Renderable(anim.Image, pos - .5f * anim.Image.size, - Args.weapon.Underwater ? "shadow" : "effect", (int)pos.Y); - } - } + yield return new Renderable(anim.Image, highPos - .5f * anim.Image.size, "effect", (int)pos.Y); + } + else + yield return new Renderable(anim.Image, pos - .5f * anim.Image.size, + Args.weapon.Underwater ? "shadow" : "effect", (int)pos.Y); + } + } - if (Trail != null) - Trail.Render(Args.firedBy); - } + if (Trail != null) + Trail.Render(Args.firedBy); + } void Explode( World world ) { diff --git a/OpenRA.Mods.RA/Effects/Contrail.cs b/OpenRA.Mods.RA/Effects/Contrail.cs index d51ac31de7..9bb5fb0ea8 100755 --- a/OpenRA.Mods.RA/Effects/Contrail.cs +++ b/OpenRA.Mods.RA/Effects/Contrail.cs @@ -21,7 +21,7 @@ namespace OpenRA.Mods.RA public readonly int[] ContrailOffset = {0, 0}; public readonly int TrailLength = 20; - public readonly Color Color = Color.White; + public readonly Color Color = Color.White; public readonly bool UsePlayerColor = true; public object Create(ActorInitializer init) { return new Contrail(init.self, this); } @@ -45,64 +45,64 @@ namespace OpenRA.Mods.RA public void Tick(Actor self) { - history.Tick(self.CenterLocation - new int2(0, move.Altitude) + history.Tick(self.CenterLocation - new int2(0, move.Altitude) - Combat.GetTurretPosition(self, facing, contrailTurret)); } - public void RenderAfterWorld(WorldRenderer wr, Actor self) { history.Render(self); } + public void RenderAfterWorld(WorldRenderer wr, Actor self) { history.Render(self); } } - class ContrailHistory - { - List positions = new List(); - readonly int TrailLength; - readonly Color Color; - readonly int StartSkip; + class ContrailHistory + { + List positions = new List(); + readonly int TrailLength; + readonly Color Color; + readonly int StartSkip; - public static Color ChooseColor(Actor self) - { - var ownerColor = Color.FromArgb(255, self.Owner.ColorRamp.GetColor(0)); - return PlayerColorRemap.ColorLerp(0.5f, ownerColor, Color.White); - } + public static Color ChooseColor(Actor self) + { + var ownerColor = Color.FromArgb(255, self.Owner.ColorRamp.GetColor(0)); + return PlayerColorRemap.ColorLerp(0.5f, ownerColor, Color.White); + } - public ContrailHistory(int trailLength, Color color) - : this(trailLength, color, 0) { } + public ContrailHistory(int trailLength, Color color) + : this(trailLength, color, 0) { } - public ContrailHistory(int trailLength, Color color, int startSkip) - { - this.TrailLength = trailLength; - this.Color = color; - this.StartSkip = startSkip; - } + public ContrailHistory(int trailLength, Color color, int startSkip) + { + this.TrailLength = trailLength; + this.Color = color; + this.StartSkip = startSkip; + } - public void Tick(float2 currentPos) - { - positions.Add(currentPos); - if (positions.Count >= TrailLength) - positions.RemoveAt(0); - } + public void Tick(float2 currentPos) + { + positions.Add(currentPos); + if (positions.Count >= TrailLength) + positions.RemoveAt(0); + } - public void Render(Actor self) - { - Color trailStart = Color; - Color trailEnd = Color.FromArgb(trailStart.A - 255 / TrailLength, trailStart.R, - trailStart.G, trailStart.B); + public void Render(Actor self) + { + Color trailStart = Color; + Color trailEnd = Color.FromArgb(trailStart.A - 255 / TrailLength, trailStart.R, + trailStart.G, trailStart.B); - for (int i = positions.Count - 1 - StartSkip; i >= 1; --i) - { - var conPos = positions[i]; - var nextPos = positions[i - 1]; + for (int i = positions.Count - 1 - StartSkip; i >= 1; --i) + { + var conPos = positions[i]; + var nextPos = positions[i - 1]; - if (self.World.LocalShroud.IsVisible(OpenRA.Traits.Util.CellContaining(conPos)) || - self.World.LocalShroud.IsVisible(OpenRA.Traits.Util.CellContaining(nextPos))) - { - Game.Renderer.WorldLineRenderer.DrawLine(conPos, nextPos, trailStart, trailEnd); + if (self.World.LocalShroud.IsVisible(OpenRA.Traits.Util.CellContaining(conPos)) || + self.World.LocalShroud.IsVisible(OpenRA.Traits.Util.CellContaining(nextPos))) + { + Game.Renderer.WorldLineRenderer.DrawLine(conPos, nextPos, trailStart, trailEnd); - trailStart = trailEnd; - trailEnd = Color.FromArgb(trailStart.A - 255 / positions.Count, trailStart.R, - trailStart.G, trailStart.B); - } - } - } - } + trailStart = trailEnd; + trailEnd = Color.FromArgb(trailStart.A - 255 / positions.Count, trailStart.R, + trailStart.G, trailStart.B); + } + } + } + } } diff --git a/OpenRA.Mods.RA/Effects/Missile.cs b/OpenRA.Mods.RA/Effects/Missile.cs index a6a7caf17d..5d69008d73 100755 --- a/OpenRA.Mods.RA/Effects/Missile.cs +++ b/OpenRA.Mods.RA/Effects/Missile.cs @@ -33,10 +33,10 @@ namespace OpenRA.Mods.RA.Effects public readonly int RangeLimit = 0; public readonly bool TurboBoost = false; public readonly int TrailInterval = 2; - public readonly int ContrailLength = 0; - public readonly Color ContrailColor = Color.White; - public readonly bool ContrailUsePlayerColor = false; - public readonly int ContrailDelay = 1; + public readonly int ContrailLength = 0; + public readonly Color ContrailColor = Color.White; + public readonly bool ContrailUsePlayerColor = false; + public readonly int ContrailDelay = 1; public IEffect Create(ProjectileArgs args) { return new Missile( this, args ); } } @@ -54,33 +54,33 @@ namespace OpenRA.Mods.RA.Effects int Facing; int t; int Altitude; - ContrailHistory Trail; + ContrailHistory Trail; - public Missile(MissileInfo info, ProjectileArgs args) - { - Info = info; - Args = args; + public Missile(MissileInfo info, ProjectileArgs args) + { + Info = info; + Args = args; - SubPxPosition = 1024 * Args.src; - Altitude = Args.srcAltitude; - Facing = Args.facing; + SubPxPosition = 1024 * Args.src; + Altitude = Args.srcAltitude; + Facing = Args.facing; - if (info.Inaccuracy > 0) - offset = (info.Inaccuracy * args.firedBy.World.SharedRandom.Gauss2D(2)).ToInt2(); + if (info.Inaccuracy > 0) + offset = (info.Inaccuracy * args.firedBy.World.SharedRandom.Gauss2D(2)).ToInt2(); - if (Info.Image != null) - { - anim = new Animation(Info.Image, () => Facing); - anim.PlayRepeating("idle"); - } + if (Info.Image != null) + { + anim = new Animation(Info.Image, () => Facing); + anim.PlayRepeating("idle"); + } - if (Info.ContrailLength > 0) - { - Trail = new ContrailHistory(Info.ContrailLength, - Info.ContrailUsePlayerColor ? ContrailHistory.ChooseColor(args.firedBy) : Info.ContrailColor, - Info.ContrailDelay); - } - } + if (Info.ContrailLength > 0) + { + Trail = new ContrailHistory(Info.ContrailLength, + Info.ContrailUsePlayerColor ? ContrailHistory.ChooseColor(args.firedBy) : Info.ContrailColor, + Info.ContrailDelay); + } + } // In pixels const int MissileCloseEnough = 7; @@ -140,8 +140,8 @@ namespace OpenRA.Mods.RA.Effects Explode(world); } - if (Trail != null) - Trail.Tick(PxPosition - new float2(0,Altitude)); + if (Trail != null) + Trail.Tick(PxPosition - new float2(0,Altitude)); } void Explode(World world) @@ -154,12 +154,12 @@ namespace OpenRA.Mods.RA.Effects public IEnumerable Render() { - if (Args.firedBy.World.LocalShroud.IsVisible(OpenRA.Traits.Util.CellContaining(PxPosition.ToFloat2()))) - yield return new Renderable(anim.Image,PxPosition.ToFloat2() - 0.5f * anim.Image.size - new float2(0, Altitude), - Args.weapon.Underwater ? "shadow" : "effect", PxPosition.Y); + if (Args.firedBy.World.LocalShroud.IsVisible(OpenRA.Traits.Util.CellContaining(PxPosition.ToFloat2()))) + yield return new Renderable(anim.Image,PxPosition.ToFloat2() - 0.5f * anim.Image.size - new float2(0, Altitude), + Args.weapon.Underwater ? "shadow" : "effect", PxPosition.Y); - if (Trail != null) - Trail.Render(Args.firedBy); + if (Trail != null) + Trail.Render(Args.firedBy); } } } diff --git a/OpenRA.Mods.RA/EngineerRepair.cs b/OpenRA.Mods.RA/EngineerRepair.cs index 571e16ed55..1b1c045412 100644 --- a/OpenRA.Mods.RA/EngineerRepair.cs +++ b/OpenRA.Mods.RA/EngineerRepair.cs @@ -37,13 +37,13 @@ namespace OpenRA.Mods.RA public string VoicePhraseForOrder(Actor self, Order order) { return (order.OrderString == "EngineerRepair" - && order.TargetActor.GetDamageState() > DamageState.Undamaged) ? "Attack" : null; + && order.TargetActor.GetDamageState() > DamageState.Undamaged) ? "Attack" : null; } public void ResolveOrder(Actor self, Order order) { if (order.OrderString == "EngineerRepair" - && order.TargetActor.GetDamageState() > DamageState.Undamaged) + && order.TargetActor.GetDamageState() > DamageState.Undamaged) { self.SetTargetLine(Target.FromOrder(order), Color.Yellow); diff --git a/OpenRA.Mods.RA/FreeActor.cs b/OpenRA.Mods.RA/FreeActor.cs index a9a0e45d82..9df8000c92 100644 --- a/OpenRA.Mods.RA/FreeActor.cs +++ b/OpenRA.Mods.RA/FreeActor.cs @@ -32,7 +32,7 @@ namespace OpenRA.Mods.RA w => { var a = w.CreateActor(info.Actor, new TypeDictionary - { + { new LocationInit( self.Location + info.SpawnOffset ), new OwnerInit( self.Owner ), new FacingInit( info.Facing ), diff --git a/OpenRA.Mods.RA/GainsExperience.cs b/OpenRA.Mods.RA/GainsExperience.cs index b405aa1fbc..45ef373575 100644 --- a/OpenRA.Mods.RA/GainsExperience.cs +++ b/OpenRA.Mods.RA/GainsExperience.cs @@ -83,7 +83,7 @@ namespace OpenRA.Mods.RA } } - public float GetDamageModifier(Actor attacker, WarheadInfo warhead) + public float GetDamageModifier(Actor attacker, WarheadInfo warhead) { return Level > 0 ? 1 / Info.ArmorModifier[Level - 1] : 1; } diff --git a/OpenRA.Mods.RA/HackyAI.cs b/OpenRA.Mods.RA/HackyAI.cs index e1fcb33735..754617b2a8 100644 --- a/OpenRA.Mods.RA/HackyAI.cs +++ b/OpenRA.Mods.RA/HackyAI.cs @@ -129,22 +129,22 @@ namespace OpenRA.Mods.RA if (!HasAdequatePower()) /* try to maintain 20% excess power */ { - if (!buildPower) return null; + if (!buildPower) return null; /* find the best thing we can build which produces power */ return buildableThings.Where(a => GetPowerProvidedBy(a) > 0) .OrderByDescending(a => GetPowerProvidedBy(a)).FirstOrDefault(); } - var myBuildings = p.World - .ActorsWithTrait() - .Where( a => a.Actor.Owner == p ) - .Select(a => a.Actor.Info.Name).ToArray(); + var myBuildings = p.World + .ActorsWithTrait() + .Where( a => a.Actor.Owner == p ) + .Select(a => a.Actor.Info.Name).ToArray(); foreach (var frac in Info.BuildingFractions) if (buildableThings.Any(b => b.Name == frac.Key)) if (myBuildings.Count(a => a == frac.Key) < frac.Value * myBuildings.Length && - playerPower.ExcessPower >= Rules.Info[frac.Key].Traits.Get().Power) + playerPower.ExcessPower >= Rules.Info[frac.Key].Traits.Get().Power) return Rules.Info[frac.Key]; return null; @@ -206,7 +206,7 @@ namespace OpenRA.Mods.RA //A bunch of hardcoded lists to keep track of which units are doing what. List unitsHangingAroundTheBase = new List(); List attackForce = new List(); - int2? attackTarget; + int2? attackTarget; //Units that the ai already knows about. Any unit not on this list needs to be given a role. List activeUnits = new List(); @@ -335,7 +335,7 @@ namespace OpenRA.Mods.RA { var buildings = self.World.ActorsWithTrait() .Where(rp => rp.Actor.Owner == p && - !IsRallyPointValid(rp.Trait.rallyPoint)).ToArray(); + !IsRallyPointValid(rp.Trait.rallyPoint)).ToArray(); if (buildings.Length > 0) BotDebug("Bot {0} needs to find rallypoints for {1} buildings.", diff --git a/OpenRA.Mods.RA/Harvester.cs b/OpenRA.Mods.RA/Harvester.cs index 969891d7d5..f6cbab3209 100644 --- a/OpenRA.Mods.RA/Harvester.cs +++ b/OpenRA.Mods.RA/Harvester.cs @@ -70,18 +70,18 @@ namespace OpenRA.Mods.RA Actor ClosestProc(Actor self, Actor ignore) { - var refs = self.World.ActorsWithTrait() - .Where(x => x.Actor != ignore && x.Actor.Owner == self.Owner) - .ToList(); + var refs = self.World.ActorsWithTrait() + .Where(x => x.Actor != ignore && x.Actor.Owner == self.Owner) + .ToList(); var mi = self.Info.Traits.Get(); var path = self.World.WorldActor.Trait().FindPath( PathSearch.FromPoints(self.World, mi, self.Owner, - refs.Select(r => r.Actor.Location + r.Trait.DeliverOffset), + refs.Select(r => r.Actor.Location + r.Trait.DeliverOffset), self.Location, false)); path.Reverse(); if (path.Count != 0) return refs.Where(x => x.Actor.Location + x.Trait.DeliverOffset == path[0]) - .Select(a => a.Actor).FirstOrDefault(); + .Select(a => a.Actor).FirstOrDefault(); else return null; } diff --git a/OpenRA.Mods.RA/Husk.cs b/OpenRA.Mods.RA/Husk.cs index 710607b7da..d63494cc35 100644 --- a/OpenRA.Mods.RA/Husk.cs +++ b/OpenRA.Mods.RA/Husk.cs @@ -45,8 +45,8 @@ namespace OpenRA.Mods.RA { var to = Util.CenterOfCell(location); var length = (int)((to - PxPosition).Length * 3 / speed); - self.QueueActivity(new DragHusk(PxPosition, to, length, this)); - } + self.QueueActivity(new DragHusk(PxPosition, to, length, this)); + } } public int2 TopLeft { get { return location; } } diff --git a/OpenRA.Mods.RA/InfiltrateForSupportPower.cs b/OpenRA.Mods.RA/InfiltrateForSupportPower.cs index 3a2e054ebe..fdb0e64cfa 100644 --- a/OpenRA.Mods.RA/InfiltrateForSupportPower.cs +++ b/OpenRA.Mods.RA/InfiltrateForSupportPower.cs @@ -32,7 +32,7 @@ namespace OpenRA.Mods.RA public void OnInfiltrate(Actor self, Actor spy) { spy.World.AddFrameEndTask(w => w.CreateActor(Info.Proxy, new TypeDictionary - { + { new OwnerInit( spy.Owner ) })); } diff --git a/OpenRA.Mods.RA/IronCurtainable.cs b/OpenRA.Mods.RA/IronCurtainable.cs index 427dc92574..f448478c4d 100644 --- a/OpenRA.Mods.RA/IronCurtainable.cs +++ b/OpenRA.Mods.RA/IronCurtainable.cs @@ -27,7 +27,7 @@ namespace OpenRA.Mods.RA RemainingTicks--; } - public float GetDamageModifier(Actor attacker, WarheadInfo warhead) + public float GetDamageModifier(Actor attacker, WarheadInfo warhead) { return (RemainingTicks > 0) ? 0.0f : 1.0f; } diff --git a/OpenRA.Mods.RA/LimitedAmmo.cs b/OpenRA.Mods.RA/LimitedAmmo.cs index 8db0d62568..38e0209e68 100644 --- a/OpenRA.Mods.RA/LimitedAmmo.cs +++ b/OpenRA.Mods.RA/LimitedAmmo.cs @@ -17,15 +17,15 @@ namespace OpenRA.Mods.RA { public readonly int Ammo = 0; public readonly int PipCount = 0; - public readonly int ReloadTicks = 25 * 2; // This is measured in ticks + public readonly int ReloadTicks = 25 * 2; // This is measured in ticks public object Create(ActorInitializer init) { return new LimitedAmmo(this); } } public class LimitedAmmo : INotifyAttack, IPips, ISync { - [Sync] - int ammo; + [Sync] + int ammo; LimitedAmmoInfo Info; public LimitedAmmo(LimitedAmmoInfo info) @@ -43,7 +43,7 @@ namespace OpenRA.Mods.RA return true; } - public int ReloadTimePerAmmo() { return Info.ReloadTicks; } + public int ReloadTimePerAmmo() { return Info.ReloadTicks; } public void Attacking(Actor self, Target target) { --ammo; } diff --git a/OpenRA.Mods.RA/Lint/CheckAutotargetWiring.cs b/OpenRA.Mods.RA/Lint/CheckAutotargetWiring.cs index c38dfc6223..6f46c394ed 100644 --- a/OpenRA.Mods.RA/Lint/CheckAutotargetWiring.cs +++ b/OpenRA.Mods.RA/Lint/CheckAutotargetWiring.cs @@ -16,16 +16,16 @@ namespace OpenRA.Mods.RA class CheckAutotargetWiring : ILintPass { public void Run(Action emitError, Action emitWarning) - { - foreach( var i in Rules.Info ) + { + foreach( var i in Rules.Info ) { if (i.Key.StartsWith("^")) continue; var attackMove = i.Value.Traits.GetOrDefault(); if (attackMove != null && !attackMove.JustMove && - !i.Value.Traits.Contains()) + !i.Value.Traits.Contains()) emitError( "{0} has AttackMove setup without AutoTarget, and will crash when resolving that order.".F(i.Key) ); } - } + } } } diff --git a/OpenRA.Mods.RA/Lint/LintBuildablePrerequisites.cs b/OpenRA.Mods.RA/Lint/LintBuildablePrerequisites.cs index 05bec32e2a..7ce5ffc4bd 100644 --- a/OpenRA.Mods.RA/Lint/LintBuildablePrerequisites.cs +++ b/OpenRA.Mods.RA/Lint/LintBuildablePrerequisites.cs @@ -15,14 +15,14 @@ using OpenRA.Traits; namespace OpenRA.Mods.RA { - class LintBuildablePrerequisites : ILintPass - { - public void Run(Action emitError, Action emitWarning) - { + class LintBuildablePrerequisites : ILintPass + { + public void Run(Action emitError, Action emitWarning) + { var providedPrereqs = Rules.Info.Keys.Concat( Rules.Info.SelectMany( a => a.Value.Traits - .WithInterface() - .Select( p => p.Prerequisite ))).ToArray(); + .WithInterface() + .Select( p => p.Prerequisite ))).ToArray(); foreach( var i in Rules.Info ) { @@ -32,6 +32,6 @@ namespace OpenRA.Mods.RA if ( !providedPrereqs.Contains(prereq) ) emitError( "Buildable actor {0} has prereq {1} not provided by anything.".F( i.Key, prereq ) ); } - } - } + } + } } diff --git a/OpenRA.Mods.RA/Move/Mobile.cs b/OpenRA.Mods.RA/Move/Mobile.cs index e66c7ea075..db628e7472 100755 --- a/OpenRA.Mods.RA/Move/Mobile.cs +++ b/OpenRA.Mods.RA/Move/Mobile.cs @@ -18,53 +18,53 @@ using OpenRA.Traits; namespace OpenRA.Mods.RA.Move { - public class MobileInfo : ITraitInfo, IFacingInfo - { - [FieldLoader.LoadUsing("LoadSpeeds")] - public readonly Dictionary TerrainSpeeds; - public readonly string[] Crushes; - public readonly int WaitAverage = 60; - public readonly int WaitSpread = 20; - public readonly int InitialFacing = 128; - public readonly int ROT = 255; - public readonly int Speed = 1; - public readonly bool OnRails = false; + public class MobileInfo : ITraitInfo, IFacingInfo + { + [FieldLoader.LoadUsing("LoadSpeeds")] + public readonly Dictionary TerrainSpeeds; + public readonly string[] Crushes; + public readonly int WaitAverage = 60; + public readonly int WaitSpread = 20; + public readonly int InitialFacing = 128; + public readonly int ROT = 255; + public readonly int Speed = 1; + public readonly bool OnRails = false; public readonly bool SharesCell = false; - public virtual object Create(ActorInitializer init) { return new Mobile(init, this); } + public virtual object Create(ActorInitializer init) { return new Mobile(init, this); } - static object LoadSpeeds(MiniYaml y) - { - Dictionary ret = new Dictionary(); - foreach (var t in y.NodesDict["TerrainSpeeds"].Nodes) - { - var speed = FieldLoader.GetValue("speed", t.Value.Value); - var cost = t.Value.NodesDict.ContainsKey("PathingCost") + static object LoadSpeeds(MiniYaml y) + { + Dictionary ret = new Dictionary(); + foreach (var t in y.NodesDict["TerrainSpeeds"].Nodes) + { + var speed = FieldLoader.GetValue("speed", t.Value.Value); + var cost = t.Value.NodesDict.ContainsKey("PathingCost") ? FieldLoader.GetValue("cost", t.Value.NodesDict["PathingCost"].Value) : (int)(10000 / speed); - ret.Add(t.Key, new TerrainInfo { Speed = speed, Cost = cost }); - } + ret.Add(t.Key, new TerrainInfo { Speed = speed, Cost = cost }); + } - return ret; - } + return ret; + } - public class TerrainInfo - { - public int Cost = int.MaxValue; - public decimal Speed = 0; - } + public class TerrainInfo + { + public int Cost = int.MaxValue; + public decimal Speed = 0; + } - public int MovementCostForCell(World world, int2 cell) - { - if (!world.Map.IsInMap(cell.X, cell.Y)) - return int.MaxValue; + public int MovementCostForCell(World world, int2 cell) + { + if (!world.Map.IsInMap(cell.X, cell.Y)) + return int.MaxValue; - var type = world.GetTerrainType(cell); - if (!TerrainSpeeds.ContainsKey(type)) - return int.MaxValue; + var type = world.GetTerrainType(cell); + if (!TerrainSpeeds.ContainsKey(type)) + return int.MaxValue; - return TerrainSpeeds[type].Cost; - } + return TerrainSpeeds[type].Cost; + } public readonly Dictionary SubCellOffsets = new Dictionary() { @@ -76,88 +76,88 @@ namespace OpenRA.Mods.RA.Move {SubCell.FullCell, new int2(0,0)}, }; - public bool CanEnterCell(World world, Player owner, int2 cell, Actor ignoreActor, bool checkTransientActors) - { - if (MovementCostForCell(world, cell) == int.MaxValue) - return false; + public bool CanEnterCell(World world, Player owner, int2 cell, Actor ignoreActor, bool checkTransientActors) + { + if (MovementCostForCell(world, cell) == int.MaxValue) + return false; if (SharesCell && world.ActorMap.HasFreeSubCell(cell)) return true; - var blockingActors = world.ActorMap.GetUnitsAt(cell).Where(x => x != ignoreActor).ToList(); - if (checkTransientActors && blockingActors.Count > 0) - { - // Non-sharable unit can enter a cell with shareable units only if it can crush all of them - if (Crushes == null) - return false; + var blockingActors = world.ActorMap.GetUnitsAt(cell).Where(x => x != ignoreActor).ToList(); + if (checkTransientActors && blockingActors.Count > 0) + { + // Non-sharable unit can enter a cell with shareable units only if it can crush all of them + if (Crushes == null) + return false; - if (blockingActors.Any(a => !(a.HasTrait() && - a.TraitsImplementing().Any(b => b.CrushableBy(Crushes, owner))))) - return false; - } + if (blockingActors.Any(a => !(a.HasTrait() && + a.TraitsImplementing().Any(b => b.CrushableBy(Crushes, owner))))) + return false; + } - return true; - } - } + return true; + } + } public class Mobile : IIssueOrder, IResolveOrder, IOrderVoice, IOccupySpace, IMove, IFacing, INudge, ISync - { - public readonly Actor self; - public readonly MobileInfo Info; - public bool IsMoving { get; internal set; } + { + public readonly Actor self; + public readonly MobileInfo Info; + public bool IsMoving { get; internal set; } - int __facing; - int2 __fromCell, __toCell; + int __facing; + int2 __fromCell, __toCell; public SubCell fromSubCell, toSubCell; - int __altitude; + int __altitude; - [Sync] - public int Facing - { - get { return __facing; } - set { __facing = value; } - } + [Sync] + public int Facing + { + get { return __facing; } + set { __facing = value; } + } - [Sync] - public int Altitude - { - get { return __altitude; } - set { __altitude = value; } - } + [Sync] + public int Altitude + { + get { return __altitude; } + set { __altitude = value; } + } - public int ROT { get { return Info.ROT; } } - public int InitialFacing { get { return Info.InitialFacing; } } + public int ROT { get { return Info.ROT; } } + public int InitialFacing { get { return Info.InitialFacing; } } - [Sync] - public int2 PxPosition { get; set; } - [Sync] - public int2 fromCell { get { return __fromCell; } } - [Sync] - public int2 toCell { get { return __toCell; } } + [Sync] + public int2 PxPosition { get; set; } + [Sync] + public int2 fromCell { get { return __fromCell; } } + [Sync] + public int2 toCell { get { return __toCell; } } - [Sync] - public int PathHash; // written by Move.EvalPath, to temporarily debug this crap. + [Sync] + public int PathHash; // written by Move.EvalPath, to temporarily debug this crap. - public void SetLocation(int2 from, SubCell fromSub, int2 to, SubCell toSub) - { - if (fromCell == from && toCell == to) return; - RemoveInfluence(); - __fromCell = from; - __toCell = to; + public void SetLocation(int2 from, SubCell fromSub, int2 to, SubCell toSub) + { + if (fromCell == from && toCell == to) return; + RemoveInfluence(); + __fromCell = from; + __toCell = to; fromSubCell = fromSub; toSubCell = toSub; - AddInfluence(); - } + AddInfluence(); + } - const int avgTicksBeforePathing = 5; - const int spreadTicksBeforePathing = 5; - internal int ticksBeforePathing = 0; + const int avgTicksBeforePathing = 5; + const int spreadTicksBeforePathing = 5; + internal int ticksBeforePathing = 0; - public Mobile(ActorInitializer init, MobileInfo info) - { - this.self = init.self; - this.Info = info; + public Mobile(ActorInitializer init, MobileInfo info) + { + this.self = init.self; + this.Info = info; toSubCell = fromSubCell = info.SharesCell ? SubCell.Center : SubCell.FullCell; if (init.Contains()) @@ -165,111 +165,111 @@ namespace OpenRA.Mods.RA.Move this.fromSubCell = this.toSubCell = init.Get(); } - if (init.Contains()) - { - this.__fromCell = this.__toCell = init.Get(); - this.PxPosition = Util.CenterOfCell(fromCell) + info.SubCellOffsets[fromSubCell]; - } + if (init.Contains()) + { + this.__fromCell = this.__toCell = init.Get(); + this.PxPosition = Util.CenterOfCell(fromCell) + info.SubCellOffsets[fromSubCell]; + } - this.Facing = init.Contains() ? init.Get() : info.InitialFacing; - this.Altitude = init.Contains() ? init.Get() : 0; - } + this.Facing = init.Contains() ? init.Get() : info.InitialFacing; + this.Altitude = init.Contains() ? init.Get() : 0; + } - public void SetPosition(Actor self, int2 cell) - { - SetLocation(cell,fromSubCell, cell,fromSubCell); - PxPosition = Util.CenterOfCell(fromCell) + Info.SubCellOffsets[fromSubCell]; - FinishedMoving(self); - } + public void SetPosition(Actor self, int2 cell) + { + SetLocation(cell,fromSubCell, cell,fromSubCell); + PxPosition = Util.CenterOfCell(fromCell) + Info.SubCellOffsets[fromSubCell]; + FinishedMoving(self); + } - public void SetPxPosition(Actor self, int2 px) - { - var cell = Util.CellContaining(px); - SetLocation(cell,fromSubCell, cell,fromSubCell); - PxPosition = px; - FinishedMoving(self); - } + public void SetPxPosition(Actor self, int2 px) + { + var cell = Util.CellContaining(px); + SetLocation(cell,fromSubCell, cell,fromSubCell); + PxPosition = px; + FinishedMoving(self); + } public void AdjustPxPosition(Actor self, int2 px) /* visual hack only */ { PxPosition = px; } - public IEnumerable Orders { get { yield return new MoveOrderTargeter(Info); } } + public IEnumerable Orders { get { yield return new MoveOrderTargeter(Info); } } - // Note: Returns a valid order even if the unit can't move to the target - public Order IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued) - { - if (order is MoveOrderTargeter) - { - if (Info.OnRails) return null; - return new Order("Move", self, queued) { TargetLocation = Util.CellContaining(target.CenterLocation) }; - } - return null; - } + // Note: Returns a valid order even if the unit can't move to the target + public Order IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued) + { + if (order is MoveOrderTargeter) + { + if (Info.OnRails) return null; + return new Order("Move", self, queued) { TargetLocation = Util.CellContaining(target.CenterLocation) }; + } + return null; + } - public int2 NearestMoveableCell(int2 target) - { - if (CanEnterCell(target)) - return target; + public int2 NearestMoveableCell(int2 target) + { + if (CanEnterCell(target)) + return target; - var searched = new List() { }; - // Limit search to a radius of 10 tiles - for (int r = 1; r < 10; r++) - foreach (var tile in self.World.FindTilesInCircle(target, r).Except(searched)) - { - if (CanEnterCell(tile)) - return tile; + var searched = new List() { }; + // Limit search to a radius of 10 tiles + for (int r = 1; r < 10; r++) + foreach (var tile in self.World.FindTilesInCircle(target, r).Except(searched)) + { + if (CanEnterCell(tile)) + return tile; - searched.Add(tile); - } + searched.Add(tile); + } - // Couldn't find a cell - return target; - } + // Couldn't find a cell + return target; + } void PerformMoveInner(Actor self, int2 targetLocation, bool queued) { int2 currentLocation = NearestMoveableCell(targetLocation); - if (!CanEnterCell(currentLocation)) - { - if (queued) self.CancelActivity(); - return; - } + if (!CanEnterCell(currentLocation)) + { + if (queued) self.CancelActivity(); + return; + } - if (!queued) self.CancelActivity(); + if (!queued) self.CancelActivity(); - ticksBeforePathing = avgTicksBeforePathing + self.World.SharedRandom.Next(-spreadTicksBeforePathing, spreadTicksBeforePathing); + ticksBeforePathing = avgTicksBeforePathing + self.World.SharedRandom.Next(-spreadTicksBeforePathing, spreadTicksBeforePathing); - self.QueueActivity(new Move(currentLocation, 8)); + self.QueueActivity(new Move(currentLocation, 8)); - self.SetTargetLine(Target.FromCell(currentLocation), Color.Green); + self.SetTargetLine(Target.FromCell(currentLocation), Color.Green); } - protected void PerformMove(Actor self, int2 targetLocation, bool queued) - { - if (queued) + protected void PerformMove(Actor self, int2 targetLocation, bool queued) + { + if (queued) self.QueueActivity(new CallFunc(() => PerformMoveInner(self, targetLocation, queued))); else PerformMoveInner(self, targetLocation, queued); - } + } - public void ResolveOrder(Actor self, Order order) - { - if (order.OrderString == "Move") - PerformMove(self, self.World.ClampToWorld(order.TargetLocation), + public void ResolveOrder(Actor self, Order order) + { + if (order.OrderString == "Move") + PerformMove(self, self.World.ClampToWorld(order.TargetLocation), order.Queued && !self.IsIdle); - if (order.OrderString == "Stop") - self.CancelActivity(); + if (order.OrderString == "Stop") + self.CancelActivity(); if (order.OrderString == "Scatter") - OnNudge(self, self, true); - } + OnNudge(self, self, true); + } - public string VoicePhraseForOrder(Actor self, Order order) - { + public string VoicePhraseForOrder(Actor self, Order order) + { switch( order.OrderString ) { case "Move": @@ -279,13 +279,13 @@ namespace OpenRA.Mods.RA.Move default: return null; } - } + } - public int2 TopLeft { get { return toCell; } } + public int2 TopLeft { get { return toCell; } } - public IEnumerable> OccupiedCells() - { - if (fromCell == toCell) + public IEnumerable> OccupiedCells() + { + if (fromCell == toCell) yield return Pair.New(fromCell, fromSubCell); else if (CanEnterCell(toCell)) yield return Pair.New(toCell, toSubCell); @@ -294,7 +294,7 @@ namespace OpenRA.Mods.RA.Move yield return Pair.New(fromCell, fromSubCell); yield return Pair.New(toCell, toSubCell); } - } + } public SubCell GetDesiredSubcell(int2 a, Actor ignoreActor) { @@ -307,152 +307,152 @@ namespace OpenRA.Mods.RA.Move { var blockingActors = self.World.ActorMap.GetUnitsAt(a,b).Where(c => c != ignoreActor); if (blockingActors.Count() > 0) - { - // Non-sharable unit can enter a cell with shareable units only if it can crush all of them - if (Info.Crushes == null) - return false; + { + // Non-sharable unit can enter a cell with shareable units only if it can crush all of them + if (Info.Crushes == null) + return false; if (blockingActors.Any(c => !(c.HasTrait() && - c.TraitsImplementing().Any(d => d.CrushableBy(Info.Crushes, self.Owner))))) - return false; - } + c.TraitsImplementing().Any(d => d.CrushableBy(Info.Crushes, self.Owner))))) + return false; + } return true; }); } - public bool CanEnterCell(int2 p) - { - return CanEnterCell(p, null, true); - } + public bool CanEnterCell(int2 p) + { + return CanEnterCell(p, null, true); + } - public bool CanEnterCell(int2 cell, Actor ignoreActor, bool checkTransientActors) - { - return Info.CanEnterCell(self.World, self.Owner, cell, ignoreActor, checkTransientActors); - } + public bool CanEnterCell(int2 cell, Actor ignoreActor, bool checkTransientActors) + { + return Info.CanEnterCell(self.World, self.Owner, cell, ignoreActor, checkTransientActors); + } public void EnteringCell(Actor self) { var crushable = self.World.ActorMap.GetUnitsAt(toCell).Where(a => a != self && a.HasTrait()); - foreach (var a in crushable) - { + foreach (var a in crushable) + { var crushActions = a.TraitsImplementing().Where(b => b.CrushableBy(Info.Crushes, self.Owner)); - foreach (var b in crushActions) + foreach (var b in crushActions) b.WarnCrush(self); } } - public void FinishedMoving(Actor self) - { - var crushable = self.World.ActorMap.GetUnitsAt(toCell).Where(a => a != self && a.HasTrait()); - foreach (var a in crushable) - { - var crushActions = a.TraitsImplementing().Where(b => b.CrushableBy(Info.Crushes, self.Owner)); - foreach (var b in crushActions) - b.OnCrush(self); - } - } + public void FinishedMoving(Actor self) + { + var crushable = self.World.ActorMap.GetUnitsAt(toCell).Where(a => a != self && a.HasTrait()); + foreach (var a in crushable) + { + var crushActions = a.TraitsImplementing().Where(b => b.CrushableBy(Info.Crushes, self.Owner)); + foreach (var b in crushActions) + b.OnCrush(self); + } + } - public int MovementSpeedForCell(Actor self, int2 cell) - { - var type = self.World.GetTerrainType(cell); + public int MovementSpeedForCell(Actor self, int2 cell) + { + var type = self.World.GetTerrainType(cell); - if (!Info.TerrainSpeeds.ContainsKey(type)) - return 0; + if (!Info.TerrainSpeeds.ContainsKey(type)) + return 0; - decimal speed = Info.Speed * Info.TerrainSpeeds[type].Speed; - foreach (var t in self.TraitsImplementing()) - speed *= t.GetSpeedModifier(); - return (int)(speed / 100); - } + decimal speed = Info.Speed * Info.TerrainSpeeds[type].Speed; + foreach (var t in self.TraitsImplementing()) + speed *= t.GetSpeedModifier(); + return (int)(speed / 100); + } - public void AddInfluence() - { - if (self.IsInWorld) - self.World.ActorMap.Add(self, this); - } + public void AddInfluence() + { + if (self.IsInWorld) + self.World.ActorMap.Add(self, this); + } - public void RemoveInfluence() - { - if (self.IsInWorld) - self.World.ActorMap.Remove(self, this); - } + public void RemoveInfluence() + { + if (self.IsInWorld) + self.World.ActorMap.Remove(self, this); + } - public void OnNudge(Actor self, Actor nudger, bool force) - { - /* initial fairly braindead implementation. */ - if (!force && self.Owner.Stances[nudger.Owner] != Stance.Ally) - return; /* don't allow ourselves to be pushed around + public void OnNudge(Actor self, Actor nudger, bool force) + { + /* initial fairly braindead implementation. */ + if (!force && self.Owner.Stances[nudger.Owner] != Stance.Ally) + return; /* don't allow ourselves to be pushed around * by the enemy! */ - if (!force && !self.IsIdle) - return; /* don't nudge if we're busy doing something! */ + if (!force && !self.IsIdle) + return; /* don't nudge if we're busy doing something! */ - // pick an adjacent available cell. - var availCells = new List(); - var notStupidCells = new List(); + // pick an adjacent available cell. + var availCells = new List(); + var notStupidCells = new List(); - for (var i = -1; i < 2; i++) - for (var j = -1; j < 2; j++) - { - var p = toCell + new int2(i, j); - if (CanEnterCell(p)) - availCells.Add(p); - else - if (p != nudger.Location && p != toCell) - notStupidCells.Add(p); - } + for (var i = -1; i < 2; i++) + for (var j = -1; j < 2; j++) + { + var p = toCell + new int2(i, j); + if (CanEnterCell(p)) + availCells.Add(p); + else + if (p != nudger.Location && p != toCell) + notStupidCells.Add(p); + } - var moveTo = availCells.Any() ? availCells.Random(self.World.SharedRandom) : - notStupidCells.Any() ? notStupidCells.Random(self.World.SharedRandom) : (int2?)null; + var moveTo = availCells.Any() ? availCells.Random(self.World.SharedRandom) : + notStupidCells.Any() ? notStupidCells.Random(self.World.SharedRandom) : (int2?)null; - if (moveTo.HasValue) - { - self.CancelActivity(); - self.SetTargetLine(Target.FromCell(moveTo.Value), Color.Green, false); - self.QueueActivity(new Move(moveTo.Value, 0)); + if (moveTo.HasValue) + { + self.CancelActivity(); + self.SetTargetLine(Target.FromCell(moveTo.Value), Color.Green, false); + self.QueueActivity(new Move(moveTo.Value, 0)); - Log.Write("debug", "OnNudge #{0} from {1} to {2}", - self.ActorID, self.Location, moveTo.Value); - } - else - Log.Write("debug", "OnNudge #{0} refuses at {1}", - self.ActorID, self.Location); - } + Log.Write("debug", "OnNudge #{0} from {1} to {2}", + self.ActorID, self.Location, moveTo.Value); + } + else + Log.Write("debug", "OnNudge #{0} refuses at {1}", + self.ActorID, self.Location); + } - class MoveOrderTargeter : IOrderTargeter - { - readonly MobileInfo unitType; + class MoveOrderTargeter : IOrderTargeter + { + readonly MobileInfo unitType; - public MoveOrderTargeter(MobileInfo unitType) - { - this.unitType = unitType; - } + public MoveOrderTargeter(MobileInfo unitType) + { + this.unitType = unitType; + } - public string OrderID { get { return "Move"; } } - public int OrderPriority { get { return 4; } } - public bool IsQueued { get; protected set; } + public string OrderID { get { return "Move"; } } + public int OrderPriority { get { return 4; } } + public bool IsQueued { get; protected set; } - public bool CanTargetActor(Actor self, Actor target, bool forceAttack, bool forceQueued, ref string cursor) - { - return false; - } + public bool CanTargetActor(Actor self, Actor target, bool forceAttack, bool forceQueued, ref string cursor) + { + return false; + } - public bool CanTargetLocation(Actor self, int2 location, List actorsAtLocation, bool forceAttack, bool forceQueued, ref string cursor) - { - IsQueued = forceQueued; - cursor = "move"; - if (!self.World.Map.IsInMap(location) || (self.World.LocalPlayer.Shroud.IsExplored(location) && - unitType.MovementCostForCell(self.World, location) == int.MaxValue)) - cursor = "move-blocked"; + public bool CanTargetLocation(Actor self, int2 location, List actorsAtLocation, bool forceAttack, bool forceQueued, ref string cursor) + { + IsQueued = forceQueued; + cursor = "move"; + if (!self.World.Map.IsInMap(location) || (self.World.LocalPlayer.Shroud.IsExplored(location) && + unitType.MovementCostForCell(self.World, location) == int.MaxValue)) + cursor = "move-blocked"; - return true; - } - } + return true; + } + } - public Activity ScriptedMove(int2 cell) { return new Move(cell); } - public Activity MoveTo(int2 cell, int nearEnough) { return new Move(cell, nearEnough); } - public Activity MoveTo(int2 cell, Actor ignoredActor) { return new Move(cell, ignoredActor); } - public Activity MoveWithinRange(Target target, int range) { return new Move(target, range); } - public Activity MoveTo(Func> pathFunc) { return new Move(pathFunc); } - } + public Activity ScriptedMove(int2 cell) { return new Move(cell); } + public Activity MoveTo(int2 cell, int nearEnough) { return new Move(cell, nearEnough); } + public Activity MoveTo(int2 cell, Actor ignoredActor) { return new Move(cell, ignoredActor); } + public Activity MoveWithinRange(Target target, int range) { return new Move(target, range); } + public Activity MoveTo(Func> pathFunc) { return new Move(pathFunc); } + } } diff --git a/OpenRA.Mods.RA/Move/PathFinder.cs b/OpenRA.Mods.RA/Move/PathFinder.cs index 6da067ec42..b12e25a26e 100755 --- a/OpenRA.Mods.RA/Move/PathFinder.cs +++ b/OpenRA.Mods.RA/Move/PathFinder.cs @@ -74,12 +74,12 @@ namespace OpenRA.Mods.RA.Move var tilesInRange = world.FindTilesInCircle(target, range) .Where( t => mi.CanEnterCell(self.World, self.Owner, t, null, true)); - var path = FindBidiPath( - PathSearch.FromPoints(world, mi, self.Owner, tilesInRange, src, true), - PathSearch.FromPoint(world, mi, self.Owner, src, target, true) - .InReverse()); + var path = FindBidiPath( + PathSearch.FromPoints(world, mi, self.Owner, tilesInRange, src, true), + PathSearch.FromPoint(world, mi, self.Owner, src, target, true) + .InReverse()); - return path; + return path; } } diff --git a/OpenRA.Mods.RA/Move/PathSearch.cs b/OpenRA.Mods.RA/Move/PathSearch.cs index 95222b2dc3..feb7e2b885 100755 --- a/OpenRA.Mods.RA/Move/PathSearch.cs +++ b/OpenRA.Mods.RA/Move/PathSearch.cs @@ -216,7 +216,7 @@ namespace OpenRA.Mods.RA.Move if (cellInfo.GetUpperBound(0) != world.Map.MapSize.X - 1 || cellInfo.GetUpperBound(1) != world.Map.MapSize.Y - 1) { - Log.Write("debug", "Discarding old pooled CellInfo of wrong size."); + Log.Write("debug", "Discarding old pooled CellInfo of wrong size."); continue; } diff --git a/OpenRA.Mods.RA/Orders/DeployOrderTargeter.cs b/OpenRA.Mods.RA/Orders/DeployOrderTargeter.cs index 6ba22e3383..3c73c69e1b 100755 --- a/OpenRA.Mods.RA/Orders/DeployOrderTargeter.cs +++ b/OpenRA.Mods.RA/Orders/DeployOrderTargeter.cs @@ -16,7 +16,7 @@ using OpenRA.Traits; namespace OpenRA.Mods.RA.Orders { - public class DeployOrderTargeter : IOrderTargeter + public class DeployOrderTargeter : IOrderTargeter { readonly Func useDeployCursor; diff --git a/OpenRA.Mods.RA/Orders/PlaceBuildingOrderGenerator.cs b/OpenRA.Mods.RA/Orders/PlaceBuildingOrderGenerator.cs index f3e18e5385..769eeb3cb5 100755 --- a/OpenRA.Mods.RA/Orders/PlaceBuildingOrderGenerator.cs +++ b/OpenRA.Mods.RA/Orders/PlaceBuildingOrderGenerator.cs @@ -92,8 +92,8 @@ namespace OpenRA.Mods.RA.Orders { foreach (var r in Preview) r.Sprite.DrawAt(Game.CellSize*topLeft + r.Pos, - wr.GetPaletteIndex(r.Palette), - r.Scale*r.Sprite.size); + wr.GetPaletteIndex(r.Palette), + r.Scale*r.Sprite.size); var res = world.WorldActor.Trait(); var isCloseEnough = BuildingInfo.IsCloseEnoughToBase(world, world.LocalPlayer, Building, topLeft); diff --git a/OpenRA.Mods.RA/Orders/SellOrderGenerator.cs b/OpenRA.Mods.RA/Orders/SellOrderGenerator.cs index e16f78274b..1a569ed604 100755 --- a/OpenRA.Mods.RA/Orders/SellOrderGenerator.cs +++ b/OpenRA.Mods.RA/Orders/SellOrderGenerator.cs @@ -32,7 +32,7 @@ namespace OpenRA.Mods.RA.Orders { var underCursor = world.FindUnitsAtMouse(mi.Location) .Where(a => a.Owner == world.LocalPlayer - && a.HasTrait()).FirstOrDefault(); + && a.HasTrait()).FirstOrDefault(); if (underCursor != null) yield return new Order("Sell", underCursor, false); diff --git a/OpenRA.Mods.RA/Orders/UnitOrderTargeter.cs b/OpenRA.Mods.RA/Orders/UnitOrderTargeter.cs index 1d764a3ff1..f2381aa871 100755 --- a/OpenRA.Mods.RA/Orders/UnitOrderTargeter.cs +++ b/OpenRA.Mods.RA/Orders/UnitOrderTargeter.cs @@ -14,7 +14,7 @@ using OpenRA.Traits; namespace OpenRA.Mods.RA.Orders { - public class UnitOrderTargeter : IOrderTargeter + public class UnitOrderTargeter : IOrderTargeter { readonly string cursor; readonly bool targetEnemyUnits, targetAllyUnits; @@ -54,7 +54,7 @@ namespace OpenRA.Mods.RA.Orders public virtual bool IsQueued { get; protected set; } } - public class UnitTraitOrderTargeter : UnitOrderTargeter + public class UnitTraitOrderTargeter : UnitOrderTargeter { public UnitTraitOrderTargeter( string order, int priority, string cursor, bool targetEnemyUnits, bool targetAllyUnits ) : base( order, priority, cursor, targetEnemyUnits, targetAllyUnits ) diff --git a/OpenRA.Mods.RA/OreRefinery.cs b/OpenRA.Mods.RA/OreRefinery.cs index 036e46d08c..06be5e338e 100644 --- a/OpenRA.Mods.RA/OreRefinery.cs +++ b/OpenRA.Mods.RA/OreRefinery.cs @@ -63,11 +63,11 @@ namespace OpenRA.Mods.RA currentDisplayTick = Info.TickRate; } - public IEnumerable> GetLinkedHarvesters() - { - return self.World.ActorsWithTrait() - .Where(a => a.Trait.LinkedProc == self); - } + public IEnumerable> GetLinkedHarvesters() + { + return self.World.ActorsWithTrait() + .Where(a => a.Trait.LinkedProc == self); + } public bool CanGiveOre(int amount) { @@ -135,9 +135,9 @@ namespace OpenRA.Mods.RA dockedHarv.ChangeOwner(newOwner); // Unlink any non-docked harvs - foreach (var harv in GetLinkedHarvesters()) - if (harv.Actor.Owner == oldOwner) - harv.Trait.UnlinkProc(harv.Actor, self); + foreach (var harv in GetLinkedHarvesters()) + if (harv.Actor.Owner == oldOwner) + harv.Trait.UnlinkProc(harv.Actor, self); PlayerResources = newOwner.PlayerActor.Trait(); } @@ -145,8 +145,8 @@ namespace OpenRA.Mods.RA public void Selling(Actor self) { CancelDock(self); } public void Sold(Actor self) { - foreach (var harv in GetLinkedHarvesters()) - harv.Trait.UnlinkProc(harv.Actor, self); + foreach (var harv in GetLinkedHarvesters()) + harv.Trait.UnlinkProc(harv.Actor, self); } public bool ShouldExplode(Actor self) { return Ore > 0; } diff --git a/OpenRA.Mods.RA/Passenger.cs b/OpenRA.Mods.RA/Passenger.cs index b1c54c8aa1..d5cc9911fe 100644 --- a/OpenRA.Mods.RA/Passenger.cs +++ b/OpenRA.Mods.RA/Passenger.cs @@ -26,7 +26,7 @@ namespace OpenRA.Mods.RA public object Create( ActorInitializer init ) { return new Passenger( this ); } } - public class Passenger : IIssueOrder, IResolveOrder, IOrderVoice + public class Passenger : IIssueOrder, IResolveOrder, IOrderVoice { readonly PassengerInfo info; public Passenger( PassengerInfo info ) { this.info = info; } diff --git a/OpenRA.Mods.RA/Player/ClassicProductionQueue.cs b/OpenRA.Mods.RA/Player/ClassicProductionQueue.cs index 5583481987..03866a8af0 100755 --- a/OpenRA.Mods.RA/Player/ClassicProductionQueue.cs +++ b/OpenRA.Mods.RA/Player/ClassicProductionQueue.cs @@ -30,8 +30,8 @@ namespace OpenRA.Mods.RA public override void Tick( Actor self ) { isActive = self.World.ActorsWithTrait() - .Any(x => x.Actor.Owner == self.Owner - && x.Trait.Info.Produces.Contains(Info.Type)); + .Any(x => x.Actor.Owner == self.Owner + && x.Trait.Info.Produces.Contains(Info.Type)); base.Tick(self); } @@ -51,8 +51,8 @@ namespace OpenRA.Mods.RA { // Find a production structure to build this actor var producers = self.World.ActorsWithTrait() - .Where(x => x.Actor.Owner == self.Owner - && x.Trait.Info.Produces.Contains(Info.Type)) + .Where(x => x.Actor.Owner == self.Owner + && x.Trait.Info.Produces.Contains(Info.Type)) .OrderByDescending(x => x.Actor.IsPrimaryBuilding() ? 1 : 0 ); // prioritize the primary. if (producers.Count() == 0) diff --git a/OpenRA.Mods.RA/Player/PlaceBuilding.cs b/OpenRA.Mods.RA/Player/PlaceBuilding.cs index 54a18aff10..4fdeaf0328 100755 --- a/OpenRA.Mods.RA/Player/PlaceBuilding.cs +++ b/OpenRA.Mods.RA/Player/PlaceBuilding.cs @@ -31,9 +31,9 @@ namespace OpenRA.Mods.RA // Find the queue with the target actor var queue = w.ActorsWithTrait() .Where(p => p.Actor.Owner == self.Owner && - p.Trait.CurrentItem() != null && - p.Trait.CurrentItem().Item == order.TargetString && - p.Trait.CurrentItem().RemainingTime == 0) + p.Trait.CurrentItem() != null && + p.Trait.CurrentItem().Item == order.TargetString && + p.Trait.CurrentItem().RemainingTime == 0) .Select(p => p.Trait) .FirstOrDefault(); @@ -97,7 +97,7 @@ namespace OpenRA.Mods.RA var producers = self.World.ActorsWithTrait() .Where( x => x.Actor.Owner == self.Owner - && x.Actor.Info.Traits.Get().Produces.Contains( bi.Queue ) ) + && x.Actor.Info.Traits.Get().Produces.Contains( bi.Queue ) ) .ToList(); var producer = producers.Where( x => x.Actor.IsPrimaryBuilding() ).Concat( producers ) .FirstOrDefault(); diff --git a/OpenRA.Mods.RA/PrimaryBuilding.cs b/OpenRA.Mods.RA/PrimaryBuilding.cs index 709cc5f793..d065d2dc62 100755 --- a/OpenRA.Mods.RA/PrimaryBuilding.cs +++ b/OpenRA.Mods.RA/PrimaryBuilding.cs @@ -54,12 +54,12 @@ namespace OpenRA.Mods.RA return; } - // THIS IS SHIT + // THIS IS SHIT // Cancel existing primaries foreach (var p in self.Info.Traits.Get().Produces) foreach (var b in self.World .ActorsWithTrait() - .Where(a => a.Actor.Owner == self.Owner) + .Where(a => a.Actor.Owner == self.Owner) .Where(x => x.Trait.IsPrimary && (x.Actor.Info.Traits.Get().Produces.Contains(p)))) b.Trait.SetPrimaryProducer(b.Actor, false); diff --git a/OpenRA.Mods.RA/Production.cs b/OpenRA.Mods.RA/Production.cs index 0f74cb8260..05dceb409d 100755 --- a/OpenRA.Mods.RA/Production.cs +++ b/OpenRA.Mods.RA/Production.cs @@ -44,7 +44,7 @@ namespace OpenRA.Mods.RA { var newUnit = self.World.CreateActor(false, producee.Name, new TypeDictionary { - new OwnerInit( self.Owner ), + new OwnerInit( self.Owner ), }); var exit = self.Location + exitinfo.ExitCell; @@ -56,75 +56,75 @@ namespace OpenRA.Mods.RA // Set the physical position of the unit as the exit cell teleportable.SetPosition(newUnit,exit); var to = Util.CenterOfCell(exit); - teleportable.AdjustPxPosition(newUnit, spawn); + teleportable.AdjustPxPosition(newUnit, spawn); if (facing != null) facing.Facing = exitinfo.Facing < 0 ? Util.GetFacing(to - spawn, facing.Facing) : exitinfo.Facing; self.World.Add(newUnit); - var mobile = newUnit.TraitOrDefault(); - if (mobile != null) - { - // Animate the spawn -> exit transition - var speed = mobile.MovementSpeedForCell(newUnit, exit); - var length = speed > 0 ? (int)((to - spawn).Length * 3 / speed) : 0; - newUnit.QueueActivity(new Drag(spawn, to, length)); - } + var mobile = newUnit.TraitOrDefault(); + if (mobile != null) + { + // Animate the spawn -> exit transition + var speed = mobile.MovementSpeedForCell(newUnit, exit); + var length = speed > 0 ? (int)((to - spawn).Length * 3 / speed) : 0; + newUnit.QueueActivity(new Drag(spawn, to, length)); + } - var target = MoveToRallyPoint(self, newUnit, exit); + var target = MoveToRallyPoint(self, newUnit, exit); newUnit.SetTargetLine(Target.FromCell(target), Color.Green, false); foreach (var t in self.TraitsImplementing()) t.UnitProduced(self, newUnit, exit); } - static int2 MoveToRallyPoint(Actor self, Actor newUnit, int2 exitLocation) - { - var rp = self.TraitOrDefault(); - if (rp == null) - return exitLocation; + static int2 MoveToRallyPoint(Actor self, Actor newUnit, int2 exitLocation) + { + var rp = self.TraitOrDefault(); + if (rp == null) + return exitLocation; - var mobile = newUnit.TraitOrDefault(); - if (mobile != null) - { - newUnit.QueueActivity(mobile.MoveTo(rp.rallyPoint, 1)); - return rp.rallyPoint; - } + var mobile = newUnit.TraitOrDefault(); + if (mobile != null) + { + newUnit.QueueActivity(mobile.MoveTo(rp.rallyPoint, 1)); + return rp.rallyPoint; + } - // todo: don't talk about HeliFly here. - var helicopter = newUnit.TraitOrDefault(); - if (helicopter != null) - { - newUnit.QueueActivity(new HeliFly(Util.CenterOfCell(rp.rallyPoint))); - return rp.rallyPoint; - } + // todo: don't talk about HeliFly here. + var helicopter = newUnit.TraitOrDefault(); + if (helicopter != null) + { + newUnit.QueueActivity(new HeliFly(Util.CenterOfCell(rp.rallyPoint))); + return rp.rallyPoint; + } - return exitLocation; - } + return exitLocation; + } - public virtual bool Produce(Actor self, ActorInfo producee) - { - if (Reservable.IsReserved(self)) - return false; + public virtual bool Produce(Actor self, ActorInfo producee) + { + if (Reservable.IsReserved(self)) + return false; - // pick a spawn/exit point pair - var exit = self.Info.Traits.WithInterface().Shuffle(self.World.SharedRandom) - .FirstOrDefault(e => CanUseExit(self, producee, e)); + // pick a spawn/exit point pair + var exit = self.Info.Traits.WithInterface().Shuffle(self.World.SharedRandom) + .FirstOrDefault(e => CanUseExit(self, producee, e)); - if (exit != null) - { - DoProduction(self, producee, exit); - return true; - } + if (exit != null) + { + DoProduction(self, producee, exit); + return true; + } - return false; - } + return false; + } - static bool CanUseExit(Actor self, ActorInfo producee, ExitInfo s) - { - var mobileInfo = producee.Traits.GetOrDefault(); + static bool CanUseExit(Actor self, ActorInfo producee, ExitInfo s) + { + var mobileInfo = producee.Traits.GetOrDefault(); - return mobileInfo == null || - mobileInfo.CanEnterCell(self.World, self.Owner, self.Location + s.ExitCell, self, true); - } + return mobileInfo == null || + mobileInfo.CanEnterCell(self.World, self.Owner, self.Location + s.ExitCell, self, true); + } } } diff --git a/OpenRA.Mods.RA/ProximityCaptor.cs b/OpenRA.Mods.RA/ProximityCaptor.cs index f7301e457e..17f65c8ac8 100644 --- a/OpenRA.Mods.RA/ProximityCaptor.cs +++ b/OpenRA.Mods.RA/ProximityCaptor.cs @@ -23,7 +23,7 @@ namespace OpenRA.Mods.RA { public readonly ProximityCaptorInfo Info; - public ProximityCaptor(ProximityCaptorInfo info) { Info = info; } + public ProximityCaptor(ProximityCaptorInfo info) { Info = info; } public bool HasAny(string[] typesList) { diff --git a/OpenRA.Mods.RA/ProximityCapturable.cs b/OpenRA.Mods.RA/ProximityCapturable.cs index 4670e2e364..adcd435ad1 100644 --- a/OpenRA.Mods.RA/ProximityCapturable.cs +++ b/OpenRA.Mods.RA/ProximityCapturable.cs @@ -136,9 +136,9 @@ namespace OpenRA.Mods.RA return UnitsInRange() .Where(a => a.Owner != OriginalOwner) .Where(a => CanBeCapturedBy(a)); - } + } - // TODO exclude other NeutralActor that arent permanent + // TODO exclude other NeutralActor that arent permanent Actor GetInRange(Actor self) { return CaptorsInRange(self).ClosestTo( self.CenterLocation ); diff --git a/OpenRA.Mods.RA/Render/RenderBuilding.cs b/OpenRA.Mods.RA/Render/RenderBuilding.cs index d246ffa300..245015f29b 100755 --- a/OpenRA.Mods.RA/Render/RenderBuilding.cs +++ b/OpenRA.Mods.RA/Render/RenderBuilding.cs @@ -27,8 +27,8 @@ namespace OpenRA.Mods.RA.Render public override IEnumerable RenderPreview(ActorInfo building, Player owner) { - return base.RenderPreview(building, owner) - .Select(a => a.WithPos(a.Pos + building.Traits.Get().Origin)); + return base.RenderPreview(building, owner) + .Select(a => a.WithPos(a.Pos + building.Traits.Get().Origin)); } } diff --git a/OpenRA.Mods.RA/Render/RenderBuildingWarFactory.cs b/OpenRA.Mods.RA/Render/RenderBuildingWarFactory.cs index 1b235e87f0..f86b0cd55a 100755 --- a/OpenRA.Mods.RA/Render/RenderBuildingWarFactory.cs +++ b/OpenRA.Mods.RA/Render/RenderBuildingWarFactory.cs @@ -19,11 +19,11 @@ namespace OpenRA.Mods.RA.Render { public override object Create(ActorInitializer init) { return new RenderBuildingWarFactory( init, this ); } - /* get around unverifiability */ - IEnumerable BaseBuildingPreview(ActorInfo building, Player owner) - { - return base.RenderPreview(building, owner); - } + /* get around unverifiability */ + IEnumerable BaseBuildingPreview(ActorInfo building, Player owner) + { + return base.RenderPreview(building, owner); + } public override IEnumerable RenderPreview(ActorInfo building, Player owner) { @@ -65,7 +65,7 @@ namespace OpenRA.Mods.RA.Render { base.Tick(self); if (isOpen && !self.World.ActorMap.GetUnitsAt(openExit) - .Any( a => a != self )) + .Any( a => a != self )) { isOpen = false; roof.PlayBackwardsThen(NormalizeSequence(self, "build-top"), diff --git a/OpenRA.Mods.RA/RenderRangeCircle.cs b/OpenRA.Mods.RA/RenderRangeCircle.cs index 98d0de88cd..a6895c5210 100644 --- a/OpenRA.Mods.RA/RenderRangeCircle.cs +++ b/OpenRA.Mods.RA/RenderRangeCircle.cs @@ -32,9 +32,9 @@ namespace OpenRA.Mods.RA ai.Traits.Get().GetMaximumRange()); foreach (var a in w.ActorsWithTrait()) - if (a.Actor.Owner == a.Actor.World.LocalPlayer) - if (a.Actor.Info.Traits.Get().RangeCircleType == RangeCircleType) - a.Trait.RenderBeforeWorld(wr, a.Actor); + if (a.Actor.Owner == a.Actor.World.LocalPlayer) + if (a.Actor.Info.Traits.Get().RangeCircleType == RangeCircleType) + a.Trait.RenderBeforeWorld(wr, a.Actor); } } diff --git a/OpenRA.Mods.RA/Reservable.cs b/OpenRA.Mods.RA/Reservable.cs index c1ce3a4423..8d6560e713 100755 --- a/OpenRA.Mods.RA/Reservable.cs +++ b/OpenRA.Mods.RA/Reservable.cs @@ -67,7 +67,7 @@ namespace OpenRA.Mods.RA public void Selling (Actor self) { Sold(self); } public void Sold (Actor self) { - if (herp != null) + if (herp != null) herp.UnReserve(); } } diff --git a/OpenRA.Mods.RA/Scripting/RASpecialPowers.cs b/OpenRA.Mods.RA/Scripting/RASpecialPowers.cs index 5429dfc629..b639da826c 100644 --- a/OpenRA.Mods.RA/Scripting/RASpecialPowers.cs +++ b/OpenRA.Mods.RA/Scripting/RASpecialPowers.cs @@ -36,10 +36,10 @@ namespace OpenRA.Scripting var cs = target.Trait(); if (cs.CanChronoshiftTo(target, targetCell, true)) target.Trait().Teleport(target, - targetCell, - duration, - killCargo, - chronosphere); + targetCell, + duration, + killCargo, + chronosphere); } diff --git a/OpenRA.Mods.RA/ServerTraits/MasterServerPinger.cs b/OpenRA.Mods.RA/ServerTraits/MasterServerPinger.cs index 5247932659..7dc87b32e2 100644 --- a/OpenRA.Mods.RA/ServerTraits/MasterServerPinger.cs +++ b/OpenRA.Mods.RA/ServerTraits/MasterServerPinger.cs @@ -66,7 +66,7 @@ namespace OpenRA.Mods.RA.Server server.lobbyInfo.Clients.Count, string.Join(",", Game.CurrentMods.Select(f => "{0}@{1}".F(f.Key, f.Value.Version)).ToArray()), server.lobbyInfo.GlobalSettings.Map, - server.Map.PlayerCount)); + server.Map.PlayerCount)); if (isInitialPing) { diff --git a/OpenRA.Mods.RA/SupplyTruck.cs b/OpenRA.Mods.RA/SupplyTruck.cs index bd633fe926..d183306a00 100644 --- a/OpenRA.Mods.RA/SupplyTruck.cs +++ b/OpenRA.Mods.RA/SupplyTruck.cs @@ -17,65 +17,65 @@ using OpenRA.Traits; namespace OpenRA.Mods.RA { - class SupplyTruckInfo : ITraitInfo - { - public readonly int Payload = 500; - public object Create(ActorInitializer init) { return new SupplyTruck(this); } - } + class SupplyTruckInfo : ITraitInfo + { + public readonly int Payload = 500; + public object Create(ActorInitializer init) { return new SupplyTruck(this); } + } - class SupplyTruck : IIssueOrder, IResolveOrder, IOrderVoice - { - SupplyTruckInfo Info; - public SupplyTruck(SupplyTruckInfo info) - { - Info = info; - } + class SupplyTruck : IIssueOrder, IResolveOrder, IOrderVoice + { + SupplyTruckInfo Info; + public SupplyTruck(SupplyTruckInfo info) + { + Info = info; + } - public IEnumerable Orders - { - get { yield return new SupplyTruckOrderTargeter(); } - } + public IEnumerable Orders + { + get { yield return new SupplyTruckOrderTargeter(); } + } - public Order IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued) - { - if (order.OrderID == "SupplyTruck") - return new Order(order.OrderID, self, queued) { TargetActor = target.Actor }; + public Order IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued) + { + if (order.OrderID == "SupplyTruck") + return new Order(order.OrderID, self, queued) { TargetActor = target.Actor }; - return null; - } + return null; + } - public string VoicePhraseForOrder(Actor self, Order order) - { - return "Move"; - } + public string VoicePhraseForOrder(Actor self, Order order) + { + return "Move"; + } - public void ResolveOrder(Actor self, Order order) - { - if (order.OrderString == "SupplyTruck") - { - self.SetTargetLine(Target.FromOrder(order), Color.Yellow); - self.CancelActivity(); - self.QueueActivity(new Enter(order.TargetActor)); - self.QueueActivity(new DonateSupplies(order.TargetActor, Info.Payload)); - } - } + public void ResolveOrder(Actor self, Order order) + { + if (order.OrderString == "SupplyTruck") + { + self.SetTargetLine(Target.FromOrder(order), Color.Yellow); + self.CancelActivity(); + self.QueueActivity(new Enter(order.TargetActor)); + self.QueueActivity(new DonateSupplies(order.TargetActor, Info.Payload)); + } + } - class SupplyTruckOrderTargeter : UnitTraitOrderTargeter - { - public SupplyTruckOrderTargeter() - : base("SupplyTruck", 5, "enter", false, true) - { - } + class SupplyTruckOrderTargeter : UnitTraitOrderTargeter + { + public SupplyTruckOrderTargeter() + : base("SupplyTruck", 5, "enter", false, true) + { + } - public override bool CanTargetActor(Actor self, Actor target, bool forceAttack, bool forceQueued, ref string cursor) - { - if (!base.CanTargetActor(self, target, forceAttack, forceQueued, ref cursor)) return false; - if (target.AppearsHostileTo(self)) return false; - if (!target.HasTrait()) return false; + public override bool CanTargetActor(Actor self, Actor target, bool forceAttack, bool forceQueued, ref string cursor) + { + if (!base.CanTargetActor(self, target, forceAttack, forceQueued, ref cursor)) return false; + if (target.AppearsHostileTo(self)) return false; + if (!target.HasTrait()) return false; - IsQueued = forceQueued; - return true; - } - } - } + IsQueued = forceQueued; + return true; + } + } + } } diff --git a/OpenRA.Mods.RA/SupportPowers/AirstrikePower.cs b/OpenRA.Mods.RA/SupportPowers/AirstrikePower.cs index 4909596e0c..a1a47531b8 100755 --- a/OpenRA.Mods.RA/SupportPowers/AirstrikePower.cs +++ b/OpenRA.Mods.RA/SupportPowers/AirstrikePower.cs @@ -37,7 +37,7 @@ namespace OpenRA.Mods.RA { var info = (Info as AirstrikePowerInfo); var flare = info.FlareType != null ? w.CreateActor(info.FlareType, new TypeDictionary - { + { new LocationInit( order.TargetLocation ), new OwnerInit( self.Owner ), }) : null; @@ -49,7 +49,7 @@ namespace OpenRA.Mods.RA } var a = w.CreateActor(info.UnitType, new TypeDictionary - { + { new LocationInit( startPos ), new OwnerInit( self.Owner ), new FacingInit( Util.GetFacing(order.TargetLocation - startPos, 0) ), diff --git a/OpenRA.Mods.RA/SupportPowers/ChronoshiftPower.cs b/OpenRA.Mods.RA/SupportPowers/ChronoshiftPower.cs index 9d34027384..e4d4e76c61 100755 --- a/OpenRA.Mods.RA/SupportPowers/ChronoshiftPower.cs +++ b/OpenRA.Mods.RA/SupportPowers/ChronoshiftPower.cs @@ -51,11 +51,11 @@ namespace OpenRA.Mods.RA { var cs = target.Trait(); var targetCell = target.Location + order.TargetLocation - order.ExtraLocation; - var cpi = Info as ChronoshiftPowerInfo; + var cpi = Info as ChronoshiftPowerInfo; if (cs.CanChronoshiftTo(target, targetCell, true)) - cs.Teleport(target, targetCell, - cpi.Duration * 25, cpi.KillCargo, self); + cs.Teleport(target, targetCell, + cpi.Duration * 25, cpi.KillCargo, self); } } @@ -87,14 +87,14 @@ namespace OpenRA.Mods.RA tile = SequenceProvider.GetSequence("overlay", "target-select").GetSprite(0); } - public IEnumerable Order(World world, int2 xy, MouseInput mi) - { - world.CancelInputMode(); - if (mi.Button == MouseButton.Left) - world.OrderGenerator = new SelectDestination(order, manager, power, xy); + public IEnumerable Order(World world, int2 xy, MouseInput mi) + { + world.CancelInputMode(); + if (mi.Button == MouseButton.Left) + world.OrderGenerator = new SelectDestination(order, manager, power, xy); - yield break; - } + yield break; + } public void Tick(World world) { @@ -206,7 +206,7 @@ namespace OpenRA.Mods.RA foreach (var r in unit.Render()) r.Sprite.DrawAt(r.Pos - Traits.Util.CenterOfCell(unit.Location) + Traits.Util.CenterOfCell(targetCell), wr.GetPaletteIndex(r.Palette), - r.Scale*r.Sprite.size); + r.Scale*r.Sprite.size); } // Unit tiles diff --git a/OpenRA.Mods.RA/SupportPowers/SpyPlanePower.cs b/OpenRA.Mods.RA/SupportPowers/SpyPlanePower.cs index ff9e7680a2..648f1a571a 100755 --- a/OpenRA.Mods.RA/SupportPowers/SpyPlanePower.cs +++ b/OpenRA.Mods.RA/SupportPowers/SpyPlanePower.cs @@ -42,7 +42,7 @@ namespace OpenRA.Mods.RA plane.QueueActivity(new CallFunc(() => plane.World.AddFrameEndTask( w => { var camera = w.CreateActor("camera", new TypeDictionary - { + { new LocationInit( order.TargetLocation ), new OwnerInit( self.Owner ), }); diff --git a/OpenRA.Mods.RA/TargetableSubmarine.cs b/OpenRA.Mods.RA/TargetableSubmarine.cs index 1d620b2d05..3a24998fbb 100644 --- a/OpenRA.Mods.RA/TargetableSubmarine.cs +++ b/OpenRA.Mods.RA/TargetableSubmarine.cs @@ -22,12 +22,12 @@ namespace OpenRA.Mods.RA public class TargetableSubmarine : TargetableUnit { public TargetableSubmarine(Actor self, TargetableSubmarineInfo info) - : base(self, info) {} + : base(self, info) {} public override string[] TargetTypes { get { return (Cloak.Cloaked) ? info.CloakedTargetTypes - : info.TargetTypes;} + : info.TargetTypes;} } } } diff --git a/OpenRA.Mods.RA/Widgets/BuildPaletteWidget.cs b/OpenRA.Mods.RA/Widgets/BuildPaletteWidget.cs index 2b99b191e9..7bc41ea049 100755 --- a/OpenRA.Mods.RA/Widgets/BuildPaletteWidget.cs +++ b/OpenRA.Mods.RA/Widgets/BuildPaletteWidget.cs @@ -72,7 +72,7 @@ namespace OpenRA.Mods.RA.Widgets .ToDictionary( u => u.Name, u => Game.modData.SpriteLoader.LoadAllSprites( - u.Traits.Get().Icon ?? (u.Name + "icon"))[0]); + u.Traits.Get().Icon ?? (u.Name + "icon"))[0]); } public override Rectangle EventBounds @@ -464,7 +464,7 @@ namespace OpenRA.Mods.RA.Widgets Game.Renderer.Fonts["Bold"].DrawText( tooltip.Name + ((buildable.Hotkey != null)? " ({0})".F(buildable.Hotkey.ToUpper()) : ""), - p.ToInt2() + new int2(5, 5), Color.White); + p.ToInt2() + new int2(5, 5), Color.White); var resources = pl.PlayerActor.Trait(); var power = pl.PlayerActor.Trait(); @@ -480,7 +480,7 @@ namespace OpenRA.Mods.RA.Widgets var bi = info.Traits.GetOrDefault(); if (bi != null) DrawRightAligned("{1}{0}".F(bi.Power, bi.Power > 0 ? "+" : ""), pos + new int2(-5, 20), - ((power.PowerProvided - power.PowerDrained) >= -bi.Power || bi.Power > 0)? Color.White: Color.Red); + ((power.PowerProvided - power.PowerDrained) >= -bi.Power || bi.Power > 0)? Color.White: Color.Red); p += new int2(5, 35); if (!canBuildThis) @@ -500,31 +500,31 @@ namespace OpenRA.Mods.RA.Widgets p.ToInt2(), Color.White); } - bool DoBuildingHotkey(string key, World world) - { + bool DoBuildingHotkey(string key, World world) + { if (!paletteOpen) return false; if (CurrentQueue == null) return false; - var toBuild = CurrentQueue.BuildableItems().FirstOrDefault(b => b.Traits.Get().Hotkey == key); + var toBuild = CurrentQueue.BuildableItems().FirstOrDefault(b => b.Traits.Get().Hotkey == key); - if ( toBuild != null ) + if ( toBuild != null ) { Sound.Play(TabClick); - HandleBuildPalette(world, toBuild.Name, true); + HandleBuildPalette(world, toBuild.Name, true); return true; } return false; - } + } void TabChange(bool shift) - { + { var queues = VisibleQueues.Concat(VisibleQueues); if (shift) queues.Reverse(); var nextQueue = queues.SkipWhile( q => q != CurrentQueue ) .ElementAtOrDefault(1); if (nextQueue != null) SetCurrentTab( nextQueue ); - } + } } } \ No newline at end of file diff --git a/OpenRA.Mods.RA/Widgets/Logic/ConnectionDialogsLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/ConnectionDialogsLogic.cs index 2f5b39b16f..af57d27391 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/ConnectionDialogsLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/ConnectionDialogsLogic.cs @@ -32,14 +32,14 @@ namespace OpenRA.Mods.RA.Widgets.Logic widget.GetWidget("CONNECTING_DESC").GetText = () => "Connecting to {0}:{1}...".F(host, port); } - } + } public class ConnectionFailedLogic { [ObjectCreator.UseCtor] public ConnectionFailedLogic( [ObjectCreator.Param] Widget widget, - [ObjectCreator.Param] OrderManager orderManager) + [ObjectCreator.Param] OrderManager orderManager) { widget.GetWidget("CONNECTION_BUTTON_CANCEL").OnClick = () => { widget.GetWidget("CONNECTION_BUTTON_CANCEL").Parent.Visible = false; diff --git a/OpenRA.Mods.RA/Widgets/Logic/DiplomacyLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/DiplomacyLogic.cs index e2ca755e20..e748bfeac3 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/DiplomacyLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/DiplomacyLogic.cs @@ -126,8 +126,8 @@ namespace OpenRA.Mods.RA.Widgets.Logic Func setupItem = (s, template) => { var item = ScrollItemWidget.Setup(template, - () => s == world.LocalPlayer.Stances[ p ], - () => SetStance(dropdown, p, s)); + () => s == world.LocalPlayer.Stances[ p ], + () => SetStance(dropdown, p, s)); item.GetWidget("LABEL").GetText = () => s.ToString(); return item; diff --git a/OpenRA.Mods.RA/Widgets/Logic/DirectConnectLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/DirectConnectLogic.cs index 8edd8171a0..d7462ffeb7 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/DirectConnectLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/DirectConnectLogic.cs @@ -22,23 +22,23 @@ namespace OpenRA.Mods.RA.Widgets.Logic dc.GetWidget("SERVER_ADDRESS").Text = Game.Settings.Player.LastServer; - dc.GetWidget("JOIN_BUTTON").OnClick = () => - { - var address = dc.GetWidget("SERVER_ADDRESS").Text; - var addressParts = address.Split(':').ToArray(); - if (addressParts.Length < 1 || addressParts.Length > 2) - return; + dc.GetWidget("JOIN_BUTTON").OnClick = () => + { + var address = dc.GetWidget("SERVER_ADDRESS").Text; + var addressParts = address.Split(':').ToArray(); + if (addressParts.Length < 1 || addressParts.Length > 2) + return; - int port; - if (addressParts.Length != 2 || !int.TryParse(addressParts[1], out port)) - port = 1234; + int port; + if (addressParts.Length != 2 || !int.TryParse(addressParts[1], out port)) + port = 1234; - Game.Settings.Player.LastServer = address; - Game.Settings.Save(); + Game.Settings.Player.LastServer = address; + Game.Settings.Save(); - Widget.CloseWindow(); - Game.JoinServer(addressParts[0], port); - }; + Widget.CloseWindow(); + Game.JoinServer(addressParts[0], port); + }; dc.GetWidget("CANCEL_BUTTON").OnClick = () => { diff --git a/OpenRA.Mods.RA/Widgets/Logic/LobbyLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/LobbyLogic.cs index 6a9601ee09..36ffc7dd41 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/LobbyLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/LobbyLogic.cs @@ -30,14 +30,14 @@ namespace OpenRA.Mods.RA.Widgets.Logic string MapUid; Map Map; - public static ColorRamp CurrentColorPreview; + public static ColorRamp CurrentColorPreview; readonly OrderManager orderManager; readonly WorldRenderer worldRenderer; [ObjectCreator.UseCtor] internal LobbyLogic([ObjectCreator.Param( "widget" )] Widget lobby, - [ObjectCreator.Param] OrderManager orderManager, - [ObjectCreator.Param] WorldRenderer worldRenderer) + [ObjectCreator.Param] OrderManager orderManager, + [ObjectCreator.Param] WorldRenderer worldRenderer) { this.orderManager = orderManager; this.worldRenderer = worldRenderer; @@ -64,7 +64,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic { var map = mapPreview.Map(); if (map == null || mi.Button != MouseButton.Left - || orderManager.LocalClient.State == Session.ClientState.Ready) + || orderManager.LocalClient.State == Session.ClientState.Ready) return; var p = map.SpawnPoints @@ -208,7 +208,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic void UpdateColorPreview(float hf, float sf, float lf, float r) { - CurrentColorPreview = new ColorRamp((byte)(hf * 255), (byte)(sf * 255), (byte)(lf * 255), (byte)(r * 255)); + CurrentColorPreview = new ColorRamp((byte)(hf * 255), (byte)(sf * 255), (byte)(lf * 255), (byte)(r * 255)); } void UpdateCurrentMap() diff --git a/OpenRA.Mods.RA/Widgets/Logic/RADownloadPackagesLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/RADownloadPackagesLogic.cs index c2e2d753f5..d829e0b9da 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/RADownloadPackagesLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/RADownloadPackagesLogic.cs @@ -29,8 +29,8 @@ namespace OpenRA.Mods.RA.Widgets.Logic [ObjectCreator.UseCtor] public RADownloadPackagesLogic([ObjectCreator.Param] Widget widget, - [ObjectCreator.Param] Dictionary installData, - [ObjectCreator.Param] Action continueLoading) + [ObjectCreator.Param] Dictionary installData, + [ObjectCreator.Param] Action continueLoading) { this.installData = installData; this.continueLoading = continueLoading; diff --git a/OpenRA.Mods.RA/Widgets/Logic/RAInstallFromCDLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/RAInstallFromCDLogic.cs index 5a1951b943..9f75bc2f4d 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/RAInstallFromCDLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/RAInstallFromCDLogic.cs @@ -29,7 +29,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic [ObjectCreator.UseCtor] public RAInstallFromCDLogic([ObjectCreator.Param] Widget widget, - [ObjectCreator.Param] Action continueLoading) + [ObjectCreator.Param] Action continueLoading) { this.continueLoading = continueLoading; panel = widget.GetWidget("INSTALL_FROMCD_PANEL"); @@ -102,7 +102,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic return; if (!InstallUtils.ExtractFromPackage(source, extractPackage, extractFiles, dest, onProgress, onError)) - return; + return; Game.RunAfterTick(() => { diff --git a/OpenRA.Mods.RA/Widgets/Logic/RAInstallLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/RAInstallLogic.cs index c1b802d108..19e48186d2 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/RAInstallLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/RAInstallLogic.cs @@ -18,12 +18,12 @@ namespace OpenRA.Mods.RA.Widgets.Logic { [ObjectCreator.UseCtor] public RAInstallLogic([ObjectCreator.Param] Widget widget, - [ObjectCreator.Param] Dictionary installData, - [ObjectCreator.Param] Action continueLoading) + [ObjectCreator.Param] Dictionary installData, + [ObjectCreator.Param] Action continueLoading) { var panel = widget.GetWidget("INSTALL_PANEL"); var args = new WidgetArgs() - { + { { "continueLoading", () => { Widget.CloseWindow(); continueLoading(); } }, { "installData", installData } }; diff --git a/OpenRA.Mods.RA/Widgets/Logic/ReplayBrowserLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/ReplayBrowserLogic.cs index 73f1f65a2c..6530f8b22e 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/ReplayBrowserLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/ReplayBrowserLogic.cs @@ -85,8 +85,8 @@ namespace OpenRA.Mods.RA.Widgets.Logic void AddReplay(ScrollPanelWidget list, string filename, ScrollItemWidget template) { var item = ScrollItemWidget.Setup(template, - () => CurrentReplay == filename, - () => CurrentReplay = filename); + () => CurrentReplay == filename, + () => CurrentReplay = filename); var f = Path.GetFileName(filename); item.GetWidget("TITLE").GetText = () => f; list.AddChild(item); diff --git a/OpenRA.Mods.RA/Widgets/Logic/ServerBrowserLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/ServerBrowserLogic.cs index 2bdea984fd..f0c8b502d4 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/ServerBrowserLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/ServerBrowserLogic.cs @@ -88,8 +88,8 @@ namespace OpenRA.Mods.RA.Widgets.Logic { return string.Join("\n", s.UsefulMods .Select(m => - Mod.AllMods.ContainsKey(m.Key) ? string.Format("{0} ({1})", Mod.AllMods[m.Key].Title, m.Value) - : string.Format("Unknown Mod: {0}",m.Key)).ToArray()); + Mod.AllMods.ContainsKey(m.Key) ? string.Format("{0} ({1})", Mod.AllMods[m.Key].Title, m.Value) + : string.Format("Unknown Mod: {0}",m.Key)).ToArray()); } void RefreshServerList(IEnumerable games) @@ -97,8 +97,8 @@ namespace OpenRA.Mods.RA.Widgets.Logic var r = Widget.RootWidget; var bg = r.GetWidget("JOINSERVER_BG"); - if (bg == null) // We got a MasterServer reply AFTER the browser is gone, just return to prevent crash - Gecko - return; + if (bg == null) // We got a MasterServer reply AFTER the browser is gone, just return to prevent crash - Gecko + return; var sl = bg.GetWidget("SERVER_LIST"); @@ -112,9 +112,9 @@ namespace OpenRA.Mods.RA.Widgets.Logic return; } - var gamesWaiting = games.Where(g => g.CanJoin()); + var gamesWaiting = games.Where(g => g.CanJoin()); - if (gamesWaiting.Count() == 0) + if (gamesWaiting.Count() == 0) { r.GetWidget("JOINSERVER_PROGRESS_TITLE").Visible = true; r.GetWidget("JOINSERVER_PROGRESS_TITLE").Text = "No games found."; diff --git a/OpenRA.Mods.RA/Widgets/Logic/SettingsMenuLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/SettingsMenuLogic.cs index 5804511489..a49bd80b74 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/SettingsMenuLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/SettingsMenuLogic.cs @@ -46,15 +46,15 @@ namespace OpenRA.Mods.RA.Widgets.Logic else Game.Settings.Player.Name = name.Text; }; - name.OnEnterKey = () => { name.LoseFocus(); return true; }; + name.OnEnterKey = () => { name.LoseFocus(); return true; }; var edgescrollCheckbox = general.GetWidget("EDGE_SCROLL"); edgescrollCheckbox.IsChecked = () => Game.Settings.Game.ViewportEdgeScroll; edgescrollCheckbox.OnClick = () => Game.Settings.Game.ViewportEdgeScroll ^= true; - var edgeScrollSlider = general.GetWidget("EDGE_SCROLL_AMOUNT"); + var edgeScrollSlider = general.GetWidget("EDGE_SCROLL_AMOUNT"); edgeScrollSlider.Value = Game.Settings.Game.ViewportEdgeScrollStep; - edgeScrollSlider.OnChange += x => Game.Settings.Game.ViewportEdgeScrollStep = x; + edgeScrollSlider.OnChange += x => Game.Settings.Game.ViewportEdgeScrollStep = x; var inversescroll = general.GetWidget("INVERSE_SCROLL"); inversescroll.IsChecked = () => Game.Settings.Game.MouseScroll == MouseScrollType.Inverted; diff --git a/OpenRA.Mods.RA/Widgets/RadarBinWidget.cs b/OpenRA.Mods.RA/Widgets/RadarBinWidget.cs index 3871b99e69..c711a2746a 100755 --- a/OpenRA.Mods.RA/Widgets/RadarBinWidget.cs +++ b/OpenRA.Mods.RA/Widgets/RadarBinWidget.cs @@ -166,9 +166,9 @@ namespace OpenRA.Mods.RA.Widgets int updateTicks = 0; public override void Tick() { - var hasRadarNew = world - .ActorsWithTrait() - .Any(a => a.Actor.Owner == world.LocalPlayer && a.Trait.IsActive); + var hasRadarNew = world + .ActorsWithTrait() + .Any(a => a.Actor.Owner == world.LocalPlayer && a.Trait.IsActive); if (hasRadarNew != hasRadar) radarAnimating = true; diff --git a/OpenRA.Mods.RA/Widgets/WorldCommandWidget.cs b/OpenRA.Mods.RA/Widgets/WorldCommandWidget.cs index fa0ad57d24..3f233ce333 100644 --- a/OpenRA.Mods.RA/Widgets/WorldCommandWidget.cs +++ b/OpenRA.Mods.RA/Widgets/WorldCommandWidget.cs @@ -53,12 +53,12 @@ namespace OpenRA.Mods.RA.Widgets if (e.Modifiers == Modifiers.None && e.Event == KeyInputEvent.Down) { if (e.KeyName == BaseCycleKey) - return CycleBases(); + return CycleBases(); if (!World.Selection.Actors.Any()) return false; - if (e.KeyName == AttackMoveKey) + if (e.KeyName == AttackMoveKey) return PerformAttackMove(); if (e.KeyName == StopKey) @@ -142,24 +142,24 @@ namespace OpenRA.Mods.RA.Widgets return true; } - bool CycleBases() - { - var bases = World.ActorsWithTrait() - .Where( a => a.Actor.Owner == World.LocalPlayer ).ToArray(); - if (!bases.Any()) return true; + bool CycleBases() + { + var bases = World.ActorsWithTrait() + .Where( a => a.Actor.Owner == World.LocalPlayer ).ToArray(); + if (!bases.Any()) return true; - var next = bases - .Select(b => b.Actor) - .SkipWhile(b => !World.Selection.Actors.Contains(b)) - .Skip(1) - .FirstOrDefault(); + var next = bases + .Select(b => b.Actor) + .SkipWhile(b => !World.Selection.Actors.Contains(b)) + .Skip(1) + .FirstOrDefault(); - if (next == null) - next = bases.Select(b => b.Actor).First(); + if (next == null) + next = bases.Select(b => b.Actor).First(); - World.Selection.Combine(World, new Actor[] { next }, false, true); - Game.viewport.Center(World.Selection.Actors); - return true; - } + World.Selection.Combine(World, new Actor[] { next }, false, true); + Game.viewport.Center(World.Selection.Actors); + return true; + } } } \ No newline at end of file diff --git a/OpenRA.Mods.RA/Widgets/WorldTooltipWidget.cs b/OpenRA.Mods.RA/Widgets/WorldTooltipWidget.cs index 37d0c8c89b..a521184588 100755 --- a/OpenRA.Mods.RA/Widgets/WorldTooltipWidget.cs +++ b/OpenRA.Mods.RA/Widgets/WorldTooltipWidget.cs @@ -62,7 +62,7 @@ namespace OpenRA.Mods.RA.Widgets var nameText = itt.Name(); var ownerText = !owner.NonCombatant ? owner.PlayerName : ""; var stanceText = (world.LocalPlayer != null && owner != actor.World.LocalPlayer - && !owner.NonCombatant) ? " ({0})".F(itt.Stance()) : ""; + && !owner.NonCombatant) ? " ({0})".F(itt.Stance()) : ""; var nameSize = Game.Renderer.Fonts["Bold"].Measure(nameText); var ownerSize = Game.Renderer.Fonts["Regular"].Measure(ownerText); diff --git a/OpenRA.Mods.RA/World/PlayMusicOnMapLoad.cs b/OpenRA.Mods.RA/World/PlayMusicOnMapLoad.cs index 50479329ec..f93d5391a0 100644 --- a/OpenRA.Mods.RA/World/PlayMusicOnMapLoad.cs +++ b/OpenRA.Mods.RA/World/PlayMusicOnMapLoad.cs @@ -37,7 +37,7 @@ namespace OpenRA.Mods.RA var onComplete = Info.Loop ? (Action)PlayMusic : () => {}; if (Game.Settings.Sound.ShellmapMusic && - Rules.Music.ContainsKey(Info.Music)) + Rules.Music.ContainsKey(Info.Music)) Sound.PlayMusicThen(Rules.Music[Info.Music], onComplete); } } diff --git a/OpenRA.Mods.RA/World/SmudgeLayer.cs b/OpenRA.Mods.RA/World/SmudgeLayer.cs index 329b6fca0c..dbf39b2bff 100755 --- a/OpenRA.Mods.RA/World/SmudgeLayer.cs +++ b/OpenRA.Mods.RA/World/SmudgeLayer.cs @@ -50,7 +50,7 @@ namespace OpenRA.Mods.RA // Add map smudges foreach (var s in w.Map.Smudges.Value.Where( s => Info.Types.Contains(s.Type ))) tiles.Add(s.Location,new TileReference((byte)Array.IndexOf(Info.Types,s.Type), - (byte)s.Depth)); + (byte)s.Depth)); } public void AddSmudge(int2 loc) diff --git a/OpenRA.TilesetBuilder/Form1.Designer.cs b/OpenRA.TilesetBuilder/Form1.Designer.cs index 2caa846896..6c5336a3fc 100644 --- a/OpenRA.TilesetBuilder/Form1.Designer.cs +++ b/OpenRA.TilesetBuilder/Form1.Designer.cs @@ -106,21 +106,21 @@ namespace OpenRA.TilesetBuilder // this.toolStrip1.Dock = System.Windows.Forms.DockStyle.None; this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.toolStripButton2, - this.toolStripButton14, - this.toolStripButton3, - this.toolStripSeparator1, - this.toolStripButton4, - this.toolStripButton12, - this.toolStripButton11, - this.toolStripButton10, - this.toolStripButton9, - this.toolStripButton8, - this.toolStripButton7, - this.toolStripButton6, - this.toolStripButton5, - this.toolStripButton13, - this.toolStripButton1}); + this.toolStripButton2, + this.toolStripButton14, + this.toolStripButton3, + this.toolStripSeparator1, + this.toolStripButton4, + this.toolStripButton12, + this.toolStripButton11, + this.toolStripButton10, + this.toolStripButton9, + this.toolStripButton8, + this.toolStripButton7, + this.toolStripButton6, + this.toolStripButton5, + this.toolStripButton13, + this.toolStripButton1}); this.toolStrip1.Location = new System.Drawing.Point(3, 0); this.toolStrip1.Name = "toolStrip1"; this.toolStrip1.Size = new System.Drawing.Size(602, 25); diff --git a/OpenRA.Utility/Program.cs b/OpenRA.Utility/Program.cs index d245b4b886..1c391ed9a6 100644 --- a/OpenRA.Utility/Program.cs +++ b/OpenRA.Utility/Program.cs @@ -55,20 +55,20 @@ namespace OpenRA.Utility Console.WriteLine(" --settings-value KEY Get value of KEY from settings.yaml"); Console.WriteLine(" --shp PNGFILE FRAMEWIDTH Convert a PNG containing one or more frames to a SHP"); Console.WriteLine(" --png SHPFILE PALETTE [--transparent] Convert a SHP to a PNG containing all of its frames, optionally setting up transparency"); - Console.WriteLine(" --extract MOD[,MOD]* FILES Extract files from mod packages"); + Console.WriteLine(" --extract MOD[,MOD]* FILES Extract files from mod packages"); Console.WriteLine(" --tmp-png MOD[,MOD]* THEATER FILES Extract terrain tiles to PNG"); } - static string GetNamedArg(string[] args, string arg) - { - if (args.Length < 2) - return null; + static string GetNamedArg(string[] args, string arg) + { + if (args.Length < 2) + return null; - var i = Array.IndexOf(args, arg); - if (i < 0 || i == args.Length - 1) // doesnt exist, or doesnt have a value. - return null; + var i = Array.IndexOf(args, arg); + if (i < 0 || i == args.Length - 1) // doesnt exist, or doesnt have a value. + return null; - return args[i + 1]; - } + return args[i + 1]; + } } } diff --git a/RALint/RALint.cs b/RALint/RALint.cs index 4d30243ad2..892917c0e5 100644 --- a/RALint/RALint.cs +++ b/RALint/RALint.cs @@ -49,16 +49,16 @@ namespace RALint Rules.LoadRules(Game.modData.Manifest, new Map()); foreach (var customPassType in Game.modData.ObjectCreator - .GetTypesImplementing()) - { - var customPass = (ILintPass)Game.modData.ObjectCreator - .CreateBasic(customPassType); + .GetTypesImplementing()) + { + var customPass = (ILintPass)Game.modData.ObjectCreator + .CreateBasic(customPassType); if (verbose) - Console.WriteLine("Pass: {0}".F(customPassType.ToString())); + Console.WriteLine("Pass: {0}".F(customPassType.ToString())); - customPass.Run(EmitError, EmitWarning); - } + customPass.Run(EmitError, EmitWarning); + } if (errors > 0) {