Pixel-Composer/scripts/node_strand_update/node_strand_update.gml

31 lines
1 KiB
Text
Raw Normal View History

2023-03-19 09:17:39 +01:00
function Node_Strand_Update(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
name = "Strand Update";
color = COLORS.node_blend_strand;
icon = THEME.strandSim;
w = 96;
inputs[| 0] = nodeValue("Strand", self, JUNCTION_CONNECT.input, VALUE_TYPE.strands, noone)
.setVisible(true, true);
inputs[| 1] = nodeValue("Step", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 4)
outputs[| 0] = nodeValue("Strand", self, JUNCTION_CONNECT.output, VALUE_TYPE.strands, noone);
2023-07-06 19:49:16 +02:00
static update = function(frame = PROJECT.animator.current_frame) {
2023-03-19 09:17:39 +01:00
var _str = inputs[| 0].getValue();
var _itr = inputs[| 1].getValue();
if(_str == noone) return;
var __str = _str;
if(!is_array(_str)) __str = [ _str ];
2023-07-25 20:12:40 +02:00
for( var i = 0, n = array_length(__str); i < n; i++ )
2023-03-19 09:17:39 +01:00
__str[i].step(_itr);
outputs[| 0].setValue(_str);
}
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {
var bbox = drawGetBbox(xx, yy, _s);
draw_sprite_fit(s_node_strandSim_update, 0, bbox.xc, bbox.yc, bbox.w, bbox.h);
}
}