Split Barrel can-fire checks to separate CanFire method
This commit is contained in:
@@ -204,26 +204,34 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
a();
|
a();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected virtual bool CanFire(Actor self, Target target)
|
||||||
|
{
|
||||||
|
if (IsReloading)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (ammoPool != null && !ammoPool.HasAmmo())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (turret != null && !turret.HasAchievedDesiredFacing)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!target.IsInRange(self.CenterPosition, MaxRange()))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (Weapon.MinRange != WDist.Zero && target.IsInRange(self.CenterPosition, Weapon.MinRange))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!Weapon.IsValidAgainst(target, self.World, self))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// Note: facing is only used by the legacy positioning code
|
// Note: facing is only used by the legacy positioning code
|
||||||
// The world coordinate model uses Actor.Orientation
|
// The world coordinate model uses Actor.Orientation
|
||||||
public virtual Barrel CheckFire(Actor self, IFacing facing, Target target)
|
public virtual Barrel CheckFire(Actor self, IFacing facing, Target target)
|
||||||
{
|
{
|
||||||
if (IsReloading)
|
if (!CanFire(self, target))
|
||||||
return null;
|
|
||||||
|
|
||||||
if (ammoPool != null && !ammoPool.HasAmmo())
|
|
||||||
return null;
|
|
||||||
|
|
||||||
if (turret != null && !turret.HasAchievedDesiredFacing)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
if (!target.IsInRange(self.CenterPosition, MaxRange()))
|
|
||||||
return null;
|
|
||||||
|
|
||||||
if (Weapon.MinRange != WDist.Zero && target.IsInRange(self.CenterPosition, Weapon.MinRange))
|
|
||||||
return null;
|
|
||||||
|
|
||||||
if (!Weapon.IsValidAgainst(target, self.World, self))
|
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
if (ticksSinceLastShot >= Weapon.ReloadDelay)
|
if (ticksSinceLastShot >= Weapon.ReloadDelay)
|
||||||
|
|||||||
Reference in New Issue
Block a user