diff --git a/Chroma/HarmonyPatches/ScenesTransition/SceneTransitionHelper.cs b/Chroma/HarmonyPatches/ScenesTransition/SceneTransitionHelper.cs new file mode 100644 index 00000000..5f282702 --- /dev/null +++ b/Chroma/HarmonyPatches/ScenesTransition/SceneTransitionHelper.cs @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Chroma/HeckImplementation/ModuleCallbacks.cs b/Chroma/HeckImplementation/ModuleCallbacks.cs index 6be6d685..ad132a73 100644 --- a/Chroma/HeckImplementation/ModuleCallbacks.cs +++ b/Chroma/HeckImplementation/ModuleCallbacks.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using Chroma.Lighting; +using Chroma.Lighting.EnvironmentEnhancement; using Chroma.Settings; using CustomJSONData; using CustomJSONData.CustomBeatmap; @@ -37,7 +38,10 @@ private static bool ConditionFeatures( Log.Logger.Log("Please do not use Legacy Chroma Lights for new maps as it is deprecated and its functionality in future versions of Chroma cannot be guaranteed", Logger.Level.Warning); } - LightIDTableManager.SetEnvironment(difficultyBeatmap.GetEnvironmentInfo().serializedName); + string? environmentName = difficultyBeatmap.GetEnvironmentInfo().serializedName; + LightIDTableManager.SetEnvironment(environmentName); + EnvironmentEnhancementManager.SetEnvironment(environmentName); + return (chromaRequirement || legacyOverride) && !ChromaConfig.Instance.ChromaEventsDisabled; } diff --git a/Chroma/Lighting/EnvironmentEnhancement/EnvironmentEnhancementManager.cs b/Chroma/Lighting/EnvironmentEnhancement/EnvironmentEnhancementManager.cs index 3d1c76d1..6fcd9396 100644 --- a/Chroma/Lighting/EnvironmentEnhancement/EnvironmentEnhancementManager.cs +++ b/Chroma/Lighting/EnvironmentEnhancement/EnvironmentEnhancementManager.cs @@ -1,6 +1,7 @@ using System; using System.Collections; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Runtime.InteropServices; using System.Text.RegularExpressions; @@ -10,6 +11,7 @@ using Heck.Animation; using IPA.Utilities; using JetBrains.Annotations; +using Newtonsoft.Json; using UnityEngine; using UnityEngine.SceneManagement; using Zenject; @@ -72,6 +74,8 @@ private EnvironmentEnhancementManager( spawnController.StartCoroutine(DelayedStart()); } + private static string EnvironmentName = string.Empty; + internal Dictionary RingRotationOffsets { get; } = new(); internal Dictionary AvoidancePosition { get; } = new(); @@ -440,10 +444,14 @@ private void GetAllGameObjects() List objectsToPrint = new(); + Dictionary objectMap = new(); + foreach (GameObject gameObject in gameObjects) { GameObjectInfo gameObjectInfo = new(gameObject); - _gameObjectInfos.Add(new GameObjectInfo(gameObject)); + _gameObjectInfos.Add(gameObjectInfo); + objectMap[gameObjectInfo.FullID] = new GameObjectJSON(gameObject); + objectsToPrint.Add(gameObjectInfo.FullID); // seriously what the fuck beat games @@ -461,6 +469,27 @@ private void GetAllGameObjects() objectsToPrint.Sort(); objectsToPrint.ForEach(n => Log.Logger.Log(n)); + + string fileDumpPath = $@"UserData\Chroma\{EnvironmentName}.json"; + + if (!File.Exists(fileDumpPath)) + { + Directory.CreateDirectory(Path.GetDirectoryName(fileDumpPath) ?? throw new InvalidOperationException()); + } + + Log.Logger.Log($"Writing to {fileDumpPath}", Logger.Level.Info); + + string str = JsonConvert.SerializeObject(objectMap); + + using FileStream file = new(fileDumpPath, FileMode.Create, FileAccess.Write); + using StreamWriter stream = new(file); + + stream.WriteLine(str); + } + + internal static void SetEnvironment(string environmentName) + { + EnvironmentName = environmentName; } } } diff --git a/Chroma/Lighting/EnvironmentEnhancement/EnvironmentJSONDump.cs b/Chroma/Lighting/EnvironmentEnhancement/EnvironmentJSONDump.cs new file mode 100644 index 00000000..9c4c5489 --- /dev/null +++ b/Chroma/Lighting/EnvironmentEnhancement/EnvironmentJSONDump.cs @@ -0,0 +1,53 @@ +using UnityEngine; + +namespace Chroma.Lighting.EnvironmentEnhancement +{ + struct Vector3Json + { + public float x; + public float y; + public float z; + + public Vector3Json(Vector3 vector3) + { + x = vector3.x; + y = vector3.y; + z = vector3.z; + } + } + + struct QuaternionJson + { + public float x; + public float y; + public float z; + public float w; + + public QuaternionJson(Quaternion quaternion) + { + x = quaternion.x; + y = quaternion.y; + z = quaternion.z; + w = quaternion.w; + } + } + + struct GameObjectJSON + { + public readonly Vector3Json position; + public readonly Vector3Json localPosition; + public readonly QuaternionJson rotation; + public readonly QuaternionJson localRotation; + public readonly Vector3Json localScale; + + public GameObjectJSON(GameObject gameObject) + { + Transform transform = gameObject.transform; + localPosition = new Vector3Json(transform.localPosition); + position = new Vector3Json(transform.position); + rotation = new QuaternionJson(transform.rotation); + localRotation = new QuaternionJson(transform.localRotation); + localScale = new Vector3Json(transform.localScale); + } + } +}