2023-02-28 09:43:01 +01:00
|
|
|
function Node_Rigid_Override(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
2023-12-03 05:02:04 +01:00
|
|
|
name = "Rigidbody Override";
|
2023-02-14 02:48:33 +01:00
|
|
|
color = COLORS.node_blend_simulation;
|
|
|
|
icon = THEME.rigidSim;
|
|
|
|
node_draw_icon = s_node_rigid_override;
|
|
|
|
|
2023-12-22 08:42:02 +01: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-20 10:15:53 +02:00
|
|
|
newInput(0, nodeValue("Object", self, CONNECT_TYPE.input, VALUE_TYPE.rigid, noone ))
|
2023-02-14 02:48:33 +01:00
|
|
|
.setVisible(true, true);
|
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(1, nodeValue_Vec2("Positions", self, [0, 0] ));
|
2023-02-14 02:48:33 +01:00
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(2, nodeValue_Vec2("Scales", self, [0, 0] ));
|
2023-02-14 02:48:33 +01:00
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(3, nodeValue_Float("Rotations", self, 0 ));
|
2023-02-14 02:48:33 +01:00
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(4, nodeValue_Color("Blends", self, 0 ));
|
2023-02-14 02:48:33 +01:00
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(5, nodeValue_Float("Alpha", self, 0 ));
|
2023-02-14 02:48:33 +01:00
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(6, nodeValue_Vec2("Velocity", self, [0, 0] ));
|
2023-02-14 02:48:33 +01:00
|
|
|
|
2024-08-08 06:57:51 +02:00
|
|
|
outputs[0] = nodeValue_Output("Object", self, VALUE_TYPE.rigid, noone );
|
2023-02-14 02:48:33 +01:00
|
|
|
|
2023-10-09 16:07:33 +02:00
|
|
|
static update = function(frame = CURRENT_FRAME) {
|
2024-03-22 11:15:22 +01:00
|
|
|
var objs = getInputData(0);
|
2024-08-08 06:57:51 +02:00
|
|
|
outputs[0].setValue(objs);
|
2023-02-14 02:48:33 +01:00
|
|
|
|
2023-10-02 08:57:44 +02:00
|
|
|
var _pos = getInputData(1);
|
|
|
|
var _sca = getInputData(2);
|
|
|
|
var _rot = getInputData(3);
|
|
|
|
var _col = getInputData(4);
|
|
|
|
var _alp = getInputData(5);
|
|
|
|
var _vel = getInputData(6);
|
2023-02-14 02:48:33 +01:00
|
|
|
|
2023-07-25 20:12:40 +02:00
|
|
|
for( var i = 0, n = array_length(objs); i < n; i++ ) {
|
2023-02-14 02:48:33 +01:00
|
|
|
var obj = objs[i];
|
|
|
|
if(obj == noone || !instance_exists(obj)) continue;
|
|
|
|
if(is_undefined(obj.phy_active)) continue;
|
|
|
|
|
2023-10-09 07:36:20 +02:00
|
|
|
if(is_array(_pos) && array_length(_pos)) {
|
|
|
|
if(is_array(_pos[0])) {
|
|
|
|
obj.x = _pos[i][0];
|
|
|
|
obj.y = _pos[i][1];
|
|
|
|
} else {
|
|
|
|
obj.x = _pos[0];
|
|
|
|
obj.y = _pos[1];
|
|
|
|
}
|
2023-02-14 02:48:33 +01:00
|
|
|
}
|
|
|
|
|
2023-10-09 07:36:20 +02:00
|
|
|
if(is_array(_sca) && array_length(_sca)) {
|
|
|
|
if(is_array(_sca[0])) {
|
|
|
|
obj.xscale = _sca[i][0];
|
|
|
|
obj.yscale = _sca[i][1];
|
|
|
|
} else {
|
|
|
|
obj.xscale = _sca[0];
|
|
|
|
obj.yscale = _sca[1];
|
|
|
|
}
|
2023-02-14 02:48:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if(is_array(_rot) && array_length(_rot) > i)
|
2023-04-10 20:02:59 +02:00
|
|
|
obj.image_angle = _rot[i];
|
2023-02-14 02:48:33 +01:00
|
|
|
|
|
|
|
if(is_array(_col) && array_length(_col) > i)
|
|
|
|
obj.image_blend = _col[i];
|
|
|
|
|
|
|
|
if(is_array(_alp) && array_length(_alp) > i)
|
|
|
|
obj.image_alpha = _alp[i];
|
|
|
|
|
|
|
|
if(is_array(_vel) && array_length(_vel) > i && is_array(_vel[i])) {
|
|
|
|
obj.phy_linear_velocity_x = _vel[i][0];
|
|
|
|
obj.phy_linear_velocity_y = _vel[i][1];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|