|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Stu\Module\Spacecraft\Lib\Reactor; |
|
4
|
|
|
|
|
5
|
|
|
use Stu\Component\Spacecraft\System\Data\FusionCoreSystemData; |
|
6
|
|
|
use Stu\Component\Spacecraft\System\Data\SingularityCoreSystemData; |
|
7
|
|
|
use Stu\Component\Spacecraft\System\Data\WarpCoreSystemData; |
|
8
|
|
|
use Stu\Component\Spacecraft\System\SpacecraftSystemTypeEnum; |
|
9
|
|
|
use Stu\Module\Spacecraft\Lib\ReactorWrapper; |
|
10
|
|
|
use Stu\Module\Spacecraft\Lib\ReactorWrapperInterface; |
|
11
|
|
|
use Stu\Module\Spacecraft\Lib\SpacecraftWrapper; |
|
12
|
|
|
|
|
13
|
|
|
class ReactorWrapperFactory implements ReactorWrapperFactoryInterface |
|
14
|
|
|
{ |
|
15
|
9 |
|
public function createReactorWrapper(SpacecraftWrapper $wrapper): ?ReactorWrapperInterface |
|
16
|
|
|
{ |
|
17
|
9 |
|
$reactorSystemData = null; |
|
18
|
9 |
|
$spacecraft = $wrapper->get(); |
|
19
|
|
|
|
|
20
|
9 |
|
if ($spacecraft->hasSpacecraftSystem(SpacecraftSystemTypeEnum::WARPCORE)) { |
|
21
|
5 |
|
$reactorSystemData = $wrapper->getSpecificShipSystem( |
|
22
|
5 |
|
SpacecraftSystemTypeEnum::WARPCORE, |
|
23
|
5 |
|
WarpCoreSystemData::class |
|
24
|
5 |
|
); |
|
25
|
|
|
} |
|
26
|
9 |
|
if ($spacecraft->hasSpacecraftSystem(SpacecraftSystemTypeEnum::SINGULARITY_REACTOR)) { |
|
27
|
|
|
$reactorSystemData = $wrapper->getSpecificShipSystem( |
|
28
|
|
|
SpacecraftSystemTypeEnum::SINGULARITY_REACTOR, |
|
29
|
|
|
SingularityCoreSystemData::class |
|
30
|
|
|
); |
|
31
|
|
|
} |
|
32
|
9 |
|
if ($spacecraft->hasSpacecraftSystem(SpacecraftSystemTypeEnum::FUSION_REACTOR)) { |
|
33
|
|
|
$reactorSystemData = $wrapper->getSpecificShipSystem( |
|
34
|
|
|
SpacecraftSystemTypeEnum::FUSION_REACTOR, |
|
35
|
|
|
FusionCoreSystemData::class |
|
36
|
|
|
); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
9 |
|
if ($reactorSystemData === null) { |
|
40
|
6 |
|
return null; |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
5 |
|
return new ReactorWrapper($wrapper, $reactorSystemData); |
|
44
|
|
|
} |
|
45
|
|
|
} |
|
46
|
|
|
|