Pixel-Composer/scripts/node_VFX_override/node_VFX_override.gml

92 lines
2.7 KiB
Text
Raw Normal View History

2023-02-28 09:43:01 +01:00
function Node_VFX_Override(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
2023-12-03 05:02:04 +01:00
name = "VFX Override";
2023-02-14 02:48:33 +01:00
color = COLORS.node_blend_vfx;
icon = THEME.vfx;
node_draw_icon = s_node_vfx_override;
2024-05-02 09:48:48 +02:00
manual_ungroupable = false;
2024-05-02 11:05:02 +02:00
setDimension(96, 48);
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);
2024-08-18 06:16:20 +02:00
newInput(1, nodeValue_Float("Positions", self, noone ));
2023-02-14 02:48:33 +01:00
2024-08-18 06:16:20 +02:00
newInput(2, nodeValue_Float("Rotations", self, noone ));
2023-02-14 02:48:33 +01:00
2024-08-18 06:16:20 +02:00
newInput(3, nodeValue_Float("Scales", self, noone ));
2023-02-14 02:48:33 +01:00
2024-08-18 06:16:20 +02:00
newInput(4, nodeValue_Color("Blend", self, noone ));
2023-02-14 02:48:33 +01:00
2024-08-18 06:16:20 +02:00
newInput(5, nodeValue_Float("Alpha", self, noone ));
2023-02-14 02:48:33 +01:00
2024-08-18 09:13:41 +02:00
newInput(6, nodeValue_Surface("Surface", self))
2023-03-13 10:45:56 +01:00
.setVisible(true, false);
2024-09-04 03:57:11 +02:00
newOutput(0, nodeValue_Output("Particles", self, VALUE_TYPE.particle, -1 ));
2023-02-14 02:48:33 +01:00
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 _pos = getInputData(1);
var _sca = getInputData(2);
var _rot = getInputData(3);
var _col = getInputData(4);
var _alp = getInputData(5);
var _srf = getInputData(6);
2023-02-14 02:48:33 +01:00
2023-11-13 07:11:52 +01:00
var nParts = array_create(array_length(parts));
2024-08-08 06:57:51 +02:00
var _a_pos = inputs[1].value_from != noone;
var _a_rot = inputs[2].value_from != noone;
var _a_sca = inputs[3].value_from != noone;
var _a_col = inputs[4].value_from != noone;
var _a_alp = inputs[5].value_from != noone;
var _a_srf = inputs[6].value_from != noone;
2024-05-02 09:48:48 +02:00
if(array_get_depth(_pos) < 2) _pos = [ _pos ];
if(array_get_depth(_sca) < 2) _sca = [ _sca ];
if(!is_array(_rot)) _rot = [ _rot ];
if(!is_array(_col)) _col = [ _col ];
if(!is_array(_alp)) _alp = [ _alp ];
if(!is_array(_srf)) _srf = [ _srf ];
2023-11-13 07:11:52 +01:00
var _l_pos = array_length(_pos);
var _l_sca = array_length(_sca);
var _l_rot = array_length(_rot);
var _l_col = array_length(_col);
var _l_alp = array_length(_alp);
var _l_srf = array_length(_srf);
2023-07-25 20:12:40 +02:00
for( var i = 0, n = array_length(parts); i < n; i++ ) {
2023-11-13 07:11:52 +01:00
var nPart = parts[i].clone();
2023-02-14 02:48:33 +01:00
2024-05-02 09:48:48 +02:00
if(_a_pos) {
nPart.x = _pos[i % _l_pos][0];
nPart.y = _pos[i % _l_pos][1];
2023-02-14 02:48:33 +01:00
}
2024-05-02 09:48:48 +02:00
if(_a_sca) {
nPart.scx = _sca[i % _l_sca][0];
nPart.scy = _sca[i % _l_sca][1];
2023-02-14 02:48:33 +01:00
}
2024-05-02 09:48:48 +02:00
if(_a_rot) nPart.rot = array_safe_get_fast(_rot, i % _l_rot);
if(_a_col) nPart.blend = array_safe_get_fast(_col, i % _l_col);
if(_a_alp) nPart.alp = array_safe_get_fast(_alp, i % _l_alp);
if(_a_srf) nPart.surf = array_safe_get_fast(_srf, i % _l_srf);
2023-03-13 10:45:56 +01:00
2023-11-13 07:11:52 +01:00
nParts[i] = nPart;
2023-02-14 02:48:33 +01:00
}
2024-05-02 09:48:48 +02:00
2024-08-08 06:57:51 +02:00
outputs[0].setValue(nParts);
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
}