|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Stu\Module\Ship\Lib\Auxiliary; |
|
6
|
|
|
|
|
7
|
|
|
use Stu\Component\Ship\ShipStateEnum; |
|
8
|
|
|
use Stu\Component\Ship\System\ShipSystemManagerInterface; |
|
9
|
|
|
use Stu\Module\Ship\Lib\Fleet\LeaveFleetInterface; |
|
10
|
|
|
use Stu\Module\Ship\Lib\Interaction\ShipUndockingInterface; |
|
11
|
|
|
use Stu\Module\Ship\Lib\ShipStateChangerInterface; |
|
12
|
|
|
use Stu\Module\Ship\Lib\ShipWrapperInterface; |
|
13
|
|
|
use Stu\Orm\Repository\ShipRepositoryInterface; |
|
14
|
|
|
|
|
15
|
|
|
final class ShipShutdown implements ShipShutdownInterface |
|
16
|
|
|
{ |
|
17
|
|
|
private ShipRepositoryInterface $shipRepository; |
|
18
|
|
|
|
|
19
|
|
|
private ShipSystemManagerInterface $shipSystemManager; |
|
20
|
|
|
|
|
21
|
|
|
private LeaveFleetInterface $leaveFleet; |
|
22
|
|
|
|
|
23
|
|
|
private ShipStateChangerInterface $shipStateChanger; |
|
24
|
|
|
|
|
25
|
|
|
private ShipUndockingInterface $shipUndocking; |
|
26
|
|
|
|
|
27
|
2 |
|
public function __construct( |
|
28
|
|
|
ShipRepositoryInterface $shipRepository, |
|
29
|
|
|
ShipSystemManagerInterface $shipSystemManager, |
|
30
|
|
|
LeaveFleetInterface $leaveFleet, |
|
31
|
|
|
ShipStateChangerInterface $shipStateChanger, |
|
32
|
|
|
ShipUndockingInterface $shipUndocking |
|
33
|
|
|
) { |
|
34
|
2 |
|
$this->shipRepository = $shipRepository; |
|
35
|
2 |
|
$this->shipSystemManager = $shipSystemManager; |
|
36
|
2 |
|
$this->leaveFleet = $leaveFleet; |
|
37
|
2 |
|
$this->shipStateChanger = $shipStateChanger; |
|
38
|
2 |
|
$this->shipUndocking = $shipUndocking; |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
1 |
|
public function shutdown(ShipWrapperInterface $wrapper): void |
|
42
|
|
|
{ |
|
43
|
1 |
|
$this->shipSystemManager->deactivateAll($wrapper); |
|
44
|
|
|
|
|
45
|
1 |
|
$ship = $wrapper->get(); |
|
46
|
|
|
|
|
47
|
1 |
|
$this->leaveFleet->leaveFleet($ship); |
|
48
|
1 |
|
$this->shipUndocking->undockAllDocked($ship); |
|
49
|
1 |
|
$this->shipStateChanger->changeShipState($wrapper, ShipStateEnum::SHIP_STATE_NONE); |
|
50
|
|
|
|
|
51
|
1 |
|
$ship->setAlertStateGreen(); |
|
52
|
1 |
|
$ship->setDockedTo(null); |
|
53
|
1 |
|
$this->shipRepository->save($ship); |
|
54
|
|
|
} |
|
55
|
|
|
} |
|
56
|
|
|
|