correctly delete old rooms
This commit is contained in:
@@ -27,15 +27,23 @@ namespace EscapeRoomEngine.Portal.Runtime
|
||||
internal bool Connected => linkedPortal != null;
|
||||
internal readonly List<PortalDriver> closePortalDrivers = new();
|
||||
|
||||
private void Awake()
|
||||
protected virtual void Awake()
|
||||
{
|
||||
DoorEvent += (_, type) =>
|
||||
{
|
||||
if (type == DoorEventType.Connected)
|
||||
// ReSharper disable once SwitchStatementMissingSomeEnumCasesNoDefault
|
||||
switch (type)
|
||||
{
|
||||
linkedPortal = FromDoorState(Module.ConnectedDoorState);
|
||||
portalCamera.screen.gameObject.SetActive(true);
|
||||
portalCamera.enabled = true;
|
||||
case DoorEventType.Connected:
|
||||
linkedPortal = FromDoorState(Module.ConnectedDoorState);
|
||||
portalCamera.screen.gameObject.SetActive(true);
|
||||
portalCamera.enabled = true;
|
||||
break;
|
||||
case DoorEventType.Locked:
|
||||
portalCamera.enabled = false;
|
||||
portalCamera.screen.gameObject.SetActive(false);
|
||||
linkedPortal = null;
|
||||
break;
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -54,7 +62,7 @@ namespace EscapeRoomEngine.Portal.Runtime
|
||||
portalDriver.Teleport(this, linkedPortal);
|
||||
if (portalDriver.player)
|
||||
{
|
||||
linkedPortal.OnDoorEvent(DoorEventType.ExitedFrom);
|
||||
linkedPortal.ExitFrom();
|
||||
}
|
||||
i--; // decrease the loop counter because the list is one element smaller now
|
||||
}
|
||||
|
||||
@@ -44,20 +44,24 @@ namespace EscapeRoomEngine.Portal.Runtime
|
||||
protected void Start()
|
||||
{
|
||||
if (hasClone)
|
||||
{
|
||||
clone = PortalDriverClone.Create(this);
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (hasClone && clone.gameObject.activeSelf)
|
||||
{
|
||||
clone.UpdatePosition(transform);
|
||||
}
|
||||
}
|
||||
|
||||
public void EnableClone(Portal at)
|
||||
{
|
||||
if (hasClone)
|
||||
{
|
||||
Logger.Log($"Enabled {clone}", LogType.Portals);
|
||||
Logger.Log($"Enabled {clone} at {at}", LogType.Portals);
|
||||
|
||||
clone.portal = at;
|
||||
clone.gameObject.SetActive(true);
|
||||
@@ -68,7 +72,7 @@ namespace EscapeRoomEngine.Portal.Runtime
|
||||
{
|
||||
if (hasClone && at.Equals(clone.portal)) // don't disable clones that are already at a different portal
|
||||
{
|
||||
Logger.Log($"Disabled {clone}", LogType.Portals);
|
||||
Logger.Log($"Disabled {clone} at {clone.portal}", LogType.Portals);
|
||||
|
||||
clone.portal = null;
|
||||
clone.gameObject.SetActive(false);
|
||||
|
||||
@@ -40,5 +40,10 @@ namespace EscapeRoomEngine.Portal.Runtime
|
||||
portal.linkedPortal.portalTransform.worldToLocalMatrix * cloning.localToWorldMatrix;
|
||||
transform.SetPositionAndRotation(m.GetPosition(), m.rotation);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return gameObject.name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user