Ejemplo n.º 1
0
        /*-------------------------------------------------------------------------------------------------------------------------
         * Called per Ai physics tick.
         *
         * holdTimer is the time that the AI has been holding the weapon, including timer modifications from gamemodes.
         * unscaledHoldTimer is the time that the AI has been holding the weapon, not including their modifications from gamemodes.
         * --------------------------------------------------------------------------------------------------------------------------*/
        public override void AiUpdate(float holdTimer, float unscaledHoldTimer)
        {
            // if the total hold time is over the usage time then drop the pickup
            if (unscaledHoldTimer > AiUsageDelay)
            {
                OnDrop();
            }

            // check if there a ship in front of the ai
            bool canSeeShip = Physics.Raycast(R.RBody.position, R.Forward, out RaycastHit hit, 15.0f, Layers.ShipToShip); // cast against the ship to ship layer, which are the bounding box colliders of each ship

            if (!canSeeShip)
            {
                return;
            }

            // figure out which ship is at the hit point. If the AI is passive towards the ship, do nothing
            ShipRefs targetShip = Ships.GetClosestShipToPoint(hit.point);

            if (R.IsPassiveTowards(targetShip))
            {
                canSeeShip = false;
            }

            if (canSeeShip)
            {
                OnUse();
            }
        }