.Trait[OrDefault]<Trait> => .Info.Traits.Get[OrDefault]<TraitInfo> where applicable
This commit is contained in:
@@ -70,7 +70,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
class Bridge : IRender, INotifyDamageStateChanged
|
||||
{
|
||||
readonly Building building;
|
||||
readonly BuildingInfo building;
|
||||
readonly Bridge[] neighbours = new Bridge[2];
|
||||
readonly BridgeHut[] huts = new BridgeHut[2]; // Huts before this / first & after this / last
|
||||
readonly Health health;
|
||||
@@ -93,7 +93,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
this.info = info;
|
||||
type = self.Info.Name;
|
||||
isDangling = new Lazy<bool>(() => huts[0] == huts[1] && (neighbours[0] == null || neighbours[1] == null));
|
||||
building = self.Trait<Building>();
|
||||
building = self.Info.Traits.Get<BuildingInfo>();
|
||||
}
|
||||
|
||||
public Bridge Neighbour(int direction) { return neighbours[direction]; }
|
||||
@@ -173,7 +173,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
IRenderable[] TemplateRenderables(WorldRenderer wr, PaletteReference palette, ushort template)
|
||||
{
|
||||
var offset = FootprintUtils.CenterOffset(self.World, building.Info).Y + 1024;
|
||||
var offset = FootprintUtils.CenterOffset(self.World, building).Y + 1024;
|
||||
|
||||
return footprint.Select(c => (IRenderable)(new SpriteRenderable(
|
||||
wr.Theater.TileSprite(new TerrainTile(template, c.Value)),
|
||||
|
||||
@@ -31,22 +31,22 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
world.ActorAdded += a =>
|
||||
{
|
||||
var b = a.TraitOrDefault<Building>();
|
||||
var b = a.Info.Traits.GetOrDefault<BuildingInfo>();
|
||||
if (b == null)
|
||||
return;
|
||||
|
||||
foreach (var u in FootprintUtils.Tiles(map.Rules, a.Info.Name, b.Info, a.Location))
|
||||
foreach (var u in FootprintUtils.Tiles(map.Rules, a.Info.Name, b, a.Location))
|
||||
if (influence.Contains(u) && influence[u] == null)
|
||||
influence[u] = a;
|
||||
};
|
||||
|
||||
world.ActorRemoved += a =>
|
||||
{
|
||||
var b = a.TraitOrDefault<Building>();
|
||||
var b = a.Info.Traits.GetOrDefault<BuildingInfo>();
|
||||
if (b == null)
|
||||
return;
|
||||
|
||||
foreach (var u in FootprintUtils.Tiles(map.Rules, a.Info.Name, b.Info, a.Location))
|
||||
foreach (var u in FootprintUtils.Tiles(map.Rules, a.Info.Name, b, a.Location))
|
||||
if (influence.Contains(u) && influence[u] == a)
|
||||
influence[u] = null;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user