-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUpdater.java
More file actions
41 lines (39 loc) · 1.14 KB
/
Copy pathUpdater.java
File metadata and controls
41 lines (39 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
public class Updater extends Thread {
Galaxy galaxy;
public Updater(Galaxy temp) {
galaxy = temp;
}
public void run() {
while(true) {
synchronized(galaxy.planet) {
for (Planet planet : galaxy.planet) {
synchronized(planet.colonies) {
for (Colony colony : planet.colonies) {
synchronized(colony.res) {
for (Resurce resurce : colony.res) {
synchronized(colony.building) {
for (Build build : colony.building) {
if(build.getClass().getSimpleName() == "PowerStation" && resurce.getClass().getSimpleName() == "Electric") {
PowerStation factory = (PowerStation) build;
resurce.count += factory.performance;
}
if(build.getClass().getSimpleName() == "MatterExtractor" && resurce.getClass().getSimpleName() == "Matter") {
MatterExtractor factory = (MatterExtractor) build;
resurce.count += factory.performance;
}
try {
sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
}
}
}
}
}
}
}
}