logic_node.ts 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. type logic_node_t = {
  2. inputs?: logic_node_input_t[];
  3. outputs?: logic_node_t[][];
  4. get?: (self: any, from: i32)=>logic_node_value_t;
  5. get_as_image?: (self: any, from: i32)=>image_t;
  6. get_cached_image?: (self: any)=>image_t;
  7. set?: (self: any, value: any)=>void;
  8. };
  9. type logic_node_value_t = {
  10. _f32?: f32;
  11. _any?: any;
  12. };
  13. type logic_node_input_t = {
  14. node?: any; // logic_node_t
  15. from?: i32; // Socket index
  16. };
  17. function logic_node_create(): logic_node_t {
  18. let n: logic_node_t = {};
  19. n.inputs = [];
  20. n.outputs = [];
  21. n.get = logic_node_get;
  22. n.get_as_image = logic_node_get_as_image;
  23. n.get_cached_image = logic_node_get_cached_image;
  24. n.set = logic_node_set;
  25. return n;
  26. }
  27. function logic_node_add_input(self: logic_node_t, node: logic_node_t, from: i32) {
  28. array_push(self.inputs, logic_node_input_create(node, from));
  29. }
  30. function logic_node_add_outputs(self: logic_node_t, nodes: logic_node_t[]) {
  31. array_push(self.outputs, nodes);
  32. }
  33. function logic_node_get(self: logic_node_t, from: i32): any {
  34. return null;
  35. }
  36. function logic_node_get_as_image(self: logic_node_t, from: i32): image_t {
  37. return null;
  38. }
  39. function logic_node_get_cached_image(self: logic_node_t): image_t {
  40. return null;
  41. }
  42. function logic_node_set(self: logic_node_t, value: any) {}
  43. function logic_node_input_create(node: logic_node_t, from: i32): logic_node_input_t {
  44. let inp: logic_node_input_t = {};
  45. inp.node = node;
  46. inp.from = from;
  47. return inp;
  48. }
  49. function logic_node_input_get(self: logic_node_input_t): logic_node_value_t {
  50. return self.node.base.get(self.node, self.from);
  51. }
  52. function logic_node_input_get_as_image(self: logic_node_input_t): image_t {
  53. return self.node.base.get_as_image(self.node, self.from);
  54. }
  55. function logic_node_input_set(self: logic_node_input_t, value: any) {
  56. self.node.base.set(self.node, value);
  57. }