Pixel-Composer/scripts/node_rigid_activate/node_rigid_activate.gml

47 lines
1.2 KiB
Text
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;
2024-03-28 14:18:02 +01:00
setDimension(96, 96);
2023-01-25 06:49:00 +01:00
manual_ungroupable = false;
2024-08-20 10:15:53 +02:00
newInput(0, nodeValue("Object", self, CONNECT_TYPE.input, VALUE_TYPE.rigid, noone))
2023-01-25 06:49:00 +01:00
.setVisible(true, true);
2024-08-18 09:13:41 +02:00
newInput(1, nodeValue_Bool("Physics activated", self, true))
2023-02-14 05:32:32 +01:00
.rejectArray();
2023-01-25 06:49:00 +01:00
2024-09-04 03:57:11 +02:00
newOutput(0, nodeValue_Output("Object", self, 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);
2024-08-08 06:57:51 +02:00
outputs[0].setValue(_obj);
2023-01-25 06:49:00 +01:00
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
2024-03-22 11:15:22 +01:00
if(!is_array(_obj)) return;
2023-01-25 06:49:00 +01:00
2023-07-25 20:12:40 +02:00
for( var i = 0, n = array_length(_obj); i < n; i++ ) {
2024-03-22 11:15:22 +01:00
var obj = _obj[i];
2023-01-25 06:49:00 +01:00
2024-03-22 11:15:22 +01:00
if(obj == noone || !instance_exists(obj)) continue;
if(is_undefined(obj.phy_active)) continue;
2023-01-25 06:49:00 +01:00
2024-03-22 11:15:22 +01:00
obj.phy_active = _act;
2023-01-25 06:49:00 +01:00
}
}
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);
}
}