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/rogue/world/entity/AiTimer.java

46 lines
916 B

package mightypork.rogue.world.entity;
import java.io.IOException;
import mightypork.gamecore.util.ion.IonBundle;
import mightypork.gamecore.util.ion.IonObjBundled;
import mightypork.gamecore.util.math.timing.TaskRepeater;
public abstract class AiTimer extends TaskRepeater implements IonObjBundled {
public AiTimer(double duration)
{
super(duration);
}
@Override
public abstract void run();
@Override
public void load(IonBundle bundle) throws IOException
{
final boolean wasPaused = bundle.get("paused", isPaused());
if (wasPaused) {
pause();
} else {
resume();
}
setProgress(bundle.get("progress", getProgress()));
setDuration(bundle.get("duration", getDuration()));
}
@Override
public void save(IonBundle bundle) throws IOException
{
bundle.put("paused", isPaused());
bundle.put("progress", getProgress());
bundle.put("duration", getDuration());
}
}