@tool
extends Node3D
class_name MutationDiscoveryElement

enum State {DISCOVERED, UNDISCOVERED, LOCKED}

@export var state: State = State.UNDISCOVERED:
    set(v):
        state = v
        update()
@export var mutation: PlantMutation:
    set(v):
        mutation = v
        update()

func _ready():
    update()

func update():
    if is_node_ready():
        %MutationTexture.visible = state == State.DISCOVERED || state == State.UNDISCOVERED
        %BackgroundHexagon.visible = state == State.DISCOVERED || state == State.UNDISCOVERED
        %BackgroundHexagonLocked.visible = state == State.LOCKED
        if state == State.DISCOVERED:
            %MutationTexture.modulate = Color.WHITE
            %BackgroundHexagon.modulate = Color("ffa617")
        elif state == State.UNDISCOVERED:
            %MutationTexture.modulate = Color("96B3DB")
            %BackgroundHexagon.modulate = Color.WHITE
        if mutation:
            %MutationTexture.texture = mutation.get_icon()
            %MutationElement.mutation = mutation
        %MutationElement.inspectable = state == State.DISCOVERED
