ICustomTerrain; more bridge code

This commit is contained in:
Chris Forbes
2010-01-19 09:35:42 +13:00
parent d56e2c8e26
commit 77418f4227
4 changed files with 22 additions and 5 deletions

View File

@@ -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)
{

View File

@@ -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<int2, int> Tiles;
TileTemplate Template;
public IEnumerable<Renderable> Render(Actor self)
{
@@ -37,7 +37,18 @@ namespace OpenRa.Traits
public void SetTiles(TileTemplate template, Dictionary<int2, int> 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;
}
}
}

View File

@@ -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 );

View File

@@ -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;