本文整理汇总了PHP中pocketmine\math\AxisAlignedBB::setBB方法的典型用法代码示例。如果您正苦于以下问题:PHP AxisAlignedBB::setBB方法的具体用法?PHP AxisAlignedBB::setBB怎么用?PHP AxisAlignedBB::setBB使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\math\AxisAlignedBB
的用法示例。
在下文中一共展示了AxisAlignedBB::setBB方法的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(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;
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->boundingBox->getOffsetBoundingBox($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->getOffsetBoundingBox($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);
//.........这里部分代码省略.........
示例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($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;
//.........这里部分代码省略.........