attack if in range of any cell of a building

This commit is contained in:
Bob
2010-11-03 21:06:55 +13:00
committed by Chris Forbes
parent c3fc7b98f3
commit 50b1ba3acc
8 changed files with 56 additions and 7 deletions

View File

@@ -219,5 +219,20 @@ namespace OpenRA.Mods.RA
return Util.RotateVectorByFacing(barrel.Position, turretFacing, .7f);
}
public static bool IsInRange( float2 attackOrigin, float range, Actor target )
{
var rsq = range * range * Game.CellSize * Game.CellSize;
foreach( var cell in target.Trait<Targetable>().TargetableSquares( target ) )
if( ( attackOrigin - cell * Game.CellSize ).LengthSquared < rsq )
return true;
return false;
}
public static bool IsInRange( float2 attackOrigin, float range, float2 targetLocation )
{
var rsq = range * range * Game.CellSize * Game.CellSize;
return ( attackOrigin - targetLocation ).LengthSquared < rsq;
}
}
}