diff --git a/OpenRA.Mods.Common/Activities/Move/Move.cs b/OpenRA.Mods.Common/Activities/Move/Move.cs index 8c927dfa88..4cfaf7098d 100644 --- a/OpenRA.Mods.Common/Activities/Move/Move.cs +++ b/OpenRA.Mods.Common/Activities/Move/Move.cs @@ -46,7 +46,7 @@ namespace OpenRA.Mods.Common.Activities getPath = () => self.World.WorldActor.Trait().FindPath( - PathSearch.FromPoint(self.World, mobile.Info, self, mobile.toCell, destination, false) + PathSearch.FromPoint(self.World, mobile.Info, self, mobile.ToCell, destination, false) .WithoutLaneBias()); this.destination = destination; this.nearEnough = WRange.Zero; @@ -62,7 +62,7 @@ namespace OpenRA.Mods.Common.Activities moveDisablers = self.TraitsImplementing(); getPath = () => self.World.WorldActor.Trait() - .FindUnitPath(mobile.toCell, destination, self); + .FindUnitPath(mobile.ToCell, destination, self); this.destination = destination; this.nearEnough = nearEnough; } @@ -73,7 +73,7 @@ namespace OpenRA.Mods.Common.Activities moveDisablers = self.TraitsImplementing(); getPath = () => self.World.WorldActor.Trait() - .FindUnitPathToRange(mobile.fromCell, subCell, self.World.Map.CenterOfSubCell(destination, subCell), nearEnough, self); + .FindUnitPathToRange(mobile.FromCell, subCell, self.World.Map.CenterOfSubCell(destination, subCell), nearEnough, self); this.destination = destination; this.nearEnough = nearEnough; } @@ -85,7 +85,7 @@ namespace OpenRA.Mods.Common.Activities getPath = () => self.World.WorldActor.Trait().FindPath( - PathSearch.FromPoint(self.World, mobile.Info, self, mobile.toCell, destination, false) + PathSearch.FromPoint(self.World, mobile.Info, self, mobile.ToCell, destination, false) .WithIgnoredActor(ignoredActor)); this.destination = destination; @@ -104,7 +104,7 @@ namespace OpenRA.Mods.Common.Activities return NoPath; return self.World.WorldActor.Trait().FindUnitPathToRange( - mobile.toCell, mobile.toSubCell, target.CenterPosition, range, self); + mobile.ToCell, mobile.ToSubCell, target.CenterPosition, range, self); }; destination = null; @@ -134,7 +134,7 @@ namespace OpenRA.Mods.Common.Activities List EvalPath(Actor self, Mobile mobile) { - var path = getPath().TakeWhile(a => a != mobile.toCell).ToList(); + var path = getPath().TakeWhile(a => a != mobile.ToCell).ToList(); mobile.PathHash = HashList(path); return path; } @@ -144,14 +144,14 @@ namespace OpenRA.Mods.Common.Activities if (moveDisablers.Any(d => d.MoveDisabled(self))) return this; - if (destination == mobile.toCell) + if (destination == mobile.ToCell) return NextActivity; if (path == null) { - if (mobile.ticksBeforePathing > 0) + if (mobile.TicksBeforePathing > 0) { - --mobile.ticksBeforePathing; + --mobile.TicksBeforePathing; return this; } @@ -161,7 +161,7 @@ namespace OpenRA.Mods.Common.Activities if (path.Count == 0) { - destination = mobile.toCell; + destination = mobile.ToCell; return this; } @@ -171,7 +171,7 @@ namespace OpenRA.Mods.Common.Activities if (nextCell == null) return this; - var firstFacing = self.World.Map.FacingBetween(mobile.fromCell, nextCell.Value.First, mobile.Facing); + var firstFacing = self.World.Map.FacingBetween(mobile.FromCell, nextCell.Value.First, mobile.Facing); if (firstFacing != mobile.Facing) { path.Add(nextCell.Value.First); @@ -179,11 +179,11 @@ namespace OpenRA.Mods.Common.Activities } else { - mobile.SetLocation(mobile.fromCell, mobile.fromSubCell, nextCell.Value.First, nextCell.Value.Second); + mobile.SetLocation(mobile.FromCell, mobile.FromSubCell, nextCell.Value.First, nextCell.Value.Second); var move = new MoveFirstHalf( this, - self.World.Map.CenterOfSubCell(mobile.fromCell, mobile.fromSubCell), - Util.BetweenCells(self.World, mobile.fromCell, mobile.toCell) + (self.World.Map.OffsetOfSubCell(mobile.fromSubCell) + self.World.Map.OffsetOfSubCell(mobile.toSubCell)) / 2, + self.World.Map.CenterOfSubCell(mobile.FromCell, mobile.FromSubCell), + Util.BetweenCells(self.World, mobile.FromCell, mobile.ToCell) + (self.World.Map.OffsetOfSubCell(mobile.FromSubCell) + self.World.Map.OffsetOfSubCell(mobile.ToSubCell)) / 2, mobile.Facing, mobile.Facing, 0); @@ -197,7 +197,7 @@ namespace OpenRA.Mods.Common.Activities { if (path.Count == 0) return; - var d = path[path.Count - 1] - mobile.toCell; + var d = path[path.Count - 1] - mobile.ToCell; if (d.LengthSquared > 2) throw new InvalidOperationException("(Move) Sanity check failed"); } @@ -224,7 +224,7 @@ namespace OpenRA.Mods.Common.Activities { // Are we close enough? var cellRange = nearEnough.Range / 1024; - if ((mobile.toCell - destination.Value).LengthSquared <= cellRange * cellRange) + if ((mobile.ToCell - destination.Value).LengthSquared <= cellRange * cellRange) { path.Clear(); return null; @@ -248,9 +248,9 @@ namespace OpenRA.Mods.Common.Activities if (--waitTicksRemaining >= 0) return null; - if (mobile.ticksBeforePathing > 0) + if (mobile.TicksBeforePathing > 0) { - --mobile.ticksBeforePathing; + --mobile.TicksBeforePathing; return null; } @@ -290,42 +290,42 @@ namespace OpenRA.Mods.Common.Activities abstract class MovePart : Activity { - protected readonly Move move; - protected readonly WPos from, to; - protected readonly int fromFacing, toFacing; - protected readonly int moveFractionTotal; + protected readonly Move Move; + protected readonly WPos From, To; + protected readonly int FromFacing, ToFacing; + protected readonly int MoveFractionTotal; protected int moveFraction; public MovePart(Move move, WPos from, WPos to, int fromFacing, int toFacing, int startingFraction) { - this.move = move; - this.from = from; - this.to = to; - this.fromFacing = fromFacing; - this.toFacing = toFacing; - this.moveFraction = startingFraction; - this.moveFractionTotal = (to - from).Length; + Move = move; + From = from; + To = to; + FromFacing = fromFacing; + ToFacing = toFacing; + moveFraction = startingFraction; + MoveFractionTotal = (to - from).Length; } public override void Cancel(Actor self) { - move.Cancel(self); + Move.Cancel(self); base.Cancel(self); } public override void Queue(Activity activity) { - move.Queue(activity); + Move.Queue(activity); } public override Activity Tick(Actor self) { var mobile = self.Trait(); - var ret = InnerTick(self, move.mobile); + var ret = InnerTick(self, Move.mobile); mobile.IsMoving = ret is MovePart; - if (moveFraction > moveFractionTotal) - moveFraction = moveFractionTotal; + if (moveFraction > MoveFractionTotal) + moveFraction = MoveFractionTotal; UpdateCenterLocation(self, mobile); return ret; @@ -333,36 +333,36 @@ namespace OpenRA.Mods.Common.Activities Activity InnerTick(Actor self, Mobile mobile) { - moveFraction += mobile.MovementSpeedForCell(self, mobile.toCell); - if (moveFraction <= moveFractionTotal) + moveFraction += mobile.MovementSpeedForCell(self, mobile.ToCell); + if (moveFraction <= MoveFractionTotal) return this; - var next = OnComplete(self, mobile, move); + var next = OnComplete(self, mobile, Move); if (next != null) return next; - return move; + return Move; } void UpdateCenterLocation(Actor self, Mobile mobile) { // avoid division through zero - if (moveFractionTotal != 0) - mobile.SetVisualPosition(self, WPos.Lerp(from, to, moveFraction, moveFractionTotal)); + if (MoveFractionTotal != 0) + mobile.SetVisualPosition(self, WPos.Lerp(From, To, moveFraction, MoveFractionTotal)); else - mobile.SetVisualPosition(self, to); + mobile.SetVisualPosition(self, To); - if (moveFraction >= moveFractionTotal) - mobile.Facing = toFacing & 0xFF; + if (moveFraction >= MoveFractionTotal) + mobile.Facing = ToFacing & 0xFF; else - mobile.Facing = int2.Lerp(fromFacing, toFacing, moveFraction, moveFractionTotal) & 0xFF; + mobile.Facing = int2.Lerp(FromFacing, ToFacing, moveFraction, MoveFractionTotal) & 0xFF; } protected abstract MovePart OnComplete(Actor self, Mobile mobile, Move parent); public override IEnumerable GetTargets(Actor self) { - return move.GetTargets(self); + return Move.GetTargets(self); } } @@ -373,14 +373,14 @@ namespace OpenRA.Mods.Common.Activities static bool IsTurn(Mobile mobile, CPos nextCell) { - return nextCell - mobile.toCell != - mobile.toCell - mobile.fromCell; + return nextCell - mobile.ToCell != + mobile.ToCell - mobile.FromCell; } protected override MovePart OnComplete(Actor self, Mobile mobile, Move parent) { - var fromSubcellOffset = self.World.Map.OffsetOfSubCell(mobile.fromSubCell); - var toSubcellOffset = self.World.Map.OffsetOfSubCell(mobile.toSubCell); + var fromSubcellOffset = self.World.Map.OffsetOfSubCell(mobile.FromSubCell); + var toSubcellOffset = self.World.Map.OffsetOfSubCell(mobile.ToSubCell); var nextCell = parent.PopPath(self, mobile); if (nextCell != null) @@ -389,15 +389,15 @@ namespace OpenRA.Mods.Common.Activities { var nextSubcellOffset = self.World.Map.OffsetOfSubCell(nextCell.Value.Second); var ret = new MoveFirstHalf( - move, - Util.BetweenCells(self.World, mobile.fromCell, mobile.toCell) + (fromSubcellOffset + toSubcellOffset) / 2, - Util.BetweenCells(self.World, mobile.toCell, nextCell.Value.First) + (toSubcellOffset + nextSubcellOffset) / 2, + Move, + Util.BetweenCells(self.World, mobile.FromCell, mobile.ToCell) + (fromSubcellOffset + toSubcellOffset) / 2, + Util.BetweenCells(self.World, mobile.ToCell, nextCell.Value.First) + (toSubcellOffset + nextSubcellOffset) / 2, mobile.Facing, - Util.GetNearestFacing(mobile.Facing, self.World.Map.FacingBetween(mobile.toCell, nextCell.Value.First, mobile.Facing)), - moveFraction - moveFractionTotal); + Util.GetNearestFacing(mobile.Facing, self.World.Map.FacingBetween(mobile.ToCell, nextCell.Value.First, mobile.Facing)), + moveFraction - MoveFractionTotal); mobile.FinishedMoving(self); - mobile.SetLocation(mobile.toCell, mobile.toSubCell, nextCell.Value.First, nextCell.Value.Second); + mobile.SetLocation(mobile.ToCell, mobile.ToSubCell, nextCell.Value.First, nextCell.Value.Second); return ret; } @@ -405,15 +405,15 @@ namespace OpenRA.Mods.Common.Activities } var ret2 = new MoveSecondHalf( - move, - Util.BetweenCells(self.World, mobile.fromCell, mobile.toCell) + (fromSubcellOffset + toSubcellOffset) / 2, - self.World.Map.CenterOfCell(mobile.toCell) + toSubcellOffset, + Move, + Util.BetweenCells(self.World, mobile.FromCell, mobile.ToCell) + (fromSubcellOffset + toSubcellOffset) / 2, + self.World.Map.CenterOfCell(mobile.ToCell) + toSubcellOffset, mobile.Facing, mobile.Facing, - moveFraction - moveFractionTotal); + moveFraction - MoveFractionTotal); mobile.EnteringCell(self); - mobile.SetLocation(mobile.toCell, mobile.toSubCell, mobile.toCell, mobile.toSubCell); + mobile.SetLocation(mobile.ToCell, mobile.ToSubCell, mobile.ToCell, mobile.ToSubCell); return ret2; } } @@ -425,7 +425,7 @@ namespace OpenRA.Mods.Common.Activities protected override MovePart OnComplete(Actor self, Mobile mobile, Move parent) { - mobile.SetPosition(self, mobile.toCell); + mobile.SetPosition(self, mobile.ToCell); return null; } } diff --git a/OpenRA.Mods.Common/Activities/Move/MoveAdjacentTo.cs b/OpenRA.Mods.Common/Activities/Move/MoveAdjacentTo.cs index 49c976f7de..f84ca05464 100644 --- a/OpenRA.Mods.Common/Activities/Move/MoveAdjacentTo.cs +++ b/OpenRA.Mods.Common/Activities/Move/MoveAdjacentTo.cs @@ -26,14 +26,14 @@ namespace OpenRA.Mods.Common.Activities readonly DomainIndex domainIndex; readonly uint movementClass; - protected Target target { get; private set; } + protected Target Target { get; private set; } protected CPos targetPosition; Activity inner; bool repath; public MoveAdjacentTo(Actor self, Target target) { - this.target = target; + Target = target; mobile = self.Trait(); pathFinder = self.World.WorldActor.Trait(); @@ -58,12 +58,12 @@ namespace OpenRA.Mods.Common.Activities protected virtual IEnumerable CandidateMovementCells(Actor self) { - return Util.AdjacentCells(self.World, target); + return Util.AdjacentCells(self.World, Target); } public override Activity Tick(Actor self) { - var targetIsValid = target.IsValidFor(self); + var targetIsValid = Target.IsValidFor(self); // Inner move order has completed. if (inner == null) @@ -82,7 +82,7 @@ namespace OpenRA.Mods.Common.Activities { // Check if the target has moved var oldTargetPosition = targetPosition; - targetPosition = self.World.Map.CellContaining(target.CenterPosition); + targetPosition = self.World.Map.CellContaining(Target.CenterPosition); var shouldStop = ShouldStop(self, oldTargetPosition); if (shouldStop || (!repath && ShouldRepath(self, oldTargetPosition))) @@ -97,7 +97,7 @@ namespace OpenRA.Mods.Common.Activities else { // Target became invalid. Move to its last known position. - target = Target.FromCell(self.World, targetPosition); + Target = Target.FromCell(self.World, targetPosition); } // Ticks the inner move activity to actually move the actor. diff --git a/OpenRA.Mods.Common/Activities/Move/MoveWithinRange.cs b/OpenRA.Mods.Common/Activities/Move/MoveWithinRange.cs index e01f335063..d012208be3 100644 --- a/OpenRA.Mods.Common/Activities/Move/MoveWithinRange.cs +++ b/OpenRA.Mods.Common/Activities/Move/MoveWithinRange.cs @@ -33,13 +33,13 @@ namespace OpenRA.Mods.Common.Activities // We are now in range. Don't move any further! // HACK: This works around the pathfinder not returning the shortest path var cp = self.CenterPosition; - return target.IsInRange(cp, maxRange) && !target.IsInRange(cp, minRange); + return Target.IsInRange(cp, maxRange) && !Target.IsInRange(cp, minRange); } protected override bool ShouldRepath(Actor self, CPos oldTargetPosition) { var cp = self.CenterPosition; - return targetPosition != oldTargetPosition && (!target.IsInRange(cp, maxRange) || target.IsInRange(cp, minRange)); + return targetPosition != oldTargetPosition && (!Target.IsInRange(cp, maxRange) || Target.IsInRange(cp, minRange)); } protected override IEnumerable CandidateMovementCells(Actor self) @@ -50,7 +50,7 @@ namespace OpenRA.Mods.Common.Activities var outerSq = maxRange.Range * maxRange.Range; var innerSq = minRange.Range * minRange.Range; - var center = target.CenterPosition; + var center = Target.CenterPosition; return map.FindTilesInAnnulus(targetPosition, minCells + 1, maxCells).Where(c => { diff --git a/OpenRA.Mods.Common/Traits/Armament.cs b/OpenRA.Mods.Common/Traits/Armament.cs index 3da3069d54..a2b5902879 100644 --- a/OpenRA.Mods.Common/Traits/Armament.cs +++ b/OpenRA.Mods.Common/Traits/Armament.cs @@ -61,9 +61,9 @@ namespace OpenRA.Mods.Common.Traits public readonly WeaponInfo Weapon; public readonly Barrel[] Barrels; - public readonly Actor self; - Lazy Turret; - Lazy Coords; + readonly Actor self; + Lazy turret; + Lazy coords; Lazy limitedAmmo; List> delayedActions = new List>(); @@ -77,8 +77,8 @@ namespace OpenRA.Mods.Common.Traits this.self = self; // We can't resolve these until runtime - Turret = Exts.Lazy(() => self.TraitsImplementing().FirstOrDefault(t => t.Name == info.Turret)); - Coords = Exts.Lazy(() => self.Trait()); + turret = Exts.Lazy(() => self.TraitsImplementing().FirstOrDefault(t => t.Name == info.Turret)); + coords = Exts.Lazy(() => self.Trait()); limitedAmmo = Exts.Lazy(() => self.TraitOrDefault()); 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; } diff --git a/OpenRA.Mods.Common/Traits/LimitedAmmo.cs b/OpenRA.Mods.Common/Traits/LimitedAmmo.cs index 5ebdf7b012..a398c85c8b 100644 --- a/OpenRA.Mods.Common/Traits/LimitedAmmo.cs +++ b/OpenRA.Mods.Common/Traits/LimitedAmmo.cs @@ -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 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); } } } diff --git a/OpenRA.Mods.Common/Traits/Mobile.cs b/OpenRA.Mods.Common/Traits/Mobile.cs index 14165f4437..91e888e339 100644 --- a/OpenRA.Mods.Common/Traits/Mobile.cs +++ b/OpenRA.Mods.Common/Traits/Mobile.cs @@ -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()) { - this.fromSubCell = this.toSubCell = init.Get(); + this.FromSubCell = this.ToSubCell = init.Get(); } if (init.Contains()) { - this.__fromCell = this.__toCell = init.Get(); - SetVisualPosition(self, init.world.Map.CenterOfSubCell(fromCell, fromSubCell)); + this.fromCell = this.toCell = init.Get(); + SetVisualPosition(self, init.world.Map.CenterOfSubCell(FromCell, FromSubCell)); } this.Facing = init.Contains() ? init.Get() : 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> 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().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().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); } diff --git a/OpenRA.Mods.Common/Traits/Reloads.cs b/OpenRA.Mods.Common/Traits/Reloads.cs index 5e218f46a9..93a4edb0c5 100644 --- a/OpenRA.Mods.Common/Traits/Reloads.cs +++ b/OpenRA.Mods.Common/Traits/Reloads.cs @@ -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(); 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(); } } diff --git a/OpenRA.Mods.Common/Traits/World/PathFinder.cs b/OpenRA.Mods.Common/Traits/World/PathFinder.cs index 4e78f8cbc5..2391e2204d 100644 --- a/OpenRA.Mods.Common/Traits/World/PathFinder.cs +++ b/OpenRA.Mods.Common/Traits/World/PathFinder.cs @@ -28,33 +28,33 @@ namespace OpenRA.Mods.Common.Traits public class PathFinder { const int MaxPathAge = 50; /* x 40ms ticks */ - static readonly List emptyPath = new List(0); + static readonly List EmptyPath = new List(0); readonly World world; public PathFinder(World world) { this.world = world; } class CachedPath { - public CPos from; - public CPos to; - public List result; - public int tick; - public Actor actor; + public CPos From; + public CPos To; + public List Result; + public int Tick; + public Actor Actor; } - List CachedPaths = new List(); + List cachedPaths = new List(); public List 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(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(cached.Result); } var mi = self.Info.Traits.Get(); @@ -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(pb); } } @@ -110,7 +110,7 @@ namespace OpenRA.Mods.Common.Traits var passable = mi.GetMovementClass(world.TileSet); tilesInRange = new List(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; } } diff --git a/OpenRA.Mods.Common/Traits/World/PathSearch.cs b/OpenRA.Mods.Common/Traits/World/PathSearch.cs index 323bbf0581..c4bce59a40 100644 --- a/OpenRA.Mods.Common/Traits/World/PathSearch.cs +++ b/OpenRA.Mods.Common/Traits/World/PathSearch.cs @@ -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> CellInfoPool = new Queue>(); - static readonly object defaultCellInfoLayerSync = new object(); + static readonly object DefaultCellInfoLayerSync = new object(); static CellLayer defaultCellInfoLayer; static CellLayer GetFromPool() @@ -325,7 +325,7 @@ namespace OpenRA.Mods.Common.Traits if (result == null) result = new CellLayer(map); - lock (defaultCellInfoLayerSync) + lock (DefaultCellInfoLayerSync) { if (defaultCellInfoLayer == null || defaultCellInfoLayer.Size != mapSize || diff --git a/OpenRA.Mods.D2k/Traits/AttackSwallow.cs b/OpenRA.Mods.D2k/Traits/AttackSwallow.cs index fa52ff69d7..d095978a41 100644 --- a/OpenRA.Mods.D2k/Traits/AttackSwallow.cs +++ b/OpenRA.Mods.D2k/Traits/AttackSwallow.cs @@ -8,8 +8,8 @@ */ #endregion -using OpenRA.Mods.D2k.Activities; using OpenRA.Mods.Common.Traits; +using OpenRA.Mods.D2k.Activities; using OpenRA.Traits; namespace OpenRA.Mods.D2k.Traits diff --git a/OpenRA.Mods.RA/Activities/ExternalCaptureActor.cs b/OpenRA.Mods.RA/Activities/ExternalCaptureActor.cs index 44672f633f..c77a412f23 100644 --- a/OpenRA.Mods.RA/Activities/ExternalCaptureActor.cs +++ b/OpenRA.Mods.RA/Activities/ExternalCaptureActor.cs @@ -39,9 +39,9 @@ namespace OpenRA.Mods.RA.Activities } var mobile = self.Trait(); - var nearest = target.Actor.OccupiesSpace.NearestCellTo(mobile.toCell); + var nearest = target.Actor.OccupiesSpace.NearestCellTo(mobile.ToCell); - if ((nearest - mobile.toCell).LengthSquared > 2) + if ((nearest - mobile.ToCell).LengthSquared > 2) return Util.SequenceActivities(new MoveAdjacentTo(self, target), this); if (!capturable.CaptureInProgress) diff --git a/OpenRA.Mods.RA/Activities/Leap.cs b/OpenRA.Mods.RA/Activities/Leap.cs index 0e46f43954..fa497a43c5 100644 --- a/OpenRA.Mods.RA/Activities/Leap.cs +++ b/OpenRA.Mods.RA/Activities/Leap.cs @@ -38,11 +38,11 @@ namespace OpenRA.Mods.RA.Activities this.weapon = weapon; this.angle = angle; mobile = self.Trait(); - mobile.SetLocation(mobile.fromCell, mobile.fromSubCell, targetMobile.fromCell, targetMobile.fromSubCell); + mobile.SetLocation(mobile.FromCell, mobile.FromSubCell, targetMobile.FromCell, targetMobile.FromSubCell); mobile.IsMoving = true; from = self.CenterPosition; - to = self.World.Map.CenterOfSubCell(targetMobile.fromCell, targetMobile.fromSubCell); + to = self.World.Map.CenterOfSubCell(targetMobile.FromCell, targetMobile.FromSubCell); length = Math.Max((to - from).Length / speed.Range, 1); self.Trait().Attacking(self, Target.FromActor(target)); @@ -59,11 +59,11 @@ namespace OpenRA.Mods.RA.Activities mobile.SetVisualPosition(self, WPos.LerpQuadratic(from, to, angle, ++ticks, length)); if (ticks >= length) { - mobile.SetLocation(mobile.toCell, mobile.toSubCell, mobile.toCell, mobile.toSubCell); + mobile.SetLocation(mobile.ToCell, mobile.ToSubCell, mobile.ToCell, mobile.ToSubCell); mobile.FinishedMoving(self); mobile.IsMoving = false; - self.World.ActorMap.GetUnitsAt(mobile.toCell, mobile.toSubCell) + self.World.ActorMap.GetUnitsAt(mobile.ToCell, mobile.ToSubCell) .Except(new[] { self }).Where(t => weapon.IsValidAgainst(t, self)) .Do(t => t.Kill(self)); diff --git a/OpenRA.Mods.RA/Scripting/Properties/MobileProperties.cs b/OpenRA.Mods.RA/Scripting/Properties/MobileProperties.cs index 473e15d2c8..d3b4f07957 100644 --- a/OpenRA.Mods.RA/Scripting/Properties/MobileProperties.cs +++ b/OpenRA.Mods.RA/Scripting/Properties/MobileProperties.cs @@ -47,7 +47,7 @@ namespace OpenRA.Mods.RA.Scripting [Desc("Moves from outside the world into the cell grid")] public void MoveIntoWorld(CPos cell) { - self.QueueActivity(mobile.MoveIntoWorld(self, cell, mobile.toSubCell)); + self.QueueActivity(mobile.MoveIntoWorld(self, cell, mobile.ToSubCell)); } [ScriptActorPropertyActivity]