use a getter for Aircraft.Location

This commit is contained in:
Bob
2010-10-08 19:54:06 +13:00
committed by Chris Forbes
parent 011a20e8b4
commit eca098b0b4
5 changed files with 4 additions and 15 deletions

View File

@@ -60,7 +60,6 @@ namespace OpenRA.Mods.RA.Activities
var speed = .2f * aircraft.MovementSpeedForCell(self, self.Location);
var angle = aircraft.Facing / 128f * Math.PI;
aircraft.center += speed * -float2.FromAngle((float)angle);
aircraft.Location = Util.CellContaining(self.CenterLocation);
aircraft.Altitude += Math.Sign(desiredAltitude - aircraft.Altitude);
}
}

View File

@@ -39,7 +39,6 @@ namespace OpenRA.Mods.RA.Activities
if (float2.WithinEpsilon(float2.Zero, dist, 2))
{
aircraft.center = Dest;
aircraft.Location = Util.CellContaining(self.CenterLocation);
return NextActivity;
}
@@ -49,7 +48,6 @@ namespace OpenRA.Mods.RA.Activities
var rawSpeed = .2f * aircraft.MovementSpeedForCell(self, self.Location);
aircraft.center += (rawSpeed / dist.Length) * dist;
aircraft.Location = Util.CellContaining(self.CenterLocation);
return this;
}

View File

@@ -42,7 +42,6 @@ namespace OpenRA.Mods.RA.Activities
var angle = aircraft.Facing / 128f * Math.PI;
aircraft.center += speed * -float2.FromAngle((float)angle);
aircraft.Location = Util.CellContaining(self.CenterLocation);
return this;
}

View File

@@ -32,7 +32,7 @@ namespace OpenRA.Mods.RA
{
protected readonly Actor self;
[Sync]
public int2 Location;
public int2 Location { get { return Util.CellContaining( center.ToInt2() ); } }
[Sync]
public int Facing { get; set; }
[Sync]
@@ -46,10 +46,7 @@ namespace OpenRA.Mods.RA
{
this.self = init.self;
if( init.Contains<LocationInit>() )
{
this.Location = init.Get<LocationInit, int2>();
this.center = Util.CenterOfCell( Location );
}
this.center = Util.CenterOfCell( init.Get<LocationInit, int2>() );
this.Facing = init.Contains<FacingInit>() ? init.Get<FacingInit,int>() : info.InitialFacing;
this.Altitude = init.Contains<AltitudeInit>() ? init.Get<AltitudeInit,int>() : 0;
@@ -67,13 +64,11 @@ namespace OpenRA.Mods.RA
public void SetPosition(Actor self, int2 cell)
{
Location = cell;
center = Util.CenterOfCell(cell);
SetPxPosition( self, Util.CenterOfCell( cell ) );
}
public void SetPxPosition( Actor self, int2 px )
{
Location = Util.CellContaining( px );
center = px;
}

View File

@@ -147,10 +147,8 @@ namespace OpenRA.Mods.RA
aircraft.Altitude += (int)(Info.InstabilityMagnitude * self.World.SharedRandom.Gauss1D(5));
offsetTicks = Info.InstabilityTicks;
}
Location = Util.CellContaining(self.CenterLocation);
}
const float Epsilon = .5f;
public float2 GetRepulseForce(Actor self, Actor h)
{