private bool CanShootTarget(AIController controller) { // otherwise, check that there are no other mechs in the way Vector3 fireOrigin = GetWeaponOrigin(controller); // Some enemies do not shoot when they are not visible on screen if(controller.doesntShootOffScreen && !WorldManager.instance.ObjectOnScreen(controller.gameObject)) { return false; } Vector3 toTarget = controller.target.transform.position - fireOrigin; float arcToTarget = Vector3.Dot(controller.headTransform.up, toTarget.normalized); // constrain the shooting to within an arc if(arcToTarget < maxFireArc || toTarget.magnitude > controller.GetAttackRange()) { return false; } if(!controller.CheckLOSFrom(fireOrigin, controller.target.transform.position, 100.0f)) { controller.OnLostSightOfTarget(); return false; } else if(!controller.isTrackingTarget) { controller.OnAquireTarget(); } // allow the weapon to decide if it can shoot yet, or if it is doing something if(controller.MechComponent != null && controller.MechComponent.leftWeapon != null && !controller.MechComponent.leftWeapon.AI_AllowFire(controller)) { return false; } return true; }