using UnityEngine;
/// Масляный щуп: при наведении показывает уровень и состояние моторного масла.
public class OilDipstick : MonoBehaviour, IInteractable
{
private CarFluids fluids;
private Vector3 restLocalPos;
private float pulledTimer;
private void Awake()
{
fluids = GetComponentInParent();
restLocalPos = transform.localPosition;
}
private void Update()
{
if (pulledTimer > 0f) pulledTimer -= Time.deltaTime;
Vector3 target = restLocalPos + (pulledTimer > 0f ? Vector3.up * 0.14f : Vector3.zero);
transform.localPosition = Vector3.Lerp(transform.localPosition, target, Time.deltaTime * 8f);
}
public string GetPrompt()
{
if (fluids == null) fluids = GetComponentInParent();
if (fluids == null) return "Масляный щуп";
CarFluids.FluidReservoir oil = fluids.EngineOil;
int level = Mathf.RoundToInt(oil.FillPercent * 100f);
int quality = Mathf.RoundToInt(oil.quality * 100f);
string qText = oil.currentLiters < 0.05f ? "масла нет!" : oil.QualityText;
string color = (oil.FillPercent < 0.5f || oil.quality < 0.5f) ? "#E5534B" : "#4CD07D";
return $"Масляный щуп [E] — вытащить\nУровень: {level}% | Состояние: {quality}% ({qText})";
}
public void Interact(GameObject interactor)
{
pulledTimer = 2.5f;
CarOwnership own = CarOwnership.Get(gameObject);
if (own != null) own.hoodInspected = true;
ProceduralAudioManager.Instance?.Play(SfxId.Pickup, transform.position, 0.6f);
}
}