using System; using UnityEngine; using UnityEngine.Rendering.Universal; namespace Auralis { [Serializable] public class PlatformSpec { public string id,art,surface;public float x,y,width,liftAmplitude;public bool stone,oneWay;public int zone,artFrame; } [Serializable] public class BridgeSpec { public string id;public float x,y,endX; } [Serializable] public class PointSpec { public float x,y; } [Serializable] public class EnemySpec:PointSpec { public string id;public int kind;public float patrol; } [Serializable] public class SignSpec:PointSpec { public string text; } [Serializable] public class RouteSpec { public int start,end;public string mode; } [Serializable] public class LevelSpec { public string name;public PlatformSpec[] platforms;public BridgeSpec[] bridges;public PointSpec[] checkpoints;public EnemySpec[] enemies;public SignSpec[] signs;public RouteSpec[] routes; } public static partial class WorldBuilder { public const float ArenaStart=-12,ArenaEnd=18,ArenaY=84.6f; public static LevelSpec Spec; // Only the empty space below the whole playable world counts as a lost fall. static float worldVoidY; public static float VoidY=>DungeonRun.Inside?DungeonRun.I.Origin.y+Mathf.Min(DungeonRun.I.Room.LowestFloor,DungeonRun.I.LocalRoomBounds.yMin)-10:PocketRoom.Active?PocketRoom.Active.Center.y-10:worldVoidY; public static WeaveBridge ArenaBridge; public static bool IsLastConnection=>GameSession.I.Save.Data.currentLevel==LevelCatalog.LastConnection; public static bool IsSecondsCity=>GameSession.I.Save.Data.currentLevel==LevelCatalog.SecondsCity; public static bool IsCrownHeart=>GameSession.I.Save.Data.currentLevel==LevelCatalog.CrownHeart; public static bool IsOpenSky=>GameSession.I.Save.Data.currentLevel==LevelCatalog.OpenSky; public static bool IsRiver=>GameSession.I.Save.Data.currentLevel==LevelCatalog.RiverWithoutBanks; public static bool IsMistWorkshop=>GameSession.I.Save.Data.currentLevel==LevelCatalog.MistWorkshop; public static bool IsRootCathedral=>GameSession.I.Save.Data.currentLevel==LevelCatalog.RootCathedral; public static bool IsNightRoots=>GameSession.I.Save.Data.currentLevel==LevelCatalog.SleepingIslands; public static bool IsFestival=>GameSession.I.Save.Data.currentLevel==LevelCatalog.Festival; public static bool IsWindSchool=>GameSession.I.Save.Data.currentLevel==LevelCatalog.WindSchool; public static bool IsAscent=>GameSession.I.Save.Data.currentLevel==LevelCatalog.Ascent; public static bool IsFirstThread=>GameSession.I.Save.Data.currentLevel==LevelCatalog.FirstThread; public static bool IsCloudGardens=>GameSession.I.Save.Data.currentLevel==LevelCatalog.CloudGardens; public static bool IsSleepingMill=>GameSession.I.Save.Data.currentLevel==LevelCatalog.SleepingMill; public static bool IsWaterways=>GameSession.I.Save.Data.currentLevel==LevelCatalog.Waterways; public static bool IsScaffold=>GameSession.I.Save.Data.currentLevel==LevelCatalog.Scaffold; public static bool IsRainGarden=>GameSession.I.Save.Data.currentLevel==LevelCatalog.RainGarden; public static bool IsBellWatch=>GameSession.I.Save.Data.currentLevel==LevelCatalog.BellWatch; public static bool IsObservatory=>GameSession.I.Save.Data.currentLevel==LevelCatalog.Observatory; public static bool IsGlassGarden=>GameSession.I.Save.Data.currentLevel==LevelCatalog.GlassGarden; public static bool IsArchiveMemory=>GameSession.I.Save.Data.currentLevel==LevelCatalog.ArchiveMemory; public static bool IsStarArchive=>GameSession.I.Save.Data.currentLevel==LevelCatalog.StarArchive; public static bool IsBelfry=>GameSession.I.Save.Data.currentLevel==LevelCatalog.Belfry; public static bool IsWindFerry=>GameSession.I.Save.Data.currentLevel==LevelCatalog.WindFerry; public static bool IsCoast=>GameSession.I.Save.Data.currentLevel==LevelCatalog.Coast; public static bool IsAqueduct=>GameSession.I.Save.Data.currentLevel==LevelCatalog.Aqueduct; public static bool HasBorun=>IsAscent||IsSleepingMill; public static bool IsVillage=>IsFestival||IsWindSchool; public static Vector2 Checkpoint(int n){var p=Spec.checkpoints[Mathf.Clamp(n,0,Spec.checkpoints.Length-1)];return new Vector2(p.x,p.y+.08f);} public static string Region(float y)=>DungeonRun.Inside?DungeonRun.I.Room.Title:IsLastConnection?(PocketRoom.Active?PocketRoom.Active.Title:LastConnectionWorld.Names[LastConnectionWorld.Area]):IsSecondsCity?SecondsCityWorld.Names[SecondsCityWorld.Area]:IsCrownHeart?CrownHeartWorld.Names[CrownHeartWorld.Area]:IsOpenSky?OpenSkyWorld.Names[OpenSkyWorld.Area]:IsRiver?RiverWithoutBanksWorld.Names[RiverWithoutBanksWorld.Area]:IsRootCathedral?RootCathedralWorld.Names[RootCathedralWorld.Area]:IsMistWorkshop?MistWorkshopWorld.Names[MistWorkshopWorld.Area]:IsNightRoots?NightRootsWorld.Names[NightRootsWorld.Area]:IsObservatory?ObservatoryWorld.Names[ObservatoryWorld.Area]:IsGlassGarden?GlassGardenWorld.Names[GlassGardenWorld.Area]:IsArchiveMemory?(GameSession.I.Player?ArchiveMemoryWorld.Names[ArchiveMemoryWorld.Area]:"Schwelle der Erinnerungen"):IsStarArchive?(GameSession.I.Player?StarArchiveWorld.Names[StarArchiveWorld.Area]:"Kompassanleger"):IsBelfry?(OrvoRoof.Inside?"Orvos Dach":BelfryWindWindow.Inside?"Das offene Windfenster":BelfrySideGallery.Inside?"Der zweite Glockenumlauf":BelfrySpatialRoute.I&&BelfrySpatialRoute.I.OnAscent?"Der äußere Glockenstieg":"Die untere Glockenhalle"):IsWindFerry?(PocketRoom.Active&&PocketRoom.Active.Id==ShipyardCourierTrial.RoomId?"Werftkurier":GameSession.I.Player?ShipyardJourney.Names[ShipyardJourney.Area]:"Die schwebende Werft"):IsBellWatch?(PocketRoom.Active&&PocketRoom.Active.Id==BellQuietTrial.RoomId?"Glockenruhe":BellWatchToolDepot.Inside?"Tavis Werkzeugdepot":BellWatchTwinCourt.Inside?"Der Doppelhof":BellWatchTerraces.Inside?"Die Wachterrassen":"Der erste Alarmhof"):IsCoast&&!PocketRoom.Active?(CoastWindNiche.Inside?"Die obere Windnische":CoastBridge.Inside?"Die Küstenbrücke":GameSession.I.Player&&GameSession.I.Player.transform.position.x>=19?"Der Kristallengang":"Der Windvorhof"):IsRainGarden&&!PocketRoom.Active&&RainGardenCourts.I?RainGardenCourts.I.Place:IsScaffold&&!PocketRoom.Active?ScaffoldQuest.Place(y):IsWaterways&&!PocketRoom.Active?WaterwaysQuest.Place(GameSession.I.Player.transform.position.x):RegionLegacy(y); static string RegionLegacy(float y)=>PocketRoom.Active?PocketRoom.Active.Title:IsSleepingMill?SleepingMillQuest.RoomName(GameSession.I.Player?GameSession.I.Player.transform.position:Vector3.zero):IsCloudGardens?(y<8?"Der Gärtnerhof":y<18?"Die beiden Blütenbahnen":y<24?"Hinter der Zisterne":y<39?"Die große Saatmaschine":"Am stillen Mühlentor"):IsFirstThread?(y<11?"Maras Fadenhof":y<22?"Die Sanduhrgalerie":y<34?"Der Wächterhof":y<43?"Das Sonnenrad":"Tavis Mühlenwerkstatt"):IsWindSchool?(y<5?"Maras Bewegungsgarten":y<12?"Die Klettergalerie":"Über dem Windübungsplatz"):IsFestival?(y<6?"Maras Bogenplatz":y<15?"Die Jasmingalerie":y<25?"Über den Dächern":y<34?"Die Drachenwerkstatt":"Der Laternenplatz"):(y<12?"Windlaternen-Garten":y<28?"Das alte Aquädukt":y<44?"Das Haus der Weber":y<64?"Der Mühlenaufzug":y<83?"Über den Wolkenbeeten":"Die Krone der Windmühle"); public static void Build() { Spec=JsonUtility.FromJson(Resources.Load(GameSession.I.Level.Resource).text); float lowest=0; foreach(var platform in Spec.platforms)lowest=Mathf.Min(lowest,platform.y-Mathf.Abs(platform.liftAmplitude)); worldVoidY=lowest-10; var root=new GameObject(GameSession.I.Level.Title).transform; var global=new GameObject("Morning light").AddComponent();global.lightType=Light2D.LightType.Global;global.color=new Color(1,.96f,.87f);global.intensity=.98f; for(int i=0;i().Init(b.id,new Vector2(b.x,b.y),new Vector2(b.endX,b.y));} ArenaBridge=null; if(HasBorun){var refuge=new GameObject("Boruns Windfaden");refuge.transform.SetParent(root);ArenaBridge=refuge.AddComponent();ArenaBridge.Init("borun-refuge",new Vector2(-4,ArenaY+1.8f),new Vector2(4,ArenaY+1.8f));refuge.SetActive(false);} if(!IsLastConnection&&!IsSecondsCity&&!IsCrownHeart)for(int i=0;i().Init(e.id,(EnemyKind)e.kind,MillSunUpperEncounter.ResolveSpawn(e.id,new Vector2(e.x,e.y)),e.patrol);} for(int i=0;i().Init(InteractableKind.Sign,"ascent-sign-"+i,0,s.text); } if(IsLastConnection){worldVoidY=-12;global.color=new Color(.96f,.92f,1);global.intensity=.96f;LastConnectionWorld.Create(root);return;} if(IsSecondsCity){worldVoidY=-12;global.color=new Color(1,.96f,.87f);global.intensity=.98f;SecondsCityWorld.Create(root);DungeonRun.Create(root,DungeonDefinition.LastHearthRooms(SecondsCityWorld.I.UnderworldEntrance));SecondsCitySoundscape.Create(root);return;} if(IsCrownHeart){worldVoidY=-12;global.color=new Color(.95f,.92f,1);global.intensity=.96f;CrownHeartWorld.Create(root);CrownHeartSoundscape.Create(root);return;} if(IsOpenSky){worldVoidY=-18;global.color=new Color(1,.96f,.86f);global.intensity=.98f;OpenSkyWorld.Create(root);OpenSkySoundscape.Create(root);CampaignRescueWorld.CreateForCurrentLevel(root);return;} if(IsRiver){worldVoidY=-18;global.color=new Color(.83f,.8f,1);global.intensity=.9f;RiverWithoutBanksWorld.Create(root);CampaignRescueWorld.CreateForCurrentLevel(root);return;} if(IsRootCathedral){worldVoidY=-12;global.color=new Color(.83f,.78f,1);global.intensity=.9f;RootCathedralWorld.Create(root);RootCathedralSoundscape.Create(root);FlightAccess.Register(RootCathedralWorld.I,()=>RootCathedralWorld.Area==5&&!PocketRoom.Active);return;} if(IsMistWorkshop){worldVoidY=-12;global.color=new Color(.81f,.8f,.98f);global.intensity=.89f;MistWorkshopWorld.Create(root);DungeonRun.Create(root,DungeonDefinition.NightVeinHeart(MistWorkshopWorld.I.UnderworldEntrance));MistWorkshopSoundscape.Create(root);return;} if(IsNightRoots){worldVoidY=-12;global.color=new Color(.82f,.79f,1);global.intensity=.88f;NightRootsWorld.Create(root);NightRootsSoundscape.Create(root);CampaignRescueWorld.CreateForCurrentLevel(root);return;} if(IsObservatory){worldVoidY=-12;global.color=new Color(.87f,.9f,1);global.intensity=.92f;ObservatoryWorld.Create(root);var ow=ObservatoryWorld.I;var aster=AsterBoss.Create(ow.ArenaRoot,ObservatoryWorld.At(4,768,ObservatoryWorld.Baselines[4]),()=>ObservatoryWorld.Area==4&&ObservatoryWorld.ArenaReady&&!DungeonRun.Inside&&!PocketRoom.Active);AsterMirrorGift.Create(aster,ow.ArenaRoot,root,ow.ArenaRightDoorFeet);ObservatorySoundscape.Create(root);return;} if(IsGlassGarden){worldVoidY=-12;global.color=new Color(.9f,.93f,1);global.intensity=.91f;GlassGardenWorld.Create(root);CampaignRescueWorld.CreateForCurrentLevel(root);return;} if(IsArchiveMemory){worldVoidY=-12;global.color=new Color(.85f,.89f,.99f);global.intensity=.9f;ArchiveMemoryWorld.Create(root);CampaignRescueWorld.CreateForCurrentLevel(root);return;} if(IsStarArchive){worldVoidY=-12;global.color=new Color(.85f,.89f,.99f);global.intensity=.9f;StarArchiveWorld.Create(root);return;} if(IsBelfry){worldVoidY=-9;global.color=new Color(.81f,.86f,.94f);global.intensity=.82f;BelfryLowerHall.Create(root);BelfrySideGallery.Create(root);BelfryWindWindow.Create(root);OrvoRoof.Create(root);BelfryJourney.Create(BelfryLowerHall.I.Architecture,root);return;} if(IsWindFerry){worldVoidY=-15;FerryLanding.Create(root);ShipyardCourierEntrance.Create(root);SaltLightEntrance.Create(root);CampaignRescueWorld.CreateForCurrentLevel(root);new GameObject("Werft · Küstenferne vor dem Sturm").AddComponent();return;} if(IsFestival){BuildFestival(root);CampaignRescueVillage.Create(root);return;} if(IsWindSchool){BuildWindSchool(root);return;} if(IsFirstThread){BuildFirstThread(root);CampaignRescueWorld.CreateForCurrentLevel(root);return;} if(IsCloudGardens){BuildCloudGardens(root);CampaignRescueWorld.CreateForCurrentLevel(root);return;} if(IsSleepingMill){BuildSleepingMill(root);return;} if(IsWaterways){BuildWaterways(root);CampaignRescueWorld.CreateForCurrentLevel(root);return;} if(IsScaffold){BuildScaffold(root);CampaignRescueWorld.CreateForCurrentLevel(root);return;} if(IsRainGarden){BuildRainGarden(root);return;} if(IsBellWatch){worldVoidY=-12;BellWatchCourt.Create(root);new GameObject("Glockenwache · ferne Kupfertürme").AddComponent();return;} if(IsCoast){worldVoidY=-15;CoastApproach.Create(root);CampaignRescueWorld.CreateForCurrentLevel(root);new GameObject("Glockenküste · Wolkenmeer und Randgras").AddComponent();return;} if(IsAqueduct){AqueductHub.Create(root);new GameObject("Aquädukt · tiefe Ferne und weiches Laub").AddComponent();return;} Door("Maras Werkstatt",1,0,4.1f,InteractableKind.Shop,"shop",root); PocketRoom.Create("weaver-hearts","Die Herzkammer der Weber",PocketRoomKind.Hearts,new Vector2(-24.5f,36),0,root); Door("Tor zur Sonnenterrasse",55,80,4.7f,InteractableKind.Finish,"finish",root); new GameObject("Boruns Windmühle").AddComponent().Init(new Vector2(7,ArenaY),root); Architecture(root); Collect("ascent-album-garden",-8,2.1f,true,root);Collect("ascent-album-weavers",-20,41,true,root);Collect("ascent-album-home",57,82,true,root); for(int i=1;i<54;i++){var p=Spec.platforms[i];if(i==51)continue;Collect("ascent-spark-"+i,p.x,p.y+1.35f,false,root);if(p.width>=8)Collect("ascent-spark-side-"+i,p.x+2,p.y+1.3f,false,root);} for(int i=0;i<9;i++)Collect("ascent-flight-"+i,29+i*3.3f,90-i*.95f,false,root); new GameObject("Depth composition · six independent planes").AddComponent(); new GameObject("Room atmosphere · water and sunlight").AddComponent(); new GameObject("Weberhaus · Drei Töne im Wind").AddComponent(); } // Room expansions can overlap inactive rooms in world space. Keep the complete // checkpoint (including its light and save contact) in its owning room hierarchy. public static void AttachCheckpointLanterns() { foreach(var lantern in UnityEngine.Object.FindObjectsByType(FindObjectsSortMode.None)) { if(lantern.Kind!=InteractableKind.Lantern||!lantern.Id.StartsWith("ascent-lantern-"))continue; if(!int.TryParse(lantern.Id.Substring("ascent-lantern-".Length),out int index))continue; Transform owner=null; if(IsStarArchive&&StarArchiveWorld.I)owner=StarArchiveWorld.I.RoomRoot(StarArchiveWorld.CheckpointRoom(index)); else if(IsArchiveMemory&&ArchiveMemoryWorld.I) { owner=ArchiveMemoryWorld.I.RoomRoot(index==2?3:index==1?1:index>=3?2:0); // Match the original local rest action without consuming // the neighbouring morning chest's centre interaction. lantern.LanternInteractionReach=1.45f; } else if(IsGlassGarden&&GlassGardenWorld.I)owner=GlassGardenWorld.I.RoomRoot(index==4?2:Mathf.Clamp(index,0,3)); else if(IsObservatory&&ObservatoryWorld.I)owner=ObservatoryWorld.I.RoomRoot(index==5?0:Mathf.Clamp(index,0,4)); else if(IsNightRoots&&NightRootsWorld.I)owner=NightRootsWorld.I.RoomRoot(index>=5?4:Mathf.Clamp(index,0,4)); else if(IsMistWorkshop&&MistWorkshopWorld.I)owner=MistWorkshopWorld.I.RoomRoot(index==4||index==5?1:index==3?4:Mathf.Clamp(index,0,2)); else if(IsRiver&&RiverWithoutBanksWorld.I)owner=RiverWithoutBanksWorld.I.RoomRoot(RiverWithoutBanksWorld.RoomForCheckpoint(index)); else if(IsRootCathedral&&RootCathedralWorld.I)owner=RootCathedralWorld.I.RoomRoot(RootCathedralWorld.CheckpointRoom(index)); else if(IsOpenSky&&OpenSkyWorld.I)owner=OpenSkyWorld.I.RoomRoot(OpenSkyWorld.RoomForCheckpoint(index)); if(owner)lantern.transform.SetParent(owner,true); } } static void Door(string name,float x,float y,float height,InteractableKind kind,string id,Transform root) {var sr=ArtLibrary.Sprite(name,ArtLibrary.Get("WorldAtlas",4),new Vector3(x,y),2,root);ArtLibrary.Height(sr,height);sr.gameObject.AddComponent().Init(kind,id,0,"");} static void Lantern(int i,Transform root) { var p=Spec.checkpoints[i];var sr=ArtLibrary.Sprite("Lichtlaterne "+i,ArtLibrary.Get("WorldAtlas",3),new Vector3(p.x,p.y),9,root);ArtLibrary.Height(sr,2.7f); sr.gameObject.AddComponent().Init(InteractableKind.Lantern,"ascent-lantern-"+i,i,""); sr.gameObject.AddComponent().Init(i,root); } static void Collect(string id,float x,float y,bool album,Transform root) {var go=new GameObject(id);go.transform.SetParent(root);go.transform.position=new Vector3(x,y);var c=go.AddComponent();c.Album=album;c.Init(InteractableKind.Collectible,id,0,"");} static void Platform(PlatformSpec p,int index,Transform root) { var go=new GameObject(p.id);go.transform.SetParent(root);go.transform.position=new Vector3(p.x,p.y);go.layer=6; var col=go.AddComponent();col.size=new Vector2(p.width,.6f);col.offset=Vector2.down*.3f;if(p.oneWay)go.AddComponent(); if(p.liftAmplitude>0){var lift=go.AddComponent();lift.Amplitude=p.liftAmplitude;go.AddComponent().Init(p,root);} TerraceArt.Build(p,index,go.transform); } static void Architecture(Transform root) { if(!Resources.Load("GameArt/TowerAtlas"))return; Structure("Aquädukt · tragender Bogen","AqueductSupportArch",new Vector2(0,9),18,-12,new Color(.80f,.89f,.86f,.93f),root); if(Resources.Load("GameArt/WeaverConservatory")) { var house=ArtLibrary.Sprite("Weberhaus · eigenständige Wintergartenarchitektur",ArtLibrary.Get("WeaverConservatory"),new Vector3(-1,27),-12,root); ArtLibrary.Height(house,20);house.color=new Color(.86f,.93f,.91f,.94f); } else Backdrop("Weberhaus · Innenraum",1,0,28,18,root); Backdrop("Werkstatt · Seitenkammer",1,-21,35,9.8f,root); if(Resources.Load("GameArt/StructuralAtlas")) { Pier("Aquädukt · Westpfeiler mit Wasserleitung","AqueductWestPier",-10.5f,root); Pier("Aquädukt · reparierter Ostpfeiler","AqueductEastPier",10.5f,root); Structure("Mühlengerüst · Holztragwerk","MillHoistFrame",new Vector2(0,41.2f),22.2f,-7,new Color(.72f,.81f,.78f,.97f),root); Support("Turmkrone · gebrochener Mosaikpfeiler",2,-7.7f,63,14.4f,root); Support("Garten · Wurzelpfeiler",3,-9,-1.5f,10.4f,root); } else Backdrop("Mühlengerüst",3,0,45,20,root); // The intact aqueduct arch is a landmark of the lower watercourse only. var gear=Backdrop("Das lebendige Mühlenrad",2,0,46.5f,7.2f,root);gear.gameObject.AddComponent(); } static SpriteRenderer Structure(string name,string sheet,Vector2 at,float height,int order,Color color,Transform root) {var sr=ArtLibrary.Sprite(name,ArtLibrary.Get(sheet),at,order,root);ArtLibrary.Height(sr,height);sr.color=color;return sr;} static SpriteRenderer Backdrop(string name,int frame,float x,float y,float height,Transform root) {var sr=ArtLibrary.Sprite(name,ArtLibrary.Get("TowerAtlas",frame),new Vector3(x,y),-12,root);ArtLibrary.Height(sr,height);sr.color=new Color(.85f,.92f,.9f,.84f);ArtLibrary.Feather(sr,.028f);return sr;} static void Support(string name,int frame,float x,float y,float height,Transform root) {var sr=ArtLibrary.Sprite(name,ArtLibrary.Get("StructuralAtlas",frame),new Vector3(x,y),-7,root);ArtLibrary.Height(sr,height);sr.color=new Color(.68f,.78f,.76f,.92f);} static void Pier(string name,string sheet,float x,Transform root) {var sr=ArtLibrary.Sprite(name,ArtLibrary.Get(sheet),new Vector3(x,-.2f),-7,root);ArtLibrary.Height(sr,23.6f);sr.color=new Color(.72f,.81f,.78f,.95f);} } public sealed class MillWheel:MonoBehaviour { Vector3 pivot;bool authoredAxle; public Vector3 Axle=>pivot; public void SetAxle(Vector3 value){pivot=value;authoredAxle=true;} void Start(){if(!authoredAxle)pivot=GetComponent().bounds.center;} void Update(){transform.RotateAround(pivot,Vector3.forward,Time.deltaTime*12);} } }