mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-21 12:09:43 +00:00
changes to skeleton ai, theoretical performance increase with huge amount of mobs and players
This commit is contained in:
parent
c9da91378d
commit
da28b3b0ff
9 changed files with 89 additions and 96 deletions
|
|
@ -4,17 +4,32 @@ abstract class Creature extends Living{
|
|||
const CLASS_TYPE = ENTITY_MOB;
|
||||
|
||||
public $inPanic;
|
||||
public $closestPlayerEID = false;
|
||||
public $closestPlayerDist = INF;
|
||||
|
||||
|
||||
public function __construct(Level $level, $eid, $class, $type = 0, $data = []){
|
||||
$this->inPanic = false; //force for now
|
||||
parent::__construct($level, $eid, $class, $type, $data);
|
||||
$this->setHealth(isset($this->data["Health"]) ? $this->data["Health"] : 1, "generic");
|
||||
$this->enableAutojump = true;
|
||||
//$this->setName((isset($mobs[$this->type]) ? $mobs[$this->type]:$this->type));
|
||||
//$this->ai->addTask(new TaskLookAround());
|
||||
//$this->ai->addTask(new TaskRandomWalk());
|
||||
//$this->ai->addTask(new TaskLookAtPlayer());
|
||||
//$this->ai->addTask(new TaskSwimming());
|
||||
$this->searchForClosestPlayers = true;
|
||||
}
|
||||
|
||||
public function handlePrePlayerSearcher(){
|
||||
parent::handlePrePlayerSearcher();
|
||||
if($this->closestPlayerEID !== false && !isset($this->level->entityList[$this->closestPlayerEID])){
|
||||
$this->closestPlayerEID = false;
|
||||
$this->closestPlayerDist = INF;
|
||||
}
|
||||
}
|
||||
|
||||
public function handlePlayerSearcher(Player $player, $dist){
|
||||
parent::handlePlayerSearcher($player, $dist);
|
||||
if($this->closestPlayerDist >= $dist){
|
||||
$this->closestPlayerEID = $player->entity->eid;
|
||||
$this->closestPlayerDist = $dist;
|
||||
}
|
||||
}
|
||||
|
||||
public function createSaveData(){
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue