44 lines
1.3 KiB
C#
44 lines
1.3 KiB
C#
using System;
|
|
using System.Linq;
|
|
using Code.Infrastructure.Camera;
|
|
using Code.OfficeGame.Player;
|
|
using Cysharp.Threading.Tasks;
|
|
using Reflex.Attributes;
|
|
using UnityEngine;
|
|
|
|
namespace Code.Game.OfficeGame.Location
|
|
{
|
|
public class PlayerLocationChecker : MonoBehaviour
|
|
{
|
|
[Inject] private CameraStateMachine _cameraStateMachine;
|
|
|
|
private LocationSegment _currentSegment;
|
|
private LocationSegment _previousSegment;
|
|
|
|
private void OnTriggerEnter(Collider other)
|
|
{
|
|
if (!other.TryGetComponent(out LocationSegmentTrigger locationSegmentTrigger))
|
|
return;
|
|
|
|
Debug.Log("Entered " + locationSegmentTrigger.segment.locationID);
|
|
|
|
_previousSegment = _currentSegment;
|
|
|
|
_currentSegment = locationSegmentTrigger.segment;
|
|
}
|
|
|
|
private void OnTriggerExit(Collider other)
|
|
{
|
|
if (!other.TryGetComponent(out LocationSegmentTrigger locationSegmentTrigger))
|
|
return;
|
|
|
|
Debug.Log("Exited " + locationSegmentTrigger.segment.locationID);
|
|
|
|
if (_currentSegment != locationSegmentTrigger.segment) return;
|
|
|
|
(_previousSegment, _currentSegment) = (_currentSegment, _previousSegment);
|
|
|
|
_currentSegment = locationSegmentTrigger.segment;
|
|
}
|
|
}
|
|
} |