Skip to content
Daan van Yperen edited this page May 31, 2019 · 1 revision

All platforms

Operations plugin

Per-entity operations DSL to transform components over time. Allows you to run actions in series or parallel. Similar to libGDX actions or artemis-orion. Actions are pooled.

Artifact

  <parent>
        <groupId>net.mostlyoriginal.artemis-odb</groupId>
        <artifactId>contrib-plugin-operations</artifactId>
        <version>2.4.0</version>
    </parent>

Example

  mSchedule.create(entiyId).set(
      sequence(
           delay(milliseconds(500)),
           MyOperationFactory.tintBetween(Color.RED, Color.BLUE, milliseconds(500)),
           deleteFromWorld()
      ));

Usage

  // register the plugin on your world configuration builder.  
  worldConfigurationBuilder.dependsOn(OperationsPlugin.class)

Creating your own operations.

See the BasicOperation hierarchy for examples.

public class MyOperationsFactory {
	public static RemoveOperation remove(Class<? extends Component> componentClass)
	{
		final RemoveOperation operation = Operation.prepare(RemoveOperation.class);
		operation.componentClass = componentClass;
		return operation;
	}
}

public class RemoveOperation extends BasicOperation {

    public Class<? extends Component> componentClass;

    public RemoveOperation() {
    }

    @Override
    public void process(Entity e) {
        e.edit().remove(componentClass);
    }

    @Override
    public void reset() {
        super.reset();
        componentClass = null;
    }
}