All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.mostlyoriginal.api.operation.flow.ParallelOperation Maven / Gradle / Ivy

There is a newer version: 2.5.0
Show newest version
package net.mostlyoriginal.api.operation.flow;

import com.artemis.Entity;
import net.mostlyoriginal.api.operation.common.Operation;
import net.mostlyoriginal.api.operation.common.OperationFlow;

/**
 * Run operations in parallel.
 *
 * @author Daan van Yperen
 */
public class ParallelOperation extends OperationFlow {

	@Override
	public boolean process(float delta, Entity e) {
		if ( isCompleted() ) return true;

		boolean operationsRemain = false;
		for (int i = 0; i < operations.size; i++) {
			if (!e.isActive()) break;
			final Operation operation = operations.get(i);
			if (!operation.process(delta, e)) {
				operationsRemain = true;
			}
		}

		completed = !operationsRemain;

		return completed;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy