unhacking most of that mess.
This commit is contained in:
@@ -8,8 +8,9 @@ namespace OpenRa.FileFormats
|
||||
{
|
||||
public readonly Dictionary<ushort, Terrain> tiles = new Dictionary<ushort, Terrain>();
|
||||
|
||||
public readonly Dictionary<ushort, TileTemplate> walk =
|
||||
new Dictionary<ushort, TileTemplate>(); // cjf will fix
|
||||
public readonly Walkability Walkability = new Walkability();
|
||||
public readonly Dictionary<ushort, TileTemplate> walk
|
||||
= new Dictionary<ushort, TileTemplate>();
|
||||
|
||||
string NextLine( StreamReader reader )
|
||||
{
|
||||
@@ -27,7 +28,7 @@ namespace OpenRa.FileFormats
|
||||
|
||||
public TileSet( string suffix )
|
||||
{
|
||||
Walkability walkability = new Walkability();
|
||||
Walkability = new Walkability();
|
||||
|
||||
char tileSetChar = char.ToUpperInvariant( suffix[ 1 ] );
|
||||
StreamReader tileIdFile = new StreamReader( FileSystem.Open( "tileSet.til" ) );
|
||||
@@ -51,7 +52,7 @@ namespace OpenRa.FileFormats
|
||||
string tilename = string.Format(pattern, i + 1);
|
||||
|
||||
if (!walk.ContainsKey((ushort)(start + i)))
|
||||
walk.Add((ushort)(start + i), walkability.GetWalkability(tilename));
|
||||
walk.Add((ushort)(start + i), Walkability.GetWalkability(tilename));
|
||||
|
||||
using( Stream s = FileSystem.Open( tilename + suffix ) )
|
||||
{
|
||||
|
||||
@@ -14,9 +14,9 @@ namespace OpenRa.FileFormats
|
||||
public Dictionary<int, int> TerrainType = new Dictionary<int, int>();
|
||||
}
|
||||
|
||||
class Walkability
|
||||
public class Walkability
|
||||
{
|
||||
public Dictionary<string, TileTemplate> walkability
|
||||
Dictionary<string, TileTemplate> walkability
|
||||
= new Dictionary<string,TileTemplate>();
|
||||
|
||||
public Walkability()
|
||||
|
||||
@@ -11,15 +11,17 @@ namespace OpenRa.Traits
|
||||
{
|
||||
class BridgeInfo : ITraitInfo
|
||||
{
|
||||
public readonly bool Long = false;
|
||||
public object Create(Actor self) { return new Bridge(self); }
|
||||
}
|
||||
|
||||
class Bridge : IRender, ICustomTerrain
|
||||
{
|
||||
Dictionary<int2, int> Tiles;
|
||||
TileTemplate Template;
|
||||
Dictionary<int2, Sprite> TileSprites;
|
||||
List<Dictionary<int2, Sprite>> TileSprites = new List<Dictionary<int2,Sprite>>();
|
||||
List<TileTemplate> Templates = new List<TileTemplate>();
|
||||
Actor self;
|
||||
int state;
|
||||
|
||||
public Bridge(Actor self) { this.self = self; self.RemoveOnDeath = false; }
|
||||
|
||||
@@ -28,15 +30,14 @@ namespace OpenRa.Traits
|
||||
|
||||
public IEnumerable<Renderable> Render(Actor self)
|
||||
{
|
||||
if (Template == null) yield break;
|
||||
foreach (var t in TileSprites)
|
||||
foreach (var t in TileSprites[state])
|
||||
yield return new Renderable(t.Value, Game.CellSize * t.Key, PaletteType.Gold);
|
||||
}
|
||||
|
||||
public void SetTiles(World world, TileTemplate template, Dictionary<int2, int> replacedTiles)
|
||||
{
|
||||
Template = template;
|
||||
Tiles = replacedTiles;
|
||||
state = template.Name[template.Name.Length - 1] - 'a';
|
||||
|
||||
foreach (var t in replacedTiles.Keys)
|
||||
world.customTerrain[t.X, t.Y] = this;
|
||||
@@ -49,18 +50,31 @@ namespace OpenRa.Traits
|
||||
new Size(Game.CellSize, Game.CellSize)));
|
||||
}
|
||||
|
||||
TileSprites = replacedTiles.ToDictionary(
|
||||
a => a.Key,
|
||||
a => sprites[new TileReference { tile = (ushort)template.Index, image = (byte)a.Value }]);
|
||||
var numStates = self.Info.Traits.Get<BridgeInfo>().Long ? 6 : 3;
|
||||
for (var n = 0; n < numStates; n++)
|
||||
{
|
||||
var stateTemplate = world.TileSet.Walkability.GetWalkability(template.Bridge + (char)(n + 'a'));
|
||||
Templates.Add( stateTemplate );
|
||||
|
||||
TileSprites.Add(replacedTiles.ToDictionary(
|
||||
a => a.Key,
|
||||
a => sprites[new TileReference { tile = (ushort)stateTemplate.Index, image = (byte)a.Value }]));
|
||||
}
|
||||
|
||||
self.Health = (int)(self.GetMaxHP() * template.HP);
|
||||
}
|
||||
|
||||
public void FinalizeBridges(World world)
|
||||
{
|
||||
// go looking for our neighbors
|
||||
}
|
||||
|
||||
public float GetCost(int2 p, UnitMovementType umt)
|
||||
{
|
||||
return self.Health > 0
|
||||
? TerrainCosts.Cost(umt, Template.TerrainType[Tiles[p]])
|
||||
: TerrainCosts.Cost(umt, 1);
|
||||
// just use the standard walkability from templates.ini. no hackery.
|
||||
|
||||
return TerrainCosts.Cost(umt,
|
||||
Templates[state].TerrainType[Tiles[p]]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,3 +28,7 @@ MINV:
|
||||
Warhead: ATMine
|
||||
TriggeredBy: Wheel, Track
|
||||
AvoidFriendly: yes
|
||||
|
||||
BR3:
|
||||
Bridge:
|
||||
Long: yes
|
||||
21
ra.yaml
21
ra.yaml
@@ -83,6 +83,17 @@ MINV:
|
||||
-Selectable:
|
||||
-Building:
|
||||
|
||||
BR3:
|
||||
Bridge:
|
||||
Long: yes
|
||||
Category: Building
|
||||
Selectable:
|
||||
BelowUnits:
|
||||
Building:
|
||||
Footprint: ____ ____
|
||||
Dimensions: 4,2
|
||||
HP: 1000
|
||||
|
||||
V2RL:
|
||||
Inherits: ^Vehicle
|
||||
Buildable:
|
||||
@@ -1457,16 +1468,6 @@ BR2:
|
||||
Dimensions: 4,2
|
||||
HP: 1000
|
||||
|
||||
BR3:
|
||||
Category: Building
|
||||
Selectable:
|
||||
Bridge:
|
||||
BelowUnits:
|
||||
Building:
|
||||
Footprint: ____ ____
|
||||
Dimensions: 4,2
|
||||
HP: 1000
|
||||
|
||||
T01:
|
||||
Inherits: ^Building
|
||||
Building:
|
||||
|
||||
Reference in New Issue
Block a user