Implemented XP orbs

This commit is contained in:
Dylan K. Taylor
2018-01-04 19:28:19 +00:00
parent 3ee225caec
commit a84910f04c
3 changed files with 194 additions and 0 deletions

View File

@ -76,6 +76,7 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
protected $totalXp = 0;
protected $xpSeed;
protected $xpCooldown = 0;
protected $baseOffset = 1.62;
@ -410,6 +411,23 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
$this->totalXp = $amount;
}
/**
* Returns whether the human can pickup XP orbs (checks cooldown time)
* @return bool
*/
public function canPickupXp() : bool{
return $this->xpCooldown === 0;
}
/**
* Sets the duration in ticks until the human can pick up another XP orb.
* @param int $value
*/
public function resetXpCooldown(int $value = 2){
$this->xpCooldown = $value;
}
public function getInventory(){
return $this->inventory;
}
@ -505,6 +523,10 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
$this->doFoodTick($tickDiff);
if($this->xpCooldown > 0){
$this->xpCooldown--;
}
return $hasUpdate;
}