# Hurry Curry! - a game about cooking
# Copyright (C) 2025 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

enum Mode {
	ITEMS,
	TILES
}

@onready var camera = $SubViewport/Node3D/Camera3D
@onready var base = $SubViewport/Node3D

var current_object: Node3D = null
var mode: Mode

func setup_object(object_name: String):
	if current_object: current_object.queue_free()
	match mode:
		Mode.ITEMS:
			current_object = ItemFactory.produce(object_name, base)
		Mode.TILES:
			var tf = TileFactory.new()
			current_object = tf.produce(object_name, Vector2i(0, 0), ["counter", "floor", "counter", null])
			current_object.rotation_degrees.y = 45.
			current_object.translate(Vector3(-0.5, 0.0, -0.5))
			camera.size = 2.
	base.add_child(current_object)
