# 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 Crate
extends CounterLike

static func interact_target(): # -> Vector3?
	return Vector3(0, 0.25, 0)

func _init(ctx: TileFactory.TileCC):
	super(ctx)
	match ctx.tile_name.variant:
		"bun":
			base.add_child(load("res://map/tiles/bun_crate.tscn").instantiate())
		"cheese":
			base.add_child(load("res://map/tiles/cheese_crate.tscn").instantiate())
		"coconut":
			base.add_child(load("res://map/tiles/coconut_crate.tscn").instantiate())
		"fish":
			base.add_child(load("res://map/tiles/fish_crate.tscn").instantiate())
		"flour":
			base.add_child(load("res://map/tiles/flour_crate.tscn").instantiate())
		"leek":
			base.add_child(load("res://map/tiles/leek_crate.tscn").instantiate())
		"lettuce":
			base.add_child(load("res://map/tiles/lettuce_crate.tscn").instantiate())
		"mushroom":
			base.add_child(load("res://map/tiles/mushroom_crate.tscn").instantiate())
		"noodles":
			base.add_child(load("res://map/tiles/noodles_crate.tscn").instantiate())
		"potato":
			base.add_child(load("res://map/tiles/potato_crate.tscn").instantiate())
		"rice":
			base.add_child(load("res://map/tiles/rice_crate.tscn").instantiate())
		"steak":
			base.add_child(load("res://map/tiles/steak_crate.tscn").instantiate())
		"strawberry":
			base.add_child(load("res://map/tiles/strawberry_crate.tscn").instantiate())
		"tomato":
			base.add_child(load("res://map/tiles/tomato_crate.tscn").instantiate())
		var item_name:
			base.add_child(load("res://map/tiles/crate.tscn").instantiate())
			for i in [
				[Vector3(0.25, 0.1, -0.2), deg_to_rad(-8)],
				[Vector3(0.25, 0.15, 0.2), deg_to_rad(8)],
				[Vector3(0, 0.1, -0.2), deg_to_rad(12)],
				[Vector3(0, 0.1, 0.1), deg_to_rad(-6)],
				[Vector3(-0.25, 0.15, -0.2), deg_to_rad(-8)],
				[Vector3(-0.25, 0.1, 0.2), deg_to_rad(4)],
			]:
				var crate_item_base = Node3D.new()
				var crate_item = ItemFactory.produce(item_name, crate_item_base)
				crate_item.position = i[0]
				crate_item_base.position = i[0]
				crate_item.rotation.y = i[1]
				crate_item_base.rotation.y = i[1]
				crate_item_base.add_child(crate_item)
				base.add_child(crate_item_base)
