Pixel-Composer/scripts/node_iterate/node_iterate.gml

52 lines
1.1 KiB
Plaintext
Raw Normal View History

2022-12-12 09:08:03 +01:00
enum ITERATION_STATUS {
not_ready,
loop,
complete,
}
2022-01-23 04:08:16 +01:00
function Node_create_Iterate(_x, _y) {
var node = new Node_Iterate(_x, _y);
ds_list_add(PANEL_GRAPH.nodes_list, node);
return node;
}
function Node_Iterate(_x, _y) : Node_Collection(_x, _y) constructor {
name = "Loop";
2022-11-18 03:20:31 +01:00
color = COLORS.node_blend_loop;
icon = THEME.loop;
2022-01-23 04:08:16 +01:00
iterated = 0;
inputs[| 0] = nodeValue( 0, "Repeat", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 1 );
custom_input_index = 1;
2022-01-25 10:58:11 +01:00
loop_start_time = 0;
2022-01-23 04:08:16 +01:00
2022-12-12 09:08:03 +01:00
static postSetRenderStatus = function(result) {
if(rendered) return;
iterated = 0;
loop_start_time = get_timer();
2022-01-23 04:08:16 +01:00
}
2022-12-12 09:08:03 +01:00
static iterationStatus = function() {
2022-01-23 04:08:16 +01:00
var iter = true;
for( var i = 0; i < ds_list_size(outputs); i++ ) {
var _out = outputs[| i].node;
iter &= _out.rendered;
}
if(iter) {
2022-01-25 10:58:11 +01:00
if(++iterated == inputs[| 0].getValue()) {
render_time = get_timer() - loop_start_time;
2022-12-12 09:08:03 +01:00
return ITERATION_STATUS.complete;
2022-01-25 10:58:11 +01:00
} else if(iterated > inputs[| 0].getValue())
2022-12-12 09:08:03 +01:00
return ITERATION_STATUS.complete;
2022-01-23 04:08:16 +01:00
resetRenderStatus();
2022-12-12 09:08:03 +01:00
return ITERATION_STATUS.loop;
2022-01-23 04:08:16 +01:00
}
2022-12-12 09:08:03 +01:00
return ITERATION_STATUS.not_ready;
2022-01-23 04:08:16 +01:00
}
}