changes to skeleton ai, theoretical performance increase with huge amount of mobs and players

This commit is contained in:
GameHerobrine 2024-04-12 06:06:59 +03:00
parent c9da91378d
commit da28b3b0ff
9 changed files with 89 additions and 96 deletions

View file

@ -553,6 +553,18 @@ class Level{
unset($this->entityListPositioned[$index][$e->eid]);
$this->entityListPositioned[$newIndex][$e->eid] = $e->eid; //set to e->eid to avoid possible memory leaks
}
if($e->searchForClosestPlayers){
$e->handlePrePlayerSearcher();
foreach($this->players as $player){
$dist = ($e->x - $player->entity->x)*($e->x - $player->entity->x) + ($e->y - $player->entity->y) + ($e->z - $player->entity->z);
$e->handlePlayerSearcher($player, $dist);
}
}
}elseif(isset($this->entityListPositioned["$curChunkX $curChunkZ"])){
unset($this->entityListPositioned["$curChunkX $curChunkZ"][$k]);
}