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


PHP CommandSender::distance方法代码示例

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


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

示例1: checkSelectors

 public static function checkSelectors(array $args, CommandSender $sender, Player $player)
 {
     foreach ($args as $name => $value) {
         switch ($name) {
             case "x":
             case "y":
             case "z":
                 if (isset($args["d" . $name])) {
                     break;
                 }
                 $delta = 0;
                 if ($value[0] === "~" and $sender instanceof Position) {
                     $delta += $player->{$name};
                 }
                 $actual = $sender->{$name};
                 if ((int) $delta !== (int) $actual) {
                     return false;
                 }
                 break;
             case "r":
                 if ($sender instanceof Position) {
                     if ($sender->distance($player) > floatval($value)) {
                         return false;
                     }
                     break;
                 }
                 return false;
             case "rm":
                 if ($sender instanceof Position) {
                     if ($sender->distance($player) < floatval($value)) {
                         return false;
                     }
                     break;
                 }
                 return false;
             case "m":
                 $mode = intval($value);
                 if ($mode === -1) {
                     break;
                     // what is the point of adding this (in PC) when they can just safely leave this out?
                 }
                 if ($mode !== $player->getGamemode()) {
                     return false;
                 }
                 break;
             case "name":
                 if ($value !== $sender->getName()) {
                     return false;
                 }
                 break;
             case "name!":
                 if ($value === $sender->getName()) {
                     return false;
                 }
                 break;
                 // TODO argument "c" (count)
             // TODO argument "c" (count)
             case "rx":
                 if ($player->yaw > floatval($value)) {
                     return false;
                 }
                 break;
             case "rxm":
                 if ($player->yaw < floatval($value)) {
                     return false;
                 }
                 break;
             case "ry":
                 if ($player->pitch > floatval($value)) {
                     return false;
                 }
                 break;
             case "rym":
                 if ($player->pitch < floatval($value)) {
                     return false;
                 }
                 break;
         }
     }
     foreach (["x", "y", "z"] as $v) {
         if (isset($args["d" . $v])) {
             if (isset($args[$v])) {
                 $from = (int) $args[$v];
             } elseif ($sender instanceof Position) {
                 // lower priority
                 $from = $sender->{$v};
             } else {
                 continue;
             }
             $to = (int) $args["d" . $v];
             $actual = $player->{$v};
             if ($from <= $actual and $actual <= $to) {
                 break;
             }
             return false;
         }
     }
     return true;
 }
开发者ID:barnseyminesuk,项目名称:Small-ZC-Plugins,代码行数:99,代码来源:CmdSel.php


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