@@ -438,9 +438,24 @@ public abstract static class Delayable extends State {
438
438
439
439
public abstract long endOfDelay (long time , Person person );
440
440
441
+ /**
442
+ * Process any aspect of this state which should only happen once.
443
+ * Because of the nature of Delay states, this state may get called
444
+ * multiple times: once per timestep while delaying. To ensure
445
+ * any actions which are supposed to happen only happen once,
446
+ * this function should be overriden in subclasses.
447
+ *
448
+ * @param person the person being simulated
449
+ * @param time the date within the simulated world
450
+ */
451
+ public void processOnce (Person person , long time ) {
452
+ // do nothing. allow subclasses to override
453
+ }
454
+
441
455
@ Override
442
456
public boolean process (Person person , long time ) {
443
457
if (this .next == null ) {
458
+ this .processOnce (person , time );
444
459
this .next = this .endOfDelay (time , person );
445
460
}
446
461
@@ -1366,7 +1381,7 @@ public long endOfDelay(long time, Person person) {
1366
1381
}
1367
1382
1368
1383
@ Override
1369
- public boolean process (Person person , long time ) {
1384
+ public void processOnce (Person person , long time ) {
1370
1385
String primaryCode = codes .get (0 ).code ;
1371
1386
HealthRecord .Procedure procedure = person .record .procedure (time , primaryCode );
1372
1387
entry = procedure ;
@@ -1406,8 +1421,6 @@ public boolean process(Person person, long time) {
1406
1421
if (assignToAttribute != null ) {
1407
1422
person .attributes .put (assignToAttribute , procedure );
1408
1423
}
1409
-
1410
- return super .process (person , time );
1411
1424
}
1412
1425
}
1413
1426
0 commit comments