77 lines
2.1 KiB
GDScript
77 lines
2.1 KiB
GDScript
extends Node3D
|
|
## Sichtbare Figur der Mitspieler.
|
|
|
|
const Mat = preload("res://scripts/mat.gd")
|
|
const Deco = preload("res://scripts/deco.gd")
|
|
|
|
const COLORS := ["d8a33c", "3c9dd8", "6fbf5a", "cf5f8f", "9b6fd8", "d87a3c"]
|
|
|
|
var _label: Label3D
|
|
var _tray: MeshInstance3D
|
|
|
|
func build(peer_id: int, label_text: String) -> void:
|
|
var col := Color(COLORS[abs(peer_id) % COLORS.size()])
|
|
var dark := Color("2b3138")
|
|
|
|
var legs := MeshInstance3D.new()
|
|
legs.mesh = Deco.box(Vector3(0.42, 0.82, 0.3))
|
|
legs.material_override = Mat.flat(dark)
|
|
legs.position = Vector3(0, 0.41, 0)
|
|
add_child(legs)
|
|
|
|
var torso := MeshInstance3D.new()
|
|
torso.mesh = Deco.box(Vector3(0.52, 0.64, 0.34))
|
|
torso.material_override = Mat.flat(col)
|
|
torso.position = Vector3(0, 1.14, 0)
|
|
add_child(torso)
|
|
|
|
for sx: float in [-1.0, 1.0]:
|
|
var arm := MeshInstance3D.new()
|
|
arm.mesh = Deco.box(Vector3(0.13, 0.6, 0.19))
|
|
arm.material_override = Mat.flat(col.darkened(0.12))
|
|
arm.position = Vector3(sx * 0.33, 1.12, 0)
|
|
add_child(arm)
|
|
|
|
var head := MeshInstance3D.new()
|
|
head.mesh = Deco.blob(0.18)
|
|
head.material_override = Mat.flat(Color("e8c39e"))
|
|
head.position = Vector3(0, 1.6, 0)
|
|
add_child(head)
|
|
|
|
var cap := MeshInstance3D.new()
|
|
cap.mesh = Deco.box(Vector3(0.38, 0.14, 0.38))
|
|
cap.material_override = Mat.flat(dark)
|
|
cap.position = Vector3(0, 1.75, 0)
|
|
add_child(cap)
|
|
|
|
var peak := MeshInstance3D.new()
|
|
peak.mesh = Deco.box(Vector3(0.38, 0.05, 0.16))
|
|
peak.material_override = Mat.flat(dark)
|
|
peak.position = Vector3(0, 1.7, 0.24)
|
|
add_child(peak)
|
|
|
|
_tray = MeshInstance3D.new()
|
|
_tray.mesh = Deco.box(Vector3(0.26, 0.3, 0.26))
|
|
_tray.material_override = Mat.flat(Color("8fd8ff"))
|
|
_tray.position = Vector3(0.2, 1.25, 0.3)
|
|
_tray.visible = false
|
|
add_child(_tray)
|
|
|
|
_label = Label3D.new()
|
|
_label.text = label_text
|
|
_label.font_size = 44
|
|
_label.pixel_size = 0.006
|
|
_label.billboard = BaseMaterial3D.BILLBOARD_ENABLED
|
|
_label.no_depth_test = true
|
|
_label.outline_size = 12
|
|
_label.outline_modulate = Color(0, 0, 0, 0.7)
|
|
_label.modulate = col
|
|
_label.position = Vector3(0, 2.05, 0)
|
|
add_child(_label)
|
|
|
|
func set_carrying(n: int) -> void:
|
|
_tray.visible = n > 0
|
|
|
|
func set_label(text: String) -> void:
|
|
_label.text = text
|