RenderBuildingWall -> WithWallSpriteBody
This commit is contained in:
@@ -411,7 +411,7 @@
|
||||
<Compile Include="Traits\Render\RenderNameTag.cs" />
|
||||
<Compile Include="Traits\Render\RenderSimple.cs" />
|
||||
<Compile Include="Traits\Render\RenderSprites.cs" />
|
||||
<Compile Include="Traits\Render\RenderBuildingWall.cs" />
|
||||
<Compile Include="Traits\Render\WithWallSpriteBody.cs" />
|
||||
<Compile Include="Traits\Render\RenderDetectionCircle.cs" />
|
||||
<Compile Include="Traits\Render\RenderRangeCircle.cs" />
|
||||
<Compile Include="Traits\Render\RenderVoxels.cs" />
|
||||
|
||||
@@ -17,11 +17,11 @@ using OpenRA.Traits;
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[Desc("Render trait for actors that change sprites if neighbors with the same trait are present.")]
|
||||
class RenderBuildingWallInfo : RenderBuildingInfo
|
||||
class WithWallSpriteBodyInfo : WithSpriteBodyInfo
|
||||
{
|
||||
public readonly string Type = "wall";
|
||||
|
||||
public override object Create(ActorInitializer init) { return new RenderBuildingWall(init, this); }
|
||||
public override object Create(ActorInitializer init) { return new WithWallSpriteBody(init, this); }
|
||||
|
||||
public override IEnumerable<IActorPreview> RenderPreviewSprites(ActorPreviewInitializer init, RenderSpritesInfo rs, string image, int facings, PaletteReference p)
|
||||
{
|
||||
@@ -39,7 +39,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
var haveNeighbour = false;
|
||||
foreach (var n in kv.Value)
|
||||
{
|
||||
var rb = init.World.Map.Rules.Actors[n].Traits.GetOrDefault<RenderBuildingWallInfo>();
|
||||
var rb = init.World.Map.Rules.Actors[n].Traits.GetOrDefault<WithWallSpriteBodyInfo>();
|
||||
if (rb != null && rb.Type == Type)
|
||||
{
|
||||
haveNeighbour = true;
|
||||
@@ -68,33 +68,26 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
}
|
||||
|
||||
class RenderBuildingWall : RenderBuilding, INotifyAddedToWorld, INotifyRemovedFromWorld
|
||||
class WithWallSpriteBody : WithSpriteBody, INotifyAddedToWorld, INotifyRemovedFromWorld, ITick
|
||||
{
|
||||
readonly RenderBuildingWallInfo info;
|
||||
readonly WithWallSpriteBodyInfo wallInfo;
|
||||
int adjacent = 0;
|
||||
bool dirty = true;
|
||||
|
||||
public RenderBuildingWall(ActorInitializer init, RenderBuildingWallInfo info)
|
||||
: base(init, info)
|
||||
public WithWallSpriteBody(ActorInitializer init, WithWallSpriteBodyInfo info)
|
||||
: base(init, info, () => 0)
|
||||
{
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
public override void BuildingComplete(Actor self)
|
||||
{
|
||||
DefaultAnimation.PlayFetchIndex(info.Sequence, () => adjacent);
|
||||
UpdateNeighbours(self);
|
||||
wallInfo = info;
|
||||
DefaultAnimation.PlayFetchIndex(NormalizeSequence(init.Self, Info.Sequence), () => adjacent);
|
||||
}
|
||||
|
||||
public override void DamageStateChanged(Actor self, AttackInfo e)
|
||||
{
|
||||
DefaultAnimation.PlayFetchIndex(NormalizeSequence(DefaultAnimation, e.DamageState, info.Sequence), () => adjacent);
|
||||
DefaultAnimation.PlayFetchIndex(NormalizeSequence(self, Info.Sequence), () => adjacent);
|
||||
}
|
||||
|
||||
public override void Tick(Actor self)
|
||||
public void Tick(Actor self)
|
||||
{
|
||||
base.Tick(self);
|
||||
|
||||
if (!dirty)
|
||||
return;
|
||||
|
||||
@@ -105,8 +98,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
adjacent = 0;
|
||||
foreach (var a in adjacentActors)
|
||||
{
|
||||
var rb = a.TraitOrDefault<RenderBuildingWall>();
|
||||
if (rb == null || rb.info.Type != info.Type)
|
||||
var rb = a.TraitOrDefault<WithWallSpriteBody>();
|
||||
if (rb == null || rb.wallInfo.Type != wallInfo.Type)
|
||||
continue;
|
||||
|
||||
var location = self.Location;
|
||||
@@ -129,7 +122,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
var adjacentActors = CVec.Directions.SelectMany(dir =>
|
||||
self.World.ActorMap.GetUnitsAt(self.Location + dir))
|
||||
.Select(a => a.TraitOrDefault<RenderBuildingWall>())
|
||||
.Select(a => a.TraitOrDefault<WithWallSpriteBody>())
|
||||
.Where(a => a != null);
|
||||
|
||||
foreach (var rb in adjacentActors)
|
||||
@@ -138,6 +131,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public void AddedToWorld(Actor self)
|
||||
{
|
||||
DefaultAnimation.PlayFetchIndex(NormalizeSequence(self, Info.Sequence), () => adjacent);
|
||||
UpdateNeighbours(self);
|
||||
}
|
||||
|
||||
@@ -1902,6 +1902,33 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
if (rrb != null)
|
||||
rrb.Key = "-WithTurretedSpriteBody";
|
||||
}
|
||||
|
||||
// Replaced RenderBuildingWall with RenderSprites + WithWallSpriteBody (+AutoSelectionSize)
|
||||
if (depth == 0)
|
||||
{
|
||||
var childKeysExcludeFromRS = new[] { "Sequence", "Type" };
|
||||
|
||||
var rb = node.Value.Nodes.FirstOrDefault(n => n.Key.StartsWith("RenderBuildingWall"));
|
||||
if (rb != null)
|
||||
{
|
||||
rb.Key = "WithWallSpriteBody";
|
||||
|
||||
var rsNodes = rb.Value.Nodes.Where(n => !childKeysExcludeFromRS.Contains(n.Key)).ToList();
|
||||
|
||||
if (rsNodes.Any())
|
||||
node.Value.Nodes.Add(new MiniYamlNode("RenderSprites", new MiniYaml("", rsNodes)));
|
||||
else
|
||||
node.Value.Nodes.Add(new MiniYamlNode("RenderSprites", ""));
|
||||
|
||||
node.Value.Nodes.Add(new MiniYamlNode("AutoSelectionSize", ""));
|
||||
|
||||
rb.Value.Nodes.RemoveAll(n => rsNodes.Contains(n));
|
||||
}
|
||||
|
||||
var rrb = node.Value.Nodes.FirstOrDefault(n => n.Key.StartsWith("-RenderBuildingWall"));
|
||||
if (rrb != null)
|
||||
rrb.Key = "-WithWallSpriteBody";
|
||||
}
|
||||
}
|
||||
|
||||
UpgradeActorRules(engineVersion, ref node.Value.Nodes, node, depth + 1);
|
||||
|
||||
@@ -287,7 +287,7 @@ BARB:
|
||||
NodeTypes: barbwire
|
||||
LineBuildNode:
|
||||
Types: barbwire
|
||||
RenderBuildingWall:
|
||||
WithWallSpriteBody:
|
||||
Type: barbwire
|
||||
|
||||
WOOD:
|
||||
@@ -303,7 +303,7 @@ WOOD:
|
||||
NodeTypes: woodfence
|
||||
LineBuildNode:
|
||||
Types: woodfence
|
||||
RenderBuildingWall:
|
||||
WithWallSpriteBody:
|
||||
Type: woodfence
|
||||
|
||||
BRIDGE1:
|
||||
|
||||
@@ -560,8 +560,10 @@
|
||||
Types: wall
|
||||
BodyOrientation:
|
||||
QuantizedFacings: 1
|
||||
RenderBuildingWall:
|
||||
RenderSprites:
|
||||
Palette: staticterrain
|
||||
WithWallSpriteBody:
|
||||
AutoSelectionSize:
|
||||
GivesExperience:
|
||||
AutoTargetIgnore:
|
||||
Sellable:
|
||||
|
||||
@@ -862,7 +862,7 @@ SBAG:
|
||||
NodeTypes: sandbag
|
||||
LineBuildNode:
|
||||
Types: sandbag
|
||||
RenderBuildingWall:
|
||||
WithWallSpriteBody:
|
||||
Type: sandbag
|
||||
|
||||
CYCL:
|
||||
@@ -887,7 +887,7 @@ CYCL:
|
||||
NodeTypes: chain
|
||||
LineBuildNode:
|
||||
Types: chain
|
||||
RenderBuildingWall:
|
||||
WithWallSpriteBody:
|
||||
Type: chain
|
||||
|
||||
BRIK:
|
||||
@@ -917,7 +917,7 @@ BRIK:
|
||||
NodeTypes: concrete
|
||||
LineBuildNode:
|
||||
Types: concrete
|
||||
RenderBuildingWall:
|
||||
WithWallSpriteBody:
|
||||
Type: concrete
|
||||
|
||||
BARRACKS:
|
||||
|
||||
@@ -312,7 +312,9 @@
|
||||
-WithCrumbleOverlay:
|
||||
-WithMakeAnimation:
|
||||
-RenderBuilding:
|
||||
RenderBuildingWall:
|
||||
RenderSprites:
|
||||
WithWallSpriteBody:
|
||||
AutoSelectionSize:
|
||||
LineBuildNode:
|
||||
Types: turret
|
||||
MustBeDestroyed:
|
||||
|
||||
@@ -513,7 +513,9 @@ wall:
|
||||
Types: wall
|
||||
TargetableBuilding:
|
||||
TargetTypes: Ground, Wall
|
||||
RenderBuildingWall:
|
||||
RenderSprites:
|
||||
WithWallSpriteBody:
|
||||
AutoSelectionSize:
|
||||
AutoTargetIgnore:
|
||||
Sellable:
|
||||
SellSounds: CHUNG.WAV
|
||||
|
||||
@@ -462,8 +462,9 @@
|
||||
Types: wall
|
||||
TargetableBuilding:
|
||||
TargetTypes: Ground, DetonateAttack, Wall
|
||||
RenderBuildingWall:
|
||||
RenderSprites:
|
||||
Palette: effect
|
||||
WithWallSpriteBody:
|
||||
GivesExperience:
|
||||
AutoTargetIgnore:
|
||||
ProximityCaptor:
|
||||
|
||||
@@ -1514,7 +1514,7 @@ SBAG:
|
||||
NodeTypes: sandbag
|
||||
LineBuildNode:
|
||||
Types: sandbag
|
||||
RenderBuildingWall:
|
||||
WithWallSpriteBody:
|
||||
Type: sandbag
|
||||
|
||||
FENC:
|
||||
@@ -1539,7 +1539,7 @@ FENC:
|
||||
NodeTypes: fence
|
||||
LineBuildNode:
|
||||
Types: fence
|
||||
RenderBuildingWall:
|
||||
WithWallSpriteBody:
|
||||
Type: fence
|
||||
|
||||
BRIK:
|
||||
@@ -1569,7 +1569,7 @@ BRIK:
|
||||
NodeTypes: concrete
|
||||
LineBuildNode:
|
||||
Types: concrete
|
||||
RenderBuildingWall:
|
||||
WithWallSpriteBody:
|
||||
Type: concrete
|
||||
|
||||
CYCL:
|
||||
@@ -1584,7 +1584,7 @@ CYCL:
|
||||
NodeTypes: chain
|
||||
LineBuildNode:
|
||||
Types: chain
|
||||
RenderBuildingWall:
|
||||
WithWallSpriteBody:
|
||||
Type: chain
|
||||
|
||||
BARB:
|
||||
@@ -1599,7 +1599,7 @@ BARB:
|
||||
NodeTypes: barbwire
|
||||
LineBuildNode:
|
||||
Types: barbwire
|
||||
RenderBuildingWall:
|
||||
WithWallSpriteBody:
|
||||
Type: barbwire
|
||||
|
||||
WOOD:
|
||||
@@ -1614,7 +1614,7 @@ WOOD:
|
||||
NodeTypes: woodfence
|
||||
LineBuildNode:
|
||||
Types: woodfence
|
||||
RenderBuildingWall:
|
||||
WithWallSpriteBody:
|
||||
Type: woodfence
|
||||
|
||||
BARRACKS:
|
||||
|
||||
@@ -1237,7 +1237,7 @@ GASAND:
|
||||
NodeTypes: sandbags
|
||||
LineBuildNode:
|
||||
Types: sandbags
|
||||
RenderBuildingWall:
|
||||
WithWallSpriteBody:
|
||||
Type: sandbags
|
||||
|
||||
GASPOT:
|
||||
|
||||
@@ -166,7 +166,9 @@
|
||||
Types: wall
|
||||
TargetableBuilding:
|
||||
TargetTypes: Ground, Wall, C4
|
||||
RenderBuildingWall:
|
||||
RenderSprites:
|
||||
AutoSelectionSize:
|
||||
WithWallSpriteBody:
|
||||
Type: wall
|
||||
GivesExperience:
|
||||
AutoTargetIgnore:
|
||||
|
||||
@@ -103,7 +103,8 @@ GACTWR:
|
||||
LineBuildNode:
|
||||
Types: turret
|
||||
-RenderBuilding:
|
||||
RenderBuildingWall:
|
||||
RenderSprites:
|
||||
WithWallSpriteBody:
|
||||
Type: wall
|
||||
Power@base:
|
||||
Amount: -10
|
||||
|
||||
Reference in New Issue
Block a user