From 22494d7e8bfc8675ea5652501993ee234dafaf4b Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Sat, 17 Apr 2010 13:13:18 +1200 Subject: [PATCH] made muzzleflash a lot saner; implemented E4 for cnc --- .../Traits/Render/RenderUnitMuzzleFlash.cs | 30 ++- mods/cnc/infantry.yaml | 27 ++- mods/cnc/sequences-infantry.xml | 201 +++++++++--------- mods/cnc/vehicles.yaml | 3 +- mods/cnc/weapons.yaml | 1 - mods/ra/vehicles.yaml | 3 +- 6 files changed, 150 insertions(+), 115 deletions(-) diff --git a/OpenRA.Game/Traits/Render/RenderUnitMuzzleFlash.cs b/OpenRA.Game/Traits/Render/RenderUnitMuzzleFlash.cs index 00523dba80..7b48c3e95b 100644 --- a/OpenRA.Game/Traits/Render/RenderUnitMuzzleFlash.cs +++ b/OpenRA.Game/Traits/Render/RenderUnitMuzzleFlash.cs @@ -22,27 +22,37 @@ using OpenRA.Graphics; namespace OpenRA.Traits { - class RenderUnitMuzzleFlashInfo : RenderUnitInfo + class WithMuzzleFlashInfo : ITraitInfo, ITraitPrerequisite { - public override object Create(Actor self) { return new RenderUnitMuzzleFlash(self); } + public object Create(Actor self) { return new WithMuzzleFlash(self); } } - class RenderUnitMuzzleFlash : RenderUnit + class WithMuzzleFlash : INotifyAttack { - public RenderUnitMuzzleFlash(Actor self) - : base(self) + Animation muzzleFlash; + bool isShowing; + + public WithMuzzleFlash(Actor self) { var unit = self.traits.Get(); var attack = self.traits.Get(); var attackInfo = self.Info.Traits.Get(); + var render = self.traits.Get(); - var muzzleFlash = new Animation(GetImage(self), ()=>unit.Facing); - muzzleFlash.PlayFetchIndex("muzzle", - () => (int)(attack.primaryRecoil * 5.9f)); - anims.Add( "muzzle", new AnimationWithOffset( + muzzleFlash = new Animation(render.GetImage(self), () => unit.Facing); + muzzleFlash.Play("muzzle"); + var len = muzzleFlash.CurrentSequence.Length; + + render.anims.Add("muzzle", new RenderSimple.AnimationWithOffset( muzzleFlash, () => attackInfo.PrimaryOffset.AbsOffset(), - () => attack.primaryRecoil <= 0 ) ); + () => !isShowing)); + } + + public void Attacking(Actor self) + { + isShowing = true; + muzzleFlash.PlayThen("muzzle", () => isShowing = false); } } } diff --git a/mods/cnc/infantry.yaml b/mods/cnc/infantry.yaml index 740529a3c1..e299a038c1 100644 --- a/mods/cnc/infantry.yaml +++ b/mods/cnc/infantry.yaml @@ -54,8 +54,31 @@ E3: PrimaryWeapon: Rockets PrimaryOffset: 0,0,0,-10 FireDelay: 5 - TakeCover: - + TakeCover: + +E4: + Inherits: ^Infantry + Buildable: + TechLevel: 5 + Owner: nod + Cost: 200 + Description: Flamethrower + LongDesc: Advanced Anti-infantry unit.\n Strong vs Infantry, Buildings\n Weak vs Vehicles + Icon: e4icnh + Selectable: + Bounds: 12,17,0,-6 + Unit: + HP: 90 + Speed: 4 + AttackBase: + PrimaryWeapon: Flamethrower + PrimaryOffset: 0,0,0,-5 + FireDelay: 3 + TakeCover: + -RenderInfantry: + RenderInfantry: + WithMuzzleFlash: + C1: Inherits: ^Infantry Selectable: diff --git a/mods/cnc/sequences-infantry.xml b/mods/cnc/sequences-infantry.xml index 2567bf7c59..cf831b86f8 100644 --- a/mods/cnc/sequences-infantry.xml +++ b/mods/cnc/sequences-infantry.xml @@ -56,6 +56,7 @@ + @@ -81,104 +82,104 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/mods/cnc/vehicles.yaml b/mods/cnc/vehicles.yaml index d9d3a16b14..7652e579c2 100644 --- a/mods/cnc/vehicles.yaml +++ b/mods/cnc/vehicles.yaml @@ -71,7 +71,8 @@ APC: PrimaryWeapon: MachineGun PrimaryOffset: 0,0,0,-4 MuzzleFlash: yes - RenderUnitMuzzleFlash: + RenderUnit: + WithMuzzleFlash: AutoTarget: Cargo: PassengerTypes: Foot diff --git a/mods/cnc/weapons.yaml b/mods/cnc/weapons.yaml index 7eeb3f9425..5289f5360c 100644 --- a/mods/cnc/weapons.yaml +++ b/mods/cnc/weapons.yaml @@ -141,7 +141,6 @@ Flamethrower: Wood: yes Verses: 90%,100%,60%,25%,50% InfDeath: 4 - Explosion: 3 ImpactSound: flamer2 SmudgeType: Scorch Damage: 35 diff --git a/mods/ra/vehicles.yaml b/mods/ra/vehicles.yaml index 15d5de7a38..0d996ece88 100644 --- a/mods/ra/vehicles.yaml +++ b/mods/ra/vehicles.yaml @@ -326,7 +326,8 @@ APC: PrimaryWeapon: M60mg PrimaryOffset: 0,0,0,-4 MuzzleFlash: yes - RenderUnitMuzzleFlash: + RenderUnit: + WithMuzzleFlash: AutoTarget: Cargo: PassengerTypes: Foot