generated from Raicuparta/ow-mod-template
-
Notifications
You must be signed in to change notification settings - Fork 7
/
RichPresenceTriggerVolume.cs
56 lines (47 loc) · 1.35 KB
/
RichPresenceTriggerVolume.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
54
55
56
using DiscordRPC;
using UnityEngine;
namespace OWRichPresence
{
public class RichPresenceTriggerVolume : MonoBehaviour
{
public OWTriggerVolume triggerVolume;
public RichPresence presence;
public void Awake()
{
if (triggerVolume == null) triggerVolume = GetComponent<OWTriggerVolume>();
triggerVolume.OnEntry += OnEntry;
triggerVolume.OnExit += OnExit;
}
public void OnDestroy()
{
triggerVolume.OnEntry -= OnEntry;
triggerVolume.OnExit -= OnExit;
}
public void OnEntry(GameObject hitObj)
{
if (hitObj.CompareTag("PlayerDetector"))
{
OWRichPresence.Push(presence);
}
}
public void OnExit(GameObject hitObj)
{
if (hitObj.CompareTag("PlayerDetector"))
{
OWRichPresence.Remove(presence);
}
}
public void SetTriggerVolume(OWTriggerVolume owtv)
{
if (owtv == null) return;
if (triggerVolume != null)
{
triggerVolume.OnEntry -= OnEntry;
triggerVolume.OnExit -= OnExit;
}
triggerVolume = owtv;
owtv.OnEntry += OnEntry;
owtv.OnExit += OnExit;
}
}
}