-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathAgentComputeExample.php
More file actions
35 lines (27 loc) · 1.13 KB
/
Copy pathAgentComputeExample.php
File metadata and controls
35 lines (27 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
declare(strict_types=1);
namespace imperazim\easylibrary\examples\agent;
use imperazim\agent\api\AgentComputeAPI;
use imperazim\agent\api\AgentRuntimeAPI;
use imperazim\agent\constant\AgentComputeMethods;
use imperazim\agent\event\AgentComputeResultEvent;
use pocketmine\event\Listener;
final class AgentComputeExample implements Listener{
public function checkRegionsIntersect() : int{
if(!AgentRuntimeAPI::isAvailable()){
return 0;
}
$response = AgentComputeAPI::runAsync(AgentComputeMethods::REGION_INTERSECTS, [
'a' => ['min_x' => 0, 'min_y' => 0, 'min_z' => 0, 'max_x' => 10, 'max_y' => 10, 'max_z' => 10],
'b' => ['min_x' => 5, 'min_y' => 0, 'min_z' => 5, 'max_x' => 15, 'max_y' => 10, 'max_z' => 15],
], 5);
return (int) ($response['task_id'] ?? 0);
}
public function onComputeResult(AgentComputeResultEvent $event) : void{
if($event->getMethod() !== AgentComputeMethods::REGION_INTERSECTS){
return;
}
$result = $event->getResult();
// Example result contains intersection information from the Agent.
}
}