generic doors
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using Escape_Room_Engine.Engine.Scripts.Modules;
|
||||
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;
|
||||
@@ -14,34 +13,35 @@ namespace Escape_Room_Engine.Engine.Scripts
|
||||
/// </summary>
|
||||
internal Vector2Int rrPosition;
|
||||
|
||||
internal Passage(DoorModule from)
|
||||
internal Passage(DoorModule from, bool spawnPassage = false)
|
||||
{
|
||||
ConnectFrom(from);
|
||||
if (spawnPassage)
|
||||
{
|
||||
fromOut = from;
|
||||
rrPosition = Vector2Int.zero;
|
||||
}
|
||||
else
|
||||
{
|
||||
ConnectFrom(from);
|
||||
}
|
||||
}
|
||||
|
||||
protected Passage() {}
|
||||
|
||||
internal void ConnectFrom(DoorModule door)
|
||||
{
|
||||
fromOut = door;
|
||||
rrPosition = fromOut.RrPosition;
|
||||
|
||||
Logger.Log($"Connected passage from {door} at {rrPosition} (RR).", LogType.PassageConnection);
|
||||
Logger.Log($"Connected passage from {door} at {rrPosition} (RR)", LogType.PassageConnection);
|
||||
}
|
||||
|
||||
internal virtual void ConnectTo(DoorModule door)
|
||||
internal void ConnectTo(DoorModule door)
|
||||
{
|
||||
if (fromOut == null)
|
||||
{
|
||||
throw new Exception("Cannot connect passage to entrance if it hasn't been connected to an exit first.");
|
||||
}
|
||||
|
||||
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);
|
||||
Logger.Log($"Connected passage to {door} at {rrPosition} (RR)", LogType.PassageConnection);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user