391
|
1 package alice.test.topology.aquarium.fx;
|
|
2
|
|
3 import alice.codesegment.CodeSegment;
|
|
4 import alice.datasegment.CommandType;
|
|
5 import alice.datasegment.Receiver;
|
|
6
|
|
7 public class CalculatePosition extends CodeSegment {
|
|
8
|
419
|
9 private Receiver info = ids.create(CommandType.TAKE); // diff fish position value
|
|
10 private Receiver info1 = ids.create(CommandType.TAKE); // absolute fish position value
|
|
11 private Receiver info2 = ids.create(CommandType.PEEK);
|
|
12
|
|
13 public CalculatePosition(String key){
|
|
14 info.setKey(key);
|
|
15 info1.setKey("OwnFishP");
|
|
16 info2.setKey("host");
|
|
17
|
|
18 }
|
|
19
|
|
20 @Override
|
|
21 public void run() {
|
|
22 FishInfo dfp = info.asClass(FishInfo.class);
|
|
23 FishInfo afp = info1.asClass(FishInfo.class);
|
|
24 String myName = info2.asString();
|
|
25
|
|
26 afp.setX(afp.getX() + dfp.getX());
|
|
27 afp.setY(afp.getY() + dfp.getY());
|
|
28 afp.setZ(afp.getZ() + dfp.getZ());
|
|
29 ods.update(info1.key, afp);
|
|
30
|
|
31 FishInfo fishInfo = new FishInfo(afp.getX(),afp.getY(),afp.getZ());
|
|
32 fishInfo.rolX = dfp.rolX;
|
|
33 fishInfo.rolY = dfp.rolY;
|
|
34 fishInfo.rolZ = dfp.rolZ;
|
|
35 fishInfo.rotate = dfp.rotate;
|
|
36 ods.update(myName+"FishabsoluteP", fishInfo);
|
|
37
|
|
38 this.recycle();
|
|
39 }
|
|
40
|
391
|
41
|
|
42 }
|