Pulver trash maze sequence

This commit is contained in:
Michal Pikulski
2025-12-19 15:26:13 +01:00
parent 15c9ba0127
commit f0905f92d3
36 changed files with 2372 additions and 842 deletions

View File

@@ -0,0 +1,92 @@
using System.Collections;
using Core;
using Interactions;
using Minigames.TrashMaze.Core;
using Minigames.TrashMaze.Data;
using UnityEngine;
namespace Minigames.TrashMaze.Objects
{
/// <summary>
/// Maze exit interactable that teleports Pulver out of the maze.
/// Uses camera blend with midway teleportation to create seamless transition.
/// Does NOT switch controllers - Pulver remains player-controlled.
/// </summary>
public class MazeExit : SaveableInteractable
{
[Header("Maze Exit Settings")]
[Tooltip("Transform where Pulver should be teleported to (maze exit position)")]
[SerializeField] private Transform teleportTarget;
[Tooltip("Camera state to blend to (typically PulverGameplay)")]
[SerializeField] private TrashMazeCameraState targetCameraState = TrashMazeCameraState.PulverGameplay;
public override string SaveId => $"{gameObject.scene.name}/MazeExit/{gameObject.name}";
protected override object GetSerializableState()
{
// MazeExit doesn't need to save state - it's a simple trigger
return null;
}
protected override void ApplySerializableState(string state)
{
// MazeExit doesn't need to restore state
}
protected override bool DoInteraction()
{
Logging.Debug("[MazeExit] Starting maze exit sequence");
StartCoroutine(ExitMazeSequence());
return true;
}
private IEnumerator ExitMazeSequence()
{
// Step 1: Find Pulver (should be the active player-controlled character)
var pulverController = FindFirstObjectByType<PulverController>();
if (pulverController == null)
{
Debug.LogError("[MazeExit] PulverController not found in scene!");
yield break;
}
GameObject pulverGameObject = pulverController.gameObject;
Logging.Debug($"[MazeExit] Found Pulver at {pulverGameObject.transform.position}");
// Step 2: Start camera blend to target state (PulverGameplay)
TeleportationHelper.StartCameraBlend(targetCameraState);
// Step 3: Wait for halfway through blend, teleport Pulver, and set tracking target
yield return TeleportationHelper.TeleportMidBlendAndSetTracking(pulverGameObject, teleportTarget, targetCameraState);
// Step 4: Wait for camera blend to complete
yield return TeleportationHelper.WaitForCameraBlend();
// Step 5: Stop Pulver movement to prevent it from continuing with cached input
if (pulverController != null)
{
pulverController.InterruptMoveTo();
Logging.Debug("[MazeExit] Stopped Pulver movement after teleportation");
}
Logging.Debug("[MazeExit] Maze exit sequence completed");
}
#if UNITY_EDITOR
private void OnValidate()
{
name = "MazeExit";
// Default to PulverGameplay camera
if (targetCameraState == TrashMazeCameraState.Gameplay)
{
targetCameraState = TrashMazeCameraState.PulverGameplay;
}
}
#endif
}
}