comment pass

This commit is contained in:
2022-12-29 16:16:49 +01:00
parent 643e03192a
commit ff01a700bd
75 changed files with 634 additions and 65 deletions

View File

@@ -7,6 +7,9 @@ using UnityEngine;
namespace EscapeRoomEngine.Portal.Runtime
{
/// <summary>
/// The portal is a specific type of <see cref="DoorState"/> for seamless transitions between spaces.
/// </summary>
public class Portal : DoorState
{
public static readonly Matrix4x4 HalfRotation = Matrix4x4.Rotate(Quaternion.Euler(0, 180, 0));
@@ -24,6 +27,9 @@ namespace EscapeRoomEngine.Portal.Runtime
/// </summary>
[BoxGroup("Internal")] public Transform portalTransform;
/// <summary>
/// Whether this portal is connected is determined by whether the reference to its linked portal is set.
/// </summary>
internal bool Connected => linkedPortal != null;
internal readonly List<PortalDriver> closePortalDrivers = new();
@@ -70,6 +76,9 @@ namespace EscapeRoomEngine.Portal.Runtime
}
}
/// <summary>
/// Begin tracking a portal driver that came close to this portal and might need to be teleported.
/// </summary>
internal void StartTrackingDriver(PortalDriver portalDriver, int entrySide)
{
closePortalDrivers.Add(portalDriver);
@@ -77,12 +86,18 @@ namespace EscapeRoomEngine.Portal.Runtime
portalDriver.entrySide = entrySide;
}
/// <summary>
/// End tracking a portal driver that distanced itself from this portal or was teleported to the linked portal.
/// </summary>
internal void StopTrackingDriver(PortalDriver portalDriver)
{
closePortalDrivers.Remove(portalDriver);
portalDriver.DisableClone(linkedPortal);
}
/// <summary>
/// Calculate which side of the portal plane a transform is.
/// </summary>
internal int CalculateSide(Transform portalDriverTransform)
{
return Math.Sign(Vector3.Dot(portalTransform.forward, portalDriverTransform.position - portalTransform.position));