diff --git a/OpenRA.Mods.Cnc/Effects/ConyardChronoVortex.cs b/OpenRA.Mods.Cnc/Effects/ConyardChronoVortex.cs new file mode 100644 index 0000000000..0995a94aa0 --- /dev/null +++ b/OpenRA.Mods.Cnc/Effects/ConyardChronoVortex.cs @@ -0,0 +1,63 @@ +#region Copyright & License Information +/* + * Copyright (c) The OpenRA Developers and Contributors + * This file is part of OpenRA, which is free software. It is made + * available to you under the terms of the GNU General Public License + * as published by the Free Software Foundation, either version 3 of + * the License, or (at your option) any later version. For more + * information, see COPYING. + */ +#endregion + +using System; +using System.Collections.Generic; +using OpenRA.Effects; +using OpenRA.Graphics; +using OpenRA.Mods.Cnc.Graphics; +using OpenRA.Mods.Cnc.Traits; +using OpenRA.Primitives; + +namespace OpenRA.Mods.Cnc.Effects +{ + sealed class ConyardChronoVortex : IEffect, ISpatiallyPartitionable + { + static readonly Size Size = new(64, 64); + static readonly WVec Offset = new(171, 0, 0); + readonly ChronoVortexRenderer renderer; + readonly WPos center; + readonly Action onCompletion; + WPos pos; + WAngle angle; + int loops = 3; + int frame; + + public ConyardChronoVortex(Actor launcher, Action onCompletion) + { + this.onCompletion = onCompletion; + renderer = launcher.World.WorldActor.Trait(); + center = launcher.CenterPosition; + pos = center + Offset.Rotate(WRot.FromYaw(angle)); + launcher.World.ScreenMap.Add(this, pos, Size); + } + + public void Tick(World world) + { + // First 16 frames are the vortex opening + // Next 16 frames are loopable + // Final 16 frames are the vortex closing + if (++frame == 32 && --loops > 0) + frame = 16; + + angle += new WAngle(42); + pos = center + Offset.Rotate(WRot.FromYaw(angle)); + world.ScreenMap.Update(this, pos, Size); + if (frame == 48) + world.AddFrameEndTask(w => { w.Remove(this); w.ScreenMap.Remove(this); onCompletion(); }); + } + + public IEnumerable Render(WorldRenderer wr) + { + yield return new ChronoVortexRenderable(renderer, pos, frame); + } + } +} diff --git a/OpenRA.Mods.Cnc/Traits/ConyardChronoReturn.cs b/OpenRA.Mods.Cnc/Traits/ConyardChronoReturn.cs index 8a3ef651c0..62f8f0cc31 100644 --- a/OpenRA.Mods.Cnc/Traits/ConyardChronoReturn.cs +++ b/OpenRA.Mods.Cnc/Traits/ConyardChronoReturn.cs @@ -10,7 +10,7 @@ #endregion using System.Collections.Generic; -using System.Linq; +using OpenRA.Mods.Cnc.Effects; using OpenRA.Mods.Common; using OpenRA.Mods.Common.Traits; using OpenRA.Mods.Common.Traits.Render; @@ -25,13 +25,6 @@ namespace OpenRA.Mods.Cnc.Traits "Otherwise, a vortex animation is played and damage is dealt each tick, ignoring modifiers.")] public class ConyardChronoReturnInfo : TraitInfo, Requires, Requires, IObservesVariablesInfo { - [SequenceReference] - [Desc("Sequence name with the baked-in vortex animation")] - public readonly string Sequence = "pdox"; - - [Desc("Sprite body to play the vortex animation on.")] - public readonly string Body = "body"; - [GrantedConditionReference] [Desc("Condition to grant while the vortex animation plays.")] public readonly string Condition = null; @@ -65,7 +58,6 @@ namespace OpenRA.Mods.Cnc.Traits IDeathActorInitModifier, ITransformActorInitModifier { readonly ConyardChronoReturnInfo info; - readonly WithSpriteBody wsb; readonly Health health; readonly Actor self; readonly string faction; @@ -92,8 +84,6 @@ namespace OpenRA.Mods.Cnc.Traits self = init.Self; health = self.Trait(); - - wsb = self.TraitsImplementing().Single(w => w.Info.Name == info.Body); faction = init.GetValue(self.Owner.Faction.InternalName); var returnInit = init.GetOrDefault(); @@ -127,16 +117,12 @@ namespace OpenRA.Mods.Cnc.Traits triggered = true; - // Don't override the selling animation - if (selling) - return; - - wsb.PlayCustomAnimation(self, info.Sequence, () => + self.World.AddFrameEndTask(w => w.Add(new ConyardChronoVortex(self, () => { triggered = false; - if (conditionToken != Actor.InvalidConditionToken) + if (conditionToken != Actor.InvalidConditionToken && !self.Disposed) conditionToken = self.RevokeCondition(conditionToken); - }); + }))); } CPos? ChooseBestDestinationCell(MobileInfo mobileInfo, CPos destination) diff --git a/OpenRA.Mods.Common/UpdateRules/Rules/20230801/RemoveConyardChronoReturnAnimation.cs b/OpenRA.Mods.Common/UpdateRules/Rules/20230801/RemoveConyardChronoReturnAnimation.cs new file mode 100644 index 0000000000..d838da2be3 --- /dev/null +++ b/OpenRA.Mods.Common/UpdateRules/Rules/20230801/RemoveConyardChronoReturnAnimation.cs @@ -0,0 +1,33 @@ +#region Copyright & License Information +/* + * Copyright (c) The OpenRA Developers and Contributors + * This file is part of OpenRA, which is free software. It is made + * available to you under the terms of the GNU General Public License + * as published by the Free Software Foundation, either version 3 of + * the License, or (at your option) any later version. For more + * information, see COPYING. + */ +#endregion + +using System.Collections.Generic; + +namespace OpenRA.Mods.Common.UpdateRules.Rules +{ + public class RemoveConyardChronoReturnAnimation : UpdateRule + { + public override string Name => "Remove Sequence and Body properties from ConyardChronoReturn."; + + public override string Description => "These properties have been replaced with a dynamic vortex renderable."; + + public override IEnumerable UpdateActorNode(ModData modData, MiniYamlNodeBuilder actorNode) + { + foreach (var trait in actorNode.ChildrenMatching("ConyardChronoReturn")) + { + trait.RemoveNodes("Sequence"); + trait.RemoveNodes("Body"); + } + + yield break; + } + } +} diff --git a/OpenRA.Mods.Common/UpdateRules/UpdatePath.cs b/OpenRA.Mods.Common/UpdateRules/UpdatePath.cs index b2ff95bd19..99b4027001 100644 --- a/OpenRA.Mods.Common/UpdateRules/UpdatePath.cs +++ b/OpenRA.Mods.Common/UpdateRules/UpdatePath.cs @@ -111,6 +111,7 @@ namespace OpenRA.Mods.Common.UpdateRules new RemoveValidRelationsFromCapturable(), new ExtractResourceStorageFromHarvester(), new ReplacePaletteModifiers(), + new RemoveConyardChronoReturnAnimation(), // Execute these rules last to avoid premature yaml merge crashes. new AbstractDocking(), diff --git a/mods/ra/bits/factpdox.shp b/mods/ra/bits/factpdox.shp deleted file mode 100644 index d07b694519..0000000000 Binary files a/mods/ra/bits/factpdox.shp and /dev/null differ diff --git a/mods/ra/rules/world.yaml b/mods/ra/rules/world.yaml index 04d6c0b7a8..fac900bf67 100644 --- a/mods/ra/rules/world.yaml +++ b/mods/ra/rules/world.yaml @@ -92,6 +92,7 @@ Name: immobile TerrainSpeeds: TerrainRenderer: + ChronoVortexRenderer: ShroudRenderer: FogVariants: shroud Index: 255, 16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 176, 192, 208, 224, 240, 20, 40, 56, 65, 97, 130, 148, 194, 24, 33, 66, 132, 28, 41, 67, 134, 1, 2, 4, 8, 3, 6, 12, 9, 7, 14, 13, 11, 5, 10, 15, 255 diff --git a/mods/ra/sequences/structures.yaml b/mods/ra/sequences/structures.yaml index 4b5c10de3d..f2f9079d4f 100644 --- a/mods/ra/sequences/structures.yaml +++ b/mods/ra/sequences/structures.yaml @@ -79,18 +79,11 @@ fact: build: Start: 1 Length: 25 - pdox: - Filename: factpdox.shp - Length: 80 damaged-idle: Start: 26 damaged-build: Start: 27 Length: 25 - damaged-pdox: - Filename: factpdox.shp - Start: 80 - Length: 80 dead: Filename: factdead.shp Tick: 800