Skip to content

Commit

Permalink
remove unnecessary parameters from Aircraft.MovementSpeedForCell, and…
Browse files Browse the repository at this point in the history
… rename to MovementSpeed
  • Loading branch information
ytinasni authored and chrisforbes committed Nov 5, 2010
1 parent 8129d5d commit 5c0cd50
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 14 deletions.
2 changes: 1 addition & 1 deletion OpenRA.Mods.RA/Activities/Fly.cs
Expand Up @@ -57,7 +57,7 @@ public static class FlyUtil
public static void Fly(Actor self, int desiredAltitude )
{
var aircraft = self.Trait<Aircraft>();
var speed = .2f * aircraft.MovementSpeedForCell(self, self.Location);
var speed = .2f * aircraft.MovementSpeed;
var angle = aircraft.Facing / 128f * Math.PI;
aircraft.center += speed * -float2.FromAngle((float)angle);
aircraft.Altitude += Math.Sign(desiredAltitude - aircraft.Altitude);
Expand Down
2 changes: 1 addition & 1 deletion OpenRA.Mods.RA/Activities/HeliAttack.cs
Expand Up @@ -45,7 +45,7 @@ public override IActivity Tick(Actor self)

var desiredFacing = Util.GetFacing(dist, aircraft.Facing);
aircraft.Facing = Util.TickFacing(aircraft.Facing, desiredFacing, aircraft.ROT);
var rawSpeed = .2f * aircraft.MovementSpeedForCell(self, self.Location);
var rawSpeed = .2f * aircraft.MovementSpeed;

if (!float2.WithinEpsilon(float2.Zero, dist, range * Game.CellSize))
aircraft.center += (rawSpeed / dist.Length) * dist;
Expand Down
2 changes: 1 addition & 1 deletion OpenRA.Mods.RA/Activities/HeliFly.cs
Expand Up @@ -46,7 +46,7 @@ public override IActivity Tick(Actor self)
aircraft.Facing = Util.TickFacing(aircraft.Facing, desiredFacing,
aircraft.ROT);

var rawSpeed = .2f * aircraft.MovementSpeedForCell(self, self.Location);
var rawSpeed = .2f * aircraft.MovementSpeed;
aircraft.center += (rawSpeed / dist.Length) * dist;

return this;
Expand Down
2 changes: 1 addition & 1 deletion OpenRA.Mods.RA/Activities/Land.cs
Expand Up @@ -38,7 +38,7 @@ public override IActivity Tick(Actor self)

var desiredFacing = Util.GetFacing(d, aircraft.Facing);
aircraft.Facing = Util.TickFacing(aircraft.Facing, desiredFacing, aircraft.ROT);
var speed = .2f * aircraft.MovementSpeedForCell(self, self.Location);
var speed = .2f * aircraft.MovementSpeed;
var angle = aircraft.Facing / 128f * Math.PI;

aircraft.center += speed * -float2.FromAngle((float)angle);
Expand Down
2 changes: 1 addition & 1 deletion OpenRA.Mods.RA/Activities/ReturnToBase.cs
Expand Up @@ -48,7 +48,7 @@ void Calculate(Actor self)
var landPos = dest.CenterLocation;
var aircraft = self.Trait<Aircraft>();

var speed = .2f * aircraft.MovementSpeedForCell(self, self.Location);
var speed = .2f * aircraft.MovementSpeed;

var approachStart = landPos - new float2(aircraft.Altitude * speed, 0);
var turnRadius = (128f / self.Info.Traits.Get<AircraftInfo>().ROT) * speed / (float)Math.PI;
Expand Down
19 changes: 11 additions & 8 deletions OpenRA.Mods.RA/Aircraft.cs
Expand Up @@ -80,14 +80,17 @@ public bool AircraftCanEnter(Actor a)
}

public bool CanEnterCell(int2 location) { return true; }

public float MovementSpeedForCell(Actor self, int2 cell)
{
var modifier = self
.TraitsImplementing<ISpeedModifier>()
.Select(t => t.GetSpeedModifier())
.Product();
return Info.Speed * modifier;

public float MovementSpeed
{
get
{
var modifier = self
.TraitsImplementing<ISpeedModifier>()
.Select( t => t.GetSpeedModifier() )
.Product();
return Info.Speed * modifier;
}
}

int2[] noCells = new int2[] { };
Expand Down
2 changes: 1 addition & 1 deletion OpenRA.Mods.RA/Helicopter.cs
Expand Up @@ -133,7 +133,7 @@ public void Tick(Actor self)
if (aircraft.Altitude <= 0)
return;

var rawSpeed = .2f * aircraft.MovementSpeedForCell(self, self.Location);
var rawSpeed = .2f * aircraft.MovementSpeed;
var otherHelis = self.World.FindUnitsInCircle(self.CenterLocation, Info.IdealSeparation)
.Where(a => a.HasTrait<Helicopter>());

Expand Down

0 comments on commit 5c0cd50

Please sign in to comment.