Remove WithSpriteTurret.AimSequence

We can now use WithTurretAimAnimation instead.
This commit is contained in:
reaperrr
2017-09-16 22:31:06 +02:00
committed by abcdefg30
parent a1ad76ba74
commit 79c78090d1
3 changed files with 22 additions and 22 deletions

View File

@@ -25,9 +25,6 @@ namespace OpenRA.Mods.Common.Traits.Render
[Desc("Sequence name to use")]
[SequenceReference] public readonly string Sequence = "turret";
[Desc("Sequence name to use when prepared to fire")]
[SequenceReference] public readonly string AimSequence = null;
[Desc("Turreted 'Turret' key to display")]
public readonly string Turret = "primary";
@@ -62,10 +59,9 @@ namespace OpenRA.Mods.Common.Traits.Render
}
}
public class WithSpriteTurret : ConditionalTrait<WithSpriteTurretInfo>, INotifyBuildComplete, INotifySold, INotifyTransform, ITick, INotifyDamageStateChanged
public class WithSpriteTurret : ConditionalTrait<WithSpriteTurretInfo>, INotifyBuildComplete, INotifySold, INotifyTransform, INotifyDamageStateChanged
{
public readonly Animation DefaultAnimation;
protected readonly AttackBase Attack;
readonly RenderSprites rs;
readonly BodyOrientation body;
readonly Turreted t;
@@ -79,7 +75,6 @@ namespace OpenRA.Mods.Common.Traits.Render
{
rs = self.Trait<RenderSprites>();
body = self.Trait<BodyOrientation>();
Attack = self.TraitOrDefault<AttackBase>();
t = self.TraitsImplementing<Turreted>()
.First(tt => tt.Name == info.Turret);
arms = self.TraitsImplementing<Armament>()
@@ -119,26 +114,11 @@ namespace OpenRA.Mods.Common.Traits.Render
DefaultAnimation.ReplaceAnim(NormalizeSequence(self, DefaultAnimation.CurrentSequence.Name));
}
protected virtual void Tick(Actor self)
{
if (Info.AimSequence == null)
return;
var sequence = Attack.IsAiming ? Info.AimSequence : Info.Sequence;
DefaultAnimation.ReplaceAnim(sequence);
}
void INotifyDamageStateChanged.DamageStateChanged(Actor self, AttackInfo e)
{
DamageStateChanged(self);
}
void ITick.Tick(Actor self)
{
// Split into a protected method to allow subclassing
Tick(self);
}
public void PlayCustomAnimation(Actor self, string name, Action after = null)
{
DefaultAnimation.PlayThen(NormalizeSequence(self, name), () =>

View File

@@ -1756,6 +1756,24 @@ namespace OpenRA.Mods.Common.UtilityCommands
}
}
// Removed AimSequence from WithSpriteTurret, use WithTurretAimAnimation instead
if (engineVersion < 20180224)
{
var spriteTurret = node.Value.Nodes.FirstOrDefault(n => n.Key.StartsWith("WithSpriteTurret", StringComparison.Ordinal));
if (spriteTurret != null)
{
var aimSequence = spriteTurret.Value.Nodes.FirstOrDefault(n => n.Key == "AimSequence");
if (aimSequence != null)
{
var aimAnim = new MiniYamlNode("WithTurretAimAnimation", "");
RenameNodeKey(aimSequence, "Sequence");
aimAnim.Value.Nodes.Add(aimSequence);
spriteTurret.Value.Nodes.Remove(aimSequence);
node.Value.Nodes.Add(aimAnim);
}
}
}
UpgradeActorRules(modData, engineVersion, ref node.Value.Nodes, node, depth + 1);
}

View File

@@ -496,15 +496,17 @@ MSAM:
Weapon: 227mm
LocalOffset: 213,128,0, 213,-128,0
Armament@SECONDARY:
Name: secondary
Weapon: 227mm
LocalOffset: 213,-128,0, 213,128,0
AttackFrontal:
WithSpriteTurret:
AimSequence: aim
SpawnActorOnDeath:
Actor: MSAM.Husk
OwnerType: InternalName
EffectiveOwnerFromOwner: true
WithTurretAimAnimation:
Sequence: aim
MLRS:
Inherits: ^Tank