using System; using System.Collections; using System.Collections.Generic; using System.IO; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.InputSystem.LowLevel; namespace Auralis { public sealed partial class PrototypeQA { [Serializable] sealed class ContactPickupEvidence { public string scope="Eight physical fund families only: three Festival lanterns, Borun mantle, Sereva knot, Orvo compass, Aster mirror, Bell band, high shipyard pennant and three glass seeds. Disposable QA profile with explicitly saved campaign prerequisites. Room/bank arrivals, the mantle-room exit callback and missing/earned gate states are isolated setup fixtures; enemies are disabled to isolate acquisition, not defeated by this test. Each measured pickup uses ordinary horizontal movement and, where the authored sprite is high, an actual jump. No Interact, Claim or ceremony Advance callback is used to acquire/dismiss a reward. Actual A dismisses existing ceremonies. Gate/visibility/pause/dead/door/world-ready guards, exact old receipts, disk reload and duplicate rewards are separate checks. This does not revalidate boss fights, approach routes, difficulty, all story text or human visual quality. Velis' conversation gift, chest opening, doors, puzzles and the Festival release remain deliberate actions."; public List approaches=new(); } [Serializable] sealed class ContactPickupRow { public string id,level,receipt;public bool expected,acquired,rawOverlap,visibleOverlap,jumped,interact,groundedAtStart; public int serialBefore,serialAfter,deathsBefore,deathsAfter,frames;public Vector2 start,end;public Bounds item,body; } ContactPickupEvidence contactEvidence;string contactBasis; static bool ContactRaw(SpriteRenderer item,PlayerMotor2D player) { Bounds a=item.bounds,b=player.GetComponent().bounds; return a.min.x<=b.max.x&&a.max.x>=b.min.x&&a.min.y<=b.max.y&&a.max.y>=b.min.y; } static void ContactKey(SaveData data,string key,bool on) {data.mechanisms.RemoveAll(k=>k==key);if(on)data.mechanisms.Add(key);} IEnumerator ContactLoad(string level,Action prepare) { yield return MasterLoadWorld(JourneyMode.Adventure,level,contactBasis,d=> { d.checkpoint=0;d.Progress.completed=false;d.flight=false;d.autoHeal=d.fallRescue=d.gentle=false;d.healCharges=0; d.equipped.Clear();d.quietAtmosphere=true;d.textSize=2;d.introSeen=true;prepare(d); }); g.Begin();Clear();g.Input.Automated=true;VoiceDirector.I.AutomaticObjectives=false;VoiceDirector.I.Stop(); foreach(var enemy in EnemyAgent.All)if(enemy)enemy.enabled=false; yield return new WaitForSecondsRealtime(.5f); } IEnumerator ContactStand(Vector2 feet) { Clear();if(g.Paused)g.Pause(false);g.Player.Teleport(feet+Vector2.up*.035f);g.Camera.Snap(); yield return new WaitForSecondsRealtime(.5f); CheckResult("Contact fixture rests on an existing supported bank",g.Player.Grounded&&RescueFloor(g.Player.transform.position),"feet="+g.Player.transform.position+", requested="+feet); } IEnumerator ContactApproach(string id,SpriteRenderer item,Vector2 start,Func acquired,bool expected) { yield return ContactStand(start); var row=new ContactPickupRow{id=id,level=g.Save.Data.currentLevel,expected=expected,start=g.Player.transform.position,groundedAtStart=g.Player.Grounded,serialBefore=g.Player.TeleportSerial,deathsBefore=g.Deaths};contactEvidence.approaches.Add(row); CheckResult(id+" begins outside actual item/body contact and without its receipt",!ContactRaw(item,g.Player)&&!acquired(),"body="+g.Player.GetComponent().bounds+", item="+item.bounds); float end=Time.realtimeSinceStartup+5,contactTime=0;bool jumpEdge=false; while(Time.realtimeSinceStartup();float dx=item.bounds.center.x-box.bounds.center.x; g.Input.Move=new Vector2(Mathf.Abs(dx)>.10f?Mathf.Clamp(dx*2,-.5f,.5f):0,0); // Reach the hanging item by a normal jump from its existing bank. No pickup radius. if(!row.jumped&&g.Player.Grounded&&Mathf.Abs(dx)<.22f&&item.bounds.min.y>box.bounds.max.y-.04f) {g.Input.JumpPressed=true;g.Input.JumpHeld=true;row.jumped=true;jumpEdge=true;} else if(jumpEdge){g.Input.ClearEdges();jumpEdge=false;} row.interact|=g.Input.InteractPressed;row.frames++; bool overlap=ContactRaw(item,g.Player);row.rawOverlap|=overlap;row.visibleOverlap|=overlap&&item.enabled&&item.gameObject.activeInHierarchy; if(overlap)contactTime+=Time.unscaledDeltaTime; yield return null; } row.rawOverlap|=ContactRaw(item,g.Player);row.acquired=acquired();row.end=g.Player.transform.position;row.body=g.Player.GetComponent().bounds;row.item=item.bounds;row.serialAfter=g.Player.TeleportSerial;row.deathsAfter=g.Deaths;Clear(); string detail="start="+row.start+", end="+row.end+", overlap="+row.rawOverlap+", visible="+row.visibleOverlap+", jump="+row.jumped+", frames="+row.frames+", receipt="+row.acquired; CheckResult(id+" uses real continuous passive contact",row.frames>0&&row.rawOverlap&&!row.interact&&row.serialBefore==row.serialAfter&&row.deathsBefore==row.deathsAfter,detail); CheckResult(id+(expected?" acquires without Interact":" preserves the missing prerequisite"),row.acquired==expected,detail); } IEnumerator ContactCeremony(string name,RewardSymbol symbol,bool heart) { yield return null; CheckResult(name+" retains its original saved-reward ceremony",RewardCeremony.Active&&RewardCeremony.Active.Symbol==symbol&&g.Paused); if(!RewardCeremony.Active)yield break; yield return new WaitForSecondsRealtime(2.15f); if(symbol==RewardSymbol.Mantle||symbol==RewardSymbol.ShipyardPennant)yield return Shot("contact-"+symbol.ToString().ToLowerInvariant()); yield return MenuPress(GamepadButton.South); if(heart) {CheckResult(name+" keeps its separate heart stage",RewardCeremony.Active&&RewardCeremony.Active.Stage==1);yield return new WaitForSecondsRealtime(2.15f);yield return MenuPress(GamepadButton.South);} CheckResult(name+" actual A returns to the existing world",!RewardCeremony.Active&&!g.Paused);yield return new WaitForSecondsRealtime(.35f);Clear(); } IEnumerator ContactReceipt(string id,Func receipt) { string expected=receipt(g.Save.Data);int capacity=g.Save.Data.healthCapacity,wallet=g.Save.Data.sparks; yield return new WaitForSecondsRealtime(.65f); CheckResult(id+" remaining contact cannot repeat reward or ceremony",receipt(g.Save.Data)==expected&&capacity==g.Save.Data.healthCapacity&&wallet==g.Save.Data.sparks&&!RewardCeremony.Active,"receipt="+expected); var disk=new SaveService(g.Save.FilePath); CheckResult(id+" persists its original receipt without extra capacity or currency",receipt(disk.Data)==expected&&disk.Data.healthCapacity==capacity&&disk.Data.sparks==wallet,"live="+expected+", disk="+receipt(disk.Data)); } IEnumerator ContactReload(string id,Func receipt) { string before=receipt(g.Save.Data);int capacity=g.Save.Data.healthCapacity,wallet=g.Save.Data.sparks;var previous=g;g.SwitchProfile(g.Profiles.Selected);yield return AdoptSession(previous);g.Begin();Clear(); yield return new WaitForSecondsRealtime(.35f); CheckResult(id+" actual profile reload retains ownership with no ceremony replay",receipt(g.Save.Data)==before&&g.Save.Data.healthCapacity==capacity&&g.Save.Data.sparks==wallet&&!RewardCeremony.Active,"receipt="+receipt(g.Save.Data)); } void ContactGuardChecks(SpriteRenderer item) { // Synchronous lifecycle fixtures on a real body/item overlap; no Update may claim here. var p=g.Player;bool wasEnabled=item.enabled;item.enabled=true;Physics2D.SyncTransforms(); CheckResult("Guard fixture has a real visible item/body overlap",ContactRaw(item,p)&&ContactPickup.Touching(item)); g.Pause(true);CheckResult("Paused body contact is inert",!ContactPickup.Touching(item));g.Pause(false); int health=p.HealthHalfUnits;MasterSet(p,"healthHalfUnits",0);CheckResult("Dead body contact is inert",!ContactPickup.Touching(item));MasterSet(p,"healthHalfUnits",health); bool ready=g.WorldReady;MasterSet(g,"WorldReady",false);CheckResult("Unready world contact is inert",!ContactPickup.Touching(item));MasterSet(g,"WorldReady",ready); bool failed=g.WorldLoadFailed;MasterSet(g,"WorldLoadFailed",true);CheckResult("Failed world contact is inert",!ContactPickup.Touching(item));MasterSet(g,"WorldLoadFailed",failed); item.enabled=false;CheckResult("Hidden item contact is inert",!ContactPickup.Touching(item));item.enabled=true; item.gameObject.SetActive(false);CheckResult("Inactive item contact is inert",!ContactPickup.Touching(item));item.gameObject.SetActive(true); var body=p.GetComponent();body.enabled=false;CheckResult("Disabled player body cannot collect",!ContactPickup.Touching(item));body.enabled=true; Vector2 feet=p.transform.position;bool passage=p.BeginPassage(feet,()=>{}); CheckResult("Existing door-entry state suppresses body pickup",passage&&p.EnteringDoor&&!ContactPickup.Touching(item));p.Teleport(feet);Physics2D.SyncTransforms();item.enabled=wasEnabled; } IEnumerator ContactFestival() { yield return ContactLoad(LevelCatalog.Festival,d=>{d.Progress.mechanisms.RemoveAll(k=>k.StartsWith("festival-lantern-")||k==FestivalQuest.TrainingId);}); var quest=FestivalQuest.I;var items=MasterField(quest,"lanterns");var platform=WorldBuilder.Spec.platforms[7]; yield return ContactApproach("untrained lantern",items[0],new Vector2(items[0].transform.position.x+1.6f,platform.y),()=>quest.Count>0,false); // First lamp is low enough for actual ground contact; use that same item for shared guards. yield return ContactStand(new Vector2(items[0].transform.position.x,platform.y));ContactGuardChecks(items[0]); ContactKey(g.Save.Data,FestivalQuest.TrainingId,true);g.Save.Write(); for(int i=0;i<3;i++) { int n=i;var slab=WorldBuilder.Spec.platforms[new[]{7,12,19}[i]];float from=items[i].transform.position.x+(i==0?1.6f:-1.8f); // Pause setup prevents collection between the gate fixture and the measured approach. g.Pause(true);g.Player.Teleport(new Vector2(from,slab.y+.035f)); yield return ContactApproach("festival-lantern-"+i,items[i],new Vector2(from,slab.y),()=>g.Save.Data.mechanisms.Contains("festival-lantern-"+n),true); yield return new WaitForSecondsRealtime(.2f);var feedback=FindFirstObjectByType(); CheckResult("Lantern "+i+" retains pickup presentation and does not release the festival",feedback&&feedback.BannerVisible&&!g.Save.Data.Progress.completed); yield return ContactReceipt("lantern "+i,d=>d.mechanisms.FindAll(k=>k.StartsWith("festival-lantern-")).Count.ToString()); yield return new WaitForSecondsRealtime(3.7f); } yield return ContactReload("three lanterns",d=>d.mechanisms.FindAll(k=>k.StartsWith("festival-lantern-")).Count.ToString()); } IEnumerator ContactMantle() { yield return ContactLoad(LevelCatalog.SleepingMill,d=>{d.bossDefeated=true;d.borunRewardClaimed=d.glide=false;d.healthCapacity=3;ContactKey(d,"mill-mantle-found",false);ContactKey(d,"mill-treasure-door-open",true);ContactKey(d,"mill-mantle-flight-shown",false);}); var room=PocketRoom.All.Find(r=>r.Id==PocketRoom.MantleRoomId);CheckResult("Original mantle room is present and earned",room&&room.CanEnter);if(!room)yield break; room.Enter();yield return new WaitForSecondsRealtime(.4f);var item=MasterField(room,"mantleItem");Vector2 start=new(item.bounds.center.x-2.2f,room.Center.y); g.Save.Data.bossDefeated=false;yield return ContactApproach("mantle before Borun release",item,start,()=>g.Save.Data.borunRewardClaimed,false); g.Pause(true);g.Player.Teleport(start);g.Save.Data.bossDefeated=true;g.Save.Write(); yield return ContactApproach("Borun mantle",item,start,()=>g.Save.Data.borunRewardClaimed,true);yield return ContactCeremony("mantle",RewardSymbol.Mantle,true); CheckResult("Mantle retains glide, one heart and the old key",g.Save.Data.glide&&g.Save.Data.healthCapacity==4&&g.Save.Data.mechanisms.Contains("mill-mantle-found")); yield return ContactReceipt("mantle",d=>d.glide+"/"+d.borunRewardClaimed+"/"+d.mechanisms.FindAll(k=>k=="mill-mantle-found").Count); room.Exit();yield return new WaitForSecondsRealtime(.25f);yield return ContactCeremony("original first-glide explanation after room exit",RewardSymbol.Item,false); CheckResult("Existing first-glide explanation keeps its separate once-only receipt",g.Save.Data.mechanisms.Contains("mill-mantle-flight-shown")); yield return ContactReload("mantle",d=>d.glide+"/"+d.borunRewardClaimed+"/"+d.mechanisms.Contains("mill-mantle-found")); } IEnumerator ContactSereva() { yield return ContactLoad(LevelCatalog.Aqueduct,d=>{d.resonance=false;ContactKey(d,SerevaBoss.FreedKey,false);ContactKey(d,ResonanceChamber.SealKey,false);}); var c=ResonanceChamber.I;var boss=SerevaArena.I.Boss;boss.enabled=false;var item=MasterField(c,"gift");Vector2 start=new(c.Gift.x-2.3f,0); yield return ContactApproach("knot before Sereva release",item,start,()=>g.Save.Data.resonance,false); g.Pause(true);g.Player.Teleport(start);ContactKey(g.Save.Data,SerevaBoss.FreedKey,true);g.Save.Write(); yield return ContactApproach("Sereva knot",item,start,()=>g.Save.Data.resonance,true);yield return ContactCeremony("resonance knot",RewardSymbol.Resonance,false); CheckResult("Collecting resonance does not operate the crystal seal",!c.Open&&!g.Save.Data.Progress.completed); yield return ContactReceipt("resonance",d=>d.resonance.ToString());yield return ContactReload("resonance",d=>d.resonance.ToString()); } IEnumerator ContactOrvo() { yield return ContactLoad(LevelCatalog.Belfry,d=>{d.windReading=false;d.healthCapacity=7;ContactKey(d,OrvoBoss.FreedKey,false);ContactKey(d,OrvoWindGift.PracticeKey,false);}); var r=OrvoRoof.I;var gift=OrvoWindGift.I;var item=MasterField(gift,"gift");r.Boss.enabled=false;Vector2 start=r.Landing+Vector2.left*2.8f; yield return ContactApproach("compass before Orvo release",item,start,()=>g.Save.Data.windReading,false); g.Pause(true);g.Player.Teleport(start);ContactKey(g.Save.Data,OrvoBoss.FreedKey,true);g.Save.Write();r.Boss.ResetEncounter(); yield return ContactApproach("Orvo compass",item,start,()=>g.Save.Data.windReading,true);yield return ContactCeremony("wind compass",RewardSymbol.WindReading,true); CheckResult("Wind compass preserves eighth heart and leaves practical wind lesson open",g.Save.Data.healthCapacity==8&&!gift.Practiced); yield return ContactReceipt("wind reading",d=>d.windReading.ToString());yield return ContactReload("wind reading",d=>d.windReading.ToString()); } IEnumerator ContactAster() { yield return ContactLoad(ObservatoryWorld.LevelId,d=> { d.mirrorWeave=false;d.healthCapacity=8;foreach(string key in new[]{"observatory-axis-0","observatory-axis-1","observatory-axis-2",ObservatoryWorld.WestShortcutKey,ObservatoryWorld.EastShortcutKey})ContactKey(d,key,true); ContactKey(d,AsterBoss.FreedKey,false);ContactKey(d,AsterMirrorGift.PracticeKey,false);ContactKey(d,ObservatoryWorld.CompleteKey,false); }); var boss=AsterBoss.I;boss.enabled=false;ObservatoryWorld.I.Enter(4,768,691);yield return new WaitForSecondsRealtime(.4f); var gift=AsterMirrorGift.I;var item=MasterField(gift,"gift");Vector2 start=boss.FloorCenter+Vector2.right*1; yield return ContactApproach("mirror before Aster release",item,start,()=>g.Save.Data.mirrorWeave,false); g.Pause(true);g.Player.Teleport(start);ContactKey(g.Save.Data,AsterBoss.FreedKey,true);g.Save.Write();boss.ResetEncounter(); yield return ContactApproach("Aster mirror",item,start,()=>g.Save.Data.mirrorWeave,true);yield return ContactCeremony("mirror weave",RewardSymbol.MirrorWeave,true); CheckResult("Mirror reward preserves ninth heart without training completion or flight",g.Save.Data.healthCapacity==9&&!gift.Practiced&&!g.Save.Data.flight&&!g.Save.Data.Progress.completed); yield return ContactReceipt("mirror weave",d=>d.mirrorWeave.ToString());yield return ContactReload("mirror weave",d=>d.mirrorWeave.ToString()); } IEnumerator ContactBand() { yield return ContactLoad(LevelCatalog.BellWatch,d=>{d.purchases.RemoveAll(k=>k==BellWatchToolDepot.ItemId);ContactKey(d,BellWatchTwinCourt.CompleteKey,false);ContactKey(d,BellWatchTwinCourt.LeftId+"-solved",false);ContactKey(d,BellWatchTwinCourt.RightId+"-solved",false);}); var depot=BellWatchToolDepot.I;depot.Room.Enter();yield return new WaitForSecondsRealtime(.4f);var item=MasterField(depot,"band");Vector2 start=depot.At(490,756); yield return ContactApproach("band before station completion",item,start,()=>depot.Owned,false); g.Pause(true);g.Player.Teleport(start);ContactKey(g.Save.Data,BellWatchTwinCourt.CompleteKey,true);g.Save.Write(); yield return ContactApproach("earned Bell band",item,start,()=>depot.Owned,true);yield return ContactCeremony("bell band",RewardSymbol.BellBand,false); CheckResult("Band is owned but never equipped automatically",depot.Owned&&!g.Save.Data.equipped.Contains(BellWatchToolDepot.ItemId)); yield return ContactReceipt("bell band",d=>d.purchases.FindAll(k=>k==BellWatchToolDepot.ItemId).Count.ToString()); // Contact with Tavi remains only a prompt: no conversation without Interact. yield return ContactStand(depot.At(1050,756));yield return new WaitForSecondsRealtime(.3f); CheckResult("Walking into Tavi does not start a conversation",g.Playing&&!g.Hud.ActiveMenu&&!RewardCeremony.Active); yield return ContactReload("bell band",d=>d.purchases.FindAll(k=>k==BellWatchToolDepot.ItemId).Count.ToString()); } IEnumerator ContactPennant() { yield return ContactLoad(LevelCatalog.WindFerry,d=>d.collected.RemoveAll(k=>k==FerryPennantWalk.PennantKey)); var w=FerryPennantWalk.I;w.Ray.enabled=false;var item=MasterField(w,"pennant");Vector2 start=w.At(1050,201); yield return ContactStand(new Vector2(item.bounds.center.x,w.At(1178,201).y));yield return new WaitForSecondsRealtime(.25f); CheckResult("Standing below the high pennant does not collect at a distance",!w.Found&&!ContactRaw(item,g.Player)); yield return ContactApproach("high shipyard pennant",item,start,()=>w.Found,true);yield return ContactCeremony("pennant",RewardSymbol.ShipyardPennant,false); CheckResult("Pennant uses an actual upward jump on its original high bank",contactEvidence.approaches[contactEvidence.approaches.Count-1].jumped); yield return ContactReceipt("pennant",d=>d.collected.FindAll(k=>k==FerryPennantWalk.PennantKey).Count.ToString());yield return ContactReload("pennant",d=>d.collected.FindAll(k=>k==FerryPennantWalk.PennantKey).Count.ToString()); } IEnumerator ContactSeeds() { yield return ContactLoad(GlassGardenWorld.LevelId,d=>{d.mechanisms.RemoveAll(k=>k.StartsWith("glass-star-seed-")||k.StartsWith("glass-guard-freed-")||k=="archive-mirror-freed-glass-terrace"||k==GlassGardenWorld.CompleteKey);}); var w=GlassGardenWorld.I;foreach(var guard in w.Guards)guard.enabled=false;w.Beetle.enabled=false;var items=MasterField(w,"seedImages"); float[] y={302,336,438};float[] x={1150,730,1220}; for(int i=0;i<3;i++) { int index=i;w.Enter(i,x[i],y[i]);yield return new WaitForSecondsRealtime(.4f);Vector2 start=GlassGardenWorld.At(i,x[i],y[i]); yield return ContactApproach("guarded glass seed "+i,items[i],start,()=>GlassGardenWorld.HasSeed(index),false); // Explicit defeated-guard prerequisites only; this suite does not claim combat. g.Pause(true);g.Player.Teleport(start); int[] guards=i==0?new[]{0}:i==1?new[]{1}:new[]{2,3};foreach(int n in guards){MasterSet(w.Guards[n],"Health",0);ContactKey(g.Save.Data,w.Guards[n].SaveKey,true);} if(i==1){MasterSet(w.Beetle,"Health",0);ContactKey(g.Save.Data,w.Beetle.SaveKey,true);}g.Save.Write(); yield return ContactApproach("earned glass seed "+i,items[i],start,()=>GlassGardenWorld.HasSeed(index),true); yield return ContactReceipt("glass seed "+i,d=>d.mechanisms.FindAll(k=>k.StartsWith("glass-star-seed-")).Count.ToString()); } CheckResult("Three contact seeds remain carried until deliberate planting",GlassGardenWorld.SeedCount==3&&!GlassGardenWorld.Complete&&!g.Save.Data.Progress.completed); yield return ContactReload("three glass seeds",d=>d.mechanisms.FindAll(k=>k.StartsWith("glass-star-seed-")).Count.ToString()); } IEnumerator ContactPickupChecks() { bool isolated=g.QA&&g.Save.FilePath.IndexOf("AuralisProfileQA",StringComparison.OrdinalIgnoreCase)>=0; CheckResult("Contact pickup suite is restricted to disposable QA profiles",isolated);if(!isolated)yield break; contactEvidence=new ContactPickupEvidence();File.WriteAllText(Path.Combine(folder,"scope.txt"),contactEvidence.scope); bool oldCeremony=RewardCeremony.EnableInQA,oldStory=StoryTransition.EnableInQA;RewardCeremony.EnableInQA=true;StoryTransition.EnableInQA=false;menuPad=InputSystem.AddDevice(); try { CrownHeartPrerequisite();contactBasis=JsonUtility.ToJson(g.Save.Data);Screen.SetResolution(1920,1080,FullScreenMode.Windowed); yield return ContactFestival();yield return ContactMantle();yield return ContactSereva();yield return ContactOrvo();yield return ContactAster();yield return ContactBand();yield return ContactPennant();yield return ContactSeeds(); } finally { Clear();RewardCeremony.EnableInQA=oldCeremony;StoryTransition.EnableInQA=oldStory; if(menuPad!=null){InputSystem.RemoveDevice(menuPad);menuPad=null;} File.WriteAllText(Path.Combine(folder,"contact-pickup.json"),JsonUtility.ToJson(contactEvidence,true)); } } } }