Pixel-Composer/scripts/node_rigid_activate/node_rigid_activate.gml

52 lines
1.4 KiB
Plaintext
Raw Normal View History

2023-02-28 09:43:01 +01:00
function Node_Rigid_Activate(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
name = "Activate Physics";
2023-02-14 05:32:32 +01:00
color = COLORS.node_blend_simulation;
icon = THEME.rigidSim;
w = 96;
2023-01-25 06:49:00 +01:00
min_h = 96;
manual_ungroupable = false;
2023-02-14 05:32:32 +01:00
inputs[| 0] = nodeValue("Object", self, JUNCTION_CONNECT.input, VALUE_TYPE.rigid, noone)
2023-01-25 06:49:00 +01:00
.setVisible(true, true);
2023-02-14 05:32:32 +01:00
inputs[| 1] = nodeValue("Physics activated", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, true)
.rejectArray();
2023-01-25 06:49:00 +01:00
2023-02-14 05:32:32 +01:00
outputs[| 0] = nodeValue("Object", self, JUNCTION_CONNECT.output, VALUE_TYPE.rigid, noone);
2023-01-25 06:49:00 +01:00
input_display_list = [
["Object", true], 0,
["Activate", false], 1,
]
2023-10-09 16:07:33 +02:00
static update = function(frame = CURRENT_FRAME) {
var _obj = getInputData(0);
2023-01-25 06:49:00 +01:00
outputs[| 0].setValue(_obj);
2023-02-14 05:32:32 +01:00
RETURN_ON_REST
2023-01-25 06:49:00 +01:00
var _act = getInputData(1);
2023-01-25 06:49:00 +01:00
if(!is_array(_obj)) _obj = [ _obj ];
2023-07-25 20:12:40 +02:00
for( var i = 0, n = array_length(_obj); i < n; i++ ) {
2023-01-25 06:49:00 +01:00
var _o = _obj[i].object;
if(!is_array(_o)) _o = [ _o ];
for( var j = 0; j < array_length(_o); j++ ) {
var obj = _o[j];
if(obj == noone || !instance_exists(obj)) continue;
if(is_undefined(obj.phy_active)) continue;
obj.phy_active = _act;
}
}
}
2023-03-05 07:16:44 +01:00
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {
2023-01-25 06:49:00 +01:00
var bbox = drawGetBbox(xx, yy, _s);
var _act = getInputData(1);
2023-01-25 06:49:00 +01:00
draw_sprite_fit(_act? s_node_rigidSim_activate : s_node_rigidSim_deactivate, 0, bbox.xc, bbox.yc, bbox.w, bbox.h);
}
}