From c0fe3fa4c9371ba4935e96c7e5d4d0798f2408ce Mon Sep 17 00:00:00 2001 From: Bob Date: Thu, 19 Nov 2009 15:18:13 +1300 Subject: [PATCH] [More whitespace fixes] --- OpenRa.Game/GameRules/UnitInfo.cs | 32 ----- OpenRa.Game/Graphics/CursorSequence.cs | 2 +- OpenRa.Game/Graphics/OverlayRenderer.cs | 2 +- OpenRa.Game/Graphics/SequenceProvider.cs | 4 +- OpenRa.Game/Graphics/Viewport.cs | 2 +- OpenRa.Game/MainWindow.cs | 2 +- OpenRa.Game/PathFinder.cs | 2 +- OpenRa.Game/PathSearch.cs | 14 +-- OpenRa.Game/PlaceBuilding.cs | 2 +- OpenRa.Game/Traits/Activities/Move.cs | 2 +- OpenRa.Game/Traits/AttackTurreted.cs | 142 +++++++++++------------ OpenRa.Game/UiOverlay.cs | 2 +- SequenceEditor/Program.cs | 2 +- SequenceEditor/Surface.cs | 2 +- 14 files changed, 90 insertions(+), 122 deletions(-) diff --git a/OpenRa.Game/GameRules/UnitInfo.cs b/OpenRa.Game/GameRules/UnitInfo.cs index 58803b0bdf..2976ac3ac0 100755 --- a/OpenRa.Game/GameRules/UnitInfo.cs +++ b/OpenRa.Game/GameRules/UnitInfo.cs @@ -102,37 +102,5 @@ namespace OpenRa.Game.GameRules public BuildingInfo(string name) : base(name) { } } - - /* - * Example: HARV - * Unit (can move, etc) - * PlayerOwned - * Selectable - * CanHarvest - * - * Example: PROC (refinery) - * Building (can't move) - * AcceptsOre (harvester returns here) - * - * Example: 3TNK (soviet heavy tank) - * Unit - * Turret (can aim in different direction to movement) - * - * Example: GUN (allied base defense turret) - * Building - * Turret - * - * some traits can be determined by fields in rules.ini - * and some can't : - * Gap-generator's ability - * Nuke, chrone, curtain, (super-weapons) - * Aircraft-landable - * Selectable (bomber/spyplane can't be selected, for example) - * AppearsFriendly (spy) - * IsInfantry (can be build in TENT/BARR, 5-in-a-square) - * IsVehicle - * Squashable (sandbags, infantry) - * Special rendering for war factory - */ } } diff --git a/OpenRa.Game/Graphics/CursorSequence.cs b/OpenRa.Game/Graphics/CursorSequence.cs index 55209762da..57cf7cd628 100644 --- a/OpenRa.Game/Graphics/CursorSequence.cs +++ b/OpenRa.Game/Graphics/CursorSequence.cs @@ -21,7 +21,7 @@ namespace OpenRa.Game.Graphics public CursorSequence(string cursorSrc, XmlElement e) { sprites = CursorSheetBuilder.LoadAllSprites(cursorSrc, ".shp"); - + start = int.Parse(e.GetAttribute("start")); if (e.GetAttribute("length") == "*" || e.GetAttribute("end") == "*") diff --git a/OpenRa.Game/Graphics/OverlayRenderer.cs b/OpenRa.Game/Graphics/OverlayRenderer.cs index fabcf03fbe..ad3a00efb1 100755 --- a/OpenRa.Game/Graphics/OverlayRenderer.cs +++ b/OpenRa.Game/Graphics/OverlayRenderer.cs @@ -16,7 +16,7 @@ namespace OpenRa.Game.Graphics "v12", "v13", "v14", "v15", "v16", "v17", "v18", "fpls", "wcrate", "scrate", "barb", "sbag", }; - + Sprite[][] overlaySprites; Sprite[] smudgeSprites; diff --git a/OpenRa.Game/Graphics/SequenceProvider.cs b/OpenRa.Game/Graphics/SequenceProvider.cs index 848e8e0920..881c7477a5 100644 --- a/OpenRa.Game/Graphics/SequenceProvider.cs +++ b/OpenRa.Game/Graphics/SequenceProvider.cs @@ -39,11 +39,11 @@ namespace OpenRa.Game.Graphics static void LoadSequencesForUnit(XmlElement eUnit) { string unitName = eUnit.GetAttribute("name"); - + var sequences = eUnit.SelectNodes("./sequence").OfType() .Select(e => new Sequence(unitName, e)) .ToDictionary(s => s.Name); - + units.Add(unitName, sequences); } diff --git a/OpenRa.Game/Graphics/Viewport.cs b/OpenRa.Game/Graphics/Viewport.cs index 4e3c145969..0f74cb84b1 100644 --- a/OpenRa.Game/Graphics/Viewport.cs +++ b/OpenRa.Game/Graphics/Viewport.cs @@ -45,7 +45,7 @@ namespace OpenRa.Game.Graphics { float2 r1 = new float2(2, -2) / screenSize; float2 r2 = new float2(-1, 1); - + renderer.BeginFrame(r1, r2, scrollPosition); Game.worldRenderer.Draw(); diff --git a/OpenRa.Game/MainWindow.cs b/OpenRa.Game/MainWindow.cs index 03726a120a..e407a60f4f 100755 --- a/OpenRa.Game/MainWindow.cs +++ b/OpenRa.Game/MainWindow.cs @@ -9,7 +9,7 @@ namespace OpenRa.Game class MainWindow : Form { readonly Renderer renderer; - + static Size GetResolution(Settings settings) { var desktopResolution = Screen.PrimaryScreen.Bounds.Size; diff --git a/OpenRa.Game/PathFinder.cs b/OpenRa.Game/PathFinder.cs index 938781a289..d180b3fda9 100644 --- a/OpenRa.Game/PathFinder.cs +++ b/OpenRa.Game/PathFinder.cs @@ -119,7 +119,7 @@ namespace OpenRa.Game { /* make some progress on the first search */ var p = fromSrc.Expand( passableCost ); - + if (fromDest.cellInfo[p.X, p.Y].Seen && fromDest.cellInfo[p.X, p.Y].MinCost < float.PositiveInfinity) return MakeBidiPath(fromSrc, fromDest, p); diff --git a/OpenRa.Game/PathSearch.cs b/OpenRa.Game/PathSearch.cs index 86d2646f81..dfd22e2f4f 100755 --- a/OpenRa.Game/PathSearch.cs +++ b/OpenRa.Game/PathSearch.cs @@ -57,8 +57,8 @@ namespace OpenRa.Game continue; if (customBlock != null && customBlock(newHere)) continue; - + var est = heuristic( newHere ); if( est == float.PositiveInfinity ) continue; @@ -84,12 +84,12 @@ namespace OpenRa.Game queue.Add( new PathDistance( heuristic( location ), location ) ); } - - - - - - + + + + + + public static PathSearch FromPoint( int2 from, int2 target, UnitMovementType umt, bool checkForBlocked ) { var search = new PathSearch { diff --git a/OpenRa.Game/PlaceBuilding.cs b/OpenRa.Game/PlaceBuilding.cs index 5b49e337fe..29cb5da425 100644 --- a/OpenRa.Game/PlaceBuilding.cs +++ b/OpenRa.Game/PlaceBuilding.cs @@ -26,7 +26,7 @@ namespace OpenRa.Game if (!Game.IsCloseEnoughToBase(Owner, Building, xy)) yield break; - + yield return OpenRa.Game.Order.PlaceBuilding( Owner, xy, Building.Name ); } else // rmb diff --git a/OpenRa.Game/Traits/Activities/Move.cs b/OpenRa.Game/Traits/Activities/Move.cs index df3b82b6f9..e4c86cee46 100755 --- a/OpenRa.Game/Traits/Activities/Move.cs +++ b/OpenRa.Game/Traits/Activities/Move.cs @@ -128,7 +128,7 @@ namespace OpenRa.Game.Traits.Activities Game.UnitInfluence.Remove( mobile ); var newPath = getPath(self, mobile).TakeWhile(a => a != self.Location).ToList(); - + Game.UnitInfluence.Add( mobile ); if (newPath.Count != 0) path = newPath; diff --git a/OpenRa.Game/Traits/AttackTurreted.cs b/OpenRa.Game/Traits/AttackTurreted.cs index e79f5ddc28..e20abb8ab3 100755 --- a/OpenRa.Game/Traits/AttackTurreted.cs +++ b/OpenRa.Game/Traits/AttackTurreted.cs @@ -1,25 +1,25 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace OpenRa.Game.Traits -{ - class AttackBase : IOrder, ITick - { - public Actor target; - - // time (in frames) until each weapon can fire again. - protected int primaryFireDelay = 0; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace OpenRa.Game.Traits +{ + class AttackBase : IOrder, ITick + { + public Actor target; + + // time (in frames) until each weapon can fire again. + protected int primaryFireDelay = 0; protected int secondaryFireDelay = 0; public float primaryRecoil = 0.0f, secondaryRecoil = 0.0f; - public AttackBase(Actor self) { } - - protected bool CanAttack( Actor self ) + public AttackBase(Actor self) { } + + protected bool CanAttack( Actor self ) { - return target != null; + return target != null; } public virtual void Tick(Actor self) @@ -31,18 +31,18 @@ namespace OpenRa.Game.Traits secondaryRecoil = Math.Max(0f, secondaryRecoil - .2f); if (target != null && target.IsDead) target = null; /* he's dead, jim. */ - } - - public void DoAttack( Actor self ) + } + + public void DoAttack( Actor self ) { - var rut = self.traits.GetOrDefault(); - - if( self.unitInfo.Primary != null && CheckFire( self, self.unitInfo.Primary, ref primaryFireDelay, - self.unitInfo.PrimaryOffset ) ) - { + var rut = self.traits.GetOrDefault(); + + if( self.unitInfo.Primary != null && CheckFire( self, self.unitInfo.Primary, ref primaryFireDelay, + self.unitInfo.PrimaryOffset ) ) + { secondaryFireDelay = Math.Max( 4, secondaryFireDelay ); - primaryRecoil = 1; - return; + primaryRecoil = 1; + return; } if (self.unitInfo.Secondary != null && CheckFire(self, self.unitInfo.Secondary, ref secondaryFireDelay, @@ -51,48 +51,48 @@ namespace OpenRa.Game.Traits if (self.unitInfo.SecondaryOffset != null) secondaryRecoil = 1; else primaryRecoil = 1; return; - } - } - - bool CheckFire( Actor self, string weaponName, ref int fireDelay, int[] offset ) - { - if( fireDelay > 0 ) return false; - var weapon = Rules.WeaponInfo[ weaponName ]; - if( weapon.Range * weapon.Range < ( target.Location - self.Location ).LengthSquared ) return false; - - fireDelay = weapon.ROF; - - Game.world.Add( new Bullet( weaponName, self.Owner, self, - self.CenterLocation.ToInt2() + Util.GetTurretPosition( self, offset, 0f ).ToInt2(), - target.CenterLocation.ToInt2() ) ); - - return true; - } - - public Order Order( Actor self, int2 xy, bool lmb, Actor underCursor ) - { - if( lmb || underCursor == null ) return null; - if( underCursor.Owner == self.Owner ) return null; - return OpenRa.Game.Order.Attack( self, underCursor ); - } - } - - class AttackTurreted : AttackBase - { - public AttackTurreted( Actor self ) : base(self) { self.traits.Get(); } - - public override void Tick(Actor self) + } + } + + bool CheckFire( Actor self, string weaponName, ref int fireDelay, int[] offset ) { - base.Tick(self); - - if( !CanAttack( self ) ) return; - - var turreted = self.traits.Get(); - turreted.desiredFacing = Util.GetFacing( target.CenterLocation - self.CenterLocation, turreted.turretFacing ); - if( turreted.desiredFacing != turreted.turretFacing ) - return; - - DoAttack( self ); - } - } -} + if( fireDelay > 0 ) return false; + var weapon = Rules.WeaponInfo[ weaponName ]; + if( weapon.Range * weapon.Range < ( target.Location - self.Location ).LengthSquared ) return false; + + fireDelay = weapon.ROF; + + Game.world.Add( new Bullet( weaponName, self.Owner, self, + self.CenterLocation.ToInt2() + Util.GetTurretPosition( self, offset, 0f ).ToInt2(), + target.CenterLocation.ToInt2() ) ); + + return true; + } + + public Order Order( Actor self, int2 xy, bool lmb, Actor underCursor ) + { + if( lmb || underCursor == null ) return null; + if( underCursor.Owner == self.Owner ) return null; + return OpenRa.Game.Order.Attack( self, underCursor ); + } + } + + class AttackTurreted : AttackBase + { + public AttackTurreted( Actor self ) : base(self) { self.traits.Get(); } + + public override void Tick(Actor self) + { + base.Tick(self); + + if( !CanAttack( self ) ) return; + + var turreted = self.traits.Get(); + turreted.desiredFacing = Util.GetFacing( target.CenterLocation - self.CenterLocation, turreted.turretFacing ); + if( turreted.desiredFacing != turreted.turretFacing ) + return; + + DoAttack( self ); + } + } +} diff --git a/OpenRa.Game/UiOverlay.cs b/OpenRa.Game/UiOverlay.cs index e8a80c2375..340ac0d951 100644 --- a/OpenRa.Game/UiOverlay.cs +++ b/OpenRa.Game/UiOverlay.cs @@ -47,7 +47,7 @@ namespace OpenRa.Game { var position = Game.controller.MousePosition.ToInt2(); var isCloseEnough = Game.IsCloseEnoughToBase(Game.LocalPlayer, bi, position); - + foreach( var t in Footprint.Tiles( bi, position ) ) spriteRenderer.DrawSprite( ( isCloseEnough && Game.IsCellBuildable( t, bi.WaterBound ? UnitMovementType.Float : UnitMovementType.Wheel ) && !Game.map.ContainsResource( t ) ) diff --git a/SequenceEditor/Program.cs b/SequenceEditor/Program.cs index ebc7482f19..a81437786a 100644 --- a/SequenceEditor/Program.cs +++ b/SequenceEditor/Program.cs @@ -68,7 +68,7 @@ namespace SequenceEditor { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); - + FileSystem.Mount(new Folder("./")); var packages = new[] { "redalert", "conquer", "hires", "general", "local", "temperat" }; diff --git a/SequenceEditor/Surface.cs b/SequenceEditor/Surface.cs index 21435e1ef0..015f0325f7 100644 --- a/SequenceEditor/Surface.cs +++ b/SequenceEditor/Surface.cs @@ -28,7 +28,7 @@ namespace SequenceEditor { base.OnMouseMove(e); mousePos = e.Location; - + if (e.Button == MouseButtons.Left) isDragging = true;