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


PHP Entity::canCollideWith方法代码示例

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


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

示例1: getCollidingEntities

 /**
  * Returns the entities colliding the current one inside the AxisAlignedBB
  *
  * @param AxisAlignedBB $bb
  * @param Entity        $entity
  *
  * @return Entity[]
  */
 public function getCollidingEntities(AxisAlignedBB $bb, Entity $entity = null)
 {
     $nearby = [];
     if ($entity === null or $entity->canCollide) {
         $minX = Math::floorFloat(($bb->minX - 2) / 16);
         $maxX = Math::floorFloat(($bb->maxX + 2) / 16);
         $minZ = Math::floorFloat(($bb->minZ - 2) / 16);
         $maxZ = Math::floorFloat(($bb->maxZ + 2) / 16);
         for ($x = $minX; $x <= $maxX; ++$x) {
             for ($z = $minZ; $z <= $maxZ; ++$z) {
                 foreach (($______chunk = $this->getChunk($x, $z)) !== null ? $______chunk->getEntities() : [] as $ent) {
                     if ($ent !== $entity and ($entity === null or $entity->canCollideWith($ent)) and $ent->boundingBox->intersectsWith($bb)) {
                         $nearby[] = $ent;
                     }
                 }
             }
         }
     }
     return $nearby;
 }
开发者ID:RedstoneAlmeida,项目名称:Steadfast2,代码行数:28,代码来源:Level.php

示例2: getCollidingEntities

 /**
  * Returns the entities colliding the current one inside the AxisAlignedBB
  *
  * @param AxisAlignedBB $bb
  * @param Entity        $entity
  *
  * @return Entity[]
  */
 public function getCollidingEntities(AxisAlignedBB $bb, Entity $entity = null) : array
 {
     $nearby = [];
     if ($entity === null or $entity->canCollide) {
         $minX = Math::floorFloat(($bb->minX - 2) / 16);
         $maxX = Math::ceilFloat(($bb->maxX + 2) / 16);
         $minZ = Math::floorFloat(($bb->minZ - 2) / 16);
         $maxZ = Math::ceilFloat(($bb->maxZ + 2) / 16);
         for ($x = $minX; $x <= $maxX; ++$x) {
             for ($z = $minZ; $z <= $maxZ; ++$z) {
                 foreach ($this->getChunkEntities($x, $z) as $ent) {
                     if ($ent instanceof Player and $ent->isSpectator()) {
                         continue;
                     }
                     if ($entity == null) {
                         if ($ent->boundingBox->intersectsWith($bb)) {
                             $nearby[] = $ent;
                         }
                     } elseif ($entity instanceof Entity and $ent !== $entity and $entity->canCollideWith($ent)) {
                         if ($ent->boundingBox->intersectsWith($bb)) {
                             $nearby[] = $ent;
                         }
                     }
                 }
             }
         }
     }
     return $nearby;
 }
开发者ID:kniffo80,项目名称:Genisys,代码行数:37,代码来源:Level.php


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