summaryrefslogtreecommitdiff
path: root/NET/worlds/console/CameraConveyor.java
diff options
context:
space:
mode:
authorFuwn <[email protected]>2026-02-12 22:33:32 -0800
committerFuwn <[email protected]>2026-02-12 22:33:32 -0800
commitc7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9 (patch)
treedf9f48bf128a6c0186a8e91857d6ff30fe0e9f18 /NET/worlds/console/CameraConveyor.java
downloadworldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.tar.xz
worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.zip
Initial commit
Diffstat (limited to 'NET/worlds/console/CameraConveyor.java')
-rw-r--r--NET/worlds/console/CameraConveyor.java90
1 files changed, 90 insertions, 0 deletions
diff --git a/NET/worlds/console/CameraConveyor.java b/NET/worlds/console/CameraConveyor.java
new file mode 100644
index 0000000..c271e80
--- /dev/null
+++ b/NET/worlds/console/CameraConveyor.java
@@ -0,0 +1,90 @@
+package NET.worlds.console;
+
+import NET.worlds.scape.FrameEvent;
+import NET.worlds.scape.FrameHandler;
+import NET.worlds.scape.NoSuchPropertyException;
+import NET.worlds.scape.Pilot;
+import NET.worlds.scape.Point3;
+import NET.worlds.scape.Point3Temp;
+import NET.worlds.scape.Property;
+import NET.worlds.scape.Restorer;
+import NET.worlds.scape.Saver;
+import NET.worlds.scape.SuperRoot;
+import NET.worlds.scape.TooNewException;
+import NET.worlds.scape.WObject;
+import java.io.IOException;
+import java.util.Enumeration;
+
+public class CameraConveyor extends SuperRoot implements FrameHandler {
+ private Point3 vector;
+ private static Object classCookie = new Object();
+
+ public CameraConveyor() {
+ }
+
+ public CameraConveyor(Point3Temp direction, float speed) {
+ this.vector = new Point3(direction.normalize().times(speed));
+ }
+
+ public CameraConveyor(Point3Temp v) {
+ this.vector = new Point3(v);
+ }
+
+ @Override
+ public boolean handle(FrameEvent e) {
+ if (e.dt == 0) {
+ return true;
+ } else {
+ Enumeration<WObject> stuff = (Enumeration<WObject>)e.receiver.getContents();
+ Point3Temp delta = Point3Temp.make(this.vector);
+ delta.times(e.dt / 1000.0F);
+
+ while (stuff.hasMoreElements()) {
+ WObject thing = stuff.nextElement();
+ if (thing instanceof Pilot) {
+ thing.moveThrough(delta);
+ }
+ }
+
+ return true;
+ }
+ }
+
+ @Override
+ public void saveState(Saver s) throws IOException {
+ s.saveVersion(1, classCookie);
+ super.saveState(s);
+ s.save(this.vector);
+ }
+
+ @Override
+ public void restoreState(Restorer r) throws IOException, TooNewException {
+ switch (r.restoreVersion(classCookie)) {
+ case 1:
+ super.restoreState(r);
+ case 0:
+ this.vector = (Point3)r.restore();
+ return;
+ default:
+ throw new TooNewException();
+ }
+ }
+
+ @Override
+ public Object properties(int index, int offset, int mode, Object value) throws NoSuchPropertyException {
+ Object ret = null;
+ switch (index - offset) {
+ case 0:
+ if (mode == 0) {
+ ret = new Property(this, index, "Velocity");
+ } else if (mode == 1) {
+ ret = this.vector;
+ }
+ break;
+ default:
+ ret = super.properties(index, offset + 1, mode, value);
+ }
+
+ return ret;
+ }
+}