本文整理汇总了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;
}