Fixed the building placement to have the cursor in the centre. Replaced magic numbers with Game.CellSize

Using the building footprint, the placement overlay is offset from the cursor so the cursor is in the approximate middle of the overlay (not precisely due to overlay snapping to tiles). The tile size (24) was used as a magic number in a lot of places, they have been replaced with Game.CellSize.
This commit is contained in:
Matthew Bowra-Dean
2009-10-15 03:16:44 +13:00
parent 00cf322feb
commit fe78e22747
14 changed files with 37 additions and 22 deletions

View File

@@ -214,7 +214,15 @@ namespace OpenRa.Game
game.world.AddFrameEndTask(_ =>
{
Log.Write("Player \"{0}\" builds {1}", building.Owner.PlayerName, building.Name);
game.world.Add(new Actor(building.Name, xy, building.Owner));
//Adjust placement for cursor to be in middle
var footprint = Rules.Footprint.GetFootprint(building.Name);
int maxWidth = 0;
foreach (var row in footprint)
if (row.Length > maxWidth)
maxWidth = row.Length;
game.world.Add(new Actor(building.Name, xy - new int2(maxWidth / 2, footprint.Length / 2), building.Owner));
game.controller.orderGenerator = null;
game.worldRenderer.uiOverlay.KillOverlay();