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);
|
138
|
11 private MakeObject obj;
|
|
12 private String key;
|
110
|
13 int range;
|
91
|
14
|
127
|
15 public SetLocation(MakeObject obj ,String key,int index,int range){
|
|
16 this.obj = obj;
|
105
|
17 this.key = key;
|
110
|
18 this.range = range;
|
105
|
19 this.position.setKey("local",key,index);
|
91
|
20 }
|
|
21
|
|
22 @Override
|
|
23 public void run(){
|
|
24
|
127
|
25 FishPoint fp = this.position.asClass(FishPoint.class);
|
|
26 //obj.setLocation(fp.getX() - 2*range, fp.getY());
|
114
|
27
|
115
|
28 float startX = 2*range - 1.5f;
|
|
29 float endX = 2*range + 1.5f;
|
127
|
30 if (startX <= fp.getX() && fp.getX() < endX)
|
|
31 obj.setLocation(fp.getX() - 2*range, fp.getY());
|
115
|
32
|
140
|
33 new SetLocation(this.obj, this.key, this.position.index, this.range);
|
110
|
34
|
91
|
35 }
|
|
36
|
|
37
|
|
38 }
|