ai changes

This commit is contained in:
GameHerobrine 2022-12-26 08:15:13 +03:00
parent 11b1a09599
commit 0f72601891
9 changed files with 52 additions and 29 deletions

View file

@ -6,13 +6,10 @@ move methods
abstract class Creature extends Living{
const CLASS_TYPE = ENTITY_MOB;
public $pathFinder, $path = null, $currentIndex = 0, $currentNode;
public $inPanic;
public function __construct(Level $level, $eid, $class, $type = 0, $data = []){
$this->inPanic = false; //force for now
$this->pathFinder = new TileNavigator(new MCBlockedProvider(), new MCDiagonalProvider(), new Pythagoras3D(), new ManhattanHeuristic3D());
parent::__construct($level, $eid, $class, $type, $data);
$this->setHealth(isset($this->data["Health"]) ? $this->data["Health"] : 1, "generic");
//$this->setName((isset($mobs[$this->type]) ? $mobs[$this->type]:$this->type));
@ -24,23 +21,6 @@ abstract class Creature extends Living{
}
public function update(){
if($this->onGround){
/*if($this->path === null && $this->pathFinder instanceof ITileNavigator){ // mt_rand(0, 120) === 0){
$this->path = $this->pathFinder->navigate(new PathTileXYZ($this->x, $this->y, $this->z, $this->level), new PathTileXYZ($this->x + mt_rand(-10, 10), $this->y, $this->z + mt_rand(-10, 10), $this->level));
}
if($this->path != null && (is_array($this->path) && count($this->path) <= 0 || $this->currentIndex >= count($this->path))){
$this->path = null;
$this->currentIndex = 0;
$this->currentNode = false;
}elseif($this->path != null && ($this->currentNode == false || $this->ai->mobController->moveTo($this->currentNode->x, $this->currentNode->y, $this->currentNode->z) === false)){
$this->currentNode = $this->path[$this->currentIndex++];
}*/
}
parent::update();
}
public function createSaveData(){
$data = parent::createSaveData();
$data["State"] = @$this->getState();