using System.Collections.Generic; using UnityEngine; namespace Auralis { // Reuses the four saved U12 residents and the existing finite wave scheduler. public sealed class LastHearthConnectedPassage:MonoBehaviour { public readonly List Answers=new(); readonly Dictionary grace=new(); readonly Dictionary ready=new(); int serial=-1; public void Register(BoxCollider2D bank){Answers.Add(bank);grace[bank]=0;ready[bank]=false;} public bool AllowsAttack(DungeonCreature foe) { if(!foe||Answers.Count!=3)return false; var bank=foe.name=="hearth-last-blue"?Answers[0]:foe.name=="hearth-last-prism"?Answers[1]:Answers[2]; if(!ready[bank])return false; var feet=GameSession.I.Player.GetComponent().position;var b=bank.bounds; return feet.x>=b.min.x-.2f&&feet.x<=b.max.x+.2f&&feet.y>=b.max.y-.25f&&feet.y<=b.max.y+3; } void Update() { var g=GameSession.I;if(!g||!g.Playing||!g.Player||!DungeonRun.Inside||!DungeonRun.I||DungeonRun.I.CurrentRoom!="I"||!DungeonRun.I.Definition.LastHearth)return; var p=g.Player;var feet=p.GetComponent().position; if(serial!=p.TeleportSerial){serial=p.TeleportSerial;foreach(var c in Answers){grace[c]=0;ready[c]=false;}} foreach(var c in Answers) { var b=c.bounds;bool near=feet.x>=b.min.x-.2f&&feet.x<=b.max.x+.2f&&feet.y>=b.max.y-.25f&&feet.y<=b.max.y+3; if(!near){grace[c]=0;ready[c]=false;} bool supported=p.Grounded&&!p.Climbing&&!p.Flying&&Mathf.Abs(feet.y-b.max.y)<.09f&&feet.x>=b.min.x+.2f&&feet.x<=b.max.x-.2f; if(!ready[c]){grace[c]=supported?grace[c]+Time.deltaTime:0;if(grace[c]>0)ready[c]=true;} } } void OnDisable(){foreach(var c in Answers){grace[c]=0;ready[c]=false;}} } }