-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMembrane.ulam
43 lines (36 loc) · 1 KB
/
Membrane.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
/**
Membrane atoms can form a 2-layer membrane using 3 bonds:
next prev
--o---------------o--
| other | other
| |
| other | other
--o---------------o--
next prev
The 4th bond is used by agents building and maintaining the membrane
\color #0054d2
\symmetry all
*/
element Membrane : QBondableT(4) + QDiffusableT(20, 2) {
constant Bits cCOLOR_DEFAULT = 0x000054d2;
constant Bits cCOLOR_DEFECT = 0x005428c8;
constant QBond.Index cCOMMON = 0; // BU.cCOMMON
constant QBond.Index cPREV = 1;
constant QBond.Index cOTHER = 2;
constant QBond.Index cNEXT = 3;
@Override Void behave() {
detachBrokenBonds();
diffuse();
}
Bool hasPrevAndNext() {
return getBond(cPREV).isAttached() && getBond(cNEXT).isAttached();
}
@Override ARGB getColor(Unsigned selector) {
ColorUtils cu;
Bits hex = cCOLOR_DEFAULT;
if (!hasPrevAndNext()) {
hex = cCOLOR_DEFECT;
}
return cu.color(hex);
}
}