Pixel-Composer/scripts/node_VFX_variable/node_VFX_variable.gml

90 lines
2.8 KiB
Text
Raw Normal View History

2023-02-28 09:43:01 +01:00
function Node_VFX_Variable(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
2023-12-03 05:02:04 +01:00
name = "VFX Variable";
2023-02-14 02:48:33 +01:00
color = COLORS.node_blend_vfx;
icon = THEME.vfx;
node_draw_icon = s_node_vfx_variable;
2024-05-02 11:05:02 +02:00
setDimension(96, 48);
2023-02-14 02:48:33 +01:00
manual_ungroupable = false;
2023-02-14 02:48:33 +01:00
2024-08-18 09:13:41 +02:00
newInput(0, nodeValue_Particle("Particles", self, -1 ))
2023-02-14 02:48:33 +01:00
.setVisible(true, true);
input_display_list = [ 0 ];
2024-09-04 03:57:11 +02:00
newOutput(0, nodeValue_Output("Positions", self, VALUE_TYPE.float, [] ))
.setDisplay(VALUE_DISPLAY.none)
2023-03-13 10:45:56 +01:00
.setVisible(false);
2023-02-14 02:48:33 +01:00
2024-09-04 03:57:11 +02:00
newOutput(1, nodeValue_Output("Scales", self, VALUE_TYPE.float, [] ))
.setDisplay(VALUE_DISPLAY.none)
2023-03-13 10:45:56 +01:00
.setVisible(false);
2023-02-14 02:48:33 +01:00
2024-09-04 03:57:11 +02:00
newOutput(2, nodeValue_Output("Rotations", self, VALUE_TYPE.float, 0 ))
.setDisplay(VALUE_DISPLAY.none)
2023-03-13 10:45:56 +01:00
.setVisible(false);
2023-02-14 02:48:33 +01:00
2024-09-04 03:57:11 +02:00
newOutput(3, nodeValue_Output("Blending", self, VALUE_TYPE.color, 0 ))
.setDisplay(VALUE_DISPLAY.none)
2023-03-13 10:45:56 +01:00
.setVisible(false);
2023-02-14 02:48:33 +01:00
2024-09-04 03:57:11 +02:00
newOutput(4, nodeValue_Output("Alpha", self, VALUE_TYPE.float, 0 ))
.setDisplay(VALUE_DISPLAY.none)
2023-03-13 10:45:56 +01:00
.setVisible(false);
2023-02-14 02:48:33 +01:00
2024-09-04 03:57:11 +02:00
newOutput(5, nodeValue_Output("Life", self, VALUE_TYPE.float, 0 ))
.setDisplay(VALUE_DISPLAY.none)
2023-03-13 10:45:56 +01:00
.setVisible(false);
2023-02-14 02:48:33 +01:00
2024-09-04 03:57:11 +02:00
newOutput(6, nodeValue_Output("Max life", self, VALUE_TYPE.float, 0 ))
.setDisplay(VALUE_DISPLAY.none)
2023-03-13 10:45:56 +01:00
.setVisible(false);
2024-09-04 03:57:11 +02:00
newOutput(7, nodeValue_Output("Surface", self, VALUE_TYPE.surface, noone ))
.setDisplay(VALUE_DISPLAY.none)
2023-03-13 10:45:56 +01:00
.setVisible(false);
2024-09-04 03:57:11 +02:00
newOutput(8, nodeValue_Output("Velocity", self, VALUE_TYPE.float, [] ))
.setDisplay(VALUE_DISPLAY.none)
2023-03-13 10:45:56 +01:00
.setVisible(false);
2023-02-14 02:48:33 +01:00
2024-09-04 03:57:11 +02:00
newOutput(9, nodeValue_Output("Seed", self, VALUE_TYPE.float, 0 ))
.setDisplay(VALUE_DISPLAY.none)
2023-10-27 15:42:17 +02:00
.setVisible(false);
2023-10-09 16:07:33 +02:00
static update = function(frame = CURRENT_FRAME) {
var parts = getInputData(0);
2023-02-14 02:48:33 +01:00
if(!is_array(parts)) return;
var _val = [];
2024-08-08 06:57:51 +02:00
for( var i = 0; i < array_length(outputs); i++ )
2023-03-13 10:45:56 +01:00
_val[i] = array_create(array_length(parts));
2023-02-14 02:48:33 +01:00
2023-07-25 20:12:40 +02:00
for( var i = 0, n = array_length(parts); i < n; i++ ) {
2023-02-14 02:48:33 +01:00
var part = parts[i];
2024-08-08 06:57:51 +02:00
if(outputs[0].visible) _val[0][i] = [part.x, part.y];
if(outputs[1].visible) _val[1][i] = [part.scx, part.scy];
if(outputs[2].visible) _val[2][i] = part.rot;
if(outputs[3].visible) _val[3][i] = part.blend;
if(outputs[4].visible) _val[4][i] = part.alp;
if(outputs[5].visible) _val[5][i] = part.life;
if(outputs[6].visible) _val[6][i] = part.life_total;
if(outputs[7].visible) _val[7][i] = part.surf;
if(outputs[8].visible) _val[8][i] = [part.speedx, part.speedy];
if(outputs[9].visible) _val[9][i] = part.seed;
2023-02-14 02:48:33 +01:00
}
2024-08-08 06:57:51 +02:00
for( var i = 0; i < array_length(outputs); i++ )
if(outputs[i].visible) outputs[i].setValue(_val[i]);
2023-02-14 02:48:33 +01:00
}
2023-03-05 07:16:44 +01:00
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {
2023-02-14 02:48:33 +01:00
var bbox = drawGetBbox(xx, yy, _s);
draw_sprite_fit(node_draw_icon, 0, bbox.xc, bbox.yc, bbox.w, bbox.h);
}
2023-10-09 16:07:33 +02:00
getPreviewingNode = VFX_PREVIEW_NODE;
2023-02-14 02:48:33 +01:00
}