This is not going to help. 60 times a second you are getting all the nodes in the tree just to get the first one (which I presume is the player). Just assign it to a reference something like:
var player
func _ready():
player = get_tree().get_nodes_in_group("world")[0]
I say something like this because I don’t know if all your nodes will be ready by the time this _ready function is called, you might need to assign the reference Player later or inject it from your root node when everything else is ready, or call an initialisation function from your root etc.
What is the point of this code? It looks like collision avoidance code, but you’re using a NavigationAgent2D. You should be pairing that with a NavigationRegion2D which should already be doing this work.
This code is triggering 60 times a second and testing everything the raycast is hitting. If you were to profile your code, this is most likely the problem. Along with what @pauldrewett pointed out.
And also, your move() function calls an enemy.play() function that isn’t listed, but if I had to bet, probably shouldn’t be getting called every frame either.