add IHasLocation

This commit is contained in:
Bob
2010-10-08 19:10:31 +13:00
committed by Chris Forbes
parent 9c362f7d41
commit 011a20e8b4
31 changed files with 133 additions and 107 deletions

View File

@@ -25,6 +25,7 @@ namespace OpenRA
public static int2 operator -(int2 a, int2 b) { return new int2(a.X - b.X, a.Y - b.Y); }
public static int2 operator *(int a, int2 b) { return new int2(a * b.X, a * b.Y); }
public static int2 operator *(int2 b, int a) { return new int2(a * b.X, a * b.Y); }
public static int2 operator /(int2 a, int b) { return new int2(a.X / b, a.Y / b); }
public static bool operator ==(int2 me, int2 other) { return (me.X == other.X && me.Y == other.Y); }
public static bool operator !=(int2 me, int2 other) { return !(me == other); }
@@ -59,5 +60,15 @@ namespace OpenRA
{
return (uint)((orig & 0xff000000) >> 24) | ((orig & 0x00ff0000) >> 8) | ((orig & 0x0000ff00) << 8) | ((orig & 0x000000ff) << 24);
}
public static int Lerp( int a, int b, int mul, int div )
{
return a + ( b - a ) * mul / div;
}
public static int2 Lerp( int2 a, int2 b, int mul, int div )
{
return a + ( b - a ) * mul / div;
}
}
}

View File

@@ -26,7 +26,8 @@ namespace OpenRA
public readonly World World;
public readonly uint ActorID;
public int2 Location { get { return Trait<IOccupySpace>().TopLeft; } }
public int2 Location { get { return Trait<IOccupySpace>().TopLeft; } }
public float2 CenterLocation { get { return Trait<IHasLocation>().PxPosition; } }
[Sync]
public Player Owner;
@@ -52,9 +53,6 @@ namespace OpenRA
AddTrait(trait.Create(init));
}
if( CenterLocation == float2.Zero && HasTrait<IOccupySpace>() )
CenterLocation = Traits.Util.CenterOfCell(Location);
Size = Lazy.New(() =>
{
var si = Info.Traits.GetOrDefault<SelectableInfo>();
@@ -99,8 +97,6 @@ namespace OpenRA
get { return currentActivity == null || currentActivity is Idle; }
}
public float2 CenterLocation;
OpenRA.FileFormats.Lazy<float2> Size;
public IEnumerable<Renderable> Render()

View File

@@ -16,11 +16,11 @@ namespace OpenRA.Traits.Activities
{
IActivity NextActivity { get; set; }
float2 endLocation;
float2 startLocation;
int2 endLocation;
int2 startLocation;
int length;
public Drag(float2 start, float2 end, int length)
public Drag(int2 start, int2 end, int length)
{
startLocation = start;
endLocation = end;
@@ -29,15 +29,16 @@ namespace OpenRA.Traits.Activities
int ticks = 0;
public IActivity Tick( Actor self )
{
self.CenterLocation = float2.Lerp(startLocation, endLocation, (float)ticks/(length-1));
{
var mobile = self.Trait<Mobile>();
mobile.PxPosition = int2.Lerp(startLocation, endLocation, ticks, length - 1);
if (++ticks >= length)
{
self.Trait<Mobile>().IsMoving = false;
mobile.IsMoving = false;
return NextActivity;
}
self.Trait<Mobile>().IsMoving = true;
mobile.IsMoving = true;
return this;
}

View File

@@ -248,7 +248,7 @@ namespace OpenRA.Traits.Activities
public override IEnumerable<float2> GetCurrentPath()
{
if( path != null )
return Enumerable.Reverse(path).Select( c => Util.CenterOfCell(c) );
return Enumerable.Reverse(path).Select( c => (float2)Util.CenterOfCell(c) );
if( destination != null )
return new float2[] { destination.Value };
return new float2[ 0 ];
@@ -257,12 +257,12 @@ namespace OpenRA.Traits.Activities
abstract class MovePart : IActivity
{
public readonly Move move;
public readonly float2 from, to;
public readonly int2 from, to;
public readonly int fromFacing, toFacing;
public int moveFraction;
public readonly int moveFractionTotal;
public MovePart( Move move, float2 from, float2 to, int fromFacing, int toFacing, int startingFraction )
public MovePart( Move move, int2 from, int2 to, int fromFacing, int toFacing, int startingFraction )
{
this.move = move;
this.from = from;
@@ -270,7 +270,7 @@ namespace OpenRA.Traits.Activities
this.fromFacing = fromFacing;
this.toFacing = toFacing;
this.moveFraction = startingFraction;
this.moveFractionTotal = (int)(( to - from ).Length*3);
this.moveFractionTotal = ( ( to - from ) * 3 ).Length;
}
public void Cancel( Actor self )
@@ -311,14 +311,12 @@ namespace OpenRA.Traits.Activities
void UpdateCenterLocation( Actor self, Mobile mobile )
{
var frac = (float)moveFraction / moveFractionTotal;
self.CenterLocation = float2.Lerp( from, to, frac );
mobile.PxPosition = int2.Lerp( from, to, moveFraction, moveFractionTotal );
if( moveFraction >= moveFractionTotal )
mobile.Facing = toFacing & 0xFF;
else
mobile.Facing = ( fromFacing + ( toFacing - fromFacing ) * moveFraction / moveFractionTotal ) & 0xFF;
mobile.Facing = int2.Lerp( fromFacing, toFacing, moveFraction, moveFractionTotal ) & 0xFF;
}
protected abstract MovePart OnComplete( Actor self, Mobile mobile, Move parent );
@@ -331,7 +329,7 @@ namespace OpenRA.Traits.Activities
class MoveFirstHalf : MovePart
{
public MoveFirstHalf( Move move, float2 from, float2 to, int fromFacing, int toFacing, int startingFraction )
public MoveFirstHalf( Move move, int2 from, int2 to, int fromFacing, int toFacing, int startingFraction )
: base( move, from, to, fromFacing, toFacing, startingFraction )
{
}
@@ -370,14 +368,14 @@ namespace OpenRA.Traits.Activities
class MoveSecondHalf : MovePart
{
public MoveSecondHalf( Move move, float2 from, float2 to, int fromFacing, int toFacing, int startingFraction )
public MoveSecondHalf( Move move, int2 from, int2 to, int fromFacing, int toFacing, int startingFraction )
: base( move, from, to, fromFacing, toFacing, startingFraction )
{
}
protected override MovePart OnComplete( Actor self, Mobile mobile, Move parent )
{
self.CenterLocation = Util.CenterOfCell( mobile.toCell );
mobile.PxPosition = Util.CenterOfCell( mobile.toCell );
mobile.SetLocation( mobile.toCell, mobile.toCell );
mobile.FinishedMoving(self);
return null;

View File

@@ -44,16 +44,16 @@ namespace OpenRA.Traits
public readonly BuildingInfo Info;
[Sync]
readonly int2 topLeft;
readonly PowerManager PlayerPower;
public int2 PxPosition { get { return ( 2 * topLeft + Info.Dimensions ) * Game.CellSize / 2; } }
public Building(ActorInitializer init)
{
this.self = init.self;
this.topLeft = init.Get<LocationInit,int2>();
Info = self.Info.Traits.Get<BuildingInfo>();
self.CenterLocation = Game.CellSize
* ((float2)topLeft + .5f * (float2)Info.Dimensions);
PlayerPower = init.self.Owner.PlayerActor.Trait<PowerManager>();
}

View File

@@ -82,16 +82,11 @@ namespace OpenRA.Traits
public int InitialFacing { get { return Info.InitialFacing; } }
[Sync]
public int2 fromCell
{
get { return __fromCell; }
}
public int2 PxPosition { get; set; }
[Sync]
public int2 toCell
{
get { return __toCell; }
}
public int2 fromCell { get { return __fromCell; } }
[Sync]
public int2 toCell { get { return __toCell; } }
[Sync]
public int PathHash; // written by Move.EvalPath, to temporarily debug this crap.
@@ -117,6 +112,7 @@ namespace OpenRA.Traits
if (init.Contains<LocationInit>())
{
this.__fromCell = this.__toCell = init.Get<LocationInit,int2>();
this.PxPosition = Util.CenterOfCell( fromCell );
AddInfluence();
}
@@ -127,7 +123,14 @@ namespace OpenRA.Traits
public void SetPosition(Actor self, int2 cell)
{
SetLocation( cell, cell );
self.CenterLocation = Util.CenterOfCell(fromCell);
PxPosition = Util.CenterOfCell(fromCell);
}
public void SetPxPosition( Actor self, int2 px )
{
var cell = Util.CellContaining( px );
SetLocation( cell, cell );
PxPosition = px;
}
public IEnumerable<IOrderTargeter> Orders { get { yield return new MoveOrderTargeter( Info ); } }

View File

@@ -70,7 +70,12 @@ namespace OpenRA.Traits
public interface IVisibilityModifier { bool IsVisible(Actor self, Player byPlayer); }
public interface IRadarColorModifier { Color RadarColorOverride(Actor self); }
public interface IOccupySpace
public interface IHasLocation
{
int2 PxPosition { get; }
}
public interface IOccupySpace : IHasLocation
{
int2 TopLeft { get; }
IEnumerable<int2> OccupiedCells();
@@ -104,15 +109,15 @@ namespace OpenRA.Traits
public interface IPips { IEnumerable<PipType> GetPips(Actor self); }
public interface ITags { IEnumerable<TagType> GetTags(); }
public interface ITeleportable /* crap name! */
public interface ITeleportable : IHasLocation /* crap name! */
{
bool CanEnterCell(int2 location);
void SetPosition(Actor self, int2 cell);
void SetPxPosition(Actor self, int2 px);
}
public interface IMove : ITeleportable
{
float MovementSpeedForCell(Actor self, int2 cell);
int Altitude { get; set; }
}
@@ -233,9 +238,10 @@ namespace OpenRA.Traits
public static readonly Target None = new Target();
public bool IsValid { get { return valid && (actor == null || actor.IsInWorld); } }
public float2 CenterLocation { get { return actor != null ? actor.CenterLocation : pos.ToInt2(); } }
public int2 PxPosition { get { return IsActor ? actor.Trait<IHasLocation>().PxPosition : pos.ToInt2(); } }
public float2 CenterLocation { get { return PxPosition; } }
public Actor Actor { get { return actor; } }
public bool IsActor { get { return actor != null; } }
public Actor Actor { get { return IsActor ? actor : null; } }
public bool IsActor { get { return actor != null && !actor.Destroyed; } }
}
}

View File

@@ -82,14 +82,14 @@ namespace OpenRA.Traits
ecc * (cosAngle * v.Y - sinAngle * v.X));
}
public static float2 CenterOfCell(int2 loc)
public static int2 CenterOfCell(int2 loc)
{
return new float2(12, 12) + Game.CellSize * (float2)loc;
return new int2( Game.CellSize / 2, Game.CellSize / 2 ) + Game.CellSize * loc;
}
public static float2 BetweenCells(int2 from, int2 to)
public static int2 BetweenCells(int2 from, int2 to)
{
return 0.5f * (CenterOfCell(from) + CenterOfCell(to));
return int2.Lerp( CenterOfCell( from ), CenterOfCell( to ), 1, 2 );
}
public static int2 AsInt2(this int[] xs) { return new int2(xs[0], xs[1]); }

View File

@@ -45,9 +45,9 @@ namespace OpenRA.Traits
for (var i = 0; i <= bins.GetUpperBound(0); i++)
bins[i, j].Clear();
foreach (var a in self.World.Actors)
foreach (var a in self.World.Queries.WithTrait<IHasLocation>())
{
var bounds = a.GetBounds(true);
var bounds = a.Actor.GetBounds(true);
if (bounds.Right <= Game.CellSize * self.World.Map.XOffset) continue;
if (bounds.Bottom <= Game.CellSize * self.World.Map.YOffset) continue;
@@ -61,7 +61,7 @@ namespace OpenRA.Traits
for (var j = j1; j <= j2; j++)
for (var i = i1; i <= i2; i++)
bins[i, j].Add(a);
bins[i, j].Add(a.Actor);
}
}

View File

@@ -50,7 +50,7 @@ namespace OpenRA.Mods.Cnc
new AltitudeInit( Rules.Info["c17"].Traits.Get<PlaneInfo>().CruiseAltitude ),
});
a.QueueActivity(new Fly(self.Location + new int2(6,0)));
a.QueueActivity(Fly.ToCell(self.Location + new int2(6,0)));
a.QueueActivity(new Land(Target.FromActor(self)));
a.QueueActivity(new CallFunc(() =>
{
@@ -60,7 +60,7 @@ namespace OpenRA.Mods.Cnc
rb.PlayCustomAnimRepeating(self, "idle");
self.World.AddFrameEndTask(ww => DoProduction(self, producee, exit));
}));
a.QueueActivity(new Fly(endPos));
a.QueueActivity(Fly.ToCell(endPos));
a.QueueActivity(new RemoveSelf());
});

View File

@@ -33,7 +33,7 @@ namespace OpenRA.Mods.Cnc
public IEnumerable<Renderable> ModifyRender(Actor self, IEnumerable<Renderable> r)
{
foreach (var c in cargo.Passengers)
c.CenterLocation = self.CenterLocation;
c.Trait<ITeleportable>().SetPxPosition( c, self.Trait<IHasLocation>().PxPosition );
return r.Concat(cargo.Passengers.SelectMany(a => a.Render()));
}

View File

@@ -25,8 +25,8 @@ namespace OpenRA.Mods.Cnc
bool preventDock = false;
public void OnDock(Actor self, Actor harv, DeliverResources dockOrder)
{
float2 startDock = harv.CenterLocation;
float2 endDock = self.CenterLocation + new float2(-15,8);
int2 startDock = harv.Trait<IHasLocation>().PxPosition;
int2 endDock = self.Trait<IHasLocation>().PxPosition + new int2(-15,8);
var harvester = harv.Trait<Harvester>();
harv.QueueActivity( new Turn(112) );

View File

@@ -18,9 +18,11 @@ namespace OpenRA.Mods.RA.Activities
{
public readonly float2 Pos;
public Fly(float2 pos) { Pos = pos; }
public Fly(int2 pos) { Pos = Util.CenterOfCell(pos); }
private Fly( float2 px ) { Pos = px; }
public static Fly ToPx( float2 px ) { return new Fly( px ); }
public static Fly ToCell( int2 pos ) { return new Fly( Util.CenterOfCell( pos ) ); }
public override IActivity Tick(Actor self)
{
var cruiseAltitude = self.Info.Traits.Get<PlaneInfo>().CruiseAltitude;
@@ -57,7 +59,7 @@ namespace OpenRA.Mods.RA.Activities
var aircraft = self.Trait<Aircraft>();
var speed = .2f * aircraft.MovementSpeedForCell(self, self.Location);
var angle = aircraft.Facing / 128f * Math.PI;
self.CenterLocation += speed * -float2.FromAngle((float)angle);
aircraft.center += speed * -float2.FromAngle((float)angle);
aircraft.Location = Util.CellContaining(self.CenterLocation);
aircraft.Altitude += Math.Sign(desiredAltitude - aircraft.Altitude);
}

View File

@@ -29,7 +29,7 @@ namespace OpenRA.Mods.RA.Activities
return NextActivity;
return Util.SequenceActivities(
new Fly(Target.CenterLocation),
Fly.ToPx(Target.CenterLocation),
new FlyTimed(50),
this);
}
@@ -46,7 +46,7 @@ namespace OpenRA.Mods.RA.Activities
if( IsCanceled ) return NextActivity;
return Util.SequenceActivities(
new Fly(Util.CenterOfCell(Target)),
Fly.ToCell(Target),
new FlyTimed(50),
this);
}

View File

@@ -47,7 +47,7 @@ namespace OpenRA.Mods.RA.Activities
var rawSpeed = .2f * aircraft.MovementSpeedForCell(self, self.Location);
if (!float2.WithinEpsilon(float2.Zero, dist, range * Game.CellSize))
self.CenterLocation += (rawSpeed / dist.Length) * dist;
aircraft.center += (rawSpeed / dist.Length) * dist;
return this;
}

View File

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

View File

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

View File

@@ -17,15 +17,15 @@ namespace OpenRA.Mods.RA.Activities
class Leap : CancelableActivity
{
Target target;
float2 initialLocation;
float t;
int2 initialLocation;
int moveFraction;
const int delay = 6;
public Leap(Actor self, Target target)
{
this.target = target;
initialLocation = self.CenterLocation;
this.target = target;
initialLocation = self.Trait<Mobile>().PxPosition;
self.Trait<RenderInfantry>().Attacking(self);
Sound.Play("dogg5p.aud", self.CenterLocation);
@@ -33,16 +33,16 @@ namespace OpenRA.Mods.RA.Activities
public override IActivity Tick(Actor self)
{
if( t == 0 && IsCanceled ) return NextActivity;
if( moveFraction == 0 && IsCanceled ) return NextActivity;
if (!target.IsValid) return NextActivity;
self.Trait<AttackLeap>().IsLeaping = true;
var mobile = self.Trait<Mobile>();
++moveFraction;
t += (1f / delay);
mobile.PxPosition = int2.Lerp(initialLocation, target.PxPosition, moveFraction, delay);
self.CenterLocation = float2.Lerp(initialLocation, target.CenterLocation, t);
if (t >= 1f)
if (moveFraction >= delay)
{
self.TraitsImplementing<IMove>().FirstOrDefault()
.SetPosition(self, Util.CellContaining(target.CenterLocation));

View File

@@ -92,9 +92,9 @@ namespace OpenRA.Mods.RA.Activities
Calculate(self);
return Util.SequenceActivities(
new Fly(w1),
new Fly(w2),
new Fly(w3),
Fly.ToPx(w1),
Fly.ToPx(w2),
Fly.ToPx(w3),
new Land(Target.FromActor(dest)),
NextActivity);
}

View File

@@ -37,14 +37,19 @@ namespace OpenRA.Mods.RA
public int Facing { get; set; }
[Sync]
public int Altitude { get; set; }
public float2 center;
AircraftInfo Info;
public Aircraft( ActorInitializer init , AircraftInfo info)
{
this.self = init.self;
if (init.Contains<LocationInit>())
this.Location = init.Get<LocationInit,int2>();
if( init.Contains<LocationInit>() )
{
this.Location = init.Get<LocationInit, int2>();
this.center = Util.CenterOfCell( Location );
}
this.Facing = init.Contains<FacingInit>() ? init.Get<FacingInit,int>() : info.InitialFacing;
this.Altitude = init.Contains<AltitudeInit>() ? init.Get<AltitudeInit,int>() : 0;
@@ -63,9 +68,15 @@ namespace OpenRA.Mods.RA
public void SetPosition(Actor self, int2 cell)
{
Location = cell;
self.CenterLocation = Util.CenterOfCell(cell);
center = Util.CenterOfCell(cell);
}
public void SetPxPosition( Actor self, int2 px )
{
Location = Util.CellContaining( px );
center = px;
}
public bool AircraftCanEnter(Actor a)
{
if( self.Owner != a.Owner ) return false;
@@ -86,5 +97,6 @@ namespace OpenRA.Mods.RA
int2[] noCells = new int2[] { };
public IEnumerable<int2> OccupiedCells() { return noCells; }
public int2 PxPosition { get { return center.ToInt2(); } }
}
}

View File

@@ -82,6 +82,13 @@ namespace OpenRA.Mods.RA
public int2 TopLeft { get { return Location; } }
public IEnumerable<int2> OccupiedCells() { return new int2[] { Location }; }
public int2 PxPosition { get; private set; }
public void SetPxPosition( Actor self, int2 px )
{
SetPosition( self, Util.CellContaining( px ) );
}
public bool CanEnterCell(int2 cell)
{
if (!self.World.Map.IsInMap(cell.X, cell.Y)) return false;
@@ -96,7 +103,7 @@ namespace OpenRA.Mods.RA
uim.Remove(self, this);
Location = cell;
self.CenterLocation = Util.CenterOfCell(cell);
PxPosition = Util.CenterOfCell(cell);
var seq = self.World.GetTerrainInfo(cell).IsWater ? "water" : "idle";
if (seq != self.Trait<RenderSimple>().anim.CurrentSequence.Name)

View File

@@ -58,18 +58,7 @@ namespace OpenRA.Mods.RA.Effects
w.Remove(this);
var loc = Traits.Util.CellContaining(location);
cargo.CancelActivity();
var mobile = cargo.TraitOrDefault<ITeleportable>();
if (mobile != null)
mobile.SetPosition(cargo, loc);
else
{
cargo.CenterLocation = Traits.Util.CenterOfCell(loc);
if (cargo.HasTrait<IOccupySpace>())
world.WorldActor.Trait<UnitInfluence>().Add(cargo, cargo.Trait<IOccupySpace>());
}
cargo.Trait<ITeleportable>().SetPosition(cargo, loc);
w.Add(cargo);
});
}

View File

@@ -139,11 +139,11 @@ namespace OpenRA.Mods.RA
.Select(h => self.Trait<Helicopter>().GetRepulseForce(self, h))
.Aggregate(float2.Zero, (a, b) => a + b);
self.CenterLocation += rawSpeed * f;
aircraft.center += rawSpeed * f;
if (--offsetTicks <= 0)
{
self.CenterLocation += Info.InstabilityMagnitude * self.World.SharedRandom.Gauss2D(5);
aircraft.center += Info.InstabilityMagnitude * self.World.SharedRandom.Gauss2D(5);
aircraft.Altitude += (int)(Info.InstabilityMagnitude * self.World.SharedRandom.Gauss1D(5));
offsetTicks = Info.InstabilityTicks;
}

View File

@@ -40,5 +40,6 @@ namespace OpenRA.Mods.RA
public int2 TopLeft { get { return location; } }
public IEnumerable<int2> OccupiedCells() { yield return TopLeft; }
public int2 PxPosition { get { return Util.CenterOfCell( location ); } }
}
}

View File

@@ -55,6 +55,7 @@ namespace OpenRA.Mods.RA
public int2 TopLeft { get { return location; } }
public IEnumerable<int2> OccupiedCells() { yield return TopLeft; }
public int2 PxPosition { get { return Util.CenterOfCell( location ); } }
}
/* tag trait for stuff that shouldnt trigger mines */

View File

@@ -100,7 +100,7 @@ namespace OpenRA.Mods.RA
});
self.CancelActivity();
self.QueueActivity(new Fly(Util.CenterOfCell(order.TargetLocation)));
self.QueueActivity(Fly.ToCell(order.TargetLocation));
}
else if (order.OrderString == "Enter")

View File

@@ -24,7 +24,7 @@ namespace OpenRA.Mods.RA
public class ExitInfo : TraitInfo<Exit>
{
public readonly float2 SpawnOffset = float2.Zero; // in px relative to CenterLocation
public readonly int2 SpawnOffset = int2.Zero; // in px relative to CenterLocation
public readonly int2 ExitCell = int2.Zero; // in cells relative to TopLeft
public readonly int Facing = -1;
}
@@ -46,21 +46,21 @@ namespace OpenRA.Mods.RA
});
var exit = self.Location + exitinfo.ExitCell;
var spawn = self.CenterLocation + exitinfo.SpawnOffset;
var spawn = self.Trait<IHasLocation>().PxPosition + exitinfo.SpawnOffset;
var move = newUnit.Trait<IMove>();
var mobile = newUnit.Trait<Mobile>();
var facing = newUnit.TraitOrDefault<IFacing>();
// Set the physical position of the unit as the exit cell
move.SetPosition(newUnit,exit);
mobile.SetPosition(newUnit,exit);
var to = Util.CenterOfCell(exit);
newUnit.CenterLocation = spawn;
mobile.PxPosition = spawn;
if (facing != null)
facing.Facing = exitinfo.Facing < 0 ? Util.GetFacing(to - spawn, facing.Facing) : exitinfo.Facing;
self.World.Add(newUnit);
// Animate the spawn -> exit transition
var speed = move.MovementSpeedForCell(self, exit);
var speed = mobile.MovementSpeedForCell(self, exit);
var length = speed > 0 ? (int)( ( to - spawn ).Length*3 / speed ) : 0;
newUnit.QueueActivity(new Drag(spawn, to, length));

View File

@@ -90,7 +90,7 @@ namespace OpenRA.Mods.RA.Render
foreach (var t in Footprint.UnpathableTiles( self.Info.Name, self.Info.Traits.Get<BuildingInfo>(), self.Location ))
{
var cell = t; // required: c# fails at bindings
self.World.AddFrameEndTask(w => w.Add(new Explosion(w, Util.CenterOfCell(cell).ToInt2(), "building", false)));
self.World.AddFrameEndTask(w => w.Add(new Explosion(w, Util.CenterOfCell(cell), "building", false)));
}
else if (e.DamageState >= DamageState.Heavy && e.PreviousDamageState < DamageState.Heavy)
{

View File

@@ -43,7 +43,6 @@ namespace OpenRA.Mods.RA
new LocationInit( exit ),
new OwnerInit( self.Owner ),
});
newUnit.CenterLocation = spawn;
var rp = self.TraitOrDefault<RallyPoint>();
if( rp != null )

View File

@@ -62,7 +62,7 @@ namespace OpenRA.Mods.RA
a.Trait<CarpetBomb>().SetTarget(order.TargetLocation);
a.CancelActivity();
a.QueueActivity(new Fly(order.TargetLocation));
a.QueueActivity(Fly.ToCell(order.TargetLocation));
if (flare != null)
a.QueueActivity(new CallFunc(() => flare.Destroy()));

View File

@@ -52,7 +52,7 @@ namespace OpenRA.Mods.RA
});
plane.CancelActivity();
plane.QueueActivity(new Fly(Util.CenterOfCell(order.TargetLocation)));
plane.QueueActivity(Fly.ToCell(order.TargetLocation));
plane.QueueActivity(new CallFunc(() => plane.World.AddFrameEndTask( w =>
{
var camera = w.CreateActor("camera", new TypeDictionary