Pixel-Composer/scripts/node_VFX_group/node_VFX_group.gml

111 lines
2.9 KiB
Text
Raw Normal View History

2023-10-09 16:07:33 +02:00
function VFX_PREVIEW_NODE() {
if(!is_instanceof(group, Node_VFX_Group)) return self;
return group.getPreviewingNode();
}
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 = ds_list_create();
ungroupable = false;
preview_node = noone;
2023-10-10 07:12:42 +02:00
allCached = false;
2023-10-09 16:07:33 +02:00
inputs[| 0] = nodeValue("Loop", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, true )
.rejectArray();
custom_input_index = ds_list_size(inputs);
2022-12-13 09:20:36 +01:00
2023-10-10 07:12:42 +02:00
if(!LOADING && !APPENDING && !CLONING) { #region
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);
2023-11-20 13:21:50 +01:00
output.inputs[| output.input_fix_len + 1].setFrom(input.outputs[| 0]);
2023-10-09 16:07:33 +02:00
preview_node = output;
2023-10-10 07:12:42 +02:00
} #endregion
static getNextNodes = function() { return allCached? getNextNodesExternal() : getNextNodesInternal(); }
insp2UpdateTooltip = "Clear cache";
insp2UpdateIcon = [ THEME.cache, 0, COLORS._main_icon ];
2023-10-09 16:07:33 +02:00
2023-10-10 07:12:42 +02:00
static onInspector2Update = function() { #region
2023-10-09 16:07:33 +02:00
for( var i = 0, n = ds_list_size(nodes); i < n; i++ ) {
var node = nodes[| i];
2023-10-10 07:12:42 +02:00
node.clearCache();
}
} #endregion
static reset = function() { #region
for( var i = 0, n = ds_list_size(nodes); i < n; i++ ) {
var node = nodes[| i];
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++ )
for( var j = 0, m = ds_list_size(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 = ds_list_size(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
}
2023-10-10 07:12:42 +02:00
} #endregion
2023-10-09 16:07:33 +02:00
2023-10-10 07:12:42 +02:00
static update = function() { #region
if(CURRENT_FRAME == 0)
2023-10-09 16:07:33 +02:00
NodeListSort(topoList, nodes);
2023-10-10 07:12:42 +02:00
allCached = true;
for( var i = 0, n = ds_list_size(nodes); i < n; i++ ) {
var node = nodes[| i];
if(!node.recoverCache()) allCached = false;
}
if(!allCached && CURRENT_FRAME == 0)
2023-10-09 16:07:33 +02:00
reset();
2023-10-10 07:12:42 +02:00
if(allCached) {
for( var i = 0, n = ds_list_size(nodes); i < n; i++ )
nodes[| i].setRenderStatus(true);
setRenderStatus(true);
2023-10-09 16:07:33 +02:00
}
2023-10-10 07:12:42 +02:00
} #endregion
2023-03-08 14:59:54 +01:00
2023-10-09 16:07:33 +02:00
static ononDoubleClick = function(panel) { #region
preview_node = noone;
for( var i = 0, n = ds_list_size(nodes); i < n; i++ ) {
var node = nodes[| i];
if(is_instanceof(node, Node_VFX_Renderer_Output) ||
is_instanceof(node, Node_VFX_Renderer)) {
preview_node = node;
break;
}
}
2023-10-10 07:12:42 +02:00
PANEL_PREVIEW.setNodePreview(self);
2023-10-09 16:07:33 +02:00
} #endregion
getPreviewingNode = function() { return preview_node; }
2022-12-13 09:20:36 +01:00
}