-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDemoAttach.ulam
48 lines (39 loc) · 1.07 KB
/
DemoAttach.ulam
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
local typedef EventWindow.SiteNum SiteNum;
/**
Attach package to membrane (test)
\symbol DA
\color #caf7b7
*/
element DemoAttach : QMortal {
@Override Void behave() {
AtomUtils au;
BondStatus bs;
BondUtils bu;
EventWindow ew;
MDist mdist;
// What the maximum bond distance?
Package pkg;
Membrane membrane;
Unsigned dist = bu.maxDist(pkg, membrane);
// Find package (at distance 2)
WindowServices ws;
ws.reset(1, 2);
if (!ws.scan(au.getType(pkg)))
return;
SiteNum packageSite = ws.getPick();
C2D packageCoord = ew.getCoordRaw(packageSite);
for (Int s = 1; s <= mdist.getLastIndex((MDist.Radius) ew.getRadius()); s++) {
SiteNum site = (SiteNum) s;
// Is it a membrane?
if (!(ew[site] is Membrane))
continue;
// Is it close enough to bond?
C2D coord = ew.getCoordRaw(site);
if (packageCoord.manhattanDistance(coord) > dist)
continue;
if (bs.isOk(bu.attach(packageSite, Package.cCOMMON, site, Membrane.cCOMMON)))
break;
}
die();
}
}