Rogue: Savage Rats, a retro-themed dungeon crawler
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
rogue-savage-rats/src/mightypork/utils/math/constraints/num/NumCache.java

37 lines
538 B

package mightypork.utils.math.constraints.num;
public class NumCache extends NumAdapter {
private final NumVar cache = Num.makeVar();
private final Num source;
private boolean inited = false;
public NumCache(Num source) {
this.source = source;
}
@Override
protected Num getSource()
{
if (!inited) poll();
return cache;
}
/**
* Update cached value and cached digest (if digest caching is enabled)
*/
@Override
public void poll()
{
inited = true;
cache.setTo(source);
super.poll();
}
}