private bool _FindCoverPointsInVolume(
     IHTNAgent npc,
     Vector3 position,
     List <CoverPoint> coverPoints,
     ref CoverPointVolume volume,
     ref float nextTime,
     float time,
     AiLocationManager location,
     float maxDistanceToCoverSqr)
 {
     if (Object.op_Equality((Object)SingletonComponent <AiManager> .Instance, (Object)null) || !((Behaviour)SingletonComponent <AiManager> .Instance).get_enabled() || !((AiManager)SingletonComponent <AiManager> .Instance).UseCover)
     {
         return(false);
     }
     if ((double)time > (double)nextTime)
     {
         nextTime = time + this.TickFrequency * AI.npc_cover_info_tick_rate_multiplier;
         if (Object.op_Equality((Object)volume, (Object)null) || !volume.Contains(position))
         {
             if (Object.op_Inequality((Object)npc.Body, (Object)null) && Object.op_Inequality((Object)npc.Body.GetParentEntity(), (Object)null) && Object.op_Inequality((Object)location.DynamicCoverPointVolume, (Object)null))
             {
                 volume = location.DynamicCoverPointVolume;
             }
             else if (Object.op_Inequality((Object)SingletonComponent <AiManager> .Instance, (Object)null) && ((Behaviour)SingletonComponent <AiManager> .Instance).get_enabled() && ((AiManager)SingletonComponent <AiManager> .Instance).UseCover)
             {
                 volume = ((AiManager)SingletonComponent <AiManager> .Instance).GetCoverVolumeContaining(position);
                 if (Object.op_Equality((Object)volume, (Object)null))
                 {
                     volume = AiManager.CreateNewCoverVolume(position, Object.op_Inequality((Object)location, (Object)null) ? location.CoverPointGroup : (Transform)null);
                 }
             }
         }
     }
     if (!Object.op_Inequality((Object)volume, (Object)null))
     {
         return(false);
     }
     if (coverPoints.Count > 0)
     {
         coverPoints.Clear();
     }
     foreach (CoverPoint coverPoint in volume.CoverPoints)
     {
         if (!coverPoint.IsReserved && !coverPoint.IsCompromised)
         {
             Vector3 position1 = coverPoint.Position;
             Vector3 vector3   = Vector3.op_Subtraction(position, position1);
             if ((double)((Vector3) ref vector3).get_sqrMagnitude() <= (double)maxDistanceToCoverSqr)
             {
                 coverPoints.Add(coverPoint);
             }
         }
     }
     if (coverPoints.Count > 1)
     {
         coverPoints.Sort((IComparer <CoverPoint>) this.coverPointComparer);
     }
     return(true);
 }
Exemplo n.º 2
0
        private bool _FindCoverPointsInVolume(Vector3 position, List <CoverPoint> coverPoints, ref CoverPointVolume volume, ref float nextTime, float time, AiLocationManager location, float maxDistanceToCoverSqr)
        {
            Transform coverPointGroup;

            if (SingletonComponent <AiManager> .Instance == null || !SingletonComponent <AiManager> .Instance.enabled || !SingletonComponent <AiManager> .Instance.UseCover)
            {
                return(false);
            }
            if (time > nextTime)
            {
                nextTime = time + this.TickFrequency * ConVar.AI.npc_cover_info_tick_rate_multiplier;
                if (location.DynamicCoverPointVolume != null)
                {
                    volume = location.DynamicCoverPointVolume;
                }
                else if ((volume == null || !volume.Contains(position)) && SingletonComponent <AiManager> .Instance != null && SingletonComponent <AiManager> .Instance.enabled && SingletonComponent <AiManager> .Instance.UseCover)
                {
                    volume = SingletonComponent <AiManager> .Instance.GetCoverVolumeContaining(position);

                    if (volume == null)
                    {
                        Vector3 vector3 = position;
                        if (location != null)
                        {
                            coverPointGroup = location.CoverPointGroup;
                        }
                        else
                        {
                            coverPointGroup = null;
                        }
                        volume = AiManager.CreateNewCoverVolume(vector3, coverPointGroup);
                    }
                }
            }
            if (volume == null)
            {
                return(false);
            }
            if (coverPoints.Count > 0)
            {
                coverPoints.Clear();
            }
            foreach (CoverPoint coverPoint in volume.CoverPoints)
            {
                if (coverPoint.IsReserved || coverPoint.IsCompromised || (position - coverPoint.Position).sqrMagnitude > maxDistanceToCoverSqr)
                {
                    continue;
                }
                coverPoints.Add(coverPoint);
            }
            if (coverPoints.Count > 1)
            {
                coverPoints.Sort(this.coverPointComparer);
            }
            return(true);
        }