From d395c5e05dd36af326223fe7084c98f2a5cd097f Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Fri, 7 Jan 2011 19:56:35 +1300 Subject: [PATCH] Remove dead helicopter instability code, and some unnecessary fp. --- OpenRA.Mods.RA/Air/Aircraft.cs | 2 +- OpenRA.Mods.RA/Air/Helicopter.cs | 42 +++++++++----------------------- 2 files changed, 13 insertions(+), 31 deletions(-) diff --git a/OpenRA.Mods.RA/Air/Aircraft.cs b/OpenRA.Mods.RA/Air/Aircraft.cs index 0ad746a0ad..2faa4047b0 100755 --- a/OpenRA.Mods.RA/Air/Aircraft.cs +++ b/OpenRA.Mods.RA/Air/Aircraft.cs @@ -112,7 +112,7 @@ namespace OpenRA.Mods.RA.Air return Info.LandableTerrainTypes.Contains(type); } - static readonly int2[] SubPxVector = + public static readonly int2[] SubPxVector = { new int2( 0, 1024 ), new int2( 25, 1023 ), diff --git a/OpenRA.Mods.RA/Air/Helicopter.cs b/OpenRA.Mods.RA/Air/Helicopter.cs index a90f08246d..4a8d140ba2 100755 --- a/OpenRA.Mods.RA/Air/Helicopter.cs +++ b/OpenRA.Mods.RA/Air/Helicopter.cs @@ -22,8 +22,6 @@ namespace OpenRA.Mods.RA.Air { class HelicopterInfo : AircraftInfo { - public readonly int InstabilityMagnitude = 1024; - public readonly int InstabilityTicks = 5; public readonly int IdealSeparation = 40; public readonly bool LandWhenIdle = true; @@ -122,7 +120,6 @@ namespace OpenRA.Mods.RA.Air } } - int offsetTicks = 0; public void Tick(Actor self) { var aircraft = self.Trait(); @@ -133,44 +130,29 @@ namespace OpenRA.Mods.RA.Air .Where(a => a.HasTrait()); var f = otherHelis - .Select(h => self.Trait().GetRepulseForce(self, h, h.Trait())) - .Aggregate(float2.Zero, (a, b) => a + b); + .Select(h => GetRepulseForce(self, h, h.Trait())) + .Aggregate(int2.Zero, (a, b) => a + b); - RepulsionFacing = Util.GetFacing( f, -1 ); + int RepulsionFacing = Util.GetFacing( f.ToFloat2(), -1 ); if( RepulsionFacing != -1 ) aircraft.TickMove( 1024 * aircraft.MovementSpeed, RepulsionFacing ); - - if (--offsetTicks <= 0) - { - InstabilityFacing = Util.GetFacing( self.World.SharedRandom.Gauss2D( 5 ), -1 ); - if( InstabilityFacing != -1 ) - aircraft.TickMove( Info.InstabilityMagnitude, InstabilityFacing ); - - aircraft.Altitude += (int)(Info.InstabilityMagnitude / 1024 * self.World.SharedRandom.Gauss1D(5)); - offsetTicks = Info.InstabilityTicks; - } } - [Sync] - int RepulsionFacing; - [Sync] - int InstabilityFacing; - - const float Epsilon = .5f; - public float2 GetRepulseForce(Actor self, Actor h, Aircraft hAir) + // Returns an int2 in subPx units + public int2 GetRepulseForce(Actor self, Actor h, Aircraft hAir) { if (self == h) - return float2.Zero; + return int2.Zero; if( hAir.Altitude < Altitude ) - return float2.Zero; - var d = self.CenterLocation - h.CenterLocation; + return int2.Zero; + var d = (self.CenterLocation - h.CenterLocation).ToInt2(); if (d.Length > Info.IdealSeparation) - return float2.Zero; + return int2.Zero; - if (d.LengthSquared < Epsilon) - return float2.FromAngle((float)self.World.SharedRandom.NextDouble() * 3.14f); - return (5 / d.LengthSquared) * d; + if (d.LengthSquared < 1) + return Aircraft.SubPxVector[self.World.SharedRandom.Next(255)]; + return (5120 / d.LengthSquared) * d; } } }