Easier actor selection in game by actor bounds center

This commit is contained in:
atlimit8
2015-11-15 11:30:40 -06:00
parent 387d0d0e3f
commit b07cd683e8
17 changed files with 100 additions and 75 deletions

View File

@@ -144,7 +144,7 @@ namespace OpenRA.Mods.RA.Traits
tileBlocked = self.World.Map.SequenceProvider.GetSequence("overlay", "build-invalid").GetSprite(0);
}
public IEnumerable<Order> Order(World world, CPos xy, MouseInput mi)
public IEnumerable<Order> Order(World world, CPos cell, int2 worldPixel, MouseInput mi)
{
if (mi.Button == Game.Settings.Game.MouseButtonPreference.Cancel)
{
@@ -160,7 +160,7 @@ namespace OpenRA.Mods.RA.Traits
if (mi.Button == Game.Settings.Game.MouseButtonPreference.Action && underCursor == null)
{
minelayer.World.CancelInputMode();
yield return new Order("PlaceMinefield", minelayer, false) { TargetLocation = xy };
yield return new Order("PlaceMinefield", minelayer, false) { TargetLocation = cell };
}
}
@@ -190,7 +190,10 @@ namespace OpenRA.Mods.RA.Traits
}
}
public string GetCursor(World world, CPos xy, MouseInput mi) { lastMousePos = xy; return "ability"; } /* TODO */
public string GetCursor(World world, CPos cell, int2 worldPixel, MouseInput mi)
{
lastMousePos = cell; return "ability"; /* TODO */
}
}
class BeginMinefieldOrderTargeter : IOrderTargeter

View File

@@ -151,7 +151,7 @@ namespace OpenRA.Mods.RA.Traits
this.self = self;
}
public IEnumerable<Order> Order(World world, CPos xy, MouseInput mi)
public IEnumerable<Order> Order(World world, CPos cell, int2 worldPixel, MouseInput mi)
{
if (mi.Button == Game.Settings.Game.MouseButtonPreference.Cancel)
{
@@ -159,11 +159,11 @@ namespace OpenRA.Mods.RA.Traits
yield break;
}
if (self.IsInWorld && self.Location != xy
&& self.Trait<PortableChrono>().CanTeleport && self.Owner.Shroud.IsExplored(xy))
if (self.IsInWorld && self.Location != cell
&& self.Trait<PortableChrono>().CanTeleport && self.Owner.Shroud.IsExplored(cell))
{
world.CancelInputMode();
yield return new Order("PortableChronoTeleport", self, mi.Modifiers.HasModifier(Modifiers.Shift)) { TargetLocation = xy };
yield return new Order("PortableChronoTeleport", self, mi.Modifiers.HasModifier(Modifiers.Shift)) { TargetLocation = cell };
}
}
@@ -194,10 +194,10 @@ namespace OpenRA.Mods.RA.Traits
Color.FromArgb(96, Color.Black));
}
public string GetCursor(World world, CPos xy, MouseInput mi)
public string GetCursor(World world, CPos cell, int2 worldPixel, MouseInput mi)
{
if (self.IsInWorld && self.Location != xy
&& self.Trait<PortableChrono>().CanTeleport && self.Owner.Shroud.IsExplored(xy))
if (self.IsInWorld && self.Location != cell
&& self.Trait<PortableChrono>().CanTeleport && self.Owner.Shroud.IsExplored(cell))
return "chrono-target";
else
return "move-blocked";

View File

@@ -115,11 +115,11 @@ namespace OpenRA.Mods.RA.Traits
tile = world.Map.SequenceProvider.GetSequence("overlay", "target-select").GetSprite(0);
}
public IEnumerable<Order> Order(World world, CPos xy, MouseInput mi)
public IEnumerable<Order> Order(World world, CPos cell, int2 worldPixel, MouseInput mi)
{
world.CancelInputMode();
if (mi.Button == MouseButton.Left)
world.OrderGenerator = new SelectDestination(world, order, manager, power, xy);
world.OrderGenerator = new SelectDestination(world, order, manager, power, cell);
yield break;
}
@@ -150,7 +150,7 @@ namespace OpenRA.Mods.RA.Traits
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)
public string GetCursor(World world, CPos cell, int2 worldPixel, MouseInput mi)
{
return "chrono-select";
}
@@ -179,7 +179,7 @@ namespace OpenRA.Mods.RA.Traits
sourceTile = world.Map.SequenceProvider.GetSequence("overlay", "target-select").GetSprite(0);
}
public IEnumerable<Order> Order(World world, CPos xy, MouseInput mi)
public IEnumerable<Order> Order(World world, CPos cell, int2 worldPixel, MouseInput mi)
{
if (mi.Button == MouseButton.Right)
{
@@ -187,7 +187,7 @@ namespace OpenRA.Mods.RA.Traits
yield break;
}
var ret = OrderInner(xy).FirstOrDefault();
var ret = OrderInner(cell).FirstOrDefault();
if (ret == null)
yield break;
@@ -281,9 +281,9 @@ namespace OpenRA.Mods.RA.Traits
return canTeleport;
}
public string GetCursor(World world, CPos xy, MouseInput mi)
public string GetCursor(World world, CPos cell, int2 worldPixel, MouseInput mi)
{
return IsValidTarget(xy) ? "chrono-target" : "move-blocked";
return IsValidTarget(cell) ? "chrono-target" : "move-blocked";
}
}
}