1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Stu\Module\Colony\Lib\Gui\Component; |
4
|
|
|
|
5
|
|
|
use Override; |
|
|
|
|
6
|
|
|
use request; |
7
|
|
|
use Stu\Component\Building\BuildingFunctionEnum; |
8
|
|
|
use Stu\Component\Colony\ColonyFunctionManagerInterface; |
9
|
|
|
use Stu\Component\Colony\OrbitShipWrappersRetrieverInterface; |
10
|
|
|
use Stu\Lib\Colony\PlanetFieldHostInterface; |
11
|
|
|
use Stu\Module\Colony\Lib\ColonyLibFactoryInterface; |
12
|
|
|
use Stu\Module\Control\GameControllerInterface; |
13
|
|
|
use Stu\Module\Control\StuTime; |
14
|
|
|
use Stu\Module\Database\View\Category\Wrapper\DatabaseCategoryWrapperFactoryInterface; |
15
|
|
|
use Stu\Orm\Entity\ColonyDepositMiningInterface; |
16
|
|
|
use Stu\Orm\Entity\ColonyInterface; |
17
|
|
|
use Stu\Orm\Repository\TorpedoTypeRepositoryInterface; |
18
|
|
|
|
19
|
|
|
final class ManagementProvider implements PlanetFieldHostComponentInterface |
20
|
|
|
{ |
21
|
1 |
|
public function __construct( |
22
|
|
|
private TorpedoTypeRepositoryInterface $torpedoTypeRepository, |
23
|
|
|
private DatabaseCategoryWrapperFactoryInterface $databaseCategoryWrapperFactory, |
24
|
|
|
private OrbitShipWrappersRetrieverInterface $orbitShipWrappersRetriever, |
25
|
|
|
private ColonyFunctionManagerInterface $colonyFunctionManager, |
26
|
|
|
private ColonyLibFactoryInterface $colonyLibFactory, |
27
|
|
|
private StuTime $stuTime |
28
|
1 |
|
) {} |
29
|
|
|
|
30
|
3 |
|
#[Override] |
31
|
|
|
public function setTemplateVariables( |
32
|
|
|
$entity, |
33
|
|
|
GameControllerInterface $game |
34
|
|
|
): void { |
35
|
|
|
|
36
|
3 |
|
if (!$entity instanceof ColonyInterface) { |
37
|
|
|
return; |
38
|
|
|
} |
39
|
|
|
|
40
|
3 |
|
$systemDatabaseEntry = $entity->getSystem()->getDatabaseEntry(); |
41
|
3 |
|
if ($systemDatabaseEntry !== null) { |
42
|
3 |
|
$starsystem = $this->databaseCategoryWrapperFactory->createDatabaseCategoryEntryWrapper($systemDatabaseEntry, $game->getUser()); |
43
|
3 |
|
$game->setTemplateVar('STARSYSTEM_ENTRY_TAL', $starsystem); |
44
|
|
|
} |
45
|
|
|
|
46
|
3 |
|
$firstOrbitShipWrapper = null; |
47
|
|
|
|
48
|
3 |
|
$targetId = request::indInt('target'); |
49
|
3 |
|
$groups = $this->orbitShipWrappersRetriever->retrieve($entity); |
50
|
|
|
|
51
|
3 |
|
if ($targetId !== 0) { |
52
|
3 |
|
foreach ($groups as $group) { |
53
|
3 |
|
foreach ($group->getWrappers() as $wrapper) { |
54
|
3 |
|
if ($wrapper->get()->getId() === $targetId) { |
55
|
|
|
$firstOrbitShipWrapper = $wrapper; |
56
|
|
|
} |
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
} |
60
|
3 |
|
if ($firstOrbitShipWrapper === null) { |
61
|
3 |
|
$firstGroup = $groups->first(); |
62
|
3 |
|
$firstOrbitShipWrapper = $firstGroup ? $firstGroup->getWrappers()->first() : null; |
63
|
|
|
} |
64
|
|
|
|
65
|
3 |
|
$game->setTemplateVar( |
66
|
3 |
|
'POPULATION_CALCULATOR', |
67
|
3 |
|
$this->colonyLibFactory->createColonyPopulationCalculator($entity) |
68
|
3 |
|
); |
69
|
|
|
|
70
|
3 |
|
$game->setTemplateVar('FIRST_ORBIT_SPACECRAFT', $firstOrbitShipWrapper); |
71
|
|
|
|
72
|
3 |
|
$particlePhalanx = $this->colonyFunctionManager->hasFunction($entity, BuildingFunctionEnum::BUILDING_FUNCTION_PARTICLE_PHALANX); |
73
|
3 |
|
$game->setTemplateVar( |
74
|
3 |
|
'BUILDABLE_TORPEDO_TYPES', |
75
|
3 |
|
$particlePhalanx ? $this->torpedoTypeRepository->getForUser($game->getUser()->getId()) : null |
76
|
3 |
|
); |
77
|
|
|
|
78
|
3 |
|
$shieldingManager = $this->colonyLibFactory->createColonyShieldingManager($entity); |
79
|
3 |
|
$game->setTemplateVar('SHIELDING_MANAGER', $shieldingManager); |
80
|
3 |
|
$game->setTemplateVar('DEPOSIT_MININGS', $this->getUserDepositMinings($entity)); |
81
|
3 |
|
$game->setTemplateVar('VISUAL_PANEL', $this->colonyLibFactory->createColonyScanPanel($entity)); |
82
|
|
|
|
83
|
3 |
|
$timestamp = $this->stuTime->time(); |
84
|
3 |
|
$game->setTemplateVar('COLONY_TIME_HOUR', $entity->getColonyTimeHour($timestamp)); |
85
|
3 |
|
$game->setTemplateVar('COLONY_TIME_MINUTE', $entity->getColonyTimeMinute($timestamp)); |
86
|
3 |
|
$game->setTemplateVar('COLONY_DAY_TIME_PREFIX', $entity->getDayTimePrefix($timestamp)); |
87
|
3 |
|
$game->setTemplateVar('COLONY_DAY_TIME_NAME', $entity->getDayTimeName($timestamp)); |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* @return array<int, array{deposit: ColonyDepositMiningInterface, currentlyMined: int}> |
92
|
|
|
*/ |
93
|
3 |
|
private function getUserDepositMinings(PlanetFieldHostInterface $host): array |
94
|
|
|
{ |
95
|
3 |
|
$production = $this->colonyLibFactory->createColonyCommodityProduction($host)->getProduction(); |
96
|
|
|
|
97
|
3 |
|
$result = []; |
98
|
3 |
|
if (!$host instanceof ColonyInterface) { |
99
|
|
|
return $result; |
100
|
|
|
} |
101
|
|
|
|
102
|
3 |
|
foreach ($host->getDepositMinings() as $deposit) { |
103
|
|
|
if ($deposit->getUser() === $host->getUser()) { |
104
|
|
|
$prod = $production[$deposit->getCommodity()->getId()] ?? null; |
105
|
|
|
|
106
|
|
|
$result[$deposit->getCommodity()->getId()] = [ |
107
|
|
|
'deposit' => $deposit, |
108
|
|
|
'currentlyMined' => $prod === null ? 0 : $prod->getProduction() |
109
|
|
|
]; |
110
|
|
|
} |
111
|
|
|
} |
112
|
|
|
|
113
|
3 |
|
return $result; |
114
|
|
|
} |
115
|
|
|
} |
116
|
|
|
|
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