lots of stuff fixed; production completion sounds work too.
This commit is contained in:
@@ -43,18 +43,24 @@ 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 ) );
|
||||
using (new PerfSample("find_unit_path"))
|
||||
{
|
||||
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 */
|
||||
|
||||
@@ -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>();
|
||||
|
||||
@@ -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":
|
||||
|
||||
Reference in New Issue
Block a user