Merge pull request #11428 from reaperrr/attack-delay
Allow attack anims/overlays to start before weapons fire
This commit is contained in:
@@ -92,7 +92,10 @@ namespace OpenRA.Mods.D2k.Activities
|
||||
});
|
||||
|
||||
foreach (var notify in self.TraitsImplementing<INotifyAttack>())
|
||||
{
|
||||
notify.PreparingAttack(self, target, null, null);
|
||||
notify.Attacking(self, target, null, null);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -98,7 +98,6 @@
|
||||
<Compile Include="Warheads\ChangeOwnerWarhead.cs" />
|
||||
<Compile Include="UtilityCommands\D2kMapImporter.cs" />
|
||||
<Compile Include="UtilityCommands\ImportD2kMapCommand.cs" />
|
||||
<Compile Include="Traits\Render\WithAttackOverlay.cs" />
|
||||
<Compile Include="Traits\Render\WithDecorationCarryable.cs" />
|
||||
<Compile Include="Traits\World\D2kEditorResourceLayer.cs" />
|
||||
<Compile Include="Lint\CheckImportActors.cs" />
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2016 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.D2k.Traits.Render
|
||||
{
|
||||
[Desc("Rendered together with an attack.")]
|
||||
public class WithAttackOverlayInfo : ITraitInfo, Requires<RenderSpritesInfo>
|
||||
{
|
||||
[FieldLoader.Require]
|
||||
[Desc("Sequence name to use")]
|
||||
[SequenceReference] public readonly string Sequence = null;
|
||||
|
||||
[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 object Create(ActorInitializer init) { return new WithAttackOverlay(init, this); }
|
||||
}
|
||||
|
||||
public class WithAttackOverlay : INotifyAttack
|
||||
{
|
||||
readonly Animation overlay;
|
||||
readonly RenderSprites renderSprites;
|
||||
readonly WithAttackOverlayInfo info;
|
||||
|
||||
bool attacking;
|
||||
|
||||
public WithAttackOverlay(ActorInitializer init, WithAttackOverlayInfo info)
|
||||
{
|
||||
this.info = info;
|
||||
|
||||
renderSprites = init.Self.Trait<RenderSprites>();
|
||||
|
||||
overlay = new Animation(init.World, renderSprites.GetImage(init.Self));
|
||||
|
||||
renderSprites.Add(new AnimationWithOffset(overlay, null, () => !attacking),
|
||||
info.Palette, info.IsPlayerPalette);
|
||||
}
|
||||
|
||||
public void Attacking(Actor self, Target target, Armament a, Barrel barrel)
|
||||
{
|
||||
attacking = true;
|
||||
overlay.PlayThen(info.Sequence, () => attacking = false);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user