package net.mostlyoriginal.api.operation;

import net.mostlyoriginal.api.operation.act.DelayOperation;
import net.mostlyoriginal.api.operation.act.DeleteFromWorldOperation;
import net.mostlyoriginal.api.operation.common.Operation;
import net.mostlyoriginal.api.operation.flow.ParallelOperation;
import net.mostlyoriginal.api.operation.flow.SerialOperation;
import net.mostlyoriginal.api.utils.Preconditions;

/**
 * @author Daan van Yperen
 */
public class OperationFactory {
	private OperationFactory() {}

	public static ParallelOperation parallel( Operation o1 ) {
		final ParallelOperation operation = Operation.prepare(ParallelOperation.class);
		operation.add(o1);
		return operation;
	}

	public static ParallelOperation parallel( Operation o1, Operation o2 ) {
		final ParallelOperation operation = Operation.prepare(ParallelOperation.class);
		operation.addAll(o1, o2);
		return operation;
	}

	public static ParallelOperation parallel( Operation o1, Operation o2, Operation o3 ) {
		final ParallelOperation operation = Operation.prepare(ParallelOperation.class);
		operation.addAll(o1, o2, o3);
		return operation;
	}

	public static ParallelOperation parallel( Operation o1, Operation o2, Operation o3, Operation o4 ) {
		final ParallelOperation operation = Operation.prepare(ParallelOperation.class);
		operation.addAll(o1, o2, o3, o4);
		return operation;
	}

	public static ParallelOperation parallel( Operation o1, Operation o2, Operation o3, Operation o4, Operation o5 ) {
		final ParallelOperation operation = Operation.prepare(ParallelOperation.class);
		operation.addAll(o1, o2, o3, o4, o5);
		return operation;
	}


	public static SerialOperation chain( Operation o1 ) {
		final SerialOperation operation = Operation.prepare(SerialOperation.class);
		operation.add(o1);
		return operation;
	}

	public static SerialOperation chain( Operation o1, Operation o2 ) {
		final SerialOperation operation = Operation.prepare(SerialOperation.class);
		operation.addAll(o1, o2);
		return operation;
	}

	public static SerialOperation chain( Operation o1, Operation o2, Operation o3 ) {
		final SerialOperation operation = Operation.prepare(SerialOperation.class);
		operation.addAll(o1, o2, o3);
		return operation;
	}

	public static SerialOperation chain( Operation o1, Operation o2, Operation o3, Operation o4 ) {
		final SerialOperation operation = Operation.prepare(SerialOperation.class);
		operation.addAll(o1, o2, o3, o4);
		return operation;
	}

	public static SerialOperation chain( Operation o1, Operation o2, Operation o3, Operation o4, Operation o5 ) {
		final SerialOperation operation = Operation.prepare(SerialOperation.class);
		operation.addAll(o1, o2, o3, o4, o5);
		return operation;
	}

	public static Operation deleteFromWorld() {
		return Operation.prepare(DeleteFromWorldOperation.class);
	}

	public static DelayOperation delay( float delay )
	{
		Preconditions.checkArgument(delay >= 0, "Delay must be >= 0.");
		DelayOperation operation = Operation.prepare(DelayOperation.class);
		operation.setDelay(delay);
		return operation;
	}
}

@@ -47,59 +47,131 @@
 ort 
-net.mostlyoriginal.api.operation.act.DelayOperation
+com.artemis.Component;%0Aimport com.badlogic.gdx.math.Interpolation;%0Aimport net.mostlyoriginal.api.component.common.Tweenable
 ;%0Aim
@@ -216,32 +216,9 @@
 act.
-DeleteFromWorldOperation
+*
 ;%0Aim
@@ -3110,11 +3110,1602 @@
 tion;%0A%09%7D
+%0A%0A%09public static AddOperation add(Component component)%0A%09%7B%0A%09%09Preconditions.checkNotNull(component);%0A%09%09AddOperation operation = Operation.prepare(AddOperation.class);%0A%09%09operation.component = component;%0A%09%09return operation;%0A%09%7D%0A%0A%09public static RemoveOperation remove(Class%3C? extends Component%3E componentClass)%0A%09%7B%0A%09%09Preconditions.checkNotNull(componentClass);%0A%09%09RemoveOperation operation = Operation.prepare(RemoveOperation.class);%0A%09%09operation.componentClass = componentClass;%0A%09%09return operation;%0A%09%7D%0A%0A%09/**%0A%09 * Setup linear tween between two component states.%0A%09 *%0A%09 * @param a component a starting state. Tweening does not release pooled components after use.%0A%09 * @param b component b starting state. Tweening does not release pooled components after use.%0A%09 * @param duration duration of tween, in seconds.%0A%09 */%0A%09public static %3CT extends Component & Tweenable%3CT%3E%3E TweenOperation tween(T a, T b, float duration)%0A%09%7B%0A%09%09return tween(a,b,duration,Interpolation.linear);%0A%09%7D%0A%0A%09/**%0A%09 * Setup tween between two component states.%0A%09 *%0A%09 * @param a component a starting state. Tweening does not release pooled components after use.%0A%09 * @param b component b starting state. Tweening does not release pooled components after use.%0A%09 * @param duration duration of tween, in seconds.%0A%09 * @param interpolation method of interpolation.%0A%09 */%0A%09public static %3CT extends Component & Tweenable%3CT%3E%3E TweenOperation tween(T a, T b, float duration, Interpolation interpolation)%0A%09%7B%0A%09%09final TweenOperation operation = Operation.prepare(TweenOperation.class);%0A%09%09operation.setup(a,b,interpolation,duration);%0A%09%09return operation;%0A%09%7D
 %0A%7D%0A

Add tweening to OperationFactory.