Search in sources :

Example 1 with AbstractPipelineNode

use of com.gempukku.libgdx.graph.pipeline.producer.node.AbstractPipelineNode in project gdx-graph by MarcinSc.

the class MultiplyPipelineNodeProducer method createNode.

@Override
public PipelineNode createNode(JsonValue data, ObjectMap<String, Array<String>> inputTypes, ObjectMap<String, String> outputTypes) {
    final String resultType = outputTypes.get("output");
    final Object resultValue = createDefaultValue(resultType);
    final ObjectMap<String, PipelineNode.FieldOutput<?>> result = new ObjectMap<>();
    final DefaultFieldOutput resultOutput = new DefaultFieldOutput(resultType);
    result.put("output", resultOutput);
    return new AbstractPipelineNode(result) {

        private Array<FieldOutput<?>> inputs;

        @Override
        public void setInputs(ObjectMap<String, Array<FieldOutput<?>>> inputs) {
            this.inputs = inputs.get("inputs");
        }

        @Override
        public void executeNode(PipelineRenderingContext pipelineRenderingContext, PipelineRequirementsCallback pipelineRequirementsCallback) {
            Object returnValue = resetDefaultValue(resultType, resultValue);
            for (FieldOutput<?> input : inputs) {
                Object value = input.getValue();
                returnValue = multiply(returnValue, value);
            }
            resultOutput.setValue(returnValue);
        }
    };
}
Also used : Array(com.badlogic.gdx.utils.Array) AbstractPipelineNode(com.gempukku.libgdx.graph.pipeline.producer.node.AbstractPipelineNode) ObjectMap(com.badlogic.gdx.utils.ObjectMap) DefaultFieldOutput(com.gempukku.libgdx.graph.pipeline.producer.node.DefaultFieldOutput) PipelineRenderingContext(com.gempukku.libgdx.graph.pipeline.producer.PipelineRenderingContext) DefaultFieldOutput(com.gempukku.libgdx.graph.pipeline.producer.node.DefaultFieldOutput)

Example 2 with AbstractPipelineNode

use of com.gempukku.libgdx.graph.pipeline.producer.node.AbstractPipelineNode in project gdx-graph by MarcinSc.

the class AddPipelineNodeProducer method createNode.

@Override
public PipelineNode createNode(JsonValue data, ObjectMap<String, Array<String>> inputTypes, ObjectMap<String, String> outputTypes) {
    final String resultType = outputTypes.get("output");
    final Object resultValue = createDefaultValue(resultType);
    final ObjectMap<String, PipelineNode.FieldOutput<?>> result = new ObjectMap<>();
    final DefaultFieldOutput resultOutput = new DefaultFieldOutput(resultType);
    result.put("output", resultOutput);
    return new AbstractPipelineNode(result) {

        private Array<FieldOutput<?>> inputs;

        @Override
        public void setInputs(ObjectMap<String, Array<FieldOutput<?>>> inputs) {
            this.inputs = inputs.get("inputs");
        }

        @Override
        public void executeNode(PipelineRenderingContext pipelineRenderingContext, PipelineRequirementsCallback pipelineRequirementsCallback) {
            Object returnValue = resetDefaultValue(resultType, resultValue);
            for (FieldOutput<?> input : inputs) {
                Object value = input.getValue();
                returnValue = add(returnValue, value);
            }
            resultOutput.setValue(returnValue);
        }
    };
}
Also used : Array(com.badlogic.gdx.utils.Array) AbstractPipelineNode(com.gempukku.libgdx.graph.pipeline.producer.node.AbstractPipelineNode) ObjectMap(com.badlogic.gdx.utils.ObjectMap) DefaultFieldOutput(com.gempukku.libgdx.graph.pipeline.producer.node.DefaultFieldOutput) PipelineRenderingContext(com.gempukku.libgdx.graph.pipeline.producer.PipelineRenderingContext) DefaultFieldOutput(com.gempukku.libgdx.graph.pipeline.producer.node.DefaultFieldOutput)

Aggregations

Array (com.badlogic.gdx.utils.Array)2 ObjectMap (com.badlogic.gdx.utils.ObjectMap)2 PipelineRenderingContext (com.gempukku.libgdx.graph.pipeline.producer.PipelineRenderingContext)2 AbstractPipelineNode (com.gempukku.libgdx.graph.pipeline.producer.node.AbstractPipelineNode)2 DefaultFieldOutput (com.gempukku.libgdx.graph.pipeline.producer.node.DefaultFieldOutput)2