当前位置: 首页>>代码示例>>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;未经允许,请勿转载。