-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCardReaderMonitor.cs
42 lines (40 loc) · 1014 Bytes
/
CardReaderMonitor.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using UnityEngine;
using Harmony;
namespace HarmonyIOLoader
{
class CardReaderMonitor : MonoBehaviour
{
private CardReader cardReader;
private float accessDuration;
private bool isEnabled;
private void Awake()
{
cardReader = GetComponent<CardReader>();
enabled = false;
}
private void Update()
{
if (!isEnabled && cardReader.HasFlag((BaseEntity.Flags)2))
{
isEnabled = true;
cardReader?.Invoke(new System.Action(Reset), accessDuration);
}
}
private void Reset()
{
cardReader?.ResetIOState();
isEnabled = false;
}
public void Init(float duration)
{
accessDuration = duration;
if (duration <= 0f)
Destroy(this);
else
{
Reset();
enabled = true;
}
}
}
}