Play spurt animation on each growth step.
This commit is contained in:
@@ -32,6 +32,9 @@ namespace OpenRA.Mods.D2k.Traits
|
|||||||
[SequenceReference]
|
[SequenceReference]
|
||||||
public readonly string[] GrowthSequences = { "grow1", "grow2", "grow3" };
|
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.")]
|
[Desc("The range of time (in ticks) that the spicebloom will take to grow until it blows up.")]
|
||||||
public readonly int[] Lifetime = { 1000, 3000 };
|
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.")]
|
[Desc("The maximum distance in cells that spice may be expelled.")]
|
||||||
public readonly int Range = 5;
|
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)
|
public IEnumerable<IActorPreview> 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
|
public class SpiceBloom : ITick, INotifyKilled
|
||||||
{
|
{
|
||||||
readonly Actor self;
|
|
||||||
readonly SpiceBloomInfo info;
|
readonly SpiceBloomInfo info;
|
||||||
readonly ResourceType resType;
|
readonly ResourceType resType;
|
||||||
readonly ResourceLayer resLayer;
|
readonly ResourceLayer resLayer;
|
||||||
readonly AnimationWithOffset anim;
|
readonly Animation body;
|
||||||
|
readonly Animation spurt;
|
||||||
readonly int growTicks;
|
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;
|
this.info = info;
|
||||||
self = init.Self;
|
|
||||||
|
|
||||||
resLayer = self.World.WorldActor.Trait<ResourceLayer>();
|
resLayer = self.World.WorldActor.Trait<ResourceLayer>();
|
||||||
resType = self.World.WorldActor.TraitsImplementing<ResourceType>().First(t => t.Info.Type == info.ResourceType);
|
resType = self.World.WorldActor.TraitsImplementing<ResourceType>().First(t => t.Info.Type == info.ResourceType);
|
||||||
|
|
||||||
var render = self.Trait<RenderSprites>();
|
var rs = self.Trait<RenderSprites>();
|
||||||
anim = new AnimationWithOffset(new Animation(init.Self.World, render.GetImage(self)), null, () => self.IsDead);
|
body = new Animation(self.World, rs.GetImage(self));
|
||||||
render.Add(anim);
|
rs.Add(new AnimationWithOffset(body, null, () => self.IsDead));
|
||||||
|
|
||||||
growTicks = self.World.SharedRandom.Next(info.Lifetime[0], info.Lifetime[1]);
|
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)
|
void ITick.Tick(Actor self)
|
||||||
@@ -102,8 +110,15 @@ namespace OpenRA.Mods.D2k.Traits
|
|||||||
self.Kill(self);
|
self.Kill(self);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var index = info.GrowthSequences.Length * ticks / growTicks;
|
var newBodyFrame = info.GrowthSequences.Length * ticks / growTicks;
|
||||||
anim.Animation.Play(info.GrowthSequences[index]);
|
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
|
Delay: 1750, 3250
|
||||||
SpawnActorOnDeath:
|
SpawnActorOnDeath:
|
||||||
Actor: spicebloom
|
Actor: spicebloom
|
||||||
Explodes:
|
|
||||||
Weapon: BloomSpawn
|
|
||||||
EmptyWeapon: BloomSpawn
|
|
||||||
Health:
|
Health:
|
||||||
HP: 9999
|
HP: 9999
|
||||||
Shape: Circle
|
Shape: Circle
|
||||||
|
|||||||
@@ -47,11 +47,6 @@ explosion:
|
|||||||
BlendMode: Alpha
|
BlendMode: Alpha
|
||||||
Offset: 12, -10
|
Offset: 12, -10
|
||||||
Tick: 120
|
Tick: 120
|
||||||
bloomspawn: DATA.R8
|
|
||||||
Start: 4233
|
|
||||||
Length: 8
|
|
||||||
Tick: 120
|
|
||||||
Offset: 0, -16
|
|
||||||
corpse: DATA.R8
|
corpse: DATA.R8
|
||||||
ZOffset: -511
|
ZOffset: -511
|
||||||
Start: 430
|
Start: 430
|
||||||
@@ -415,6 +410,13 @@ spicebloom:
|
|||||||
Length: 1
|
Length: 1
|
||||||
ZOffset: -1023
|
ZOffset: -1023
|
||||||
Offset: -16,-16
|
Offset: -16,-16
|
||||||
|
spurt: DATA.R8
|
||||||
|
Start: 4233
|
||||||
|
Length: 8
|
||||||
|
Tick: 80
|
||||||
|
BlendMode: Additive
|
||||||
|
ZOffset: 511
|
||||||
|
Offset: 0, -16
|
||||||
|
|
||||||
moveflsh:
|
moveflsh:
|
||||||
idle: DATA.R8
|
idle: DATA.R8
|
||||||
|
|||||||
@@ -296,13 +296,4 @@ BloomExplosion:
|
|||||||
cy: 20
|
cy: 20
|
||||||
harvester: 25
|
harvester: 25
|
||||||
DamageTypes: Prone50Percent, TriggerProne, ExplosionDeath
|
DamageTypes: Prone50Percent, TriggerProne, ExplosionDeath
|
||||||
AffectsParent: true
|
AffectsParent: true
|
||||||
|
|
||||||
BloomSpawn:
|
|
||||||
Range: 0c1
|
|
||||||
Projectile: Bullet
|
|
||||||
Speed: 1c0
|
|
||||||
Blockable: false
|
|
||||||
Image: null
|
|
||||||
Warhead@1Eff: CreateEffect
|
|
||||||
Explosions: bloomspawn
|
|
||||||
Reference in New Issue
Block a user