[More whitespace fixes]

This commit is contained in:
Bob
2009-11-19 15:18:13 +13:00
parent a17296ff8a
commit c0fe3fa4c9
14 changed files with 90 additions and 122 deletions

View File

@@ -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
*/
}
}

View File

@@ -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") == "*")

View File

@@ -16,7 +16,7 @@ namespace OpenRa.Game.Graphics
"v12", "v13", "v14", "v15", "v16", "v17", "v18",
"fpls", "wcrate", "scrate", "barb", "sbag",
};
Sprite[][] overlaySprites;
Sprite[] smudgeSprites;

View File

@@ -39,11 +39,11 @@ namespace OpenRa.Game.Graphics
static void LoadSequencesForUnit(XmlElement eUnit)
{
string unitName = eUnit.GetAttribute("name");
var sequences = eUnit.SelectNodes("./sequence").OfType<XmlElement>()
.Select(e => new Sequence(unitName, e))
.ToDictionary(s => s.Name);
units.Add(unitName, sequences);
}

View File

@@ -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();

View File

@@ -9,7 +9,7 @@ namespace OpenRa.Game
class MainWindow : Form
{
readonly Renderer renderer;
static Size GetResolution(Settings settings)
{
var desktopResolution = Screen.PrimaryScreen.Bounds.Size;

View File

@@ -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);

View File

@@ -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 {

View File

@@ -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

View File

@@ -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;

View File

@@ -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<RenderUnitTurreted>();
if( self.unitInfo.Primary != null && CheckFire( self, self.unitInfo.Primary, ref primaryFireDelay,
self.unitInfo.PrimaryOffset ) )
{
var rut = self.traits.GetOrDefault<RenderUnitTurreted>();
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<Turreted>(); }
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>();
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<Turreted>(); }
public override void Tick(Actor self)
{
base.Tick(self);
if( !CanAttack( self ) ) return;
var turreted = self.traits.Get<Turreted>();
turreted.desiredFacing = Util.GetFacing( target.CenterLocation - self.CenterLocation, turreted.turretFacing );
if( turreted.desiredFacing != turreted.turretFacing )
return;
DoAttack( self );
}
}
}

View File

@@ -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 ) )

View File

@@ -68,7 +68,7 @@ namespace SequenceEditor
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
FileSystem.Mount(new Folder("./"));
var packages = new[] { "redalert", "conquer", "hires", "general", "local", "temperat" };

View File

@@ -28,7 +28,7 @@ namespace SequenceEditor
{
base.OnMouseMove(e);
mousePos = e.Location;
if (e.Button == MouseButtons.Left)
isDragging = true;