From bf51e0600de15419cb2a5eb260ba703b9c7f17b8 Mon Sep 17 00:00:00 2001 From: reaperrr Date: Wed, 15 Jul 2015 07:25:43 +0200 Subject: [PATCH] RenderBuildingWall -> WithWallSpriteBody --- OpenRA.Mods.Common/OpenRA.Mods.Common.csproj | 2 +- ...rBuildingWall.cs => WithWallSpriteBody.cs} | 36 ++++++++----------- .../UtilityCommands/UpgradeRules.cs | 27 ++++++++++++++ mods/cnc/rules/civilian.yaml | 4 +-- mods/cnc/rules/defaults.yaml | 4 ++- mods/cnc/rules/structures.yaml | 6 ++-- mods/d2k/rules/defaults.yaml | 4 ++- mods/d2k/rules/structures.yaml | 4 ++- mods/ra/rules/defaults.yaml | 3 +- mods/ra/rules/structures.yaml | 12 +++---- mods/ts/rules/civilian-structures.yaml | 2 +- mods/ts/rules/defaults.yaml | 4 ++- mods/ts/rules/gdi-support.yaml | 3 +- 13 files changed, 71 insertions(+), 40 deletions(-) rename OpenRA.Mods.Common/Traits/Render/{RenderBuildingWall.cs => WithWallSpriteBody.cs} (80%) diff --git a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj index ec22d6a22d..6020d044b3 100644 --- a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj +++ b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj @@ -411,7 +411,7 @@ - + diff --git a/OpenRA.Mods.Common/Traits/Render/RenderBuildingWall.cs b/OpenRA.Mods.Common/Traits/Render/WithWallSpriteBody.cs similarity index 80% rename from OpenRA.Mods.Common/Traits/Render/RenderBuildingWall.cs rename to OpenRA.Mods.Common/Traits/Render/WithWallSpriteBody.cs index 29160a0e85..8976ef6742 100644 --- a/OpenRA.Mods.Common/Traits/Render/RenderBuildingWall.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithWallSpriteBody.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 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(); + var rb = init.World.Map.Rules.Actors[n].Traits.GetOrDefault(); 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(); - if (rb == null || rb.info.Type != info.Type) + var rb = a.TraitOrDefault(); + 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()) + .Select(a => a.TraitOrDefault()) .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); } diff --git a/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs b/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs index 7078102a48..8968e854ba 100644 --- a/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs +++ b/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs @@ -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); diff --git a/mods/cnc/rules/civilian.yaml b/mods/cnc/rules/civilian.yaml index fc02e60d23..ce160cf1bd 100644 --- a/mods/cnc/rules/civilian.yaml +++ b/mods/cnc/rules/civilian.yaml @@ -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: diff --git a/mods/cnc/rules/defaults.yaml b/mods/cnc/rules/defaults.yaml index 46d7572e6d..87e44b605a 100644 --- a/mods/cnc/rules/defaults.yaml +++ b/mods/cnc/rules/defaults.yaml @@ -560,8 +560,10 @@ Types: wall BodyOrientation: QuantizedFacings: 1 - RenderBuildingWall: + RenderSprites: Palette: staticterrain + WithWallSpriteBody: + AutoSelectionSize: GivesExperience: AutoTargetIgnore: Sellable: diff --git a/mods/cnc/rules/structures.yaml b/mods/cnc/rules/structures.yaml index d0e53b1f1d..611c7849dd 100644 --- a/mods/cnc/rules/structures.yaml +++ b/mods/cnc/rules/structures.yaml @@ -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: diff --git a/mods/d2k/rules/defaults.yaml b/mods/d2k/rules/defaults.yaml index 00da36ee6f..c6491bdc77 100644 --- a/mods/d2k/rules/defaults.yaml +++ b/mods/d2k/rules/defaults.yaml @@ -312,7 +312,9 @@ -WithCrumbleOverlay: -WithMakeAnimation: -RenderBuilding: - RenderBuildingWall: + RenderSprites: + WithWallSpriteBody: + AutoSelectionSize: LineBuildNode: Types: turret MustBeDestroyed: diff --git a/mods/d2k/rules/structures.yaml b/mods/d2k/rules/structures.yaml index 69de28c6ca..cda6dc708d 100644 --- a/mods/d2k/rules/structures.yaml +++ b/mods/d2k/rules/structures.yaml @@ -513,7 +513,9 @@ wall: Types: wall TargetableBuilding: TargetTypes: Ground, Wall - RenderBuildingWall: + RenderSprites: + WithWallSpriteBody: + AutoSelectionSize: AutoTargetIgnore: Sellable: SellSounds: CHUNG.WAV diff --git a/mods/ra/rules/defaults.yaml b/mods/ra/rules/defaults.yaml index 14921451c6..5974b4df2b 100644 --- a/mods/ra/rules/defaults.yaml +++ b/mods/ra/rules/defaults.yaml @@ -462,8 +462,9 @@ Types: wall TargetableBuilding: TargetTypes: Ground, DetonateAttack, Wall - RenderBuildingWall: + RenderSprites: Palette: effect + WithWallSpriteBody: GivesExperience: AutoTargetIgnore: ProximityCaptor: diff --git a/mods/ra/rules/structures.yaml b/mods/ra/rules/structures.yaml index e377c63bb3..aa43ffe048 100644 --- a/mods/ra/rules/structures.yaml +++ b/mods/ra/rules/structures.yaml @@ -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: diff --git a/mods/ts/rules/civilian-structures.yaml b/mods/ts/rules/civilian-structures.yaml index 1e6546d8c5..70695da9e8 100644 --- a/mods/ts/rules/civilian-structures.yaml +++ b/mods/ts/rules/civilian-structures.yaml @@ -1237,7 +1237,7 @@ GASAND: NodeTypes: sandbags LineBuildNode: Types: sandbags - RenderBuildingWall: + WithWallSpriteBody: Type: sandbags GASPOT: diff --git a/mods/ts/rules/defaults.yaml b/mods/ts/rules/defaults.yaml index a44a716de4..cfaf6d1532 100644 --- a/mods/ts/rules/defaults.yaml +++ b/mods/ts/rules/defaults.yaml @@ -166,7 +166,9 @@ Types: wall TargetableBuilding: TargetTypes: Ground, Wall, C4 - RenderBuildingWall: + RenderSprites: + AutoSelectionSize: + WithWallSpriteBody: Type: wall GivesExperience: AutoTargetIgnore: diff --git a/mods/ts/rules/gdi-support.yaml b/mods/ts/rules/gdi-support.yaml index 188e373f2f..3ec5e206a6 100644 --- a/mods/ts/rules/gdi-support.yaml +++ b/mods/ts/rules/gdi-support.yaml @@ -103,7 +103,8 @@ GACTWR: LineBuildNode: Types: turret -RenderBuilding: - RenderBuildingWall: + RenderSprites: + WithWallSpriteBody: Type: wall Power@base: Amount: -10