public static bool SampleCircleWaterDepthOnly(NavPointSampler.SampleCount sampleCount, Vector3 center, float radius, NavPointSampler.SampleScoreParams scoreParams, ref List <NavPointSample> samples) { if (scoreParams.Agent == null || scoreParams.Agent.GetNavAgent == null) { return(false); } float single = 90f; if (sampleCount == NavPointSampler.SampleCount.Eight) { single = 45f; } else if (sampleCount == NavPointSampler.SampleCount.Sixteen) { single = 22.5f; } for (float i = 0f; i < 360f; i += single) { NavPointSample navPointSample = NavPointSampler.SamplePointWaterDepthOnly(NavPointSampler.GetPointOnCircle(center, radius, i), 2f); if (navPointSample.Score > 0f) { samples.Add(navPointSample); } } if (samples.Count > 0) { samples.Sort(NavPointSampler.NavPointSampleComparer); } return(samples.Count > 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); }
public static bool SampleCircle( NavPointSampler.SampleCount sampleCount, Vector3 center, float radius, NavPointSampler.SampleScoreParams scoreParams, ref List <NavPointSample> samples) { if (scoreParams.Agent == null || Object.op_Equality((Object)scoreParams.Agent.GetNavAgent, (Object)null)) { return(false); } float num1 = 90f; switch (sampleCount) { case NavPointSampler.SampleCount.Eight: num1 = 45f; break; case NavPointSampler.SampleCount.Sixteen: num1 = 22.5f; break; } float num2 = 2f + (float)NavPointSampler.GetFeatureCount((int)scoreParams.Features); for (float degrees = 0.0f; (double)degrees < 360.0; degrees += num1) { NavPointSample navPointSample = NavPointSampler.SamplePoint(NavPointSampler.GetPointOnCircle(center, radius, degrees), scoreParams); if ((double)navPointSample.Score > 0.0) { samples.Add(navPointSample); if ((double)navPointSample.Score >= (double)num2) { break; } } } if (samples.Count == 0) { for (float degrees = 0.0f; (double)degrees < 360.0; degrees += num1) { NavPointSample navPointSample = NavPointSampler.SamplePointWaterDepthOnly(NavPointSampler.GetPointOnCircle(center, radius, degrees), 2f); if ((double)navPointSample.Score > 0.0) { samples.Add(navPointSample); } } } if (samples.Count > 0) { samples.Sort((IComparer <NavPointSample>)NavPointSampler.NavPointSampleComparer); } return(samples.Count > 0); }
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); }