Files
HauntedBloodlines/Assets/Scripts/Lights/LeaveLampInHolder.cs
2025-05-29 22:31:40 +03:00

63 lines
2.0 KiB
C#

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<GetLamp>()) != null)
{
getLamp = GetComponentInChildren<GetLamp>();
}
else
{
getLamp = null;
}
}
public void Start()
{
if(getLamp != null)
{
_hasLampInHolder = true;
}
}
public void LampUpdate()
{
if (ItemsInHandsData.GetInstance().HasLampInHands && !_hasLampInHolder)
{
getLamp = ItemsInHandsData.GetInstance().CurrentBulb.GetComponent<GetLamp>();
_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();
}
}
}