2022-12-13 09:20:36 +01:00
|
|
|
function Node_Group_Output(_x, _y, _group = -1) : Node(_x, _y, _group) constructor {
|
2022-01-13 05:24:03 +01:00
|
|
|
name = "Output";
|
2023-02-14 05:32:32 +01:00
|
|
|
destroy_when_upgroup = true;
|
2022-12-10 05:06:01 +01:00
|
|
|
color = COLORS.node_blend_collection;
|
2022-01-13 05:24:03 +01:00
|
|
|
previewable = false;
|
|
|
|
auto_height = false;
|
|
|
|
|
|
|
|
w = 96;
|
2022-01-16 05:17:35 +01:00
|
|
|
h = 32 + 24;
|
|
|
|
min_h = h;
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-02-14 05:32:32 +01:00
|
|
|
inputs[| 0] = nodeValue("Value", self, JUNCTION_CONNECT.input, VALUE_TYPE.any, -1)
|
2022-01-19 06:11:17 +01:00
|
|
|
.setVisible(true, true);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-02-14 05:32:32 +01:00
|
|
|
inputs[| 1] = nodeValue("Order", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0)
|
|
|
|
.rejectArray();
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2022-01-18 05:31:19 +01:00
|
|
|
outParent = undefined;
|
|
|
|
output_index = -1;
|
|
|
|
|
2023-02-14 05:32:32 +01:00
|
|
|
static onValueUpdate = function(index = 0) {
|
2022-01-18 05:31:19 +01:00
|
|
|
if(is_undefined(outParent)) return;
|
|
|
|
|
|
|
|
group.sortIO();
|
|
|
|
}
|
|
|
|
|
2022-12-16 09:18:09 +01:00
|
|
|
static getNextNodes = function() {
|
2022-12-21 02:30:23 +01:00
|
|
|
if(is_undefined(outParent)) return;
|
2022-12-16 09:18:09 +01:00
|
|
|
group.setRenderStatus(true);
|
2022-12-21 02:30:23 +01:00
|
|
|
//printIf(global.RENDER_LOG, "Value to amount " + string(ds_list_size(outParent.value_to)));
|
2022-12-16 09:18:09 +01:00
|
|
|
|
|
|
|
for(var j = 0; j < ds_list_size(outParent.value_to); j++) {
|
|
|
|
var _to = outParent.value_to[| j];
|
|
|
|
printIf(global.RENDER_LOG, "Value to " + _to.name);
|
|
|
|
|
|
|
|
if(!_to.node.active || _to.value_from == noone) {
|
|
|
|
printIf(global.RENDER_LOG, "no value from");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(_to.value_from.node != group) {
|
|
|
|
printIf(global.RENDER_LOG, "value from not equal group");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
printIf(global.RENDER_LOG, "Group output ready " + string(_to.node.isUpdateReady()));
|
|
|
|
|
|
|
|
if(_to.node.isUpdateReady()) {
|
2023-01-25 06:49:00 +01:00
|
|
|
ds_queue_enqueue(RENDER_QUEUE, _to.node);
|
2022-12-16 09:18:09 +01:00
|
|
|
printIf(global.RENDER_LOG, "Push node " + _to.node.name + " to stack");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-19 03:05:13 +01:00
|
|
|
static createOutput = function(override_order = true) {
|
2022-01-18 05:31:19 +01:00
|
|
|
if(group && is_struct(group)) {
|
|
|
|
if(override_order) {
|
|
|
|
output_index = ds_list_size(group.outputs);
|
|
|
|
inputs[| 1].setValue(output_index);
|
|
|
|
} else {
|
|
|
|
output_index = inputs[| 1].getValue();
|
|
|
|
}
|
|
|
|
|
2023-02-14 05:32:32 +01:00
|
|
|
if(!is_undefined(outParent))
|
|
|
|
ds_list_remove(group.outputs, outParent);
|
|
|
|
|
|
|
|
outParent = nodeValue("Value", group, JUNCTION_CONNECT.output, VALUE_TYPE.any, -1)
|
2022-01-19 03:05:13 +01:00
|
|
|
.setVisible(true, true);
|
2022-01-18 05:31:19 +01:00
|
|
|
outParent.from = self;
|
2022-01-19 03:05:13 +01:00
|
|
|
|
2022-01-18 05:31:19 +01:00
|
|
|
ds_list_add(group.outputs, outParent);
|
|
|
|
group.setHeight();
|
|
|
|
group.sortIO();
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2022-01-18 05:31:19 +01:00
|
|
|
outParent.setFrom(inputs[| 0]);
|
|
|
|
}
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
2022-01-19 06:11:17 +01:00
|
|
|
|
2022-01-13 05:24:03 +01:00
|
|
|
if(!LOADING && !APPENDING)
|
|
|
|
createOutput();
|
|
|
|
|
2022-01-18 05:31:19 +01:00
|
|
|
static step = function() {
|
|
|
|
if(is_undefined(outParent)) return;
|
|
|
|
|
2023-02-14 05:32:32 +01:00
|
|
|
outParent.name = display_name;
|
2022-01-25 10:58:11 +01:00
|
|
|
|
2022-12-10 05:06:01 +01:00
|
|
|
inputs[| 0].type = VALUE_TYPE.any;
|
|
|
|
if(inputs[| 0].value_from != noone) {
|
|
|
|
inputs[| 0].type = inputs[| 0].value_from.type;
|
|
|
|
inputs[| 0].display_type = inputs[| 0].value_from.display_type;
|
|
|
|
}
|
|
|
|
|
2022-01-25 10:58:11 +01:00
|
|
|
outParent.type = inputs[| 0].type;
|
2022-12-10 05:06:01 +01:00
|
|
|
outParent.display_type = inputs[| 0].display_type;
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
2022-12-10 05:06:01 +01:00
|
|
|
|
|
|
|
static triggerRender = function() {
|
2022-01-18 05:31:19 +01:00
|
|
|
if(is_undefined(outParent)) return;
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2022-01-18 05:31:19 +01:00
|
|
|
for(var j = 0; j < ds_list_size(outParent.value_to); j++) {
|
2022-12-10 05:06:01 +01:00
|
|
|
if(outParent.value_to[| j].value_from == outParent)
|
|
|
|
outParent.value_to[| j].node.triggerRender();
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-18 05:31:19 +01:00
|
|
|
static postDeserialize = function() {
|
|
|
|
createOutput(false);
|
2023-02-14 05:32:32 +01:00
|
|
|
|
|
|
|
var _inputs = load_map[? "inputs"];
|
|
|
|
inputs[| 1].applyDeserialize(_inputs[| 1], load_scale);
|
|
|
|
group.sortIO();
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
|
2022-01-19 03:05:13 +01:00
|
|
|
static onDestroy = function() {
|
2022-01-18 05:31:19 +01:00
|
|
|
if(is_undefined(outParent)) return;
|
|
|
|
ds_list_delete(group.outputs, ds_list_find_index(group.outputs, outParent));
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
2023-02-14 05:32:32 +01:00
|
|
|
|
|
|
|
static ungroup = function() {
|
|
|
|
var fr = inputs[| 0].value_from;
|
|
|
|
|
|
|
|
for( var i = 0; i < ds_list_size(outParent.value_to); i++ ) {
|
|
|
|
var to = outParent.value_to[| i];
|
|
|
|
if(to.value_from != outParent) continue;
|
|
|
|
|
|
|
|
to.setFrom(fr);
|
|
|
|
}
|
|
|
|
}
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|