本文整理匯總了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;
}
示例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;
}