Beispiel #1
0
        private static bool NavigateInDirOfBestSample(
            BaseContext c,
            NavPointSampler.SampleCount sampleCount,
            float radius,
            NavPointSampler.SampleFeatures features,
            float minRange,
            float maxRange)
        {
            List <NavPointSample> navPointSampleList1 = c.AIAgent.RequestNavPointSamplesInCircle(sampleCount, radius, features);

            if (navPointSampleList1 == null)
            {
                return(false);
            }
            foreach (NavPointSample navPointSample1 in navPointSampleList1)
            {
                Vector3        vector3         = Vector3.op_Subtraction(navPointSample1.Position, c.Position);
                Vector3        normalized      = ((Vector3) ref vector3).get_normalized();
                NavPointSample navPointSample2 = NavPointSampler.SamplePoint(Vector3.op_Addition(c.Position, Vector3.op_Addition(Vector3.op_Multiply(normalized, minRange), Vector3.op_Multiply(normalized, (maxRange - minRange) * Random.get_value()))), new NavPointSampler.SampleScoreParams()
                {
                    WaterMaxDepth = c.AIAgent.GetStats.MaxWaterDepth,
                    Agent         = c.AIAgent,
                    Features      = features
                });
                if (!Mathf.Approximately(navPointSample2.Score, 0.0f))
                {
                    NavigateToOperator.MakeUnstuck(c);
                    Vector3 position = navPointSample2.Position;
                    c.AIAgent.Destination = position;
                    c.AIAgent.SetTargetPathStatus(0.05f);
                    return(true);
                }
            }
            float num = 2f;
            List <NavPointSample> navPointSampleList2 = c.AIAgent.RequestNavPointSamplesInCircleWaterDepthOnly(sampleCount, radius, num);

            if (navPointSampleList2 == null)
            {
                return(false);
            }
            foreach (NavPointSample navPointSample1 in navPointSampleList2)
            {
                Vector3        vector3         = Vector3.op_Subtraction(navPointSample1.Position, c.Position);
                Vector3        normalized      = ((Vector3) ref vector3).get_normalized();
                NavPointSample navPointSample2 = NavPointSampler.SamplePointWaterDepthOnly(Vector3.op_Addition(c.Position, Vector3.op_Addition(Vector3.op_Multiply(normalized, minRange), Vector3.op_Multiply(normalized, (maxRange - minRange) * Random.get_value()))), num);
                if (!Mathf.Approximately(navPointSample2.Score, 0.0f))
                {
                    NavigateToOperator.MakeUnstuck(c);
                    Vector3 position = navPointSample2.Position;
                    c.AIAgent.Destination = position;
                    c.AIAgent.SetTargetPathStatus(0.05f);
                    return(true);
                }
            }
            return(false);
        }
        private static bool NavigateInDirOfBestSample(NPCHumanContext c, NavPointSampler.SampleCount sampleCount, float radius, NavPointSampler.SampleFeatures features, float minRange, float maxRange)
        {
            bool flag;
            List <NavPointSample> navPointSamples = c.AIAgent.RequestNavPointSamplesInCircle(sampleCount, radius, features);

            if (navPointSamples == null)
            {
                return(false);
            }
            List <NavPointSample> .Enumerator enumerator = navPointSamples.GetEnumerator();
            try
            {
                while (enumerator.MoveNext())
                {
                    Vector3 position = (enumerator.Current.Position - c.Position).normalized;
                    Vector3 vector3  = c.Position + (position * minRange) + (position * ((maxRange - minRange) * UnityEngine.Random.@value));
                    if (c.AIAgent.AttackTarget != null && !NavPointSampler.IsValidPointDirectness(vector3, c.Position, c.EnemyPosition))
                    {
                        continue;
                    }
                    NavPointSampler.SampleScoreParams sampleScoreParam = new NavPointSampler.SampleScoreParams()
                    {
                        WaterMaxDepth = c.AIAgent.GetStats.MaxWaterDepth,
                        Agent         = c.AIAgent,
                        Features      = features
                    };
                    NavPointSample navPointSample = NavPointSampler.SamplePoint(vector3, sampleScoreParam);
                    if (Mathf.Approximately(navPointSample.Score, 0f) || Mathf.Approximately(navPointSample.Position.sqrMagnitude, 0f))
                    {
                        continue;
                    }
                    HumanNavigateToOperator.MakeUnstuck(c);
                    vector3 = navPointSample.Position;
                    c.AIAgent.GetNavAgent.destination = vector3;
                    c.Human.SetTargetPathStatus(0.05f);
                    c.AIAgent.SetFact(NPCPlayerApex.Facts.IsMoving, 1, true, false);
                    flag = true;
                    return(flag);
                }
                return(false);
            }
            finally
            {
                ((IDisposable)enumerator).Dispose();
            }
            return(flag);
        }
        private static bool NavigateInDirOfBestSample(BaseContext c, NavPointSampler.SampleCount sampleCount, float radius, NavPointSampler.SampleFeatures features, float minRange, float maxRange)
        {
            Vector3 position;
            bool    flag;
            List <NavPointSample> navPointSamples = c.AIAgent.RequestNavPointSamplesInCircle(sampleCount, radius, features);

            if (navPointSamples == null)
            {
                return(false);
            }
            foreach (NavPointSample navPointSample in navPointSamples)
            {
                position = navPointSample.Position - c.Position;
                Vector3 vector3   = position.normalized;
                Vector3 position1 = c.Position + (vector3 * minRange) + (vector3 * ((maxRange - minRange) * UnityEngine.Random.@value));
                NavPointSampler.SampleScoreParams sampleScoreParam = new NavPointSampler.SampleScoreParams()
                {
                    WaterMaxDepth = c.AIAgent.GetStats.MaxWaterDepth,
                    Agent         = c.AIAgent,
                    Features      = features
                };
                NavPointSample navPointSample1 = NavPointSampler.SamplePoint(position1, sampleScoreParam);
                if (Mathf.Approximately(navPointSample1.Score, 0f))
                {
                    continue;
                }
                NavigateToOperator.MakeUnstuck(c);
                position1             = navPointSample1.Position;
                c.AIAgent.Destination = position1;
                c.AIAgent.SetTargetPathStatus(0.05f);
                flag = true;
                return(flag);
            }
            float single = 2f;

            navPointSamples = c.AIAgent.RequestNavPointSamplesInCircleWaterDepthOnly(sampleCount, radius, single);
            if (navPointSamples == null)
            {
                return(false);
            }
            List <NavPointSample> .Enumerator enumerator = navPointSamples.GetEnumerator();
            try
            {
                while (enumerator.MoveNext())
                {
                    position = enumerator.Current.Position - c.Position;
                    Vector3        vector31        = position.normalized;
                    Vector3        position2       = c.Position + (vector31 * minRange) + (vector31 * ((maxRange - minRange) * UnityEngine.Random.@value));
                    NavPointSample navPointSample2 = NavPointSampler.SamplePointWaterDepthOnly(position2, single);
                    if (Mathf.Approximately(navPointSample2.Score, 0f))
                    {
                        continue;
                    }
                    NavigateToOperator.MakeUnstuck(c);
                    position2             = navPointSample2.Position;
                    c.AIAgent.Destination = position2;
                    c.AIAgent.SetTargetPathStatus(0.05f);
                    flag = true;
                    return(flag);
                }
                return(false);
            }
            finally
            {
                ((IDisposable)enumerator).Dispose();
            }
            return(flag);
        }