electrodynamics/electrical/src/main/scala/resonantinduction/electrical/armbot/task/TaskIdle.java

108 lines
2.2 KiB
Java
Raw Normal View History

2014-01-11 10:44:07 +01:00
package resonantinduction.electrical.armbot.task;
2014-01-08 15:18:24 +01:00
import java.util.List;
import net.minecraft.nbt.NBTTagCompound;
2014-02-13 05:42:56 +01:00
import resonantinduction.core.ArgumentData;
2014-01-10 09:00:46 +01:00
import resonantinduction.electrical.armbot.TaskBaseProcess;
2014-01-11 06:59:55 +01:00
import resonantinduction.electrical.encoder.coding.IProgrammableMachine;
import calclavia.lib.science.units.UnitHelper;
2014-01-08 15:18:24 +01:00
public class TaskIdle extends TaskBaseProcess
{
/** The amount of time in which the machine will idle. */
public int idleTime = 80;
private int totalIdleTime = 80;
public TaskIdle()
{
super("wait");
this.args.add(new ArgumentData("idleTime", 20));
}
@Override
public ProcessReturn onMethodCalled()
{
if (super.onMethodCalled() == ProcessReturn.CONTINUE)
{
if (UnitHelper.tryToParseInt(this.getArg("idleTime")) > 0)
{
this.totalIdleTime = this.idleTime = UnitHelper.tryToParseInt(this.getArg("idleTime"));
return ProcessReturn.CONTINUE;
}
return ProcessReturn.ARGUMENT_ERROR;
}
return ProcessReturn.GENERAL_ERROR;
}
@Override
public ProcessReturn onUpdate()
{
if (this.idleTime > 0)
{
this.idleTime--;
return ProcessReturn.CONTINUE;
}
return ProcessReturn.DONE;
}
@Override
public void load(NBTTagCompound taskCompound)
{
super.load(taskCompound);
this.totalIdleTime = taskCompound.getInteger("idleTotal");
}
@Override
public void save(NBTTagCompound taskCompound)
{
super.save(taskCompound);
taskCompound.setInteger("idleTotal", this.totalIdleTime);
}
@Override
public TaskBaseProcess loadProgress(NBTTagCompound taskCompound)
{
super.loadProgress(taskCompound);
this.idleTime = taskCompound.getInteger("idleTime");
return this;
}
@Override
public NBTTagCompound saveProgress(NBTTagCompound taskCompound)
{
super.saveProgress(taskCompound);
taskCompound.setInteger("idleTime", this.idleTime);
return taskCompound;
}
@Override
public String toString()
{
return super.toString() + " " + Integer.toString(this.totalIdleTime);
}
@Override
public TaskBaseProcess clone()
{
return new TaskIdle();
}
@Override
public boolean canUseTask(IProgrammableMachine device)
{
return true;
}
@Override
public void getToolTips(List<String> list)
{
super.getToolTips(list);
list.add(" Wait: " + this.totalIdleTime);
}
}