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

47 lines
916 B

package mightypork.rogue.world.entity;
10 years ago
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 {
10 years ago
public AiTimer(double duration)
{
super(duration);
}
@Override
public abstract void run();
10 years ago
@Override
public void load(IonBundle bundle) throws IOException
{
10 years ago
final boolean wasPaused = bundle.get("paused", isPaused());
if (wasPaused) {
pause();
} else {
resume();
}
setProgress(bundle.get("progress", getProgress()));
setDuration(bundle.get("duration", getDuration()));
}
10 years ago
@Override
public void save(IonBundle bundle) throws IOException
{
bundle.put("paused", isPaused());
bundle.put("progress", getProgress());
10 years ago
bundle.put("duration", getDuration());
}
}