2023-02-28 09:43:01 +01:00
|
|
|
function Node_Tunnel_Out(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
2023-12-03 05:02:04 +01:00
|
|
|
name = "Tunnel Out";
|
2023-01-25 06:49:00 +01:00
|
|
|
color = COLORS.node_blend_tunnel;
|
2023-12-04 12:09:31 +01:00
|
|
|
is_group_io = true;
|
|
|
|
preview_draw = false;
|
2023-01-25 06:49:00 +01:00
|
|
|
|
|
|
|
w = 96;
|
|
|
|
|
2023-02-14 05:32:32 +01:00
|
|
|
inputs[| 0] = nodeValue("Name", self, JUNCTION_CONNECT.input, VALUE_TYPE.text, "" )
|
2023-12-05 13:49:18 +01:00
|
|
|
.setDisplay(VALUE_DISPLAY.text_tunnel)
|
2023-02-14 05:32:32 +01:00
|
|
|
.rejectArray();
|
2023-01-25 06:49:00 +01:00
|
|
|
|
2023-02-14 05:32:32 +01:00
|
|
|
outputs[| 0] = nodeValue("Value out", self, JUNCTION_CONNECT.output, VALUE_TYPE.any, noone );
|
2023-01-25 06:49:00 +01:00
|
|
|
|
2023-03-05 07:16:44 +01:00
|
|
|
insp2UpdateTooltip = "Goto tunnel in";
|
|
|
|
insp2UpdateIcon = [ THEME.tunnel, 1, c_white ];
|
|
|
|
|
2023-10-27 13:55:31 +02:00
|
|
|
static onInspector2Update = function() { #region
|
2023-10-02 08:57:44 +02:00
|
|
|
var _key = getInputData(0);
|
2023-03-05 07:16:44 +01:00
|
|
|
if(!ds_map_exists(TUNNELS_IN, _key)) return;
|
|
|
|
|
|
|
|
var _node = TUNNELS_IN[? _key].node;
|
|
|
|
graphFocusNode(_node);
|
2023-10-27 13:55:31 +02:00
|
|
|
} #endregion
|
2023-03-05 07:16:44 +01:00
|
|
|
|
2023-10-27 13:55:31 +02:00
|
|
|
static isRenderable = function() { #region
|
2023-10-02 08:57:44 +02:00
|
|
|
var _key = getInputData(0);
|
2023-04-04 13:44:37 +02:00
|
|
|
if(!ds_map_exists(TUNNELS_IN, _key)) return false;
|
|
|
|
|
|
|
|
return TUNNELS_IN[? _key].node.rendered;
|
2023-10-27 13:55:31 +02:00
|
|
|
} #endregion
|
2023-01-25 06:49:00 +01:00
|
|
|
|
2023-10-27 13:55:31 +02:00
|
|
|
static onDrawNodeBehind = function(_x, _y, _mx, _my, _s) { #region
|
2023-01-25 06:49:00 +01:00
|
|
|
var xx = _x + x * _s;
|
|
|
|
var yy = _y + y * _s;
|
|
|
|
|
2023-03-05 07:16:44 +01:00
|
|
|
var hover = PANEL_GRAPH.pHOVER && point_in_rectangle(_mx, _my, xx, yy, xx + w * _s, yy + h * _s);
|
2023-03-12 02:28:21 +01:00
|
|
|
var tun = findPanel("Panel_Tunnels");
|
|
|
|
hover |= tun && tun.tunnel_hover == self;
|
2023-01-25 06:49:00 +01:00
|
|
|
if(!hover) return;
|
|
|
|
|
2023-10-02 08:57:44 +02:00
|
|
|
var _key = getInputData(0);
|
2023-01-25 06:49:00 +01:00
|
|
|
if(!ds_map_exists(TUNNELS_IN, _key)) return;
|
|
|
|
|
|
|
|
var node = TUNNELS_IN[? _key].node;
|
2023-02-14 05:32:32 +01:00
|
|
|
if(node.group != group) return;
|
|
|
|
|
2023-01-25 06:49:00 +01:00
|
|
|
draw_set_color(COLORS.node_blend_tunnel);
|
|
|
|
draw_set_alpha(0.35);
|
2023-03-02 07:59:14 +01:00
|
|
|
var frx = _x + (node.x + node.w / 2) * _s;
|
|
|
|
var fry = _y + (node.y + node.h / 2) * _s;
|
|
|
|
var tox = xx + w * _s / 2;
|
|
|
|
var toy = yy + h * _s / 2;
|
2023-03-05 07:16:44 +01:00
|
|
|
draw_line_dashed(frx, fry, tox, toy, 8 * _s, 16 * _s, current_time / 10);
|
2023-01-25 06:49:00 +01:00
|
|
|
draw_set_alpha(1);
|
2023-10-27 13:55:31 +02:00
|
|
|
} #endregion
|
2023-01-25 06:49:00 +01:00
|
|
|
|
2023-10-27 13:55:31 +02:00
|
|
|
static onValueUpdate = function(index = -1) { #region
|
2023-10-02 08:57:44 +02:00
|
|
|
var _key = getInputData(0);
|
2023-01-25 06:49:00 +01:00
|
|
|
|
|
|
|
TUNNELS_OUT[? node_id] = _key;
|
2023-03-05 07:16:44 +01:00
|
|
|
|
2023-10-07 16:23:40 +02:00
|
|
|
if(index == 0) { RENDER_ALL_REORDER }
|
2023-10-27 13:55:31 +02:00
|
|
|
} #endregion
|
2023-01-25 06:49:00 +01:00
|
|
|
|
2023-10-27 13:55:31 +02:00
|
|
|
static step = function() { #region
|
2023-10-02 08:57:44 +02:00
|
|
|
var _key = getInputData(0);
|
2023-01-25 06:49:00 +01:00
|
|
|
if(ds_map_exists(TUNNELS_IN, _key)) {
|
2023-10-07 16:23:40 +02:00
|
|
|
outputs[| 0].setType(TUNNELS_IN[? _key].type);
|
2023-01-25 06:49:00 +01:00
|
|
|
outputs[| 0].display_type = TUNNELS_IN[? _key].display_type;
|
|
|
|
} else {
|
2023-10-07 16:23:40 +02:00
|
|
|
outputs[| 0].setType(VALUE_TYPE.any);
|
2023-01-25 06:49:00 +01:00
|
|
|
outputs[| 0].display_type = VALUE_DISPLAY._default;
|
|
|
|
}
|
2023-10-27 13:55:31 +02:00
|
|
|
} #endregion
|
2023-01-25 06:49:00 +01:00
|
|
|
|
2023-10-27 13:55:31 +02:00
|
|
|
static update = function(frame = CURRENT_FRAME) { #region
|
2023-10-02 08:57:44 +02:00
|
|
|
var _key = getInputData(0);
|
2023-01-25 06:49:00 +01:00
|
|
|
|
|
|
|
if(ds_map_exists(TUNNELS_IN, _key))
|
|
|
|
outputs[| 0].setValue(TUNNELS_IN[? _key].getValue());
|
2023-10-27 13:55:31 +02:00
|
|
|
} #endregion
|
2023-01-25 06:49:00 +01:00
|
|
|
|
2023-10-27 13:55:31 +02:00
|
|
|
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { #region
|
2023-11-23 08:28:04 +01:00
|
|
|
draw_set_text(f_sdf, fa_center, fa_center, COLORS._main_text);
|
2023-10-02 08:57:44 +02:00
|
|
|
var str = string(getInputData(0));
|
2023-01-25 06:49:00 +01:00
|
|
|
|
|
|
|
var bbox = drawGetBbox(xx, yy, _s);
|
|
|
|
var ss = string_scale(str, bbox.w, bbox.h);
|
|
|
|
draw_text_transformed(bbox.xc, bbox.yc, str, ss, ss, 0);
|
2023-10-27 13:55:31 +02:00
|
|
|
} #endregion
|
2023-02-14 05:32:32 +01:00
|
|
|
|
2023-10-07 16:23:40 +02:00
|
|
|
static onClone = function() { onValueUpdate(0); }
|
|
|
|
|
|
|
|
static postConnect = function() { onValueUpdate(0); }
|
2023-01-25 06:49:00 +01:00
|
|
|
}
|