Add WithNukeLaunchAnimation and -Overlay traits.
This commit is contained in:
committed by
Matthias Mailänder
parent
c63620e979
commit
4526344eed
@@ -443,6 +443,8 @@
|
|||||||
<Compile Include="Traits\Render\WithHarvestOverlay.cs" />
|
<Compile Include="Traits\Render\WithHarvestOverlay.cs" />
|
||||||
<Compile Include="Traits\Render\WithIdleOverlay.cs" />
|
<Compile Include="Traits\Render\WithIdleOverlay.cs" />
|
||||||
<Compile Include="Traits\Render\WithMuzzleOverlay.cs" />
|
<Compile Include="Traits\Render\WithMuzzleOverlay.cs" />
|
||||||
|
<Compile Include="Traits\Render\WithNukeLaunchAnimation.cs" />
|
||||||
|
<Compile Include="Traits\Render\WithNukeLaunchOverlay.cs" />
|
||||||
<Compile Include="Traits\Render\WithParachute.cs" />
|
<Compile Include="Traits\Render\WithParachute.cs" />
|
||||||
<Compile Include="Traits\Render\WithRangeCircle.cs" />
|
<Compile Include="Traits\Render\WithRangeCircle.cs" />
|
||||||
<Compile Include="Traits\Render\WithRearmAnimation.cs" />
|
<Compile Include="Traits\Render\WithRearmAnimation.cs" />
|
||||||
|
|||||||
54
OpenRA.Mods.Common/Traits/Render/WithNukeLaunchAnimation.cs
Normal file
54
OpenRA.Mods.Common/Traits/Render/WithNukeLaunchAnimation.cs
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
#region Copyright & License Information
|
||||||
|
/*
|
||||||
|
* Copyright 2007-2017 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.Traits;
|
||||||
|
|
||||||
|
namespace OpenRA.Mods.Common.Traits.Render
|
||||||
|
{
|
||||||
|
[Desc("Replaces the building animation when `NukePower` is triggered.")]
|
||||||
|
public class WithNukeLaunchAnimationInfo : ConditionalTraitInfo, Requires<WithSpriteBodyInfo>
|
||||||
|
{
|
||||||
|
[Desc("Sequence name to use")]
|
||||||
|
[SequenceReference] public readonly string Sequence = "active";
|
||||||
|
|
||||||
|
public override object Create(ActorInitializer init) { return new WithNukeLaunchAnimation(init.Self, this); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class WithNukeLaunchAnimation : ConditionalTrait<WithNukeLaunchAnimationInfo>, INotifyNuke, INotifyBuildComplete, INotifySold
|
||||||
|
{
|
||||||
|
readonly WithSpriteBody spriteBody;
|
||||||
|
bool buildComplete;
|
||||||
|
|
||||||
|
public WithNukeLaunchAnimation(Actor self, WithNukeLaunchAnimationInfo info)
|
||||||
|
: base(info)
|
||||||
|
{
|
||||||
|
spriteBody = self.TraitOrDefault<WithSpriteBody>();
|
||||||
|
}
|
||||||
|
|
||||||
|
void INotifyNuke.Launching(Actor self)
|
||||||
|
{
|
||||||
|
if (buildComplete && spriteBody != null && !IsTraitDisabled)
|
||||||
|
spriteBody.PlayCustomAnimation(self, Info.Sequence, () => spriteBody.CancelCustomAnimation(self));
|
||||||
|
}
|
||||||
|
|
||||||
|
void INotifyBuildComplete.BuildingComplete(Actor self)
|
||||||
|
{
|
||||||
|
buildComplete = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void INotifySold.Selling(Actor self)
|
||||||
|
{
|
||||||
|
buildComplete = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void INotifySold.Sold(Actor self) { }
|
||||||
|
}
|
||||||
|
}
|
||||||
77
OpenRA.Mods.Common/Traits/Render/WithNukeLaunchOverlay.cs
Normal file
77
OpenRA.Mods.Common/Traits/Render/WithNukeLaunchOverlay.cs
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
#region Copyright & License Information
|
||||||
|
/*
|
||||||
|
* Copyright 2007-2017 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.Effects;
|
||||||
|
using OpenRA.Graphics;
|
||||||
|
using OpenRA.Traits;
|
||||||
|
|
||||||
|
namespace OpenRA.Mods.Common.Traits.Render
|
||||||
|
{
|
||||||
|
[Desc("Displays an overlay when `NukePower` is triggered.")]
|
||||||
|
public class WithNukeLaunchOverlayInfo : ConditionalTraitInfo, Requires<RenderSpritesInfo>, Requires<BodyOrientationInfo>
|
||||||
|
{
|
||||||
|
[Desc("Sequence name to use")]
|
||||||
|
[SequenceReference] public readonly string Sequence = "active";
|
||||||
|
|
||||||
|
[Desc("Position relative to body")]
|
||||||
|
public readonly WVec Offset = WVec.Zero;
|
||||||
|
|
||||||
|
[Desc("Custom palette name")]
|
||||||
|
[PaletteReference("IsPlayerPalette")] public readonly string Palette = null;
|
||||||
|
|
||||||
|
[Desc("Custom palette is a player palette BaseName")]
|
||||||
|
public readonly bool IsPlayerPalette = false;
|
||||||
|
|
||||||
|
public override object Create(ActorInitializer init) { return new WithNukeLaunchOverlay(init.Self, this); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class WithNukeLaunchOverlay : ConditionalTrait<WithNukeLaunchOverlayInfo>, INotifyBuildComplete, INotifySold, INotifyNuke
|
||||||
|
{
|
||||||
|
readonly Animation overlay;
|
||||||
|
bool buildComplete;
|
||||||
|
bool visible;
|
||||||
|
|
||||||
|
public WithNukeLaunchOverlay(Actor self, WithNukeLaunchOverlayInfo info)
|
||||||
|
: base(info)
|
||||||
|
{
|
||||||
|
var rs = self.Trait<RenderSprites>();
|
||||||
|
var body = self.Trait<BodyOrientation>();
|
||||||
|
|
||||||
|
buildComplete = !self.Info.HasTraitInfo<BuildingInfo>(); // always render instantly for units
|
||||||
|
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 || !buildComplete,
|
||||||
|
p => RenderUtils.ZOffsetFromCenter(self, p, 1));
|
||||||
|
|
||||||
|
rs.Add(anim, info.Palette, info.IsPlayerPalette);
|
||||||
|
}
|
||||||
|
|
||||||
|
void INotifyBuildComplete.BuildingComplete(Actor self)
|
||||||
|
{
|
||||||
|
buildComplete = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void INotifySold.Sold(Actor self) { }
|
||||||
|
void INotifySold.Selling(Actor self)
|
||||||
|
{
|
||||||
|
buildComplete = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void INotifyNuke.Launching(Actor self)
|
||||||
|
{
|
||||||
|
visible = true;
|
||||||
|
overlay.PlayThen(overlay.CurrentSequence.Name, () => visible = false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -72,10 +72,6 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
[Desc("Corresponds to `Type` from `FlashPaletteEffect` on the world actor.")]
|
[Desc("Corresponds to `Type` from `FlashPaletteEffect` on the world actor.")]
|
||||||
public readonly string FlashType = null;
|
public readonly string FlashType = null;
|
||||||
|
|
||||||
[SequenceReference]
|
|
||||||
[Desc("Sequence the launching actor should play when activating this power.")]
|
|
||||||
public readonly string ActivationSequence = "active";
|
|
||||||
|
|
||||||
public WeaponInfo WeaponInfo { get; private set; }
|
public WeaponInfo WeaponInfo { get; private set; }
|
||||||
|
|
||||||
public override object Create(ActorInitializer init) { return new NukePower(init.Self, this); }
|
public override object Create(ActorInitializer init) { return new NukePower(init.Self, this); }
|
||||||
@@ -103,11 +99,8 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
base.Activate(self, order, manager);
|
base.Activate(self, order, manager);
|
||||||
PlayLaunchSounds();
|
PlayLaunchSounds();
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(info.ActivationSequence))
|
foreach (var launchpad in self.TraitsImplementing<INotifyNuke>())
|
||||||
{
|
launchpad.Launching(self);
|
||||||
var wsb = self.Trait<WithSpriteBody>();
|
|
||||||
wsb.PlayCustomAnimation(self, info.ActivationSequence);
|
|
||||||
}
|
|
||||||
|
|
||||||
var targetPosition = self.World.Map.CenterOfCell(order.TargetLocation);
|
var targetPosition = self.World.Map.CenterOfCell(order.TargetLocation);
|
||||||
var palette = info.IsPlayerPalette ? info.MissilePalette + self.Owner.InternalName : info.MissilePalette;
|
var palette = info.IsPlayerPalette ? info.MissilePalette + self.Owner.InternalName : info.MissilePalette;
|
||||||
|
|||||||
@@ -84,6 +84,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
public interface INotifyBuildingPlaced { void BuildingPlaced(Actor self); }
|
public interface INotifyBuildingPlaced { void BuildingPlaced(Actor self); }
|
||||||
public interface INotifyRepair { void Repairing(Actor self, Actor target); }
|
public interface INotifyRepair { void Repairing(Actor self, Actor target); }
|
||||||
|
public interface INotifyNuke { void Launching(Actor self); }
|
||||||
public interface INotifyBurstComplete { void FiredBurst(Actor self, Target target, Armament a); }
|
public interface INotifyBurstComplete { void FiredBurst(Actor self, Target target, Armament a); }
|
||||||
public interface INotifyChat { bool OnChat(string from, string message); }
|
public interface INotifyChat { bool OnChat(string from, string message); }
|
||||||
public interface INotifyProduction { void UnitProduced(Actor self, Actor other, CPos exit); }
|
public interface INotifyProduction { void UnitProduced(Actor self, Actor other, CPos exit); }
|
||||||
|
|||||||
@@ -974,6 +974,16 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// nuke launch animation is now it's own trait
|
||||||
|
if (engineVersion < 20170820)
|
||||||
|
{
|
||||||
|
if (depth == 1 && node.Key.StartsWith("NukePower"))
|
||||||
|
{
|
||||||
|
node.Value.Nodes.RemoveAll(n => n.Key == "ActivationSequence");
|
||||||
|
addNodes.Add(new MiniYamlNode("WithNukeLaunchAnimation", new MiniYaml("")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
UpgradeActorRules(modData, engineVersion, ref node.Value.Nodes, node, depth + 1);
|
UpgradeActorRules(modData, engineVersion, ref node.Value.Nodes, node, depth + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -724,6 +724,7 @@ TMPL:
|
|||||||
ArrowSequence: arrow
|
ArrowSequence: arrow
|
||||||
ClockSequence: clock
|
ClockSequence: clock
|
||||||
CircleSequence: circles
|
CircleSequence: circles
|
||||||
|
WithNukeLaunchAnimation:
|
||||||
SupportPowerChargeBar:
|
SupportPowerChargeBar:
|
||||||
Power:
|
Power:
|
||||||
Amount: -150
|
Amount: -150
|
||||||
|
|||||||
@@ -1072,9 +1072,13 @@ palace:
|
|||||||
DisplayBeacon: True
|
DisplayBeacon: True
|
||||||
DisplayRadarPing: True
|
DisplayRadarPing: True
|
||||||
CameraRange: 10c0
|
CameraRange: 10c0
|
||||||
ActivationSequence:
|
|
||||||
ArrowSequence: arrow
|
ArrowSequence: arrow
|
||||||
CircleSequence: circles
|
CircleSequence: circles
|
||||||
|
WithNukeLaunchOverlay:
|
||||||
|
RequiresCondition: !launchpad-damaged
|
||||||
|
GrantConditionOnDamageState@LAUNCHPADDAMAGED:
|
||||||
|
Condition: launchpad-damaged
|
||||||
|
ValidDamageState: Medium, Heavy, Critical
|
||||||
ProduceActorPower@fremen:
|
ProduceActorPower@fremen:
|
||||||
Description: Recruit Fremen
|
Description: Recruit Fremen
|
||||||
LongDesc: Elite infantry unit armed with assault rifles and rockets\n Strong vs Infantry, Vehicles\n Weak vs Artillery\n Special Ability: Invisibility
|
LongDesc: Elite infantry unit armed with assault rifles and rockets\n Strong vs Infantry, Vehicles\n Weak vs Artillery\n Special Ability: Invisibility
|
||||||
|
|||||||
@@ -566,6 +566,9 @@ palace.atreides:
|
|||||||
idle: DATA.R8
|
idle: DATA.R8
|
||||||
Start: 2924
|
Start: 2924
|
||||||
Offset: -48,48
|
Offset: -48,48
|
||||||
|
active: DATA.R8
|
||||||
|
Start: 2924
|
||||||
|
Offset: -48,48
|
||||||
make: DATA.R8
|
make: DATA.R8
|
||||||
Start: 4677
|
Start: 4677
|
||||||
Length: 11
|
Length: 11
|
||||||
@@ -980,10 +983,10 @@ palace.harkonnen:
|
|||||||
damaged-idle: DATA.R8
|
damaged-idle: DATA.R8
|
||||||
Start: 3085
|
Start: 3085
|
||||||
Offset: -48,48
|
Offset: -48,48
|
||||||
# active: DATA.R8 # TODO: overlay
|
active: DATA.R8
|
||||||
# Start: 5084
|
Start: 5084
|
||||||
# Length: 20
|
Length: 20
|
||||||
# Offset: -48,64
|
Offset: -48,64
|
||||||
damaged-active: DATA.R8
|
damaged-active: DATA.R8
|
||||||
Start: 5084
|
Start: 5084
|
||||||
Length: 20
|
Length: 20
|
||||||
@@ -1371,6 +1374,9 @@ palace.ordos:
|
|||||||
idle: DATA.R8
|
idle: DATA.R8
|
||||||
Start: 3244
|
Start: 3244
|
||||||
Offset: -48,48
|
Offset: -48,48
|
||||||
|
active: DATA.R8
|
||||||
|
Start: 3244
|
||||||
|
Offset: -48,48
|
||||||
make: DATA.R8
|
make: DATA.R8
|
||||||
Start: 4677
|
Start: 4677
|
||||||
Length: 11
|
Length: 11
|
||||||
@@ -1485,6 +1491,9 @@ palace.corrino:
|
|||||||
idle: DATA.R8
|
idle: DATA.R8
|
||||||
Start: 3252
|
Start: 3252
|
||||||
Offset: -48,48
|
Offset: -48,48
|
||||||
|
active: DATA.R8
|
||||||
|
Start: 3252
|
||||||
|
Offset: -48,48
|
||||||
damaged-idle: DATA.R8
|
damaged-idle: DATA.R8
|
||||||
Start: 3253
|
Start: 3253
|
||||||
Offset: -48,48
|
Offset: -48,48
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ MSLO:
|
|||||||
Amount: -150
|
Amount: -150
|
||||||
MustBeDestroyed:
|
MustBeDestroyed:
|
||||||
RequiredForShortGame: false
|
RequiredForShortGame: false
|
||||||
|
WithNukeLaunchAnimation:
|
||||||
|
|
||||||
GAP:
|
GAP:
|
||||||
Inherits: ^ScienceBuilding
|
Inherits: ^ScienceBuilding
|
||||||
|
|||||||
@@ -378,6 +378,7 @@ NAMISL:
|
|||||||
DisplayRadarPing: True
|
DisplayRadarPing: True
|
||||||
BeaconPoster:
|
BeaconPoster:
|
||||||
CameraRange: 10c0
|
CameraRange: 10c0
|
||||||
|
WithNukeLaunchOverlay:
|
||||||
SelectionDecorations:
|
SelectionDecorations:
|
||||||
VisualBounds: 75,48
|
VisualBounds: 75,48
|
||||||
|
|
||||||
|
|||||||
@@ -1871,10 +1871,10 @@ namisl:
|
|||||||
make: ntmislmk
|
make: ntmislmk
|
||||||
Length: 18
|
Length: 18
|
||||||
ShadowStart: 18
|
ShadowStart: 18
|
||||||
active: ntmisl_a # TODO: This is an overlay, but currently used as animation
|
active: ntmisl_a
|
||||||
Length: 10
|
Length: 10
|
||||||
Tick: 80
|
Tick: 80
|
||||||
damaged-active: ntmisl_a # TODO: This is an overlay, but currently used as animation
|
damaged-active: ntmisl_a
|
||||||
Start: 10
|
Start: 10
|
||||||
Length: 10
|
Length: 10
|
||||||
Tick: 80
|
Tick: 80
|
||||||
|
|||||||
Reference in New Issue
Block a user