StyleCop fixes

This commit is contained in:
reaperrr
2015-01-04 04:21:44 +01:00
parent 654f56c5d5
commit cb3ba37462
13 changed files with 165 additions and 165 deletions

View File

@@ -61,9 +61,9 @@ namespace OpenRA.Mods.Common.Traits
public readonly WeaponInfo Weapon;
public readonly Barrel[] Barrels;
public readonly Actor self;
Lazy<Turreted> Turret;
Lazy<IBodyOrientation> Coords;
readonly Actor self;
Lazy<Turreted> turret;
Lazy<IBodyOrientation> coords;
Lazy<LimitedAmmo> limitedAmmo;
List<Pair<int, Action>> delayedActions = new List<Pair<int, Action>>();
@@ -77,8 +77,8 @@ namespace OpenRA.Mods.Common.Traits
this.self = self;
// We can't resolve these until runtime
Turret = Exts.Lazy(() => self.TraitsImplementing<Turreted>().FirstOrDefault(t => t.Name == info.Turret));
Coords = Exts.Lazy(() => self.Trait<IBodyOrientation>());
turret = Exts.Lazy(() => self.TraitsImplementing<Turreted>().FirstOrDefault(t => t.Name == info.Turret));
coords = Exts.Lazy(() => self.Trait<IBodyOrientation>());
limitedAmmo = Exts.Lazy(() => self.TraitOrDefault<LimitedAmmo>());
Weapon = self.World.Map.Rules.Weapons[info.Weapon.ToLowerInvariant()];
@@ -205,23 +205,23 @@ namespace OpenRA.Mods.Common.Traits
public WVec MuzzleOffset(Actor self, Barrel b)
{
var bodyOrientation = Coords.Value.QuantizeOrientation(self, self.Orientation);
var bodyOrientation = coords.Value.QuantizeOrientation(self, self.Orientation);
var localOffset = b.Offset + new WVec(-Recoil, WRange.Zero, WRange.Zero);
if (Turret.Value != null)
if (turret.Value != null)
{
var turretOrientation = Coords.Value.QuantizeOrientation(self, Turret.Value.LocalOrientation(self));
var turretOrientation = coords.Value.QuantizeOrientation(self, turret.Value.LocalOrientation(self));
localOffset = localOffset.Rotate(turretOrientation);
localOffset += Turret.Value.Offset;
localOffset += turret.Value.Offset;
}
return Coords.Value.LocalToWorld(localOffset.Rotate(bodyOrientation));
return coords.Value.LocalToWorld(localOffset.Rotate(bodyOrientation));
}
public WRot MuzzleOrientation(Actor self, Barrel b)
{
var orientation = self.Orientation + WRot.FromYaw(b.Yaw);
if (Turret.Value != null)
orientation += Turret.Value.LocalOrientation(self);
if (turret.Value != null)
orientation += turret.Value.LocalOrientation(self);
return orientation;
}

View File

@@ -34,19 +34,19 @@ namespace OpenRA.Mods.Common.Traits
public class LimitedAmmo : INotifyAttack, IPips, ISync
{
[Sync] int ammo;
LimitedAmmoInfo Info;
LimitedAmmoInfo info;
public LimitedAmmo(LimitedAmmoInfo info)
{
ammo = info.Ammo;
Info = info;
this.info = info;
}
public bool FullAmmo() { return ammo == Info.Ammo; }
public bool FullAmmo() { return ammo == info.Ammo; }
public bool HasAmmo() { return ammo > 0; }
public bool GiveAmmo()
{
if (ammo >= Info.Ammo) return false;
if (ammo >= info.Ammo) return false;
++ammo;
return true;
}
@@ -58,7 +58,7 @@ namespace OpenRA.Mods.Common.Traits
return true;
}
public int ReloadTimePerAmmo() { return Info.ReloadTicks; }
public int ReloadTimePerAmmo() { return info.ReloadTicks; }
public void Attacking(Actor self, Target target, Armament a, Barrel barrel) { TakeAmmo(); }
@@ -66,10 +66,10 @@ namespace OpenRA.Mods.Common.Traits
public IEnumerable<PipType> GetPips(Actor self)
{
var pips = Info.PipCount != 0 ? Info.PipCount : Info.Ammo;
var pips = info.PipCount != 0 ? info.PipCount : info.Ammo;
return Enumerable.Range(0, pips).Select(i =>
(ammo * pips) / Info.Ammo > i ?
Info.PipType : Info.PipTypeEmpty);
(ammo * pips) / info.Ammo > i ?
info.PipType : info.PipTypeEmpty);
}
}
}

View File

@@ -159,7 +159,7 @@ namespace OpenRA.Mods.Common.Traits
if (otherMobile == null) return false;
// Sign of dot-product indicates (roughly) if vectors are facing in same or opposite directions:
var dp = CVec.Dot(selfMobile.toCell - self.Location, otherMobile.toCell - other.Location);
var dp = CVec.Dot(selfMobile.ToCell - self.Location, otherMobile.ToCell - other.Location);
if (dp <= 0) return false;
return true;
@@ -249,60 +249,60 @@ namespace OpenRA.Mods.Common.Traits
public class Mobile : IIssueOrder, IResolveOrder, IOrderVoice, IPositionable, IMove, IFacing, ISync, INotifyAddedToWorld, INotifyRemovedFromWorld, INotifyBlockingMove
{
public readonly Actor self;
const int AverageTicksBeforePathing = 5;
const int SpreadTicksBeforePathing = 5;
internal int TicksBeforePathing = 0;
readonly Actor self;
public readonly MobileInfo Info;
public bool IsMoving { get; set; }
int __facing;
CPos __fromCell, __toCell;
public SubCell fromSubCell, toSubCell;
int facing;
CPos fromCell, toCell;
public SubCell FromSubCell, ToSubCell;
[Sync] public int Facing
{
get { return __facing; }
set { __facing = value; }
get { return facing; }
set { facing = value; }
}
public int ROT { get { return Info.ROT; } }
[Sync] public WPos CenterPosition { get; private set; }
[Sync] public CPos fromCell { get { return __fromCell; } }
[Sync] public CPos toCell { get { return __toCell; } }
[Sync] public CPos FromCell { get { return fromCell; } }
[Sync] public CPos ToCell { get { return toCell; } }
[Sync] public int PathHash; // written by Move.EvalPath, to temporarily debug this crap.
public void SetLocation(CPos from, SubCell fromSub, CPos to, SubCell toSub)
{
if (fromCell == from && toCell == to && fromSubCell == fromSub && toSubCell == toSub)
if (FromCell == from && ToCell == to && FromSubCell == fromSub && ToSubCell == toSub)
return;
RemoveInfluence();
__fromCell = from;
__toCell = to;
fromSubCell = fromSub;
toSubCell = toSub;
fromCell = from;
toCell = to;
FromSubCell = fromSub;
ToSubCell = toSub;
AddInfluence();
}
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;
self = init.self;
Info = info;
toSubCell = fromSubCell = info.SharesCell ? init.world.Map.DefaultSubCell : SubCell.FullCell;
ToSubCell = FromSubCell = info.SharesCell ? init.world.Map.DefaultSubCell : SubCell.FullCell;
if (init.Contains<SubCellInit>())
{
this.fromSubCell = this.toSubCell = init.Get<SubCellInit, SubCell>();
this.FromSubCell = this.ToSubCell = init.Get<SubCellInit, SubCell>();
}
if (init.Contains<LocationInit>())
{
this.__fromCell = this.__toCell = init.Get<LocationInit, CPos>();
SetVisualPosition(self, init.world.Map.CenterOfSubCell(fromCell, fromSubCell));
this.fromCell = this.toCell = init.Get<LocationInit, CPos>();
SetVisualPosition(self, init.world.Map.CenterOfSubCell(FromCell, FromSubCell));
}
this.Facing = init.Contains<FacingInit>() ? init.Get<FacingInit, int>() : info.InitialFacing;
@@ -318,7 +318,7 @@ namespace OpenRA.Mods.Common.Traits
{
// Try same sub-cell
if (preferred == SubCell.Any)
preferred = fromSubCell;
preferred = FromSubCell;
// Fix sub-cell assignment
if (Info.SharesCell)
@@ -346,7 +346,7 @@ namespace OpenRA.Mods.Common.Traits
public void SetPosition(Actor self, WPos pos)
{
var cell = self.World.Map.CellContaining(pos);
SetLocation(cell, fromSubCell, cell, fromSubCell);
SetLocation(cell, FromSubCell, cell, FromSubCell);
SetVisualPosition(self, pos);
FinishedMoving(self);
}
@@ -435,7 +435,7 @@ namespace OpenRA.Mods.Common.Traits
if (!queued) self.CancelActivity();
ticksBeforePathing = avgTicksBeforePathing + self.World.SharedRandom.Next(-spreadTicksBeforePathing, spreadTicksBeforePathing);
TicksBeforePathing = AverageTicksBeforePathing + self.World.SharedRandom.Next(-SpreadTicksBeforePathing, SpreadTicksBeforePathing);
self.QueueActivity(new Move(self, currentLocation, 8));
@@ -481,21 +481,21 @@ namespace OpenRA.Mods.Common.Traits
}
}
public CPos TopLeft { get { return toCell; } }
public CPos TopLeft { get { return ToCell; } }
public IEnumerable<Pair<CPos, SubCell>> OccupiedCells()
{
if (fromCell == toCell)
return new[] { Pair.New(fromCell, fromSubCell) };
if (CanEnterCell(toCell))
return new[] { Pair.New(toCell, toSubCell) };
return new[] { Pair.New(fromCell, fromSubCell), Pair.New(toCell, toSubCell) };
if (FromCell == ToCell)
return new[] { Pair.New(FromCell, FromSubCell) };
if (CanEnterCell(ToCell))
return new[] { Pair.New(ToCell, ToSubCell) };
return new[] { Pair.New(FromCell, FromSubCell), Pair.New(ToCell, ToSubCell) };
}
public bool IsLeavingCell(CPos location, SubCell subCell = SubCell.Any)
{
return toCell != location && __fromCell == location
&& (subCell == SubCell.Any || fromSubCell == subCell || subCell == SubCell.FullCell || fromSubCell == SubCell.FullCell);
return ToCell != location && fromCell == location
&& (subCell == SubCell.Any || FromSubCell == subCell || subCell == SubCell.FullCell || FromSubCell == SubCell.FullCell);
}
public SubCell GetAvailableSubCell(CPos a, SubCell preferredSubCell = SubCell.Any, Actor ignoreActor = null, bool checkTransientActors = true)
@@ -510,7 +510,7 @@ namespace OpenRA.Mods.Common.Traits
public void EnteringCell(Actor self)
{
var crushables = self.World.ActorMap.GetUnitsAt(toCell).Where(a => a != self)
var crushables = self.World.ActorMap.GetUnitsAt(ToCell).Where(a => a != self)
.SelectMany(a => a.TraitsImplementing<ICrushable>().Where(b => b.CrushableBy(Info.Crushes, self.Owner)));
foreach (var crushable in crushables)
crushable.WarnCrush(self);
@@ -518,7 +518,7 @@ namespace OpenRA.Mods.Common.Traits
public void FinishedMoving(Actor self)
{
var crushables = self.World.ActorMap.GetUnitsAt(toCell).Where(a => a != self)
var crushables = self.World.ActorMap.GetUnitsAt(ToCell).Where(a => a != self)
.SelectMany(a => a.TraitsImplementing<ICrushable>().Where(c => c.CrushableBy(Info.Crushes, self.Owner)));
foreach (var crushable in crushables)
crushable.OnCrush(self);
@@ -571,11 +571,11 @@ namespace OpenRA.Mods.Common.Traits
for (var i = -1; i < 2; i++)
for (var j = -1; j < 2; j++)
{
var p = toCell + new CVec(i, j);
var p = ToCell + new CVec(i, j);
if (CanEnterCell(p))
availCells.Add(p);
else
if (p != nudger.Location && p != toCell)
if (p != nudger.Location && p != ToCell)
notStupidCells.Add(p);
}

View File

@@ -28,13 +28,13 @@ namespace OpenRA.Mods.Common.Traits
public class Reloads : ITick
{
[Sync] int remainingTicks;
ReloadsInfo Info;
ReloadsInfo info;
LimitedAmmo la;
int previousAmmo;
public Reloads(Actor self, ReloadsInfo info)
{
Info = info;
this.info = info;
remainingTicks = info.Period;
la = self.Trait<LimitedAmmo>();
previousAmmo = la.GetAmmoCount();
@@ -44,18 +44,18 @@ namespace OpenRA.Mods.Common.Traits
{
if (!la.FullAmmo() && --remainingTicks == 0)
{
remainingTicks = Info.Period;
remainingTicks = info.Period;
for (var i = 0; i < Info.Count; i++)
for (var i = 0; i < info.Count; i++)
la.GiveAmmo();
previousAmmo = la.GetAmmoCount();
}
// Resets the tick counter if ammo was fired.
if (Info.ResetOnFire && la.GetAmmoCount() < previousAmmo)
if (info.ResetOnFire && la.GetAmmoCount() < previousAmmo)
{
remainingTicks = Info.Period;
remainingTicks = info.Period;
previousAmmo = la.GetAmmoCount();
}
}

View File

@@ -28,33 +28,33 @@ namespace OpenRA.Mods.Common.Traits
public class PathFinder
{
const int MaxPathAge = 50; /* x 40ms ticks */
static readonly List<CPos> emptyPath = new List<CPos>(0);
static readonly List<CPos> EmptyPath = new List<CPos>(0);
readonly World world;
public PathFinder(World world) { this.world = world; }
class CachedPath
{
public CPos from;
public CPos to;
public List<CPos> result;
public int tick;
public Actor actor;
public CPos From;
public CPos To;
public List<CPos> Result;
public int Tick;
public Actor Actor;
}
List<CachedPath> CachedPaths = new List<CachedPath>();
List<CachedPath> cachedPaths = new List<CachedPath>();
public List<CPos> FindUnitPath(CPos from, CPos target, Actor self)
{
using (new PerfSample("Pathfinder"))
{
var cached = CachedPaths.FirstOrDefault(p => p.from == from && p.to == target && p.actor == self);
var cached = cachedPaths.FirstOrDefault(p => p.From == from && p.To == target && p.Actor == self);
if (cached != null)
{
Log.Write("debug", "Actor {0} asked for a path from {1} tick(s) ago", self.ActorID, world.WorldTick - cached.tick);
if (world.WorldTick - cached.tick > MaxPathAge)
CachedPaths.Remove(cached);
return new List<CPos>(cached.result);
Log.Write("debug", "Actor {0} asked for a path from {1} tick(s) ago", self.ActorID, world.WorldTick - cached.Tick);
if (world.WorldTick - cached.Tick > MaxPathAge)
cachedPaths.Remove(cached);
return new List<CPos>(cached.Result);
}
var mi = self.Info.Traits.Get<MobileInfo>();
@@ -65,7 +65,7 @@ namespace OpenRA.Mods.Common.Traits
{
var passable = mi.GetMovementClass(world.TileSet);
if (!domainIndex.IsPassable(from, target, (uint)passable))
return emptyPath;
return EmptyPath;
}
var fromPoint = PathSearch.FromPoint(world, mi, self, target, from, true)
@@ -79,8 +79,8 @@ namespace OpenRA.Mods.Common.Traits
CheckSanePath2(pb, from, target);
CachedPaths.RemoveAll(p => world.WorldTick - p.tick > MaxPathAge);
CachedPaths.Add(new CachedPath { from = from, to = target, actor = self, result = pb, tick = world.WorldTick });
cachedPaths.RemoveAll(p => world.WorldTick - p.Tick > MaxPathAge);
cachedPaths.Add(new CachedPath { From = from, To = target, Actor = self, Result = pb, Tick = world.WorldTick });
return new List<CPos>(pb);
}
}
@@ -110,7 +110,7 @@ namespace OpenRA.Mods.Common.Traits
var passable = mi.GetMovementClass(world.TileSet);
tilesInRange = new List<CPos>(tilesInRange.Where(t => domainIndex.IsPassable(src, t, (uint)passable)));
if (!tilesInRange.Any())
return emptyPath;
return EmptyPath;
}
var path = FindBidiPath(
@@ -148,7 +148,7 @@ namespace OpenRA.Mods.Common.Traits
}
// no path exists
return emptyPath;
return EmptyPath;
}
}
@@ -212,7 +212,7 @@ namespace OpenRA.Mods.Common.Traits
return path;
}
return emptyPath;
return EmptyPath;
}
}

View File

@@ -143,7 +143,7 @@ namespace OpenRA.Mods.Common.Traits
// For horizontal/vertical directions, the set is the three cells 'ahead'. For diagonal directions, the set
// is the three cells ahead, plus the two cells to the side, which we cannot exclude without knowing if
// the cell directly between them and our parent is passable.
static CVec[][] DirectedNeighbors = {
static CVec[][] directedNeighbors = {
new CVec[] { new CVec(-1, -1), new CVec(0, -1), new CVec(1, -1), new CVec(-1, 0), new CVec(-1, 1) },
new CVec[] { new CVec(-1, -1), new CVec(0, -1), new CVec(1, -1) },
new CVec[] { new CVec(-1, -1), new CVec(0, -1), new CVec(1, -1), new CVec(1, 0), new CVec(1, 1) },
@@ -161,7 +161,7 @@ namespace OpenRA.Mods.Common.Traits
var dy = p.Y - prev.Y;
var index = dy * 3 + dx + 4;
return DirectedNeighbors[index];
return directedNeighbors[index];
}
public CPos Expand(World world)
@@ -285,7 +285,7 @@ namespace OpenRA.Mods.Common.Traits
}
static readonly Queue<CellLayer<CellInfo>> CellInfoPool = new Queue<CellLayer<CellInfo>>();
static readonly object defaultCellInfoLayerSync = new object();
static readonly object DefaultCellInfoLayerSync = new object();
static CellLayer<CellInfo> defaultCellInfoLayer;
static CellLayer<CellInfo> GetFromPool()
@@ -325,7 +325,7 @@ namespace OpenRA.Mods.Common.Traits
if (result == null)
result = new CellLayer<CellInfo>(map);
lock (defaultCellInfoLayerSync)
lock (DefaultCellInfoLayerSync)
{
if (defaultCellInfoLayer == null ||
defaultCellInfoLayer.Size != mapSize ||