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

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