bridge pathing works
This commit is contained in:
@@ -56,7 +56,6 @@ namespace OpenRa
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
var custom = Game.world.customTerrain[newHere.X, newHere.Y];
|
var custom = Game.world.customTerrain[newHere.X, newHere.Y];
|
||||||
if (custom != null) throw new NotImplementedException();
|
|
||||||
var costHere = (custom != null) ? custom.GetCost(newHere, umt) : passableCost[(int)umt][newHere.X, newHere.Y];
|
var costHere = (custom != null) ? custom.GetCost(newHere, umt) : passableCost[(int)umt][newHere.X, newHere.Y];
|
||||||
|
|
||||||
if (costHere == float.PositiveInfinity)
|
if (costHere == float.PositiveInfinity)
|
||||||
|
|||||||
@@ -28,8 +28,8 @@ namespace OpenRa
|
|||||||
|
|
||||||
static class TerrainCosts
|
static class TerrainCosts
|
||||||
{
|
{
|
||||||
static double[][] costs = Util.MakeArray<double[]>( 4,
|
static float[][] costs = Util.MakeArray<float[]>(4,
|
||||||
a => Util.MakeArray<double>( 11, b => double.PositiveInfinity ));
|
a => Util.MakeArray<float>(11, b => float.PositiveInfinity));
|
||||||
|
|
||||||
static TerrainCosts()
|
static TerrainCosts()
|
||||||
{
|
{
|
||||||
@@ -40,12 +40,12 @@ namespace OpenRa
|
|||||||
for( int j = 0 ; j < 4 ; j++ )
|
for( int j = 0 ; j < 4 ; j++ )
|
||||||
{
|
{
|
||||||
string val = section.GetValue( ( (UnitMovementType)j ).ToString(), "0%" );
|
string val = section.GetValue( ( (UnitMovementType)j ).ToString(), "0%" );
|
||||||
costs[ j ][ i ] = 100.0 / double.Parse( val.Substring( 0, val.Length - 1 ) );
|
costs[j][i] = 100f / float.Parse(val.Substring(0, val.Length - 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double Cost( UnitMovementType unitMovementType, int r )
|
public static float Cost( UnitMovementType unitMovementType, int r )
|
||||||
{
|
{
|
||||||
return costs[ (byte)unitMovementType ][ r ];
|
return costs[ (byte)unitMovementType ][ r ];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ using System.Drawing;
|
|||||||
|
|
||||||
namespace OpenRa.Traits
|
namespace OpenRa.Traits
|
||||||
{
|
{
|
||||||
class BridgeInfo : OwnedActorInfo, ITraitInfo
|
class BridgeInfo : ITraitInfo
|
||||||
{
|
{
|
||||||
public object Create(Actor self) { return new Bridge(self); }
|
public object Create(Actor self) { return new Bridge(self); }
|
||||||
}
|
}
|
||||||
@@ -19,8 +19,9 @@ namespace OpenRa.Traits
|
|||||||
Dictionary<int2, int> Tiles;
|
Dictionary<int2, int> Tiles;
|
||||||
TileTemplate Template;
|
TileTemplate Template;
|
||||||
Dictionary<int2, Sprite> TileSprites;
|
Dictionary<int2, Sprite> TileSprites;
|
||||||
|
Actor self;
|
||||||
|
|
||||||
public Bridge(Actor self) { self.RemoveOnDeath = false; }
|
public Bridge(Actor self) { this.self = self; self.RemoveOnDeath = false; }
|
||||||
|
|
||||||
static string cachedTheater;
|
static string cachedTheater;
|
||||||
static Cache<TileReference, Sprite> sprites;
|
static Cache<TileReference, Sprite> sprites;
|
||||||
@@ -55,9 +56,9 @@ namespace OpenRa.Traits
|
|||||||
|
|
||||||
public float GetCost(int2 p, UnitMovementType umt)
|
public float GetCost(int2 p, UnitMovementType umt)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
return self.Health > 0
|
||||||
var origTile = Tiles[p]; // if this explodes, then SetTiles did something horribly wrong.
|
? TerrainCosts.Cost(umt, Template.TerrainType[Tiles[p]])
|
||||||
return float.PositiveInfinity;
|
: TerrainCosts.Cost(umt, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
9
ra.yaml
9
ra.yaml
@@ -1438,11 +1438,14 @@ DOMF:
|
|||||||
Fake:
|
Fake:
|
||||||
|
|
||||||
BRIDGE:
|
BRIDGE:
|
||||||
Inherits: ^Building
|
Category: Building
|
||||||
|
Selectable:
|
||||||
Bridge:
|
Bridge:
|
||||||
BelowUnits:
|
BelowUnits:
|
||||||
-Selectable:
|
Building:
|
||||||
-Building:
|
Footprint: ____ ____
|
||||||
|
Dimensions: 4,2
|
||||||
|
HP: 1000
|
||||||
|
|
||||||
T01:
|
T01:
|
||||||
Inherits: ^Building
|
Inherits: ^Building
|
||||||
|
|||||||
@@ -535,8 +535,11 @@ Traits=Unit,RenderUnit,BelowUnits,InvisibleToOthers
|
|||||||
Selectable=no
|
Selectable=no
|
||||||
|
|
||||||
[Bridge]
|
[Bridge]
|
||||||
Traits=Bridge, BelowUnits
|
Traits=Bridge, BelowUnits, Building
|
||||||
Selectable=no
|
Strength=1000
|
||||||
|
Dimensions=4,2
|
||||||
|
Footprint=____ ____
|
||||||
|
Selectable=yes ;; temp hack
|
||||||
|
|
||||||
[InfantryTypes]
|
[InfantryTypes]
|
||||||
DOG
|
DOG
|
||||||
|
|||||||
Reference in New Issue
Block a user