public static void NavigateToTopologyPreference(BaseContext c) { if (IsRoamReady.Evaluate(c) && c.AIAgent.IsNavRunning()) { if (NavigateToOperator.NavigateInDirOfBestSample(c, NavPointSampler.SampleCount.Eight, 4f, NavPointSampler.SampleFeatures.DiscourageSharpTurns | NavPointSampler.SampleFeatures.TopologyPreference | NavPointSampler.SampleFeatures.RangeFromSpawn, c.AIAgent.GetStats.MinRoamRange, c.AIAgent.GetStats.MaxRoamRange)) { float maxRoamDelay = c.AIAgent.GetStats.MaxRoamDelay - c.AIAgent.GetStats.MinRoamDelay; float single = UnityEngine.Random.@value * maxRoamDelay / maxRoamDelay; float single1 = c.AIAgent.GetStats.RoamDelayDistribution.Evaluate(single) * maxRoamDelay; c.NextRoamTime = Time.realtimeSinceStartup + c.AIAgent.GetStats.MinRoamDelay + single1; return; } NavigateToOperator.NavigateToRandomLoc(c); } }
public override void DoExecute(BaseContext c) { if (c.GetFact(BaseNpc.Facts.CanNotMove) == (byte)1) { c.AIAgent.StopMoving(); c.SetFact(BaseNpc.Facts.PathToTargetStatus, (byte)2); } else { if (!c.AIAgent.IsNavRunning() || c.AIAgent.GetNavAgent.get_pathPending()) { return; } switch (this.Operator) { case NavigateToOperator.OperatorType.EnemyLoc: NavigateToOperator.NavigateToEnemy(c); break; case NavigateToOperator.OperatorType.RandomLoc: NavigateToOperator.NavigateToRandomLoc(c); break; case NavigateToOperator.OperatorType.Spawn: NavigateToOperator.NavigateToSpawn(c); break; case NavigateToOperator.OperatorType.FoodLoc: NavigateToOperator.NavigateToFood(c); break; case NavigateToOperator.OperatorType.FleeEnemy: NavigateToOperator.FleeEnemy(c); break; case NavigateToOperator.OperatorType.FleeHurtDir: NavigateToOperator.FleeHurtDir(c); break; case NavigateToOperator.OperatorType.TopologyPreference: NavigateToOperator.NavigateToTopologyPreference(c); break; } } }
public static void NavigateToTopologyPreference(BaseContext c) { if (!IsRoamReady.Evaluate(c) || !c.AIAgent.IsNavRunning()) { return; } if (NavigateToOperator.NavigateInDirOfBestSample(c, NavPointSampler.SampleCount.Eight, 4f, NavPointSampler.SampleFeatures.DiscourageSharpTurns | NavPointSampler.SampleFeatures.TopologyPreference | NavPointSampler.SampleFeatures.RangeFromSpawn, c.AIAgent.GetStats.MinRoamRange, c.AIAgent.GetStats.MaxRoamRange)) { float num1 = c.AIAgent.GetStats.MaxRoamDelay - c.AIAgent.GetStats.MinRoamDelay; float num2 = Random.get_value() * num1 / num1; float num3 = c.AIAgent.GetStats.RoamDelayDistribution.Evaluate(num2) * num1; c.NextRoamTime = Time.get_realtimeSinceStartup() + c.AIAgent.GetStats.MinRoamDelay + num3; } else { NavigateToOperator.NavigateToRandomLoc(c); } }