IWallConnectorInfo to allow gates connect to walls in map editor
This commit is contained in:
@@ -17,7 +17,7 @@ using OpenRA.Traits;
|
|||||||
|
|
||||||
namespace OpenRA.Mods.Common.Traits
|
namespace OpenRA.Mods.Common.Traits
|
||||||
{
|
{
|
||||||
class WithGateSpriteBodyInfo : WithSpriteBodyInfo, Requires<GateInfo>
|
class WithGateSpriteBodyInfo : WithSpriteBodyInfo, IWallConnectorInfo, Requires<GateInfo>
|
||||||
{
|
{
|
||||||
[Desc("Cells (outside the gate footprint) that contain wall cells that can connect to the gate")]
|
[Desc("Cells (outside the gate footprint) that contain wall cells that can connect to the gate")]
|
||||||
public readonly CVec[] WallConnections = { };
|
public readonly CVec[] WallConnections = { };
|
||||||
@@ -34,6 +34,11 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
yield return new SpriteActorPreview(anim, WVec.Zero, 0, p, rs.Scale);
|
yield return new SpriteActorPreview(anim, WVec.Zero, 0, p, rs.Scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string IWallConnectorInfo.GetWallConnectionType()
|
||||||
|
{
|
||||||
|
return Type;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class WithGateSpriteBody : WithSpriteBody, INotifyRemovedFromWorld, INotifyBuildComplete, IWallConnector
|
class WithGateSpriteBody : WithSpriteBody, INotifyRemovedFromWorld, INotifyBuildComplete, IWallConnector
|
||||||
|
|||||||
@@ -17,8 +17,14 @@ using OpenRA.Traits;
|
|||||||
|
|
||||||
namespace OpenRA.Mods.Common.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.")]
|
[Desc("Render trait for actors that change sprites if neighbors with the same trait are present.")]
|
||||||
class WithWallSpriteBodyInfo : WithSpriteBodyInfo, Requires<BuildingInfo>
|
class WithWallSpriteBodyInfo : WithSpriteBodyInfo, IWallConnectorInfo, Requires<BuildingInfo>
|
||||||
{
|
{
|
||||||
public readonly string Type = "wall";
|
public readonly string Type = "wall";
|
||||||
|
|
||||||
@@ -40,8 +46,8 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
var haveNeighbour = false;
|
var haveNeighbour = false;
|
||||||
foreach (var n in kv.Value)
|
foreach (var n in kv.Value)
|
||||||
{
|
{
|
||||||
var rb = init.World.Map.Rules.Actors[n].TraitInfos<WithWallSpriteBodyInfo>().FirstOrDefault(Exts.IsTraitEnabled);
|
var rb = init.World.Map.Rules.Actors[n].TraitInfos<IWallConnectorInfo>().FirstOrDefault(Exts.IsTraitEnabled);
|
||||||
if (rb != null && rb.Type == Type)
|
if (rb != null && rb.GetWallConnectionType() == Type)
|
||||||
{
|
{
|
||||||
haveNeighbour = true;
|
haveNeighbour = true;
|
||||||
break;
|
break;
|
||||||
@@ -67,6 +73,11 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
yield return new SpriteActorPreview(anim, WVec.Zero, 0, p, rs.Scale);
|
yield return new SpriteActorPreview(anim, WVec.Zero, 0, p, rs.Scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string IWallConnectorInfo.GetWallConnectionType()
|
||||||
|
{
|
||||||
|
return Type;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class WithWallSpriteBody : WithSpriteBody, INotifyRemovedFromWorld, IWallConnector, ITick
|
class WithWallSpriteBody : WithSpriteBody, INotifyRemovedFromWorld, IWallConnector, ITick
|
||||||
|
|||||||
Reference in New Issue
Block a user