1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Stu\Module\Spacecraft\Lib\Movement\Component; |
6
|
|
|
|
7
|
|
|
use InvalidArgumentException; |
8
|
|
|
use Override; |
|
|
|
|
9
|
|
|
use Stu\Component\Spacecraft\System\SpacecraftSystemTypeEnum; |
10
|
|
|
use Stu\Component\Map\DirectionEnum; |
11
|
|
|
use Stu\Module\Control\StuTime; |
12
|
|
|
use Stu\Module\Ship\Lib\ShipLoaderInterface; |
13
|
|
|
use Stu\Orm\Entity\FlightSignature; |
14
|
|
|
use Stu\Orm\Entity\Location; |
15
|
|
|
use Stu\Orm\Entity\Map; |
16
|
|
|
use Stu\Orm\Entity\Spacecraft; |
17
|
|
|
use Stu\Orm\Entity\SpacecraftRump; |
18
|
|
|
use Stu\Orm\Repository\FlightSignatureRepositoryInterface; |
19
|
|
|
use Stu\Orm\Repository\SpacecraftRumpRepositoryInterface; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Creates flight signatures for ship movements |
23
|
|
|
*/ |
24
|
|
|
final class FlightSignatureCreator implements FlightSignatureCreatorInterface |
25
|
|
|
{ |
26
|
11 |
|
public function __construct( |
27
|
|
|
private FlightSignatureRepositoryInterface $flightSignatureRepository, |
28
|
|
|
private StuTime $stuTime, |
29
|
|
|
private ShipLoaderInterface $shipLoader, |
30
|
|
|
private SpacecraftRumpRepositoryInterface $spacecraftRumpRepository |
31
|
11 |
|
) {} |
32
|
|
|
|
33
|
10 |
|
#[Override] |
34
|
|
|
public function createSignatures( |
35
|
|
|
Spacecraft $spacecraft, |
36
|
|
|
DirectionEnum $direction, |
37
|
|
|
Location $currentLocation, |
38
|
|
|
Location $nextLocation |
39
|
|
|
): void { |
40
|
10 |
|
if ($currentLocation instanceof Map !== $nextLocation instanceof Map) { |
41
|
2 |
|
throw new InvalidArgumentException('wayopints have different type'); |
42
|
|
|
} |
43
|
|
|
|
44
|
8 |
|
$fromSignature = $this->createSignature($spacecraft); |
45
|
8 |
|
$fromSignature->setLocation($currentLocation); |
46
|
|
|
|
47
|
8 |
|
$toSignature = $this->createSignature($spacecraft); |
48
|
8 |
|
$toSignature->setLocation($nextLocation); |
49
|
|
|
|
50
|
8 |
|
$this->create( |
51
|
8 |
|
$direction, |
52
|
8 |
|
$fromSignature, |
53
|
8 |
|
$toSignature |
54
|
8 |
|
); |
55
|
|
|
} |
56
|
|
|
|
57
|
8 |
|
private function create( |
58
|
|
|
DirectionEnum $direction, |
59
|
|
|
FlightSignature $fromSignature, |
60
|
|
|
FlightSignature $toSignature |
61
|
|
|
): void { |
62
|
|
|
|
63
|
8 |
|
$fromSignature->setToDirection($direction); |
64
|
8 |
|
$toSignature->setFromDirection($direction->getOpposite()); |
65
|
|
|
|
66
|
8 |
|
$this->flightSignatureRepository->save($fromSignature); |
67
|
8 |
|
$this->flightSignatureRepository->save($toSignature); |
68
|
|
|
} |
69
|
|
|
|
70
|
8 |
|
private function createSignature(Spacecraft $spacecraft): FlightSignature |
71
|
|
|
{ |
72
|
8 |
|
$signature = $this->flightSignatureRepository->prototype(); |
73
|
8 |
|
$signature->setUserId($spacecraft->getUser()->getId()); |
74
|
8 |
|
$signature->setShipId($spacecraft->getId()); |
75
|
8 |
|
$signature->setSpacecraftName($spacecraft->getName()); |
76
|
8 |
|
$signature->setRump($this->getWarpSignature($spacecraft)); |
77
|
8 |
|
$signature->setIsCloaked($spacecraft->isCloaked()); |
78
|
8 |
|
$signature->setTime(time()); |
79
|
|
|
|
80
|
8 |
|
return $signature; |
81
|
|
|
} |
82
|
|
|
|
83
|
8 |
|
private function getWarpSignature(Spacecraft $spacecraft): SpacecraftRump |
84
|
|
|
{ |
85
|
8 |
|
$rump = $spacecraft->getRump(); |
86
|
8 |
|
$wrapper = $this->shipLoader->getWrapperByIdAndUser( |
87
|
8 |
|
$spacecraft->getId(), |
88
|
8 |
|
$spacecraft->getUser()->getId() |
89
|
8 |
|
); |
90
|
8 |
|
$warpsystem = $wrapper->getWarpDriveSystemData(); |
91
|
8 |
|
$system = $spacecraft->getSpacecraftSystem(SpacecraftSystemTypeEnum::WARPDRIVE); |
92
|
8 |
|
if ($system->getMode()->isActivated() && $warpsystem) { |
93
|
|
|
$signaturetime = $warpsystem->getWarpSignatureTimer(); |
94
|
|
|
if ($signaturetime + 300 >= $this->stuTime->time() && $this->spacecraftRumpRepository->find($warpsystem->getWarpSignature())) { |
95
|
|
|
$rump = $this->spacecraftRumpRepository->find($warpsystem->getWarpSignature()); |
96
|
|
|
} |
97
|
|
|
} |
98
|
8 |
|
return $rump; |
99
|
|
|
} |
100
|
|
|
} |
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