|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Stu\Component\Spacecraft\Trait; |
|
4
|
|
|
|
|
5
|
|
|
use Stu\Component\Spacecraft\SpacecraftAlertStateEnum; |
|
6
|
|
|
use Stu\Component\Spacecraft\SpacecraftStateEnum; |
|
7
|
|
|
use Stu\Component\Spacecraft\System\SpacecraftSystemTypeEnum; |
|
8
|
|
|
use Stu\Orm\Entity\SpacecraftInterface; |
|
9
|
|
|
|
|
10
|
|
|
trait SpacecraftStateTrait |
|
11
|
|
|
{ |
|
12
|
|
|
use SpacecraftTrait; |
|
13
|
|
|
use SpacecraftSystemExistenceTrait; |
|
14
|
|
|
|
|
15
|
2 |
|
public function isWarped(): bool |
|
16
|
|
|
{ |
|
17
|
2 |
|
return $this->getThis()->getWarpDriveState(); |
|
18
|
|
|
} |
|
19
|
|
|
|
|
20
|
1 |
|
public function isAlertGreen(): bool |
|
21
|
|
|
{ |
|
22
|
1 |
|
return $this->getThis()->getAlertState() === SpacecraftAlertStateEnum::ALERT_GREEN; |
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
|
public function isUnderRepair(): bool |
|
26
|
|
|
{ |
|
27
|
|
|
return $this->getThis()->getState() === SpacecraftStateEnum::REPAIR_ACTIVE |
|
28
|
|
|
|| $this->getThis()->getState() === SpacecraftStateEnum::REPAIR_PASSIVE; |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
public function getHealthPercentage(): float |
|
32
|
|
|
{ |
|
33
|
|
|
$self = $this->getThis(); |
|
34
|
|
|
return ($self->getHull() + $self->getShield()) |
|
35
|
|
|
/ ($self->getMaxHull() + $self->getMaxShield(true)) * 100; |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
1 |
|
public function isTractoring(): bool |
|
39
|
|
|
{ |
|
40
|
1 |
|
return $this->getThis()->getTractoredShip() !== null; |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
1 |
|
public function isWarpPossible(): bool |
|
44
|
|
|
{ |
|
45
|
1 |
|
return $this->hasSpacecraftSystem(SpacecraftSystemTypeEnum::WARPDRIVE) && $this->getSystem() === null; |
|
|
|
|
|
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
public function setAlertStateGreen(): SpacecraftInterface |
|
49
|
|
|
{ |
|
50
|
|
|
return $this->getThis()->setAlertState(SpacecraftAlertStateEnum::ALERT_GREEN); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
1 |
|
public function displayNbsActions(): bool |
|
54
|
|
|
{ |
|
55
|
1 |
|
return !$this->getThis()->isCloaked() |
|
56
|
1 |
|
&& !$this->getThis()->isWarped(); |
|
57
|
|
|
} |
|
58
|
|
|
} |
|
59
|
|
|
|