From 23c185fdd810b376fc19348a78653c2cab97c2d1 Mon Sep 17 00:00:00 2001 From: Tanasart Date: Sun, 23 Jun 2024 12:30:42 +0700 Subject: [PATCH] aray awerning --- .../_node_VFX_spawner/_node_VFX_spawner.gml | 10 ++++---- scripts/node_data/node_data.gml | 5 ++-- scripts/node_particle/node_particle.gml | 2 ++ scripts/node_string_join/node_string_join.gml | 1 + .../node_surface_data/node_surface_data.gml | 1 + scripts/node_value/node_value.gml | 25 +++---------------- 6 files changed, 15 insertions(+), 29 deletions(-) diff --git a/scripts/_node_VFX_spawner/_node_VFX_spawner.gml b/scripts/_node_VFX_spawner/_node_VFX_spawner.gml index 402e5cfc5..b090e62e8 100644 --- a/scripts/_node_VFX_spawner/_node_VFX_spawner.gml +++ b/scripts/_node_VFX_spawner/_node_VFX_spawner.gml @@ -4,8 +4,7 @@ function Node_VFX_Spawner_Base(_x, _y, _group = noone) : Node(_x, _y, _group) co inputs[| 0] = nodeValue("Particle sprite", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone ); - inputs[| 1] = nodeValue("Spawn delay", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 4, "Frames delay between each particle spawn." ) - .rejectArray(); + inputs[| 1] = nodeValue("Spawn delay", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 4, "Frames delay between each particle spawn." ); inputs[| 2] = nodeValue("Spawn amount", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, [ 2, 2 ], "Amount of particle spawn in that frame." ) .setDisplay(VALUE_DISPLAY.range, { linked : true }); @@ -14,7 +13,6 @@ function Node_VFX_Spawner_Base(_x, _y, _group = noone) : Node(_x, _y, _group) co .setDisplay(VALUE_DISPLAY.area); inputs[| 4] = nodeValue("Spawn distribution", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0 ) - .rejectArray() .setDisplay(VALUE_DISPLAY.enum_scroll, [ "Area", "Border", "Map" ] ); inputs[| 5] = nodeValue("Lifespan", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, [ 20, 30 ] ) @@ -75,6 +73,7 @@ function Node_VFX_Spawner_Base(_x, _y, _group = noone) : Node(_x, _y, _group) co .setDisplay(VALUE_DISPLAY.enum_button, [ "Uniform", "Random" ]); inputs[| 25] = nodeValue("Boundary data", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, []) + .setArrayDepth(1) .setVisible(false, true); inputs[| 26] = nodeValue("On animation end", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, ANIM_END_ACTION.loop) @@ -89,7 +88,8 @@ function Node_VFX_Spawner_Base(_x, _y, _group = noone) : Node(_x, _y, _group) co inputs[| 30] = nodeValue("Distribution map", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone) - inputs[| 31] = nodeValue("Atlas", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, [] ); + inputs[| 31] = nodeValue("Atlas", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, [] ) + .setArrayDepth(1); inputs[| 32] = nodeValue("Seed", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, seed_random(6)) .setDisplay(VALUE_DISPLAY._default, { side_button : button(function() { randomize(); inputs[| 32].setValue(seed_random(6)); }).setIcon(THEME.icon_random, 0, COLORS._main_icon) }); @@ -137,7 +137,7 @@ function Node_VFX_Spawner_Base(_x, _y, _group = noone) : Node(_x, _y, _group) co inputs[| 49] = nodeValue("Stretch Animation", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false ); - for (var i = 16, n = ds_list_size(inputs); i < n; i++) + for (var i = 2, n = ds_list_size(inputs); i < n; i++) inputs[| i].rejectArray(); input_len = ds_list_size(inputs); diff --git a/scripts/node_data/node_data.gml b/scripts/node_data/node_data.gml index f2d880f34..c340e6399 100644 --- a/scripts/node_data/node_data.gml +++ b/scripts/node_data/node_data.gml @@ -729,14 +729,15 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor { static getInputData = function(index, def = 0) { #region INLINE - return array_safe_get_fast(inputs_data, index, def); + var _dat = array_safe_get_fast(inputs_data, index, def); + return _dat; } #endregion static setInputData = function(index, value) { #region INLINE - inputs_data[index] = value; var _inp = inputs[| index]; + inputs_data[index] = value; if(is_struct(_inp)) input_value_map[$ _inp.internalName] = value; } #endregion diff --git a/scripts/node_particle/node_particle.gml b/scripts/node_particle/node_particle.gml index 4125bfcdc..db8c05a44 100644 --- a/scripts/node_particle/node_particle.gml +++ b/scripts/node_particle/node_particle.gml @@ -5,10 +5,12 @@ function Node_Particle(_x, _y, _group = noone) : Node_VFX_Spawner_Base(_x, _y, _ onSurfaceSize = function() { return getInputData(input_len, DEF_SURF); }; inputs[| 3] = nodeValue("Spawn area", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, DEF_AREA_REF ) + .rejectArray() .setUnitRef(onSurfaceSize, VALUE_UNIT.reference) .setDisplay(VALUE_DISPLAY.area, { onSurfaceSize }); inputs[| input_len + 0] = nodeValue("Output dimension", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, DEF_SURF) + .rejectArray() .setDisplay(VALUE_DISPLAY.vector); inputs[| input_len + 1] = nodeValue("Round position", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, true, "Round position to the closest integer value to avoid jittering.") diff --git a/scripts/node_string_join/node_string_join.gml b/scripts/node_string_join/node_string_join.gml index 93c43c99f..d23655752 100644 --- a/scripts/node_string_join/node_string_join.gml +++ b/scripts/node_string_join/node_string_join.gml @@ -8,6 +8,7 @@ function Node_String_Join(_x, _y, _group = noone) : Node(_x, _y, _group) constru inputs[| 1] = nodeValue("Divider", self, JUNCTION_CONNECT.input, VALUE_TYPE.text, "") .rejectArray(); + inputs[| 1].editWidget.format = TEXT_AREA_FORMAT.delimiter; outputs[| 0] = nodeValue("Text", self, JUNCTION_CONNECT.output, VALUE_TYPE.text, ""); diff --git a/scripts/node_surface_data/node_surface_data.gml b/scripts/node_surface_data/node_surface_data.gml index 5b6cf3fe2..0068ebc3d 100644 --- a/scripts/node_surface_data/node_surface_data.gml +++ b/scripts/node_surface_data/node_surface_data.gml @@ -6,6 +6,7 @@ function Node_Surface_data(_x, _y, _group = noone) : Node(_x, _y, _group) constr outputs[| 0] = nodeValue("Dimension", self, JUNCTION_CONNECT.output, VALUE_TYPE.integer, [ 1, 1 ]) .setDisplay(VALUE_DISPLAY.vector); + outputs[| 1] = nodeValue("Array length", self, JUNCTION_CONNECT.output, VALUE_TYPE.integer, 0); diff --git a/scripts/node_value/node_value.gml b/scripts/node_value/node_value.gml index 69e967101..5d1aaa770 100644 --- a/scripts/node_value/node_value.gml +++ b/scripts/node_value/node_value.gml @@ -1340,28 +1340,9 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru cache_array[0] = true; } - if(!is_array(val)) { //Value is scalar - if(_cac) cache_array[1] = false; - return false; - } - - if(array_depth == 0 && !typeArray(display_type)) { // Value is not an array by default, and no array depth enforced - if(_cac) cache_array[1] = true; - return true; - } - - var ar = val; - repeat(array_depth + typeArray(display_type)) { //Recursively get the first member of subarray to check if value has depth of "array_depth" or not - if(!is_array(ar) || !array_length(ar)) { //empty array - if(_cac) cache_array[1] = false; - return false; - } - - ar = ar[0]; - } - - if(_cac) cache_array[1] = is_array(ar); - return is_array(ar); + var _dep = array_get_depth(val) > array_depth + typeArray(display_type); + if(_cac) cache_array[1] = _dep; + return _dep; } #endregion static arrayLength = function(val = undefined) { #region