[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) { } 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) public CursorSequence(string cursorSrc, XmlElement e)
{ {
sprites = CursorSheetBuilder.LoadAllSprites(cursorSrc, ".shp"); sprites = CursorSheetBuilder.LoadAllSprites(cursorSrc, ".shp");
start = int.Parse(e.GetAttribute("start")); start = int.Parse(e.GetAttribute("start"));
if (e.GetAttribute("length") == "*" || e.GetAttribute("end") == "*") if (e.GetAttribute("length") == "*" || e.GetAttribute("end") == "*")

View File

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

View File

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

View File

@@ -45,7 +45,7 @@ namespace OpenRa.Game.Graphics
{ {
float2 r1 = new float2(2, -2) / screenSize; float2 r1 = new float2(2, -2) / screenSize;
float2 r2 = new float2(-1, 1); float2 r2 = new float2(-1, 1);
renderer.BeginFrame(r1, r2, scrollPosition); renderer.BeginFrame(r1, r2, scrollPosition);
Game.worldRenderer.Draw(); Game.worldRenderer.Draw();

View File

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

View File

@@ -119,7 +119,7 @@ namespace OpenRa.Game
{ {
/* make some progress on the first search */ /* make some progress on the first search */
var p = fromSrc.Expand( passableCost ); var p = fromSrc.Expand( passableCost );
if (fromDest.cellInfo[p.X, p.Y].Seen && fromDest.cellInfo[p.X, p.Y].MinCost < float.PositiveInfinity) if (fromDest.cellInfo[p.X, p.Y].Seen && fromDest.cellInfo[p.X, p.Y].MinCost < float.PositiveInfinity)
return MakeBidiPath(fromSrc, fromDest, p); return MakeBidiPath(fromSrc, fromDest, p);

View File

@@ -57,8 +57,8 @@ namespace OpenRa.Game
continue; continue;
if (customBlock != null && customBlock(newHere)) if (customBlock != null && customBlock(newHere))
continue; continue;
var est = heuristic( newHere ); var est = heuristic( newHere );
if( est == float.PositiveInfinity ) if( est == float.PositiveInfinity )
continue; continue;
@@ -84,12 +84,12 @@ namespace OpenRa.Game
queue.Add( new PathDistance( heuristic( location ), location ) ); queue.Add( new PathDistance( heuristic( location ), location ) );
} }
public static PathSearch FromPoint( int2 from, int2 target, UnitMovementType umt, bool checkForBlocked ) public static PathSearch FromPoint( int2 from, int2 target, UnitMovementType umt, bool checkForBlocked )
{ {
var search = new PathSearch { var search = new PathSearch {

View File

@@ -26,7 +26,7 @@ namespace OpenRa.Game
if (!Game.IsCloseEnoughToBase(Owner, Building, xy)) if (!Game.IsCloseEnoughToBase(Owner, Building, xy))
yield break; yield break;
yield return OpenRa.Game.Order.PlaceBuilding( Owner, xy, Building.Name ); yield return OpenRa.Game.Order.PlaceBuilding( Owner, xy, Building.Name );
} }
else // rmb else // rmb

View File

@@ -128,7 +128,7 @@ namespace OpenRa.Game.Traits.Activities
Game.UnitInfluence.Remove( mobile ); Game.UnitInfluence.Remove( mobile );
var newPath = getPath(self, mobile).TakeWhile(a => a != self.Location).ToList(); var newPath = getPath(self, mobile).TakeWhile(a => a != self.Location).ToList();
Game.UnitInfluence.Add( mobile ); Game.UnitInfluence.Add( mobile );
if (newPath.Count != 0) if (newPath.Count != 0)
path = newPath; path = newPath;

View File

@@ -1,25 +1,25 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
namespace OpenRa.Game.Traits namespace OpenRa.Game.Traits
{ {
class AttackBase : IOrder, ITick class AttackBase : IOrder, ITick
{ {
public Actor target; public Actor target;
// time (in frames) until each weapon can fire again. // time (in frames) until each weapon can fire again.
protected int primaryFireDelay = 0; protected int primaryFireDelay = 0;
protected int secondaryFireDelay = 0; protected int secondaryFireDelay = 0;
public float primaryRecoil = 0.0f, secondaryRecoil = 0.0f; public float primaryRecoil = 0.0f, secondaryRecoil = 0.0f;
public AttackBase(Actor self) { } public AttackBase(Actor self) { }
protected bool CanAttack( Actor self ) protected bool CanAttack( Actor self )
{ {
return target != null; return target != null;
} }
public virtual void Tick(Actor self) public virtual void Tick(Actor self)
@@ -31,18 +31,18 @@ namespace OpenRa.Game.Traits
secondaryRecoil = Math.Max(0f, secondaryRecoil - .2f); secondaryRecoil = Math.Max(0f, secondaryRecoil - .2f);
if (target != null && target.IsDead) target = null; /* he's dead, jim. */ 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>(); var rut = self.traits.GetOrDefault<RenderUnitTurreted>();
if( self.unitInfo.Primary != null && CheckFire( self, self.unitInfo.Primary, ref primaryFireDelay, if( self.unitInfo.Primary != null && CheckFire( self, self.unitInfo.Primary, ref primaryFireDelay,
self.unitInfo.PrimaryOffset ) ) self.unitInfo.PrimaryOffset ) )
{ {
secondaryFireDelay = Math.Max( 4, secondaryFireDelay ); secondaryFireDelay = Math.Max( 4, secondaryFireDelay );
primaryRecoil = 1; primaryRecoil = 1;
return; return;
} }
if (self.unitInfo.Secondary != null && CheckFire(self, self.unitInfo.Secondary, ref secondaryFireDelay, 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; if (self.unitInfo.SecondaryOffset != null) secondaryRecoil = 1;
else primaryRecoil = 1; else primaryRecoil = 1;
return; return;
} }
} }
bool CheckFire( Actor self, string weaponName, ref int fireDelay, int[] offset ) 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)
{ {
base.Tick(self); if( fireDelay > 0 ) return false;
var weapon = Rules.WeaponInfo[ weaponName ];
if( !CanAttack( self ) ) return; if( weapon.Range * weapon.Range < ( target.Location - self.Location ).LengthSquared ) return false;
var turreted = self.traits.Get<Turreted>(); fireDelay = weapon.ROF;
turreted.desiredFacing = Util.GetFacing( target.CenterLocation - self.CenterLocation, turreted.turretFacing );
if( turreted.desiredFacing != turreted.turretFacing ) Game.world.Add( new Bullet( weaponName, self.Owner, self,
return; self.CenterLocation.ToInt2() + Util.GetTurretPosition( self, offset, 0f ).ToInt2(),
target.CenterLocation.ToInt2() ) );
DoAttack( self );
} 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 position = Game.controller.MousePosition.ToInt2();
var isCloseEnough = Game.IsCloseEnoughToBase(Game.LocalPlayer, bi, position); var isCloseEnough = Game.IsCloseEnoughToBase(Game.LocalPlayer, bi, position);
foreach( var t in Footprint.Tiles( bi, position ) ) foreach( var t in Footprint.Tiles( bi, position ) )
spriteRenderer.DrawSprite( ( isCloseEnough && Game.IsCellBuildable( t, bi.WaterBound spriteRenderer.DrawSprite( ( isCloseEnough && Game.IsCellBuildable( t, bi.WaterBound
? UnitMovementType.Float : UnitMovementType.Wheel ) && !Game.map.ContainsResource( t ) ) ? UnitMovementType.Float : UnitMovementType.Wheel ) && !Game.map.ContainsResource( t ) )

View File

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

View File

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