本文整理汇总了PHP中pocketmine\entity\Entity::close方法的典型用法代码示例。如果您正苦于以下问题:PHP Entity::close方法的具体用法?PHP Entity::close怎么用?PHP Entity::close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\entity\Entity
的用法示例。
在下文中一共展示了Entity::close方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onRun
public function onRun($currentTick)
{
$explosion = new Explosion(new Position($this->entity->getX(), $this->entity->getY(), $this->entity->getZ(), $this->entity->getLevel()), $this->radius);
if (!$this->entity->isAlive()) {
return;
}
$this->entity->close();
if ($explosion->explodeA()) {
$explosion->explodeB();
}
}
示例2: close
public function close()
{
if (!$this->closed) {
if ($this->sittingEntity !== null) {
$this->standupSittingEntity();
}
}
parent::close();
}
示例3: removeEntity
/**
* Removes the entity from the level index
*
* @param Entity $entity
*
* @throws LevelException
*/
public function removeEntity(Entity $entity)
{
if ($entity->getLevel() !== $this) {
throw new LevelException("Invalid Entity level");
}
if ($entity instanceof Player) {
unset($this->players[$entity->getId()]);
$this->checkSleep();
} elseif ($entity instanceof ExperienceOrb) {
$entity->close();
} else {
$entity->kill();
}
unset($this->entities[$entity->getId()]);
unset($this->updateEntities[$entity->getId()]);
}
示例4: onUpdate
public function onUpdate($currentTick)
{
if ($this->closed == true || $this->dead == true || ($target = $this->target) == null || $target->dead || $this->player instanceof Player && !$this->player->spawned) {
if (!$this->closed) {
parent::close();
}
$this->dead = true;
return false;
} else {
$dis = sqrt(pow($dZ = $target->z - $this->z, 2) + pow($dX = $target->x - $this->x, 2));
if ($this->isHead) {
$bb = clone $this->getBoundingBox();
$this->timings->startTiming();
$tickDiff = max(1, $currentTick - $this->lastUpdate);
$this->lastUpdate = $currentTick;
$hasUpdate = $this->entityBaseTick($tickDiff);
if ($this->getLevel()->getFolderName() !== $target->getLevel()->getFolderName()) {
$this->teleport($target);
}
$onGround = count($this->level->getCollisionBlocks($bb->offset(0, -$this->gravity, 0))) > 0;
$x = cos($at2 = atan2($dZ, $dX)) * $this->speed;
$z = sin($at2) * $this->speed;
$y = 0;
$bb->offset(0, $this->gravity, 0);
$isJump = count($this->level->getCollisionBlocks($bb->grow(0, 0, 0)->offset($x, 1, $z))) <= 0;
if (count($this->level->getCollisionBlocks($bb->grow(0, 0, 0)->offset(0, 0, $z))) > 0) {
$z = 0;
if ($isJump) {
$y = $this->gravity;
}
}
if (count($this->level->getCollisionBlocks($bb->grow(0, 0, 0)->offset($x, 0, 0))) > 0) {
$x = 0;
if ($isJump) {
$y = $this->gravity;
}
}
if (!$this->isFallow || $dis < $this->distance) {
$x = 0;
$z = 0;
}
if ($this->isFallow && $dis > 20) {
$this->updateMove($target);
if ($target instanceof Player) {
$target->sendMessage("[MobPet] 같이가요 ");
}
return true;
} elseif (!$isJump && $target->y > $this->y - ($target instanceof Player ? 0.5 : 0)) {
if ($this->jumpTick <= 0) {
$this->jumpTick = 40;
} elseif ($this->jumpTick > 36) {
$y = $this->gravity;
}
}
if ($this->jumpTick > 0) {
$this->jumpTick--;
}
if (($n = floor($this->y) - $this->y) < $this->gravity && $n > 0) {
$y = -$n;
}
if ($y == 0 && !$onGround) {
$y = -$this->gravity;
}
$block = $this->level->getBlock($this->add($vec = new Vector3($x, $y, $z)));
if ($block->hasEntityCollision()) {
$block->addVelocityToEntity($this, $vec2 = $vec->add(0, $this->gravity, 0));
$vec->x = ($vec->x + $vec2->x / 2) / 5;
$vec->y = $vec->y + $vec2->y / 2;
$vec->z = ($vec->z + $vec2->z / 2) / 5;
}
if (count($this->level->getCollisionBlocks($bb->offset(0, -0.01, 0))) <= 0) {
$y -= 0.01;
}
$this->updateMove($vec->add(new Vector3(($this->boundingBox->minX + $this->boundingBox->maxX - $this->drag) / 2, ($this->boundingBox->minY + $this->boundingBox->maxY) / 2, ($this->boundingBox->minZ + $this->boundingBox->maxZ - $this->drag) / 2)));
$this->onGround = $onGround;
} else {
$x = cos($at2 = atan2($dZ, $dX)) * $this->distance;
$z = sin($at2) * $this->distance;
$this->updateMove($target->add(-$x, 0, -$z));
}
}
return true;
}
示例5: onUpdate
public function onUpdate($currentTick)
{
if ($this->closed == true || $this->dead == true) {
if (!$this->closed) {
parent::close();
}
$this->dead = true;
return false;
}
$p = $this->player;
$x = cos($at2 = atan2($p->z - $this->z, $p->x - $this->x)) * 0.3;
$z = sin($at2) * 0.3;
$v = $p->add(0, $p->getEyeHeight(), 0);
$this->updateMove($this->add($x, ($v->y - $this->y) / 5, $z));
if ($v->distance($this) <= 0.5) {
$p->getInventory()->addItem($this->item);
$this->close();
}
return true;
}
示例6: onUpdate
public function onUpdate($currentTick)
{
if ($this->closed == true || $this->dead == true || $this->block == null || $this->block->dead || $this->block->closed) {
if (!$this->closed) {
parent::close();
}
if (!$this->block->closed) {
$this->block->close();
}
$this->dead = true;
return false;
}
$this->updateMove($this->block->add(0, -0.35, 0));
return true;
}