/// Cross-matrix now! uses world positions private void InteractDoor(Vector3Int currentPos, Vector3Int targetPos) { // Make sure there is a door controller DoorTrigger door = MatrixManager.Instance.GetFirst <DoorTrigger>(targetPos); if (!door) { door = MatrixManager.Instance.GetFirst <DoorTrigger>(Vector3Int.RoundToInt(currentPos)); if (door) { RegisterDoor registerDoor = door.GetComponent <RegisterDoor>(); Vector3Int localPos = MatrixManager.Instance.WorldToLocalInt(targetPos, matrix); if (registerDoor.IsPassable(localPos)) { door = null; } } } // Attempt to open door if (door != null && allowInput) { door.Interact(gameObject, TransformState.HiddenPos); } }
/// <summary> /// Interact with a door at the specified position if there is a closed door there. /// </summary> /// <param name="currentPos">current world position </param> /// <param name="targetPos">position to interact with</param> private void InteractDoor(Vector3Int currentPos, Vector3Int targetPos) { // Make sure there is a door which can be interacted with DoorTrigger door = MatrixManager.GetClosedDoorAt(currentPos, targetPos); // Attempt to open door if (door != null) { door.Interact(gameObject, TransformState.HiddenPos); } }