1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Stu\Module\Colony\Lib\Gui\Component; |
4
|
|
|
|
5
|
|
|
use Override; |
|
|
|
|
6
|
|
|
use RuntimeException; |
7
|
|
|
use Stu\Component\Colony\OrbitShipWrappersRetrieverInterface; |
8
|
|
|
use Stu\Lib\Colony\PlanetFieldHostProviderInterface; |
9
|
|
|
use Stu\Module\Colony\Lib\ColonyLibFactoryInterface; |
10
|
|
|
use Stu\Module\Control\GameControllerInterface; |
11
|
|
|
use Stu\Module\Ship\Lib\ShipWrapperInterface; |
12
|
|
|
use Stu\Orm\Entity\ColonyInterface; |
13
|
|
|
use Stu\Orm\Repository\ShipRumpBuildingFunctionRepositoryInterface; |
14
|
|
|
|
15
|
|
|
final class ShipRetrofitProvider implements PlanetFieldHostComponentInterface |
16
|
|
|
{ |
17
|
1 |
|
public function __construct( |
18
|
|
|
private ShipRumpBuildingFunctionRepositoryInterface $shipRumpBuildingFunctionRepository, |
19
|
|
|
private PlanetFieldHostProviderInterface $planetFieldHostProvider, |
20
|
|
|
private ColonyLibFactoryInterface $colonyLibFactory, |
21
|
|
|
private OrbitShipWrappersRetrieverInterface $orbitShipWrappersRetriever |
22
|
1 |
|
) {} |
23
|
|
|
|
24
|
|
|
/** @param ColonyInterface $entity */ |
25
|
1 |
|
#[Override] |
26
|
|
|
public function setTemplateVariables( |
27
|
|
|
$entity, |
28
|
|
|
GameControllerInterface $game |
29
|
|
|
): void { |
30
|
1 |
|
$field = $this->planetFieldHostProvider->loadFieldViaRequestParameter($game->getUser(), false); |
31
|
|
|
|
32
|
1 |
|
$building = $field->getBuilding(); |
33
|
1 |
|
if ($building === null) { |
34
|
|
|
throw new RuntimeException('building is null'); |
35
|
|
|
} |
36
|
|
|
|
37
|
1 |
|
$fieldFunctions = $building->getFunctions()->toArray(); |
38
|
1 |
|
$colonySurface = $this->colonyLibFactory->createColonySurface($entity); |
39
|
|
|
|
40
|
1 |
|
if (!$colonySurface->hasShipyard()) { |
41
|
1 |
|
return; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
$retrofitShipWrappers = []; |
45
|
|
|
$groups = $this->orbitShipWrappersRetriever->retrieve($entity); |
46
|
|
|
|
47
|
|
|
foreach ($groups as $group) { |
48
|
|
|
|
49
|
|
|
/** @var ShipWrapperInterface $wrapper */ |
50
|
|
|
foreach ($group->getWrappers() as $wrapper) { |
51
|
|
|
|
52
|
|
|
$ship = $wrapper->get(); |
53
|
|
|
if ( |
54
|
|
|
!$wrapper->canBeRetrofitted() || $ship->isUnderRetrofit() |
55
|
|
|
) { |
56
|
|
|
continue; |
57
|
|
|
} |
58
|
|
|
foreach ($this->shipRumpBuildingFunctionRepository->getByShipRump($ship->getRump()) as $rump_rel) { |
59
|
|
|
if (array_key_exists($rump_rel->getBuildingFunction()->value, $fieldFunctions)) { |
60
|
|
|
$retrofitShipWrappers[$ship->getId()] = $wrapper; |
61
|
|
|
break; |
62
|
|
|
} |
63
|
|
|
} |
64
|
|
|
} |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
$game->setTemplateVar('RETROFIT_SHIP_WRAPPERS', $retrofitShipWrappers); |
68
|
|
|
$game->setTemplateVar('FIELD', $field); |
69
|
|
|
} |
70
|
|
|
} |
71
|
|
|
|
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