1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Stu\Module\Ship\Lib\Movement\Component\Consequence\PostFlight; |
6
|
|
|
|
7
|
|
|
use Stu\Module\Ship\Lib\Message\MessageCollectionInterface; |
8
|
|
|
use Stu\Module\Ship\Lib\Movement\Component\Consequence\AbstractFlightConsequence; |
9
|
|
|
use Stu\Module\Ship\Lib\Movement\Component\FlightSignatureCreatorInterface; |
10
|
|
|
use Stu\Module\Ship\Lib\Movement\Route\FlightRouteInterface; |
11
|
|
|
use Stu\Module\Ship\Lib\Movement\Route\UpdateFlightDirectionInterface; |
12
|
|
|
use Stu\Module\Ship\Lib\ShipWrapperInterface; |
13
|
|
|
|
14
|
|
|
class PostFlightDirectionConsequence extends AbstractFlightConsequence |
15
|
|
|
{ |
16
|
|
|
private FlightSignatureCreatorInterface $flightSignatureCreator; |
17
|
|
|
|
18
|
|
|
private UpdateFlightDirectionInterface $updateFlightDirection; |
19
|
|
|
|
20
|
5 |
|
public function __construct( |
21
|
|
|
FlightSignatureCreatorInterface $flightSignatureCreator, |
22
|
|
|
UpdateFlightDirectionInterface $updateFlightDirection |
23
|
|
|
) { |
24
|
5 |
|
$this->flightSignatureCreator = $flightSignatureCreator; |
25
|
5 |
|
$this->updateFlightDirection = $updateFlightDirection; |
26
|
|
|
} |
27
|
|
|
|
28
|
3 |
|
protected function triggerSpecific( |
29
|
|
|
ShipWrapperInterface $wrapper, |
30
|
|
|
FlightRouteInterface $flightRoute, |
31
|
|
|
MessageCollectionInterface $messages |
32
|
|
|
): void { |
33
|
|
|
|
34
|
3 |
|
$ship = $wrapper->get(); |
35
|
|
|
|
36
|
3 |
|
if ($flightRoute->isTraversing()) { |
37
|
|
|
|
38
|
2 |
|
$oldWaypoint = $flightRoute->getCurrentWaypoint(); |
39
|
2 |
|
$waypoint = $flightRoute->getNextWaypoint(); |
40
|
|
|
|
41
|
2 |
|
$flightDirection = $this->updateFlightDirection->updateWhenTraversing( |
42
|
2 |
|
$oldWaypoint, |
43
|
2 |
|
$waypoint, |
44
|
2 |
|
$ship |
45
|
2 |
|
); |
46
|
|
|
|
47
|
|
|
//create flight signatures |
48
|
2 |
|
if (!$wrapper->get()->isTractored()) { |
49
|
1 |
|
$this->flightSignatureCreator->createSignatures( |
50
|
1 |
|
$ship, |
51
|
1 |
|
$flightDirection, |
52
|
1 |
|
$oldWaypoint, |
53
|
1 |
|
$waypoint, |
54
|
1 |
|
); |
55
|
|
|
} |
56
|
|
|
} |
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
|