using UnityEngine; using Unheimlich.Features.Hallucination; using Unheimlich.Features.Dialogue.UI; namespace Unheimlich.World.Environment { /// /// Sits on each stair-segment prefab and acts as the single configuration point /// for the InfiniteStaircaseController. /// /// Responsibilities: /// - Holds a reference to the segment's FloatingLabel (set in prefab). /// - Holds a reference to the segment's HallucinationTriggerZone (set in prefab). /// - Exposes Configure() so the controller can push the right word and event /// at spawn time without any GetComponent chains on the controller side. /// public class StaircaseSegment : MonoBehaviour { [Header("References")] [Tooltip("FloatingLabel present on this prefab. Assign in the prefab inspector.")] [SerializeField] private FloatingLabel _floatingLabel; [Tooltip("HallucinationTriggerZone present on this prefab. Assign in the prefab inspector.")] [SerializeField] private HallucinationTriggerZone _triggerZone; // ─── Public API ──────────────────────────────────────────────────────── /// /// Called by InfiniteStaircaseController right after this segment is spawned. /// Sets the word on the FloatingLabel and overrides the HallucinationEvent on the zone. /// /// Text to display. Null or empty = label keeps its prefab default. /// Event to fire when the player enters the zone. Null = no event. public void Configure(string word, HallucinationEvent hallucinationEvent) { if (_floatingLabel != null && !string.IsNullOrEmpty(word)) _floatingLabel.SetText(word); if (_triggerZone != null) _triggerZone.SetEvent(hallucinationEvent); } // ─── Editor helpers ──────────────────────────────────────────────────── #if UNITY_EDITOR private void Reset() { _floatingLabel = GetComponentInChildren(); _triggerZone = GetComponentInChildren(); } #endif } }