Revert "add IHasLocation"

This reverts commit 699b4b1154.
This commit is contained in:
Chris Forbes
2010-09-28 07:43:49 +13:00
parent a3c0448e15
commit f402ec7898
31 changed files with 105 additions and 136 deletions

View File

@@ -24,7 +24,7 @@ namespace OpenRA.Mods.RA
public class ExitInfo : TraitInfo<Exit>
{
public readonly int2 SpawnOffset = int2.Zero; // in px relative to CenterLocation
public readonly float2 SpawnOffset = float2.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.ToInt2() + exitinfo.SpawnOffset;
var spawn = self.CenterLocation + exitinfo.SpawnOffset;
var mobile = newUnit.Trait<Mobile>();
var move = newUnit.Trait<IMove>();
var facing = newUnit.TraitOrDefault<IFacing>();
// Set the physical position of the unit as the exit cell
mobile.SetPosition(newUnit,exit);
move.SetPosition(newUnit,exit);
var to = Util.CenterOfCell(exit);
mobile.PxPosition = spawn;
newUnit.CenterLocation = 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 = mobile.MovementSpeedForCell(self, exit);
var speed = move.MovementSpeedForCell(self, exit);
var length = speed > 0 ? (int)( ( to - spawn ).Length*3 / speed ) : 0;
newUnit.QueueActivity(new Drag(spawn, to, length));