1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Stu\Module\Spacecraft\View\ShowSystemSettings; |
6
|
|
|
|
7
|
|
|
use Stu\Component\Spacecraft\System\Data\SubspaceSystemData; |
8
|
|
|
use Stu\Component\Spacecraft\System\SpacecraftSystemTypeEnum; |
9
|
|
|
use Stu\Component\Spacecraft\System\SpacecraftSystemWrapperFactoryInterface; |
10
|
|
|
use Stu\Module\Control\GameControllerInterface; |
|
|
|
|
11
|
|
|
use Stu\Module\Control\StuTime; |
12
|
|
|
use Stu\Module\Spacecraft\Lib\SpacecraftWrapperInterface; |
13
|
|
|
use Stu\Orm\Repository\FlightSignatureRepositoryInterface; |
14
|
|
|
|
15
|
|
|
class SubspaceSensorSystemSettings implements SystemSettingsProviderInterface |
16
|
|
|
{ |
17
|
1 |
|
public function __construct( |
18
|
|
|
private readonly SpacecraftSystemWrapperFactoryInterface $spacecraftSystemWrapperFactory, |
19
|
|
|
private readonly FlightSignatureRepositoryInterface $flightSignatureRepository, |
20
|
|
|
private readonly StuTime $stuTime |
21
|
1 |
|
) {} |
22
|
|
|
|
23
|
|
|
public function setTemplateVariables( |
24
|
|
|
SpacecraftSystemTypeEnum $systemType, |
25
|
|
|
SpacecraftWrapperInterface $wrapper, |
26
|
|
|
GameControllerInterface $game |
27
|
|
|
): void { |
28
|
|
|
$game->setMacroInAjaxWindow('html/spacecraft/system/subspaceScanner.twig'); |
29
|
|
|
|
30
|
|
|
$spacecraft = $wrapper->get(); |
31
|
|
|
|
32
|
|
|
$isSubspaceScannerActive = $spacecraft->getSystemState(SpacecraftSystemTypeEnum::SUBSPACE_SCANNER); |
33
|
|
|
$isMatrixScannerHealthy = $spacecraft->isSystemHealthy(SpacecraftSystemTypeEnum::MATRIX_SCANNER); |
34
|
|
|
|
35
|
|
|
if ($isMatrixScannerHealthy && $isSubspaceScannerActive) { |
36
|
|
|
|
37
|
|
|
$subspaceSystemData = $wrapper->getSubspaceSystemData(); |
38
|
|
|
if ($subspaceSystemData === null) { |
39
|
|
|
return; |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
$time = $this->stuTime->time(); |
43
|
|
|
|
44
|
|
|
$this->setAnalyzedSignature($subspaceSystemData, $game); |
45
|
|
|
$this->setAnalyzeTime($time, $subspaceSystemData, $game); |
46
|
|
|
$this->setSignatures($wrapper, $time, $game); |
47
|
|
|
} else { |
48
|
|
|
$game->setTemplateVar('SYSTEMWARNING', true); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
$game->setTemplateVar('USER', $game->getUser()); |
52
|
|
|
$game->setTemplateVar('SPACECRAFT', $spacecraft); |
53
|
|
|
$game->setTemplateVar( |
54
|
|
|
'systemWrapper', |
55
|
|
|
$this->spacecraftSystemWrapperFactory->create($wrapper->get(), $systemType) |
56
|
|
|
); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
private function setAnalyzedSignature(SubspaceSystemData $subspaceSystemData, GameControllerInterface $game): void |
60
|
|
|
{ |
61
|
|
|
$flightSigId = $subspaceSystemData->getFlightSigId(); |
62
|
|
|
if ($flightSigId) { |
|
|
|
|
63
|
|
|
$flightSig = $this->flightSignatureRepository->find($flightSigId); |
64
|
|
|
$game->setTemplateVar('ANALYZED_SIGNATURE', $flightSig); |
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
private function setAnalyzeTime(int $time, SubspaceSystemData $subspaceSystemData, GameControllerInterface $game): void |
69
|
|
|
{ |
70
|
|
|
$analyzeTime = $subspaceSystemData->getAnalyzeTime(); |
71
|
|
|
if ($analyzeTime) { |
|
|
|
|
72
|
|
|
$currentTime = $time; |
73
|
|
|
$maxTime = $analyzeTime + (10 * 60); |
74
|
|
|
$game->setTemplateVar('ANALYZE_TIME', $analyzeTime); |
75
|
|
|
|
76
|
|
|
if ($currentTime <= $maxTime) { |
77
|
|
|
$game->setTemplateVar('ANALYZE_TIME', $analyzeTime); |
78
|
|
|
} |
79
|
|
|
} |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
private function setSignatures(SpacecraftWrapperInterface $wrapper, int $time, GameControllerInterface $game): void |
83
|
|
|
{ |
84
|
|
|
$spacecraft = $wrapper->get(); |
85
|
|
|
$location = $spacecraft->getLocation(); |
86
|
|
|
|
87
|
|
|
$layerId = $location->getLayer()?->getId(); |
88
|
|
|
if ($layerId === null) { |
89
|
|
|
return; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
$system = $spacecraft->getSystem(); |
93
|
|
|
if ($system) { |
94
|
|
|
$cx = $system->getCx(); |
95
|
|
|
$cy = $system->getCy(); |
96
|
|
|
} else { |
97
|
|
|
$cx = $location->getCx(); |
98
|
|
|
$cy = $location->getCy(); |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
if ($cx && $cy && $layerId) { |
102
|
|
|
|
103
|
|
|
$timeThreshold = $time - (12 * 3600); |
104
|
|
|
$sensorRange = $wrapper->getLssSystemData()?->getSensorRange() ?? 0; |
105
|
|
|
|
106
|
|
|
$signatures = $this->flightSignatureRepository->getSignaturesInSensorRange( |
107
|
|
|
$game->getUser()->getId(), |
108
|
|
|
$cx, |
109
|
|
|
$cy, |
110
|
|
|
$layerId, |
111
|
|
|
$sensorRange, |
112
|
|
|
$timeThreshold |
113
|
|
|
); |
114
|
|
|
$game->setTemplateVar('SIGNATURES', $signatures); |
115
|
|
|
} |
116
|
|
|
} |
117
|
|
|
} |
118
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths