lots of stuff fixed; production completion sounds work too.

This commit is contained in:
Chris Forbes
2009-11-08 20:32:07 +13:00
parent 5fd7f477c1
commit f22170800a
3 changed files with 25 additions and 21 deletions

View File

@@ -44,17 +44,23 @@ namespace OpenRa.Game
public List<int2> FindUnitPath( int2 from, int2 target, UnitMovementType umt )
{
using (new PerfSample("find_unit_path"))
return FindPath( PathSearch.FromPoint( from, target, umt, false ) );
{
var pb = FindBidiPath(
PathSearch.FromPoint(target, from, umt, false),
PathSearch.FromPoint(from, target, umt, false));
return pb;
}
}
public List<int2> FindUnitPathToRange( int2 src, int2 target, UnitMovementType umt, int range )
{
using( new PerfSample( "find_unit_path_multiple_src" ) )
{
var tilesInRange = Game.FindTilesInCircle( src, range )
var tilesInRange = Game.FindTilesInCircle(target, range)
.Where( t => Game.IsCellBuildable( t, umt ) );
var path = FindPath( PathSearch.FromPoints( tilesInRange, target, umt, false ));
var path = FindPath( PathSearch.FromPoints( tilesInRange, src, umt, false ));
path.Reverse();
return path;
}
@@ -124,7 +130,7 @@ namespace OpenRa.Game
/* make some progress on the first search */
var p = fromSrc.Expand( passableCost );
if (fromDest.cellInfo[p.X, p.Y].MinCost < float.PositiveInfinity)
if (fromDest.cellInfo[p.X, p.Y].Seen && fromDest.cellInfo[p.X, p.Y].MinCost < float.PositiveInfinity)
return MakeBidiPath(fromSrc, fromDest, p);
/* make some progress on the second search */

View File

@@ -34,26 +34,17 @@ namespace OpenRa.Game
public bool TakeCash( int num )
{
if (Cash >= num)
{
if (Cash < num) return false;
Cash -= num;
return true;
}
return false;
// TODO: decrease cash.
// returns: if enough cash was available, true
//return true;
}
public void Tick()
{
foreach( var p in production )
{
if( p.Value != null )
p.Value.Tick( this );
}
}
// Key: Production category. Categories are: Building, Infantry, Vehicle, Ship, Plane (and one per super, if they're done in here)
readonly Dictionary<string, ProductionItem> production = new Dictionary<string, ProductionItem>();

View File

@@ -96,10 +96,17 @@ namespace OpenRa.Game
time = .05f * time; /* temporary hax so we can build stuff fast for test */
Action complete = null;
if( group != "Building" ) complete = () => Game.world.AddFrameEndTask( _ => Game.BuildUnit( order.Player, order.TargetString ) );
order.Player.BeginProduction( group, new ProductionItem( order.TargetString, (int)time, ui.Cost, complete ) );
order.Player.BeginProduction(group,
new ProductionItem(order.TargetString, (int)time, ui.Cost,
() => Game.world.AddFrameEndTask(
_ =>
{
if (order.Player == Game.LocalPlayer)
Game.PlaySound(group == "Building"
? "conscmp1.aud" : "unitrdy1.aud", false);
if (group != "Building")
Game.BuildUnit(order.Player, order.TargetString);
})));
break;
}
case "PauseProduction":