This commit is contained in:
Chris Forbes
2009-11-09 23:20:19 +13:00
parent 0040db61cd
commit df00598d98
5 changed files with 26 additions and 4 deletions

View File

@@ -51,6 +51,7 @@ namespace OpenRa.Game.GameRules
public readonly int[] SecondaryOffset = null; public readonly int[] SecondaryOffset = null;
public readonly int Recoil = 0; public readonly int Recoil = 0;
public readonly string SecondaryAnim = null; public readonly string SecondaryAnim = null;
public readonly bool MuzzleFlash = false;
public UnitInfo(string name) { Name = name; } public UnitInfo(string name) { Name = name; }

View File

@@ -33,6 +33,9 @@ namespace OpenRa.Game.Traits.Activities
} }
} }
public void Cancel(Actor self, Mobile mobile) { } public void Cancel(Actor self, Mobile mobile)
{
mobile.InternalSetActivity(null);
}
} }
} }

View File

@@ -10,6 +10,7 @@ namespace OpenRa.Game.Traits
class RenderUnitTurreted : RenderUnit class RenderUnitTurreted : RenderUnit
{ {
public Animation turretAnim; public Animation turretAnim;
public Animation muzzleFlash;
public float primaryRecoil = 0.0f, secondaryRecoil = 0.0f; public float primaryRecoil = 0.0f, secondaryRecoil = 0.0f;
public RenderUnitTurreted(Actor self) public RenderUnitTurreted(Actor self)
@@ -17,8 +18,17 @@ namespace OpenRa.Game.Traits
{ {
turretAnim = new Animation(self.unitInfo.Name); turretAnim = new Animation(self.unitInfo.Name);
if (self.traits.Contains<Turreted>()) if (self.traits.Contains<Turreted>())
{
if (self.unitInfo.MuzzleFlash)
{
muzzleFlash = new Animation(self.unitInfo.Name);
muzzleFlash.PlayFetchIndex("muzzle",
() => (Util.QuantizeFacing(self.traits.Get<Turreted>().turretFacing,8)) * 6 + (int)(primaryRecoil * 6));
}
turretAnim.PlayFetchIndex("turret", turretAnim.PlayFetchIndex("turret",
() => self.traits.Get<Turreted>().turretFacing / 8); () => self.traits.Get<Turreted>().turretFacing / 8);
}
else else
turretAnim.PlayRepeating("turret"); /* not really a turret; it's a spinner */ turretAnim.PlayRepeating("turret"); /* not really a turret; it's a spinner */
} }
@@ -33,6 +43,10 @@ namespace OpenRa.Game.Traits
if (self.unitInfo.SecondaryOffset != null) if (self.unitInfo.SecondaryOffset != null)
yield return Util.Centered(turretAnim.Image, self.CenterLocation yield return Util.Centered(turretAnim.Image, self.CenterLocation
+ Util.GetTurretPosition(self, self.unitInfo.SecondaryOffset, secondaryRecoil)); + Util.GetTurretPosition(self, self.unitInfo.SecondaryOffset, secondaryRecoil));
if (muzzleFlash != null && primaryRecoil > 0)
yield return Util.Centered(muzzleFlash.Image, self.CenterLocation
+ Util.GetTurretPosition(self, self.unitInfo.PrimaryOffset, primaryRecoil));
} }
public override void Tick(Actor self) public override void Tick(Actor self)
@@ -41,6 +55,8 @@ namespace OpenRa.Game.Traits
turretAnim.Tick(); turretAnim.Tick();
primaryRecoil = Math.Max(0f, primaryRecoil - .2f); primaryRecoil = Math.Max(0f, primaryRecoil - .2f);
secondaryRecoil = Math.Max(0f, secondaryRecoil - .2f); secondaryRecoil = Math.Max(0f, secondaryRecoil - .2f);
if (muzzleFlash != null)
muzzleFlash.Tick();
} }
} }
} }

View File

@@ -270,6 +270,7 @@
<unit name="jeep"> <unit name="jeep">
<sequence name="idle" start="0" length="32" /> <sequence name="idle" start="0" length="32" />
<sequence name="turret" start="32" length="32" /> <sequence name="turret" start="32" length="32" />
<sequence name="muzzle" start="0" length="48" src="minigun" />
</unit> </unit>
<!-- apc --> <!-- apc -->
<unit name="apc"> <unit name="apc">

View File

@@ -52,6 +52,7 @@ Traits=Mobile, McvDeploy, RenderUnit
Description=Ranger Description=Ranger
Traits=Mobile, Turreted, AttackTurreted, RenderUnitTurreted Traits=Mobile, Turreted, AttackTurreted, RenderUnitTurreted
PrimaryOffset=0,0,0,-2 PrimaryOffset=0,0,0,-2
MuzzleFlash=yes
[APC] [APC]
Description=Armored Personnel Carrier Description=Armored Personnel Carrier
Traits=Mobile, RenderUnit Traits=Mobile, RenderUnit
@@ -323,14 +324,14 @@ Produces=Infantry
RallyPoint=1,3 RallyPoint=1,3
[TENT] [TENT]
Description=Allied Barracks Description=Allied Barracks
Traits=Building, RenderBuilding Traits=Building, RenderBuilding, RallyPoint
Dimensions=2,2 Dimensions=2,2
Footprint=xx xx Footprint=xx xx
Produces=Infantry Produces=Infantry
RallyPoint=1,3 RallyPoint=1,3
[KENN] [KENN]
Description=Kennel Description=Kennel
Traits=Building, RenderBuilding Traits=Building, RenderBuilding, RallyPoint
Dimensions=1,1 Dimensions=1,1
Footprint=x Footprint=x
RallyPoint=1,2 RallyPoint=1,2