private Threat CreateThreat(RocketComponent rocket)
 {
     return(new Threat
     {
         GameObject = rocket.gameObject,
         Distance = Vector3.Distance(rocket.transform.position, transform.position)
     });
 }
        /// <summary>
        /// Tests if the given rocket is flying towards us.
        /// </summary>
        /// <param name="rocket"></param>
        /// <returns></returns>
        private bool FliesTowardsUs(RocketComponent rocket)
        {
            var body = rocket.GetComponent <Rigidbody>();
            var velocityDirection = body.velocity.normalized;
            var delta             = (transform.position - rocket.transform.position).normalized;
            var angle             = Vector3.Angle(velocityDirection, delta);

            if (angle >= 90)
            {
                return(false);
            }

            return(true);
        }
        private bool TargetsUs(RocketComponent rocket)
        {
            if (!rocket.IsActivated)
            {
                return(false);
            }

            if (rocket.target != gameObject)
            {
                return(false);
            }

            if (!FliesTowardsUs(rocket))
            {
                return(false);
            }

            return(true);
        }