32 lines
879 B
C#
32 lines
879 B
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using BITKit;
|
|
using BITKit.Entities;
|
|
using BITKit.Entities.Player;
|
|
using UnityEngine;
|
|
|
|
namespace BITFALL.Scenes
|
|
{
|
|
public class PortalArea : MonoBehaviour
|
|
{
|
|
private static readonly IntervalUpdate _CD = new(1);
|
|
[SerializeField] private Transform area;
|
|
[SerializeField] private Transform nextArea;
|
|
private void OnTriggerEnter(Collider other)
|
|
{
|
|
if (other.TryGetComponent<IEntityPlayerComponent>(out var player) is false) return;
|
|
if (player.As<MonoBehaviour>().TryGetComponent<IEntityMovement>(out var movement) is false) return;
|
|
if (_CD.AllowUpdate is false) return;
|
|
var pos = area.InverseTransformPoint(movement.Position);
|
|
|
|
var nextPos = nextArea.TransformPoint(pos);
|
|
|
|
movement.Position = nextPos;
|
|
|
|
BIT4Log.Log($"Teleported to next area:{nextArea.name}");
|
|
}
|
|
}
|
|
|
|
}
|