-
Notifications
You must be signed in to change notification settings - Fork 0
/
CockpitDetector.cs
53 lines (45 loc) · 1.17 KB
/
CockpitDetector.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
43
44
45
46
47
48
49
50
51
52
53
using UnityEngine;
namespace BandTogether;
[RequireComponent(typeof(OWTriggerVolume))]
public class CockpitDetector : MonoBehaviour
{
[SerializeField] NomaiInterfaceSlot activateSlot;
[SerializeField] NomaiMultiPartDoor doorController;
OWTriggerVolume trigger;
bool doorOpen = false;
private void Start()
{
trigger = GetComponent<OWTriggerVolume>();
trigger.OnEntry += OnEntry;
trigger.OnExit += OnExit;
}
private void Update()
{
if (!doorOpen && PlayerData.GetPersistentCondition("BT_FINISH_COCKPIT_QUEST"))
{
doorOpen = true;
doorController.Open(activateSlot);
}
}
private void OnDisable()
{
trigger.OnEntry -= OnEntry;
trigger.OnExit -= OnExit;
}
private void OnEntry(GameObject hitObj)
{
if (hitObj.transform.parent.name == "Module_Cockpit_Body"
&& !PlayerData.GetPersistentCondition("BT_FINISH_COCKPIT_QUEST"))
{
ModMain.SetPersistentCondition("BT_GOT_COCKPIT", true);
}
}
private void OnExit(GameObject hitObj)
{
if (hitObj.transform.parent.name == "Module_Cockpit_Body"
&& !PlayerData.GetPersistentCondition("BT_FINISH_COCKPIT_QUEST"))
{
ModMain.SetPersistentCondition("BT_GOT_COCKPIT", false);
}
}
}