some accessors

This commit is contained in:
Chris Forbes
2010-01-11 21:59:32 +13:00
parent e7a99541e5
commit 10a5b40e16
5 changed files with 34 additions and 15 deletions

View File

@@ -2,6 +2,8 @@
using System.Windows.Forms;
using System.Collections.Generic;
using System.Linq;
using OpenRa.Game.GameRules;
using OpenRa.Game.Traits;
namespace OpenRa.Game
{
@@ -27,5 +29,27 @@ namespace OpenRa.Game
{
return xs.Aggregate(1f, (a, x) => a * x);
}
public static WeaponInfo GetPrimaryWeapon(this Actor self)
{
var info = self.Info.Traits.WithInterface<AttackBaseInfo>().FirstOrDefault();
if (info == null) return null;
var weapon = info.PrimaryWeapon;
if (weapon == null) return null;
return Rules.WeaponInfo[weapon];
}
public static WeaponInfo GetSecondaryWeapon(this Actor self)
{
var info = self.Info.Traits.WithInterface<AttackBaseInfo>().FirstOrDefault();
if (info == null) return null;
var weapon = info.SecondaryWeapon;
if (weapon == null) return null;
return Rules.WeaponInfo[weapon];
}
}
}