134
|
1 package alice.test.topology.aquarium;
|
91
|
2
|
|
3 import alice.codesegment.CodeSegment;
|
|
4 import alice.datasegment.CommandType;
|
|
5 import alice.datasegment.Receiver;
|
|
6
|
|
7
|
111
|
8 public class SetLocation extends CodeSegment{
|
91
|
9
|
97
|
10 private Receiver position = ids.create(CommandType.PEEK);
|
91
|
11 MakeObject obj;
|
105
|
12 String key;
|
114
|
13 String vector;
|
110
|
14 int range;
|
91
|
15
|
127
|
16 public SetLocation(MakeObject obj ,String key,int index,int range){
|
|
17 this.obj = obj;
|
105
|
18 this.key = key;
|
110
|
19 this.range = range;
|
105
|
20 this.position.setKey("local",key,index);
|
91
|
21 }
|
|
22
|
|
23 @Override
|
|
24 public void run(){
|
|
25
|
127
|
26 FishPoint fp = this.position.asClass(FishPoint.class);
|
|
27 //obj.setLocation(fp.getX() - 2*range, fp.getY());
|
114
|
28
|
115
|
29 float startX = 2*range - 1.5f;
|
|
30 float endX = 2*range + 1.5f;
|
127
|
31 if (startX <= fp.getX() && fp.getX() < endX)
|
|
32 obj.setLocation(fp.getX() - 2*range, fp.getY());
|
115
|
33
|
111
|
34 new SetLocation(this.obj,this.key,this.position.index,this.range);
|
110
|
35
|
91
|
36 }
|
|
37
|
|
38
|
|
39 }
|