add ability to emit a muzzleflash from multiple weapons; make ftnk somewhat nicer

This commit is contained in:
Chris Forbes
2010-09-07 19:05:14 +12:00
parent 173dc59039
commit fee6d450e4
4 changed files with 30 additions and 16 deletions

View File

@@ -8,6 +8,7 @@
*/ */
#endregion #endregion
using System.Collections.Generic;
using OpenRA.Graphics; using OpenRA.Graphics;
using OpenRA.Traits; using OpenRA.Traits;
@@ -20,27 +21,36 @@ namespace OpenRA.Mods.RA
class WithMuzzleFlash : INotifyAttack class WithMuzzleFlash : INotifyAttack
{ {
Animation muzzleFlash; List<Animation> muzzleFlashes = new List<Animation>();
bool isShowing; bool isShowing;
public WithMuzzleFlash(Actor self) public WithMuzzleFlash(Actor self)
{ {
var attackInfo = self.Info.Traits.Get<AttackBaseInfo>(); var attackInfo = self.Info.Traits.Get<AttackBaseInfo>();
var attack = self.Trait<AttackBase>();
var render = self.Trait<RenderSimple>(); var render = self.Trait<RenderSimple>();
var facing = self.Trait<IFacing>();
muzzleFlash = new Animation(render.GetImage(self), () => self.Trait<IFacing>().Facing); foreach (var t in attack.Turrets)
{
var turret = t;
var muzzleFlash = new Animation(render.GetImage(self), () => self.Trait<IFacing>().Facing);
muzzleFlash.Play("muzzle"); muzzleFlash.Play("muzzle");
render.anims.Add("muzzle", new RenderSimple.AnimationWithOffset( render.anims.Add("muzzle{0}".F(muzzleFlashes.Count), new RenderSimple.AnimationWithOffset(
muzzleFlash, muzzleFlash,
() => attackInfo.PrimaryOffset.AbsOffset(), () => Combat.GetTurretPosition(self, facing, turret),
() => !isShowing)); () => !isShowing));
muzzleFlashes.Add(muzzleFlash);
}
} }
public void Attacking(Actor self) public void Attacking(Actor self)
{ {
isShowing = true; isShowing = true;
muzzleFlash.PlayThen("muzzle", () => isShowing = false); foreach( var mf in muzzleFlashes )
mf.PlayThen("muzzle", () => isShowing = false);
} }
} }
} }

View File

@@ -67,7 +67,8 @@
</unit> </unit>
<!-- Flame Tank --> <!-- Flame Tank -->
<unit name="ftnk"> <unit name="ftnk">
<sequence name="idle" start="0" facings="32" /> <sequence name="idle" start="0" length="1" facings="32" />
<sequence name="muzzle" start="0" length="13" facings="8" src="flame" />
</unit> </unit>
<!-- Mobile HQ --> <!-- Mobile HQ -->
<unit name="mhq"> <unit name="mhq">
@@ -78,7 +79,8 @@
<unit name="msam"> <unit name="msam">
<sequence name="idle" start="0" facings="32" /> <sequence name="idle" start="0" facings="32" />
<sequence name="turret" start="32" facings="32" /> <sequence name="turret" start="32" facings="32" />
<sequence name="aim" start="64" facings="32" /> <!-- hack --> <sequence name="aim" start="64" facings="32" />
<!-- hack -->
<sequence name="turret-3" start="64" facings="32" /> <sequence name="turret-3" start="64" facings="32" />
</unit> </unit>
<!-- SSM Launcher --> <!-- SSM Launcher -->

View File

@@ -136,10 +136,12 @@ FTNK:
Range: 4 Range: 4
AttackBase: AttackBase:
PrimaryWeapon: BigFlamer PrimaryWeapon: BigFlamer
PrimaryOffset: 0,0,0,-2 PrimaryOffset: 2,-8,0,-2
MuzzleFlash: yes SecondaryWeapon: BigFlamer
SecondaryOffset: -2,-8,0,-2
RenderUnit: RenderUnit:
AutoTarget: AutoTarget:
WithMuzzleFlash:
BGGY: BGGY:
Inherits: ^Vehicle Inherits: ^Vehicle

View File

@@ -170,10 +170,10 @@ Flamethrower:
BigFlamer: BigFlamer:
ROF: 50 ROF: 50
Range: 2 Range: 3.5
Report: FLAMER2 Report: FLAMER2
Projectile: Bullet Projectile: Bullet
Speed: 100 Speed: 20
Warhead: Warhead:
Spread: 8 Spread: 8
Verses: 90%,100%,60%,25%,50% Verses: 90%,100%,60%,25%,50%
@@ -181,7 +181,7 @@ BigFlamer:
Explosion: 3 Explosion: 3
ImpactSound: flamer2 ImpactSound: flamer2
SmudgeType: Scorch SmudgeType: Scorch
Damage: 50 Damage: 40
Chemspray: Chemspray:
ROF: 70 ROF: 70