mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
44 lines
1.2 KiB
C#
44 lines
1.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using UnityEngine;
|
|
|
|
namespace NewHorizons.Components
|
|
{
|
|
[RequireComponent(typeof(OWTriggerVolume))]
|
|
public class MapRestrictionVolume : MonoBehaviour
|
|
{
|
|
private OWTriggerVolume _triggerVolume;
|
|
|
|
public void Awake()
|
|
{
|
|
_triggerVolume = this.GetRequiredComponent<OWTriggerVolume>();
|
|
_triggerVolume.OnEntry += OnTriggerVolumeEntry;
|
|
_triggerVolume.OnExit += OnTriggerVolumeExit;
|
|
}
|
|
|
|
public void OnDestroy()
|
|
{
|
|
if (_triggerVolume == null) return;
|
|
_triggerVolume.OnEntry -= OnTriggerVolumeEntry;
|
|
_triggerVolume.OnExit -= OnTriggerVolumeExit;
|
|
}
|
|
|
|
public void OnTriggerVolumeEntry(GameObject hitObj)
|
|
{
|
|
if (hitObj.CompareTag("PlayerDetector"))
|
|
{
|
|
Locator.GetMapController()?.OnPlayerEnterMapRestriction();
|
|
}
|
|
}
|
|
|
|
public void OnTriggerVolumeExit(GameObject hitObj)
|
|
{
|
|
if (hitObj.CompareTag("PlayerDetector"))
|
|
{
|
|
Locator.GetMapController()?.OnPlayerExitMapRestriction();
|
|
}
|
|
}
|
|
}
|
|
}
|