using System; using UnityEngine; namespace Auralis { // Source-image coordinates refer to the actual banks authored by the four worlds. // Enemy predicates pacify completed places; pickups remain available on revisits. public static class ChapterSixPopulation { const string Prefix="pop46-6-"; public static void Build() { if(!GameSession.I)return; switch(GameSession.I.Save.Data.currentLevel) { case OpenSkyWorld.LevelId:if(OpenSkyWorld.I)Sky();break; case SecondsCityWorld.LevelId:if(SecondsCityWorld.I)Seconds();break; case LastConnectionWorld.LevelId:if(LastConnectionWorld.I)Connection();break; case CrownHeartWorld.LevelId:if(CrownHeartWorld.I)Crown();break; } } static bool Outside(string level,int actual,int expected)=>GameSession.I&&GameSession.I.Save.Data.currentLevel==level &&actual==expected&&!DungeonRun.Inside&&!PocketRoom.Active; static Rect Zone(Vector2 left,Vector2 right,float height=5.4f)=>Rect.MinMaxRect(left.x,left.y+.05f,right.x,left.y+height); static void CrownAt(Transform root,string id,Vector2 feet,Vector2 left,Vector2 right,Func active,bool intro=false) { id=Prefix+id;var actor=Kronenscherbe.Create(root,id,feet+Vector2.up*1.6f,Zone(left,right),active,intro); CampaignPopulation.Placements.Add(new CampaignPopulation.Placement{Id=id,Kind="Kronenscherbe",From=left,To=right,Count=1,Value=3,Available=active,Actor=actor,Airborne=true}); } static Func Pair(Transform root,string id,Vector2 first,Vector2 second,Rect bounds,Func active,bool sequential=false) { Kronensplitter lead=null;var members=new Kronensplitter[2]; for(int i=0;i<2;i++) { // Keep both historical member IDs. The first lesson exposes one // creature; the second follows only an earned first release, // including when that release was saved in an earlier session. Func available=active; if(sequential&&i>0)available=()=> (active==null||active())&&lead&&!lead.Alive; string key=Prefix+id+"-"+i;var actor=Kronensplitter.Create(root,key,i==0?first:second,bounds,available,i*.7f); members[i]=actor;if(i==0)lead=actor; CampaignPopulation.Placements.Add(new CampaignPopulation.Placement{Id=key,Kind="Kronensplitter",From=bounds.min,To=bounds.max,Count=1,Value=1,Available=available,Actor=actor,Airborne=true}); } return ()=>members[0]&&members[1]&&!members[0].Alive&&!members[1].Alive; } static void Hearts(Transform root,string id,Vector2 a,Vector2 b,Func active,int value=2) =>CampaignPopulation.Hearts(root,Prefix+id,a+Vector2.up*.7f,b+Vector2.up*.7f,3,value,active); static void Supply(Transform root,string id,Vector2 feet,SupplyKind kind,int count,Func active) =>CampaignPopulation.Supply(root,Prefix+id,feet+Vector2.up*.65f,kind,count,active); static void Sky() { var w=OpenSkyWorld.I; Func room=r=>Outside(OpenSkyWorld.LevelId,OpenSkyWorld.Area,r); // Initial bank 0..463 is entirely safe. The new stationary introduction is // on the lower 555..1090 island, after the first actual free-flight crossing. CrownAt(w.RoomRoot(0),"sky-first-crown",OpenSkyWorld.At(0,700,749),OpenSkyWorld.At(0,580,749),OpenSkyWorld.At(0,810,749),()=>room(0)&&!OpenSkyWorld.Complete,true); // Existing room 1 contains the familiar three-ray formation. Room 2 (rest) // and room 3 (shield lesson) gain no enemies. On the late rim, first // land on the wide fixed gallery, learn one small splinter, then // repeat it. Historical member receipts survive this relocation. Pair(w.RoomRoot(4),"sky-rim-little",OpenSkyWorld.At(4,770,275),OpenSkyWorld.At(4,855,275), Zone(OpenSkyWorld.At(4,735,329),OpenSkyWorld.At(4,890,329)), ()=>room(4)&&!OpenSkyWorld.Complete&&CrownRimPlatformPassage.I&&CrownRimPlatformPassage.I.CombatReady,sequential:true); // The larger known crown wakes only after a true lower-floor // landing. Neither fragile return step becomes a fighting perch. CrownAt(w.RoomRoot(4),"sky-rim-crown",OpenSkyWorld.At(4,1120,584),OpenSkyWorld.At(4,1010,584),OpenSkyWorld.At(4,1250,584), ()=>room(4)&&!OpenSkyWorld.Complete&&CrownRimPlatformPassage.I&&CrownRimPlatformPassage.I.LowerCombatReady); // The only optional little group is on the lower bank, well below Alma's // upper workbench, the trial doorway and the permanent return bridge. Pair(w.RoomRoot(5),"sky-upper-little",OpenSkyWorld.At(5,550,567),OpenSkyWorld.At(5,660,567), Zone(OpenSkyWorld.At(5,470,620),OpenSkyWorld.At(5,760,620)),()=>room(5)&&!OpenSkyWorld.Complete); Hearts(w.RoomRoot(0),"sky-safe-start",OpenSkyWorld.At(0,330,563),OpenSkyWorld.At(0,410,563),()=>room(0)); Hearts(w.RoomRoot(0),"sky-first-return",OpenSkyWorld.At(0,900,749),OpenSkyWorld.At(0,1010,749),()=>room(0)); Hearts(w.RoomRoot(1),"sky-middle-isle",OpenSkyWorld.At(1,710,668),OpenSkyWorld.At(1,830,668),()=>room(1)); Hearts(w.RoomRoot(1),"sky-ray-return",OpenSkyWorld.At(1,1190,472),OpenSkyWorld.At(1,1290,472),()=>room(1)); Hearts(w.RoomRoot(3),"sky-shield-return",OpenSkyWorld.At(3,1210,329),OpenSkyWorld.At(3,1310,329),()=>room(3)&&OpenSkyWorld.Has(OpenSkyWorld.DeflectedKey)); Hearts(w.RoomRoot(4),"sky-crown-return",OpenSkyWorld.At(4,1260,584),OpenSkyWorld.At(4,1320,584),()=>room(4)); Hearts(w.RoomRoot(5),"sky-optional-low",OpenSkyWorld.At(5,850,620),OpenSkyWorld.At(5,960,620),()=>room(5)); Hearts(w.RoomRoot(4),"sky-optional-high",OpenSkyWorld.At(4,775,329),OpenSkyWorld.At(4,845,329),()=>room(4)); Supply(w.RoomRoot(2),"sky-rest-potion",OpenSkyWorld.At(2,865,592),SupplyKind.Potion,1,()=>room(2)); Supply(w.RoomRoot(0),"sky-flight-feathers",OpenSkyWorld.At(0,1040,749),SupplyKind.WindFeather,3,()=>room(0)); } static void Seconds() { var w=SecondsCityWorld.I; Func room=r=>Outside(SecondsCityWorld.LevelId,SecondsCityWorld.Area,r); // Clock guard (square 0) and canal beetle (square 2) already exist. The // familiar upper-left guardian precedes the crown's return in square 1. CampaignPopulation.Bank(w.RoomRoot(0),Prefix+"seconds-left-guard",EnemyKind.Guardian, SecondsCityWorld.At(0,450,351),SecondsCityWorld.At(0,590,351),available:()=>room(0)&&!SecondsCityWorld.Connected(0)); Func crownReady=()=> { if(!room(1)||SecondsCityWorld.Connected(1))return false; if(w.ConnectedRoutes[1])return w.ConnectedRoutes[1].CanFight(w.Banks["1-left"]); return true; }; // Before the thread and connector, so connecting the square does not hide // an encounter that the player has not yet reached. The letter at 338 and // landing at 180 are outside its bounded attack bay. CrownAt(w.RoomRoot(1),"seconds-thread-crown",SecondsCityWorld.At(1,525,366), SecondsCityWorld.At(1,430,366),SecondsCityWorld.At(1,625,366),crownReady); // Reuse the small family learned at the crown rim. The broad left // roof provides a grounded answer before the canal descent; the // arrival at 245, Enna below, and the right-hand reflection stay safe. var roofCleared=Pair(w.RoomRoot(2),"seconds-roof-little",SecondsCityWorld.At(2,505,250),SecondsCityWorld.At(2,605,250), Zone(SecondsCityWorld.At(2,460,313),SecondsCityWorld.At(2,650,313)),()=>room(2)&&!SecondsCityWorld.Connected(2),sequential:true); Hearts(w.RoomRoot(0),"seconds-lower-return",SecondsCityWorld.At(0,730,725),SecondsCityWorld.At(0,810,725),()=>room(0)); Hearts(w.RoomRoot(0),"seconds-upper-return",SecondsCityWorld.At(0,1110,350),SecondsCityWorld.At(0,1190,350),()=>room(0)); Hearts(w.RoomRoot(1),"seconds-left-bank",SecondsCityWorld.At(1,410,366),SecondsCityWorld.At(1,470,366),()=>room(1)); Hearts(w.RoomRoot(1),"seconds-thread-return",SecondsCityWorld.At(1,970,366),SecondsCityWorld.At(1,1035,366),()=>room(1)); Hearts(w.RoomRoot(2),"seconds-canal-return",SecondsCityWorld.At(2,565,674),SecondsCityWorld.At(2,640,674),()=>room(2)); Hearts(w.RoomRoot(2),"seconds-roof-return",SecondsCityWorld.At(2,1220,377),SecondsCityWorld.At(2,1290,377),()=>room(2)); // The cache also survives a peaceful connected revisit, where the // creatures no longer appear. Each pickup still pays only once. Hearts(w.RoomRoot(2),"seconds-roof-release",SecondsCityWorld.At(2,650,313),SecondsCityWorld.At(2,700,313),()=>room(2)&&(roofCleared()||SecondsCityWorld.Connected(2))); Hearts(w.RoomRoot(0),"seconds-optional-left-roof",SecondsCityWorld.At(0,485,351),SecondsCityWorld.At(0,555,351),()=>room(0)); Hearts(w.RoomRoot(2),"seconds-optional-high",SecondsCityWorld.At(2,540,313),SecondsCityWorld.At(2,630,313),()=>room(2)); Supply(w.RoomRoot(1),"seconds-safe-potion",SecondsCityWorld.At(1,885,749),SupplyKind.Potion,1,()=>room(1)); Supply(w.RoomRoot(2),"seconds-flight-feathers",SecondsCityWorld.At(2,655,674),SupplyKind.WindFeather,3,()=>room(2)); } static void Connection() { var w=LastConnectionWorld.I; Func room=r=>Outside(LastConnectionWorld.LevelId,LastConnectionWorld.Area,r); // The existing patrol now occupies an outer approach court. Its old // receipt survives, and any completed alternative pacifies the approach. CampaignPopulation.Bank(w.RoomRoot(0),Prefix+"connection-low-patrol",EnemyKind.Hopper, w.SpatialApproach.PatrolLeft,w.SpatialApproach.PatrolRight, available:()=>room(0)&&!LastConnectionWorld.AnyRouteComplete&&!w.SpatialApproach.Peaceful); Hearts(w.RoomRoot(0),"connection-axis-low",LastConnectionWorld.At(0,800,842),LastConnectionWorld.At(0,890,842),()=>room(0)); Hearts(w.RoomRoot(0),"connection-axis-high",LastConnectionWorld.At(0,425,247),LastConnectionWorld.At(0,515,247),()=>room(0)); Hearts(w.RoomRoot(3),"connection-flight-start",LastConnectionWorld.At(3,370,479),LastConnectionWorld.At(3,460,479),()=>room(3)); Hearts(w.RoomRoot(3),"connection-flight-arrival",LastConnectionWorld.At(3,1080,289),LastConnectionWorld.At(3,1170,289),()=>room(3)); // Equal new route-return reward: 3 x 3 hearts for each individual route. // Combat's reward is outside U11 at its real hub return; no second branch // or all-routes flag is required to make any of these appear. Hearts(w.RoomRoot(1),"connection-glide-reward",LastConnectionWorld.At(1,1360,496),LastConnectionWorld.At(1,1420,496),()=>room(1)&&LastConnectionWorld.RouteComplete(0),3); Hearts(w.RoomRoot(0),"connection-combat-reward",LastConnectionWorld.At(0,600,842),LastConnectionWorld.At(0,665,842),()=>room(0)&&LastConnectionWorld.RouteComplete(1),3); Hearts(w.RoomRoot(2),"connection-mirror-reward",LastConnectionWorld.At(2,1330,813),LastConnectionWorld.At(2,1395,813),()=>room(2)&&LastConnectionWorld.RouteComplete(2),3); Supply(w.RoomRoot(0),"connection-axis-feathers",LastConnectionWorld.At(0,840,842),SupplyKind.WindFeather,3,()=>room(0)); } static void Crown() { var w=CrownHeartWorld.I; Func room=r=>Outside(CrownHeartWorld.LevelId,CrownHeartWorld.Area,r); // Two short encounter places in total: this familiar crown on the wide // approach, then the existing hopper/beetle court. Upper bypass stays open. CrownAt(w.RoomRoot(0),"heart-approach-crown",CrownHeartWorld.At(0,800,674), CrownHeartWorld.At(0,650,674),CrownHeartWorld.At(0,950,674),()=>room(0)&&!CrownHeartWorld.Defeated); Hearts(w.RoomRoot(0),"heart-approach-return",CrownHeartWorld.At(0,1120,674),CrownHeartWorld.At(0,1230,674),()=>room(0)); Hearts(w.RoomRoot(1),"heart-court-low",CrownHeartWorld.At(1,735,804),CrownHeartWorld.At(1,835,804),()=>room(1)); Hearts(w.RoomRoot(2),"heart-vista-low",CrownHeartWorld.At(2,625,758),CrownHeartWorld.At(2,725,758),()=>room(2)); Hearts(w.RoomRoot(0),"heart-optional-upper",CrownHeartWorld.At(0,825,386),CrownHeartWorld.At(0,905,386),()=>room(0)); Supply(w.RoomRoot(1),"heart-court-feathers",CrownHeartWorld.At(1,565,804),SupplyKind.WindFeather,3,()=>room(1)); Supply(w.RoomRoot(2),"heart-last-lantern-potion",CrownHeartWorld.At(2,1040,758),SupplyKind.Potion,1,()=>room(2)); // No additions in the arena, rescue or epilogue. } } }