Move weapon/turret definitions out of AttackBase.

Weapons are now defined with the Armament trait
and turret parameters live in Turreted.
This has the side effect of allowing any number
and distribution of weapons and turrets.
This commit is contained in:
Paul Chote
2013-03-14 03:55:34 +13:00
parent aa6f12f0a1
commit 0167bbfbaa
81 changed files with 4023 additions and 820 deletions

View File

@@ -8,10 +8,12 @@
*/
#endregion
using System;
using System.Collections.Generic;
using System.Linq;
using OpenRA.Graphics;
using OpenRA.Traits;
using System;
using OpenRA.Mods.RA;
namespace OpenRA.Mods.RA.Render
{
@@ -27,25 +29,25 @@ namespace OpenRA.Mods.RA.Render
public WithMuzzleFlash(Actor self)
{
var attack = self.Trait<AttackBase>();
var render = self.Trait<RenderSimple>();
var facing = self.TraitOrDefault<IFacing>();
var turreted = self.TraitOrDefault<Turreted>();
var getFacing = turreted != null ? () => turreted.turretFacing :
facing != null ? (Func<int>)(() => facing.Facing) : () => 0;
foreach (var w in attack.Weapons)
foreach( var b in w.Barrels )
var arms = self.TraitsImplementing<Armament>();
foreach (var a in arms)
foreach(var b in a.Barrels)
{
var barrel = b;
var turret = w.Turret;
var turreted = self.TraitsImplementing<Turreted>()
.FirstOrDefault(t => t.info.Turret == a.Info.Turret);
var getFacing = turreted != null ? () => turreted.turretFacing :
facing != null ? (Func<int>)(() => facing.Facing) : () => 0;
var muzzleFlash = new Animation(render.GetImage(self), getFacing);
muzzleFlash.Play("muzzle");
muzzleFlashes.Add("muzzle{0}".F(muzzleFlashes.Count), new AnimationWithOffset(
muzzleFlash,
() => Combat.GetBarrelPosition(self, facing, turret, barrel).ToFloat2(),
() => a.MuzzlePxPosition(self, facing, barrel).ToFloat2(),
() => !isShowing));
}
}