pocketmine\entity\Human::exhaust PHP Méthode

exhaust() public méthode

Increases a human's exhaustion level.
public exhaust ( float $amount, integer $cause = PlayerExhaustEvent::CAUSE_CUSTOM ) : float
$amount float
$cause integer
Résultat float the amount of exhaustion level increased
    public function exhaust(float $amount, int $cause = PlayerExhaustEvent::CAUSE_CUSTOM) : float
    {
        $this->server->getPluginManager()->callEvent($ev = new PlayerExhaustEvent($this, $amount, $cause));
        if ($ev->isCancelled()) {
            return 0.0;
        }
        $exhaustion = $this->getExhaustion();
        $exhaustion += $ev->getAmount();
        while ($exhaustion >= 4.0) {
            $exhaustion -= 4.0;
            $saturation = $this->getSaturation();
            if ($saturation > 0) {
                $saturation = max(0, $saturation - 1.0);
                $this->setSaturation($saturation);
            } else {
                $food = $this->getFood();
                if ($food > 0) {
                    $food--;
                    $this->setFood($food);
                }
            }
        }
        $this->setExhaustion($exhaustion);
        return $ev->getAmount();
    }