public override void Perform(MobUpdateContext context) { NavMesh navMesh = context.moveRequest.Room.runtime_nav_mesh; float max_range = 5.0f; // Compute max range from mob type uint[] navCells = navMesh.ComputeNavCellsInRadius(context.mob.Position, max_range, false); Random rng = context.mob.AIState.behavior_data.GetMobRandomNumberGenerator(); RNGUtilities.DeterministicKnuthShuffle(rng, navCells); Point3d targetPosition = new Point3d(context.mob.Position); // Pick the first random nav cell in range that we have line of sight to foreach (uint navCellIndex in navCells) { Point3d testTarget = navMesh.ComputeNavCellCenter(navCellIndex); bool canSee = navMesh.PointCanSeeOtherPoint(context.mob.Position, testTarget); if (canSee) { targetPosition = testTarget; break; } } // Compute the side effect of actually moving the mob on the update context context.MoveMob(targetPosition); context.MobPostDialog("Soo bored..."); }