aboutsummaryrefslogtreecommitdiff
path: root/comp2511/blackout/RelaySatellite.java
blob: 1087db84151d5b776598143d2b26deefe2d5a22c (plain)
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package unsw.blackout;

import java.util.Optional;

import unsw.utils.Angle;

public class RelaySatellite extends SatelliteBase {
    public RelaySatellite(String satelliteID, double height, Angle position) {
        super(satelliteID, height, position);
    }

    @ Override
    final public double getVelocity() {
        return 1_500.0;
    }
    @ Override
    final public double getRange() {
        return 300_000.0;
    }

    /**
     * Relay satellites oscillate between 140 and 90 degrees, so we override move to incorporate this behaviour.
     */
    private boolean is_counterclockwise = true;
    @ Override
    final public void move() {
        double current = this.getAngle().toDegrees();
        
        if (current < 140.0 || current > 190.0) {
            if (current > 190.0 && current < 345.0) {
                is_counterclockwise = false;
            } else {
                is_counterclockwise = true;
            }
        }

        double offset = this.getMoveOffsetRadians();
        double rposition = (this.getAngle().toRadians() + (is_counterclockwise ? offset : -offset)) % Math.toRadians(360.0);
        setAngle(Angle.fromRadians(rposition + (rposition < 0 ? Math.toRadians(360.0) : 0)));
    }

    @ Override
    final protected boolean isSupportedDeviceType(String type) {
        return true; // Supports all devices!
    }
    @ Override 
    final protected boolean canRelay() {
        return true;
    }
    @ Override
    final protected Optional<Integer> getFileStoreLimit() {
        return Optional.of(0); // Cannot store any files!
    }
    @ Override
    final protected Optional<Integer> getByteStoreLimit() {
        return Optional.of(0); // Cannot store any bytes!
    }
    @ Override
    final protected Optional<Integer> getByteDownloadSpeed() {
        return Optional.empty(); // Infinite download speed
    }
    @ Override
    final protected Optional<Integer> getByteUploadSpeed() {
        return Optional.empty(); // Infinite upload speed.
    }
}