Merge branch 'master' of git@github.com:beedee/OpenRA
This commit is contained in:
@@ -11,6 +11,7 @@ namespace OpenRa.Game
|
|||||||
{
|
{
|
||||||
class BuildingInfluenceMap
|
class BuildingInfluenceMap
|
||||||
{
|
{
|
||||||
|
bool[,] blocked = new bool[128, 128];
|
||||||
Pair<Actor, float>[,] influence = new Pair<Actor, float>[128, 128];
|
Pair<Actor, float>[,] influence = new Pair<Actor, float>[128, 128];
|
||||||
readonly int maxDistance; /* clip limit for voronoi cells */
|
readonly int maxDistance; /* clip limit for voronoi cells */
|
||||||
static readonly Pair<Actor, float> NoClaim = Pair.New((Actor)null, float.MaxValue);
|
static readonly Pair<Actor, float> NoClaim = Pair.New((Actor)null, float.MaxValue);
|
||||||
@@ -31,7 +32,7 @@ namespace OpenRa.Game
|
|||||||
|
|
||||||
void AddInfluence(Actor a)
|
void AddInfluence(Actor a)
|
||||||
{
|
{
|
||||||
var tiles = Footprint.UnpathableTiles(a.unitInfo, a.Location).ToArray();
|
var tiles = Footprint.Tiles(a).ToArray();
|
||||||
var min = int2.Max(new int2(0, 0),
|
var min = int2.Max(new int2(0, 0),
|
||||||
tiles.Aggregate(int2.Min) - new int2(maxDistance, maxDistance));
|
tiles.Aggregate(int2.Min) - new int2(maxDistance, maxDistance));
|
||||||
var max = int2.Min(new int2(128, 128),
|
var max = int2.Min(new int2(128, 128),
|
||||||
@@ -41,6 +42,10 @@ namespace OpenRa.Game
|
|||||||
|
|
||||||
var initialTileCount = 0;
|
var initialTileCount = 0;
|
||||||
|
|
||||||
|
foreach (var u in Footprint.UnpathableTiles(a.unitInfo, a.Location))
|
||||||
|
if (IsValid(u))
|
||||||
|
blocked[u.X, u.Y] = true;
|
||||||
|
|
||||||
foreach (var t in tiles)
|
foreach (var t in tiles)
|
||||||
if (IsValid(t))
|
if (IsValid(t))
|
||||||
{
|
{
|
||||||
@@ -98,11 +103,15 @@ namespace OpenRa.Game
|
|||||||
|
|
||||||
void RemoveInfluence(Actor a)
|
void RemoveInfluence(Actor a)
|
||||||
{
|
{
|
||||||
var tiles = Footprint.UnpathableTiles(a.unitInfo, a.Location).ToArray();
|
var tiles = Footprint.Tiles(a).ToArray();
|
||||||
var min = int2.Max(new int2(0, 0),
|
var min = int2.Max(new int2(0, 0),
|
||||||
tiles.Aggregate(int2.Min) - new int2(maxDistance, maxDistance));
|
tiles.Aggregate(int2.Min) - new int2(maxDistance, maxDistance));
|
||||||
var max = int2.Min(new int2(128, 128),
|
var max = int2.Min(new int2(128, 128),
|
||||||
tiles.Aggregate(int2.Max) + new int2(maxDistance, maxDistance));
|
tiles.Aggregate(int2.Max) + new int2(maxDistance, maxDistance));
|
||||||
|
|
||||||
|
foreach (var u in Footprint.UnpathableTiles(a.unitInfo, a.Location))
|
||||||
|
if (IsValid(u))
|
||||||
|
blocked[u.X, u.Y] = false;
|
||||||
|
|
||||||
for (var j = min.Y; j <= max.Y; j++)
|
for (var j = min.Y; j <= max.Y; j++)
|
||||||
for (var i = min.X; i <= max.X; i++)
|
for (var i = min.X; i <= max.X; i++)
|
||||||
@@ -149,6 +158,11 @@ namespace OpenRa.Game
|
|||||||
return (int)influence[cell.X, cell.Y].Second;
|
return (int)influence[cell.X, cell.Y].Second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool CanMoveHere(int2 cell)
|
||||||
|
{
|
||||||
|
return IsValid(cell) && !blocked[cell.X, cell.Y];
|
||||||
|
}
|
||||||
|
|
||||||
struct Cell : IComparable<Cell>
|
struct Cell : IComparable<Cell>
|
||||||
{
|
{
|
||||||
public int2 location;
|
public int2 location;
|
||||||
|
|||||||
@@ -143,6 +143,7 @@ namespace OpenRa.Game
|
|||||||
public static int RenderFrame = 0;
|
public static int RenderFrame = 0;
|
||||||
public static double RenderTime = 0.0;
|
public static double RenderTime = 0.0;
|
||||||
public static double TickTime = 0.0;
|
public static double TickTime = 0.0;
|
||||||
|
public static double OreTime = 0.0;
|
||||||
|
|
||||||
public static Stopwatch sw;
|
public static Stopwatch sw;
|
||||||
|
|
||||||
@@ -162,7 +163,9 @@ namespace OpenRa.Game
|
|||||||
|
|
||||||
if (--oreTicks == 0)
|
if (--oreTicks == 0)
|
||||||
{
|
{
|
||||||
map.GrowOre(p => IsCellBuildable(p, UnitMovementType.Wheel), SharedRandom);
|
var oresw = new Stopwatch();
|
||||||
|
map.GrowOre(p => IsCellBuildable(p, UnitMovementType.Wheel), SharedRandom);
|
||||||
|
OreTime = oresw.ElapsedTime();
|
||||||
oreTicks = oreFrequency;
|
oreTicks = oreFrequency;
|
||||||
}
|
}
|
||||||
world.Tick();
|
world.Tick();
|
||||||
|
|||||||
@@ -99,10 +99,11 @@ namespace OpenRa.Game.Graphics
|
|||||||
|
|
||||||
lineRenderer.Flush();
|
lineRenderer.Flush();
|
||||||
|
|
||||||
renderer.DrawText(string.Format("RenderFrame {0} ({2:F1} ms) Tick {1} ({3:F1} ms)",
|
renderer.DrawText(string.Format("RenderFrame {0} ({2:F1} ms) Tick {1} ({3:F1} ms) Ore ({4:F1} ms)",
|
||||||
Game.RenderFrame, Game.orderManager.FrameNumber,
|
Game.RenderFrame, Game.orderManager.FrameNumber,
|
||||||
Game.RenderTime * 1000,
|
Game.RenderTime * 1000,
|
||||||
Game.TickTime * 1000), new int2(5, 5), Color.White);
|
Game.TickTime * 1000,
|
||||||
|
Game.OreTime * 1000), new int2(5, 5), Color.White);
|
||||||
}
|
}
|
||||||
|
|
||||||
const float conditionYellow = 0.5f; /* todo: get these from gamerules */
|
const float conditionYellow = 0.5f; /* todo: get these from gamerules */
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ namespace OpenRa.Game
|
|||||||
for( int i = 0 ; i < path.Count ; i++ )
|
for( int i = 0 ; i < path.Count ; i++ )
|
||||||
{
|
{
|
||||||
var sl = path[ i ];
|
var sl = path[ i ];
|
||||||
if( i == 0 || Game.BuildingInfluence.GetBuildingAt( path[ i ] ) == null & Game.UnitInfluence.GetUnitAt( path[ i ] ) == null )
|
if( i == 0 || (Game.BuildingInfluence.CanMoveHere(path[i]) && Game.UnitInfluence.GetUnitAt( path[ i ] ) == null) )
|
||||||
{
|
{
|
||||||
queue.Add( new PathDistance( estimator( sl ), sl ) );
|
queue.Add( new PathDistance( estimator( sl ), sl ) );
|
||||||
cellInfo[ sl.X, sl.Y ] = new CellInfo( cost, prev, false );
|
cellInfo[ sl.X, sl.Y ] = new CellInfo( cost, prev, false );
|
||||||
@@ -105,7 +105,7 @@ namespace OpenRa.Game
|
|||||||
continue;
|
continue;
|
||||||
if( passableCost[(int)umt][ newHere.X, newHere.Y ] == double.PositiveInfinity )
|
if( passableCost[(int)umt][ newHere.X, newHere.Y ] == double.PositiveInfinity )
|
||||||
continue;
|
continue;
|
||||||
if (Game.BuildingInfluence.GetBuildingAt(newHere) != null)
|
if (!Game.BuildingInfluence.CanMoveHere(newHere))
|
||||||
continue;
|
continue;
|
||||||
if( checkForBlock && Game.UnitInfluence.GetUnitAt( newHere ) != null )
|
if( checkForBlock && Game.UnitInfluence.GetUnitAt( newHere ) != null )
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -15,6 +15,12 @@ namespace OpenRa.Game.Traits.Activities
|
|||||||
{
|
{
|
||||||
if (isDone)
|
if (isDone)
|
||||||
{
|
{
|
||||||
|
var harv = self.traits.Get<Harvester>();
|
||||||
|
|
||||||
|
/* todo: give cash */
|
||||||
|
harv.gemsCarried = 0;
|
||||||
|
harv.oreCarried = 0;
|
||||||
|
|
||||||
mobile.InternalSetActivity(NextActivity);
|
mobile.InternalSetActivity(NextActivity);
|
||||||
/* todo: return to the ore patch */
|
/* todo: return to the ore patch */
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -33,9 +33,9 @@ namespace OpenRa.Game.Traits.Activities
|
|||||||
|
|
||||||
static bool CanEnterCell( int2 c, Actor self )
|
static bool CanEnterCell( int2 c, Actor self )
|
||||||
{
|
{
|
||||||
|
if (!Game.BuildingInfluence.CanMoveHere(c)) return false;
|
||||||
var u = Game.UnitInfluence.GetUnitAt( c );
|
var u = Game.UnitInfluence.GetUnitAt( c );
|
||||||
var b = Game.BuildingInfluence.GetBuildingAt( c );
|
return (u == null || u == self);
|
||||||
return ( u == null || u == self ) && b == null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Tick( Actor self, Mobile mobile )
|
public void Tick( Actor self, Mobile mobile )
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ namespace OpenRa.Game.Traits
|
|||||||
class Harvester : IOrder
|
class Harvester : IOrder
|
||||||
{
|
{
|
||||||
const int capacity = 28;
|
const int capacity = 28;
|
||||||
int oreCarried = 0; /* sum of these must not exceed capacity */
|
public int oreCarried = 0; /* sum of these must not exceed capacity */
|
||||||
int gemsCarried = 0;
|
public int gemsCarried = 0;
|
||||||
|
|
||||||
public bool IsFull { get { return oreCarried + gemsCarried == capacity; } }
|
public bool IsFull { get { return oreCarried + gemsCarried == capacity; } }
|
||||||
public bool IsEmpty { get { return oreCarried == 0 && gemsCarried == 0; } }
|
public bool IsEmpty { get { return oreCarried == 0 && gemsCarried == 0; } }
|
||||||
|
|||||||
Reference in New Issue
Block a user