package ncrashed.warp.cores.actions;

import ncrashed.warp.ModHelper;
import ncrashed.warp.api.ICoreAction;
import ncrashed.warp.api.ICoreStructure;
import ncrashed.warp.api.IWarpCore;

public class GetMFSUEnergy implements ICoreAction {

	@Override
	public int getRequiredEnergy(IWarpCore core, int multCounter, int north,
			int south, int west, int east, int up, int down) 
	{
		return 0;
	}

	@Override
	public boolean performAction(IWarpCore core, int multCounter, int north,
			int south, int west, int east, int up, int down) 
	{
		ICoreStructure structure = core.getCoreStructure();
		int value = ModHelper.ic2GetEnergy(core.getCoreWorld(), 
				core.getCoreX() + structure.getStorageX() - structure.getCoreX(), 
				core.getCoreY() + structure.getStorageY() - structure.getCoreY(), 
				core.getCoreZ() + structure.getStorageZ() - structure.getCoreZ()
				);

		structure.setExpander(core.getCoreWorld(), core.getCoreX(), core.getCoreY(), core.getCoreZ(), 0, value & 65535);
		structure.setExpander(core.getCoreWorld(), core.getCoreX(), core.getCoreY(), core.getCoreZ(), 1, value >> 16);
		core.restartCheckingTickers();
		return true;
	}

	@Override
	public int getLowMultCounter() 
	{
		return 28;
	}

	@Override
	public int getHighMultCounter() 
	{
		return 28;
	}

	@Override
	public int getSuccessCooldown(IWarpCore core, int multCounter, int north,
			int south, int west, int east, int up, int down) 
	{
		return 1;
	}

	@Override
	public int getFailCooldown(IWarpCore core, int multCounter, int north,
			int south, int west, int east, int up, int down)
	{
		return 1;
	}

	@Override
	public int getMinimumCooldown(IWarpCore core, int multCounter, int north,
			int south, int west, int east, int up, int down) 
	{
		return 0;
	}

	@Override
	public boolean printActionResult() 
	{
		return false;
	}

	@Override
	public int getErrorBit() 
	{
		return 0;
	}

}
