53 lines
1.6 KiB
C#
53 lines
1.6 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.Events;
|
|
|
|
namespace InfallibleCode
|
|
{
|
|
public class ExaminableItemRotateToFind : MonoBehaviour, IDiscoverable
|
|
{
|
|
[SerializeField] private UnityEvent EventToTriggerAfterDiscover;
|
|
[SerializeField] private ExaminableItemInputEvent examinableItemInputEvent;
|
|
|
|
public bool itemToGetExists;
|
|
bool itemAddedToInventory;
|
|
public bool eventHappened;
|
|
|
|
public void Discover()
|
|
{
|
|
print("gamw to item");
|
|
if (!eventHappened)
|
|
{
|
|
print("Event happened");
|
|
if (itemToGetExists)
|
|
{
|
|
print("Update discoverable");
|
|
StartCoroutine(UpdateDiscoverable());
|
|
eventHappened = true;
|
|
}
|
|
if (EventToTriggerAfterDiscover != null)
|
|
{
|
|
EventToTriggerAfterDiscover.Invoke();
|
|
eventHappened = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
IEnumerator UpdateDiscoverable()
|
|
{
|
|
examinableItemInputEvent.UpdateEventInput();
|
|
while (ExaminableItemData.GetInstance().IsExamining)
|
|
{
|
|
yield return null;
|
|
}
|
|
yield return new WaitForSeconds(0f);
|
|
examinableItemInputEvent.StopUpdatingEventInput();
|
|
if (examinableItemInputEvent.invokedOnce == false)
|
|
{
|
|
eventHappened = false;
|
|
}
|
|
}
|
|
}
|
|
}
|