本文整理匯總了PHP中pocketmine\entity\Entity::onUpdate方法的典型用法代碼示例。如果您正苦於以下問題:PHP Entity::onUpdate方法的具體用法?PHP Entity::onUpdate怎麽用?PHP Entity::onUpdate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pocketmine\entity\Entity
的用法示例。
在下文中一共展示了Entity::onUpdate方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: onUpdate
public function onUpdate($currentTick)
{
if ($this->closed) {
return false;
}
$this->timings->startTiming();
$hasUpdate = parent::onUpdate($currentTick);
$collector = null;
if (!$this->collected) {
foreach ($this->level->getPlayers() as $p) {
if ($this->distanceSquared($p) <= 36) {
//6 or less
$collector = $p;
$this->collected = true;
break;
}
}
}
if ($this->age > 1200 || $this->collected) {
$this->kill();
$hasUpdate = true;
}
if ($collector !== null) {
$collector->giveExp($this->getAmount());
$this->kill();
}
$this->timings->stopTiming();
return $hasUpdate;
}
示例2: onUpdate
public function onUpdate($currentTick)
{
if ($this->closed) {
return false;
}
$this->timings->startTiming();
$hasUpdate = parent::onUpdate($currentTick);
if ($this->age > 1200) {
$this->kill();
$hasUpdate = true;
}
$this->timings->stopTiming();
return $hasUpdate;
}
示例3: onUpdate
public function onUpdate($currentTick)
{
if ($this->closed) {
return false;
}
$this->timings->startTiming();
$hasUpdate = parent::onUpdate($currentTick);
if ($this->age > 50) {
$this->kill();
$hasUpdate = true;
$this->getLevel()->dropItem($this, ItemItem::get(ItemItem::EYE_OF_ENDER), $this);
}
$this->timings->stopTiming();
return $hasUpdate;
}