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


PHP AxisAlignedBB::addCoord方法代码示例

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


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

示例1: move

 public function move($dx, $dy, $dz)
 {
     if ($dx == 0 and $dz == 0 and $dy == 0) {
         return true;
     }
     if ($this->keepMovement) {
         $this->boundingBox->offset($dx, $dy, $dz);
         $this->setPosition($this->temporalVector->setComponents(($this->boundingBox->minX + $this->boundingBox->maxX) / 2, $this->boundingBox->minY, ($this->boundingBox->minZ + $this->boundingBox->maxZ) / 2));
         $this->onGround = $this->isPlayer ? true : false;
         return true;
     } else {
         Timings::$entityMoveTimer->startTiming();
         $this->ySize *= 0.4;
         /*
         if($this->isColliding){ //With cobweb?
         	$this->isColliding = false;
         	$dx *= 0.25;
         	$dy *= 0.05;
         	$dz *= 0.25;
         	$this->motionX = 0;
         	$this->motionY = 0;
         	$this->motionZ = 0;
         }
         */
         $movX = $dx;
         $movY = $dy;
         $movZ = $dz;
         $axisalignedbb = clone $this->boundingBox;
         /*$sneakFlag = $this->onGround and $this instanceof Player;
         
         			if($sneakFlag){
         				for($mov = 0.05; $dx != 0.0 and count($this->level->getCollisionCubes($this, $this->boundingBox->getOffsetBoundingBox($dx, -1, 0))) === 0; $movX = $dx){
         					if($dx < $mov and $dx >= -$mov){
         						$dx = 0;
         					}elseif($dx > 0){
         						$dx -= $mov;
         					}else{
         						$dx += $mov;
         					}
         				}
         
         				for(; $dz != 0.0 and count($this->level->getCollisionCubes($this, $this->boundingBox->getOffsetBoundingBox(0, -1, $dz))) === 0; $movZ = $dz){
         					if($dz < $mov and $dz >= -$mov){
         						$dz = 0;
         					}elseif($dz > 0){
         						$dz -= $mov;
         					}else{
         						$dz += $mov;
         					}
         				}
         
         				//TODO: big messy loop
         			}*/
         $list = $this->level->getCollisionCubes($this, $this->level->getTickRate() > 1 ? $this->boundingBox->getOffsetBoundingBox($dx, $dy, $dz) : $this->boundingBox->addCoord($dx, $dy, $dz), false);
         foreach ($list as $bb) {
             $dy = $bb->calculateYOffset($this->boundingBox, $dy);
         }
         $this->boundingBox->offset(0, $dy, 0);
         $fallingFlag = ($this->onGround or $dy != $movY and $movY < 0);
         foreach ($list as $bb) {
             $dx = $bb->calculateXOffset($this->boundingBox, $dx);
         }
         $this->boundingBox->offset($dx, 0, 0);
         foreach ($list as $bb) {
             $dz = $bb->calculateZOffset($this->boundingBox, $dz);
         }
         $this->boundingBox->offset(0, 0, $dz);
         if ($this->stepHeight > 0 and $fallingFlag and $this->ySize < 0.05 and ($movX != $dx or $movZ != $dz)) {
             $cx = $dx;
             $cy = $dy;
             $cz = $dz;
             $dx = $movX;
             $dy = $this->stepHeight;
             $dz = $movZ;
             $axisalignedbb1 = clone $this->boundingBox;
             $this->boundingBox->setBB($axisalignedbb);
             $list = $this->level->getCollisionCubes($this, $this->boundingBox->addCoord($dx, $dy, $dz), false);
             foreach ($list as $bb) {
                 $dy = $bb->calculateYOffset($this->boundingBox, $dy);
             }
             $this->boundingBox->offset(0, $dy, 0);
             foreach ($list as $bb) {
                 $dx = $bb->calculateXOffset($this->boundingBox, $dx);
             }
             $this->boundingBox->offset($dx, 0, 0);
             foreach ($list as $bb) {
                 $dz = $bb->calculateZOffset($this->boundingBox, $dz);
             }
             $this->boundingBox->offset(0, 0, $dz);
             if ($cx ** 2 + $cz ** 2 >= $dx ** 2 + $dz ** 2) {
                 $dx = $cx;
                 $dy = $cy;
                 $dz = $cz;
                 $this->boundingBox->setBB($axisalignedbb1);
             } else {
                 $this->ySize += 0.5;
             }
         }
         $this->x = ($this->boundingBox->minX + $this->boundingBox->maxX) / 2;
         $this->y = $this->boundingBox->minY - $this->ySize;
//.........这里部分代码省略.........
开发者ID:NewDelion,项目名称:PocketMine-0.13.x,代码行数:101,代码来源:Entity.php

示例2: move

 public function move($dx, $dy, $dz)
 {
     if ($dx == 0 and $dz == 0 and $dy == 0) {
         return true;
     }
     if ($this->keepMovement) {
         $this->boundingBox->offset($dx, $dy, $dz);
         $this->setPosition(new Vector3(($this->boundingBox->minX + $this->boundingBox->maxX) / 2, $this->boundingBox->minY, ($this->boundingBox->minZ + $this->boundingBox->maxZ) / 2));
         $this->onGround = $this instanceof Player ? true : false;
     } else {
         Timings::$entityMoveTimer->startTiming();
         $this->ySize *= 0.4;
         /*
         if($this->isColliding){ //With cobweb?
         	$this->isColliding = false;
         	$dx *= 0.25;
         	$dy *= 0.05;
         	$dz *= 0.25;
         	$this->motionX = 0;
         	$this->motionY = 0;
         	$this->motionZ = 0;
         }
         */
         $movX = $dx;
         $movY = $dy;
         $movZ = $dz;
         $axisalignedbb = clone $this->boundingBox;
         /*$sneakFlag = $this->onGround and $this instanceof Player;
         
         			if($sneakFlag){
         				for($mov = 0.05; $dx != 0.0 and count($this->level->getCollisionCubes($this, $this->boundingBox->getOffsetBoundingBox($dx, -1, 0))) === 0; $movX = $dx){
         					if($dx < $mov and $dx >= -$mov){
         						$dx = 0;
         					}elseif($dx > 0){
         						$dx -= $mov;
         					}else{
         						$dx += $mov;
         					}
         				}
         
         				for(; $dz != 0.0 and count($this->level->getCollisionCubes($this, $this->boundingBox->getOffsetBoundingBox(0, -1, $dz))) === 0; $movZ = $dz){
         					if($dz < $mov and $dz >= -$mov){
         						$dz = 0;
         					}elseif($dz > 0){
         						$dz -= $mov;
         					}else{
         						$dz += $mov;
         					}
         				}
         
         				//TODO: big messy loop
         			}*/
         $list = $this->level->getCollisionCubes($this, $this->boundingBox->addCoord($dx, $dy, $dz));
         foreach ($list as $bb) {
             $dy = $bb->calculateYOffset($this->boundingBox, $dy);
         }
         $this->boundingBox->offset(0, $dy, 0);
         if ($movY != $dy) {
             $dx = 0;
             $dy = 0;
             $dz = 0;
         }
         $fallingFlag = ($this->onGround or $dy != $movY and $movY < 0);
         foreach ($list as $bb) {
             $dx = $bb->calculateXOffset($this->boundingBox, $dx);
         }
         $this->boundingBox->offset($dx, 0, 0);
         if ($movX != $dx) {
             $dx = 0;
             $dy = 0;
             $dz = 0;
         }
         foreach ($list as $bb) {
             $dz = $bb->calculateZOffset($this->boundingBox, $dz);
         }
         $this->boundingBox->offset(0, 0, $dz);
         if ($movZ != $dz) {
             $dx = 0;
             $dy = 0;
             $dz = 0;
         }
         if ($this->stepHeight > 0 and $fallingFlag and $this->ySize < 0.05 and ($movX != $dx or $movZ != $dz)) {
             $cx = $dx;
             $cy = $dy;
             $cz = $dz;
             $dx = $movX;
             $dy = $this->stepHeight;
             $dz = $movZ;
             $axisalignedbb1 = clone $this->boundingBox;
             $this->boundingBox->setBB($axisalignedbb);
             $list = $this->level->getCollisionCubes($this, $this->boundingBox->addCoord($movX, $dy, $movZ), false);
             foreach ($list as $bb) {
                 $dy = $bb->calculateYOffset($this->boundingBox, $dy);
             }
             $this->boundingBox->offset(0, $dy, 0);
             if ($movY != $dy) {
                 $dx = 0;
                 $dy = 0;
                 $dz = 0;
             }
//.........这里部分代码省略.........
开发者ID:rryy,项目名称:PocketMine-MP,代码行数:101,代码来源:Entity.php


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