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

@@ -17,7 +17,7 @@ namespace OpenRa.Game.Traits
if (first && self.Owner == game.LocalPlayer)
{
self.Owner.TechTree.Build(self.unitInfo.Name, true);
self.CenterLocation = 24 * (float2)self.Location + 0.5f * self.SelectedSize;
self.CenterLocation = Game.CellSize * (float2)self.Location + 0.5f * self.SelectedSize;
}
first = false;
}

View File

@@ -59,7 +59,7 @@ namespace OpenRa.Game.Traits
void UpdateCenterLocation()
{
float fraction = (moveFraction > 0) ? (float)moveFraction / moveFractionTotal : 0f;
self.CenterLocation = new float2(12, 12) + 24 * float2.Lerp(fromCell, toCell, fraction);
self.CenterLocation = new float2(12, 12) + Game.CellSize * float2.Lerp(fromCell, toCell, fraction);
}
public void Tick(Actor self, Game game, int dt)

View File

@@ -25,7 +25,7 @@ namespace OpenRa.Game.Traits
{
var mobile = self.traits.Get<Mobile>();
float fraction = (mobile.moveFraction > 0) ? (float)mobile.moveFraction / mobile.moveFractionTotal : 0f;
var centerLocation = new float2(12, 12) + 24 * float2.Lerp(mobile.fromCell, mobile.toCell, fraction);
var centerLocation = new float2(12, 12) + Game.CellSize * float2.Lerp(mobile.fromCell, mobile.toCell, fraction);
yield return Centered(anim.Image, centerLocation);
}
}

View File

@@ -18,7 +18,7 @@ namespace OpenRa.Game.Traits
public IEnumerable<Pair<Sprite, float2>> Render(Actor self)
{
yield return Pair.New(Image, 24 * (float2)self.Location);
yield return Pair.New(Image, Game.CellSize * (float2)self.Location);
}
}
}

View File

@@ -7,7 +7,7 @@ namespace OpenRa.Game.Traits
{
class Turreted : ITick // temporary.
{
public int turretFacing = 24;
public int turretFacing = Game.CellSize;
public Turreted(Actor self)
{