using System.Collections; using System.Collections.Generic; using UnityEngine; namespace InfallibleCode { public class LeaveLampInHolder : MonoBehaviour, IInteractable { [SerializeField] private GetLamp getLamp; public bool _hasLampInHolder; private void Awake() { if ((transform.GetComponentInChildren()) != null) { getLamp = GetComponentInChildren(); } else { getLamp = null; } } public void Start() { if(getLamp != null) { _hasLampInHolder = true; } } public void LampUpdate() { if (ItemsInHandsData.GetInstance().HasLampInHands && !_hasLampInHolder) { getLamp = ItemsInHandsData.GetInstance().CurrentBulb.GetComponent(); _hasLampInHolder = true; ItemsInHandsData.GetInstance().ChangeBulb_LerpItem = 0f; ItemsInHandsData.GetInstance().StopAllCoroutines(); ItemsInHandsData.GetInstance().StartCoroutine(ItemsInHandsData.GetInstance().LeaveLamp(transform)); } } //public IEnumerator LeaveLamp() //{ // while (_lerpItem <= 1.0f) // { // _lerpItem += 0.8f * Time.unscaledDeltaTime; // ItemsInHandsData.GetInstance().CurrentBulb.localPosition = Vector3.Lerp(ItemsInHandsData.GetInstance().CurrentBulb.localPosition, transform.localPosition, _lerpItem); // ItemsInHandsData.GetInstance().CurrentBulb.rotation = Quaternion.Lerp(ItemsInHandsData.GetInstance().CurrentBulb.rotation, transform.rotation, _lerpItem); // ItemsInHandsData.GetInstance().HasLampInHands = false; // Debug.Log("Is lerping item in hand"); // yield return null; // } //} public void Interact() { LampUpdate(); } } }