add muzzle flashes to pbox/hbox

This commit is contained in:
Chris Forbes
2011-05-30 20:26:57 +12:00
parent e24c8971b6
commit 0ba41acf4a
4 changed files with 45 additions and 17 deletions

View File

@@ -194,9 +194,10 @@ namespace OpenRA.Mods.RA
return Util.RotateVectorByFacing(localRecoil, facing, .7f); return Util.RotateVectorByFacing(localRecoil, facing, .7f);
} }
public static float2 GetTurretPosition(Actor self, IFacing facing, Turret turret) public static float2 GetTurretPosition(Actor self, IFacing facing, Turret turret)
{ {
if(facing == null) return turret.ScreenSpacePosition; /* things that don't have a rotating base don't need the turrets repositioned */ if (facing == null) return turret.ScreenSpacePosition; /* things that don't have a rotating base don't need the turrets repositioned */
var ru = self.TraitOrDefault<RenderUnit>(); var ru = self.TraitOrDefault<RenderUnit>();
var numDirs = (ru != null) ? ru.anim.CurrentSequence.Facings : 8; var numDirs = (ru != null) ? ru.anim.CurrentSequence.Facings : 8;

View File

@@ -11,10 +11,11 @@
using System.Collections.Generic; using System.Collections.Generic;
using OpenRA.Graphics; using OpenRA.Graphics;
using OpenRA.Traits; using OpenRA.Traits;
using System;
namespace OpenRA.Mods.RA.Render namespace OpenRA.Mods.RA.Render
{ {
class WithMuzzleFlashInfo : ITraitInfo, Requires<RenderSimpleInfo> class WithMuzzleFlashInfo : ITraitInfo, Requires<RenderSimpleInfo>, Requires<AttackBaseInfo>
{ {
public object Create(ActorInitializer init) { return new WithMuzzleFlash(init.self); } public object Create(ActorInitializer init) { return new WithMuzzleFlash(init.self); }
} }
@@ -28,21 +29,29 @@ namespace OpenRA.Mods.RA.Render
{ {
var attack = self.Trait<AttackBase>(); var attack = self.Trait<AttackBase>();
var render = self.Trait<RenderSimple>(); var render = self.Trait<RenderSimple>();
var facing = self.Trait<IFacing>(); var facing = self.TraitOrDefault<IFacing>();
var turreted = self.TraitOrDefault<Turreted>();
foreach (var t in attack.Turrets) var getFacing = facing != null
{ ? () => facing.Facing :
var turret = t; turreted != null ? (Func<int>)(() => turreted.turretFacing) : () => 0;
var muzzleFlash = new Animation(render.GetImage(self), () => self.Trait<IFacing>().Facing);
muzzleFlash.Play("muzzle");
render.anims.Add("muzzle{0}".F(muzzleFlashes.Count), new RenderSimple.AnimationWithOffset( foreach (var w in attack.Weapons)
muzzleFlash, foreach( var b in w.Barrels )
() => Combat.GetTurretPosition(self, facing, turret), {
() => !isShowing)); var barrel = b;
var turret = w.Turret;
muzzleFlashes.Add(muzzleFlash); var muzzleFlash = new Animation(render.GetImage(self), getFacing);
} muzzleFlash.Play("muzzle");
render.anims.Add("muzzle{0}".F(muzzleFlashes.Count), new RenderSimple.AnimationWithOffset(
muzzleFlash,
() => Combat.GetBarrelPosition(self, facing, turret, barrel),
() => !isShowing));
muzzleFlashes.Add(muzzleFlash);
}
} }
public void Attacking(Actor self, Target target) public void Attacking(Actor self, Target target)

View File

@@ -379,12 +379,17 @@ PBOX:
Type: Wood Type: Wood
RevealsShroud: RevealsShroud:
Range: 6 Range: 6
AttackOmni: AttackTurreted:
PrimaryWeapon: Vulcan PrimaryWeapon: Vulcan
PrimaryOffset: 0,0,0,-2
PrimaryLocalOffset: 0,-12,0
AutoTarget: AutoTarget:
IronCurtainable: IronCurtainable:
RenderRangeCircle: RenderRangeCircle:
-AcceptsSupplies: -AcceptsSupplies:
WithMuzzleFlash:
Turreted:
ROT: 255
HBOX: HBOX:
Inherits: ^Building Inherits: ^Building
@@ -408,12 +413,17 @@ HBOX:
Type: Wood Type: Wood
RevealsShroud: RevealsShroud:
Range: 6 Range: 6
AttackOmni: AttackTurreted:
PrimaryWeapon: Vulcan PrimaryWeapon: Vulcan
PrimaryOffset: 0,0,0,-2
PrimaryLocalOffset: 0,-12,0
AutoTarget: AutoTarget:
IronCurtainable: IronCurtainable:
RenderRangeCircle: RenderRangeCircle:
-AcceptsSupplies: -AcceptsSupplies:
WithMuzzleFlash:
Turreted:
ROT: 255
GUN: GUN:
Inherits: ^Building Inherits: ^Building

View File

@@ -285,6 +285,10 @@ pbox:
make: pboxmake make: pboxmake
Start: 0 Start: 0
Length: * Length: *
muzzle: minigun
Start: 0
Length: 6
Facings: 8
hbox: hbox:
damaged-idle: damaged-idle:
@@ -294,6 +298,10 @@ hbox:
make: hboxmake make: hboxmake
Start: 0 Start: 0
Length: * Length: *
muzzle: minigun
Start: 0
Length: 6
Facings: 8
gap: gap:
idle: idle: