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);
}
};
}
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);
}
};
}
Aggregations