using UnityEngine; namespace MazeGen { /// /// Placeholder marker for a single Exit, positioned just outside its owning room's /// edge in the exit's direction. Purely informational now that agents move /// autonomously - colored relative to whichever agent the camera is currently /// following, so the doors that actually matter stand out among a cluster of nearby /// rooms: green = usable from the followed agent's room, not yet leading anywhere /// explored; blue = usable from there but leads to an already-visited room; transparent /// gray = not on the followed room at all (or no agent is being followed). /// [RequireComponent(typeof(SpriteRenderer), typeof(CircleCollider2D))] public class ExitMarker : MonoBehaviour { private static readonly Color UnexploredColor = Color.green; private static readonly Color ExploredColor = new Color(0.25f, 0.55f, 1f); private static readonly Color OtherRoomColor = new Color(0.5f, 0.5f, 0.5f, 0.6f); public Exit ExitData { get; private set; } public void Initialize(Room room, Exit exit) { ExitData = exit; transform.position = (Vector2)room.Position + exit.Direction * (room.Radius + 0.35f); transform.localScale = Vector3.one * 0.3f; var sr = GetComponent(); sr.sprite = RoomView.SharedSquareSprite; sr.sortingOrder = 1; var col = GetComponent(); col.radius = 0.5f; col.isTrigger = true; UpdateVisual(null, null); } /// /// Recolors this marker relative to whichever room the agent is currently standing /// in. `currentRoom`/`agent` may be null before the agent has spawned yet. /// public void UpdateVisual(Room currentRoom, MazeAgent agent) { var sr = GetComponent(); bool isOnCurrentRoom = currentRoom != null && ExitData.OwnerRoomId == currentRoom.Id; if (!isOnCurrentRoom) { sr.color = OtherRoomColor; return; } bool leadsToExploredRoom = ExitData.ConnectedRoomId.HasValue && agent != null && agent.HasVisited(ExitData.ConnectedRoomId.Value); sr.color = leadsToExploredRoom ? ExploredColor : UnexploredColor; } } }