New types for cell and pixel coordinate position/vectors.

This commit is contained in:
James Dunne
2012-06-20 23:22:27 -05:00
parent 0b98a8ce5e
commit 9c49143534
162 changed files with 1291 additions and 865 deletions

View File

@@ -27,9 +27,12 @@ namespace OpenRA.Mods.RA
public class ExitInfo : TraitInfo<Exit>
{
public readonly int2 SpawnOffset = int2.Zero; // in px relative to CenterLocation
public readonly int2 ExitCell = int2.Zero; // in cells relative to TopLeft
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;
public PVecInt SpawnOffsetVector { get { return (PVecInt)SpawnOffset; } }
public CVec ExitCellVector { get { return (CVec)ExitCell; } }
}
public class Exit {}
@@ -48,8 +51,8 @@ namespace OpenRA.Mods.RA
new OwnerInit( self.Owner ),
});
var exit = self.Location + exitinfo.ExitCell;
var spawn = self.Trait<IHasLocation>().PxPosition + exitinfo.SpawnOffset;
var exit = self.Location + exitinfo.ExitCellVector;
var spawn = self.Trait<IHasLocation>().PxPosition + exitinfo.SpawnOffsetVector;
var teleportable = newUnit.Trait<ITeleportable>();
var facing = newUnit.TraitOrDefault<IFacing>();
@@ -78,7 +81,7 @@ namespace OpenRA.Mods.RA
t.UnitProduced(self, newUnit, exit);
}
static int2 MoveToRallyPoint(Actor self, Actor newUnit, int2 exitLocation)
static CPos MoveToRallyPoint(Actor self, Actor newUnit, CPos exitLocation)
{
var rp = self.TraitOrDefault<RallyPoint>();
if (rp == null)
@@ -126,7 +129,7 @@ namespace OpenRA.Mods.RA
var mobileInfo = producee.Traits.GetOrDefault<MobileInfo>();
return mobileInfo == null ||
mobileInfo.CanEnterCell(self.World, self.Owner, self.Location + s.ExitCell, self, true);
mobileInfo.CanEnterCell(self.World, self.Owner, self.Location + s.ExitCellVector, self, true);
}
}
}