summaryrefslogtreecommitdiff
path: root/NET/worlds/console/CameraConveyor.java
blob: c2094dbcf0911e9a1ec483379352909c6f07f927 (plain) (blame)
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/*     */ 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;
/*     */   
/*     */   public CameraConveyor() {}
/*     */   
/*     */   public CameraConveyor(Point3Temp direction, float speed)
/*     */   {
/*  46 */     this.vector = new Point3(direction.normalize().times(speed));
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public CameraConveyor(Point3Temp v)
/*     */   {
/*  55 */     this.vector = new Point3(v);
/*     */   }
/*     */   
/*     */   public boolean handle(FrameEvent e) {
/*  59 */     if (e.dt == 0)
/*  60 */       return true;
/*  61 */     Enumeration<WObject> stuff = e.receiver.getContents();
/*     */     
/*  63 */     Point3Temp delta = Point3Temp.make(this.vector);
/*  64 */     delta.times(e.dt / 1000.0F);
/*     */     
/*  66 */     while (stuff.hasMoreElements()) {
/*  67 */       WObject thing = (WObject)stuff.nextElement();
/*  68 */       if ((thing instanceof Pilot)) {
/*  69 */         thing.moveThrough(delta);
/*     */       }
/*     */     }
/*  72 */     return true;
/*     */   }
/*     */   
/*  75 */   private static Object classCookie = new Object();
/*     */   
/*     */   public void saveState(Saver s) throws IOException
/*     */   {
/*  79 */     s.saveVersion(1, classCookie);
/*  80 */     super.saveState(s);
/*  81 */     s.save(this.vector);
/*     */   }
/*     */   
/*     */   public void restoreState(Restorer r) throws IOException, TooNewException
/*     */   {
/*  86 */     switch (r.restoreVersion(classCookie)) {
/*     */     case 1: 
/*  88 */       super.restoreState(r);
/*     */     case 0: 
/*  90 */       this.vector = ((Point3)r.restore());
/*  91 */       break;
/*     */     default: 
/*  93 */       throw new TooNewException();
/*     */     }
/*     */     
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */   public Object properties(int index, int offset, int mode, Object value)
/*     */     throws NoSuchPropertyException
/*     */   {
/* 103 */     Object ret = null;
/*     */     
/* 105 */     switch (index - offset) {
/*     */     case 0: 
/* 107 */       if (mode == 0) {
/* 108 */         ret = new Property(this, index, "Velocity");
/* 109 */       } else if (mode == 1)
/* 110 */         ret = this.vector;
/* 111 */       break;
/*     */     default: 
/* 113 */       ret = super.properties(index, offset + 1, mode, value);
/*     */     }
/*     */     
/* 116 */     return ret;
/*     */   }
/*     */ }


/* Location:              C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\console\CameraConveyor.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */