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

@@ -43,18 +43,24 @@ namespace OpenRa.Game
public List<int2> FindUnitPath( int2 from, int2 target, UnitMovementType umt ) public List<int2> FindUnitPath( int2 from, int2 target, UnitMovementType umt )
{ {
using( new PerfSample( "find_unit_path" ) ) 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 ) public List<int2> FindUnitPathToRange( int2 src, int2 target, UnitMovementType umt, int range )
{ {
using( new PerfSample( "find_unit_path_multiple_src" ) ) 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 ) ); .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(); path.Reverse();
return path; return path;
} }
@@ -124,7 +130,7 @@ namespace OpenRa.Game
/* make some progress on the first search */ /* make some progress on the first search */
var p = fromSrc.Expand( passableCost ); 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); return MakeBidiPath(fromSrc, fromDest, p);
/* make some progress on the second search */ /* make some progress on the second search */

View File

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

View File

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