1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# Hurry Curry! - a game about cooking
# Copyright 2024 nokoe
#
# 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 Grass
extends Tile
const GRASS_MESH: Mesh = preload("res://map/tiles/grass_side.tres")
func _init(ctx: TileFactory.TileCC):
super(ctx)
var random = RandomNumberGenerator.new()
random.seed = str(ctx.position).hash()
var multimesh_instance := MultiMeshInstance3D.new()
var multimesh := MultiMesh.new()
multimesh.mesh = GRASS_MESH
multimesh.transform_format = MultiMesh.TRANSFORM_3D
multimesh.instance_count = Global.get_setting("graphics.grass_amount")
for i in multimesh.instance_count:
var origin := Vector3(random.randf_range(-.5, .5), 0.25, random.randf_range(-.5, .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))
base_mesh.add_child(multimesh_instance)
multimesh_instance.multimesh = multimesh
func get_base_mesh():
return preload("res://map/tiles/grass.tscn").instantiate()
|