From e97770f86035630e3b211aa56a0f6bace82318e9 Mon Sep 17 00:00:00 2001 From: Khalid Ali Date: Wed, 16 Sep 2020 18:45:12 -0400 Subject: [PATCH] Skeleton setup + Tuple Impl --- .../RadiationDetector.java | 89 +++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 Plugin Radioactive Cloud/src/main/java/net/simon987/pluginradioactivecloud/RadiationDetector.java diff --git a/Plugin Radioactive Cloud/src/main/java/net/simon987/pluginradioactivecloud/RadiationDetector.java b/Plugin Radioactive Cloud/src/main/java/net/simon987/pluginradioactivecloud/RadiationDetector.java new file mode 100644 index 0000000..a3ca753 --- /dev/null +++ b/Plugin Radioactive Cloud/src/main/java/net/simon987/pluginradioactivecloud/RadiationDetector.java @@ -0,0 +1,89 @@ +package net.simon987.pluginradioactivecloud; + +import java.util.HashSet; + +import org.bson.Document; +import net.simon987.server.assembly.HardwareModule; +import net.simon987.server.assembly.Status; +import net.simon987.server.game.objects.ControllableUnit; + +public class RadiationDetector extends HardwareModule { + + // Need to change to whatever the last unique address is + public static final int DEFAULT_ADDRESS = 0x010F; + + /** + * Hardware ID (Should be unique) -- NEEDS TO BE CHANGED + */ + public static final char HWID = 0x010F; + + /** + * Radiation detected by cubot + */ + private double currentRadiation = 0; + + /** + * Helper class for getTiles + */ + private class Tuple { + public final int x; + public final int y; + + public Tuple(int x, int y) { + this.x = x; + this.y = y; + } + + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + + if (!(o instanceof Tuple)) { + return false; + } + + Tuple t = (Tuple) o; + + return Integer.compare(x, t.x) == 0 && Integer.compare(y, t.y) == 0; + } + } + + /** + * Find tiles between two given tiles. + */ + private HashSet getTiles(int x0, int y0, int x1, int y1) { + + HashSet ret = new HashSet<>(); + double slope = (y1 - y0) / (double) (x1 - x0); + + return ret; + } + + public RadiationDetector(ControllableUnit unit) { + super(null, unit); + + // Set default values + currentRadiation = 0; + } + + public RadiationDetector(Document document, ControllableUnit cubot) { + super(document, cubot); + + // Set default values + currentRadiation = 0; + } + + @Override + public void handleInterrupt(Status status) { + + // Fill in + } + + @Override + public char getId() { + return HWID; + } + +}