summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2024-09-28 22:36:28 +0200
committermetamuffin <metamuffin@disroot.org>2024-09-28 22:36:28 +0200
commit093fd9d82b75a45c8b03899266e691adc2f293f3 (patch)
treee2c246c3e38c9daf820d1672692cf99ed60b268b
parenteb379e405d18c72e169124e138961caeda3d4c54 (diff)
downloadhurrycurry-093fd9d82b75a45c8b03899266e691adc2f293f3.tar
hurrycurry-093fd9d82b75a45c8b03899266e691adc2f293f3.tar.bz2
hurrycurry-093fd9d82b75a45c8b03899266e691adc2f293f3.tar.zst
parse character int
-rw-r--r--client/player/character/character.gd43
1 files changed, 28 insertions, 15 deletions
diff --git a/client/player/character/character.gd b/client/player/character/character.gd
index d3138c3e..65275549 100644
--- a/client/player/character/character.gd
+++ b/client/player/character/character.gd
@@ -42,6 +42,8 @@ var current_animation := "idle"
@onready var tie = $Main/Tie
@onready var knife = $Main/HandRight/Knife
+const NUM_COLORS = 5;
+const NUM_HAIRS = 3;
@onready var hairstyles := [$Main/HeadDefault/Hair, $Main/HeadDefault/Hair2, $Main/HeadDefault/Hair3]
var colors = [
Color(0.204, 0.361, 0.624),
@@ -57,6 +59,22 @@ var colors = [
@onready var step_sounds: PlayRandom = $Steps
@onready var boost_sounds: PlayRandom = $Boosts
+class ParsedStyle:
+ var color: int
+ var hair: int
+ var robot: bool
+ var customer: bool
+ func _init(n: int) -> void:
+ customer = n < 0
+ if customer: n *= -1
+ if n == 51: robot = true
+ else:
+ hair = n % NUM_HAIRS
+ color = n / NUM_HAIRS % NUM_COLORS
+ func pack() -> int:
+ if robot: return 51
+ return (hair + color * NUM_HAIRS) * (-1 if customer else 1)
+
func _ready():
play_animation("idle")
@@ -86,23 +104,18 @@ func _process(delta):
was_boosting = boosting and walking
func set_style(id: int):
- if id == 51: return set_robot(true)
- if id < 0:
- to_customer()
- id *= -1
-
- var hairstyle = id % hairstyles.size()
- @warning_ignore("integer_division")
- var color = id / hairstyles.size() % colors.size()
-
+ var p = ParsedStyle.new(id)
+ set_customer(p.customer)
+ set_robot(p.robot)
for h in hairstyles: h.hide()
- hairstyles[hairstyle].show()
-
- $Main.get_active_material(0).albedo_color = colors[color]
+ hairstyles[p.hair].show()
+ $Main.get_active_material(0).albedo_color = colors[p.color]
-func to_customer():
- main.mesh = CUSTOMER_MAIN_MESH
- tie.queue_free()
+func set_customer(b: bool):
+ if b:
+ main.mesh = CUSTOMER_MAIN_MESH
+ tie.queue_free()
+ else: pass # TODO
func set_robot(b: bool):
head_robot.visible = b