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


PHP Entity::kill方法代碼示例

本文整理匯總了PHP中pocketmine\entity\Entity::kill方法的典型用法代碼示例。如果您正苦於以下問題:PHP Entity::kill方法的具體用法?PHP Entity::kill怎麽用?PHP Entity::kill使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pocketmine\entity\Entity的用法示例。


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

示例1: kill

 public function kill()
 {
     parent::kill();
     foreach ($this->getDrops() as $item) {
         $this->getLevel()->dropItem($this, $item);
     }
 }
開發者ID:ecoron,項目名稱:MinionsLandPE,代碼行數:7,代碼來源:Boat.php

示例2: kill

 public function kill()
 {
     parent::kill();
     foreach ($this->getDrops() as $i) {
         $this->getLevel()->dropItem($this, ItemItem::get($i[0], $i[1], $i[2]));
     }
 }
開發者ID:robozeri,項目名稱:Yuriko-MP,代碼行數:7,代碼來源:Boat.php

示例3: kill

 public function kill()
 {
     if (!$this->isAlive()) {
         return;
     }
     $this->explode();
     parent::kill();
     if (!$this->closed) {
         $this->close();
     }
 }
開發者ID:robske110,項目名稱:ClearSky,代碼行數:11,代碼來源:EnderCrystal.php

示例4: kill

 public function kill()
 {
     if (!$this->isAlive()) {
         return;
     }
     parent::kill();
     foreach ($this->getDrops() as $item) {
         $this->getLevel()->dropItem($this, $item);
     }
     if (!$this->closed) {
         $this->close();
     }
 }
開發者ID:ClearSkyTeam,項目名稱:ClearSky,代碼行數:13,代碼來源:Snake.php

示例5: 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->everyoneSleeping();
     } else {
         $entity->kill();
     }
     unset($this->entities[$entity->getId()]);
     unset($this->updateEntities[$entity->getId()]);
 }
開發者ID:RedstoneAlmeida,項目名稱:Steadfast2,代碼行數:21,代碼來源:Level.php

示例6: kill

 public function kill()
 {
     if (!$this->spawned) {
         return;
     }
     $message = "death.attack.generic";
     $params = [$this->getDisplayName()];
     $cause = $this->getLastDamageCause();
     switch ($cause === null ? EntityDamageEvent::CAUSE_CUSTOM : $cause->getCause()) {
         case EntityDamageEvent::CAUSE_ENTITY_ATTACK:
             if ($cause instanceof EntityDamageByEntityEvent) {
                 $e = $cause->getDamager();
                 if ($e instanceof Player) {
                     $message = "death.attack.player";
                     $params[] = $e->getDisplayName();
                     break;
                 } elseif ($e instanceof Living) {
                     $message = "death.attack.mob";
                     $params[] = $e->getNameTag() !== "" ? $e->getNameTag() : $e->getName();
                     break;
                 } else {
                     $params[] = "Unknown";
                 }
             }
             break;
         case EntityDamageEvent::CAUSE_PROJECTILE:
             if ($cause instanceof EntityDamageByEntityEvent) {
                 $e = $cause->getDamager();
                 if ($e instanceof Player) {
                     $message = "death.attack.arrow";
                     $params[] = $e->getDisplayName();
                 } elseif ($e instanceof Living) {
                     $message = "death.attack.arrow";
                     $params[] = $e->getNameTag() !== "" ? $e->getNameTag() : $e->getName();
                     break;
                 } else {
                     $params[] = "Unknown";
                 }
             }
             break;
         case EntityDamageEvent::CAUSE_SUICIDE:
             $message = "death.attack.generic";
             break;
         case EntityDamageEvent::CAUSE_VOID:
             $message = "death.attack.outOfWorld";
             break;
         case EntityDamageEvent::CAUSE_FALL:
             if ($cause instanceof EntityDamageEvent) {
                 if ($cause->getFinalDamage() > 2) {
                     $message = "death.fell.accident.generic";
                     break;
                 }
             }
             $message = "death.attack.fall";
             break;
         case EntityDamageEvent::CAUSE_SUFFOCATION:
             $message = "death.attack.inWall";
             break;
         case EntityDamageEvent::CAUSE_LAVA:
             $message = "death.attack.lava";
             break;
         case EntityDamageEvent::CAUSE_FIRE:
             $message = "death.attack.onFire";
             break;
         case EntityDamageEvent::CAUSE_FIRE_TICK:
             $message = "death.attack.inFire";
             break;
         case EntityDamageEvent::CAUSE_DROWNING:
             $message = "death.attack.drown";
             break;
         case EntityDamageEvent::CAUSE_CONTACT:
             if ($cause instanceof EntityDamageByBlockEvent) {
                 if ($cause->getDamager()->getId() === Block::CACTUS) {
                     $message = "death.attack.cactus";
                 }
             }
             break;
         case EntityDamageEvent::CAUSE_BLOCK_EXPLOSION:
         case EntityDamageEvent::CAUSE_ENTITY_EXPLOSION:
             if ($cause instanceof EntityDamageByEntityEvent) {
                 $e = $cause->getDamager();
                 if ($e instanceof Player) {
                     $message = "death.attack.explosion.player";
                     $params[] = $e->getDisplayName();
                 } elseif ($e instanceof Living) {
                     $message = "death.attack.explosion.player";
                     $params[] = $e->getNameTag() !== "" ? $e->getNameTag() : $e->getName();
                     break;
                 }
             } else {
                 $message = "death.attack.explosion";
             }
             break;
         case EntityDamageEvent::CAUSE_MAGIC:
             $message = "death.attack.magic";
             break;
         case EntityDamageEvent::CAUSE_CUSTOM:
             break;
         default:
     }
//.........這裏部分代碼省略.........
開發者ID:NewDelion,項目名稱:PocketMine-0.13.x,代碼行數:101,代碼來源:Player.php

示例7: removeEntity

 /**
  * Removes the entity from the level index
  *
  * @param Entity $entity
  *
  * @throws \RuntimeException
  */
 public function removeEntity(Entity $entity)
 {
     if ($entity->getLevel() !== $this) {
         throw new \RuntimeException("Invalid Entity level");
     }
     if ($entity instanceof Player) {
         unset($this->players[$entity->getID()]);
         //$this->everyoneSleeping();
     } else {
         $entity->kill();
     }
     if ($this->isChunkLoaded($entity->chunkX, $entity->chunkZ)) {
         $this->getChunkAt($entity->chunkX, $entity->chunkZ, true)->removeEntity($entity);
     }
     unset($this->entities[$entity->getID()]);
 }
開發者ID:boybook,項目名稱:PocketMine-MP,代碼行數:23,代碼來源:Level.php

示例8: kill

 public function kill()
 {
     if ($this->dead === true or $this->spawned === false) {
         return;
     }
     $message = $this->getName() . " died";
     $cause = $this->getLastDamageCause();
     $ev = null;
     if ($cause instanceof EntityDamageEvent) {
         $ev = $cause;
         $cause = $ev->getCause();
     }
     switch ($cause) {
         case EntityDamageEvent::CAUSE_ENTITY_ATTACK:
             if ($ev instanceof EntityDamageByEntityEvent) {
                 $e = $ev->getDamager();
                 if ($e instanceof Player) {
                     $message = $this->getName() . " was killed by " . $e->getName();
                     break;
                 } elseif ($e instanceof Living) {
                     $message = $this->getName() . " was slain by " . $e->getName();
                     break;
                 }
             }
             $message = $this->getName() . " was killed";
             break;
         case EntityDamageEvent::CAUSE_PROJECTILE:
             if ($ev instanceof EntityDamageByEntityEvent) {
                 $e = $ev->getDamager();
                 if ($e instanceof Living) {
                     $message = $this->getName() . " was shot by " . $e->getName();
                     break;
                 }
             }
             $message = $this->getName() . " was shot by arrow";
             break;
         case EntityDamageEvent::CAUSE_SUICIDE:
             $message = $this->getName() . " died";
             break;
         case EntityDamageEvent::CAUSE_VOID:
             $message = $this->getName() . " fell out of the world";
             break;
         case EntityDamageEvent::CAUSE_FALL:
             $message = $this->getName() . " fell from a high place";
             break;
         case EntityDamageEvent::CAUSE_SUFFOCATION:
             $message = $this->getName() . " suffocated in a wall";
             break;
         case EntityDamageEvent::CAUSE_LAVA:
             $message = $this->getName() . " tried to swim in lava";
             break;
         case EntityDamageEvent::CAUSE_FIRE:
             $message = $this->getName() . " went up in flames";
             break;
         case EntityDamageEvent::CAUSE_FIRE_TICK:
             $message = $this->getName() . " burned to death";
             break;
         case EntityDamageEvent::CAUSE_DROWNING:
             $message = $this->getName() . " drowned";
             break;
         case EntityDamageEvent::CAUSE_CONTACT:
             $message = $this->getName() . " was pricked to death";
             break;
         case EntityDamageEvent::CAUSE_BLOCK_EXPLOSION:
         case EntityDamageEvent::CAUSE_ENTITY_EXPLOSION:
             $message = $this->getName() . " blew up";
             break;
         case EntityDamageEvent::CAUSE_MAGIC:
             $message = $this->getName() . " was slain by magic";
             break;
         case EntityDamageEvent::CAUSE_CUSTOM:
             break;
         default:
     }
     if ($this->dead) {
         return;
     }
     Entity::kill();
     $this->server->getPluginManager()->callEvent($ev = new PlayerDeathEvent($this, $this->getDrops(), $message));
     if (!$ev->getKeepInventory()) {
         foreach ($ev->getDrops() as $item) {
             $this->level->dropItem($this, $item);
         }
         if ($this->inventory !== null) {
             $this->inventory->clearAll();
         }
     }
     if ($ev->getDeathMessage() != "") {
         $this->server->broadcast($ev->getDeathMessage(), Server::BROADCAST_CHANNEL_USERS);
     }
     if ($this->server->isHardcore()) {
         $this->setBanned(true);
     } else {
         $pk = new RespawnPacket();
         $pos = $this->getSpawn();
         $pk->x = $pos->x;
         $pk->y = $pos->y;
         $pk->z = $pos->z;
         $this->dataPacket($pk);
     }
//.........這裏部分代碼省略.........
開發者ID:ZenaGamingsky,項目名稱:Steadfast2,代碼行數:101,代碼來源:Player.php

示例9: kill

 public function kill()
 {
     if (!$this->isAlive()) {
         return;
     }
     parent::kill();
     $this->server->getPluginManager()->callEvent($ev = new EntityDeathEvent($this, $this->getDrops()));
     foreach ($ev->getDrops() as $item) {
         $this->getLevel()->dropItem($this, $item);
     }
 }
開發者ID:ianju,項目名稱:PocketMine-MP,代碼行數:11,代碼來源:Living.php

示例10: 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()]);
 }
開發者ID:orlando092,項目名稱:ImagicalMine,代碼行數:23,代碼來源:Level.php

示例11: kill

 public function kill()
 {
     if (!$this->isAlive()) {
         return;
     }
     parent::kill();
     $this->server->getPluginManager()->callEvent($ev = new EntityDeathEvent($this, $this->getDrops()));
     foreach ($ev->getDrops() as $item) {
         $this->getLevel()->dropItem($this, $item);
     }
     if ($this->server->getProperty("experience.enable", true) and $this->server->getProperty("experience.mob-drop", true)) {
         $DropExp = $this->getExperience();
         $vector = new Vector3(ceil($this->x), ceil($this->y), ceil($this->z));
         $this->getLevel()->spawnExperienceOrb($vector, $DropExp);
     }
 }
開發者ID:vellrya,項目名稱:ClearSky,代碼行數:16,代碼來源:Living.php


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