# 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 . # class_name GrassMesher extends FloorMesher const GRASS_MESH: Mesh = preload("res://map/tiles/grass_side.tres") var multimesh_instance := MultiMeshInstance3D.new() func _init(mesh: MeshInstance3D) -> void: super(mesh) mesh_instance.add_child(multimesh_instance) func flush() -> void: super() var random = RandomNumberGenerator.new() random.seed = "gr4ss".hash() var multimesh := MultiMesh.new() multimesh.mesh = GRASS_MESH multimesh.transform_format = MultiMesh.TRANSFORM_3D multimesh.instance_count = tiles.size() * Settings.read("graphics.grass_amount") var t := tiles.values() for i in multimesh.instance_count: var p = t[i / Settings.read("graphics.grass_amount")] var origin := Vector3(random.randf_range(-.5, .5), 0.25, random.randf_range(-.5, .5)) + Vector3(p.x + 0.5, 0.0, p.y + 0.5) var basis_ := (Basis(Vector3(0, 1, 0), random.randf_range(0, PI)) * Basis(Vector3(1, 0, 0), PI/2)).scaled(Vector3(0.75, 0.5, 0.75)) multimesh.set_instance_transform(i, Transform3D(basis_, origin)) multimesh_instance.multimesh = multimesh