1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Stu\Module\Station\Lib; |
6
|
|
|
|
7
|
|
|
use Stu\Lib\Map\VisualPanel\AbstractVisualPanel; |
8
|
|
|
use Stu\Lib\Map\VisualPanel\VisualPanelEntryData; |
9
|
|
|
use Stu\Lib\Map\VisualPanel\VisualPanelRow; |
10
|
|
|
use Stu\Lib\Map\VisualPanel\VisualPanelRowIndex; |
11
|
|
|
use Stu\Module\Logging\LoggerUtilInterface; |
12
|
|
|
use Stu\Orm\Entity\ShipInterface; |
13
|
|
|
use Stu\Orm\Entity\StarSystemInterface; |
14
|
|
|
use Stu\Orm\Entity\UserInterface; |
15
|
|
|
use Stu\Orm\Repository\ShipRepositoryInterface; |
16
|
|
|
|
17
|
|
|
class SystemScanPanel extends AbstractVisualPanel |
18
|
|
|
{ |
19
|
|
|
private ShipInterface $currentShip; |
20
|
|
|
|
21
|
|
|
private UserInterface $user; |
22
|
|
|
|
23
|
|
|
private StarSystemInterface $system; |
24
|
|
|
|
25
|
|
|
private ShipRepositoryInterface $shipRepository; |
26
|
|
|
|
27
|
|
|
private StationUiFactoryInterface $stationUiFactory; |
28
|
|
|
|
29
|
|
|
public function __construct( |
30
|
|
|
StationUiFactoryInterface $stationUiFactory, |
31
|
|
|
ShipRepositoryInterface $shipRepository, |
32
|
|
|
ShipInterface $currentShip, |
33
|
|
|
StarSystemInterface $system, |
34
|
|
|
UserInterface $user, |
35
|
|
|
LoggerUtilInterface $loggerUtil |
36
|
|
|
) { |
37
|
|
|
parent::__construct($loggerUtil); |
38
|
|
|
|
39
|
|
|
$this->shipRepository = $shipRepository; |
40
|
|
|
$this->currentShip = $currentShip; |
41
|
|
|
$this->system = $system; |
42
|
|
|
$this->user = $user; |
43
|
|
|
$this->stationUiFactory = $stationUiFactory; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @return array<VisualPanelEntryData> |
48
|
|
|
*/ |
49
|
|
|
private function getInnerSystemResult(): iterable |
50
|
|
|
{ |
51
|
|
|
return $this->shipRepository->getSensorResultInnerSystem( |
52
|
|
|
$this->currentShip, |
53
|
|
|
$this->user->getId(), |
54
|
|
|
$this->system |
55
|
|
|
); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
protected function loadLSS(): array |
59
|
|
|
{ |
60
|
|
|
if ($this->loggerUtil->doLog()) { |
61
|
|
|
$startTime = microtime(true); |
|
|
|
|
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
$result = $this->getInnerSystemResult(); |
65
|
|
|
if ($this->loggerUtil->doLog()) { |
66
|
|
|
$endTime = microtime(true); |
|
|
|
|
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
$currentShip = $this->currentShip; |
|
|
|
|
70
|
|
|
|
71
|
|
|
if ($this->loggerUtil->doLog()) { |
72
|
|
|
$startTime = microtime(true); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
$rows = []; |
76
|
|
|
|
77
|
|
|
foreach ($result as $data) { |
78
|
|
|
$y = $data->getPosY(); |
79
|
|
|
|
80
|
|
|
if ($y < 1) { |
81
|
|
|
continue; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
//create new row if y changed |
85
|
|
|
if (!array_key_exists($y, $rows)) { |
86
|
|
|
$navPanelRow = new VisualPanelRow(); |
87
|
|
|
$rowIndex = new VisualPanelRowIndex($y, 'th'); |
88
|
|
|
$navPanelRow->addEntry($rowIndex); |
89
|
|
|
|
90
|
|
|
$rows[$y] = $navPanelRow; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
$navPanelRow = $rows[$y]; |
94
|
|
|
$entry = $this->stationUiFactory->createSystemScanPanelEntry( |
95
|
|
|
$data, |
96
|
|
|
$this->system, |
97
|
|
|
); |
98
|
|
|
$navPanelRow->addEntry($entry); |
99
|
|
|
} |
100
|
|
|
if ($this->loggerUtil->doLog()) { |
101
|
|
|
$endTime = microtime(true); |
102
|
|
|
//$this->loggerUtil->log(sprintf("\tloadLSS-loop, seconds: %F", $endTime - $startTime)); |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
return $rows; |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* @return array<array{value: int}> |
110
|
|
|
*/ |
111
|
|
|
public function getHeadRow(): array |
112
|
|
|
{ |
113
|
|
|
if ($this->headRow === null) { |
114
|
|
|
|
115
|
|
|
$row = []; |
116
|
|
|
|
117
|
|
|
foreach (range(1, $this->system->getMaxX()) as $x) { |
118
|
|
|
$row[]['value'] = $x; |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
$this->headRow = $row; |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
return $this->headRow; |
|
|
|
|
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
protected function getPanelViewportPercentage(): int |
128
|
|
|
{ |
129
|
|
|
return 33; |
130
|
|
|
} |
131
|
|
|
} |
132
|
|
|
|