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

Some necessary functions & fix for AttackOverlay #21411

Merged
merged 5 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 14 additions & 4 deletions OpenRA.Mods.Common/Traits/Render/WithAttackOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ namespace OpenRA.Mods.Common.Traits.Render
[Desc("Rendered together with an attack.")]
public class WithAttackOverlayInfo : TraitInfo, Requires<RenderSpritesInfo>
{
[Desc("Armament that will play the animation. Set to null to allow all armaments.")]
public readonly string Armament = null;

[SequenceReference]
[FieldLoader.Require]
[Desc("Sequence name to use")]
Expand All @@ -29,6 +32,8 @@ public class WithAttackOverlayInfo : TraitInfo, Requires<RenderSpritesInfo>
[Desc("Custom palette is a player palette BaseName")]
public readonly bool IsPlayerPalette = false;

public readonly bool IsDecoration = false;

[Desc("Delay in ticks before overlay starts, either relative to attack preparation or attack.")]
public readonly int Delay = 0;

Expand All @@ -52,10 +57,15 @@ public WithAttackOverlay(ActorInitializer init, WithAttackOverlayInfo info)
this.info = info;

renderSprites = init.Self.Trait<RenderSprites>();
var body = init.Self.TraitOrDefault<BodyOrientation>();
var facing = init.Self.TraitOrDefault<IFacing>();

overlay = new Animation(init.World, renderSprites.GetImage(init.Self), RenderSprites.MakeFacingFunc(init.Self));
overlay = new Animation(init.World, renderSprites.GetImage(init.Self), facing == null ? () => WAngle.Zero : (body == null ? () => facing.Facing : () => body.QuantizeFacing(facing.Facing)))
{
IsDecoration = info.IsDecoration
};

renderSprites.Add(new AnimationWithOffset(overlay, null, () => !attacking),
renderSprites.Add(new AnimationWithOffset(overlay, null, () => !attacking, p => RenderUtils.ZOffsetFromCenter(init.Self, p, 1)),
info.Palette, info.IsPlayerPalette);
}

Expand All @@ -67,7 +77,7 @@ void PlayOverlay()

void INotifyAttack.Attacking(Actor self, in Target target, Armament a, Barrel barrel)
{
if (info.DelayRelativeTo == AttackDelayType.Attack)
if (info.DelayRelativeTo == AttackDelayType.Attack && (string.IsNullOrEmpty(info.Armament) || info.Armament == a.Info.Name))
{
if (info.Delay > 0)
tick = info.Delay;
Expand All @@ -78,7 +88,7 @@ void INotifyAttack.Attacking(Actor self, in Target target, Armament a, Barrel ba

void INotifyAttack.PreparingAttack(Actor self, in Target target, Armament a, Barrel barrel)
{
if (info.DelayRelativeTo == AttackDelayType.Preparation)
if (info.DelayRelativeTo == AttackDelayType.Preparation && (string.IsNullOrEmpty(info.Armament) || info.Armament == a.Info.Name))
{
if (info.Delay > 0)
tick = info.Delay;
Expand Down
19 changes: 8 additions & 11 deletions mods/ts/rules/gdi-vehicles.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -139,22 +139,19 @@ SMECH:
FacingTolerance: 0
Armament:
Weapon: AssaultCannon
LocalOffset: 0,0,620
Voiced:
VoiceSet: Mech
QuantizeFacingsFromSequence:
Sequence: stand
WithFacingSpriteBody:
Sequence: stand
Palette: player-nomuzzle
IsPlayerPalette: True
WithAttackAnimation:
Sequence: shoot
WithInfantryBody:
DefaultAttackSequence: shoot
RequiresCondition: !inside-tunnel
BodyOrientation:
QuantizedFacings: 8
CameraPitch: 250
WithAttackOverlay@muzzle:
Sequence: shoot-muzzle
Palette: muzzle
WithMoveAnimation:
MoveSequence: walk
ValidMovementTypes: Horizontal, Turn
IsDecoration: true
Selectable:
Bounds: 603, 1930, 0, -482
-DamagedByTerrain@VEINS:
Expand Down
2 changes: 1 addition & 1 deletion mods/ts/sequences/vehicles.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ smech:
Start: 96
Facings: -8
ShadowStart: 232
walk:
run:
Facings: -8
Length: 12
ShadowStart: 136
Expand Down