Merge pull request #12709 from pchote/spicebloom-spurt
Play spicebloom spurt animation on each growth step.
This commit is contained in:
@@ -29,6 +29,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 };
|
||||
|
||||
@@ -47,7 +50,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<IActorPreview> RenderPreviewSprites(ActorPreviewInitializer init, RenderSpritesInfo rs, string image, int facings, PaletteReference p)
|
||||
{
|
||||
@@ -60,29 +63,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<ResourceLayer>();
|
||||
resType = self.World.WorldActor.TraitsImplementing<ResourceType>().First(t => t.Info.Type == info.ResourceType);
|
||||
|
||||
var render = self.Trait<RenderSprites>();
|
||||
anim = new AnimationWithOffset(new Animation(init.Self.World, render.GetImage(self)), null, () => self.IsDead);
|
||||
render.Add(anim);
|
||||
var rs = self.Trait<RenderSprites>();
|
||||
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)
|
||||
@@ -99,8 +107,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,9 +18,6 @@ spicebloom.spawnpoint:
|
||||
Delay: 1750, 3250
|
||||
SpawnActorOnDeath:
|
||||
Actor: spicebloom
|
||||
Explodes:
|
||||
Weapon: BloomSpawn
|
||||
EmptyWeapon: BloomSpawn
|
||||
Health:
|
||||
HP: 9999
|
||||
Shape: Circle
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user