From 35ce351fbdf161de2c2720a93d47c8ffe0f6b686 Mon Sep 17 00:00:00 2001 From: iAmAsval Date: Fri, 17 Sep 2021 00:00:53 +0200 Subject: [PATCH] Cube Movements --- FModel/ViewModels/MapViewerViewModel.cs | 79 +++++++++++++++++++++++++ FModel/Views/MapViewer.xaml | 2 + 2 files changed, 81 insertions(+) diff --git a/FModel/ViewModels/MapViewerViewModel.cs b/FModel/ViewModels/MapViewerViewModel.cs index b13a8306..cd945bed 100644 --- a/FModel/ViewModels/MapViewerViewModel.cs +++ b/FModel/ViewModels/MapViewerViewModel.cs @@ -102,6 +102,13 @@ namespace FModel.ViewModels set => SetProperty(ref _brCorruptionZones, value, "ApolloGameplay_CorruptionZones"); } + private bool _brCubeMovements; + public bool BrCubeMovements + { + get => _brCubeMovements; + set => SetProperty(ref _brCubeMovements, value, "ApolloGameplay_CubeMovements"); + } + private bool _prLandmarks; public bool PrLandmarks { @@ -283,6 +290,9 @@ namespace FModel.ViewModels case "ApolloGameplay_CorruptionZones": await LoadCorruptionZones(); break; + case "ApolloGameplay_CubeMovements": + await LoadCubeMovements(); + break; case "PapayaGameplay_CannonballGame": await LoadCannonballGame(); break; @@ -909,5 +919,74 @@ namespace FModel.ViewModels _bitmaps[0]["ApolloGameplay_CorruptionZones"] = new MapLayer {Layer = rotatedBitmap.Resize(_widthHeight, _widthHeight), IsEnabled = false}; }); } + + /// + /// FortniteGame/Plugins/GameFeatures/CorruptionGameplay/Content/CorruptionGameplay_LevelOverlay.uasset + /// too lazy to filters + /// + private async Task LoadCubeMovements() + { + await _threadWorkerView.Begin(_ => + { + _fillPaint.StrokeWidth = 5; + var cubeMovementsBitmap = new SKBitmap(_widthHeight, _widthHeight, SKColorType.Rgba8888, SKAlphaType.Premul); + using var c = new SKCanvas(cubeMovementsBitmap); + + if (!Utils.TryLoadObject("/CorruptionGameplay/Levels/CorruptionGameplay_ApolloTerrain_Overlay.BP_CubeMovementGradient_2", out UObject overlay) || + !overlay.TryGetValue(out FSoftObjectPath[] cubeMovementStaticPaths, "cubeMovementStaticPaths") || cubeMovementStaticPaths.Length < 1) + return; + + var oldColor = _pathPaint.Color; + _pathPaint.Color = SKColors.Purple; + foreach (var cubeMovementStaticPath in cubeMovementStaticPaths) + { + var objectPath = cubeMovementStaticPath.AssetPathName.Text.SubstringBeforeLast("."); + var objectName = cubeMovementStaticPath.SubPathString.SubstringAfterLast("."); + if (!Utils.TryLoadObject($"{objectPath}.{objectName}", out UObject staticPath)) + continue; + + DrawCubeMovements(c, staticPath); + } + + if (Utils.TryLoadObject("/CorruptionGameplay/Levels/CubeMovement/Apollo_CM_Gold_Overlay.CM_Spline_Gold", out UObject goldPath)) + { + _pathPaint.Color = SKColors.Gold; + DrawCubeMovements(c, goldPath); + } + + _pathPaint.Color = oldColor; + _bitmaps[0]["ApolloGameplay_CubeMovements"] = new MapLayer {Layer = cubeMovementsBitmap, IsEnabled = false}; + }); + } + + private void DrawCubeMovements(SKCanvas c, UObject staticPath) + { + if (!staticPath.TryGetValue(out FStructFallback[] pathTravelers, "PathTravelers") || pathTravelers.Length < 1 || + !pathTravelers[0].TryGetValue(out FPackageIndex[] generatedSplinesArray, "GeneratedSplinesArray") || generatedSplinesArray.Length < 1 || + !pathTravelers[0].TryGetValue(out FStructFallback[] stepMetaData, "StepMetaData") || stepMetaData.Length < 1) + return; + + var bDone = false; + var path = new SKPath(); + for (var i = 0; i < generatedSplinesArray.Length; i++) + { + if (!stepMetaData[i].TryGetValue(out bool bSkipStep, "bSkipStep") || bSkipStep || + !Utils.TryGetPackageIndexExport(generatedSplinesArray[i], out UObject uObject) || + !uObject.TryGetValue(out FVector relativeLocation, "RelativeLocation")) continue; + + var vector = GetMapPosition(relativeLocation, _brRadius); + if (!bDone) + { + path.MoveTo(vector.X, vector.Y); + bDone = true; + } + else + { + path.LineTo(vector.X, vector.Y); + } + } + + c.DrawPath(path, _pathPaint); + } } } diff --git a/FModel/Views/MapViewer.xaml b/FModel/Views/MapViewer.xaml index 7c88543b..f7f9fd27 100644 --- a/FModel/Views/MapViewer.xaml +++ b/FModel/Views/MapViewer.xaml @@ -42,6 +42,8 @@ +