|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Stu\Component\Spacecraft\Trait; |
|
4
|
|
|
|
|
5
|
|
|
use Stu\Orm\Entity\ColonyInterface; |
|
6
|
|
|
use Stu\Orm\Entity\LayerInterface; |
|
7
|
|
|
use Stu\Orm\Entity\MapInterface; |
|
8
|
|
|
use Stu\Orm\Entity\MapRegionInterface; |
|
9
|
|
|
use Stu\Orm\Entity\StarSystemInterface; |
|
10
|
|
|
use Stu\Orm\Entity\StarSystemMapInterface; |
|
11
|
|
|
|
|
12
|
|
|
trait SpacecraftLocationTrait |
|
13
|
|
|
{ |
|
14
|
|
|
use SpacecraftTrait; |
|
15
|
|
|
|
|
16
|
5 |
|
public function getPosX(): int |
|
17
|
|
|
{ |
|
18
|
5 |
|
return $this->getThis()->getLocation()->getX(); |
|
19
|
|
|
} |
|
20
|
|
|
|
|
21
|
5 |
|
public function getPosY(): int |
|
22
|
|
|
{ |
|
23
|
5 |
|
return $this->getThis()->getLocation()->getY(); |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
8 |
|
public function getMap(): ?MapInterface |
|
27
|
|
|
{ |
|
28
|
8 |
|
$location = $this->getThis()->getLocation(); |
|
29
|
|
|
|
|
30
|
8 |
|
if ($location instanceof MapInterface) { |
|
31
|
6 |
|
return $location; |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
2 |
|
return $location->getSystem()->getMap(); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
9 |
|
public function getStarsystemMap(): ?StarSystemMapInterface |
|
38
|
|
|
{ |
|
39
|
9 |
|
if ($this->getThis()->getLocation() instanceof StarSystemMapInterface) { |
|
40
|
5 |
|
return $this->getThis()->getLocation(); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
6 |
|
return null; |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
3 |
|
public function getLayer(): ?LayerInterface |
|
47
|
|
|
{ |
|
48
|
3 |
|
return $this->getThis()->getLocation()->getLayer(); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
2 |
|
public function getMapRegion(): ?MapRegionInterface |
|
52
|
|
|
{ |
|
53
|
2 |
|
$systemMap = $this->getStarsystemMap(); |
|
54
|
2 |
|
if ($systemMap !== null) { |
|
55
|
|
|
return null; |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
2 |
|
$map = $this->getMap(); |
|
59
|
2 |
|
if ($map === null) { |
|
60
|
|
|
return null; |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
2 |
|
return $map->getMapRegion(); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
public function isOverColony(): ?ColonyInterface |
|
67
|
|
|
{ |
|
68
|
|
|
return $this->getStarsystemMap() !== null ? $this->getStarsystemMap()->getColony() : null; |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
2 |
|
public function isOverSystem(): ?StarSystemInterface |
|
72
|
|
|
{ |
|
73
|
2 |
|
$location = $this->getThis()->getLocation(); |
|
74
|
2 |
|
if ($location instanceof StarSystemMapInterface) { |
|
75
|
|
|
return null; |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
2 |
|
return $location->getSystem(); |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
6 |
|
public function getSystem(): ?StarSystemInterface |
|
82
|
|
|
{ |
|
83
|
6 |
|
return $this->getStarsystemMap() !== null ? $this->getStarsystemMap()->getSystem() : null; |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
4 |
|
public function getSectorString(): string |
|
87
|
|
|
{ |
|
88
|
4 |
|
return $this->getThis()->getLocation()->getSectorString(); |
|
89
|
|
|
} |
|
90
|
|
|
} |
|
91
|
|
|
|