using System.Text.Json; using XFEEDToolBox.Controls; using XFEEDToolBox.Core.Galaxy; using XFEEDToolBox.Core.Models; namespace XFEEDToolBox; public partial class App { private static async Task RunGalaxyFrameFadeProbeAsync(string directory,IReadOnlyList recorded) { static void Require(bool value,string message){if(!value)throw new InvalidOperationException(message);} var actual=recorded.First(s=>s.SystemAddress is >0&&((ulong)s.SystemAddress.Value&7)==5); var origin=new Coordinates(49985,40985,24105); var cell=GalaxyCellQueryPlan.CellAddress((ulong)actual.SystemAddress!.Value); var bounds=GalaxyOriginalCatalogueLod.CellBounds(cell,origin); var sign=actual.Position.Z-bounds.Minimum.Z>=bounds.Maximum.Z-actual.Position.Z?1:-1; var focus=new Coordinates(actual.Position.X,actual.Position.Y,actual.Position.Z-sign*64); // Keep the captured star and its position untouched. Only the camera, // descriptor, timing and classification flags are controlled fixtures. var appearance=new GalaxyOriginalStellarAppearance(0xffe0b070,null,null,1,4,0,.05f,false) {NavRouteMembership=false,NavRouteMembershipMode=0,NavRouteViewMode=0}; var target=actual with{OriginalAppearance=appearance}; GalaxyOriginalPointOverrides Flags(long generation,bool member=false,bool known=true,IEnumerable? overrides=null)=> new(Environment.ProcessId,generation,0,0,true,known,overrides??[],member?[actual.SystemAddress!.Value]:[]); var descriptor=GalaxyOriginalCatalogueLod.Create(focus,1,32,.001,1,0); Require(descriptor.IntersectsCell(cell,origin),"The actual recorded frame-fade target is outside the controlled whole cell."); var selection=new GalaxyCatalogueSelection(descriptor,origin) {OriginalViewMode=0,SmallMode=false,NavRouteMembershipMode=0,NavRouteViewMode=0,PointOverrides=Flags(1)}; var previous=MainWindow.Content;var host=new Grid();var map=new GalaxyMapView();host.Children.Add(map);MainWindow.Content=host; async Task Save(string name) { map.RenderNowForProbe(); using(await map.FreezeForXamlProbeAsync())await CaptureRefinementElementAsync(host,Path.Combine(directory,name+".png")); } try { map.UseManualOriginalFrameClockForProbe(); map.Filter=GalaxyMapFilter.Default with{Mode=GalaxyMapMode.Map,Values=null,ShowBackground=false,ShowGrid=false, ShowLinks=false,ShowRoute=false,ShowConstellations=false,ShowCurrentTradeFlows=false,ShowHistoricalTradeFlows=false, ShowRegionNames=false,ShowNebulaNames=false,ShowGalacticZonesPlane=false,ShowGalacticZoneNames=false}; await Task.Delay(180);map.SetCameraPoseForProbe(new(focus,sign>0?0:Math.PI,0,80)); map.Systems=[target];map.CatalogueSelection=selection;map.RenderNowForProbe(); Require(map.FrameFadeTransitionForProbe==0&&map.VisibleStars==0&&map.VisibleNameLabels==0&&map.FrameFadedStarsForProbe==1, "The initial original ellipsoid did not hide the controlled non-member model and label."); map.SelectAt(map.ProjectForProbe(target.Position));Require(map.Selection is null,"The fully faded star retained a hit."); await Save("frame-fade-initial"); map.AdvanceOriginalFrameFadeForProbe(1d/60,180);map.RenderNowForProbe(); var transition=map.FrameFadeTransitionForProbe; Require(transition>1&&map.VisibleStars==1&&map.VisibleNameLabels==1,"The recovered input clock did not reveal the actual recorded star."); await Save("frame-fade-settled"); map.CatalogueSelection=selection with{OriginalViewMode=1};map.AdvanceOriginalFrameFadeForProbe(1d/60,1);map.RenderNowForProbe(); Require(map.FrameFadeTransitionForProbe==1&&map.VisibleStars==0,"The decreasing-to-one branch did not retain the original ellipsoid."); map.Systems=[target with{OriginalAppearance=appearance with{NavRouteMembership=true}}];map.RenderNowForProbe(); map.CatalogueSelection=selection with{OriginalViewMode=1,PointOverrides=Flags(2,true)};map.RenderNowForProbe(); Require(map.VisibleStars==1,"Original NavRoute membership failed to apply its separate minimum alpha."); await Save("frame-fade-member"); var extra=new GalaxyOriginalPointOverride(actual.SystemAddress!.Value,1,false,false,actual.Position,actual.Name,actual.StarClass,appearance); var outside=GalaxyOriginalCatalogueLod.Create(new(actual.Position.X+10000,actual.Position.Y,actual.Position.Z),1,32,.001,1,0); Require(!outside.IntersectsCell(cell,origin),"The supplemental-object fixture still belongs to an ordinary cell."); var forced=selection with{Descriptor=outside,OriginalViewMode=1,PointOverrides=Flags(4,known:false,overrides:[extra])}; Require(forced.OriginalSize(target)==0,"D50 Extra floor was incorrectly applied to the independent primary size."); map.SetCameraPoseForProbe(new(focus,sign>0?0:Math.PI,0,800));map.CatalogueSelection=forced;map.Systems=[target]; map.AdvanceOriginalFrameFadeForProbe(1d/60,1);map.RenderNowForProbe(); Require(map.VisibleStars==1&&map.VisibleNameLabels==1,"Published D50 presence with farFade=false was lost outside ordinary cells or beyond the far-fade band."); await Save("frame-fade-d50-forced"); map.CatalogueSelection=forced with{PointOverrides=Flags(5,known:false,overrides:[extra with{FarFade=true}])};map.RenderNowForProbe(); Require(map.VisibleStars==0&&map.VisibleNameLabels==0,"D50 farFade=true did not hide the same recorded point beyond700ly."); map.SelectAt(map.ProjectForProbe(target.Position));Require(map.Selection is null,"The fully faded D50 point retained a hit."); await Save("frame-fade-d50-far-hidden"); map.SetCameraPoseForProbe(new(focus,sign>0?0:Math.PI,0,80)); map.Systems=[target with{OriginalAppearance=appearance with{NavRouteMembership=null}}];map.RenderNowForProbe(); map.CatalogueSelection=selection with{OriginalViewMode=1,PointOverrides=Flags(3,known:false)};map.RenderNowForProbe(); Require(map.VisibleStars==1,"Unknown membership was incorrectly classified as a non-member."); map.Filter=map.Filter with{Values=new HashSet(),IncludeUnknown=false};map.RenderNowForProbe(); Require(map.VisibleStars==0&&map.VisibleNameLabels==0,"Frame flags bypassed the empty strict query."); map.SelectAt(map.ProjectForProbe(target.Position));Require(map.Selection is null,"The strict hidden star retained a hit."); await Save("frame-fade-empty"); map.CatalogueSelection=selection;map.Systems=[target];map.Filter=map.Filter with{Mode=GalaxyMapMode.Realistic,Values=null}; map.AdvanceOriginalFrameFadeForProbe(1d/60,180);map.RenderNowForProbe(); Require(map.VisibleStars==0,"Known original size zero was replaced by a fallback size."); map.CatalogueSelection=selection with{SmallMode=true};map.RenderNowForProbe(); Require(map.VisibleStars==1,"Current small-mode selection failed to use the cached original small size."); var result=new{actual.Name,actual.SystemAddress,actual.Position,cameraAndDescriptorExplicitFixture=true, appearanceAndMembershipExplicitFixture=true,generatedCatalogueCoordinates=false,gameAccess=false, initialTransition=0,settledTransition=transition,clockStepSeconds=1d/60,clockSteps=180, initialModelLabelAndHitHidden=true,settledActualStarVisible=true,navRouteMinimumIndependent=true, d50PublishedPresenceForcesBeyondOrdinaryCells=true,d50ConsumedPendingRemainsPresent=true, d50FarFadeControlsSameRecordedPoint=true,d50MinimumExtraNotAppliedToPrimarySize=true, unknownMembershipNotAssumedFalse=true,strictEmptyNoModelLabelOrHit=true, knownZeroOriginalSizeHidden=true,currentSmallModeUsesCachedRawSize=true,liveSourceFlagsConfirmed=false}; await File.WriteAllTextAsync(Path.Combine(directory,"frame-fade-probe.json"),JsonSerializer.Serialize(result,new JsonSerializerOptions{WriteIndented=true})); return result; } finally{map.SuspendPage();MainWindow.Content=previous;} } }