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

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

package net.mostlyoriginal.api.operation.flow;

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

/**
 * Fire operations one at a time.
 * 

* Calls in order. Will fire at most 1 operation per process. * * @author Daan van Yperen */ public class SequenceOperation extends OperationFlow { int index = 0; public SequenceOperation() { } @Override public boolean process(float delta, Entity e) { if (index < operations.size) { nextOperation(delta, e, operations.get(index)); } if (index >= operations.size) { completed = true; } return completed; } protected void nextOperation(float delta, Entity e, Operation operation) { Preconditions.checkArgument(!operation.isCompleted(), "Operation should never be completed before the first process."); if ( e.isActive() && operation.process(delta, e)) { index++; } } @Override public void rewind() { super.rewind(); index = 0; } @Override public void reset() { super.reset(); index = 0; } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy