36 lines
800 B
C#
36 lines
800 B
C#
using System;
|
|
using Code.Gameplay.Orders.Order;
|
|
using UnityEngine;
|
|
|
|
namespace Code.Generator
|
|
{
|
|
public class RoomTrigger : MonoBehaviour
|
|
{
|
|
public IOrderService OrderService;
|
|
public event Action OnEnter;
|
|
public event Action OnExit;
|
|
|
|
private bool _playerEntered, _playerExited;
|
|
|
|
private void OnTriggerEnter(Collider other)
|
|
{
|
|
if (_playerEntered) return;
|
|
|
|
_playerEntered = true;
|
|
|
|
OrderService.RoomPassed();
|
|
|
|
OnEnter?.Invoke();
|
|
}
|
|
private void OnTriggerExit(Collider other)
|
|
{
|
|
if (_playerExited) return;
|
|
|
|
Debug.Log(other.name);
|
|
|
|
_playerExited = true;
|
|
|
|
OnExit?.Invoke();
|
|
}
|
|
}
|
|
} |