moved Game.PathFinder into World
This commit is contained in:
@@ -19,7 +19,6 @@ namespace OpenRa
|
|||||||
|
|
||||||
public static World world;
|
public static World world;
|
||||||
internal static Viewport viewport;
|
internal static Viewport viewport;
|
||||||
public static PathFinder PathFinder;
|
|
||||||
public static Controller controller;
|
public static Controller controller;
|
||||||
internal static Chrome chrome;
|
internal static Chrome chrome;
|
||||||
public static UserSettings Settings;
|
public static UserSettings Settings;
|
||||||
@@ -90,8 +89,6 @@ namespace OpenRa
|
|||||||
LoadMapActors(Rules.AllRules);
|
LoadMapActors(Rules.AllRules);
|
||||||
skipMakeAnims = false;
|
skipMakeAnims = false;
|
||||||
|
|
||||||
PathFinder = new PathFinder();
|
|
||||||
|
|
||||||
chrome = new Chrome(renderer);
|
chrome = new Chrome(renderer);
|
||||||
|
|
||||||
SpawnPoints = Rules.AllRules.GetSection("Waypoints")
|
SpawnPoints = Rules.AllRules.GetSection("Waypoints")
|
||||||
@@ -336,7 +333,7 @@ namespace OpenRa
|
|||||||
|
|
||||||
foreach (var t in Footprint.Tiles(buildingName, bi, position)) search.AddInitialCell(t);
|
foreach (var t in Footprint.Tiles(buildingName, bi, position)) search.AddInitialCell(t);
|
||||||
|
|
||||||
return Game.PathFinder.FindPath(search).Count != 0;
|
return Game.world.PathFinder.FindPath(search).Count != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SyncLobbyInfo(string data)
|
public static void SyncLobbyInfo(string data)
|
||||||
|
|||||||
@@ -11,15 +11,15 @@ namespace OpenRa
|
|||||||
{
|
{
|
||||||
float[][,] passableCost = new float[4][,];
|
float[][,] passableCost = new float[4][,];
|
||||||
|
|
||||||
public PathFinder()
|
public PathFinder( World world )
|
||||||
{
|
{
|
||||||
for (var umt = UnitMovementType.Foot; umt <= UnitMovementType.Float; umt++)
|
for (var umt = UnitMovementType.Foot; umt <= UnitMovementType.Float; umt++)
|
||||||
passableCost[(int)umt] = new float[128, 128];
|
passableCost[(int)umt] = new float[128, 128];
|
||||||
for( int x = 0 ; x < 128 ; x++ )
|
for( int x = 0 ; x < 128 ; x++ )
|
||||||
for( int y = 0 ; y < 128 ; y++ )
|
for( int y = 0 ; y < 128 ; y++ )
|
||||||
for (var umt = UnitMovementType.Foot; umt <= UnitMovementType.Float; umt++ )
|
for (var umt = UnitMovementType.Foot; umt <= UnitMovementType.Float; umt++ )
|
||||||
passableCost[(int)umt][ x, y ] = ( Game.world.Map.IsInMap( x, y ) )
|
passableCost[(int)umt][ x, y ] = ( world.Map.IsInMap( x, y ) )
|
||||||
? (float)TerrainCosts.Cost( umt, Game.world.TileSet.GetWalkability( Game.world.Map.MapTiles[ x, y ] ) )
|
? (float)TerrainCosts.Cost( umt, world.TileSet.GetWalkability( world.Map.MapTiles[ x, y ] ) )
|
||||||
: float.PositiveInfinity;
|
: float.PositiveInfinity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ namespace OpenRa.Traits.Activities
|
|||||||
foreach( var r in refineries )
|
foreach( var r in refineries )
|
||||||
search.AddInitialCell( r.Location + refineryDeliverOffset );
|
search.AddInitialCell( r.Location + refineryDeliverOffset );
|
||||||
|
|
||||||
var path = Game.PathFinder.FindPath( search );
|
var path = Game.world.PathFinder.FindPath( search );
|
||||||
path.Reverse();
|
path.Reverse();
|
||||||
if( path.Count != 0 )
|
if( path.Count != 0 )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ namespace OpenRa.Traits.Activities
|
|||||||
checkForBlocked = true
|
checkForBlocked = true
|
||||||
};
|
};
|
||||||
search.AddInitialCell(self.Location);
|
search.AddInitialCell(self.Location);
|
||||||
return Game.PathFinder.FindPath(search);
|
return Game.world.PathFinder.FindPath(search);
|
||||||
}));
|
}));
|
||||||
self.QueueActivity(new Harvest());
|
self.QueueActivity(new Harvest());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ namespace OpenRa.Traits.Activities
|
|||||||
|
|
||||||
public Move( int2 destination, int nearEnough )
|
public Move( int2 destination, int nearEnough )
|
||||||
{
|
{
|
||||||
this.getPath = ( self, mobile ) => Game.PathFinder.FindUnitPath(
|
this.getPath = ( self, mobile ) => Game.world.PathFinder.FindUnitPath(
|
||||||
self.Location, destination,
|
self.Location, destination,
|
||||||
mobile.GetMovementType() );
|
mobile.GetMovementType() );
|
||||||
this.destination = destination;
|
this.destination = destination;
|
||||||
@@ -30,9 +30,9 @@ namespace OpenRa.Traits.Activities
|
|||||||
public Move(int2 destination, Actor ignoreBuilding)
|
public Move(int2 destination, Actor ignoreBuilding)
|
||||||
{
|
{
|
||||||
this.getPath = (self, mobile) =>
|
this.getPath = (self, mobile) =>
|
||||||
Game.PathFinder.FindPath(
|
Game.world.PathFinder.FindPath(
|
||||||
PathSearch.FromPoint( self.Location, destination, mobile.GetMovementType(), false )
|
PathSearch.FromPoint( self.Location, destination, mobile.GetMovementType(), false )
|
||||||
.WithCustomBlocker( Game.PathFinder.AvoidUnitsNear( self.Location, 4 )).WithIgnoredBuilding( ignoreBuilding ));
|
.WithCustomBlocker( Game.world.PathFinder.AvoidUnitsNear( self.Location, 4 )).WithIgnoredBuilding( ignoreBuilding ));
|
||||||
|
|
||||||
this.destination = destination;
|
this.destination = destination;
|
||||||
this.nearEnough = 0;
|
this.nearEnough = 0;
|
||||||
@@ -41,7 +41,7 @@ namespace OpenRa.Traits.Activities
|
|||||||
|
|
||||||
public Move( Actor target, int range )
|
public Move( Actor target, int range )
|
||||||
{
|
{
|
||||||
this.getPath = ( self, mobile ) => Game.PathFinder.FindUnitPathToRange(
|
this.getPath = ( self, mobile ) => Game.world.PathFinder.FindUnitPathToRange(
|
||||||
self.Location, target.Location,
|
self.Location, target.Location,
|
||||||
mobile.GetMovementType(), range );
|
mobile.GetMovementType(), range );
|
||||||
this.destination = null;
|
this.destination = null;
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ namespace OpenRa
|
|||||||
public readonly BuildingInfluenceMap BuildingInfluence;
|
public readonly BuildingInfluenceMap BuildingInfluence;
|
||||||
public readonly UnitInfluenceMap UnitInfluence;
|
public readonly UnitInfluenceMap UnitInfluence;
|
||||||
|
|
||||||
|
public readonly PathFinder PathFinder;
|
||||||
|
|
||||||
public readonly Map Map;
|
public readonly Map Map;
|
||||||
public readonly TileSet TileSet;
|
public readonly TileSet TileSet;
|
||||||
|
|
||||||
@@ -37,6 +39,8 @@ namespace OpenRa
|
|||||||
oreTicks = oreFrequency;
|
oreTicks = oreFrequency;
|
||||||
Map.InitOreDensity();
|
Map.InitOreDensity();
|
||||||
|
|
||||||
|
PathFinder = new PathFinder(this);
|
||||||
|
|
||||||
CreateActor("World", new int2(int.MaxValue, int.MaxValue), null);
|
CreateActor("World", new int2(int.MaxValue, int.MaxValue), null);
|
||||||
|
|
||||||
WorldRenderer = new WorldRenderer(this, Game.renderer);
|
WorldRenderer = new WorldRenderer(this, Game.renderer);
|
||||||
|
|||||||
Reference in New Issue
Block a user