aboutsummaryrefslogtreecommitdiff
path: root/Assets/Scripts/SoulCoreGameLoop/UI/AreaHint.cs
blob: 6b676fefc2533df7fcfd3691803c3901f30b400e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using System;
using UnityEngine;
using TMPro;

namespace SoulCoreGameLoop.UI
{
    [RequireComponent(typeof(Animator))]
    public class AreaHint : MonoBehaviour, IUIEventSender<AreaHintMessage>
    {
        private static readonly int TriggerPlay = Animator.StringToHash("Play");
        
        public TMP_Text areaName;
        private Animator _animator;
        
        private void Awake()
        {
            _animator = GetComponent<Animator>();
            UIEventListener.Register(this);
        }
        
        private void OnDestroy()
            => UIEventListener.Unregister<AreaHintMessage>();
        

        public void OnReceive(AreaHintMessage evt)
        {
            areaName.text = evt.AreaName;
            _animator.SetTrigger(TriggerPlay);
        }
    }

    public struct AreaHintMessage
    {
        public readonly string AreaName;
        
        public AreaHintMessage(string areaName)
        {
            AreaName = areaName;
        }
    }
}