Replace WPos.ToCPos -> Map.CellContaining.

This commit is contained in:
Paul Chote
2013-09-17 22:57:30 +12:00
parent 4bc09692e0
commit 9487f49cd5
43 changed files with 81 additions and 83 deletions

View File

@@ -104,15 +104,4 @@ namespace OpenRA
#endregion
}
public static class RectangleExtensions
{
public static CPos TopLeftAsCPos(this Rectangle r) { return new CPos(r.Left, r.Top); }
public static CPos BottomRightAsCPos(this Rectangle r) { return new CPos(r.Right, r.Bottom); }
}
public static class WorldCoordinateExtensions
{
public static CPos ToCPos(this WPos a) { return new CPos(a.X / 1024, a.Y / 1024); }
}
}

View File

@@ -179,7 +179,7 @@ namespace OpenRA.GameRules
if (target.Type == TargetType.Terrain)
{
var cell = target.CenterPosition.ToCPos();
var cell = world.Map.CellContaining(target.CenterPosition);
if (!world.Map.Contains(cell))
return false;

View File

@@ -67,13 +67,13 @@ namespace OpenRA.Graphics
// Start of the first line segment is the tail of the list - don't smooth it.
var curPos = trail[idx(next - skip - 1)];
var curCell = curPos.ToCPos();
var curCell = wr.world.Map.CellContaining(curPos);
var curColor = color;
for (var i = 0; i < length - skip - 4; i++)
{
var j = next - skip - i - 2;
var nextPos = Average(trail[idx(j)], trail[idx(j-1)], trail[idx(j-2)], trail[idx(j-3)]);
var nextCell = nextPos.ToCPos();
var nextCell = wr.world.Map.CellContaining(nextPos);
var nextColor = Exts.ColorLerp(i * 1f / (length - 4), color, Color.Transparent);
if (!world.FogObscures(curCell) && !world.FogObscures(nextCell))

View File

@@ -100,6 +100,11 @@ namespace OpenRA.Graphics
Zoom = Game.Settings.Graphics.PixelDouble ? 2 : 1;
}
public CPos ViewToWorld(int2 view)
{
return worldRenderer.world.Map.CellContaining(worldRenderer.Position(ViewToWorldPx(view)));
}
public int2 ViewToWorldPx(int2 view) { return (1f / Zoom * view.ToFloat2()).ToInt2() + TopLeft; }
public int2 WorldToViewPx(int2 world) { return (Zoom * (world - TopLeft).ToFloat2()).ToInt2(); }
@@ -149,8 +154,8 @@ namespace OpenRA.Graphics
{
// Calculate the intersection of the visible rectangle and the map.
var map = worldRenderer.world.Map;
var tl = map.Clamp(worldRenderer.Position(TopLeft).ToCPos() - new CVec(1, 1));
var br = map.Clamp(worldRenderer.Position(BottomRight).ToCPos());
var tl = map.Clamp(map.CellContaining(worldRenderer.Position(TopLeft)) - new CVec(1, 1));
var br = map.Clamp(map.CellContaining(worldRenderer.Position(BottomRight)));
cells = new CellRegion(tl, br);
cellsDirty = false;

View File

@@ -471,6 +471,11 @@ namespace OpenRA
return new WPos(1024 * c.X + 512, 1024 * c.Y + 512, 0);
}
public CPos CellContaining(WPos pos)
{
return new CPos(pos.X / 1024, pos.Y / 1024);
}
public void Resize(int width, int height) // editor magic.
{
var oldMapTiles = MapTiles.Value;

View File

@@ -103,7 +103,7 @@ namespace OpenRA.Orders
.Select(x => new { Trait = trait, Order = x }))
.OrderByDescending(x => x.Order.OrderPriority))
{
var actorsAt = self.World.ActorMap.GetUnitsAt(target.CenterPosition.ToCPos()).ToList();
var actorsAt = self.World.ActorMap.GetUnitsAt(self.World.Map.CellContaining(target.CenterPosition)).ToList();
var modifiers = TargetModifiers.None;
if (mi.Modifiers.HasModifier(Modifiers.Ctrl))

View File

@@ -138,9 +138,9 @@ namespace OpenRA.Traits
return result.Keys;
}
public static IEnumerable<CPos> AdjacentCells(Target target)
public static IEnumerable<CPos> AdjacentCells(World w, Target target)
{
var cells = target.Positions.Select(p => p.ToCPos()).Distinct();
var cells = target.Positions.Select(p => w.Map.CellContaining(p)).Distinct();
return ExpandFootprint(cells, true);
}
}

View File

@@ -181,7 +181,7 @@ namespace OpenRA.Traits
return cells.Select(c => c.First);
}
return new[] { a.CenterPosition.ToCPos() };
return new[] { a.World.Map.CellContaining(a.CenterPosition) };
}
public void Explore(World world, CPos center, WRange range)

View File

@@ -92,7 +92,7 @@ namespace OpenRA.Widgets
public void UpdateMouseover()
{
TooltipType = WorldTooltipType.None;
var cell = worldRenderer.Position(worldRenderer.Viewport.ViewToWorldPx(Viewport.LastMousePos)).ToCPos();
var cell = worldRenderer.Viewport.ViewToWorld(Viewport.LastMousePos);
if (!world.Map.Contains(cell))
return;

View File

@@ -141,8 +141,7 @@ namespace OpenRA.Widgets
return;
var pos = worldRenderer.Position(xy);
var orders = world.OrderGenerator.Order(world, pos.ToCPos(), mi).ToArray();
var orders = world.OrderGenerator.Order(world, world.Map.CellContaining(pos), mi).ToArray();
world.PlayVoiceForOrders(orders);
var flashed = false;
@@ -180,7 +179,7 @@ namespace OpenRA.Widgets
var xy = worldRenderer.Viewport.ViewToWorldPx(screenPos);
var pos = worldRenderer.Position(xy);
var cell = pos.ToCPos();
var cell = World.Map.CellContaining(pos);
var mi = new MouseInput
{

View File

@@ -45,7 +45,7 @@ namespace OpenRA.Mods.RA.AI
if (owner.attackOrFleeFuzzy.CanAttack(owner.units, enemyUnits))
{
foreach (var u in owner.units)
owner.world.IssueOrder(new Order("AttackMove", u, false) { TargetLocation = owner.Target.CenterPosition.ToCPos() });
owner.world.IssueOrder(new Order("AttackMove", u, false) { TargetLocation = owner.Target.Location });
// We have gathered sufficient units. Attack the nearest enemy unit.
owner.fsm.ChangeState(owner, new GroundUnitsAttackMoveState(), true);
@@ -89,7 +89,7 @@ namespace OpenRA.Mods.RA.AI
{
owner.world.IssueOrder(new Order("Stop", leader, false));
foreach (var unit in owner.units.Where(a => !ownUnits.Contains(a)))
owner.world.IssueOrder(new Order("AttackMove", unit, false) { TargetLocation = leader.CenterPosition.ToCPos() });
owner.world.IssueOrder(new Order("AttackMove", unit, false) { TargetLocation = leader.Location });
}
else
{

View File

@@ -32,7 +32,7 @@ namespace OpenRA.Mods.RA.Activities
if (target.Type != TargetType.Actor)
return NextActivity;
if (!Util.AdjacentCells(target).Any(c => c == self.Location))
if (!Util.AdjacentCells(self.World, target).Any(c => c == self.Location))
return Util.SequenceActivities(new MoveAdjacentTo(self, target), this);
// Move to the middle of the target, ignoring impassable tiles

View File

@@ -37,7 +37,7 @@ namespace OpenRA.Mods.RA.Activities
// TODO: Queue a move order to the transport? need to be
// careful about units that can't path to the transport
var cells = Util.AdjacentCells(Target.FromActor(transport));
var cells = Util.AdjacentCells(self.World, Target.FromActor(transport));
if (!cells.Contains(self.Location))
return NextActivity;

View File

@@ -37,7 +37,7 @@ namespace OpenRA.Mods.RA.Activities
return Util.SequenceActivities(
new MoveAdjacentTo(self, Target.FromActor(rearmTarget)),
movement.MoveTo(rearmTarget.CenterPosition.ToCPos(), rearmTarget),
movement.MoveTo(self.World.Map.CellContaining(rearmTarget.CenterPosition), rearmTarget),
new Rearm(self),
new Repair(rearmTarget),
this);

View File

@@ -37,7 +37,7 @@ namespace OpenRA.Mods.RA.Activities
movementClass = (uint)mobile.Info.GetMovementClass(self.World.TileSet);
if (target.IsValidFor(self))
targetPosition = target.CenterPosition.ToCPos();
targetPosition = self.World.Map.CellContaining(target.CenterPosition);
repath = true;
}
@@ -73,7 +73,7 @@ namespace OpenRA.Mods.RA.Activities
{
// Check if the target has moved
var oldTargetPosition = targetPosition;
targetPosition = target.CenterPosition.ToCPos();
targetPosition = self.World.Map.CellContaining(target.CenterPosition);
var shroudStop = ShouldStop(self, oldTargetPosition);
if (shroudStop || (!repath && ShouldRepath(self, oldTargetPosition)))
@@ -101,7 +101,7 @@ namespace OpenRA.Mods.RA.Activities
protected virtual IEnumerable<CPos> CandidateMovementCells(Actor self)
{
return Util.AdjacentCells(target);
return Util.AdjacentCells(self.World, target);
}
void UpdateInnerPath(Actor self)

6
OpenRA.Mods.RA/Air/Aircraft.cs Executable file → Normal file
View File

@@ -45,7 +45,7 @@ namespace OpenRA.Mods.RA.Air
[Sync] public int Facing { get; set; }
[Sync] public WPos CenterPosition { get; private set; }
public CPos TopLeft { get { return CenterPosition.ToCPos(); } }
public CPos TopLeft { get { return self.World.Map.CellContaining(CenterPosition); } }
public IDisposable Reservation;
public int ROT { get { return info.ROT; } }
@@ -201,7 +201,7 @@ namespace OpenRA.Mods.RA.Air
return new Order(order.OrderID, self, queued) { TargetActor = target.Actor };
if (order.OrderID == "Move")
return new Order(order.OrderID, self, queued) { TargetLocation = target.CenterPosition.ToCPos() };
return new Order(order.OrderID, self, queued) { TargetLocation = self.World.Map.CellContaining(target.CenterPosition) };
return null;
}
@@ -246,7 +246,7 @@ namespace OpenRA.Mods.RA.Air
return false;
IsQueued = modifiers.HasModifier(TargetModifiers.ForceQueue);
cursor = self.World.Map.Contains(target.CenterPosition.ToCPos()) ? "move" : "move-blocked";
cursor = self.World.Map.Contains(self.World.Map.CellContaining(target.CenterPosition)) ? "move" : "move-blocked";
return true;
}

View File

@@ -32,7 +32,7 @@ namespace OpenRA.Mods.RA.Air
var rp = hasHost ? host.TraitOrDefault<RallyPoint>() : null;
var destination = rp != null ? rp.rallyPoint :
(hasHost ? host.CenterPosition.ToCPos() : self.CenterPosition.ToCPos());
(hasHost ? self.World.Map.CellContaining(host.CenterPosition) : self.Location);
return new AttackMove.AttackMoveActivity(self, self.Trait<IMove>().MoveTo(destination, 1));
}

View File

@@ -107,7 +107,7 @@ namespace OpenRA.Mods.RA
case TargetType.FrozenActor:
return new Order("Attack", self, queued) { ExtraData = target.FrozenActor.ID };
case TargetType.Terrain:
return new Order("Attack", self, queued) { TargetLocation = target.CenterPosition.ToCPos() };
return new Order("Attack", self, queued) { TargetLocation = self.World.Map.CellContaining(target.CenterPosition) };
}
}
@@ -241,7 +241,7 @@ namespace OpenRA.Mods.RA
case TargetType.FrozenActor:
return CanTargetActor(self, target, modifiers, ref cursor);
case TargetType.Terrain:
return CanTargetLocation(self, target.CenterPosition.ToCPos(), othersAtTarget, modifiers, ref cursor);
return CanTargetLocation(self, self.World.Map.CellContaining(target.CenterPosition), othersAtTarget, modifiers, ref cursor);
default:
return false;
}

View File

@@ -32,7 +32,7 @@ namespace OpenRA.Mods.RA
public void TickIdle(Actor self)
{
var target = self.CenterPosition + new WVec(0, -1024*Info.MoveRadius, 0).Rotate(WRot.FromFacing(self.World.SharedRandom.Next(255)));
self.Trait<AttackMove>().ResolveOrder(self, new Order("AttackMove", self, false) { TargetLocation = target.ToCPos() });
self.Trait<AttackMove>().ResolveOrder(self, new Order("AttackMove", self, false) { TargetLocation = self.World.Map.CellContaining(target) });
}
}
}

View File

@@ -102,7 +102,7 @@ namespace OpenRA.Mods.RA
IEnumerable<CPos> GetAdjacentCells()
{
return Util.AdjacentCells(Target.FromActor(self)).Where(c => self.Location != c);
return Util.AdjacentCells(self.World, Target.FromActor(self)).Where(c => self.Location != c);
}
bool CanUnload()
@@ -218,7 +218,7 @@ namespace OpenRA.Mods.RA
initialized = true;
}
var cell = self.CenterPosition.ToCPos();
var cell = self.World.Map.CellContaining(self.CenterPosition);
if (currentCell != cell)
{
currentCell = cell;

View File

@@ -35,7 +35,7 @@ namespace OpenRA.Mods.RA
public static void DoImpact(WPos pos, WarheadInfo warhead, WeaponInfo weapon, Actor firedBy, float firepowerModifier)
{
var world = firedBy.World;
var targetTile = pos.ToCPos();
var targetTile = world.Map.CellContaining(pos);
if (!world.Map.Contains(targetTile))
return;

View File

@@ -85,8 +85,8 @@ namespace OpenRA.Mods.RA
public IEnumerable<Pair<CPos, SubCell>> OccupiedCells() { yield return Pair.New(Location, SubCell.FullCell); }
public WPos CenterPosition { get; private set; }
public void SetPosition(Actor self, WPos pos) { SetPosition(self, pos.ToCPos()); }
public void SetVisualPosition(Actor self, WPos pos) { SetPosition(self, pos.ToCPos()); }
public void SetPosition(Actor self, WPos pos) { SetPosition(self, self.World.Map.CellContaining(pos)); }
public void SetVisualPosition(Actor self, WPos pos) { SetPosition(self, self.World.Map.CellContaining(pos)); }
public bool CanEnterCell(CPos cell, Actor ignoreActor, bool checkTransientActors)
{

View File

@@ -134,7 +134,7 @@ namespace OpenRA.Mods.RA.Effects
trail.Update(pos);
if (ticks++ >= length || (!info.High && world.ActorMap
.GetUnitsAt(pos.ToCPos()).Any(a => a.HasTrait<IBlocksBullets>())))
.GetUnitsAt(world.Map.CellContaining(pos)).Any(a => a.HasTrait<IBlocksBullets>())))
{
Explode(world);
}
@@ -148,7 +148,7 @@ namespace OpenRA.Mods.RA.Effects
if (anim == null || ticks >= length)
yield break;
var cell = pos.ToCPos();
var cell = wr.world.Map.CellContaining(pos);
if (!args.SourceActor.World.FogObscures(cell))
{
if (info.Shadow)

View File

@@ -43,7 +43,7 @@ namespace OpenRA.Mods.RA.Effects
public IEnumerable<IRenderable> Render(WorldRenderer wr)
{
if (wr.world.FogObscures(pos.ToCPos()))
if (wr.world.FogObscures(wr.world.Map.CellContaining(pos)))
yield break;
yield return new TextRenderable(font, pos, 0, color, text);

View File

@@ -26,7 +26,7 @@ namespace OpenRA.Mods.RA.Effects
{
this.world = world;
this.pos = pos;
this.cell = pos.ToCPos();
this.cell = world.Map.CellContaining(pos);
this.paletteName = paletteName;
anim = new Animation(world, image);
anim.PlayThen(sequence, () => world.AddFrameEndTask(w => w.Remove(this)));

View File

@@ -26,7 +26,7 @@ namespace OpenRA.Mods.RA.Effects
{
this.world = world;
this.pos = pos;
this.cell = pos.ToCPos();
this.cell = world.Map.CellContaining(pos);
this.palette = palette;
anim = new Animation(world, "explosion");
anim.PlayThen(sequence, () => world.AddFrameEndTask(w => w.Remove(this)));

View File

@@ -64,7 +64,7 @@ namespace OpenRA.Mods.RA.Effects
public IEnumerable<IRenderable> Render(WorldRenderer wr)
{
var cell = pos.ToCPos();
var cell = wr.world.Map.CellContaining(pos);
if (!args.SourceActor.World.FogObscures(cell))
{
if (info.Shadow)

View File

@@ -154,7 +154,7 @@ namespace OpenRA.Mods.RA.Effects
if (info.ContrailLength > 0)
trail.Update(pos);
var cell = pos.ToCPos();
var cell = world.Map.CellContaining(pos);
var shouldExplode = (pos.Z < 0) // Hit the ground
|| (dist.LengthSquared < MissileCloseEnough.Range * MissileCloseEnough.Range) // Within range
@@ -186,7 +186,7 @@ namespace OpenRA.Mods.RA.Effects
if (info.ContrailLength > 0)
yield return trail;
if (!args.SourceActor.World.FogObscures(pos.ToCPos()))
if (!args.SourceActor.World.FogObscures(wr.world.Map.CellContaining(pos)))
{
var palette = wr.Palette(args.Weapon.Palette);
foreach (var r in anim.Render(pos, palette))

View File

@@ -36,7 +36,7 @@ namespace OpenRA.Mods.RA.Effects
parachuteOffset = pai.Offset;
// Adjust x,y to match the target subcell
cargo.Trait<IPositionable>().SetPosition(cargo, dropPosition.ToCPos());
cargo.Trait<IPositionable>().SetPosition(cargo, cargo.World.Map.CellContaining(dropPosition));
var cp = cargo.CenterPosition;
pos = new WPos(cp.X, cp.Y, dropPosition.Z);
}

View File

@@ -25,7 +25,7 @@ namespace OpenRA.Mods.RA.Effects
{
this.world = world;
this.pos = pos;
this.cell = pos.ToCPos();
this.cell = world.Map.CellContaining(pos);
anim = new Animation(world, trail);
anim.PlayThen("idle",

View File

@@ -260,7 +260,7 @@ namespace OpenRA.Mods.RA
return new Order(order.OrderID, self, queued) { TargetActor = target.Actor };
if (order.OrderID == "Harvest")
return new Order(order.OrderID, self, queued) { TargetLocation = target.CenterPosition.ToCPos() };
return new Order(order.OrderID, self, queued) { TargetLocation = self.World.Map.CellContaining(target.CenterPosition) };
return null;
}
@@ -437,7 +437,7 @@ namespace OpenRA.Mods.RA
if (modifiers.HasModifier(TargetModifiers.ForceMove))
return false;
var location = target.CenterPosition.ToCPos();
var location = self.World.Map.CellContaining(target.CenterPosition);
// Don't leak info about resources under the shroud
if (!self.Owner.Shroud.IsExplored(location))
return false;

View File

@@ -82,7 +82,7 @@ namespace OpenRA.Mods.RA
{
self.World.ActorMap.RemoveInfluence(self, this);
CenterPosition = pos;
TopLeft = pos.ToCPos();
TopLeft = self.World.Map.CellContaining(pos);
self.World.ActorMap.AddInfluence(self, this);
self.World.ActorMap.UpdatePosition(self, this);
self.World.ScreenMap.Update(self);

View File

@@ -58,7 +58,7 @@ namespace OpenRA.Mods.RA
switch (order.OrderID)
{
case "BeginMinefield":
var start = target.CenterPosition.ToCPos();
var start = self.World.Map.CellContaining(target.CenterPosition);
self.World.OrderGenerator = new MinefieldOrderGenerator(self, start);
return new Order("BeginMinefield", self, false) { TargetLocation = start };
case "PlaceMine":
@@ -201,7 +201,7 @@ namespace OpenRA.Mods.RA
if (target.Type != TargetType.Terrain)
return false;
var location = target.CenterPosition.ToCPos();
var location = self.World.Map.CellContaining(target.CenterPosition);
if (!self.World.Map.Contains(location))
return false;

View File

@@ -266,7 +266,7 @@ namespace OpenRA.Mods.RA.Move
public void SetPosition(Actor self, WPos pos)
{
var cell = pos.ToCPos();
var cell = self.World.Map.CellContaining(pos);
SetLocation(cell, fromSubCell, cell, fromSubCell);
SetVisualPosition(self, pos);
FinishedMoving(self);
@@ -306,7 +306,7 @@ namespace OpenRA.Mods.RA.Move
if (Info.OnRails)
return null;
return new Order("Move", self, queued) { TargetLocation = target.CenterPosition.ToCPos() };
return new Order("Move", self, queued) { TargetLocation = self.World.Map.CellContaining(target.CenterPosition) };
}
return null;
}
@@ -573,7 +573,7 @@ namespace OpenRA.Mods.RA.Move
if (rejectMove || !target.IsValidFor(self))
return false;
var location = target.CenterPosition.ToCPos();
var location = self.World.Map.CellContaining(target.CenterPosition);
IsQueued = modifiers.HasModifier(TargetModifiers.ForceQueue);
cursor = "move";

View File

@@ -85,7 +85,7 @@ namespace OpenRA.Mods.RA.Move
using (new PerfSample("Pathfinder"))
{
var mi = self.Info.Traits.Get<MobileInfo>();
var targetCell = target.ToCPos();
var targetCell = self.World.Map.CellContaining(target);
var rangeSquared = range.Range*range.Range;
// Correct for SubCell offset

View File

@@ -79,14 +79,14 @@ namespace OpenRA.Mods.RA.Orders
public IEnumerable<IRenderable> Render(WorldRenderer wr, World world) { yield break; }
public void RenderAfterWorld(WorldRenderer wr, World world)
{
var position = wr.Position(wr.Viewport.ViewToWorldPx(Viewport.LastMousePos)).ToCPos();
var topLeft = position - FootprintUtils.AdjustForBuildingSize(BuildingInfo);
var xy = wr.Viewport.ViewToWorld(Viewport.LastMousePos);
var topLeft = xy - FootprintUtils.AdjustForBuildingSize(BuildingInfo);
var rules = world.Map.Rules;
var actorInfo = rules.Actors[Building];
foreach (var dec in actorInfo.Traits.WithInterface<IPlaceBuildingDecoration>())
dec.Render(wr, world, actorInfo, world.Map.CenterOfCell(position));
dec.Render(wr, world, actorInfo, world.Map.CenterOfCell(xy));
var cells = new Dictionary<CPos, bool>();
// Linebuild for walls.

View File

@@ -62,7 +62,7 @@ namespace OpenRA.Mods.RA
self.World.OrderGenerator = new PortableChronoOrderGenerator(self);
if (order.OrderID == "PortableChronoTeleport")
return new Order(order.OrderID, self, queued) { TargetLocation = target.CenterPosition.ToCPos() };
return new Order(order.OrderID, self, queued) { TargetLocation = self.World.Map.CellContaining(target.CenterPosition) };
return new Order(order.OrderID, self, queued) { TargetActor = target.Actor };
}
@@ -120,7 +120,7 @@ namespace OpenRA.Mods.RA
// TODO: When target modifiers are configurable this needs to be revisited
if (modifiers.HasModifier(TargetModifiers.ForceMove) || modifiers.HasModifier(TargetModifiers.ForceQueue))
{
var xy = target.CenterPosition.ToCPos();
var xy = self.World.Map.CellContaining(target.CenterPosition);
IsQueued = modifiers.HasModifier(TargetModifiers.ForceQueue);
@@ -153,7 +153,7 @@ namespace OpenRA.Mods.RA
yield break;
}
if (self.IsInWorld && self.CenterPosition.ToCPos() != xy
if (self.IsInWorld && self.Location != xy
&& self.Trait<PortableChrono>().CanTeleport && self.Owner.Shroud.IsExplored(xy))
{
world.CancelInputMode();
@@ -190,7 +190,7 @@ namespace OpenRA.Mods.RA
public string GetCursor(World world, CPos xy, MouseInput mi)
{
if (self.IsInWorld && self.CenterPosition.ToCPos() != xy
if (self.IsInWorld && self.Location != xy
&& self.Trait<PortableChrono>().CanTeleport && self.Owner.Shroud.IsExplored(xy))
return "chrono-target";
else

4
OpenRA.Mods.RA/RallyPoint.cs Executable file → Normal file
View File

@@ -41,7 +41,7 @@ namespace OpenRA.Mods.RA
public Order IssueOrder( Actor self, IOrderTargeter order, Target target, bool queued )
{
if (order.OrderID == "SetRallyPoint")
return new Order(order.OrderID, self, false) { TargetLocation = target.CenterPosition.ToCPos(), SuppressVisualFeedback = true };
return new Order(order.OrderID, self, false) { TargetLocation = self.World.Map.CellContaining(target.CenterPosition), SuppressVisualFeedback = true };
return null;
}
@@ -62,7 +62,7 @@ namespace OpenRA.Mods.RA
if (target.Type != TargetType.Terrain)
return false;
var location = target.CenterPosition.ToCPos();
var location = self.World.Map.CellContaining(target.CenterPosition);
if (self.World.Map.Contains(location))
{
cursor = "ability";

View File

@@ -78,7 +78,7 @@ namespace OpenRA.Mods.RA
self.CancelActivity();
self.QueueActivity(new MoveAdjacentTo(self, target));
self.QueueActivity(movement.MoveTo(order.TargetActor.CenterPosition.ToCPos(), order.TargetActor));
self.QueueActivity(movement.MoveTo(self.World.Map.CellContaining(order.TargetActor.CenterPosition), order.TargetActor));
self.QueueActivity(new Rearm(self));
self.QueueActivity(new Repair(order.TargetActor));

View File

@@ -41,8 +41,7 @@ namespace OpenRA.Mods.RA
if (--ticks <= 0)
{
var position = self.CenterPosition;
if (position.Z > 0 && self.GetDamageState() >= info.MinDamage &&
!self.World.FogObscures(position.ToCPos()))
if (position.Z > 0 && self.GetDamageState() >= info.MinDamage && !self.World.FogObscures(self))
{
var offset = info.Offset.Rotate(body.QuantizeOrientation(self, self.Orientation));
var pos = position + body.LocalToWorld(offset);

View File

@@ -123,7 +123,7 @@ namespace OpenRA.Mods.RA
public void RenderAfterWorld(WorldRenderer wr, World world)
{
var xy = wr.Position(wr.Viewport.ViewToWorldPx(Viewport.LastMousePos)).ToCPos();
var xy = wr.Viewport.ViewToWorld(Viewport.LastMousePos);
var targetUnits = power.UnitsInRange(xy);
foreach (var unit in targetUnits)
if (manager.self.Owner.Shroud.IsTargetable(unit))
@@ -132,7 +132,7 @@ namespace OpenRA.Mods.RA
public IEnumerable<IRenderable> Render(WorldRenderer wr, World world)
{
var xy = wr.Position(wr.Viewport.ViewToWorldPx(Viewport.LastMousePos)).ToCPos();
var xy = wr.Viewport.ViewToWorld(Viewport.LastMousePos);
var tiles = world.Map.FindTilesInCircle(xy, range);
var pal = wr.Palette("terrain");
foreach (var t in tiles)
@@ -212,7 +212,7 @@ namespace OpenRA.Mods.RA
public IEnumerable<IRenderable> Render(WorldRenderer wr, World world)
{
var xy = wr.Position(wr.Viewport.ViewToWorldPx(Viewport.LastMousePos)).ToCPos();
var xy = wr.Viewport.ViewToWorld(Viewport.LastMousePos);
var pal = wr.Palette("terrain");
// Source tiles

View File

@@ -100,14 +100,14 @@ namespace OpenRA.Mods.RA
public void RenderAfterWorld(WorldRenderer wr, World world)
{
var xy = wr.Position(wr.Viewport.ViewToWorldPx(Viewport.LastMousePos)).ToCPos();
var xy = wr.Viewport.ViewToWorld(Viewport.LastMousePos);
foreach (var unit in power.UnitsInRange(xy))
wr.DrawSelectionBox(unit, Color.Red);
}
public IEnumerable<IRenderable> Render(WorldRenderer wr, World world)
{
var xy = wr.Position(wr.Viewport.ViewToWorldPx(Viewport.LastMousePos)).ToCPos();
var xy = wr.Viewport.ViewToWorld(Viewport.LastMousePos);
var pal = wr.Palette("terrain");
foreach (var t in world.Map.FindTilesInCircle(xy, range))

View File

@@ -158,8 +158,8 @@ namespace OpenRA.Mods.RA.Widgets
// Draw viewport rect
if (hasRadar)
{
var tl = CellToMinimapPixel(worldRenderer.Position(worldRenderer.Viewport.TopLeft).ToCPos());
var br = CellToMinimapPixel(worldRenderer.Position(worldRenderer.Viewport.BottomRight).ToCPos());
var tl = CellToMinimapPixel(world.Map.CellContaining(worldRenderer.Position(worldRenderer.Viewport.TopLeft)));
var br = CellToMinimapPixel(world.Map.CellContaining(worldRenderer.Position(worldRenderer.Viewport.BottomRight)));
Game.Renderer.EnableScissor(mapRect);
DrawRadarPings();
@@ -180,7 +180,8 @@ namespace OpenRA.Mods.RA.Widgets
foreach (var radarPing in radarPings.Pings.Where(e => e.IsVisible()))
{
var c = radarPing.Color;
var points = radarPing.Points(CellToMinimapPixel(radarPing.Position.ToCPos())).ToArray();
var pingCell = world.Map.CellContaining(radarPing.Position);
var points = radarPing.Points(CellToMinimapPixel(pingCell)).ToArray();
lr.DrawLine(points[0], points[1], c, c);
lr.DrawLine(points[1], points[2], c, c);