cleaning techtree & sidebar; building placement is mostly fixed
This commit is contained in:
@@ -173,70 +173,4 @@ namespace OpenRa.Game
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class PlaceBuilding : IOrderGenerator
|
||||
{
|
||||
public readonly Player Owner;
|
||||
public readonly string Name;
|
||||
|
||||
public PlaceBuilding( Player owner, string name )
|
||||
{
|
||||
Owner = owner;
|
||||
Name = name;
|
||||
}
|
||||
|
||||
public IEnumerable<Order> Order( int2 xy )
|
||||
{
|
||||
// todo: check that space is free
|
||||
yield return new PlaceBuildingOrder( this, xy );
|
||||
}
|
||||
|
||||
public void PrepareOverlay(int2 xy)
|
||||
{
|
||||
Game.worldRenderer.uiOverlay.SetCurrentOverlay(xy, Name);
|
||||
}
|
||||
}
|
||||
|
||||
class PlaceBuildingOrder : Order
|
||||
{
|
||||
PlaceBuilding building;
|
||||
int2 xy;
|
||||
|
||||
public PlaceBuildingOrder(PlaceBuilding building, int2 xy)
|
||||
{
|
||||
this.building = building;
|
||||
this.xy = xy;
|
||||
}
|
||||
|
||||
public override void Apply(bool leftMouseButton)
|
||||
{
|
||||
if (leftMouseButton)
|
||||
{
|
||||
Game.world.AddFrameEndTask(_ =>
|
||||
{
|
||||
Log.Write("Player \"{0}\" builds {1}", building.Owner.PlayerName, building.Name);
|
||||
|
||||
//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();
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
Game.world.AddFrameEndTask(_ =>
|
||||
{
|
||||
Game.controller.orderGenerator = null;
|
||||
Game.worldRenderer.uiOverlay.KillOverlay();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user