project uses tabs instead of spaces(as in CONTRIBUTING.md)

This commit is contained in:
GameHerobrine 2022-12-26 07:01:28 +03:00
parent f00318b6ed
commit 62571f26cd
115 changed files with 2291 additions and 2364 deletions

View file

@ -2,74 +2,74 @@
class EntityAI
{
/**
* @var MobController
*/
public $mobController;
/**
* @var Living
*/
public $entity;
/**
* @var TaskBase[]
*/
protected $tasks;
public $lastTask;
public $counter = 0;
public function __construct($entity){
$this->entity = $entity;
$this->tasks = [];
$this->mobController = new MobController($entity);
}
/**
* Add a task for entity
* @param TaskBase $task
*/
public function addTask(TaskBase $task){
console("[DEBUG] Adding new task...",true, true, 2);
$this->tasks[$task->__toString()] = $task;
}
/**
*
* @param mixed $id classname
* @return TaskBase | false
*/
public function getTask($id){
return isset($this->tasks[$id]) ? $this->tasks[$id] : false;
}
public function isStarted($id){
$task = @$this->getTask($id);
return $task instanceof TaskBase && $task->isStarted;
}
/**
* @var MobController
*/
public $mobController;
/**
* @var Living
*/
public $entity;
/**
* @var TaskBase[]
*/
protected $tasks;
public $lastTask;
public $counter = 0;
public function __construct($entity){
$this->entity = $entity;
$this->tasks = [];
$this->mobController = new MobController($entity);
}
/**
* Add a task for entity
* @param TaskBase $task
*/
public function addTask(TaskBase $task){
console("[DEBUG] Adding new task...",true, true, 2);
$this->tasks[$task->__toString()] = $task;
}
/**
*
* @param mixed $id classname
* @return TaskBase | false
*/
public function getTask($id){
return isset($this->tasks[$id]) ? $this->tasks[$id] : false;
}
public function isStarted($id){
$task = @$this->getTask($id);
return $task instanceof TaskBase && $task->isStarted;
}
public function updateTasks(){
if($this->counter % 3 != 0){
return;
}
foreach($this->tasks as $t){
if(!$t->isStarted && $t->canBeExecuted($this)){
$t->isStarted = true;
$t->onStart($this);
}
if($t->isStarted){
$t->onUpdate($this);
if($t->selfCounter <= 0){
$t->isStarted = false;
$t->onEnd($this);
}
}
}
}
public function __destruct(){
unset($this->entity);
}
public function updateTasks(){
if($this->counter % 3 != 0){
return;
}
foreach($this->tasks as $t){
if(!$t->isStarted && $t->canBeExecuted($this)){
$t->isStarted = true;
$t->onStart($this);
}
if($t->isStarted){
$t->onUpdate($this);
if($t->selfCounter <= 0){
$t->isStarted = false;
$t->onEnd($this);
}
}
}
}
public function __destruct(){
unset($this->entity);
}
}