Pixel-Composer/scripts/node_VFX_group/node_VFX_group.gml

108 lines
2.8 KiB
Text
Raw Normal View History

2024-11-30 12:02:41 +01:00
function VFX_PREVIEW_NODE() { return is(group, Node_VFX_Group)? group.getPreviewingNode() : self; }
function VFX_PREVIEW_SURFACE() { return is(group, Node_VFX_Group)? group.getPreviewValues() : self; }
2023-10-09 16:07:33 +02:00
2023-02-28 09:43:01 +01:00
function Node_VFX_Group(_x, _y, _group = noone) : Node_Collection(_x, _y, _group) constructor {
2022-12-13 09:20:36 +01:00
name = "VFX";
2022-12-16 09:18:09 +01:00
color = COLORS.node_blend_vfx;
2023-02-14 05:32:32 +01:00
icon = THEME.vfx;
2023-10-10 07:12:42 +02:00
update_on_frame = true;
managedRenderOrder = true;
2023-10-09 16:07:33 +02:00
topoList = [];
2023-10-09 16:07:33 +02:00
ungroupable = false;
preview_node = noone;
2023-10-10 07:12:42 +02:00
allCached = false;
2023-10-09 16:07:33 +02:00
2024-08-18 09:13:41 +02:00
newInput(0, nodeValue_Bool("Loop", self, true ))
2023-10-09 16:07:33 +02:00
.rejectArray();
2024-08-08 06:57:51 +02:00
custom_input_index = array_length(inputs);
2022-12-13 09:20:36 +01:00
2024-11-30 12:02:41 +01:00
if(NODE_NEW_MANUAL) {
2022-12-13 09:20:36 +01:00
var input = nodeBuild("Node_VFX_Spawner", -256, -32, self);
2023-10-09 16:07:33 +02:00
var output = nodeBuild("Node_VFX_Renderer_Output", 256 + 32 * 5, -32, self);
2024-08-08 06:57:51 +02:00
output.inputs[output.input_fix_len + 1].setFrom(input.outputs[0]);
2023-10-09 16:07:33 +02:00
preview_node = output;
2024-11-30 12:02:41 +01:00
}
2023-10-10 07:12:42 +02:00
2024-12-07 10:35:29 +01:00
static getNextNodes = function(checkLoop = false) { return allCached? getNextNodesExternal() : getNextNodesInternal(); }
2023-10-10 07:12:42 +02:00
2024-11-26 05:52:57 +01:00
setTrigger(2, "Clear cache", [ THEME.cache, 0, COLORS._main_icon ]);
2023-10-09 16:07:33 +02:00
2024-11-30 12:02:41 +01:00
static onInspector2Update = function() {
for( var i = 0, n = array_length(nodes); i < n; i++ ) {
var node = nodes[i];
2023-10-10 07:12:42 +02:00
node.clearCache();
}
2024-11-30 12:02:41 +01:00
}
2023-10-10 07:12:42 +02:00
2024-11-30 12:02:41 +01:00
static reset = function() {
for( var i = 0, n = array_length(nodes); i < n; i++ ) {
var node = nodes[i];
2023-10-10 07:12:42 +02:00
if(!struct_has(node, "reset")) continue;
node.reset();
2023-10-09 16:07:33 +02:00
}
2022-12-13 09:20:36 +01:00
2023-10-09 16:07:33 +02:00
var loop = getInputData(0);
if(!loop) return;
2024-01-10 08:37:15 +01:00
if(IS_PLAYING)
2023-10-09 16:07:33 +02:00
for( var i = 0; i < TOTAL_FRAMES; i++ )
2024-06-25 11:53:40 +02:00
for( var j = 0, m = array_length(topoList); j < m; j++ ) {
var node = topoList[j];
var _ins = instanceof(node);
if(!string_pos("Node_VFX", _ins))
continue;
if(_ins == "Node_VFX_Renderer" || _ins == "Node_VFX_Renderer_Output")
continue;
2023-10-09 16:07:33 +02:00
2023-10-10 07:12:42 +02:00
node.doUpdate(i);
2023-10-09 16:07:33 +02:00
}
for( var i = 0, n = array_length(nodes); i < n; i++ ) {
var node = nodes[i];
2023-10-10 07:12:42 +02:00
if(!struct_has(node, "resetSeed")) continue;
node.resetSeed();
2023-10-09 16:07:33 +02:00
}
2024-11-30 12:02:41 +01:00
}
2023-10-09 16:07:33 +02:00
2024-11-30 12:02:41 +01:00
static update = function() {
2024-01-19 09:33:37 +01:00
if(IS_FIRST_FRAME)
2024-06-25 11:53:40 +02:00
topoList = NodeListSort(nodes);
2023-10-10 07:12:42 +02:00
allCached = true;
for( var i = 0, n = array_length(nodes); i < n; i++ ) {
var node = nodes[i];
2023-10-10 07:12:42 +02:00
if(!node.recoverCache()) allCached = false;
}
2024-01-19 09:33:37 +01:00
if(!allCached && IS_FIRST_FRAME)
2023-10-09 16:07:33 +02:00
reset();
2023-10-10 07:12:42 +02:00
if(allCached) {
for( var i = 0, n = array_length(nodes); i < n; i++ )
nodes[i].setRenderStatus(true);
2023-10-10 07:12:42 +02:00
setRenderStatus(true);
2023-10-09 16:07:33 +02:00
}
2024-11-30 12:02:41 +01:00
}
2023-03-08 14:59:54 +01:00
2024-11-30 12:02:41 +01:00
static ononDoubleClick = function(panel) {
2023-10-09 16:07:33 +02:00
preview_node = noone;
for( var i = 0, n = array_length(nodes); i < n; i++ ) {
var node = nodes[i];
2024-11-30 12:02:41 +01:00
if(is(node, Node_VFX_Renderer_Output) || is(node, Node_VFX_Renderer)) {
preview_node = node;
break;
}
2023-10-09 16:07:33 +02:00
}
2023-10-10 07:12:42 +02:00
PANEL_PREVIEW.setNodePreview(self);
2024-11-30 12:02:41 +01:00
}
2023-10-09 16:07:33 +02:00
getPreviewingNode = function() { return preview_node; }
2024-11-30 12:02:41 +01:00
getPreviewValues = function() { return preview_node.getPreviewValues(); }
2022-12-13 09:20:36 +01:00
}