當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Entity::entityBaseTick方法代碼示例

本文整理匯總了PHP中pocketmine\entity\Entity::entityBaseTick方法的典型用法代碼示例。如果您正苦於以下問題:PHP Entity::entityBaseTick方法的具體用法?PHP Entity::entityBaseTick怎麽用?PHP Entity::entityBaseTick使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pocketmine\entity\Entity的用法示例。


在下文中一共展示了Entity::entityBaseTick方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: entityBaseTick

 public function entityBaseTick($tickDiff = 1)
 {
     Timings::$timerEntityBaseTick->startTiming();
     if (!$this->isCreated()) {
         return false;
     }
     $hasUpdate = Entity::entityBaseTick($tickDiff);
     if ($this->attackTime > 0) {
         $this->attackTime -= $tickDiff;
     }
     if ($this->isInsideOfSolid()) {
         $hasUpdate = true;
         $ev = new EntityDamageEvent($this, EntityDamageEvent::CAUSE_SUFFOCATION, 1);
         $this->attack($ev->getFinalDamage(), $ev);
     }
     if ($this instanceof Enderman) {
         if ($this->level->getBlock(new Vector3(Math::floorFloat($this->x), (int) $this->y, Math::floorFloat($this->z))) instanceof Water) {
             $ev = new EntityDamageEvent($this, EntityDamageEvent::CAUSE_DROWNING, 2);
             $this->attack($ev->getFinalDamage(), $ev);
             $this->move(mt_rand(-20, 20), mt_rand(-20, 20), mt_rand(-20, 20));
         }
     } else {
         if (!$this->hasEffect(Effect::WATER_BREATHING) && $this->isInsideOfWater()) {
             $hasUpdate = true;
             $airTicks = $this->getDataProperty(self::DATA_AIR) - $tickDiff;
             if ($airTicks <= -20) {
                 $airTicks = 0;
                 $ev = new EntityDamageEvent($this, EntityDamageEvent::CAUSE_DROWNING, 2);
                 $this->attack($ev->getFinalDamage(), $ev);
             }
             $this->setDataProperty(self::DATA_AIR, self::DATA_TYPE_SHORT, $airTicks);
         } else {
             $this->setDataProperty(self::DATA_AIR, self::DATA_TYPE_SHORT, 300);
         }
     }
     Timings::$timerEntityBaseTick->stopTiming();
     return $hasUpdate;
 }
開發者ID:rilex04,項目名稱:EntityManager,代碼行數:38,代碼來源:Monster.php

示例2: entityBaseTick

 public function entityBaseTick($tickDiff = 1)
 {
     Timings::$timerLivingEntityBaseTick->startTiming();
     $hasUpdate = parent::entityBaseTick($tickDiff);
     if ($this->isAlive()) {
         if ($this->isInsideOfSolid()) {
             $hasUpdate = true;
             $ev = new EntityDamageEvent($this, EntityDamageEvent::CAUSE_SUFFOCATION, 1);
             $this->attack($ev->getFinalDamage(), $ev);
         }
         if (!$this->hasEffect(Effect::WATER_BREATHING) and $this->isInsideOfWater()) {
             if ($this instanceof WaterAnimal) {
                 $this->setDataProperty(self::DATA_AIR, self::DATA_TYPE_SHORT, 300);
             } else {
                 $hasUpdate = true;
                 $airTicks = $this->getDataProperty(self::DATA_AIR) - $tickDiff;
                 if ($airTicks <= -20) {
                     $airTicks = 0;
                     $ev = new EntityDamageEvent($this, EntityDamageEvent::CAUSE_DROWNING, 2);
                     $this->attack($ev->getFinalDamage(), $ev);
                 }
                 $this->setDataProperty(self::DATA_AIR, self::DATA_TYPE_SHORT, $airTicks);
             }
         } else {
             if ($this instanceof WaterAnimal) {
                 $hasUpdate = true;
                 $airTicks = $this->getDataProperty(self::DATA_AIR) - $tickDiff;
                 if ($airTicks <= -20) {
                     $airTicks = 0;
                     $ev = new EntityDamageEvent($this, EntityDamageEvent::CAUSE_SUFFOCATION, 2);
                     $this->attack($ev->getFinalDamage(), $ev);
                 }
                 $this->setDataProperty(self::DATA_AIR, self::DATA_TYPE_SHORT, $airTicks);
             } else {
                 $this->setDataProperty(self::DATA_AIR, self::DATA_TYPE_SHORT, 300);
             }
         }
     }
     if ($this->attackTime > 0) {
         $this->attackTime -= $tickDiff;
     }
     Timings::$timerLivingEntityBaseTick->stopTiming();
     return $hasUpdate;
 }
開發者ID:ianju,項目名稱:PocketMine-MP,代碼行數:44,代碼來源:Living.php

示例3: entityBaseTick

 public function entityBaseTick($tickDiff = 1)
 {
     Timings::$timerEntityBaseTick->startTiming();
     if ($this->dead === true) {
         ++$this->deadTicks;
         if ($this->deadTicks >= 10) {
             $this->despawnFromAll();
             if (!$this instanceof Player) {
                 $this->close();
             }
         }
         Timings::$timerEntityBaseTick->stopTiming();
         return $this->deadTicks < 10;
     }
     parent::entityBaseTick($tickDiff);
     if ($this->dead !== true and $this->isInsideOfSolid()) {
         $ev = new EntityDamageEvent($this, EntityDamageEvent::CAUSE_SUFFOCATION, 1);
         $this->attack($ev->getFinalDamage(), $ev);
     }
     if ($this->dead !== true and $this->isInsideOfWater()) {
         $this->airTicks -= $tickDiff;
         if ($this->airTicks <= -20) {
             $this->airTicks = 0;
             $ev = new EntityDamageEvent($this, EntityDamageEvent::CAUSE_DROWNING, 2);
             $this->attack($ev->getFinalDamage(), $ev);
         }
     } else {
         $this->airTicks = 300;
     }
     if ($this->attackTime > 0) {
         $this->attackTime -= $tickDiff;
     }
     Timings::$timerEntityBaseTick->stopTiming();
 }
開發者ID:rryy,項目名稱:PocketMine-MP,代碼行數:34,代碼來源:Living.php

示例4: entityBaseTick

 public function entityBaseTick()
 {
     Timings::$timerEntityBaseTick->startTiming();
     parent::entityBaseTick();
     if ($this->dead !== true and $this->isInsideOfSolid()) {
         $this->server->getPluginManager()->callEvent($ev = new EntityDamageEvent($this, EntityDamageEvent::CAUSE_SUFFOCATION, 1));
         if (!$ev->isCancelled()) {
             $this->attack($ev->getFinalDamage(), $ev);
         }
     }
     if ($this->dead !== true and $this->isInsideOfWater()) {
         --$this->airTicks;
         if ($this->airTicks <= -20) {
             $this->airTicks = 0;
             $this->server->getPluginManager()->callEvent($ev = new EntityDamageEvent($this, EntityDamageEvent::CAUSE_DROWNING, 2));
             if (!$ev->isCancelled()) {
                 $this->attack($ev->getFinalDamage(), $ev);
             }
         }
         $this->extinguish();
     } else {
         $this->airTicks = 300;
     }
     if ($this->attackTime > 0) {
         --$this->attackTime;
     }
     Timings::$timerEntityBaseTick->stopTiming();
 }
開發者ID:boybook,項目名稱:PocketMine-MP,代碼行數:28,代碼來源:Living.php


注:本文中的pocketmine\entity\Entity::entityBaseTick方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。