Files
modular-vr/Assets/Escape Room Engine/Engine/Scripts/Passage.cs
2022-11-04 09:46:00 +01:00

47 lines
1.4 KiB
C#

using Escape_Room_Engine.Engine.Scripts.Modules;
using UnityEngine;
using Logger = Escape_Room_Engine.Engine.Scripts.Utilities.Logger;
using LogType = Escape_Room_Engine.Engine.Scripts.Utilities.LogType;
namespace Escape_Room_Engine.Engine.Scripts
{
public class Passage
{
internal DoorModule fromOut, toIn;
/// <summary>
/// The room relative (<i>RR</i>) position of this passage.
/// </summary>
internal Vector2Int rrPosition;
internal Passage(DoorModule from, bool spawnPassage = false)
{
if (spawnPassage)
{
fromOut = from;
rrPosition = Vector2Int.zero;
}
else
{
ConnectFrom(from);
}
}
internal void ConnectFrom(DoorModule door)
{
fromOut = door;
rrPosition = fromOut.RrPosition;
Logger.Log($"Connected passage from {door} at {rrPosition} (RR)", LogType.PassageConnection);
}
internal void ConnectTo(DoorModule door)
{
toIn = door;
// to make sure the origin of the player doesn't move, the two doors must be placed in the same location
toIn.PlaceRoomRelative(rrPosition);
Logger.Log($"Connected passage to {door} at {rrPosition} (RR)", LogType.PassageConnection);
}
}
}