# Hurry Curry! - a game about cooking
# Copyright (C) 2026 Hurry Curry! Contributors
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, version 3 of the License only.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <https://www.gnu.org/licenses/>.
#
class_name Renderer
extends SubViewportContainer

var current_object: Node3D = null

func setup_item(name: String):
	if current_object: current_object.queue_free()
	current_object = ItemFactory.produce(name, $SubViewport/Node3D/Base)
	$SubViewport/Node3D/Camera3D.size = 1.
	$SubViewport/Node3D/Base.add_child(current_object)

func setup_tile(parts: Array):
	if current_object: current_object.queue_free()
	var tf = TileFactory.new()
	current_object = Node3D.new()
	tf.produce(current_object, parts, Vector2i(0, 0), [["counter"], ["floor"], ["counter"], []])
	current_object.translate(Vector3(-0.5, 0.0, -0.5))
	$SubViewport/Node3D/Camera3D.size = 2.
	$SubViewport/Node3D/Base.add_child(current_object)
