2023-08-19 20:42:02 -06:00
|
|
|
extends SharedSlime
|
2023-08-20 00:00:17 -06:00
|
|
|
class_name Villager
|
2023-08-20 01:03:30 -06:00
|
|
|
|
|
|
|
var color_changes = true
|
|
|
|
|
|
|
|
func get_color_idx() -> int:
|
|
|
|
return $slime.color_idx
|
|
|
|
|
2023-08-20 02:05:40 -06:00
|
|
|
func get_color():
|
|
|
|
return $slime.get_color()
|
|
|
|
|
2023-08-20 01:03:30 -06:00
|
|
|
func _on_area_3d_body_entered(body):
|
|
|
|
if "color_changes" not in body:
|
|
|
|
return
|
|
|
|
var other = body.get_color_idx()
|
|
|
|
var mine = get_color_idx()
|
|
|
|
if other == mine:
|
|
|
|
return
|
|
|
|
var delta = abs(other - mine)
|
|
|
|
if delta % 2 == 0:
|
|
|
|
if mine < other:
|
|
|
|
$slime.change_color(other)
|
|
|
|
elif mine > other:
|
|
|
|
$slime.change_color(other)
|
|
|
|
|
|
|
|
|