Replace CPos.CenterPosition -> Map.CenterOfCell.

This commit is contained in:
Paul Chote
2013-09-17 22:27:19 +12:00
parent b6d1d26eeb
commit 7b52fa52b6
48 changed files with 105 additions and 90 deletions

View File

@@ -64,7 +64,7 @@ namespace OpenRA.Mods.RA
var delta = new WVec(0, -1024, 0).Rotate(attackRotation);
var altitude = self.World.Map.Rules.Actors[info.UnitType].Traits.Get<PlaneInfo>().CruiseAltitude.Range;
var target = order.TargetLocation.CenterPosition + new WVec(0, 0, altitude);
var target = self.World.Map.CenterOfCell(order.TargetLocation) + new WVec(0, 0, altitude);
var startEdge = target - (self.World.Map.DistanceToEdge(target, -delta) + info.Cordon).Range * delta / 1024;
var finishEdge = target + (self.World.Map.DistanceToEdge(target, delta) + info.Cordon).Range * delta / 1024;
@@ -174,7 +174,7 @@ namespace OpenRA.Mods.RA
beacon = new Beacon(
order.Player,
order.TargetLocation.CenterPosition,
self.World.Map.CenterOfCell(order.TargetLocation),
Info.BeaconPalettePrefix,
Info.BeaconPoster,
Info.BeaconPosterPalette,

View File

@@ -136,7 +136,7 @@ namespace OpenRA.Mods.RA
var tiles = world.Map.FindTilesInCircle(xy, range);
var pal = wr.Palette("terrain");
foreach (var t in tiles)
yield return new SpriteRenderable(tile, t.CenterPosition, WVec.Zero, -511, pal, 1f, true);
yield return new SpriteRenderable(tile, wr.world.Map.CenterOfCell(t), WVec.Zero, -511, pal, 1f, true);
}
public string GetCursor(World world, CPos xy, MouseInput mi)
@@ -217,11 +217,11 @@ namespace OpenRA.Mods.RA
// Source tiles
foreach (var t in world.Map.FindTilesInCircle(sourceLocation, range))
yield return new SpriteRenderable(sourceTile, t.CenterPosition, WVec.Zero, -511, pal, 1f, true);
yield return new SpriteRenderable(sourceTile, wr.world.Map.CenterOfCell(t), WVec.Zero, -511, pal, 1f, true);
// Destination tiles
foreach (var t in world.Map.FindTilesInCircle(xy, range))
yield return new SpriteRenderable(sourceTile, t.CenterPosition, WVec.Zero, -511, pal, 1f, true);
yield return new SpriteRenderable(sourceTile, wr.world.Map.CenterOfCell(t), WVec.Zero, -511, pal, 1f, true);
// Unit previews
foreach (var unit in power.UnitsInRange(sourceLocation))
@@ -241,7 +241,7 @@ namespace OpenRA.Mods.RA
var canEnter = manager.self.Owner.Shroud.IsExplored(targetCell) &&
unit.Trait<Chronoshiftable>().CanChronoshiftTo(unit, targetCell);
var tile = canEnter ? validTile : invalidTile;
yield return new SpriteRenderable(tile, targetCell.CenterPosition, WVec.Zero, -511, pal, 1f, true);
yield return new SpriteRenderable(tile, wr.world.Map.CenterOfCell(targetCell), WVec.Zero, -511, pal, 1f, true);
}
}
}

View File

@@ -49,7 +49,7 @@ namespace OpenRA.Mods.RA
self.Trait<RenderBuilding>().PlayCustomAnim(self, "active");
Sound.Play(info.IronCurtainSound, order.TargetLocation.CenterPosition);
Sound.Play(info.IronCurtainSound, self.World.Map.CenterOfCell(order.TargetLocation));
foreach (var target in UnitsInRange(order.TargetLocation)
.Where(a => a.Owner.Stances[self.Owner] == Stance.Ally))
@@ -109,8 +109,9 @@ namespace OpenRA.Mods.RA
{
var xy = wr.Position(wr.Viewport.ViewToWorldPx(Viewport.LastMousePos)).ToCPos();
var pal = wr.Palette("terrain");
foreach (var t in world.Map.FindTilesInCircle(xy, range))
yield return new SpriteRenderable(tile, t.CenterPosition, WVec.Zero, -511, pal, 1f, true);
yield return new SpriteRenderable(tile, wr.world.Map.CenterOfCell(t), WVec.Zero, -511, pal, 1f, true);
}
public string GetCursor(World world, CPos xy, MouseInput mi)

View File

@@ -77,9 +77,10 @@ namespace OpenRA.Mods.RA
var rb = self.Trait<RenderSimple>();
rb.PlayCustomAnim(self, "active");
var targetPosition = self.World.Map.CenterOfCell(order.TargetLocation);
var missile = new NukeLaunch(self.Owner, npi.MissileWeapon,
self.CenterPosition + body.LocalToWorld(npi.SpawnOffset),
order.TargetLocation.CenterPosition,
targetPosition,
npi.FlightVelocity, npi.FlightDelay, npi.SkipAscent);
self.World.AddFrameEndTask(w => w.Add(missile));
@@ -103,7 +104,7 @@ namespace OpenRA.Mods.RA
{
var beacon = new Beacon(
order.Player,
order.TargetLocation.CenterPosition,
targetPosition,
Info.BeaconPalettePrefix,
Info.BeaconPoster,
Info.BeaconPosterPalette,

View File

@@ -58,7 +58,7 @@ namespace OpenRA.Mods.RA
var altitude = self.World.Map.Rules.Actors[info.UnitType].Traits.Get<PlaneInfo>().CruiseAltitude;
var a = w.CreateActor(info.UnitType, new TypeDictionary
{
new CenterPositionInit(startPos.CenterPosition + new WVec(WRange.Zero, WRange.Zero, altitude)),
new CenterPositionInit(w.Map.CenterOfCell(startPos) + new WVec(WRange.Zero, WRange.Zero, altitude)),
new OwnerInit(self.Owner),
new FacingInit(Util.GetFacing(order.TargetLocation - startPos, 0))
});

View File

@@ -34,7 +34,7 @@ namespace OpenRA.Mods.RA
var plane = self.World.CreateActor("u2", new TypeDictionary
{
new CenterPositionInit(enterCell.CenterPosition + new WVec(WRange.Zero, WRange.Zero, altitude)),
new CenterPositionInit(self.World.Map.CenterOfCell(enterCell) + new WVec(WRange.Zero, WRange.Zero, altitude)),
new OwnerInit(self.Owner),
new FacingInit(Util.GetFacing(order.TargetLocation - enterCell, 0))
});

View File

@@ -74,7 +74,7 @@ namespace OpenRA.Mods.RA
{
ping = manager.RadarPings.Value.Add(
() => order.Player.IsAlliedWith(self.World.RenderPlayer),
order.TargetLocation.CenterPosition,
self.World.Map.CenterOfCell(order.TargetLocation),
order.Player.Color.RGB,
Info.RadarPingDuration);
}