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


PHP math\AxisAlignedBB類代碼示例

本文整理匯總了PHP中pocketmine\math\AxisAlignedBB的典型用法代碼示例。如果您正苦於以下問題:PHP AxisAlignedBB類的具體用法?PHP AxisAlignedBB怎麽用?PHP AxisAlignedBB使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: recalculateBoundingBox

 protected function recalculateBoundingBox()
 {
     $f = 0.1875;
     $damage = $this->getFullDamage();
     $bb = new AxisAlignedBB($this->x, $this->y, $this->z, $this->x + 1, $this->y + 2, $this->z + 1);
     $j = $damage & 0x3;
     $isOpen = ($damage & 0x4) > 0;
     $isRight = ($damage & 0x10) > 0;
     if ($j === 0) {
         if ($isOpen) {
             if (!$isRight) {
                 $bb->setBounds($this->x, $this->y, $this->z, $this->x + 1, $this->y + 1, $this->z + $f);
             } else {
                 $bb->setBounds($this->x, $this->y, $this->z + 1 - $f, $this->x + 1, $this->y + 1, $this->z + 1);
             }
         } else {
             $bb->setBounds($this->x, $this->y, $this->z, $this->x + $f, $this->y + 1, $this->z + 1);
         }
     } elseif ($j === 1) {
         if ($isOpen) {
             if (!$isRight) {
                 $bb->setBounds($this->x + 1 - $f, $this->y, $this->z, $this->x + 1, $this->y + 1, $this->z + 1);
             } else {
                 $bb->setBounds($this->x, $this->y, $this->z, $this->x + $f, $this->y + 1, $this->z + 1);
             }
         } else {
             $bb->setBounds($this->x, $this->y, $this->z, $this->x + 1, $this->y + 1, $this->z + $f);
         }
     } elseif ($j === 2) {
         if ($isOpen) {
             if (!$isRight) {
                 $bb->setBounds($this->x, $this->y, $this->z + 1 - $f, $this->x + 1, $this->y + 1, $this->z + 1);
             } else {
                 $bb->setBounds($this->x, $this->y, $this->z, $this->x + 1, $this->y + 1, $this->z + $f);
             }
         } else {
             $bb->setBounds($this->x + 1 - $f, $this->y, $this->z, $this->x + 1, $this->y + 1, $this->z + 1);
         }
     } elseif ($j === 3) {
         if ($isOpen) {
             if (!$isRight) {
                 $bb->setBounds($this->x, $this->y, $this->z, $this->x + $f, $this->y + 1, $this->z + 1);
             } else {
                 $bb->setBounds($this->x + 1 - $f, $this->y, $this->z, $this->x + 1, $this->y + 1, $this->z + 1);
             }
         } else {
             $bb->setBounds($this->x, $this->y, $this->z + 1 - $f, $this->x + 1, $this->y + 1, $this->z + 1);
         }
     }
     return $bb;
 }
開發者ID:TexusDark,項目名稱:Ananas-MP,代碼行數:51,代碼來源:Door.php

示例2: recalculateBoundingBox

 protected function recalculateBoundingBox()
 {
     $damage = $this->getDamage();
     $f = 0.1875;
     if (($damage & 0x8) > 0) {
         $bb = new AxisAlignedBB($this->x, $this->y + 1 - $f, $this->z, $this->x + 1, $this->y + 1, $this->z + 1);
     } else {
         $bb = new AxisAlignedBB($this->x, $this->y, $this->z, $this->x + 1, $this->y + $f, $this->z + 1);
     }
     if (($damage & 0x4) > 0) {
         if (($damage & 0x3) === 0) {
             $bb->setBounds($this->x, $this->y, $this->z + 1 - $f, $this->x + 1, $this->y + 1, $this->z + 1);
         } elseif (($damage & 0x3) === 1) {
             $bb->setBounds($this->x, $this->y, $this->z, $this->x + 1, $this->y + 1, $this->z + $f);
         }
         if (($damage & 0x3) === 2) {
             $bb->setBounds($this->x + 1 - $f, $this->y, $this->z, $this->x + 1, $this->y + 1, $this->z + 1);
         }
         if (($damage & 0x3) === 3) {
             $bb->setBounds($this->x, $this->y, $this->z, $this->x + $f, $this->y + 1, $this->z + 1);
         }
     }
     return $bb;
 }
開發者ID:psh3253,項目名稱:PocketMine-MP_Windows,代碼行數:24,代碼來源:IronTrapdoor.php

示例3: recalculateBoundingBox

 protected function recalculateBoundingBox()
 {
     $damage = $this->getDamage();
     $f = 0.1875;
     if (($damage & self::MASK_UPPER) > 0) {
         $bb = new AxisAlignedBB($this->x, $this->y + 1 - $f, $this->z, $this->x + 1, $this->y + 1, $this->z + 1);
     } else {
         $bb = new AxisAlignedBB($this->x, $this->y, $this->z, $this->x + 1, $this->y + $f, $this->z + 1);
     }
     if (($damage & self::MASK_OPENED) > 0) {
         if (($damage & 0x3) === self::MASK_SIDE_NORTH) {
             $bb->setBounds($this->x, $this->y, $this->z + 1 - $f, $this->x + 1, $this->y + 1, $this->z + 1);
         } elseif (($damage & 0x3) === self::MASK_SIDE_SOUTH) {
             $bb->setBounds($this->x, $this->y, $this->z, $this->x + 1, $this->y + 1, $this->z + $f);
         }
         if (($damage & 0x3) === self::MASK_SIDE_WEST) {
             $bb->setBounds($this->x + 1 - $f, $this->y, $this->z, $this->x + 1, $this->y + 1, $this->z + 1);
         }
         if (($damage & 0x3) === self::MASK_SIDE_EAST) {
             $bb->setBounds($this->x, $this->y, $this->z, $this->x + $f, $this->y + 1, $this->z + 1);
         }
     }
     return $bb;
 }
開發者ID:xxFlare,項目名稱:PocketMine-MP,代碼行數:24,代碼來源:Trapdoor.php

示例4: collidesWithBB

 /**
  * Checks for collision against an AxisAlignedBB
  *
  * @param AxisAlignedBB $bb
  *
  * @return bool
  */
 public function collidesWithBB(AxisAlignedBB $bb)
 {
     $bb2 = $this->getBoundingBox();
     return $bb2 !== null and $bb->intersectsWith($bb2);
 }
開發者ID:1455931078,項目名稱:Genisys,代碼行數:12,代碼來源:Block.php

示例5: collidesWithBB

 /**
  * Checks for collision against an AxisAlignedBB
  *
  * @param AxisAlignedBB $bb
  * @param Block[]       $list
  */
 public function collidesWithBB(AxisAlignedBB $bb, &$list = [])
 {
     $bb2 = $this->getBoundingBox();
     if ($bb2 !== null and $bb->intersectsWith($bb2)) {
         $list[] = $bb2;
     }
 }
開發者ID:TylerGames,項目名稱:PocketMine-MP,代碼行數:13,代碼來源:Block.php

示例6: setPosition

 public function setPosition(Vector3 $pos)
 {
     if ($this->closed) {
         return false;
     }
     if ($pos instanceof Position and $pos->level !== null and $pos->level !== $this->level) {
         if ($this->switchLevel($pos->getLevel()) === false) {
             return false;
         }
     }
     $this->x = $pos->x;
     $this->y = $pos->y;
     $this->z = $pos->z;
     $radius = $this->width / 2;
     $this->boundingBox->setBounds($pos->x - $radius, $pos->y, $pos->z - $radius, $pos->x + $radius, $pos->y + $this->height, $pos->z + $radius);
     $this->checkChunks();
     return true;
 }
開發者ID:Cecil107,項目名稱:PocketMine-0.13.0,代碼行數:18,代碼來源:Entity.php

示例7: setPosition

 public function setPosition(Vector3 $pos)
 {
     if ($this->closed) {
         return \false;
     }
     if ($pos instanceof Position and $pos->level !== \null and $pos->level !== $this->level) {
         if ($this->switchLevel($pos->getLevel()) === \false) {
             return \false;
         }
     }
     $this->x = $pos->x;
     $this->y = $pos->y;
     $this->z = $pos->z;
     $radius = $this->width / 2;
     $this->boundingBox->setBounds($pos->x - $radius, $pos->y, $pos->z - $radius, $pos->x + $radius, $pos->y + $this->height, $pos->z + $radius);
     if ($this->chunk === \null or $this->chunkX !== $this->x >> 4 and $this->chunkZ !== $this->z >> 4) {
         if ($this->chunk !== \null) {
             $this->chunk->removeEntity($this);
         }
         $this->level->loadChunk($this->x >> 4, $this->z >> 4);
         $this->chunk = $this->level->getChunk($this->x >> 4, $this->z >> 4, \true);
         $this->chunkX = $this->chunk->getX();
         $this->chunkZ = $this->chunk->getZ();
         if (!$this->justCreated) {
             $newChunk = $this->level->getUsingChunk($this->x >> 4, $this->z >> 4);
             foreach ($this->hasSpawned as $player) {
                 if (!isset($newChunk[$player->getId()])) {
                     $this->despawnFrom($player);
                 } else {
                     unset($newChunk[$player->getId()]);
                 }
             }
             foreach ($newChunk as $player) {
                 $this->spawnTo($player);
             }
         }
         $this->chunk->addEntity($this);
     }
     return \true;
 }
開發者ID:Cybertechpp,項目名稱:Steadfast2,代碼行數:40,代碼來源:Entity.php

示例8: setPosition

 public function setPosition(Vector3 $pos, $force = false)
 {
     if ($pos instanceof Position and $pos->getLevel() instanceof Level and $pos->getLevel() !== $this->getLevel()) {
         if ($this->switchLevel($pos->getLevel()) === false) {
             return false;
         }
     }
     if (!$this->justCreated and $force !== true) {
         $ev = new EntityMoveEvent($this, $pos);
         $this->server->getPluginManager()->callEvent($ev);
         if ($ev->isCancelled()) {
             return false;
         }
     }
     $this->x = $pos->x;
     $this->y = $pos->y;
     $this->z = $pos->z;
     $radius = $this->width / 2;
     $this->boundingBox->setBounds($pos->x - $radius, $pos->y + $this->ySize, $pos->z - $radius, $pos->x + $radius, $pos->y + $this->height + $this->ySize, $pos->z + $radius);
     if ($this->chunk === null or $this->chunk->getX() !== $this->x >> 4 and $this->chunk->getZ() !== $this->z >> 4) {
         if ($this->chunk instanceof FullChunk) {
             $this->chunk->removeEntity($this);
         }
         $this->getLevel()->loadChunk($this->x >> 4, $this->z >> 4);
         $this->chunk = $this->getLevel()->getChunkAt($this->x >> 4, $this->z >> 4);
         if (!$this->justCreated) {
             $newChunk = $this->getLevel()->getUsingChunk($this->x >> 4, $this->z >> 4);
             foreach ($this->hasSpawned as $player) {
                 if (!isset($newChunk[$player->getID()])) {
                     $this->despawnFrom($player);
                 } else {
                     unset($newChunk[$player->getID()]);
                 }
             }
             foreach ($newChunk as $player) {
                 $this->spawnTo($player);
             }
         }
         $this->chunk->addEntity($this);
     }
     return true;
 }
開發者ID:boybook,項目名稱:PocketMine-MP,代碼行數:42,代碼來源:Entity.php


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