Remove unnecessary int2 -> PPos -> int2 conversions.
This commit is contained in:
@@ -149,9 +149,8 @@ namespace OpenRA.Graphics
|
||||
return (CPos)( (1f / Game.CellSize) * (1f/Zoom*loc.ToFloat2() + Location) ).ToInt2();
|
||||
}
|
||||
|
||||
public PPos ViewToWorldPx(int2 loc) { return (PPos)(1f/Zoom*loc.ToFloat2() + Location).ToInt2(); }
|
||||
public PPos ViewToWorldPx(MouseInput mi) { return ViewToWorldPx(mi.Location); }
|
||||
public int2 WorldToViewPx(PPos loc) { return (Zoom * (loc.ToFloat2() - Location)).ToInt2(); }
|
||||
public int2 ViewToWorldPx(int2 loc) { return (1f/Zoom*loc.ToFloat2() + Location).ToInt2(); }
|
||||
public int2 WorldToViewPx(int2 loc) { return (Zoom * (loc.ToFloat2() - Location)).ToInt2(); }
|
||||
|
||||
public void Center(float2 loc)
|
||||
{
|
||||
|
||||
@@ -75,8 +75,8 @@ namespace OpenRA.Graphics
|
||||
{
|
||||
var comparer = new RenderableComparer(this);
|
||||
var vb = Game.viewport.ViewBounds(world);
|
||||
var tl = Game.viewport.ViewToWorldPx(new int2(vb.Left, vb.Top)).ToInt2();
|
||||
var br = Game.viewport.ViewToWorldPx(new int2(vb.Right, vb.Bottom)).ToInt2();
|
||||
var tl = Game.viewport.ViewToWorldPx(new int2(vb.Left, vb.Top));
|
||||
var br = Game.viewport.ViewToWorldPx(new int2(vb.Right, vb.Bottom));
|
||||
var actors = world.ScreenMap.ActorsInBox(tl, br)
|
||||
.Append(world.WorldActor)
|
||||
.ToList();
|
||||
|
||||
@@ -127,9 +127,6 @@ namespace OpenRA.Traits
|
||||
.Select(kv => kv.Key);
|
||||
}
|
||||
|
||||
// Legacy fallback
|
||||
public IEnumerable<Actor> ActorsAt(PPos pxPos) { return ActorsAt(pxPos.ToInt2()); }
|
||||
|
||||
public IEnumerable<Actor> ActorsInBox(int2 a, int2 b)
|
||||
{
|
||||
return ActorsInBox(Rectangle.FromLTRB(Math.Min(a.X, b.X), Math.Min(a.Y, b.Y), Math.Max(a.X, b.X), Math.Max(a.Y, b.Y)));
|
||||
|
||||
@@ -23,6 +23,7 @@ namespace OpenRA.Widgets
|
||||
{
|
||||
protected readonly World world;
|
||||
readonly WorldRenderer worldRenderer;
|
||||
int2 dragStart, dragEnd;
|
||||
|
||||
[ObjectCreator.UseCtor]
|
||||
public WorldInteractionControllerWidget(World world, WorldRenderer worldRenderer)
|
||||
@@ -47,11 +48,10 @@ namespace OpenRA.Widgets
|
||||
worldRenderer.DrawRollover(u);
|
||||
}
|
||||
|
||||
PPos dragStart, dragEnd;
|
||||
|
||||
public override bool HandleMouseInput(MouseInput mi)
|
||||
{
|
||||
var xy = Game.viewport.ViewToWorldPx(mi);
|
||||
var xy = Game.viewport.ViewToWorldPx(mi.Location);
|
||||
|
||||
var UseClassicMouseStyle = Game.Settings.Game.UseClassicMouseStyle;
|
||||
|
||||
@@ -127,7 +127,7 @@ namespace OpenRA.Widgets
|
||||
}
|
||||
|
||||
|
||||
public Pair<PPos, PPos>? SelectionBox
|
||||
public Pair<int2, int2>? SelectionBox
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -136,11 +136,11 @@ namespace OpenRA.Widgets
|
||||
}
|
||||
}
|
||||
|
||||
public void ApplyOrders(World world, PPos xy, MouseInput mi)
|
||||
public void ApplyOrders(World world, int2 xy, MouseInput mi)
|
||||
{
|
||||
if (world.OrderGenerator == null) return;
|
||||
|
||||
var orders = world.OrderGenerator.Order(world, xy.ToCPos(), mi).ToArray();
|
||||
var orders = world.OrderGenerator.Order(world, ((PPos)xy).ToCPos(), mi).ToArray();
|
||||
orders.Do(o => world.IssueOrder(o));
|
||||
|
||||
world.PlayVoiceForOrders(orders);
|
||||
@@ -183,9 +183,9 @@ namespace OpenRA.Widgets
|
||||
}
|
||||
|
||||
static readonly Actor[] NoActors = {};
|
||||
IEnumerable<Actor> SelectActorsInBox(World world, PPos a, PPos b, Func<Actor, bool> cond)
|
||||
IEnumerable<Actor> SelectActorsInBox(World world, int2 a, int2 b, Func<Actor, bool> cond)
|
||||
{
|
||||
return world.ScreenMap.ActorsInBox(a.ToInt2(), b.ToInt2())
|
||||
return world.ScreenMap.ActorsInBox(a, b)
|
||||
.Where(x => x.HasTrait<Selectable>() && x.Trait<Selectable>().Info.Selectable && !world.FogObscures(x) && cond(x))
|
||||
.GroupBy(x => x.GetSelectionPriority())
|
||||
.OrderByDescending(g => g.Key)
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace OpenRA
|
||||
if (world.RenderPlayer == null)
|
||||
return NoFrozenActors;
|
||||
|
||||
return world.ScreenMap.FrozenActorsAt(world.RenderPlayer, Game.viewport.ViewToWorldPx(mouseLocation).ToInt2());
|
||||
return world.ScreenMap.FrozenActorsAt(world.RenderPlayer, Game.viewport.ViewToWorldPx(mouseLocation));
|
||||
}
|
||||
|
||||
public static IEnumerable<Actor> FindActorsInBox(this World world, CPos tl, CPos br)
|
||||
|
||||
Reference in New Issue
Block a user