|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Stu\Lib\Map\VisualPanel; |
|
6
|
|
|
|
|
7
|
|
|
use Stu\Component\Map\EncodedMapInterface; |
|
8
|
|
|
use Stu\Component\Ship\ShipLSSModeEnum; |
|
9
|
|
|
use Stu\Component\Ship\ShipRumpEnum; |
|
10
|
|
|
use Stu\Orm\Entity\LayerInterface; |
|
11
|
|
|
use Stu\Orm\Entity\ShipInterface; |
|
12
|
|
|
|
|
13
|
|
|
class VisualNavPanelEntry extends SignaturePanelEntry |
|
14
|
|
|
{ |
|
15
|
|
|
private ShipInterface $currentShip; |
|
16
|
|
|
|
|
17
|
|
|
private bool $isTachyonSystemActive; |
|
18
|
|
|
|
|
19
|
|
|
private bool $tachyonFresh; |
|
20
|
|
|
|
|
21
|
1 |
|
public function __construct( |
|
22
|
|
|
VisualPanelEntryData $data, |
|
23
|
|
|
?LayerInterface $layer, |
|
24
|
|
|
EncodedMapInterface $encodedMap, |
|
25
|
|
|
ShipInterface $currentShip, |
|
26
|
|
|
bool $isTachyonSystemActive = false, |
|
27
|
|
|
bool $tachyonFresh = false |
|
28
|
|
|
) { |
|
29
|
1 |
|
parent::__construct($data, $layer, $encodedMap); |
|
30
|
1 |
|
$this->currentShip = $currentShip; |
|
31
|
1 |
|
$this->isTachyonSystemActive = $isTachyonSystemActive; |
|
32
|
1 |
|
$this->tachyonFresh = $tachyonFresh; |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
protected function getDisplayCount(): ?string |
|
36
|
|
|
{ |
|
37
|
|
|
if ($this->data->getShipCount() > 0) { |
|
38
|
|
|
return (string) $this->data->getShipCount(); |
|
39
|
|
|
} |
|
40
|
|
|
if ($this->data->hasCloakedShips()) { |
|
41
|
|
|
if ($this->tachyonFresh) { |
|
42
|
|
|
return "?"; |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
if ( |
|
46
|
|
|
$this->isTachyonSystemActive |
|
47
|
|
|
&& abs($this->data->getPosX() - $this->currentShip->getPosX()) < $this->getTachyonRange() |
|
48
|
|
|
&& abs($this->data->getPosY() - $this->currentShip->getPosY()) < $this->getTachyonRange() |
|
49
|
|
|
) { |
|
50
|
|
|
return "?"; |
|
51
|
|
|
} |
|
52
|
|
|
} |
|
53
|
|
|
return null; |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
private function getTachyonRange(): int |
|
57
|
|
|
{ |
|
58
|
|
|
return $this->currentShip->isBase() ? 7 : 3; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
private function isCurrentShipPosition(): bool |
|
62
|
|
|
{ |
|
63
|
|
|
return $this->data->getSystemId() == $this->currentShip->getSystemsId() |
|
64
|
|
|
&& $this->data->getPosX() == $this->currentShip->getPosX() |
|
65
|
|
|
&& $this->data->getPosY() == $this->currentShip->getPosY(); |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
public function getBorder(): string |
|
69
|
|
|
{ |
|
70
|
|
|
// current position gets grey border |
|
71
|
|
|
if ($this->isCurrentShipPosition()) { |
|
72
|
|
|
return '#9b9b9b'; |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
// hierarchy based border style |
|
76
|
|
|
if ( |
|
77
|
|
|
$this->currentShip->getLSSmode() == ShipLSSModeEnum::LSS_BORDER |
|
78
|
|
|
) { |
|
79
|
|
|
$factionColor = $this->data->getFactionColor(); |
|
80
|
|
|
if (!empty($factionColor)) { |
|
81
|
|
|
return $factionColor; |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
$allyColor = $this->data->getAllyColor(); |
|
85
|
|
|
if (!empty($allyColor)) { |
|
86
|
|
|
return $allyColor; |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
$userColor = $this->data->getUserColor(); |
|
90
|
|
|
if (!empty($userColor)) { |
|
91
|
|
|
return $userColor; |
|
92
|
|
|
} |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
// default border style |
|
96
|
|
|
return '#2d2d2d'; |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
public function getCSSClass(): string |
|
100
|
|
|
{ |
|
101
|
|
|
if ($this->isCurrentShipPosition()) { |
|
102
|
|
|
return 'lss_current'; |
|
103
|
|
|
} |
|
104
|
|
|
return parent::getCSSClass(); |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
public function isClickAble(): bool |
|
108
|
|
|
{ |
|
109
|
|
|
if ( |
|
110
|
|
|
$this->currentShip->getRump()->getRoleId() === ShipRumpEnum::SHIP_ROLE_SENSOR |
|
111
|
|
|
|| $this->currentShip->getRump()->getRoleId() === ShipRumpEnum::SHIP_ROLE_BASE |
|
112
|
|
|
) { |
|
113
|
|
|
return true; |
|
114
|
|
|
} |
|
115
|
|
|
if (!$this->currentShip->canMove()) { |
|
116
|
|
|
return false; |
|
117
|
|
|
} |
|
118
|
|
|
return !$this->isCurrentShipPosition(); |
|
119
|
|
|
} |
|
120
|
|
|
|
|
121
|
|
|
public function getOnClick(): string |
|
122
|
|
|
{ |
|
123
|
|
|
if ( |
|
124
|
|
|
$this->currentShip->getRump()->getRoleId() === ShipRumpEnum::SHIP_ROLE_SENSOR |
|
125
|
|
|
|| $this->currentShip->getRump()->getRoleId() === ShipRumpEnum::SHIP_ROLE_BASE |
|
126
|
|
|
) { |
|
127
|
|
|
return sprintf( |
|
128
|
|
|
'showSectorScanWindow(this, %d, %d, %d, %s);', |
|
129
|
|
|
$this->data->getPosX(), |
|
130
|
|
|
$this->data->getPosY(), |
|
131
|
|
|
0, |
|
132
|
|
|
'true' |
|
133
|
|
|
); |
|
134
|
|
|
} |
|
135
|
|
|
return sprintf('moveToPosition(%d,%d);', $this->data->getPosX(), $this->data->getPosY()); |
|
136
|
|
|
} |
|
137
|
|
|
|
|
138
|
|
|
public function isRowIndex(): bool |
|
139
|
|
|
{ |
|
140
|
|
|
return false; |
|
141
|
|
|
} |
|
142
|
|
|
} |
|
143
|
|
|
|