本文整理汇总了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;
}