GetPrimaryWeapon() dies too.

This commit is contained in:
Chris Forbes
2010-07-31 18:26:57 +12:00
parent d202e27f79
commit 9a218f7b52
5 changed files with 7 additions and 18 deletions

View File

@@ -40,7 +40,7 @@ namespace OpenRA.Mods.RA.Activities
return this;
}
var range = self.GetPrimaryWeapon().Range - 1;
var range = self.traits.Get<AttackBase>().GetMaximumRange() - 1;
var dist = target.CenterLocation - self.CenterLocation;
var desiredFacing = Util.GetFacing(dist, unit.Facing);

View File

@@ -29,7 +29,7 @@ namespace OpenRA.Mods.RA
if (!target.IsValid) return;
if (self.GetCurrentActivity() is Leap) return;
var weapon = self.GetPrimaryWeapon();
var weapon = self.traits.Get<AttackBase>().Weapons[0].Info;
if (weapon.Range * Game.CellSize * weapon.Range * Game.CellSize
< (target.CenterLocation - self.CenterLocation).LengthSquared) return;

View File

@@ -126,6 +126,9 @@ namespace OpenRA.Mods.RA
facing = 0
};
if (args.weapon.Report != null)
Sound.Play(args.weapon.Report + ".aud", pos);
DoImpacts(args);
}
@@ -176,17 +179,6 @@ namespace OpenRA.Mods.RA
return true;
}
public static WeaponInfo GetPrimaryWeapon(this Actor self)
{
var info = self.Info.Traits.GetOrDefault<AttackBaseInfo>();
if (info == null) return null;
var weapon = info.PrimaryWeapon;
if (weapon == null) return null;
return Rules.Weapons[weapon.ToLowerInvariant()];
}
static float2 GetRecoil(Actor self, float recoil)
{
var abInfo = self.Info.Traits.GetOrDefault<AttackBaseInfo>();

View File

@@ -40,9 +40,6 @@ namespace OpenRA.Mods.RA
self.World.AddFrameEndTask( w =>
{
Combat.DoExplosion(self, info.PrimaryWeapon, self.CenterLocation, altitude);
var report = self.GetPrimaryWeapon().Report;
if (report != null)
Sound.Play(report + ".aud", self.CenterLocation);
// Remove from world
self.Kill(self);

View File

@@ -23,7 +23,7 @@ namespace OpenRA.Mods.RA
self.World.WorldRenderer.DrawRangeCircle(
Color.FromArgb(128, Color.Yellow),
self.CenterLocation, (int)self.GetPrimaryWeapon().Range);
self.CenterLocation, (int)self.traits.Get<AttackBase>().GetMaximumRange());
}
}
}