add Target overload for IsInRange
This commit is contained in:
@@ -45,7 +45,7 @@ namespace OpenRA.Mods.RA.Activities
|
||||
var mobile = self.Trait<Mobile>();
|
||||
var targetCell = Util.CellContaining(Target.CenterLocation);
|
||||
|
||||
if (!Combat.IsInRange( self.CenterLocation, Range, Util.CenterOfCell(targetCell)))
|
||||
if (!Combat.IsInRange( self.CenterLocation, Range, Target))
|
||||
return Util.SequenceActivities( mobile.MoveTo( Target, Range ), this );
|
||||
|
||||
var desiredFacing = Util.GetFacing((targetCell - self.Location).ToFloat2(), 0);
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace OpenRA.Mods.RA
|
||||
if (IsLeaping) return;
|
||||
|
||||
var weapon = self.Trait<AttackBase>().Weapons[0].Info;
|
||||
if( !Combat.IsInRange( self.CenterLocation, weapon.Range, target.Actor ) ) return;
|
||||
if( !Combat.IsInRange( self.CenterLocation, weapon.Range, target ) ) return;
|
||||
|
||||
self.CancelActivity();
|
||||
self.QueueActivity(new Leap(self, target));
|
||||
|
||||
@@ -234,5 +234,14 @@ namespace OpenRA.Mods.RA
|
||||
var rsq = range * range * Game.CellSize * Game.CellSize;
|
||||
return ( attackOrigin - targetLocation ).LengthSquared < rsq;
|
||||
}
|
||||
|
||||
public static bool IsInRange( float2 attackOrigin, float range, Target target )
|
||||
{
|
||||
if( !target.IsValid ) return false;
|
||||
if( target.IsActor )
|
||||
return IsInRange( attackOrigin, range, target.Actor );
|
||||
else
|
||||
return IsInRange( attackOrigin, range, target.CenterLocation );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,13 +102,10 @@ namespace OpenRA.Mods.RA
|
||||
if (limitedAmmo != null && !limitedAmmo.HasAmmo())
|
||||
return;
|
||||
|
||||
if( target.IsActor && !Combat.IsInRange( self.CenterLocation, Info.Range, target.Actor ) )
|
||||
if( !Combat.IsInRange( self.CenterLocation, Info.Range, target ) )
|
||||
return;
|
||||
else if( !target.IsActor && !Combat.IsInRange( self.CenterLocation, Info.Range, target.CenterLocation ) )
|
||||
if( Combat.IsInRange( self.CenterLocation, Info.MinRange, target ) )
|
||||
return;
|
||||
|
||||
if (Info.MinRange * Info.MinRange * Game.CellSize * Game.CellSize >
|
||||
(target.CenterLocation - self.CenterLocation).LengthSquared) return;
|
||||
|
||||
if (!IsValidAgainst(self.World, target)) return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user