Pixel-Composer/scripts/__node_module/__node_module.gml
Tanasart a581d4fbe1 1.17.0.2
- [Loop array] Output now duplicate data instead of referencing it.
- [Splice Spritesheet] Fix output empty when either width or height is set to 1.
- [Splice Spritesheet] Fix vertical orientation output error.
- [Atlas set] Add an option to recalculate position after applying new rotation.
2024-05-07 11:53:51 +07:00

74 lines
1.9 KiB
Plaintext

function NodeModule(parent) constructor {
self.parent = parent;
inputs = ds_list_create();
load_map = -1;
load_scale = false;
static isLeaf = function() { #region
for( var i = 0, n = ds_list_size(inputs); i < n; i++ ) {
var _inp = inputs[| i];
if(_inp.value_from != noone) return false;
}
return true;
} #endregion
static drawConnections = function(params = {}, _inputs = []) { #region
for(var i = 0; i < ds_list_size(inputs); i++) {
var jun = inputs[| i];
if(jun.value_from == noone) continue;
if(!jun.value_from.node.active) continue;
if(!jun.isVisible()) continue;
if(i >= 0) array_push(_inputs, jun);
}
} #endregion
static isRendered = function() { #region //Check if every input is ready (updated)
for(var j = 0; j < ds_list_size(inputs); j++)
if(!inputs[| j].isRendered()) return false;
return true;
} #endregion
static resetCache = function() { #region
for( var i = 0; i < ds_list_size(inputs); i++ ) {
if(!is_instanceof(inputs[| i], NodeValue)) continue;
inputs[| i].resetCache();
}
} #endregion
static serialize = function(scale = false, preset = false) { #region
var _map = {};
var _inputs = [];
for(var i = 0; i < ds_list_size(inputs); i++)
array_push(_inputs, inputs[| i].serialize(scale, preset));
_map.inputs = _inputs;
_map.outputs = [];
return _map;
} #endregion
static deserialize = function(_map, scale = false, preset = false) { #region
load_map = _map;
load_scale = scale;
} #endregion
static applyDeserialize = function(preset = false) { #region
var _inputs = load_map.inputs;
var amo = min(ds_list_size(inputs), array_length(_inputs));
for(var i = 0; i < amo; i++)
inputs[| i].applyDeserialize(_inputs[i], load_scale, preset);
} #endregion
static connect = function() { #region
for(var i = 0; i < ds_list_size(inputs); i++)
inputs[| i].connect(false);
} #endregion
}