diff --git a/OpenRa.Game/OpenRa.Game.csproj b/OpenRa.Game/OpenRa.Game.csproj
index d90d1bacc1..d29c73fcf3 100644
--- a/OpenRa.Game/OpenRa.Game.csproj
+++ b/OpenRa.Game/OpenRa.Game.csproj
@@ -73,7 +73,6 @@
-
@@ -118,6 +117,7 @@
+
diff --git a/OpenRa.Game/Bridges.cs b/OpenRa.Game/Traits/BridgeLoadHook.cs
similarity index 81%
rename from OpenRa.Game/Bridges.cs
rename to OpenRa.Game/Traits/BridgeLoadHook.cs
index 28d00bcdf0..1f045175fe 100644
--- a/OpenRa.Game/Bridges.cs
+++ b/OpenRa.Game/Traits/BridgeLoadHook.cs
@@ -2,13 +2,14 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
-using OpenRa.Traits;
-namespace OpenRa
+namespace OpenRa.Traits
{
- static class Bridges
+ class BridgeLoadHookInfo : StatelessTraitInfo { }
+
+ class BridgeLoadHook : ILoadWorldHook
{
- public static void MakeBridges(World w)
+ static void MakeBridges(World w)
{
var mini = w.Map.XOffset; var maxi = w.Map.XOffset + w.Map.Width;
var minj = w.Map.YOffset; var maxj = w.Map.YOffset + w.Map.Height;
@@ -40,8 +41,8 @@ namespace OpenRa
if (!template.TerrainType.ContainsKey(n)) continue;
if (w.Map.IsInMap(x, y))
- if (w.Map.MapTiles[x, y].tile == tile
- && w.Map.MapTiles[x,y].image == n)
+ if (w.Map.MapTiles[x, y].tile == tile
+ && w.Map.MapTiles[x, y].image == n)
{
// stash it
replacedTiles[new int2(x, y)] = w.Map.MapTiles[x, y].image;
@@ -63,5 +64,7 @@ namespace OpenRa
{
return w.TileSet.walk[t].Bridge != null;
}
+
+ public void WorldLoaded(World w) { MakeBridges(w); }
}
}
diff --git a/OpenRa.Game/Traits/TraitsInterfaces.cs b/OpenRa.Game/Traits/TraitsInterfaces.cs
index 4108aefc00..6fe8ff525a 100644
--- a/OpenRa.Game/Traits/TraitsInterfaces.cs
+++ b/OpenRa.Game/Traits/TraitsInterfaces.cs
@@ -102,4 +102,5 @@ namespace OpenRa.Traits
public interface ITraitPrerequisite { }
public interface INotifySelection { void SelectionChanged(); }
+ public interface ILoadWorldHook { void WorldLoaded(World w); }
}
diff --git a/OpenRa.Game/World.cs b/OpenRa.Game/World.cs
index 0691f62c39..f087859c01 100644
--- a/OpenRa.Game/World.cs
+++ b/OpenRa.Game/World.cs
@@ -77,9 +77,11 @@ namespace OpenRa
Queries = new AllQueries( this );
Timer.Time( "queries: {0}" );
- Bridges.MakeBridges(this);
+ foreach (var wlh in WorldActor.traits.WithInterface())
+ wlh.WorldLoaded(this);
+
PathFinder = new PathFinder(this);
- Timer.Time( "bridge, pathing: {0}" );
+ Timer.Time( "hooks, pathing: {0}" );
Minimap = new Minimap(this, Game.renderer);
Timer.Time( "minimap: {0}" );
diff --git a/mods/cnc/system.yaml b/mods/cnc/system.yaml
index 04bc7f83be..371a12d26d 100644
--- a/mods/cnc/system.yaml
+++ b/mods/cnc/system.yaml
@@ -14,6 +14,7 @@ World:
WaterPaletteRotation:
BuildingInfluence:
UnitInfluence:
+ BridgeLoadHook:
PaletteFromFile@terrain_temperat:
Name: terrain
Theater: temperat
diff --git a/mods/ra/rules.yaml b/mods/ra/rules.yaml
index 6ccd281a36..f587ba79d3 100644
--- a/mods/ra/rules.yaml
+++ b/mods/ra/rules.yaml
@@ -72,6 +72,7 @@ World:
BuildingInfluence:
UnitInfluence:
ChoosePaletteOnSelect:
+ BridgeLoadHook:
PaletteFromFile@terrain_temperat:
Name: terrain
Filename: temperat.pal