Use Target range checks in CarpetBomb.
This commit is contained in:
@@ -14,25 +14,37 @@ using OpenRA.Traits;
|
|||||||
|
|
||||||
namespace OpenRA.Mods.RA
|
namespace OpenRA.Mods.RA
|
||||||
{
|
{
|
||||||
class CarpetBombInfo : TraitInfo<CarpetBomb>
|
class CarpetBombInfo : ITraitInfo
|
||||||
{
|
{
|
||||||
[WeaponReference]
|
[WeaponReference]
|
||||||
public readonly string Weapon = null;
|
public readonly string Weapon = null;
|
||||||
public readonly int Range = 3;
|
public readonly int Range = 3;
|
||||||
|
|
||||||
|
public object Create(ActorInitializer init) { return new CarpetBomb(this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
class CarpetBomb : ITick, ISync // TODO: maybe integrate this better with the normal weapons system?
|
// TODO: maybe integrate this better with the normal weapons system?
|
||||||
|
class CarpetBomb : ITick, ISync
|
||||||
{
|
{
|
||||||
[Sync] CPos Target;
|
CarpetBombInfo info;
|
||||||
[Sync] int dropDelay;
|
Target target;
|
||||||
|
|
||||||
public void SetTarget(CPos targetCell) { Target = targetCell; }
|
[Sync] int dropDelay;
|
||||||
|
[Sync] WRange range;
|
||||||
|
|
||||||
|
public CarpetBomb(CarpetBombInfo info)
|
||||||
|
{
|
||||||
|
this.info = info;
|
||||||
|
|
||||||
|
// TODO: Push this conversion into the yaml
|
||||||
|
range = WRange.FromCells(info.Range);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetTarget(CPos targetCell) { target = Target.FromCell(targetCell); }
|
||||||
|
|
||||||
public void Tick(Actor self)
|
public void Tick(Actor self)
|
||||||
{
|
{
|
||||||
var info = self.Info.Traits.Get<CarpetBombInfo>();
|
if (!target.IsInRange(self.CenterPosition, range))
|
||||||
|
|
||||||
if( !Combat.IsInRange( self.CenterLocation, info.Range, Target.ToPPos() ) )
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var limitedAmmo = self.TraitOrDefault<LimitedAmmo>();
|
var limitedAmmo = self.TraitOrDefault<LimitedAmmo>();
|
||||||
|
|||||||
Reference in New Issue
Block a user