From cc3c618d60f41f31e19b2c6412a11c9ccfecf9fb Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sun, 5 Feb 2017 13:23:48 +0000 Subject: [PATCH] Play spurt animation on each growth step. --- OpenRA.Mods.D2k/Traits/SpiceBloom.cs | 41 +++++++++++++++++++--------- mods/d2k/rules/arrakis.yaml | 3 -- mods/d2k/sequences/misc.yaml | 12 ++++---- mods/d2k/weapons/other.yaml | 11 +------- 4 files changed, 36 insertions(+), 31 deletions(-) diff --git a/OpenRA.Mods.D2k/Traits/SpiceBloom.cs b/OpenRA.Mods.D2k/Traits/SpiceBloom.cs index 2989d48f04..d5b72caa36 100644 --- a/OpenRA.Mods.D2k/Traits/SpiceBloom.cs +++ b/OpenRA.Mods.D2k/Traits/SpiceBloom.cs @@ -32,6 +32,9 @@ namespace OpenRA.Mods.D2k.Traits [SequenceReference] public readonly string[] GrowthSequences = { "grow1", "grow2", "grow3" }; + [SequenceReference] + public readonly string SpurtSequence = "spurt"; + [Desc("The range of time (in ticks) that the spicebloom will take to grow until it blows up.")] public readonly int[] Lifetime = { 1000, 3000 }; @@ -50,7 +53,7 @@ namespace OpenRA.Mods.D2k.Traits [Desc("The maximum distance in cells that spice may be expelled.")] public readonly int Range = 5; - public object Create(ActorInitializer init) { return new SpiceBloom(init, this); } + public object Create(ActorInitializer init) { return new SpiceBloom(init.Self, this); } public IEnumerable RenderPreviewSprites(ActorPreviewInitializer init, RenderSpritesInfo rs, string image, int facings, PaletteReference p) { @@ -63,29 +66,34 @@ namespace OpenRA.Mods.D2k.Traits public class SpiceBloom : ITick, INotifyKilled { - readonly Actor self; readonly SpiceBloomInfo info; readonly ResourceType resType; readonly ResourceLayer resLayer; - readonly AnimationWithOffset anim; - + readonly Animation body; + readonly Animation spurt; readonly int growTicks; - int ticks; - public SpiceBloom(ActorInitializer init, SpiceBloomInfo info) + int ticks; + int bodyFrame = 0; + bool showSpurt = true; + + public SpiceBloom(Actor self, SpiceBloomInfo info) { this.info = info; - self = init.Self; resLayer = self.World.WorldActor.Trait(); resType = self.World.WorldActor.TraitsImplementing().First(t => t.Info.Type == info.ResourceType); - var render = self.Trait(); - anim = new AnimationWithOffset(new Animation(init.Self.World, render.GetImage(self)), null, () => self.IsDead); - render.Add(anim); + var rs = self.Trait(); + body = new Animation(self.World, rs.GetImage(self)); + rs.Add(new AnimationWithOffset(body, null, () => self.IsDead)); growTicks = self.World.SharedRandom.Next(info.Lifetime[0], info.Lifetime[1]); - anim.Animation.Play(info.GrowthSequences[0]); + body.Play(info.GrowthSequences[0]); + + spurt = new Animation(self.World, rs.GetImage(self)); + rs.Add(new AnimationWithOffset(spurt, null, () => !showSpurt)); + spurt.PlayThen(info.SpurtSequence, () => showSpurt = false); } void ITick.Tick(Actor self) @@ -102,8 +110,15 @@ namespace OpenRA.Mods.D2k.Traits self.Kill(self); else { - var index = info.GrowthSequences.Length * ticks / growTicks; - anim.Animation.Play(info.GrowthSequences[index]); + var newBodyFrame = info.GrowthSequences.Length * ticks / growTicks; + if (newBodyFrame != bodyFrame) + { + bodyFrame = newBodyFrame; + body.Play(info.GrowthSequences[bodyFrame]); + + showSpurt = true; + spurt.PlayThen(info.SpurtSequence, () => showSpurt = false); + } } } diff --git a/mods/d2k/rules/arrakis.yaml b/mods/d2k/rules/arrakis.yaml index 228664f7bf..c14038a802 100644 --- a/mods/d2k/rules/arrakis.yaml +++ b/mods/d2k/rules/arrakis.yaml @@ -18,9 +18,6 @@ spicebloom.spawnpoint: Delay: 1750, 3250 SpawnActorOnDeath: Actor: spicebloom - Explodes: - Weapon: BloomSpawn - EmptyWeapon: BloomSpawn Health: HP: 9999 Shape: Circle diff --git a/mods/d2k/sequences/misc.yaml b/mods/d2k/sequences/misc.yaml index f487686470..c1d1b7074d 100644 --- a/mods/d2k/sequences/misc.yaml +++ b/mods/d2k/sequences/misc.yaml @@ -47,11 +47,6 @@ explosion: BlendMode: Alpha Offset: 12, -10 Tick: 120 - bloomspawn: DATA.R8 - Start: 4233 - Length: 8 - Tick: 120 - Offset: 0, -16 corpse: DATA.R8 ZOffset: -511 Start: 430 @@ -415,6 +410,13 @@ spicebloom: Length: 1 ZOffset: -1023 Offset: -16,-16 + spurt: DATA.R8 + Start: 4233 + Length: 8 + Tick: 80 + BlendMode: Additive + ZOffset: 511 + Offset: 0, -16 moveflsh: idle: DATA.R8 diff --git a/mods/d2k/weapons/other.yaml b/mods/d2k/weapons/other.yaml index 59c324dcf4..def3962142 100644 --- a/mods/d2k/weapons/other.yaml +++ b/mods/d2k/weapons/other.yaml @@ -296,13 +296,4 @@ BloomExplosion: cy: 20 harvester: 25 DamageTypes: Prone50Percent, TriggerProne, ExplosionDeath - AffectsParent: true - -BloomSpawn: - Range: 0c1 - Projectile: Bullet - Speed: 1c0 - Blockable: false - Image: null - Warhead@1Eff: CreateEffect - Explosions: bloomspawn + AffectsParent: true \ No newline at end of file