1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Stu\Orm\Entity; |
6
|
|
|
|
7
|
|
|
use Doctrine\ORM\Mapping\Column; |
8
|
|
|
use Doctrine\ORM\Mapping\Entity; |
9
|
|
|
use Doctrine\ORM\Mapping\GeneratedValue; |
10
|
|
|
use Doctrine\ORM\Mapping\Id; |
11
|
|
|
use Doctrine\ORM\Mapping\Index; |
12
|
|
|
use Doctrine\ORM\Mapping\JoinColumn; |
13
|
|
|
use Doctrine\ORM\Mapping\ManyToOne; |
14
|
|
|
use Doctrine\ORM\Mapping\Table; |
15
|
|
|
use Stu\Lib\Map\Location; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @Entity(repositoryClass="Stu\Orm\Repository\AnomalyRepository") |
19
|
|
|
* @Table( |
20
|
|
|
* name="stu_anomaly", |
21
|
|
|
* indexes={ |
22
|
|
|
* @Index(name="anomaly_to_type_idx", columns={"anomaly_type_id"}), |
23
|
|
|
* @Index(name="anomaly_map_idx", columns={"map_id"}), |
24
|
|
|
* @Index(name="anomaly_starsystem_map_idx", columns={"starsystem_map_id"}) |
25
|
|
|
* } |
26
|
|
|
* ) |
27
|
|
|
**/ |
28
|
|
|
class Anomaly implements AnomalyInterface |
29
|
|
|
{ |
30
|
|
|
/** |
31
|
|
|
* @Id |
32
|
|
|
* @Column(type="integer") |
33
|
|
|
* @GeneratedValue(strategy="IDENTITY") |
34
|
|
|
* |
35
|
|
|
*/ |
36
|
|
|
private int $id; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @Column(type="integer") |
40
|
|
|
* |
41
|
|
|
*/ |
42
|
|
|
private int $remaining_ticks; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @Column(type="integer") |
46
|
|
|
* |
47
|
|
|
*/ |
48
|
|
|
private int $anomaly_type_id; |
|
|
|
|
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @Column(type="integer", nullable=true) * |
52
|
|
|
* |
53
|
|
|
*/ |
54
|
|
|
private ?int $map_id = null; |
|
|
|
|
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @Column(type="integer", nullable=true) * |
58
|
|
|
* |
59
|
|
|
*/ |
60
|
|
|
private ?int $starsystem_map_id = null; |
|
|
|
|
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @ManyToOne(targetEntity="AnomalyType") |
64
|
|
|
* @JoinColumn(name="anomaly_type_id", referencedColumnName="id", onDelete="CASCADE") |
65
|
|
|
*/ |
66
|
|
|
private AnomalyTypeInterface $anomalyType; |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @ManyToOne(targetEntity="Map") |
70
|
|
|
* @JoinColumn(name="map_id", referencedColumnName="id") |
71
|
|
|
*/ |
72
|
|
|
private ?MapInterface $map = null; |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* @ManyToOne(targetEntity="StarSystemMap") |
76
|
|
|
* @JoinColumn(name="starsystem_map_id", referencedColumnName="id") |
77
|
|
|
*/ |
78
|
|
|
private ?StarSystemMapInterface $starsystem_map = null; |
79
|
|
|
|
80
|
|
|
public function getId(): int |
81
|
|
|
{ |
82
|
|
|
return $this->id; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
public function getRemainingTicks(): int |
86
|
|
|
{ |
87
|
|
|
return $this->remaining_ticks; |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
public function setRemainingTicks(int $remainingTicks): AnomalyInterface |
91
|
|
|
{ |
92
|
|
|
$this->remaining_ticks = $remainingTicks; |
93
|
|
|
|
94
|
|
|
return $this; |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
public function isActive(): bool |
98
|
|
|
{ |
99
|
|
|
return $this->getRemainingTicks() > 0; |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
public function getAnomalyType(): AnomalyTypeInterface |
103
|
|
|
{ |
104
|
|
|
return $this->anomalyType; |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
public function setAnomalyType(AnomalyTypeInterface $anomalyType): AnomalyInterface |
108
|
|
|
{ |
109
|
|
|
$this->anomalyType = $anomalyType; |
110
|
|
|
|
111
|
|
|
return $this; |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
public function getMap(): ?MapInterface |
115
|
|
|
{ |
116
|
|
|
return $this->map; |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
public function setMap(?MapInterface $map): AnomalyInterface |
120
|
|
|
{ |
121
|
|
|
$this->map = $map; |
122
|
|
|
|
123
|
|
|
return $this; |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
public function getStarsystemMap(): ?StarSystemMapInterface |
127
|
|
|
{ |
128
|
|
|
return $this->starsystem_map; |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
public function setStarsystemMap(?StarSystemMapInterface $starsystem_map): AnomalyInterface |
132
|
|
|
{ |
133
|
|
|
$this->starsystem_map = $starsystem_map; |
134
|
|
|
|
135
|
|
|
return $this; |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
public function getLocation(): Location |
139
|
|
|
{ |
140
|
|
|
return new Location($this->getMap(), $this->getStarsystemMap()); |
141
|
|
|
} |
142
|
|
|
} |
143
|
|
|
|