New types for cell and pixel coordinate position/vectors.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user