void WeaponTryFire(bool alternative)
{
if (activeWeapon == null)
{
return;
}
//set real weapon fire direction
{
Vec3 seeDir = (TurnToPosition - Position).GetNormalize();
Vec3 lookTo = TurnToPosition;
for (int iter = 0; iter < 100; iter++)
{
activeWeapon.SetForceFireRotationLookTo(lookTo);
Vec3 fireDir = activeWeapon.GetFireRotation(alternative).GetForward();
Degree angle = MathUtils.GetVectorsAngle(seeDir, fireDir);
if (angle < 80)
{
break;
}
const float step = .3f;
lookTo += seeDir * step;
}
activeWeapon.SetForceFireRotationLookTo(lookTo);
}
bool fired = activeWeapon.TryFire(alternative);
Gun activeGun = activeWeapon as Gun;
if (activeGun != null)
{
if (fired)
{
int index = GetWeaponIndex(activeWeapon.Type);
weapons[index].normalBulletCount = activeGun.NormalMode.BulletCount;
weapons[index].normalMagazineCount = activeGun.NormalMode.BulletMagazineCount;
weapons[index].alternativeBulletCount = activeGun.AlternativeMode.BulletCount;
weapons[index].alternativeMagazineCount =
activeGun.AlternativeMode.BulletMagazineCount;
}
}
}