using System; using System.Collections.Generic; using UnityEngine; namespace Auralis { // Original separated regional atlas pieces at their established .01 density. // Native end/underside alpha is retained. No room painting is stretched and // no procedural bowl/cap replaces the source silhouette. public sealed class LateDungeonSpatialArt:MonoBehaviour { public const float Density=.01f; public readonly List Registrations=new(); readonly List owned=new();int family;string key;Material architectureMaterial; Rect left,right,body,ladder;float contact,rungs; static LateDungeonSpatialArt Create(Transform parent,int family) { var o=new GameObject("Regionaler Außenweg · Originalmaterial");o.transform.SetParent(parent,false);o.AddComponent(); var a=o.AddComponent();a.family=family; if(family<=8){a.key="LateStarArchitectureV1";a.left=new(24,296,88,161);a.right=new(1424,296,88,161);a.body=new(112,303,1312,154);a.contact=303;a.ladder=new(97,540,148,69);a.rungs=69;} else if(family<=10){a.key="LateRootArchitectureV1";a.left=new(14,310,96,154);a.right=new(1430,310,93,154);a.body=new(110,319,1320,145);a.contact=319;a.ladder=new(84,492,150,68);a.rungs=68;} else{a.key="LateCrownArchitectureV1";a.left=new(24,310,100,145);a.right=new(1424,310,88,145);a.body=new(124,311,1300,144);a.contact=311;a.ladder=new(95,553,184,75);a.rungs=75;} a.architectureMaterial=DungeonArchitecturePatina.Create(family<=8?"star":family<=10?"root":"crown"); return a; } public static void PaintBank(Transform root,BoxCollider2D bank,int family,bool isCatch) { var a=Create(root,family);a.Deck(bank.bounds.min.x,bank.bounds.max.y,bank.bounds.size.x,isCatch?10:12); } void Deck(float x,float y,float width,int order) { float capLeft=left.width*Density,capRight=right.width*Density; if(width(true))r.enabled=false; var a=Create(ladder.transform,family);float density=.72f/a.ladder.width,height=ladder.Top-ladder.Bottom,unit=a.rungs*density; int count=Mathf.CeilToInt(height/unit); for(int i=0;inew[]{"Lagergewölbe","Abgesackter Transportbogen","Windschacht"}, 8=>new[]{"Dunkler Filtergang","Zerbrochene Glasrippen","Kühlbecken"}, 9=>new[]{"Äußere Aderkammer","Tiefer gewachsener Wurzelkörper","Ostader"}, 10=>new[]{"Warme Außenkanäle","Offener Luftabzug","Geschützter Wurzelbogen"}, 11=>new[]{"Werkhof der Krone","Tragende Lastführung","Gebrochenes Verteilerrad"}, _=>new[]{"Verlassener Schutzgang","Rücksiegelgewölbe","Oberer Tragefaden"} }; for(int n=0;n=passage.MainBanks.Count)continue;var bank=passage.MainBanks[index];var a=Create(bank.transform,family); a.StructuralBody(names[n],bank.bounds,n); } } void StructuralBody(string label,Bounds bank,int index) { float left=bank.min.x,right=bank.max.x,floor=bank.max.y; float depth=family==9?6.5f:family==11?7.4f:4.8f; float roof=family==9?5.6f:family==12?5.2f:6.3f; gameObject.AddComponent().Init("U"+family,label,Rect.MinMaxRect(left,floor-depth,right,floor+roof)); // Structural arches have an open centre and no door threshold. // A full portal painting here would read as another usable exit. Rect arch;Rect stem;float archStand; if(family<=8){arch=new(330,459,421,480);stem=new(395,708,56,190);archStand=910;} else if(family<=10){arch=new(286,471,558,443);stem=new(347,693,50,184);archStand=882;} else{arch=new(399,451,360,486);stem=new(413,678,74,142);archStand=908;} float archWidth=arch.width*Density; int count=Mathf.Max(1,Mathf.FloorToInt((right-left-.8f)/archWidth)); for(int i=0;i=9&&family<=10)return; // The root kit already has an open arch. // An annular strip retains the atlas's own stones, scale and UVs. // Only portal fill, sill and unrelated crystal pedestals are excluded. Vector2[] outside,inside; if(family<=8) { outside=new Vector2[]{new(381,907),new(381,653),new(414,589),new(475,524),new(542,462),new(609,524),new(670,589),new(699,653),new(699,907)}; inside=new Vector2[]{new(465,907),new(465,693),new(477,651),new(505,606),new(542,579),new(579,606),new(607,651),new(619,693),new(619,907)}; } else { outside=new Vector2[]{new(403,907),new(409,666),new(411,524),new(482,524),new(550,454),new(607,454),new(676,524),new(745,524),new(747,666),new(753,907)}; inside=new Vector2[]{new(490,907),new(489,674),new(499,621),new(522,582),new(561,547),new(593,547),new(635,582),new(657,621),new(670,674),new(670,907)}; } var vertices=new Vector2[outside.Length*2];var triangles=new ushort[(outside.Length-1)*6]; for(int i=0;i("GameArt/"+key); if(!texture||rect.width<.1f||rect.height<.1f||rect.xMin<0||rect.yMin<0||rect.xMax>texture.width||rect.yMax>texture.height)throw new InvalidOperationException("Invalid original spatial crop: "+key+" "+rect); var sprite=Sprite.Create(texture,new Rect(rect.x,texture.height-rect.yMax,rect.width,rect.height),new Vector2(.5f,.5f),100,0,SpriteMeshType.FullRect);owned.Add(sprite); var r=ArtLibrary.Sprite(label,sprite,Vector3.zero,order,transform);ArtLibrary.RegisterSource(r,density,anchor,at); DungeonArchitecturePatina.Apply(r,architectureMaterial); Registrations.Add(new(){Renderer=r,ArtKey=key,SourceRect=rect,SourceAnchor=anchor,WorldAnchor=at,WorldUnitsPerPixel=density}); return r; } void OnDestroy(){foreach(var s in owned)if(s)Destroy(s);if(architectureMaterial)Destroy(architectureMaterial);} } }