当前位置: 首页>>代码示例>>PHP>>正文


PHP Entity::close方法代码示例

本文整理汇总了PHP中pocketmine\entity\Entity::close方法的典型用法代码示例。如果您正苦于以下问题:PHP Entity::close方法的具体用法?PHP Entity::close怎么用?PHP Entity::close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pocketmine\entity\Entity的用法示例。


在下文中一共展示了Entity::close方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: onRun

 public function onRun($currentTick)
 {
     $explosion = new Explosion(new Position($this->entity->getX(), $this->entity->getY(), $this->entity->getZ(), $this->entity->getLevel()), $this->radius);
     if (!$this->entity->isAlive()) {
         return;
     }
     $this->entity->close();
     if ($explosion->explodeA()) {
         $explosion->explodeB();
     }
 }
开发者ID:xionbig,项目名称:LuckyBlock,代码行数:11,代码来源:TaskExplodeMob.php

示例2: close

 public function close()
 {
     if (!$this->closed) {
         if ($this->sittingEntity !== null) {
             $this->standupSittingEntity();
         }
     }
     parent::close();
 }
开发者ID:MrDoni98,项目名称:PocketMine-MP-Plugins,代码行数:9,代码来源:Chair.php

示例3: removeEntity

 /**
  * Removes the entity from the level index
  *
  * @param Entity $entity
  *
  * @throws LevelException
  */
 public function removeEntity(Entity $entity)
 {
     if ($entity->getLevel() !== $this) {
         throw new LevelException("Invalid Entity level");
     }
     if ($entity instanceof Player) {
         unset($this->players[$entity->getId()]);
         $this->checkSleep();
     } elseif ($entity instanceof ExperienceOrb) {
         $entity->close();
     } else {
         $entity->kill();
     }
     unset($this->entities[$entity->getId()]);
     unset($this->updateEntities[$entity->getId()]);
 }
开发者ID:orlando092,项目名称:ImagicalMine,代码行数:23,代码来源:Level.php

示例4: onUpdate

 public function onUpdate($currentTick)
 {
     if ($this->closed == true || $this->dead == true || ($target = $this->target) == null || $target->dead || $this->player instanceof Player && !$this->player->spawned) {
         if (!$this->closed) {
             parent::close();
         }
         $this->dead = true;
         return false;
     } else {
         $dis = sqrt(pow($dZ = $target->z - $this->z, 2) + pow($dX = $target->x - $this->x, 2));
         if ($this->isHead) {
             $bb = clone $this->getBoundingBox();
             $this->timings->startTiming();
             $tickDiff = max(1, $currentTick - $this->lastUpdate);
             $this->lastUpdate = $currentTick;
             $hasUpdate = $this->entityBaseTick($tickDiff);
             if ($this->getLevel()->getFolderName() !== $target->getLevel()->getFolderName()) {
                 $this->teleport($target);
             }
             $onGround = count($this->level->getCollisionBlocks($bb->offset(0, -$this->gravity, 0))) > 0;
             $x = cos($at2 = atan2($dZ, $dX)) * $this->speed;
             $z = sin($at2) * $this->speed;
             $y = 0;
             $bb->offset(0, $this->gravity, 0);
             $isJump = count($this->level->getCollisionBlocks($bb->grow(0, 0, 0)->offset($x, 1, $z))) <= 0;
             if (count($this->level->getCollisionBlocks($bb->grow(0, 0, 0)->offset(0, 0, $z))) > 0) {
                 $z = 0;
                 if ($isJump) {
                     $y = $this->gravity;
                 }
             }
             if (count($this->level->getCollisionBlocks($bb->grow(0, 0, 0)->offset($x, 0, 0))) > 0) {
                 $x = 0;
                 if ($isJump) {
                     $y = $this->gravity;
                 }
             }
             if (!$this->isFallow || $dis < $this->distance) {
                 $x = 0;
                 $z = 0;
             }
             if ($this->isFallow && $dis > 20) {
                 $this->updateMove($target);
                 if ($target instanceof Player) {
                     $target->sendMessage("[MobPet] 같이가요 ");
                 }
                 return true;
             } elseif (!$isJump && $target->y > $this->y - ($target instanceof Player ? 0.5 : 0)) {
                 if ($this->jumpTick <= 0) {
                     $this->jumpTick = 40;
                 } elseif ($this->jumpTick > 36) {
                     $y = $this->gravity;
                 }
             }
             if ($this->jumpTick > 0) {
                 $this->jumpTick--;
             }
             if (($n = floor($this->y) - $this->y) < $this->gravity && $n > 0) {
                 $y = -$n;
             }
             if ($y == 0 && !$onGround) {
                 $y = -$this->gravity;
             }
             $block = $this->level->getBlock($this->add($vec = new Vector3($x, $y, $z)));
             if ($block->hasEntityCollision()) {
                 $block->addVelocityToEntity($this, $vec2 = $vec->add(0, $this->gravity, 0));
                 $vec->x = ($vec->x + $vec2->x / 2) / 5;
                 $vec->y = $vec->y + $vec2->y / 2;
                 $vec->z = ($vec->z + $vec2->z / 2) / 5;
             }
             if (count($this->level->getCollisionBlocks($bb->offset(0, -0.01, 0))) <= 0) {
                 $y -= 0.01;
             }
             $this->updateMove($vec->add(new Vector3(($this->boundingBox->minX + $this->boundingBox->maxX - $this->drag) / 2, ($this->boundingBox->minY + $this->boundingBox->maxY) / 2, ($this->boundingBox->minZ + $this->boundingBox->maxZ - $this->drag) / 2)));
             $this->onGround = $onGround;
         } else {
             $x = cos($at2 = atan2($dZ, $dX)) * $this->distance;
             $z = sin($at2) * $this->distance;
             $this->updateMove($target->add(-$x, 0, -$z));
         }
     }
     return true;
 }
开发者ID:Skull3x,项目名称:MineBlock,代码行数:83,代码来源:MobPet.php

示例5: onUpdate

 public function onUpdate($currentTick)
 {
     if ($this->closed == true || $this->dead == true) {
         if (!$this->closed) {
             parent::close();
         }
         $this->dead = true;
         return false;
     }
     $p = $this->player;
     $x = cos($at2 = atan2($p->z - $this->z, $p->x - $this->x)) * 0.3;
     $z = sin($at2) * 0.3;
     $v = $p->add(0, $p->getEyeHeight(), 0);
     $this->updateMove($this->add($x, ($v->y - $this->y) / 5, $z));
     if ($v->distance($this) <= 0.5) {
         $p->getInventory()->addItem($this->item);
         $this->close();
     }
     return true;
 }
开发者ID:Skull3x,项目名称:MineBlock,代码行数:20,代码来源:Fishing.php

示例6: onUpdate

 public function onUpdate($currentTick)
 {
     if ($this->closed == true || $this->dead == true || $this->block == null || $this->block->dead || $this->block->closed) {
         if (!$this->closed) {
             parent::close();
         }
         if (!$this->block->closed) {
             $this->block->close();
         }
         $this->dead = true;
         return false;
     }
     $this->updateMove($this->block->add(0, -0.35, 0));
     return true;
 }
开发者ID:Skull3x,项目名称:MineBlock,代码行数:15,代码来源:ItemPet.php


注:本文中的pocketmine\entity\Entity::close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。