2021-10-03 19:56:35 +02:00
|
|
|
tool
|
|
|
|
class_name MMMateial
|
|
|
|
extends Resource
|
|
|
|
|
2021-10-04 13:09:43 +02:00
|
|
|
export(Vector2) var image_size : Vector2 = Vector2(128, 128)
|
2021-10-03 19:56:35 +02:00
|
|
|
export(Array) var nodes : Array
|
2021-10-04 13:09:43 +02:00
|
|
|
|
2021-10-09 14:04:09 +02:00
|
|
|
var initialized : bool = false
|
|
|
|
|
|
|
|
func initialize():
|
|
|
|
if !initialized:
|
|
|
|
initialized = true
|
|
|
|
|
|
|
|
for n in nodes:
|
|
|
|
n.connect("changed", self, "on_node_changed")
|
2021-10-09 13:33:59 +02:00
|
|
|
|
2021-10-04 13:09:43 +02:00
|
|
|
func add_node(node : MMNode) -> void:
|
|
|
|
nodes.append(node)
|
2021-10-09 13:33:59 +02:00
|
|
|
|
|
|
|
node.connect("changed", self, "on_node_changed")
|
|
|
|
|
|
|
|
emit_changed()
|
|
|
|
|
|
|
|
func remove_node(node : MMNode) -> void:
|
|
|
|
nodes.erase(node)
|
|
|
|
|
|
|
|
node.disconnect("changed", self, "on_node_changed")
|
|
|
|
|
2021-10-04 13:09:43 +02:00
|
|
|
emit_changed()
|
2021-10-09 13:33:59 +02:00
|
|
|
|
|
|
|
func render() -> void:
|
2021-10-09 14:04:09 +02:00
|
|
|
if !initialized:
|
|
|
|
initialize()
|
|
|
|
|
2021-10-09 13:33:59 +02:00
|
|
|
var did_render : bool = true
|
|
|
|
|
|
|
|
while did_render:
|
|
|
|
did_render = false
|
|
|
|
|
|
|
|
for n in nodes:
|
|
|
|
if n && n.render(self):
|
|
|
|
did_render = true
|
|
|
|
|
|
|
|
func on_node_changed() -> void:
|
|
|
|
call_deferred("render")
|