diff --git a/OpenRA.Mods.Common/Traits/Render/WithGateSpriteBody.cs b/OpenRA.Mods.Common/Traits/Render/WithGateSpriteBody.cs index 87ae9adebb..0f7eb940b1 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithGateSpriteBody.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithGateSpriteBody.cs @@ -17,7 +17,7 @@ using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits { - class WithGateSpriteBodyInfo : WithSpriteBodyInfo, Requires + class WithGateSpriteBodyInfo : WithSpriteBodyInfo, IWallConnectorInfo, Requires { [Desc("Cells (outside the gate footprint) that contain wall cells that can connect to the gate")] public readonly CVec[] WallConnections = { }; @@ -34,6 +34,11 @@ namespace OpenRA.Mods.Common.Traits yield return new SpriteActorPreview(anim, WVec.Zero, 0, p, rs.Scale); } + + string IWallConnectorInfo.GetWallConnectionType() + { + return Type; + } } class WithGateSpriteBody : WithSpriteBody, INotifyRemovedFromWorld, INotifyBuildComplete, IWallConnector diff --git a/OpenRA.Mods.Common/Traits/Render/WithWallSpriteBody.cs b/OpenRA.Mods.Common/Traits/Render/WithWallSpriteBody.cs index ac0a329d0d..1016e6a617 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithWallSpriteBody.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithWallSpriteBody.cs @@ -17,8 +17,14 @@ using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits { + [RequireExplicitImplementation] + interface IWallConnectorInfo : ITraitInfoInterface + { + string GetWallConnectionType(); + } + [Desc("Render trait for actors that change sprites if neighbors with the same trait are present.")] - class WithWallSpriteBodyInfo : WithSpriteBodyInfo, Requires + class WithWallSpriteBodyInfo : WithSpriteBodyInfo, IWallConnectorInfo, Requires { public readonly string Type = "wall"; @@ -40,8 +46,8 @@ namespace OpenRA.Mods.Common.Traits var haveNeighbour = false; foreach (var n in kv.Value) { - var rb = init.World.Map.Rules.Actors[n].TraitInfos().FirstOrDefault(Exts.IsTraitEnabled); - if (rb != null && rb.Type == Type) + var rb = init.World.Map.Rules.Actors[n].TraitInfos().FirstOrDefault(Exts.IsTraitEnabled); + if (rb != null && rb.GetWallConnectionType() == Type) { haveNeighbour = true; break; @@ -67,6 +73,11 @@ namespace OpenRA.Mods.Common.Traits yield return new SpriteActorPreview(anim, WVec.Zero, 0, p, rs.Scale); } + + string IWallConnectorInfo.GetWallConnectionType() + { + return Type; + } } class WithWallSpriteBody : WithSpriteBody, INotifyRemovedFromWorld, IWallConnector, ITick