2017-07-30 17:30:10 +01:00
|
|
|
extends Control
|
|
|
|
|
|
|
|
var offset_pos = Vector2(32, 32)
|
|
|
|
|
|
|
|
onready var render_target = get_node("Viewport")
|
|
|
|
onready var tex_frame = get_node("TextureFrame")
|
|
|
|
|
|
|
|
var entities = Array()
|
|
|
|
|
|
|
|
func _ready():
|
|
|
|
set_fixed_process(true)
|
|
|
|
tex_frame.set_texture(render_target.get_render_target_texture())
|
|
|
|
render_target.init(entities)
|
2017-07-30 18:36:23 +01:00
|
|
|
set_pos(Vector2(32, 32))
|
2017-07-30 17:30:10 +01:00
|
|
|
|
|
|
|
func register_entity(e):
|
|
|
|
entities.append(weakref(e))
|
|
|
|
render_target.init(entities)
|
|
|
|
|
|
|
|
func collect_entities():
|
|
|
|
var to_remove
|
|
|
|
for i in range(0, entities.size()):
|
|
|
|
if not entities[i].get_ref():
|
|
|
|
if to_remove == null:
|
|
|
|
to_remove = Array()
|
|
|
|
to_remove.push_back(i)
|
|
|
|
|
|
|
|
func _fixed_process(delta):
|
|
|
|
collect_entities()
|
|
|
|
|
|
|
|
func _draw():
|
|
|
|
if entities.size() > 0:
|
|
|
|
render_target.render_target_clear()
|
2017-07-30 19:11:15 +01:00
|
|
|
render_target.it_changed()
|
2017-07-30 17:30:10 +01:00
|
|
|
# gc the shit out of em
|
|
|
|
collect_entities()
|