using System; using Unity.BossRoom.Gameplay.UserInput; using Unity.Netcode; using UnityEngine; namespace Unity.BossRoom.Gameplay.UI { /// /// Responsible for managing and creating a feedback icon where the player clicked to move /// [RequireComponent(typeof(ClientInputSender))] public class ClientClickFeedback : NetworkBehaviour { [SerializeField] GameObject m_FeedbackPrefab; GameObject m_FeedbackObj; ClientInputSender m_ClientSender; ClickFeedbackLerper m_ClickFeedbackLerper; void Start() { if (NetworkManager.Singleton.LocalClientId != OwnerClientId) { enabled = false; return; } m_ClientSender = GetComponent(); m_ClientSender.ClientMoveEvent += OnClientMove; m_FeedbackObj = Instantiate(m_FeedbackPrefab); m_FeedbackObj.SetActive(false); m_ClickFeedbackLerper = m_FeedbackObj.GetComponent(); } void OnClientMove(Vector3 position) { m_FeedbackObj.SetActive(true); m_ClickFeedbackLerper.SetTarget(position); } public override void OnDestroy() { base.OnDestroy(); if (m_ClientSender) { m_ClientSender.ClientMoveEvent -= OnClientMove; } } } }