From bf6c30e9ef1bd01badacdd8809f2b69a599e1c96 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Mon, 28 Dec 2009 12:54:43 +1300 Subject: [PATCH] air units are targetable --- OpenRa.Game/Actor.cs | 7 ++----- OpenRa.Game/Controller.cs | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/OpenRa.Game/Actor.cs b/OpenRa.Game/Actor.cs index 1091e3a71a..bf32437eaf 100755 --- a/OpenRa.Game/Actor.cs +++ b/OpenRa.Game/Actor.cs @@ -92,11 +92,8 @@ namespace OpenRa.Game if (!Rules.Map.IsInMap(xy.X, xy.Y)) return null; - // HACK: Get the first unit in the cell - // This will need to be updated for multiple-infantry-in-a-cell - // HACK: this doesn't work for targeting air units either - var underCursor = Game.UnitInfluence.GetUnitsAt( xy ).FirstOrDefault() - ?? Game.BuildingInfluence.GetBuildingAt( xy ); + var loc = mi.Location + Game.viewport.Location; + var underCursor = Game.FindUnits(loc, loc).FirstOrDefault(); if (underCursor != null && !underCursor.Info.Selectable) underCursor = null; diff --git a/OpenRa.Game/Controller.cs b/OpenRa.Game/Controller.cs index a1c0dc38a8..c51f7f6499 100644 --- a/OpenRa.Game/Controller.cs +++ b/OpenRa.Game/Controller.cs @@ -124,7 +124,7 @@ namespace OpenRa.Game { var mods = GetModifierKeys(); var c = (orderGenerator is UnitOrderGenerator) ? orderGenerator.Order(dragEnd.ToInt2(), - new MouseInput { Button = MouseButton.Right, Modifiers = mods }) + new MouseInput { Location = (Game.CellSize * dragEnd - Game.viewport.Location).ToInt2(), Button = MouseButton.Right, Modifiers = mods }) .Where(o => o.Validate()) .Select(o => CursorForOrderString(o.OrderString, o.Subject, o.TargetLocation)) .FirstOrDefault(a => a != null) : null;