using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Threading;
using BepInEx;
using HarmonyLib;
using Newtonsoft.Json;
using TMPro;
using ULTRAKILL.Portal;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.AddressableAssets.Initialization;
using UnityEngine.Events;
using UnityEngine.ResourceManagement.AsyncOperations;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using VolumetricSkyboxes.Assets;
using VolumetricSkyboxes.Collections;
using VolumetricSkyboxes.Components;
using VolumetricSkyboxes.Models;
using VolumetricSkyboxes.UI;
using VolumetricSkyboxes.Utils;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("0.0.0.0")]
namespace VolumetricSkyboxes
{
public class VolumetricSkyboxContainer : IDisposable
{
public readonly GameObject SkyboxGameObject;
public readonly VolumetricSkyboxData Data;
private readonly AsyncOperationHandle<VolumetricSkyboxData> _dataHandle;
private readonly AsyncOperationHandle<GameObject> _gameObjectHandle;
public static VolumetricSkyboxContainer FromGuid(string guid)
{
string text = Path.Combine(PathsUtils.UnpackedSkyboxesPath, guid);
string path = Path.Combine(text, "data.json");
string text2 = Path.Combine(text, "catalog.json");
if (!Directory.Exists(text) || !File.Exists(path) || !File.Exists(text2))
{
Debug.LogWarning((object)("Can't locate unpacked skybox [guid=" + guid + "]"));
return null;
}
return new VolumetricSkyboxContainer(JsonConvert.DeserializeObject<VolumetricSkyboxBundleData>(File.ReadAllText(path)), text2);
}
private VolumetricSkyboxContainer(VolumetricSkyboxBundleData data, string catalogPath)
{
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
Addressables.LoadContentCatalogAsync(catalogPath, false, (string)null).WaitForCompletion();
_dataHandle = Addressables.LoadAssetAsync<VolumetricSkyboxData>((object)data.dataPath);
_gameObjectHandle = Addressables.LoadAssetAsync<GameObject>((object)data.prefabPath);
Data = _dataHandle.WaitForCompletion();
SkyboxGameObject = _gameObjectHandle.WaitForCompletion();
}
public void Dispose()
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
Addressables.Release<VolumetricSkyboxData>(_dataHandle);
Addressables.Release<GameObject>(_gameObjectHandle);
}
}
[BepInProcess("ULTRAKILL.exe")]
[BepInPlugin("dev.flazhik.volumetric-skyboxes", "Volumetric Skyboxes", "1.0.0")]
public class VolumetricSkyboxesPlugin : BaseUnityPlugin
{
[AddressableAsset("Assets/VolumetricSkyboxes/Bootstrap.prefab", typeof(GameObject))]
private static GameObject _bootstrap;
private static readonly string CatalogDir;
private static Harmony _harmony;
private static bool _init;
static VolumetricSkyboxesPlugin()
{
AssemblyUtils.LoadAssembly("VolumetricSkyboxesScripts.dll");
CatalogDir = Path.Combine(PathsUtils.AssemblyPath, "Assets");
}
private void Awake()
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Expected O, but got Unknown
((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
SetAddressableProperties();
Addressables.InitializeAsync().WaitForCompletion();
Addressables.LoadContentCatalogAsync(Path.Combine(CatalogDir, "catalog.json"), true, (string)null).WaitForCompletion();
_harmony = new Harmony("dev.flazhik.volumetric-skyboxes");
Startup();
}
private void Startup()
{
_harmony.PatchAll();
SceneManager.sceneLoaded += OnSceneLoaded;
}
private void OnSceneLoaded(Scene scene, LoadSceneMode loadSceneMode)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
if (scene != SceneManager.GetActiveScene())
{
return;
}
string currentScene = SceneHelper.CurrentScene;
if (!(currentScene == "Main Menu"))
{
if (currentScene == "Endless")
{
Object.Instantiate<GameObject>(_bootstrap);
}
}
else if (!_init)
{
PrepareFileSystem();
MonoSingleton<AssetsManager>.Instance.RegisterPrefabs(Assembly.GetExecutingAssembly());
VolumetricSkyboxesManager instance = MonoSingleton<VolumetricSkyboxesManager>.Instance;
instance.ReloadSkyboxes();
instance.ClearCache();
_init = true;
}
}
private static void PrepareFileSystem()
{
string[] array = new string[3]
{
PathsUtils.SkyboxesPath,
PathsUtils.DataPath,
PathsUtils.UnpackedSkyboxesPath
};
foreach (string path in array)
{
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
}
string text = Path.Combine(PathsUtils.AssemblyPath, "Skyboxes");
if (Directory.Exists(text))
{
array = Directory.GetDirectories(text, "*", SearchOption.AllDirectories);
for (int i = 0; i < array.Length; i++)
{
Directory.CreateDirectory(array[i].Replace(text, PathsUtils.SkyboxesPath));
}
array = Directory.GetFiles(text, "*.*", SearchOption.AllDirectories);
foreach (string obj in array)
{
File.Copy(obj, obj.Replace(text, PathsUtils.SkyboxesPath), overwrite: true);
}
Directory.Delete(text, recursive: true);
}
}
private void SetAddressableProperties()
{
AddressablesRuntimeProperties.SetPropertyValue("UnpackedVolumetricSkyboxesPath", PathsUtils.UnpackedSkyboxesPath);
AddressablesRuntimeProperties.SetPropertyValue("VolumetricSkyboxesRuntimePath", PathsUtils.AssemblyPath);
AddressablesRuntimeProperties.SetPropertyValue("VolumetricSkyboxesAssetsPath", CatalogDir);
}
}
internal static class PluginInfo
{
public const string Guid = "dev.flazhik.volumetric-skyboxes";
public const string Name = "Volumetric Skyboxes";
public const string Version = "1.0.0";
}
}
namespace VolumetricSkyboxes.Utils
{
public static class AssemblyUtils
{
public static void LoadAssembly(string scriptName)
{
Assembly.Load(File.ReadAllBytes(Path.Combine(PathsUtils.AssemblyPath, scriptName)));
}
}
public static class ReflectionUtils
{
private const BindingFlags PrivateFields = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
public static T GetPrivate<T>(this object instance, string field)
{
FieldInfo field2 = instance.GetType().GetField(field, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
return (T)((field2 != null) ? field2.GetValue(instance) : null);
}
public static T GetPrivateProperty<T>(this object instance, string field)
{
PropertyInfo property = instance.GetType().GetProperty(field, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
return (T)((property != null) ? property.GetValue(instance) : null);
}
public static void SetPrivate<TV>(this object instance, string field, TV value)
{
FieldInfo field2 = instance.GetType().GetField(field, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.SetField);
if (field2 != null)
{
field2.SetValue(instance, value);
}
}
}
public static class SkyboxFileUtility
{
public static VolumetricSkyboxBundleData UnpackSkybox(string path, bool forced = false)
{
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
//IL_00d3: Expected O, but got Unknown
FileInfo path2 = new FileInfo(path);
if (!File.Exists(path) || !PathsUtils.HasValidExtenstion(path2))
{
return null;
}
VolumetricSkyboxBundleData bundleData = GetBundleData(path);
if (bundleData == null || bundleData.guid == null)
{
return null;
}
string text = Path.Combine(PathsUtils.UnpackedSkyboxesPath, bundleData.guid);
bool flag = Directory.Exists(text);
bool num = flag && File.Exists(Path.Combine(text, "data.json")) && File.Exists(Path.Combine(text, "catalog.json"));
bool flag2 = true;
if (num)
{
VolumetricSkyboxBundleData val = JsonConvert.DeserializeObject<VolumetricSkyboxBundleData>(File.ReadAllText(Path.Combine(text, "data.json")));
if (val.guid != null && val.buildHash == bundleData.buildHash && !forced)
{
flag2 = false;
}
}
if (!flag2)
{
return bundleData;
}
try
{
if (flag)
{
Directory.Delete(text, recursive: true);
}
Directory.CreateDirectory(text);
ZipArchive val2 = new ZipArchive((Stream)File.Open(path, FileMode.Open, FileAccess.Read));
try
{
val2.ExtractToDirectory(text);
return bundleData;
}
finally
{
((IDisposable)val2)?.Dispose();
}
}
catch (Exception ex)
{
Debug.LogError((object)("Error unpacking skybox guid=[" + bundleData.guid + "]"));
Debug.LogException(ex);
return null;
}
}
private static VolumetricSkyboxBundleData GetBundleData(string path)
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Expected O, but got Unknown
using FileStream fileStream = File.Open(path, FileMode.Open, FileAccess.Read);
ZipArchive val = new ZipArchive((Stream)fileStream);
try
{
ZipArchiveEntry entry = val.GetEntry("data.json");
if (entry == null)
{
return null;
}
using StreamReader streamReader = new StreamReader(entry.Open());
return JsonConvert.DeserializeObject<VolumetricSkyboxBundleData>(streamReader.ReadToEnd());
}
finally
{
((IDisposable)val)?.Dispose();
}
}
}
public static class RenderingUtils
{
public static readonly int SandboxGrabbableLayer = LayerMask.NameToLayer("SandboxGrabbable");
public static readonly int SpecialLightingLayer = LayerMask.NameToLayer("SpecialLighting");
public static readonly int SandboxGrabbableMask = 1 << SandboxGrabbableLayer;
public static readonly int SpecialLightingLayerMask = 1 << SpecialLightingLayer;
public static readonly int BackgroundLayersMask = SandboxGrabbableMask | SpecialLightingLayerMask;
}
public static class PathsUtils
{
public const string SkyboxExtension = ".cgvsb";
private static readonly string AppData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
public static readonly string ApplicationPath = Path.Combine(Directory.GetParent(Application.dataPath)?.FullName);
public static readonly string SkyboxesPath = Path.Combine(ApplicationPath, "Cybergrind", "VolumetricSkyboxes");
public static readonly string PreferencesPath = Path.Combine(ApplicationPath, "Preferences");
public static readonly string AssemblyPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
public static readonly string DataPath = Path.Combine(AppData, "VolumetricSkyboxes");
public static readonly string UnpackedSkyboxesPath = Path.Combine(DataPath, "Unpacked");
public static bool HasValidExtenstion(FileInfo path)
{
return ".cgvsb".Equals(path.Extension.ToLower());
}
}
}
namespace VolumetricSkyboxes.UI
{
[RequireComponent(typeof(Button))]
public class ControllerPointerToggle : MonoBehaviour
{
[Serializable]
public class ToggleEvent : UnityEvent<bool>
{
}
[SerializeField]
public Image onImage;
public ToggleEvent onValueChanged = new ToggleEvent();
[SerializeField]
private bool m_IsOn;
private Button _button;
public bool isOn
{
get
{
return m_IsOn;
}
set
{
m_IsOn = value;
((UnityEvent<bool>)onValueChanged).Invoke(m_IsOn);
}
}
private void Awake()
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Expected O, but got Unknown
_button = ((Component)this).GetComponent<Button>();
((UnityEvent)_button.onClick).AddListener(new UnityAction(InternalToggle));
}
private void Start()
{
SetCheckmark();
}
private void InternalToggle()
{
isOn = !isOn;
SetCheckmark();
}
private void SetCheckmark()
{
((Behaviour)onImage).enabled = m_IsOn;
}
}
}
namespace VolumetricSkyboxes.Patches
{
[HarmonyPatch(typeof(CustomFogController))]
public class CustomFogControllerPatch
{
private static BackgroundCamera _backgroundCam;
private static void NotifyBackgroundCamera(bool disabled, bool levelStarted, float r, float g, float b, float min, float max)
{
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
if (levelStarted)
{
if ((Object)(object)_backgroundCam == (Object)null)
{
_backgroundCam = Object.FindObjectOfType<BackgroundCamera>();
}
if (!((Object)(object)_backgroundCam == (Object)null))
{
_backgroundCam.SetCurrentEnvironmentalFog(disabled, new Color(r, g, b), min, max);
}
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(CustomFogController), "SetState")]
public static void CustomFogController_SetState_Postfix(CustomFogController __instance, float ___redAmount, float ___greenAmount, float ___blueAmount, float ___startDistance, float ___endDistance, bool ___levelStarted)
{
NotifyBackgroundCamera(GetDisabled(__instance), ___levelStarted, ___redAmount, ___greenAmount, ___blueAmount, ___startDistance, ___endDistance);
}
[HarmonyPostfix]
[HarmonyPatch(typeof(CustomFogController), "UpdateColor")]
public static void CustomFogController_UpdateColor_Postfix(CustomFogController __instance, float ___redAmount, float ___greenAmount, float ___blueAmount, float ___startDistance, float ___endDistance, bool ___levelStarted)
{
NotifyBackgroundCamera(GetDisabled(__instance), ___levelStarted, ___redAmount, ___greenAmount, ___blueAmount, ___startDistance, ___endDistance);
}
[HarmonyPostfix]
[HarmonyPatch(typeof(CustomFogController), "SetFogStartDistance")]
public static void CustomFogController_SetFogStartDistance_Postfix(CustomFogController __instance, float ___redAmount, float ___greenAmount, float ___blueAmount, float ___startDistance, float ___endDistance, bool ___levelStarted)
{
NotifyBackgroundCamera(GetDisabled(__instance), ___levelStarted, ___redAmount, ___greenAmount, ___blueAmount, ___startDistance, ___endDistance);
}
[HarmonyPostfix]
[HarmonyPatch(typeof(CustomFogController), "SetFogEndDistance")]
public static void CustomFogController_SetFogEndDistance_Postfix(CustomFogController __instance, float ___redAmount, float ___greenAmount, float ___blueAmount, float ___startDistance, float ___endDistance, bool ___levelStarted)
{
NotifyBackgroundCamera(GetDisabled(__instance), ___levelStarted, ___redAmount, ___greenAmount, ___blueAmount, ___startDistance, ___endDistance);
}
[HarmonyPostfix]
[HarmonyPatch(typeof(CustomFogController), "SetPreset")]
public static void CustomFogController_SetPreset_Postfix(CustomFogController __instance, float ___redAmount, float ___greenAmount, float ___blueAmount, float ___startDistance, float ___endDistance, bool ___levelStarted)
{
NotifyBackgroundCamera(GetDisabled(__instance), ___levelStarted, ___redAmount, ___greenAmount, ___blueAmount, ___startDistance, ___endDistance);
}
[HarmonyPostfix]
[HarmonyPatch(typeof(CustomFogController), "ResetValues")]
public static void CustomFogController_ResetValues_Postfix(CustomFogController __instance, float ___redAmount, float ___greenAmount, float ___blueAmount, float ___startDistance, float ___endDistance, bool ___levelStarted)
{
NotifyBackgroundCamera(GetDisabled(__instance), ___levelStarted, ___redAmount, ___greenAmount, ___blueAmount, ___startDistance, ___endDistance);
}
private static bool GetDisabled(CustomFogController instance)
{
return instance.GetPrivateProperty<bool>("fogDisabled");
}
}
[HarmonyPatch(typeof(CustomTextures))]
public class CustomTexturesPatch
{
[HarmonyPostfix]
[HarmonyPatch(typeof(CustomTextures), "Start")]
public static void CustomTextures_Start_Postfix(CustomTextures __instance, Material ___skyMaterial, Material[] ___gridMaterials)
{
MonoSingleton<VolumetricSkyboxesManager>.Instance.SaveTexturesEditor(___skyMaterial);
MonoSingleton<VolumetricSkyboxesManager>.Instance.SaveOriginalGridTextures(___gridMaterials);
}
[HarmonyPostfix]
[HarmonyPatch(typeof(CustomTextures), "SetTexture")]
public static void CustomTextures_SetTexture_Postfix(CustomTextures __instance, Dictionary<string, Texture2D> ___imageCache, string key, bool ___editBase, bool ___editTop, bool ___editTopRow)
{
if ((int)Traverse.Create((object)__instance).Field("currentEditMode").GetValue() == 1)
{
MonoSingleton<VolumetricSkyboxesManager>.Instance.ChangeOriginalGridTextures(___imageCache[key], ___editBase, ___editTop, ___editTopRow);
}
}
}
[HarmonyPatch(typeof(CameraController))]
public class CameraControllerPatch
{
private static Camera _backgroundCam;
[HarmonyPostfix]
[HarmonyPatch(typeof(CameraController), "Start")]
[HarmonyPriority(400)]
public static void CameraController_Start_Postfix(CameraController __instance)
{
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
//IL_0112: Unknown result type (might be due to invalid IL or missing references)
//IL_0117: Unknown result type (might be due to invalid IL or missing references)
if (!(((Component)__instance).tag == "MainCamera"))
{
return;
}
Camera[] cameras = Camera.allCameras;
Camera val = GetCamera("Main Camera");
Camera val2 = GetCamera("Virtual Camera");
if ((Object)(object)_backgroundCam != (Object)null)
{
return;
}
_backgroundCam = Object.Instantiate<Camera>(val2, ((Component)val).transform);
((Object)_backgroundCam).name = "Background Camera";
_backgroundCam.depth = val.depth - 1f;
if (!(SceneHelper.CurrentScene != "Endless"))
{
((Component)_backgroundCam).gameObject.AddComponent<BackgroundCamera>();
((Component)_backgroundCam).transform.position = ((Component)val).transform.position;
((Component)_backgroundCam).transform.rotation = ((Component)val).transform.rotation;
_backgroundCam.orthographic = false;
val.cullingMask &= ~RenderingUtils.BackgroundLayersMask;
_backgroundCam.cullingMask = RenderingUtils.BackgroundLayersMask;
val.clearFlags = (CameraClearFlags)3;
_backgroundCam.clearFlags = (CameraClearFlags)1;
Scene activeScene = SceneManager.GetActiveScene();
(from c in ((Scene)(ref activeScene)).GetRootGameObjects()
where ((Object)c).name == "Player"
select c).First();
}
Camera GetCamera(string name)
{
return cameras.First((Camera cam) => ((Object)cam).name == name);
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(CameraController), "LateUpdate")]
public static void CameraController_LateUpdate_Postfix(CameraController __instance)
{
if (!((Object)(object)_backgroundCam == (Object)null))
{
_backgroundCam.fieldOfView = __instance.cam.fieldOfView;
}
}
}
[HarmonyPatch]
public class PostProcessV2HandlerPatch
{
private static Camera m_backgroundCam;
private static Camera BackgroundCam
{
get
{
if (!Object.op_Implicit((Object)(object)m_backgroundCam))
{
CameraController instance = MonoSingleton<CameraController>.Instance;
if (instance == null)
{
return null;
}
Camera cam = instance.cam;
if (cam == null)
{
return null;
}
Transform obj = ((Component)cam).transform.Find("Background Camera");
if (obj == null)
{
return null;
}
return ((Component)obj).GetComponent<Camera>();
}
return m_backgroundCam;
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(PostProcessV2_Handler), "SetupRTs")]
[HarmonyPriority(401)]
public static void PostProcessV2_Handler_SetupRTs_Postfix(PostProcessV2_Handler __instance, RenderBuffer[] ___buffers, RenderTexture ___depthBuffer, Material ___screenNormal, ref bool ___reinitializeTextures)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)BackgroundCam == (Object)null))
{
BackgroundCam.SetTargetBuffers(___buffers, ___depthBuffer.depthBuffer);
___screenNormal.SetTexture("_DepthBuffer", (Texture)(object)___depthBuffer);
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(PostProcessV2_Handler), "OnPreRenderCallback")]
[HarmonyPriority(402)]
public static void PostProcessV2_Handler_OnPreRenderCallback_Postfix(PostProcessV2_Handler __instance, RenderBuffer[] ___buffers, RenderTexture ___depthBuffer)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)BackgroundCam == (Object)null))
{
BackgroundCam.SetTargetBuffers(___buffers, ___depthBuffer.depthBuffer);
}
}
}
}
namespace VolumetricSkyboxes.Models
{
[JsonObject(/*Could not decode attribute arguments.*/)]
public class VolumetricSkyboxesList
{
[JsonProperty]
private HashSet<string> _guids = new HashSet<string>();
public static string CurrentPath => Path.Combine(PathsUtils.PreferencesPath, "VolumetricSkyboxes.json");
public HashSet<string> Guids => _guids;
public int Count => _guids.Count;
public event Action OnChanged;
public void Add(string guid)
{
_guids.Add(guid);
this.OnChanged?.Invoke();
}
public void Remove(string guid)
{
_guids.Remove(guid);
this.OnChanged?.Invoke();
}
public bool Has(string guid)
{
return _guids.Contains(guid);
}
}
}
namespace VolumetricSkyboxes.Components
{
public class ArenaLightingManager : MonoBehaviour
{
[SerializeField]
public Image colorImage;
[SerializeField]
private Slider redSlider;
[SerializeField]
private Slider greenSlider;
[SerializeField]
private Slider blueSlider;
[SerializeField]
private Slider intensitySlider;
[SerializeField]
private ControllerPointerToggle overrideLightingToggle;
private List<Tuple<Light, float>> _lights;
private OutdoorLightMaster _olm;
private PrefsManager _prefsManager;
private VolumetricSkyboxesManager _manager;
private VolumetricSkyboxContainer _lightingSource;
private float intensityAmount;
private float redAmount;
private float greenAmount;
private float blueAmount;
private bool skyboxesOverrideLighting;
private bool skyboxesOverridePanorama;
private void Awake()
{
_olm = MonoSingleton<OutdoorLightMaster>.Instance;
_prefsManager = MonoSingleton<PrefsManager>.Instance;
_manager = MonoSingleton<VolumetricSkyboxesManager>.Instance;
_lights = (from light in ((Component)_olm).gameObject.GetComponentsInChildren<Light>()
where (int)light.type == 1
select new Tuple<Light, float>(light, light.intensity)).ToList();
intensityAmount = _prefsManager.GetFloatLocal("cyberGrind.volumetricSkyboxes.arenaLighting.intensity", 1f);
redAmount = _prefsManager.GetFloatLocal("cyberGrind.volumetricSkyboxes.arenaLighting.r", 1f);
greenAmount = _prefsManager.GetFloatLocal("cyberGrind.volumetricSkyboxes.arenaLighting.g", 1f);
blueAmount = _prefsManager.GetFloatLocal("cyberGrind.volumetricSkyboxes.arenaLighting.b", 1f);
skyboxesOverrideLighting = _prefsManager.GetBoolLocal("cyberGrind.volumetricSkyboxes.arenaLighting.useSkyboxesLighting", true);
}
private void Start()
{
redSlider.value = redAmount;
greenSlider.value = greenAmount;
blueSlider.value = blueAmount;
intensitySlider.value = intensityAmount;
overrideLightingToggle.isOn = skyboxesOverrideLighting;
((UnityEvent<bool>)overrideLightingToggle.onValueChanged).AddListener((UnityAction<bool>)SetUseSkyboxLighting);
VolumetricSkyboxesManager manager = _manager;
manager.OnSkyboxesListChanged = (Action<ICollection<VolumetricSkyboxContainer>>)Delegate.Combine(manager.OnSkyboxesListChanged, new Action<ICollection<VolumetricSkyboxContainer>>(SkyboxesListChanged));
SkyboxesListChanged(_manager.Skyboxes);
UpdateLightingSettings();
}
private void OnDestroy()
{
VolumetricSkyboxesManager manager = _manager;
manager.OnSkyboxesListChanged = (Action<ICollection<VolumetricSkyboxContainer>>)Delegate.Remove(manager.OnSkyboxesListChanged, new Action<ICollection<VolumetricSkyboxContainer>>(SkyboxesListChanged));
}
public void SetRed(float amount)
{
redAmount = amount;
UpdateLightingSettings();
}
public void SetGreen(float amount)
{
greenAmount = amount;
UpdateLightingSettings();
}
public void SetBlue(float amount)
{
blueAmount = amount;
UpdateLightingSettings();
}
public void SetIntensity(float amount)
{
intensityAmount = amount;
UpdateLightingSettings();
}
public void SetUseSkyboxLighting(bool value)
{
skyboxesOverrideLighting = value;
UpdateLightingSettings();
}
private void UpdateLightingSettings()
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
Color lightingColor = default(Color);
float lightingIntensity;
if (skyboxesOverrideLighting && _lightingSource != null)
{
lightingColor = _lightingSource.Data.lightingColor;
lightingIntensity = _lightingSource.Data.lightingIntensity;
}
else
{
((Color)(ref lightingColor))..ctor(redAmount, greenAmount, blueAmount);
lightingIntensity = intensityAmount;
}
foreach (var (val2, num2) in _lights)
{
val2.color = lightingColor;
val2.intensity = num2 * lightingIntensity;
((Graphic)colorImage).color = lightingColor;
}
_prefsManager.SetFloatLocal("cyberGrind.volumetricSkyboxes.arenaLighting.intensity", intensityAmount);
_prefsManager.SetFloatLocal("cyberGrind.volumetricSkyboxes.arenaLighting.r", redAmount);
_prefsManager.SetFloatLocal("cyberGrind.volumetricSkyboxes.arenaLighting.g", greenAmount);
_prefsManager.SetFloatLocal("cyberGrind.volumetricSkyboxes.arenaLighting.b", blueAmount);
_prefsManager.SetBoolLocal("cyberGrind.volumetricSkyboxes.arenaLighting.useSkyboxesLighting", skyboxesOverrideLighting);
}
private void SkyboxesListChanged(ICollection<VolumetricSkyboxContainer> containers)
{
_lightingSource = containers.LastOrDefault((VolumetricSkyboxContainer t) => t.Data.customLighting);
UpdateLightingSettings();
}
}
[RequireComponent(typeof(Camera))]
public class BackgroundCamera : MonoBehaviour
{
public Camera camera;
private bool _origFogState;
private Color _origFogColor;
private float _origFogMin;
private float _origFogMax;
private VolumetricSkyboxContainer _fogSource;
private VolumetricSkyboxesManager _manager;
private void Awake()
{
camera = ((Component)this).GetComponent<Camera>();
}
private void Start()
{
_manager = MonoSingleton<VolumetricSkyboxesManager>.Instance;
VolumetricSkyboxesManager manager = _manager;
manager.OnSkyboxesListChanged = (Action<ICollection<VolumetricSkyboxContainer>>)Delegate.Combine(manager.OnSkyboxesListChanged, new Action<ICollection<VolumetricSkyboxContainer>>(UpdateFogSource));
UpdateFogSource(_manager.Skyboxes);
}
private void OnDestroy()
{
VolumetricSkyboxesManager manager = _manager;
manager.OnSkyboxesListChanged = (Action<ICollection<VolumetricSkyboxContainer>>)Delegate.Remove(manager.OnSkyboxesListChanged, new Action<ICollection<VolumetricSkyboxContainer>>(UpdateFogSource));
}
public void SetCurrentEnvironmentalFog(bool fogDisabled, Color fogColor, float fogStartDistance, float fogEndDistance)
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
_origFogState = !fogDisabled;
_origFogColor = fogColor;
_origFogMin = fogStartDistance;
_origFogMax = fogEndDistance;
}
private void OnPreCull()
{
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
RenderSettings.fog = _fogSource != null && _fogSource.Data.customFog;
if (RenderSettings.fog)
{
RenderSettings.fogColor = _fogSource.Data.fogColor;
RenderSettings.fogStartDistance = _fogSource.Data.fogMinimum;
RenderSettings.fogEndDistance = _fogSource.Data.fogMaximum;
}
}
private void OnPostRender()
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
RenderSettings.fog = _origFogState;
RenderSettings.fogColor = _origFogColor;
RenderSettings.fogStartDistance = _origFogMin;
RenderSettings.fogEndDistance = _origFogMax;
}
private void UpdateFogSource(ICollection<VolumetricSkyboxContainer> containers)
{
_fogSource = containers.LastOrDefault((VolumetricSkyboxContainer t) => t.Data.customFog);
}
}
public class SkyboxesLowerPanel : MonoBehaviour
{
[SerializeField]
public Button showVolumetricSkyboxes;
[SerializeField]
public Button settingsBtn;
}
public class SkyboxParallaxEffect : MonoBehaviour
{
public float parallaxCoefficient = 1f;
private CameraController _cameraController;
private Vector3 _playerPosition;
private void Awake()
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
_playerPosition = ((Component)MonoSingleton<CameraController>.Instance).transform.position;
_cameraController = MonoSingleton<CameraController>.Instance;
}
private void Update()
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
Vector3 val = ((Component)_cameraController).transform.position - _playerPosition;
Transform transform = ((Component)this).transform;
transform.position += val * (1f - parallaxCoefficient);
_playerPosition = ((Component)_cameraController).transform.position;
}
}
public class VolumetricSkyboxEntry : MonoBehaviour
{
public Button button;
public Image icon;
public Image iconInset;
public TMP_Text title;
public TMP_Text author;
}
[ConfigureSingleton(/*Could not decode attribute arguments.*/)]
public class VolumetricSkyboxesBootstrap : MonoSingleton<VolumetricSkyboxesBootstrap>
{
[SerializeField]
public GameObject browsePanel;
[SerializeField]
public VolumetricSkyboxesBrowser skyboxesBrowser;
[SerializeField]
public ArenaLightingManager arenaLightingManager;
[SerializeField]
public GameObject settingsPanel;
[SerializeField]
public GameObject lowerPanel;
protected void Awake()
{
Instantiate();
}
public void Instantiate()
{
//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
//IL_01c2: Expected O, but got Unknown
//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
//IL_01df: Expected O, but got Unknown
CustomTextures customTextures = Object.FindObjectOfType<CustomTextures>(true);
GameObject @private = customTextures.GetPrivate<GameObject>("gridWrapper");
ShopButton val = GetShopButton("skyboxBtn");
GameObject defaultGridWrapper = customTextures.GetPrivate<GameObject>("gridWrapper");
Transform parent = @private.transform.parent;
Transform parent2 = ((Component)Object.FindObjectOfType<CyberGrindSettingsNavigator>()).transform.Find("Logic/Themes");
((Component)skyboxesBrowser).transform.parent = parent2;
((Component)arenaLightingManager).transform.parent = parent2;
browsePanel.transform.SetParent(((Component)parent).transform, false);
lowerPanel.transform.SetParent(((Component)parent).transform, false);
settingsPanel.transform.SetParent(((Component)parent).transform, false);
SkyboxesLowerPanel component = lowerPanel.GetComponent<SkyboxesLowerPanel>();
browsePanel.gameObject.SetActive(false);
lowerPanel.SetActive(false);
settingsPanel.SetActive(false);
string[] array = new string[3] { "gridBtn", "emissionBtn", "fogBtn" };
foreach (string fieldName2 in array)
{
ShopButton obj = GetShopButton(fieldName2);
obj.toDeactivate = obj.toDeactivate.Concat((IEnumerable<GameObject>)(object)new GameObject[3] { browsePanel, lowerPanel, settingsPanel }).ToArray();
}
val.toActivate = val.toActivate.Concat((IEnumerable<GameObject>)(object)new GameObject[1] { lowerPanel }).ToArray();
((UnityEvent)component.showVolumetricSkyboxes.onClick).AddListener((UnityAction)delegate
{
bool flag = !browsePanel.activeSelf;
browsePanel.SetActive(flag);
defaultGridWrapper.SetActive(!flag && !settingsPanel.activeSelf);
settingsPanel.SetActive(false);
});
((UnityEvent)component.settingsBtn.onClick).AddListener((UnityAction)delegate
{
browsePanel.SetActive(false);
defaultGridWrapper.SetActive(false);
settingsPanel.SetActive(true);
});
ShopButton GetShopButton(string fieldName)
{
return ((Component)customTextures.GetPrivate<Button>(fieldName)).gameObject.GetComponent<ShopButton>();
}
}
}
public class VolumetricSkyboxesBrowser : DirectoryTreeBrowser<VolumetricSkyboxBundleData>
{
private readonly Dictionary<string, Sprite> _spriteCache = new Dictionary<string, Sprite>();
private VolumetricSkyboxesList _skyboxes = new VolumetricSkyboxesList();
private VolumetricSkyboxesManager _skyboxesManager;
protected override int maxPageLength => 6;
protected override IDirectoryTree<VolumetricSkyboxBundleData> baseDirectory => new SkyboxesFileTree(PathsUtils.SkyboxesPath);
private void Awake()
{
base.currentDirectory = ((DirectoryTreeBrowser<VolumetricSkyboxBundleData>)this).baseDirectory;
_skyboxesManager = MonoSingleton<VolumetricSkyboxesManager>.Instance;
LoadSkyboxesList();
}
private void Start()
{
_skyboxes.OnChanged += SaveSkyboxes;
_skyboxesManager.AddSkyboxes(_skyboxes.Guids);
}
private void OnDestroy()
{
_skyboxes.OnChanged += SaveSkyboxes;
}
private void LoadSkyboxesList()
{
VolumetricSkyboxesList volumetricSkyboxesList;
using (StreamReader streamReader = new StreamReader(File.Open(VolumetricSkyboxesList.CurrentPath, FileMode.OpenOrCreate)))
{
volumetricSkyboxesList = JsonConvert.DeserializeObject<VolumetricSkyboxesList>(streamReader.ReadToEnd());
}
if (volumetricSkyboxesList != null)
{
_skyboxes = volumetricSkyboxesList;
}
((DirectoryTreeBrowser<VolumetricSkyboxBundleData>)this).Rebuild(true);
}
public void SaveSkyboxesList()
{
File.WriteAllText(VolumetricSkyboxesList.CurrentPath, JsonConvert.SerializeObject((object)_skyboxes));
}
public void ReloadSkyboxes()
{
_skyboxesManager.ReloadSkyboxes();
_skyboxesManager.ClearCache();
((DirectoryTreeBrowser<VolumetricSkyboxBundleData>)this).Rebuild(true);
}
protected override Action BuildLeaf(VolumetricSkyboxBundleData skybox, int indexInPage)
{
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Expected O, but got Unknown
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
GameObject go = Object.Instantiate<GameObject>(base.itemButtonTemplate, base.itemParent, false);
VolumetricSkyboxEntry component = go.GetComponent<VolumetricSkyboxEntry>();
if (_skyboxes.Has(skybox.guid))
{
((Graphic)((Component)component.button).gameObject.GetComponent<Image>()).color = Color.green;
((Graphic)component.iconInset).color = Color.green;
}
((UnityEvent)component.button.onClick).AddListener((UnityAction)delegate
{
if (!_skyboxes.Has(skybox.guid))
{
_skyboxes.Add(skybox.guid);
_skyboxesManager.AddSkybox(skybox.guid);
}
else
{
_skyboxes.Remove(skybox.guid);
_skyboxesManager.RemoveSkybox(skybox.guid);
}
((DirectoryTreeBrowser<VolumetricSkyboxBundleData>)this).Rebuild(false);
});
component.title.text = skybox.skyboxName;
component.author.text = "by " + skybox.author;
Sprite val = LoadIcon(skybox.guid);
if (val != null)
{
component.icon.sprite = val;
}
go.SetActive(true);
return delegate
{
Object.Destroy((Object)(object)go);
};
}
protected override Action BuildDirectory(IDirectoryTree<VolumetricSkyboxBundleData> folder, int indexInPage)
{
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Expected O, but got Unknown
GameObject btn = Object.Instantiate<GameObject>(base.folderButtonTemplate, base.itemParent, false);
((UnityEventBase)btn.GetComponent<Button>().onClick).RemoveAllListeners();
((UnityEvent)btn.GetComponent<Button>().onClick).AddListener((UnityAction)delegate
{
base.StepDown(folder);
});
btn.GetComponentInChildren<TMP_Text>().text = folder.name;
btn.SetActive(true);
return delegate
{
Object.Destroy((Object)(object)btn);
};
}
private Sprite LoadIcon(string guid)
{
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Expected O, but got Unknown
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
if (_spriteCache.TryGetValue(guid, out var value))
{
return value;
}
try
{
byte[] array = File.ReadAllBytes(Path.Combine(PathsUtils.UnpackedSkyboxesPath, guid, "icon.png"));
Texture2D val = new Texture2D(0, 0, (TextureFormat)4, false)
{
filterMode = (FilterMode)0
};
ImageConversion.LoadImage(val, array);
Sprite val2 = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f);
((Texture)val2.texture).filterMode = (FilterMode)0;
_spriteCache[guid] = val2;
return val2;
}
catch (Exception)
{
return null;
}
}
private void SaveSkyboxes()
{
File.WriteAllText(VolumetricSkyboxesList.CurrentPath, JsonConvert.SerializeObject((object)_skyboxes));
}
}
[ConfigureSingleton(/*Could not decode attribute arguments.*/)]
public class VolumetricSkyboxesLoader : MonoSingleton<VolumetricSkyboxesLoader>
{
private readonly Dictionary<SongIdentifier, VolumetricSkyboxContainer> _cache = new Dictionary<SongIdentifier, VolumetricSkyboxContainer>();
public VolumetricSkyboxContainer Load(string guid)
{
if (_cache.TryGetValue(SongIdentifier.op_Implicit(guid), out var value))
{
return value;
}
_cache.Add(SongIdentifier.op_Implicit(guid), VolumetricSkyboxContainer.FromGuid(guid));
return _cache[SongIdentifier.op_Implicit(guid)];
}
}
public class VolumetricSkyboxesManager : MonoSingleton<VolumetricSkyboxesManager>
{
private const float NearClipPlaneThreshold = 0.1f;
private const float FarClipPlaneThreshold = 20000f;
private static readonly Vector3 ArenaPosition = new Vector3(0f, 25f, 60f);
private static readonly HashSet<Type> UndesiredComponents = new HashSet<Type>
{
typeof(Collider),
typeof(MonoSingleton),
typeof(HurtZone),
typeof(Enemy),
typeof(EnemyIdentifier),
typeof(Portal),
typeof(AddForce)
};
public Action<ICollection<VolumetricSkyboxContainer>> OnSkyboxesListChanged;
private readonly Dictionary<string, VolumetricSkyboxContainer> _skyboxes = new Dictionary<string, VolumetricSkyboxContainer>();
private readonly Dictionary<string, GameObject> _skyboxObjects = new Dictionary<string, GameObject>();
private Material _originalSkyboxMaterial;
private readonly Texture[] _originalGridTextures = (Texture[])(object)new Texture[3];
public ICollection<VolumetricSkyboxContainer> Skyboxes => _skyboxes.Values;
public void SaveTexturesEditor(Material mat)
{
_originalSkyboxMaterial = mat;
}
public void SaveOriginalGridTextures(Material[] gridMaterials)
{
for (int i = 0; i < _originalGridTextures.Length; i++)
{
_originalGridTextures[i] = gridMaterials[i].mainTexture;
}
}
public void ReloadSkyboxes(bool forced = false)
{
string[] files = Directory.GetFiles(PathsUtils.SkyboxesPath, "*.cgvsb", SearchOption.AllDirectories);
for (int i = 0; i < files.Length; i++)
{
SkyboxFileUtility.UnpackSkybox(files[i], forced);
}
}
public void ClearCache()
{
HashSet<string> hashSet = (from skyboxFile in Directory.GetFiles(PathsUtils.SkyboxesPath, "*.cgvsb", SearchOption.AllDirectories)
select SkyboxFileUtility.UnpackSkybox(skyboxFile) into data
where !string.IsNullOrEmpty(data.guid)
select data.guid).ToHashSet();
DirectoryInfo[] directories = new DirectoryInfo(PathsUtils.UnpackedSkyboxesPath).GetDirectories();
foreach (DirectoryInfo directoryInfo in directories)
{
if (!hashSet.Contains(directoryInfo.Name))
{
try
{
directoryInfo.Delete(recursive: true);
}
catch (Exception)
{
}
}
}
}
public void AddSkyboxes(ICollection<string> guids)
{
foreach (string guid in guids)
{
AddSkybox(guid);
}
}
public void AddSkybox(string guid)
{
if (_skyboxObjects.ContainsKey(guid))
{
return;
}
VolumetricSkyboxContainer volumetricSkyboxContainer = MonoSingleton<VolumetricSkyboxesLoader>.Instance.Load(guid);
if (volumetricSkyboxContainer != null)
{
GameObject skyboxGameObject = volumetricSkyboxContainer.SkyboxGameObject;
if ((Object)(object)skyboxGameObject == (Object)null || (Object)(object)GetAnchor(skyboxGameObject) == (Object)null)
{
Debug.LogError((object)"Invalid skybox: GameObject is null or doesn't have an ArenaAnchor object in its root");
return;
}
RemoveUndesiredComponents(skyboxGameObject);
GameObject val = Object.Instantiate<GameObject>(skyboxGameObject);
_skyboxObjects.Add(guid, val);
_skyboxes.Add(guid, volumetricSkyboxContainer);
ChangePanorama();
ChangeGridTextures();
OnSkyboxesListChanged?.Invoke(_skyboxes.Values);
val.AddComponent<SkyboxParallaxEffect>().parallaxCoefficient = volumetricSkyboxContainer.Data.ParallaxCoefficient;
AdjustSkyboxPosition(val, volumetricSkyboxContainer.Data.ParallaxCoefficient);
MoveToBackgroundLayer(val);
SetLightsCullingMask(val);
RemoveAnchor(val);
SetClipPlanes();
}
}
public void RemoveSkybox(string guid)
{
if (_skyboxObjects.TryGetValue(guid, out var value))
{
_skyboxes.Remove(guid);
OnSkyboxesListChanged?.Invoke(_skyboxes.Values);
Object.Destroy((Object)(object)value);
_skyboxObjects.Remove(guid);
ChangePanorama();
ChangeGridTextures();
}
}
public void ChangePanorama()
{
if (MonoSingleton<PrefsManager>.Instance.GetBoolLocal("cyberGrind.volumetricSkyboxes.arenaLighting.useSkyboxesPanorama", true))
{
VolumetricSkyboxData val = _skyboxes.Values.Select((VolumetricSkyboxContainer entry) => entry.Data).FirstOrDefault((Func<VolumetricSkyboxData, bool>)((VolumetricSkyboxData data) => Object.op_Implicit((Object)(object)data.skyboxMaterial)));
if (val != null)
{
MonoSingleton<OutdoorLightMaster>.Instance.SetPrivate<Material>("skyboxMaterial", val.skyboxMaterial);
goto IL_0095;
}
}
MonoSingleton<OutdoorLightMaster>.Instance.SetPrivate<Material>("skyboxMaterial", _originalSkyboxMaterial);
goto IL_0095;
IL_0095:
MonoSingleton<OutdoorLightMaster>.Instance.UpdateSkyboxMaterial();
}
public void ChangeGridTextures()
{
VolumetricSkyboxesManager volumetricSkyboxesManager = this;
CustomTextures instance = Object.FindObjectOfType<CustomTextures>();
Material[] gridMaterials = instance.GetPrivate<Material[]>("gridMaterials");
if (MonoSingleton<PrefsManager>.Instance.GetBoolLocal("cyberGrind.volumetricSkyboxes.useSkyboxesGridTextures", true))
{
VolumetricSkyboxData val = _skyboxes.Values.Select((VolumetricSkyboxContainer entry) => entry.Data).FirstOrDefault((Func<VolumetricSkyboxData, bool>)((VolumetricSkyboxData data) => (Object)(object)data.baseGridTexture != (Object)null || (Object)(object)data.topRowGridTexture != (Object)null || (Object)(object)data.topGridTexture != (Object)null));
if (val != null)
{
SetTexture(0, (Texture)(object)val.baseGridTexture);
SetTexture(1, (Texture)(object)val.topGridTexture);
SetTexture(2, (Texture)(object)val.topRowGridTexture);
goto IL_00dc;
}
}
for (int i = 0; i < 3; i++)
{
gridMaterials[i].mainTexture = _originalGridTextures[i];
}
goto IL_00dc;
IL_00dc:
instance.SetPrivate("gridMaterials", gridMaterials);
void SetTexture(int index, Texture texture)
{
gridMaterials[index].mainTexture = (((Object)(object)texture != (Object)null) ? texture : _originalGridTextures[index]);
}
}
public void ChangeOriginalGridTextures(Texture2D texture, bool baseTex, bool top, bool topRow)
{
if (baseTex)
{
_originalGridTextures[0] = (Texture)(object)texture;
}
if (top)
{
_originalGridTextures[1] = (Texture)(object)texture;
}
if (topRow)
{
_originalGridTextures[2] = (Texture)(object)texture;
}
ChangeGridTextures();
}
private void SetClipPlanes()
{
Camera val = Object.FindObjectOfType<BackgroundCamera>()?.camera;
if (!((Object)(object)val == (Object)null))
{
val.nearClipPlane = Math.Max(_skyboxes.Values.Min((VolumetricSkyboxContainer entry) => entry.Data.NearClipPlane), 0.1f);
val.farClipPlane = Math.Min(_skyboxes.Values.Max((VolumetricSkyboxContainer entry) => entry.Data.FarClipPlane), 20000f);
}
}
private static void AdjustSkyboxPosition(GameObject skybox, float parallaxCoefficient)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
Transform anchor = GetAnchor(skybox);
Vector3 val = anchor.position - ArenaPosition;
Vector3 val2 = ((Component)MonoSingleton<CameraController>.Instance).transform.position - ArenaPosition;
skybox.transform.rotation = anchor.rotation;
Transform transform = skybox.transform;
transform.position += val2 * (1f - parallaxCoefficient) - val;
}
private static void MoveToBackgroundLayer(GameObject go)
{
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Expected O, but got Unknown
if (go.layer != RenderingUtils.SpecialLightingLayer)
{
go.layer = RenderingUtils.SandboxGrabbableLayer;
}
foreach (Transform item in go.transform)
{
Transform val = item;
if (((Component)val).gameObject.layer != RenderingUtils.SpecialLightingLayer)
{
((Component)val).gameObject.layer = RenderingUtils.SandboxGrabbableLayer;
}
if ((Object)(object)((Component)val).GetComponentInChildren<Transform>() != (Object)null)
{
MoveToBackgroundLayer(((Component)val).gameObject);
}
}
}
private static void SetLightsCullingMask(GameObject skybox)
{
Light[] componentsInChildren = skybox.GetComponentsInChildren<Light>(true);
foreach (Light val in componentsInChildren)
{
val.cullingMask = (((val.cullingMask & RenderingUtils.SpecialLightingLayerMask) != 0 && (val.cullingMask & RenderingUtils.SandboxGrabbableMask) == 0) ? RenderingUtils.SpecialLightingLayerMask : RenderingUtils.SandboxGrabbableMask);
}
}
private static void RemoveUndesiredComponents(GameObject skybox)
{
foreach (Component item in UndesiredComponents.SelectMany((Type componentType) => skybox.GetComponentsInChildren(componentType, true)))
{
Object.Destroy((Object)(object)item);
}
MeshRenderer[] componentsInChildren = skybox.GetComponentsInChildren<MeshRenderer>(true);
foreach (MeshRenderer val in componentsInChildren)
{
if (((Renderer)val).isPartOfStaticBatch)
{
Object.Destroy((Object)(object)val);
}
}
}
private static Transform GetAnchor(GameObject go)
{
return go.transform.Find("ArenaAnchor");
}
private static void RemoveAnchor(GameObject go)
{
Object.Destroy((Object)(object)((Component)go.transform.Find("ArenaAnchor")).gameObject);
}
}
public class VolumetricSkyboxesSettings : MonoBehaviour
{
[SerializeField]
public ControllerPointerToggle overrideSkyboxesToggle;
[SerializeField]
public ControllerPointerToggle overrideGridTexturesToggle;
private void Awake()
{
overrideSkyboxesToggle.isOn = MonoSingleton<PrefsManager>.Instance.GetBoolLocal("cyberGrind.volumetricSkyboxes.arenaLighting.useSkyboxesPanorama", true);
((UnityEvent<bool>)overrideSkyboxesToggle.onValueChanged).AddListener((UnityAction<bool>)delegate(bool value)
{
MonoSingleton<PrefsManager>.Instance.SetBoolLocal("cyberGrind.volumetricSkyboxes.arenaLighting.useSkyboxesPanorama", value);
MonoSingleton<VolumetricSkyboxesManager>.Instance.ChangePanorama();
});
overrideGridTexturesToggle.isOn = MonoSingleton<PrefsManager>.Instance.GetBoolLocal("cyberGrind.volumetricSkyboxes.useSkyboxesGridTextures", true);
((UnityEvent<bool>)overrideGridTexturesToggle.onValueChanged).AddListener((UnityAction<bool>)delegate(bool value)
{
MonoSingleton<PrefsManager>.Instance.SetBoolLocal("cyberGrind.volumetricSkyboxes.useSkyboxesGridTextures", value);
MonoSingleton<VolumetricSkyboxesManager>.Instance.ChangeGridTextures();
});
}
}
}
namespace VolumetricSkyboxes.Collections
{
public class SkyboxesFileTree : IDirectoryTree<VolumetricSkyboxBundleData>, IDirectoryTree
{
public string name { get; private set; }
public IDirectoryTree<VolumetricSkyboxBundleData> parent { get; set; }
public IEnumerable<IDirectoryTree<VolumetricSkyboxBundleData>> children { get; private set; }
public IEnumerable<VolumetricSkyboxBundleData> files { get; private set; }
private DirectoryInfo RealDirectory { get; }
public SkyboxesFileTree(string path, IDirectoryTree<VolumetricSkyboxBundleData> parent = null)
{
RealDirectory = new DirectoryInfo(path);
this.parent = parent;
Refresh();
}
private SkyboxesFileTree(DirectoryInfo realDirectory, IDirectoryTree<VolumetricSkyboxBundleData> parent = null)
{
RealDirectory = realDirectory;
this.parent = parent;
Refresh();
}
public void Refresh()
{
RealDirectory.Create();
name = RealDirectory.Name;
children = from dir in RealDirectory.GetDirectories()
select new SkyboxesFileTree(dir, this);
files = (from file in RealDirectory.GetFiles().Where(PathsUtils.HasValidExtenstion)
select SkyboxFileUtility.UnpackSkybox(file.FullName) into data
where data != null
select data).ToList();
}
public override bool Equals(object obj)
{
if (obj != null && !(GetType() != obj.GetType()))
{
return string.Equals(RealDirectory.FullName, (obj as DirectoryInfo)?.FullName, StringComparison.InvariantCultureIgnoreCase);
}
return false;
}
public override int GetHashCode()
{
return RealDirectory.GetHashCode();
}
public IEnumerable<VolumetricSkyboxBundleData> GetFilesRecursive()
{
return children.SelectMany((IDirectoryTree<VolumetricSkyboxBundleData> child) => child.GetFilesRecursive()).Concat(files);
}
}
}
namespace VolumetricSkyboxes.Assets
{
[AttributeUsage(AttributeTargets.Field)]
public class AddressableAsset : Attribute
{
public string Path { get; }
public Type AssetType { get; }
public AddressableAsset(string path, Type type)
{
Path = path;
AssetType = type;
}
}
[ConfigureSingleton(/*Could not decode attribute arguments.*/)]
public class AssetsManager : MonoSingleton<AssetsManager>
{
private const BindingFlags Flags = BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;
public void RegisterPrefabs(Assembly assembly)
{
Type[] types = assembly.GetTypes();
for (int i = 0; i < types.Length; i++)
{
CheckType(types[i]);
}
}
private static void CheckType(IReflect type)
{
type.GetFields(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic).ToList().ForEach(ProcessField);
}
private static void ProcessField(FieldInfo field)
{
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
if (field.FieldType.IsArray || !typeof(Object).IsAssignableFrom(field.FieldType) || !field.IsStatic)
{
return;
}
AddressableAsset addressableAsset = field.GetCustomAttribute<AddressableAsset>();
if (addressableAsset != null)
{
AsyncOperationHandle<GameObject> val = Addressables.LoadAssetAsync<GameObject>((object)addressableAsset.Path);
val.Completed += delegate(AsyncOperationHandle<GameObject> value)
{
field.SetValue(null, Convert.ChangeType(value.Result, addressableAsset.AssetType));
};
}
}
}
}