diff --git a/OpenRa.Game/Shroud.cs b/OpenRa.Game/Shroud.cs index b3a9e0adc2..8943aaa216 100644 --- a/OpenRa.Game/Shroud.cs +++ b/OpenRa.Game/Shroud.cs @@ -137,7 +137,7 @@ namespace OpenRa internal void Draw(SpriteRenderer r) { - return; + return; // temp; just so i can see until i'm done with the bridges. if (dirty) { diff --git a/OpenRa.Game/Traits/Bridge.cs b/OpenRa.Game/Traits/Bridge.cs index e626e2c93d..43b5b5635a 100644 --- a/OpenRa.Game/Traits/Bridge.cs +++ b/OpenRa.Game/Traits/Bridge.cs @@ -12,11 +12,11 @@ namespace OpenRa.Traits public object Create(Actor self) { return new Bridge(); } } - class Bridge : IRender, ITick + class Bridge : IRender, ITick, ICustomTerrain { Animation anim; - - public Bridge() {} + Dictionary Tiles; + TileTemplate Template; public IEnumerable Render(Actor self) { @@ -37,7 +37,18 @@ namespace OpenRa.Traits public void SetTiles(TileTemplate template, Dictionary replacedTiles) { - /* todo: stash these, etc */ + Template = template; + Tiles = replacedTiles; + + foreach (var t in replacedTiles.Keys) + Game.world.customTerrain[t.X, t.Y] = this; + } + + public double GetCost(int2 p, UnitMovementType umt) + { + var origTile = Tiles[p]; // if this explodes, then SetTiles did something horribly wrong. + + return 1.0; } } } diff --git a/OpenRa.Game/Traits/TraitsInterfaces.cs b/OpenRa.Game/Traits/TraitsInterfaces.cs index cc7afc4569..51f401d358 100644 --- a/OpenRa.Game/Traits/TraitsInterfaces.cs +++ b/OpenRa.Game/Traits/TraitsInterfaces.cs @@ -25,6 +25,8 @@ namespace OpenRa.Traits public interface IAcceptThief { void OnSteal(Actor self, Actor thief); } public interface IAcceptSpy { void OnInfiltrate(Actor self, Actor spy); } + public interface ICustomTerrain { double GetCost(int2 p, UnitMovementType umt); } + interface IProducer { bool Produce( Actor self, ActorInfo producee ); diff --git a/OpenRa.Game/World.cs b/OpenRa.Game/World.cs index bd68474af9..26e46e35e7 100644 --- a/OpenRa.Game/World.cs +++ b/OpenRa.Game/World.cs @@ -4,6 +4,7 @@ using OpenRa.Effects; using OpenRa.Support; using OpenRa.FileFormats; using OpenRa.Graphics; +using OpenRa.Traits; namespace OpenRa { @@ -21,6 +22,9 @@ namespace OpenRa public readonly Map Map; public readonly TileSet TileSet; + // for tricky things like bridges. + public readonly ICustomTerrain[,] customTerrain = new ICustomTerrain[128, 128]; + public readonly WorldRenderer WorldRenderer; internal readonly Minimap Minimap;