Render integrated muzzle flashes as their own tint-ignoring animations.

This commit is contained in:
Paul Chote
2021-02-05 22:16:31 +00:00
committed by reaperrr
parent 594e5b80d7
commit 5832ec76d4
13 changed files with 215 additions and 26 deletions

View File

@@ -0,0 +1,58 @@
#region Copyright & License Information
/*
* Copyright 2007-2021 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.Cnc.Traits.Render
{
class WithSplitAttackPaletteInfantryBodyInfo : WithInfantryBodyInfo
{
[PaletteReference]
[Desc("Palette to use for the split attack rendering.")]
public readonly string SplitAttackPalette = null;
[Desc("Sequence suffix to use.")]
public readonly string SplitAttackSuffix = "muzzle";
public override object Create(ActorInitializer init) { return new WithSplitAttackPaletteInfantryBody(init, this); }
}
class WithSplitAttackPaletteInfantryBody : WithInfantryBody
{
readonly WithSplitAttackPaletteInfantryBodyInfo info;
readonly Animation splitAnimation;
bool visible;
public WithSplitAttackPaletteInfantryBody(ActorInitializer init, WithSplitAttackPaletteInfantryBodyInfo info)
: base(init, info)
{
this.info = info;
var rs = init.Self.Trait<RenderSprites>();
splitAnimation = new Animation(init.World, rs.GetImage(init.Self), RenderSprites.MakeFacingFunc(init.Self));
rs.Add(new AnimationWithOffset(splitAnimation, null, () => IsTraitDisabled || !visible), info.SplitAttackPalette);
}
protected override void Attacking(Actor self, Armament a, Barrel barrel)
{
base.Attacking(self, a, barrel);
var sequence = DefaultAnimation.CurrentSequence.Name + "-" + info.SplitAttackSuffix;
if (state == AnimationState.Attacking && splitAnimation.HasSequence(sequence))
{
visible = true;
splitAnimation.PlayThen(sequence, () => visible = false);
}
}
}
}

View File

@@ -74,7 +74,7 @@ namespace OpenRA.Mods.Common.Traits.Render
bool dirty; bool dirty;
string idleSequence; string idleSequence;
int idleDelay; int idleDelay;
AnimationState state; protected AnimationState state;
IRenderInfantrySequenceModifier rsm; IRenderInfantrySequenceModifier rsm;
bool IsModifyingSequence => rsm != null && rsm.IsModifyingSequence; bool IsModifyingSequence => rsm != null && rsm.IsModifyingSequence;
@@ -135,7 +135,7 @@ namespace OpenRA.Mods.Common.Traits.Render
} }
} }
void Attacking(Actor self, Armament a, Barrel barrel) protected virtual void Attacking(Actor self, Armament a, Barrel barrel)
{ {
var info = GetDisplayInfo(); var info = GetDisplayInfo();
var sequence = info.DefaultAttackSequence; var sequence = info.DefaultAttackSequence;
@@ -213,7 +213,7 @@ namespace OpenRA.Mods.Common.Traits.Render
} }
} }
enum AnimationState protected enum AnimationState
{ {
Idle, Idle,
Attacking, Attacking,

View File

@@ -48,7 +48,7 @@ UMAGON:
Weapon: Sniper Weapon: Sniper
AttackFrontal: AttackFrontal:
Voice: Attack Voice: Attack
WithInfantryBody: WithSplitAttackPaletteInfantryBody:
DefaultAttackSequence: attack DefaultAttackSequence: attack
ProducibleWithLevel: ProducibleWithLevel:
Prerequisites: barracks.upgraded Prerequisites: barracks.upgraded
@@ -80,7 +80,7 @@ CHAMSPY:
Infiltrates: Infiltrates:
Types: SpyInfiltrate Types: SpyInfiltrate
Notification: BuildingInfiltrated Notification: BuildingInfiltrated
-WithInfantryBody: -WithSplitAttackPaletteInfantryBody:
WithDisguisingInfantryBody: WithDisguisingInfantryBody:
IdleSequences: idle1, idle2 IdleSequences: idle1, idle2
@@ -106,7 +106,7 @@ MUTANT:
Weapon: Vulcan Weapon: Vulcan
AttackFrontal: AttackFrontal:
Voice: Attack Voice: Attack
WithInfantryBody: WithSplitAttackPaletteInfantryBody:
DefaultAttackSequence: attack DefaultAttackSequence: attack
ProducibleWithLevel: ProducibleWithLevel:
Prerequisites: barracks.upgraded Prerequisites: barracks.upgraded
@@ -133,7 +133,7 @@ MWMN:
Weapon: Vulcan Weapon: Vulcan
AttackFrontal: AttackFrontal:
Voice: Attack Voice: Attack
WithInfantryBody: WithSplitAttackPaletteInfantryBody:
DefaultAttackSequence: attack DefaultAttackSequence: attack
ProducibleWithLevel: ProducibleWithLevel:
Prerequisites: barracks.upgraded Prerequisites: barracks.upgraded
@@ -160,8 +160,10 @@ MUTANT3:
Weapon: Vulcan Weapon: Vulcan
AttackFrontal: AttackFrontal:
Voice: Attack Voice: Attack
WithInfantryBody: WithSplitAttackPaletteInfantryBody:
DefaultAttackSequence: attack DefaultAttackSequence: attack
Palette: player-nobright
SplitAttackPalette: bright
ProducibleWithLevel: ProducibleWithLevel:
Prerequisites: barracks.upgraded Prerequisites: barracks.upgraded
@@ -180,8 +182,6 @@ TRATOS:
Speed: 71 Speed: 71
RevealsShroud: RevealsShroud:
Range: 4c0 Range: 4c0
WithInfantryBody:
DefaultAttackSequence:
OXANNA: OXANNA:
Inherits: ^Soldier Inherits: ^Soldier
@@ -197,7 +197,7 @@ OXANNA:
Speed: 56 Speed: 56
RevealsShroud: RevealsShroud:
Range: 4c0 Range: 4c0
WithInfantryBody: WithSplitAttackPaletteInfantryBody:
DefaultAttackSequence: attack DefaultAttackSequence: attack
SLAV: SLAV:
@@ -214,14 +214,16 @@ SLAV:
Speed: 56 Speed: 56
RevealsShroud: RevealsShroud:
Range: 4c0 Range: 4c0
WithInfantryBody: WithSplitAttackPaletteInfantryBody:
DefaultAttackSequence: attack DefaultAttackSequence: attack
CIV1: CIV1:
Inherits: ^CivilianInfantry Inherits: ^CivilianInfantry
Inherits@AUTOTARGET: ^AutoTargetGroundAssaultMove Inherits@AUTOTARGET: ^AutoTargetGroundAssaultMove
WithInfantryBody: WithSplitAttackPaletteInfantryBody:
DefaultAttackSequence: attack DefaultAttackSequence: attack
Palette: player-nomuzzle
SplitAttackPalette: muzzle
Armament: Armament:
Weapon: Pistola Weapon: Pistola
AttackFrontal: AttackFrontal:
@@ -244,8 +246,10 @@ CTECH:
Inherits@AUTOTARGET: ^AutoTargetGroundAssaultMove Inherits@AUTOTARGET: ^AutoTargetGroundAssaultMove
RenderSprites: RenderSprites:
Image: civ3 Image: civ3
WithInfantryBody: WithSplitAttackPaletteInfantryBody:
DefaultAttackSequence: attack DefaultAttackSequence: attack
Palette: player-nomuzzle
SplitAttackPalette: muzzle
Armament: Armament:
Weapon: Pistola Weapon: Pistola
AttackFrontal: AttackFrontal:

View File

@@ -131,8 +131,12 @@ JFISH:
MaxMoveDelay: 600 MaxMoveDelay: 600
WithAttackAnimation: WithAttackAnimation:
Sequence: attack Sequence: attack
WithAttackOverlay@muzzle:
Sequence: attack-shock
Palette: bright
RenderSprites: RenderSprites:
Image: floater Image: floater
Palette: player-nobright
Selectable: Selectable:
Bounds: 32,32,0,-5 Bounds: 32,32,0,-5
AmbientSound: AmbientSound:

View File

@@ -585,7 +585,7 @@
ValidDamageStates: Light, Medium, Heavy, Critical ValidDamageStates: Light, Medium, Heavy, Critical
QuantizeFacingsFromSequence: QuantizeFacingsFromSequence:
Sequence: stand Sequence: stand
WithInfantryBody: WithSplitAttackPaletteInfantryBody:
AttackMove: AttackMove:
Voice: Move Voice: Move
Passenger: Passenger:
@@ -705,8 +705,10 @@
Prone350Percent: 350 Prone350Percent: 350
DamageTriggers: TriggerProne DamageTriggers: TriggerProne
ProneOffset: 300,0,0 ProneOffset: 300,0,0
WithInfantryBody: WithSplitAttackPaletteInfantryBody:
IdleSequences: idle1, idle2 IdleSequences: idle1, idle2
Palette: player-nomuzzle
SplitAttackPalette: muzzle
^Cyborg: ^Cyborg:
Inherits@1: ^Infantry Inherits@1: ^Infantry
@@ -734,9 +736,11 @@
Prone350Percent: 350 Prone350Percent: 350
ProneOffset: 300,0,0 ProneOffset: 300,0,0
ProneSequencePrefix: crippled- ProneSequencePrefix: crippled-
WithInfantryBody: WithSplitAttackPaletteInfantryBody:
DefaultAttackSequence: attack DefaultAttackSequence: attack
IdleSequences: idle1, idle2 IdleSequences: idle1, idle2
Palette: player-nomuzzle
SplitAttackPalette: muzzle
GrantConditionOnDamageState@CRITICAL: GrantConditionOnDamageState@CRITICAL:
Condition: critical Condition: critical
ValidDamageStates: Critical ValidDamageStates: Critical

View File

@@ -26,7 +26,7 @@ E2:
ProneOffset: 160,128,-555 ProneOffset: 160,128,-555
AttackFrontal: AttackFrontal:
Voice: Attack Voice: Attack
WithInfantryBody: WithSplitAttackPaletteInfantryBody:
DefaultAttackSequence: attack DefaultAttackSequence: attack
RevealsShroud: RevealsShroud:
Range: 7c0 Range: 7c0
@@ -77,7 +77,7 @@ MEDIC:
AutoTargetPriority@DEFAULT: AutoTargetPriority@DEFAULT:
ValidTargets: Infantry ValidTargets: Infantry
AttackFrontal: AttackFrontal:
WithInfantryBody: WithSplitAttackPaletteInfantryBody:
DefaultAttackSequence: heal DefaultAttackSequence: heal
ChangesHealth: ChangesHealth:
Step: 500 Step: 500
@@ -119,7 +119,7 @@ JUMPJET:
-Crushable: -Crushable:
AttackFrontal: AttackFrontal:
Voice: Attack Voice: Attack
WithInfantryBody: WithSplitAttackPaletteInfantryBody:
RequiresCondition: !airborne RequiresCondition: !airborne
DefaultAttackSequence: attack DefaultAttackSequence: attack
WithInfantryBody@flying: WithInfantryBody@flying:
@@ -127,6 +127,13 @@ JUMPJET:
DefaultAttackSequence: flying-attack DefaultAttackSequence: flying-attack
StandSequences: flying StandSequences: flying
MoveSequence: flying MoveSequence: flying
Palette: player-nomuzzle
WithInfantryBody@flying-muzzle:
RequiresCondition: airborne
DefaultAttackSequence: flying-attack-muzzle
StandSequences: flying-muzzle
MoveSequence: flying-muzzle
Palette: muzzle
-TakeCover: -TakeCover:
Hovers: Hovers:
RequiresCondition: airborne RequiresCondition: airborne
@@ -243,7 +250,7 @@ GHOST:
Demolition: Demolition:
DetonationDelay: 45 DetonationDelay: 45
Voice: Attack Voice: Attack
WithInfantryBody: WithSplitAttackPaletteInfantryBody:
DefaultAttackSequence: attack DefaultAttackSequence: attack
ProducibleWithLevel: ProducibleWithLevel:
Prerequisites: barracks.upgraded Prerequisites: barracks.upgraded

View File

@@ -142,8 +142,13 @@ SMECH:
Sequence: stand Sequence: stand
WithFacingSpriteBody: WithFacingSpriteBody:
Sequence: stand Sequence: stand
Palette: player-nomuzzle
IsPlayerPalette: True
WithAttackAnimation: WithAttackAnimation:
Sequence: shoot Sequence: shoot
WithAttackOverlay@muzzle:
Sequence: shoot-muzzle
Palette: muzzle
WithMoveAnimation: WithMoveAnimation:
MoveSequence: walk MoveSequence: walk
ValidMovementTypes: Horizontal, Turn ValidMovementTypes: Horizontal, Turn

View File

@@ -27,7 +27,7 @@ E3:
ProneOffset: 52,64,-652 ProneOffset: 52,64,-652
AttackFrontal: AttackFrontal:
Voice: Attack Voice: Attack
WithInfantryBody: WithSplitAttackPaletteInfantryBody:
DefaultAttackSequence: attack DefaultAttackSequence: attack
RevealsShroud: RevealsShroud:
Range: 7c0 Range: 7c0

View File

@@ -31,6 +31,40 @@
Tileset: TEMPERATE Tileset: TEMPERATE
Filename: unittem.pal Filename: unittem.pal
ShadowIndex: 1 ShadowIndex: 1
PaletteFromFile@playersno-nomuzzle:
Name: player-nomuzzle
Tileset: SNOW
Filename: unitsno.pal
ShadowIndex: 1
TransparentIndex: 0, 246, 247, 248, 249, 250
PaletteFromFile@playertem-nomuzzle:
Name: player-nomuzzle
Tileset: TEMPERATE
Filename: unittem.pal
ShadowIndex: 1
TransparentIndex: 0, 246, 247, 248, 249, 250
PaletteFromFile@playersno-nobright:
Name: player-nobright
Tileset: SNOW
Filename: unitsno.pal
ShadowIndex: 1
TransparentIndex: 0, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255
PaletteFromFile@playertem-nobright:
Name: player-nobright
Tileset: TEMPERATE
Filename: unittem.pal
ShadowIndex: 1
TransparentIndex: 0, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255
PaletteFromFile@muzzle:
Name: muzzle
Filename: unittem.pal
ShadowIndex: 1
TransparentIndex: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 251, 252, 253, 254, 255
PaletteFromFile@bright:
Name: bright
Filename: unittem.pal
ShadowIndex: 1
TransparentIndex: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239
PaletteFromFile@depth: PaletteFromFile@depth:
Name: depth Name: depth
Filename: depth.pal Filename: depth.pal
@@ -102,6 +136,14 @@
PlayerColorPalette: PlayerColorPalette:
BasePalette: player BasePalette: player
RemapIndex: 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 RemapIndex: 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31
PlayerColorPalette@NOMUZZLE:
BaseName: player-nomuzzle
BasePalette: player-nomuzzle
RemapIndex: 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31
PlayerColorPalette@NOBRIGHT:
BaseName: player-nobright
BasePalette: player-nobright
RemapIndex: 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31
PaletteFromPlayerPaletteWithAlpha@cloak: PaletteFromPlayerPaletteWithAlpha@cloak:
BaseName: cloak BaseName: cloak
BasePalette: player BasePalette: player

View File

@@ -26,7 +26,7 @@ E1:
RequiresCondition: rank-elite RequiresCondition: rank-elite
AttackFrontal: AttackFrontal:
Voice: Attack Voice: Attack
WithInfantryBody: WithSplitAttackPaletteInfantryBody:
DefaultAttackSequence: attack DefaultAttackSequence: attack
ProducibleWithLevel: ProducibleWithLevel:
Prerequisites: barracks.upgraded Prerequisites: barracks.upgraded

View File

@@ -91,3 +91,9 @@ floater:
ShadowStart: 48 ShadowStart: 48
Tick: 100 Tick: 100
Offset: 0, 0, 16 Offset: 0, 0, 16
attack-shock:
Length: 16
Start: 16
Tick: 100
Offset: 0, 0, 16
IgnoreWorldTint: True

View File

@@ -59,11 +59,21 @@
Length: 6 Length: 6
Facings: 8 Facings: 8
ShadowStart: 456 ShadowStart: 456
attack-muzzle:
Start: 164
Length: 6
Facings: 8
IgnoreWorldTint: True
prone-attack: prone-attack:
Start: 212 Start: 212
Length: 6 Length: 6
Facings: 8 Facings: 8
ShadowStart: 504 ShadowStart: 504
prone-attack-muzzle:
Start: 212
Length: 6
Facings: 8
IgnoreWorldTint: True
e1.gdi: e1.gdi:
Inherits: ^BasicInfantry Inherits: ^BasicInfantry
@@ -149,11 +159,12 @@ civ1:
Length: 6 Length: 6
Facings: 8 Facings: 8
ShadowStart: 456 ShadowStart: 456
panic-attack: attack-muzzle:
Start: 164 Start: 164
Length: 6 Length: 6
Facings: 8 Facings: 8
ShadowStart: 456 ShadowStart: 456
IgnoreWorldTint: True
panic-run: panic-run:
Start: 86 Start: 86
Length: 6 Length: 6
@@ -212,11 +223,21 @@ cyborg:
Length: 6 Length: 6
Facings: 8 Facings: 8
ShadowStart: 534 ShadowStart: 534
attack-muzzle:
Start: 164
Length: 6
Facings: 8
IgnoreWorldTint: True
crippled-attack: crippled-attack:
Start: 212 Start: 212
Length: 6 Length: 6
Facings: 8 Facings: 8
ShadowStart: 582 ShadowStart: 582
crippled-attack-muzzle:
Start: 212
Length: 6
Facings: 8
IgnoreWorldTint: True
emp-overlay: emp_fx01 emp-overlay: emp_fx01
Length: * Length: *
ZOffset: 512 ZOffset: 512
@@ -259,11 +280,23 @@ cyc2:
Length: 6 Length: 6
Facings: 8 Facings: 8
ShadowStart: 520 ShadowStart: 520
attack-muzzle:
Start: 212
Length: 6
Facings: 8
ShadowStart: 520
IgnoreWorldTint: True
crippled-attack: crippled-attack:
Start: 260 Start: 260
Length: 6 Length: 6
Facings: 8 Facings: 8
ShadowStart: 568 ShadowStart: 568
crippled-attack-muzzle:
Start: 260
Length: 6
Facings: 8
ShadowStart: 568
IgnoreWorldTint: True
emp-overlay: emp_fx01 emp-overlay: emp_fx01
Length: * Length: *
ZOffset: 512 ZOffset: 512
@@ -364,6 +397,11 @@ jumpjet:
Length: 6 Length: 6
Start: 292 Start: 292
ShadowStart: 743 ShadowStart: 743
flying-muzzle:
Facings: 8
Length: 6
Start: 292
IgnoreWorldTint: True
die-twirling: # TODO: animation for falling from sky starts at 436 die-twirling: # TODO: animation for falling from sky starts at 436
Start: 445 Start: 445
Length: 6 Length: 6
@@ -389,16 +427,31 @@ jumpjet:
Length: 6 Length: 6
Facings: 8 Facings: 8
ShadowStart: 615 ShadowStart: 615
attack-muzzle:
Start: 164
Length: 6
Facings: 8
IgnoreWorldTint: True
flying-attack: flying-attack:
Start: 388 Start: 388
Facings: 8 Facings: 8
Length: 6 Length: 6
ShadowStart: 839 ShadowStart: 839
flying-attack-muzzle:
Start: 388
Facings: 8
Length: 6
IgnoreWorldTint: True
prone-attack: prone-attack:
Start: 212 Start: 212
Length: 6 Length: 6
Facings: 8 Facings: 8
ShadowStart: 663 ShadowStart: 663
prone-attack-muzzle:
Start: 212
Length: 6
Facings: 8
IgnoreWorldTint: True
standup: standup:
Start: 260 Start: 260
Length: 2 Length: 2

View File

@@ -250,6 +250,12 @@ smech:
Facings: -8 Facings: -8
ShadowStart: 240 ShadowStart: 240
Tick: 80 Tick: 80
shoot-muzzle:
Start: 104
Length: 4
Facings: -8
Tick: 80
IgnoreWorldTint: True
icon: smchicon icon: smchicon
trucka: trucka: