Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added smoke to the nuclear missile silo #668

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 87 additions & 0 deletions OpenRA.Mods.RA2/Traits/Render/WithNuclearMissileSmokeOverlay.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* 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 OpenRA.Graphics;
using OpenRA.Mods.Common.Traits;
using OpenRA.Mods.Common.Traits.Render;
using OpenRA.Traits;

namespace OpenRA.Mods.RA2.Traits.Render
{
[Desc("Displays an overlay when `NukePower` is triggered.")]
public class WithNuclearMissileSmokeOverlayInfo : ConditionalTraitInfo, Requires<RenderSpritesInfo>, Requires<BodyOrientationInfo>
{
[SequenceReference]
[Desc("Sequence name to use")]
public readonly string Sequence = "smoke";

[Desc("Position relative to body")]
public readonly WVec Offset = WVec.Zero;

[PaletteReference("IsPlayerPalette")]
[Desc("Custom palette name")]
public readonly string Palette = null;

[Desc("Custom palette is a player palette BaseName.")]
public readonly bool IsPlayerPalette = false;

[Desc("Measured in ticks.")]
public readonly int Delay = 0;

public override object Create(ActorInitializer init) { return new WithNuclearMissileSmokeOverlay(init.Self, this); }
}

public class WithNuclearMissileSmokeOverlay : ConditionalTrait<WithNuclearMissileSmokeOverlayInfo>, INotifyNuke, ITick
{
readonly Animation overlay;
bool visible, isLaunched;
int launchDelay;

public WithNuclearMissileSmokeOverlay(Actor self, WithNuclearMissileSmokeOverlayInfo info)
: base(info)
{
var rs = self.Trait<RenderSprites>();
var body = self.Trait<BodyOrientation>();

overlay = new Animation(self.World, rs.GetImage(self));
overlay.PlayThen(info.Sequence, () => visible = false);

var anim = new AnimationWithOffset(overlay,
() => body.LocalToWorld(info.Offset.Rotate(body.QuantizeOrientation(self, self.Orientation))),
() => IsTraitDisabled || !visible,
p => RenderUtils.ZOffsetFromCenter(self, p, 1));

rs.Add(anim, info.Palette, info.IsPlayerPalette);
}

void INotifyNuke.Launching(Actor self)
{
isLaunched = true;
launchDelay = Info.Delay;
}

void ITick.Tick(Actor self)
{
if (!isLaunched)
return;

if (launchDelay-- > 0)
return;

if (!visible)
{
visible = true;
overlay.PlayThen(overlay.CurrentSequence.Name, () => visible = false);
isLaunched = false;
}
}
}
}
5 changes: 4 additions & 1 deletion mods/ra2/rules/soviet-structures.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,7 @@ namisl:
LaunchSound: snuklaun.wav
MissileWeapon: atomic
MissilePalette: player
MissileDelay: 35
MissileDelay: 40
SpawnOffset: 0,0,-1c0
IsPlayerPalette: true
DisplayTimerStances: Ally, Neutral, Enemy
Expand All @@ -886,6 +886,9 @@ namisl:
PauseOnCondition: lowpower
WithNukeLaunchAnimation:
RequiresCondition: !build-incomplete
WithNuclearMissileSmokeOverlay:
Delay: 40
Palette: effect50alpha
SpawnSurvivors:
DeathTypes: ExplosionDeath, BulletDeath
Actors: e2, e2, e2, e2, e2, e2, e2
Expand Down
3 changes: 3 additions & 0 deletions mods/ra2/sequences/soviet-structures.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,9 @@ namisl:
Length: 16
ShadowStart: 48
Tick: 120
smoke: nuketo
Length: *
Tick: 120
make: ntmislmk
UseTilesetCode: true
Length: 26
Expand Down