25 lines
465 B
GDScript
25 lines
465 B
GDScript
extends SharedSlime
|
|
class_name Villager
|
|
|
|
var color_changes = true
|
|
|
|
func get_color_idx() -> int:
|
|
return $slime.color_idx
|
|
|
|
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()
|
|
print(other, mine)
|
|
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)
|
|
|
|
|