using System;
using System.Collections;
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.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Threading;
using BepInEx;
using Gravity;
using HarmonyLib;
using Newtonsoft.Json;
using Randomness;
using TMPro;
using ULTRAKILL.Portal;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.AddressableAssets.Initialization;
using UnityEngine.Audio;
using UnityEngine.Events;
using UnityEngine.ResourceManagement.AsyncOperations;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using VolumetricSkyboxes.Assets;
using VolumetricSkyboxes.Collections;
using VolumetricSkyboxes.Components;
using VolumetricSkyboxes.Components.SkyboxPipeline;
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.1.0")]
public class VolumetricSkyboxesPlugin : BaseUnityPlugin
{
[AddressableAsset("Assets/VolumetricSkyboxes/Bootstrap.prefab", typeof(GameObject))]
internal static GameObject _bootstrap;
public static Camera PortalCamera;
public static bool IsCybergrind;
private static readonly string CatalogDir;
private static Harmony _harmony;
private static bool _init;
static VolumetricSkyboxesPlugin()
{
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()
{
SceneManager.sceneLoaded += OnSceneLoaded;
_harmony.PatchAll();
}
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;
}
IsCybergrind = SceneHelper.CurrentScene == "Endless";
string currentScene = SceneHelper.CurrentScene;
if (!(currentScene == "Main Menu"))
{
if (currentScene == "Endless")
{
Object.Instantiate<GameObject>(_bootstrap);
Light componentInChildren = MonoSingleton<DefaultReferenceManager>.Instance.radianceEffect.GetComponentInChildren<Light>();
componentInChildren.cullingMask &= ~RenderingUtils.BackgroundLayersMask;
}
}
else
{
Init();
}
}
private static void Init()
{
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))
{
InitialSkyboxesSetup(text);
}
}
private static void InitialSkyboxesSetup(string initialDir)
{
string[] directories = Directory.GetDirectories(initialDir, "*", SearchOption.AllDirectories);
for (int i = 0; i < directories.Length; i++)
{
Directory.CreateDirectory(directories[i].Replace(initialDir, PathsUtils.SkyboxesPath));
}
directories = Directory.GetFiles(initialDir, "*.*", SearchOption.AllDirectories);
foreach (string obj in directories)
{
File.Copy(obj, obj.Replace(initialDir, PathsUtils.SkyboxesPath), overwrite: true);
}
Directory.Delete(initialDir, 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.1.0";
}
public class VolumetricSkyboxesTextureManager
{
private Material _originalSkyboxMaterial;
private readonly Texture[] _originalGridTextures = (Texture[])(object)new Texture[3];
public void SaveSkyboxMaterial(Material mat)
{
_originalSkyboxMaterial = mat;
}
public void SaveOriginalGridTextures(Material[] gridMaterials)
{
for (int i = 0; i < _originalGridTextures.Length; i++)
{
_originalGridTextures[i] = gridMaterials[i].mainTexture;
}
}
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();
}
public void ChangePanorama()
{
//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
OutdoorLightMaster instance = MonoSingleton<OutdoorLightMaster>.Instance;
if (MonoSingleton<PrefsManager>.Instance.GetBoolLocal("cyberGrind.volumetricSkyboxes.arenaLighting.useSkyboxesPanorama", true))
{
VolumetricSkyboxData val = MonoSingleton<VolumetricSkyboxesManager>.Instance.Skyboxes.Select((VolumetricSkyboxContainer entry) => entry.Data).FirstOrDefault((Func<VolumetricSkyboxData, bool>)((VolumetricSkyboxData data) => Object.op_Implicit((Object)(object)data.skyboxMaterial)));
if (val != null)
{
instance.SetPrivate<Material>("skyboxMaterial", val.skyboxMaterial);
instance.SetPrivate("skyboxRotation", 0f);
instance.skyboxAnimation = (SkyboxAnimation)0;
RenderSettings.skybox.SetFloat("_Rotation", 0f);
goto IL_00c7;
}
}
instance.SetPrivate<Material>("skyboxMaterial", _originalSkyboxMaterial);
instance.skyboxAnimation = (SkyboxAnimation)1;
goto IL_00c7;
IL_00c7:
MonoSingleton<OutdoorLightMaster>.Instance.UpdateSkyboxMaterial();
}
public void ChangeGridTextures()
{
Material[] gridMaterials = ((Renderer)MonoSingleton<EndlessGrid>.Instance.cubes[0][0].MeshRenderer).sharedMaterials;
if (MonoSingleton<PrefsManager>.Instance.GetBoolLocal("cyberGrind.volumetricSkyboxes.useSkyboxesGridTextures", true))
{
VolumetricSkyboxData val = MonoSingleton<VolumetricSkyboxesManager>.Instance.Skyboxes.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);
return;
}
}
for (int num = 0; num < 3; num++)
{
SetTexture(num, null);
}
void SetTexture(int index, Texture texture)
{
gridMaterials[index].mainTexture = (((Object)(object)texture != (Object)null) ? texture : _originalGridTextures[index]);
}
}
}
}
namespace VolumetricSkyboxes.Utils
{
public static class PortalUtils
{
private delegate void FollowUpdateDelegate(Follow instance);
private delegate void PortalManagerUpdateDelegate(PortalManagerV2 instance);
private static readonly FollowUpdateDelegate FollowUpdate = AccessTools.MethodDelegate<FollowUpdateDelegate>(AccessTools.Method(typeof(Follow), "Update", (Type[])null, (Type[])null), (object)null, true);
private static readonly PortalManagerUpdateDelegate PortalManagerUpdate = AccessTools.MethodDelegate<PortalManagerUpdateDelegate>(AccessTools.Method(typeof(PortalManagerV2), "Update", (Type[])null, (Type[])null), (object)null, true);
public static void FixComponentsPositioning(SkyboxParallaxEffect skybox, Matrix4x4 travelMatrix)
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: 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_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
MovingPlatform[] movingPlatforms = skybox.movingPlatforms;
foreach (MovingPlatform val in movingPlatforms)
{
val.targetPosition = ((Matrix4x4)(ref travelMatrix)).MultiplyPoint3x4(val.targetPosition);
val.currentPosition = ((Matrix4x4)(ref travelMatrix)).MultiplyPoint3x4(val.currentPosition);
val.originalPosition = ((Matrix4x4)(ref travelMatrix)).MultiplyPoint3x4(val.originalPosition);
}
Follow[] followers = skybox.followers;
foreach (Follow instance in followers)
{
FollowUpdate(instance);
}
}
public static void SyncPortals()
{
if (MonoSingleton<VolumetricSkyboxesManager>.Instance.portalsArePresent)
{
PortalManagerUpdate(MonoSingleton<PortalManagerV2>.Instance);
}
}
}
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 void ReloadSkyboxes(bool forced = false)
{
string[] files = Directory.GetFiles(PathsUtils.SkyboxesPath, "*.cgvsb", SearchOption.AllDirectories);
for (int i = 0; i < files.Length; i++)
{
UnpackSkybox(files[i], forced);
}
}
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;
}
}
public static void ClearCache()
{
HashSet<string> hashSet = (from skyboxFile in Directory.GetFiles(PathsUtils.SkyboxesPath, "*.cgvsb", SearchOption.AllDirectories)
select 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)
{
}
}
}
}
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 PortalLayer = LayerMask.NameToLayer("Portal");
public static readonly int SandboxGrabbableMask = 1 << SandboxGrabbableLayer;
public static readonly int SpecialLightingLayerMask = 1 << SpecialLightingLayer;
public static readonly int PortalLayerMask = 1 << SpecialLightingLayer;
public static readonly int BackgroundLayersMask = SandboxGrabbableMask | SpecialLightingLayerMask | PortalLayerMask;
public static void MoveToBackgroundLayer(GameObject gameObject)
{
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Expected O, but got Unknown
if (gameObject.layer != SpecialLightingLayer && gameObject.layer != PortalLayer)
{
gameObject.layer = SandboxGrabbableLayer;
}
foreach (Transform item in gameObject.transform)
{
Transform val = item;
if (((Component)val).gameObject.layer != SpecialLightingLayer && ((Component)val).gameObject.layer != PortalLayer)
{
((Component)val).gameObject.layer = SandboxGrabbableLayer;
}
if ((Object)(object)((Component)val).GetComponentInChildren<Transform>() != (Object)null)
{
MoveToBackgroundLayer(((Component)val).gameObject);
}
}
}
}
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(AudioMixerController))]
public class AudioMixerControllerPatch
{
private const string MuteSoundsKey = "cyberGrind.volumetricSkyboxes.muteSounds";
private const string AllVolume = "skyboxesVolume";
private const string AllPitch = "skyboxesPitch";
[HarmonyPostfix]
[HarmonyPatch(typeof(AudioMixerController), "UpdateSFXVolume")]
public static void AudioMixerController_UpdateSFXVolume_Postfix(AudioMixerController __instance, float ___temporaryDipAmount)
{
VolumetricSkyboxesBootstrap instance = MonoSingleton<VolumetricSkyboxesBootstrap>.Instance;
if (VolumetricSkyboxesPlugin.IsCybergrind && !((Object)(object)instance == (Object)null))
{
float num = default(float);
instance.skyboxesSound.SetFloat("skyboxesVolume", __instance.CalculateVolume((!MonoSingleton<PrefsManager>.Instance.GetBoolLocal("cyberGrind.volumetricSkyboxes.muteSounds", false) && (!instance.skyboxesSound.GetFloat("skyboxesPitch", ref num) || (double)num != 0.0)) ? __instance.sfxVolume : 0f) + ___temporaryDipAmount);
}
}
}
[HarmonyPatch]
public static class CoinPatch
{
[HarmonyPatch(typeof(Coin), "ReflectRevolver")]
public static class CoinReflectRevolverPatch
{
private static void Prefix()
{
PortalPatchCallerContext.FromPortalUnawareCaller = true;
}
private static void Finalizer()
{
PortalPatchCallerContext.FromPortalUnawareCaller = false;
}
}
[HarmonyPatch(typeof(Coin), "Punchflection")]
public static class CoinPunchflectionPatch
{
private static void Prefix()
{
PortalPatchCallerContext.FromPortalUnawareCaller = true;
}
private static void Finalizer()
{
PortalPatchCallerContext.FromPortalUnawareCaller = false;
}
}
[HarmonyPatch(typeof(Coin), "EnemyReflect")]
public static class CoinEnemyReflectPatch
{
private static void Prefix()
{
PortalPatchCallerContext.FromPortalUnawareCaller = true;
}
private static void Finalizer()
{
PortalPatchCallerContext.FromPortalUnawareCaller = false;
}
}
}
[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(EndlessGrid))]
public class EndlessGridPatch
{
[HarmonyPostfix]
[HarmonyPatch(typeof(EndlessGrid), "Start")]
public static void EndlessGrid_Start_Postfix(EndlessGrid __instance)
{
Light[] array = Object.FindObjectsByType<Light>((FindObjectsInactive)1, (FindObjectsSortMode)0);
foreach (Light obj in array)
{
obj.cullingMask &= ~RenderingUtils.BackgroundLayersMask;
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(EndlessGrid), "NextWave")]
public static void EndlessGrid_NextWave_Postfix(EndlessGrid __instance)
{
OnNextWave[] array = Object.FindObjectsOfType<OnNextWave>(true);
for (int i = 0; i < array.Length; i++)
{
array[i].Execute();
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(EndlessGrid), "OnTriggerEnter")]
public static void EndlessGrid_OnTriggerEnter_Postfix(EndlessGrid __instance, Collider other)
{
if (((Component)other).CompareTag("Player"))
{
((Component)((Component)__instance.waveNumberText).transform.parent.parent).gameObject.SetActive(!MonoSingleton<PrefsManager>.Instance.GetBoolLocal("cyberGrind.volumetricSkyboxes.disableScorePanel", false));
OnCybergrindStart[] array = Object.FindObjectsOfType<OnCybergrindStart>(true);
for (int i = 0; i < array.Length; i++)
{
array[i].Execute();
}
}
}
}
[HarmonyPatch(typeof(FinalDoorOpener))]
public class FinalDoorOpenerPatch
{
[HarmonyPrefix]
[HarmonyPatch(typeof(FinalDoorOpener), "OnEnable")]
public static void FinalDoorOpener_OnEnable_Prefix(FinalDoorOpener __instance)
{
if (!(SceneHelper.CurrentScene != "Endless"))
{
((MonoBehaviour)__instance).StartCoroutine(Execute());
}
}
private static IEnumerator Execute()
{
yield return (object)new WaitForSeconds(1f);
foreach (OnDoorsOpen item in from e in Object.FindObjectsOfType<OnDoorsOpen>(true)
orderby e.priority
select e)
{
item.Execute();
}
}
}
[HarmonyPatch]
public static class HookArmPatch
{
[HarmonyPatch(typeof(HookArm), "TryMigrateToAdjacentPortal")]
public static class HookArmTryMigrateToAdjacentPortalPatch
{
private static void Prefix()
{
PortalPatchCallerContext.FromPortalUnawareCaller = true;
}
private static void Finalizer()
{
PortalPatchCallerContext.FromPortalUnawareCaller = false;
}
}
[HarmonyPatch(typeof(HookArm), "FixedUpdate")]
public static class HookArmFixedUpdatePatch
{
private static void Prefix()
{
PortalPatchCallerContext.FromPortalUnawareCaller = true;
}
private static void Finalizer()
{
PortalPatchCallerContext.FromPortalUnawareCaller = false;
}
}
}
[HarmonyPatch]
public static class LayeringPatch
{
private static MethodBase[] TargetMethods()
{
return (from m in typeof(Object).GetMethods(BindingFlags.Static | BindingFlags.Public)
where m.Name == "Instantiate" && !m.IsGenericMethod && !m.ContainsGenericParameters
select m).Cast<MethodBase>().ToArray();
}
public static void Postfix(Object __result)
{
Handle(__result);
}
private static void Handle(Object obj)
{
if (!VolumetricSkyboxesPlugin.IsCybergrind || obj == (Object)null)
{
return;
}
GameObject val = (GameObject)(object)((obj is GameObject) ? obj : null);
if (val == null)
{
Component val2 = (Component)(object)((obj is Component) ? obj : null);
if (val2 != null)
{
Process(val2.gameObject);
}
}
else
{
Process(val);
}
}
private static void Process(GameObject go)
{
if (!((Object)(object)((Component)go.transform).GetComponentInParent<SkyboxParallaxEffect>() != (Object)null))
{
Light[] componentsInChildren = go.GetComponentsInChildren<Light>(true);
foreach (Light obj in componentsInChildren)
{
obj.cullingMask &= ~RenderingUtils.BackgroundLayersMask;
}
}
}
}
[HarmonyPatch]
public static class NailgunPatch
{
[HarmonyPatch(typeof(Nailgun), "Shoot")]
public static class NailgunShootPatch
{
private static void Prefix()
{
PortalPatchCallerContext.FromPortalUnawareCaller = true;
}
private static void Finalizer()
{
PortalPatchCallerContext.FromPortalUnawareCaller = false;
}
}
[HarmonyPatch(typeof(Nailgun), "BurstFire")]
public static class NailgunBurstFirePatch
{
private static void Prefix()
{
PortalPatchCallerContext.FromPortalUnawareCaller = true;
}
private static void Finalizer()
{
PortalPatchCallerContext.FromPortalUnawareCaller = false;
}
}
[HarmonyPatch(typeof(Nailgun), "SuperSaw")]
public static class NailgunSuperSawPatch
{
private static void Prefix()
{
PortalPatchCallerContext.FromPortalUnawareCaller = true;
}
private static void Finalizer()
{
PortalPatchCallerContext.FromPortalUnawareCaller = false;
}
}
}
[HarmonyPatch(typeof(NewMovement))]
public class NewMovementPatch
{
private static bool isCybergrind;
[HarmonyPostfix]
[HarmonyPatch(typeof(NewMovement), "Awake")]
public static void NewMovement_Awake_Postfix(NewMovement __instance, ref PortalAwarePlayerCollider ___portalAwareCollider)
{
if (!(SceneHelper.CurrentScene != "Endless"))
{
___portalAwareCollider = null;
}
}
}
[HarmonyPatch(typeof(PortalManagerV2))]
public class PortalManagerV2Patch
{
private delegate bool CheckPlayerTraversalsDelegate(PortalManagerV2 instance, out (IPortalTraveller traveller, PortalTravelDetails details) result);
private delegate void TraverseAndCallBackDelegate(PortalManagerV2 instance, in IPortalTraveller traveller, in PortalTravelDetails details);
private delegate void UpdatePortalAwareRenderersDelegate(PortalManagerV2 instance);
private static readonly CheckPlayerTraversalsDelegate CheckPlayerTraversals = AccessTools.MethodDelegate<CheckPlayerTraversalsDelegate>(AccessTools.Method(typeof(PortalManagerV2), "CheckPlayerTraversals", (Type[])null, (Type[])null), (object)null, true);
private static readonly TraverseAndCallBackDelegate TraverseAndCallBack = AccessTools.MethodDelegate<TraverseAndCallBackDelegate>(AccessTools.Method(typeof(PortalManagerV2), "TraverseAndCallBack", (Type[])null, (Type[])null), (object)null, true);
private static readonly UpdatePortalAwareRenderersDelegate UpdatePortalAwareRenderers = AccessTools.MethodDelegate<UpdatePortalAwareRenderersDelegate>(AccessTools.Method(typeof(PortalManagerV2), "UpdatePortalAwareRenderers", (Type[])null, (Type[])null), (object)null, true);
private static Camera m_backgroundCam;
[HarmonyPrefix]
[HarmonyPatch(typeof(PortalManagerV2), "AddTraveller")]
public static bool PortalManagerV2_AddTraveller_Prefix(PortalManagerV2 __instance)
{
return !VolumetricSkyboxesPlugin.IsCybergrind;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(PortalManagerV2), "Update")]
public static bool PortalManagerV2_Update_Prefix(PortalManagerV2 __instance)
{
if (!VolumetricSkyboxesPlugin.IsCybergrind || (Object)(object)GetBackgroundCamera() == (Object)null)
{
return true;
}
__instance.mainCamera = GetBackgroundCamera();
return true;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(PortalManagerV2), "LateUpdate")]
public static bool PortalManagerV2_LateUpdate_Prefix(PortalManagerV2 __instance, IPortalTraveller ___playerTraveller, ref Dictionary<int, Vector3> ___lastTravellerPositions, bool ___initialized, List<Portal> ___portalComponents)
{
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
if (!VolumetricSkyboxesPlugin.IsCybergrind || (Object)(object)MonoSingleton<VolumetricSkyboxesManager>.Instance == (Object)null)
{
return true;
}
MonoSingleton<VolumetricSkyboxesManager>.Instance.UpdateParallax();
if (___playerTraveller is BackgroundCamera && CheckPlayerTraversals(__instance, out var result))
{
TraverseAndCallBack(__instance, in result.Item1, in result.Item2);
___lastTravellerPositions[___playerTraveller.id] = ___playerTraveller.travellerPosition;
}
UpdatePortalAwareRenderers(__instance);
if (!___initialized)
{
return false;
}
PortalUtils.SyncPortals();
__instance.render.Setup(__instance.Scene, __instance.mainCamera, __instance.portalCamera);
return false;
}
[HarmonyPostfix]
[HarmonyPatch(typeof(PortalManagerV2), "FixedUpdate")]
public static void PortalManagerV2_FixedUpdate_Postfix(PortalManagerV2 __instance)
{
if (VolumetricSkyboxesPlugin.IsCybergrind)
{
PortalUtils.SyncPortals();
}
}
[HarmonyTranspiler]
[HarmonyPatch(typeof(PortalManagerV2), "OnPreRenderCallback")]
private static IEnumerable<CodeInstruction> PortalManagerV2_OnPreRenderCallback_Transpiler(IEnumerable<CodeInstruction> instructions)
{
//IL_002c: 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_004c: Expected O, but got Unknown
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Expected O, but got Unknown
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Expected O, but got Unknown
FieldInfo fieldInfo = AccessTools.Field(typeof(PostProcessV2_Handler), "mainCam");
FieldInfo fieldInfo2 = AccessTools.Field(typeof(VolumetricSkyboxesPlugin), "PortalCamera");
return new CodeMatcher(instructions, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[2]
{
new CodeMatch((OpCode?)OpCodes.Ldloc_0, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Ldfld, (object)fieldInfo, (string)null)
}).RemoveInstructions(2).Insert((CodeInstruction[])(object)new CodeInstruction[1]
{
new CodeInstruction(OpCodes.Ldsfld, (object)fieldInfo2)
})
.InstructionEnumeration();
}
private static Camera GetBackgroundCamera()
{
if ((Object)(object)m_backgroundCam != (Object)null)
{
return m_backgroundCam;
}
CameraController instance = MonoSingleton<CameraController>.Instance;
object backgroundCam;
if (instance == null)
{
backgroundCam = null;
}
else
{
Camera cam = instance.cam;
if (cam == null)
{
backgroundCam = null;
}
else
{
Transform obj = ((Component)cam).transform.Find("Background Camera");
backgroundCam = ((obj != null) ? ((Component)obj).GetComponent<Camera>() : null);
}
}
m_backgroundCam = (Camera)backgroundCam;
return m_backgroundCam;
}
}
[HarmonyPatch]
public static class PortalPatch
{
[HarmonyPrefix]
[HarmonyPatch(typeof(PortalManagerV2), "Update")]
public static bool PortalManagerV2_Update_Patch(PortalManagerV2 __instance, ref List<Portal> ___portalComponents)
{
___portalComponents = ___portalComponents.Where((Portal portal) => (Object)(object)portal != (Object)null).ToList();
return true;
}
}
public static class PortalPatchCallerContext
{
[ThreadStatic]
public static bool FromPortalUnawareCaller;
}
[HarmonyPatch]
public static class PortalPhysicsPatch
{
private static readonly PortalTraversalV2[] EmptyTraversals = Array.Empty<PortalTraversalV2>();
private static readonly ICastable RaycastCastable = (ICastable)new Raycast();
[HarmonyPrefix]
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
public static bool PortalPhysicsV2_Raycast_Prefix(ref bool __result, Vector3 origin, Vector3 direction, float maxDistance, int layerMask, ref PhysicsCastResult hitInfo, ref PortalTraversalV2[] portalTraversals, ref Vector3 endPoint, QueryTriggerInteraction queryTriggerInteraction)
{
//IL_0012: 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_0025: 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_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: 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 (!VolumetricSkyboxesPlugin.IsCybergrind || !PortalPatchCallerContext.FromPortalUnawareCaller)
{
return true;
}
PortalCastStateV2 val = new PortalCastStateV2
{
layerMask = layerMask,
queryTriggerInteraction = queryTriggerInteraction,
origin = origin,
direction = ((Vector3)(ref direction)).normalized,
maxDistance = maxDistance
};
endPoint = val.origin + val.direction * val.maxDistance;
int num = (RaycastCastable.Cast(val, ref hitInfo) ? 1 : 0);
portalTraversals = EmptyTraversals;
__result = num != 0;
return false;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(PortalPhysicsV2), "PortalCastAll")]
public static bool PortalPhysicsV2_PortalCastAll_Prefix(ICastable castable, PortalCastStateV2 state, ref PortalTraversalV2[] portalTraversals, ref PhysicsCastResult[] __result)
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
if (!VolumetricSkyboxesPlugin.IsCybergrind || !PortalPatchCallerContext.FromPortalUnawareCaller)
{
return true;
}
PhysicsCastResult[] array = castable.CastAll(state);
portalTraversals = EmptyTraversals;
__result = array;
return false;
}
}
[HarmonyPatch(typeof(RandomInstantiate))]
public class RandomInstantiatePatch
{
[HarmonyPostfix]
[HarmonyPatch(typeof(RandomInstantiate), "PerformTheAction")]
public static void RandomInstantiate_PerformTheAction_Postfix(RandomInstantiate __instance)
{
if (!VolumetricSkyboxesPlugin.IsCybergrind)
{
return;
}
List<GameObject> list = __instance.GetPrivate<List<GameObject>>("createdObjects");
foreach (GameObject item in list)
{
RenderingUtils.MoveToBackgroundLayer(item);
}
foreach (AudioSource item2 in list.SelectMany((GameObject go) => go.GetComponentsInChildren<AudioSource>(true)))
{
item2.outputAudioMixerGroup = MonoSingleton<VolumetricSkyboxesBootstrap>.Instance.skyboxesMixerGroup;
}
}
}
[HarmonyPatch]
public static class RevolverBeamPatch
{
[HarmonyPatch(typeof(RevolverBeam), "Shoot")]
public static class RevolverBeamShootPatch
{
private static void Prefix()
{
PortalPatchCallerContext.FromPortalUnawareCaller = true;
}
private static void Finalizer()
{
PortalPatchCallerContext.FromPortalUnawareCaller = false;
}
}
}
[HarmonyPatch(typeof(SpaceSkybox))]
public class SpaceSkyboxPatch
{
private static bool isCybergrind;
[HarmonyPrefix]
[HarmonyPatch(typeof(SpaceSkybox), "OnEnable")]
public static void SpaceSkybox_OnEnable_Prefix(SpaceSkybox __instance)
{
isCybergrind = SceneHelper.CurrentScene == "Endless";
}
[HarmonyPrefix]
[HarmonyPatch(typeof(SpaceSkybox), "UpdateCamera")]
public static bool SpaceSkybox_UpdateCamera_Prefix(SpaceSkybox __instance, Camera cam, ref Camera ___playerCam, ref Camera ___fakeCam, CameraController ___cc, RenderTexture ___skybox)
{
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
if (!isCybergrind)
{
return true;
}
if (!((Behaviour)__instance).isActiveAndEnabled)
{
return false;
}
if (Application.isPlaying)
{
___playerCam = ___cc.cam;
}
if ((Object)(object)cam != (Object)null)
{
___playerCam = cam;
}
if ((Object)(object)___playerCam == (Object)null)
{
return false;
}
((Component)___fakeCam).transform.rotation = ((Component)___playerCam).transform.rotation;
___fakeCam.cullingMask = RenderingUtils.BackgroundLayersMask;
___fakeCam.fieldOfView = ___playerCam.fieldOfView;
___fakeCam.targetTexture = ___skybox;
___fakeCam.Render();
return false;
}
}
[HarmonyPatch]
public static class ZapperPatch
{
[HarmonyPatch(typeof(Zapper), "FixedUpdate")]
public static class ZapperFixedUpdatePatch
{
private static void Prefix()
{
PortalPatchCallerContext.FromPortalUnawareCaller = true;
}
private static void Finalizer()
{
PortalPatchCallerContext.FromPortalUnawareCaller = false;
}
}
[HarmonyPatch(typeof(Zapper), "TryMigrateToAdjacentPortal")]
public static class ZapperTryMigrateToAdjacentPortalPatch
{
private static void Prefix()
{
PortalPatchCallerContext.FromPortalUnawareCaller = true;
}
private static void Finalizer()
{
PortalPatchCallerContext.FromPortalUnawareCaller = false;
}
}
}
[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)
{
if (SceneHelper.CurrentScene != "Endless")
{
VolumetricSkyboxesPlugin.PortalCamera = Camera.main;
}
else if (((Component)__instance).tag == "MainCamera")
{
SetupBackgroundCamera();
}
}
private static void SetupBackgroundCamera()
{
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_0109: Unknown result type (might be due to invalid IL or missing references)
//IL_010e: Unknown result type (might be due to invalid IL or missing references)
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;
VolumetricSkyboxesPlugin.PortalCamera = _backgroundCam;
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;
[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)GetBackgroundCamera() == (Object)null))
{
GetBackgroundCamera().SetTargetBuffers(___buffers, ___depthBuffer.depthBuffer);
___screenNormal.SetTexture("_DepthBuffer", (Texture)(object)___depthBuffer);
}
}
[HarmonyTranspiler]
[HarmonyPatch(typeof(PostProcessV2_Handler), "OnPreRenderCallback")]
public static IEnumerable<CodeInstruction> PostProcessV2_Handler_OnPreRenderCallback_Transpiler(IEnumerable<CodeInstruction> instructions)
{
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
//IL_00d1: Expected O, but got Unknown
//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
//IL_00df: Expected O, but got Unknown
//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ed: Expected O, but got Unknown
//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
//IL_0100: Expected O, but got Unknown
List<CodeInstruction> list = new List<CodeInstruction>(instructions);
MethodInfo methodInfo = AccessTools.Method(typeof(Object), "op_Equality", new Type[2]
{
typeof(Object),
typeof(Object)
}, (Type[])null);
FieldInfo fieldInfo = AccessTools.Field(typeof(VolumetricSkyboxesPlugin), "PortalCamera");
Label label = default(Label);
foreach (CodeInstruction item in list)
{
if (!(item.opcode != OpCodes.Brtrue) || !(item.opcode != OpCodes.Brtrue_S))
{
label = (Label)item.operand;
break;
}
}
list.InsertRange(0, (IEnumerable<CodeInstruction>)(object)new CodeInstruction[4]
{
new CodeInstruction(OpCodes.Ldarg_1, (object)null),
new CodeInstruction(OpCodes.Ldsfld, (object)fieldInfo),
new CodeInstruction(OpCodes.Call, (object)methodInfo),
new CodeInstruction(OpCodes.Brtrue, (object)label)
});
return list;
}
[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)GetBackgroundCamera() == (Object)null))
{
GetBackgroundCamera().SetTargetBuffers(___buffers, ___depthBuffer.depthBuffer);
}
}
private static Camera GetBackgroundCamera()
{
if ((Object)(object)m_backgroundCam != (Object)null)
{
return m_backgroundCam;
}
CameraController instance = MonoSingleton<CameraController>.Instance;
object backgroundCam;
if (instance == null)
{
backgroundCam = null;
}
else
{
Camera cam = instance.cam;
if (cam == null)
{
backgroundCam = null;
}
else
{
Transform obj = ((Component)cam).transform.Find("Background Camera");
backgroundCam = ((obj != null) ? ((Component)obj).GetComponent<Camera>() : null);
}
}
m_backgroundCam = (Camera)backgroundCam;
return m_backgroundCam;
}
}
}
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, IPortalTraveller
{
public Camera camera;
private bool _origFogState;
private Color _origFogColor;
private float _origFogMin;
private float _origFogMax;
private VolumetricSkyboxContainer _fogSource;
private VolumetricSkyboxesManager _manager;
public int id => ((Object)this).GetInstanceID();
public PortalTravellerType travellerType => (PortalTravellerType)5;
public Vector3 travellerPosition => ((Component)this).transform.position;
public Vector3 travellerVelocity => default(Vector3);
private void Awake()
{
camera = ((Component)this).GetComponent<Camera>();
}
private void Start()
{
_manager = MonoSingleton<VolumetricSkyboxesManager>.Instance;
MonoSingleton<PortalManagerV2>.Instance.AddPlayer((IPortalTraveller)(object)this);
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 bool? OnTravel(PortalTravelDetails details)
{
//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)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: 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_004b: 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_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)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: 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)
//IL_006b: 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)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
SkyboxParallaxEffect componentInParent = ((Component)PortalUtils.GetPortalObject(details.enterHandle)).GetComponentInParent<SkyboxParallaxEffect>();
if ((Object)(object)componentInParent == (Object)null)
{
Debug.LogWarning((object)"No parent skybox found for portal");
return false;
}
Transform transform = ((Component)componentInParent).transform;
Vector3 position = transform.position;
Matrix4x4 inverse = ((Matrix4x4)(ref details.enterToExit)).inverse;
Quaternion rotation = transform.rotation;
Vector3 val = ((Matrix4x4)(ref inverse)).MultiplyVector(rotation * Vector3.forward);
Vector3 normalized = ((Vector3)(ref val)).normalized;
val = ((Matrix4x4)(ref inverse)).MultiplyVector(rotation * Vector3.up);
transform.rotation = Quaternion.LookRotation(normalized, ((Vector3)(ref val)).normalized);
transform.position = ((Matrix4x4)(ref inverse)).MultiplyPoint3x4(position);
PortalUtils.FixComponentsPositioning(componentInParent, inverse);
PortalUtils.SyncPortals();
return true;
}
public void OnTeleportBlocked(PortalTravelDetails details)
{
}
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 ExplodeUponContact : MonoBehaviour
{
public int throwsLeft;
public GameObject thatExplosionTemplate;
private GameObject _thatExplosion;
private bool _collided;
public void Throw()
{
throwsLeft--;
}
private void OnCollisionEnter(Collision cols)
{
//IL_0007: 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)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: 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)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
ContactPoint val = cols.contacts[0];
if (_collided || throwsLeft >= 0 || !LayerMaskDefaults.IsMatchingLayer(((Component)((ContactPoint)(ref val)).otherCollider).gameObject.layer, (LMD)1))
{
return;
}
foreach (Transform item in ((Component)this).transform)
{
((Component)item).gameObject.SetActive(false);
}
_collided = true;
Vector3 velocity = ((Component)this).GetComponent<Rigidbody>().velocity;
Quaternion val2 = Quaternion.LookRotation(((ContactPoint)(ref val)).normal);
_thatExplosion = Object.Instantiate<GameObject>(thatExplosionTemplate, ((Component)this).gameObject.transform.position - velocity * Time.fixedDeltaTime * 2f, val2);
((MonoBehaviour)this).Invoke("DestroyPlushie", 1f);
}
private void DestroyPlushie()
{
Object.Destroy((Object)(object)_thatExplosion);
Object.Destroy((Object)(object)((Component)this).gameObject);
}
}
public class SkyboxesLowerPanel : MonoBehaviour
{
[SerializeField]
public Button showVolumetricSkyboxes;
[SerializeField]
public GameObject buttonsGroup;
[SerializeField]
public Button settingsBtn;
public void ShowDiscordInvite()
{
Application.OpenURL("https://discord.gg/Mc8RhjmbMS");
}
}
[DefaultExecutionOrder(-100)]
public class SkyboxParallaxEffect : MonoBehaviour
{
public float parallaxCoefficient = 1f;
public Follow[] followers;
public MovingPlatform[] movingPlatforms;
private CameraController _cameraController;
private Vector3 _playerPosition;
private Transform _transform;
private void Awake()
{
//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)
_transform = ((Component)this).transform;
_cameraController = MonoSingleton<CameraController>.Instance;
_playerPosition = ((Component)_cameraController).transform.position;
followers = ((Component)this).gameObject.GetComponentsInChildren<Follow>(true);
movingPlatforms = ((Component)this).gameObject.GetComponentsInChildren<MovingPlatform>();
}
public void FixedUpdate()
{
AdjustPosition();
PortalUtils.SyncPortals();
}
public void AdjustPosition()
{
//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)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: 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_001f: 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_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: 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_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
Vector3 position = ((Component)_cameraController).transform.position;
Vector3 val = position - _playerPosition;
if (!(val == Vector3.zero))
{
float num = 1f - parallaxCoefficient;
Matrix4x4 travelMatrix = Matrix4x4.Translate(val * num);
_transform.position = ((Matrix4x4)(ref travelMatrix)).MultiplyPoint3x4(_transform.position);
PortalUtils.FixComponentsPositioning(this, travelMatrix);
_playerPosition = 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 VolumetricSkyboxesCredits credits;
[SerializeField]
public GameObject settingsPanel;
[SerializeField]
public GameObject lowerPanel;
[SerializeField]
public GameObject portalsHack;
[SerializeField]
public AudioMixer skyboxesSound;
[SerializeField]
public AudioMixerGroup skyboxesMixerGroup;
protected void Awake()
{
Instantiate();
}
public void Instantiate()
{
//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
//IL_01ca: Expected O, but got Unknown
//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
//IL_01eb: Expected O, but got Unknown
CustomTextures customTextures = Object.FindObjectOfType<CustomTextures>(true);
GameObject obj = customTextures.GetPrivate<GameObject>("gridWrapper");
ShopButton val = GetShopButton("skyboxBtn");
GameObject defaultGridWrapper = customTextures.GetPrivate<GameObject>("gridWrapper");
Transform parent = obj.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 panel = lowerPanel.GetComponent<SkyboxesLowerPanel>();
browsePanel.gameObject.SetActive(false);
lowerPanel.SetActive(false);
settingsPanel.SetActive(false);
string[] array = new string[3] { "gridBtn", "emissionBtn", "fogBtn" };
foreach (string fieldName in array)
{
ShopButton obj2 = GetShopButton(fieldName);
obj2.toDeactivate = obj2.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)panel.showVolumetricSkyboxes.onClick).AddListener((UnityAction)delegate
{
bool flag = !browsePanel.activeSelf;
browsePanel.SetActive(flag);
panel.buttonsGroup.SetActive(flag);
defaultGridWrapper.SetActive(!flag && !settingsPanel.activeSelf);
settingsPanel.SetActive(false);
});
((UnityEvent)panel.settingsBtn.onClick).AddListener((UnityAction)delegate
{
browsePanel.SetActive(false);
defaultGridWrapper.SetActive(false);
settingsPanel.SetActive(true);
});
Object.Instantiate<GameObject>(portalsHack);
ShopButton GetShopButton(string field)
{
return ((Component)customTextures.GetPrivate<Button>(field)).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));
}
}
public class VolumetricSkyboxesCredits : MonoBehaviour
{
private readonly List<GameObject> _currentPlushies = new List<GameObject>();
[SerializeField]
public GameObject flazhikPlushie;
[SerializeField]
public GameObject frenchinatorPlushie;
[SerializeField]
public GameObject clofPlushie;
[SerializeField]
public GameObject squeakySound;
private NewMovement _nm;
private int _nightmareEventCounter;
private bool _nightmareEvent;
private void Awake()
{
_nm = MonoSingleton<NewMovement>.Instance;
}
public void SpawnPlushies()
{
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00da: Unknown result type (might be due to invalid IL or missing references)
//IL_00df: Unknown result type (might be due to invalid IL or missing references)
//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
//IL_010b: Unknown result type (might be due to invalid IL or missing references)
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
//IL_0115: Unknown result type (might be due to invalid IL or missing references)
if (!_nightmareEvent)
{
if (_nightmareEventCounter > 10)
{
_nightmareEvent = true;
((MonoBehaviour)this).StartCoroutine(NightmareEvent());
((MonoBehaviour)this).StartCoroutine(NightmareSqueaking());
((MonoBehaviour)this).StartCoroutine(DeathScreen());
((MonoBehaviour)this).StartCoroutine(QuitOnMusicStop());
}
else
{
Quaternion val = Quaternion.Euler(0f, 180f, 0f);
Vector3 position = ((Component)_nm).transform.position;
Object.Instantiate<GameObject>(squeakySound, position, Quaternion.identity, ((Component)this).transform);
_currentPlushies.Add(Object.Instantiate<GameObject>(frenchinatorPlushie, position + new Vector3(-1f, 1.5f, 0.5f), val));
_currentPlushies.Add(Object.Instantiate<GameObject>(flazhikPlushie, position + new Vector3(0f, 1.5f, 0.5f), val));
_currentPlushies.Add(Object.Instantiate<GameObject>(clofPlushie, position + new Vector3(1f, 1.5f, 0.5f), val));
_nightmareEventCounter++;
}
}
}
private IEnumerator NightmareEvent()
{
((Component)this).GetComponent<AudioSource>().Play();
Vector3 val = default(Vector3);
Quaternion val2 = default(Quaternion);
while (true)
{
object obj = Random.Range(0, 3) switch
{
0 => flazhikPlushie,
1 => frenchinatorPlushie,
_ => clofPlushie,
};
((Component)MonoSingleton<CameraController>.Instance).transform.GetPositionAndRotation(ref val, ref val2);
Object.Instantiate<GameObject>((GameObject)obj, ((Component)_nm).transform.position + val2 * Vector3.forward * 2f, Quaternion.Euler(0f, 180f, 0f), ((Component)this).transform);
yield return (object)new WaitForSeconds(0.02f);
}
}
private IEnumerator NightmareSqueaking()
{
((Component)this).GetComponent<AudioSource>().Play();
while (true)
{
Object.Instantiate<GameObject>(squeakySound, ((Component)_nm).transform.position, Quaternion.Euler(0f, 180f, 0f), ((Component)this).transform);
yield return (object)new WaitForSeconds(0.1f);
}
}
private IEnumerator DeathScreen()
{
DeathSequence deathSequence = MonoSingleton<NewMovement>.Instance.deathSequence;
AudioClip deathSequenceClip = ((Component)deathSequence).GetComponent<AudioSource>().clip;
AudioSource music = ((Component)this).GetComponent<AudioSource>();
float musicClipLength = music.clip.length;
yield return (object)new WaitUntil((Func<bool>)(() => music.isPlaying && musicClipLength - music.time <= deathSequenceClip.length - 0.1f));
((Component)deathSequence).gameObject.SetActive(true);
}
private IEnumerator QuitOnMusicStop()
{
yield return (object)new WaitUntil((Func<bool>)(() => !((Component)this).GetComponent<AudioSource>().isPlaying && Application.isFocused));
Application.Quit();
}
}
[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;
}
VolumetricSkyboxContainer volumetricSkyboxContainer = VolumetricSkyboxContainer.FromGuid(guid);
if (volumetricSkyboxContainer == null)
{
return null;
}
volumetricSkyboxContainer.SkyboxGameObject.SetActive(false);
_cache.Add(SongIdentifier.op_Implicit(guid), volumetricSkyboxContainer);
return _cache[SongIdentifier.op_Implicit(guid)];
}
}
public class VolumetricSkyboxesManager : MonoSingleton<VolumetricSkyboxesManager>
{
private static readonly List<ISkyboxPipelineStep> SkyboxesPipeline = new List<ISkyboxPipelineStep>
{
new AdjustSkyboxPositionStep(),
new RemoveUndesiredComponentsStep(),
new PortalsSanitizeStep(),
new ApplyComponentsStep(),
new SetAudioMixerStep(),
new AssignToBackgroundLayersStep(),
new SetLightsCullingMaskStep()
};
public Action<ICollection<VolumetricSkyboxContainer>> OnSkyboxesListChanged;
public bool portalsArePresent;
private readonly Dictionary<string, VolumetricSkyboxContainer> _skyboxes = new Dictionary<string, VolumetricSkyboxContainer>();
private readonly Dictionary<string, GameObject> _skyboxObjects = new Dictionary<string, GameObject>();
private readonly Dictionary<string, SkyboxParallaxEffect> _parallaxComponents = new Dictionary<string, SkyboxParallaxEffect>();
private VolumetricSkyboxesTextureManager _textureManager;
public ICollection<VolumetricSkyboxContainer> Skyboxes => _skyboxes.Values;
private void Awake()
{
_textureManager = new VolumetricSkyboxesTextureManager();
}
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)
{
return;
}
GameObject skyboxGameObject = volumetricSkyboxContainer.SkyboxGameObject;
if ((Object)(object)skyboxGameObject == (Object)null || (Object)(object)skyboxGameObject.transform.Find("ArenaAnchor") == (Object)null)
{
Debug.LogError((object)"Invalid skybox: GameObject is null or doesn't have an ArenaAnchor object in its root");
return;
}
GameObject val = Object.Instantiate<GameObject>(skyboxGameObject);
_skyboxObjects.Add(guid, val);
_skyboxes.Add(guid, volumetricSkyboxContainer);
foreach (ISkyboxPipelineStep item in SkyboxesPipeline)
{
item.Execute(volumetricSkyboxContainer, val);
}
val.SetActive(true);
_parallaxComponents.Add(guid, val.GetComponent<SkyboxParallaxEffect>());
SetClipPlanes();
_textureManager.ChangePanorama();
_textureManager.ChangeGridTextures();
OnSkyboxesListChanged?.Invoke(_skyboxes.Values);
UpdatePortals();
}
public void RemoveSkybox(string guid)
{
if (_skyboxObjects.TryGetValue(guid, out var value))
{
_skyboxes.Remove(guid);
OnSkyboxesListChanged?.Invoke(_skyboxes.Values);
Object.Destroy((Object)(object)value);
_parallaxComponents.Remove(guid);
_skyboxObjects.Remove(guid);
_textureManager.ChangePanorama();
_textureManager.ChangeGridTextures();
UpdatePortals();
}
}
public void ReloadSkyboxes(bool forced = false)
{
SkyboxFileUtility.ReloadSkyboxes(forced);
}
public void ClearCache()
{
SkyboxFileUtility.ClearCache();
}
public void ChangePanorama()
{
_textureManager.ChangePanorama();
}
public void ChangeGridTextures()
{
_textureManager.ChangeGridTextures();
}
public void UpdateParallax()
{
foreach (SkyboxParallaxEffect value in _parallaxComponents.Values)
{
value.AdjustPosition();
}
PortalUtils.SyncPortals();
}
public void SaveTexturesEditor(Material mat)
{
_textureManager.SaveSkyboxMaterial(mat);
}
public void SaveOriginalGridTextures(Material[] mats)
{
_textureManager.SaveOriginalGridTextures(mats);
}
public void ChangeOriginalGridTextures(Texture2D tex, bool baseTex, bool top, bool topRow)
{
_textureManager.ChangeOriginalGridTextures(tex, baseTex, top, topRow);
}
private void UpdatePortals()
{
portalsArePresent = _skyboxes.Any((KeyValuePair<string, VolumetricSkyboxContainer> skybox) => (Object)(object)((Component)skybox.Value.SkyboxGameObject.transform).GetComponentInChildren<Portal>(true) != (Object)null);
}
private void SetClipPlanes()
{
Camera val = Object.FindObjectOfType<BackgroundCamera>()?.camera;
if (!((Object)(object)val == (Object)null))
{
val.nearClipPlane = _skyboxes.Values.Min((VolumetricSkyboxContainer entry) => entry.Data.NearClipPlane);
val.farClipPlane = _skyboxes.Values.Max((VolumetricSkyboxContainer entry) => entry.Data.FarClipPlane);
}
}
}
public class VolumetricSkyboxesSettings : MonoBehaviour
{
[SerializeField]
public ControllerPointerToggle overrideSkyboxesToggle;
[SerializeField]
public ControllerPointerToggle overrideGridTexturesToggle;
[SerializeField]
public ControllerPointerToggle muteSoundsToggle;
[SerializeField]
public ControllerPointerToggle disableScorePanelToggle;
private void Awake()
{
RegisterToggle("cyberGrind.volumetricSkyboxes.arenaLighting.useSkyboxesPanorama", fallback: true, overrideSkyboxesToggle, delegate
{
MonoSingleton<VolumetricSkyboxesManager>.Instance.ChangePanorama();
});
RegisterToggle("cyberGrind.volumetricSkyboxes.useSkyboxesGridTextures", fallback: true, overrideGridTexturesToggle, delegate
{
MonoSingleton<VolumetricSkyboxesManager>.Instance.ChangeGridTextures();
});
RegisterToggle("cyberGrind.volumetricSkyboxes.muteSounds", fallback: false, muteSoundsToggle);
RegisterToggle("cyberGrind.volumetricSkyboxes.disableScorePanel", fallback: false, disableScorePanelToggle);
}
private static void RegisterToggle(string key, bool fallback, ControllerPointerToggle toggle, Action postAction = null)
{
toggle.isOn = MonoSingleton<PrefsManager>.Instance.GetBoolLocal(key, fallback);
((UnityEvent<bool>)toggle.onValueChanged).AddListener((UnityAction<bool>)delegate(bool value)
{
MonoSingleton<PrefsManager>.Instance.SetBoolLocal(key, value);
});
postAction?.Invoke();
}
}
}
namespace VolumetricSkyboxes.Components.SkyboxPipeline
{
public class AdjustSkyboxPositionStep : ISkyboxPipelineStep
{
private static readonly Vector3 ArenaPosition = new Vector3(0f, 25f, 60f);
public void Execute(VolumetricSkyboxContainer container, GameObject skybox)
{
//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_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: 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 - container.Data.ParallaxCoefficient) - val;
Object.Destroy((Object)(object)((Component)anchor).gameObject);
}
private static Transform GetAnchor(GameObject go)
{
return go.transform.Find("ArenaAnchor");
}
}
public class ApplyComponentsStep : ISkyboxPipelineStep
{
public void Execute(VolumetricSkyboxContainer container, GameObject skybox)
{
skybox.AddComponent<SkyboxParallaxEffect>().parallaxCoefficient = container.Data.ParallaxCoefficient;
}
}
public class AssignToBackgroundLayersStep : ISkyboxPipelineStep
{
public void Execute(VolumetricSkyboxContainer _, GameObject skybox)
{
RenderingUtils.MoveToBackgroundLayer(skybox);
}
}
public interface ISkyboxPipelineStep
{
void Execute(VolumetricSkyboxContainer container, GameObject skybox);
}
public class RemoveUndesiredComponentsStep : ISkyboxPipelineStep
{
private static readonly HashSet<Type> UndesiredComponents = new HashSet<Type>
{
typeof(Collider),
typeof(MonoSingleton),
typeof(HurtZone),
typeof(Enemy),
typeof(EnemyIdentifier),
typeof(AddForce),
typeof(PortalTravelFlagsSetter),
typeof(GoreZone),
typeof(StencilValuesByLayer),
typeof(AudioReverbZone),
typeof(GravityVolume)
};
public void Execute(VolumetricSkyboxContainer _, 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);
}
}
}
}
public class PortalsSanitizeStep : ISkyboxPipelineStep
{
public void Execute(VolumetricSkyboxContainer _, GameObject skybox)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
Portal[] componentsInChildren = skybox.GetComponentsInChildren<Portal>(true);
foreach (Portal obj in componentsInChildren)
{
obj.entryTravelFlags = (PortalTravellerFlags)32;
obj.exitTravelFlags = (PortalTravellerFlags)32;
obj.passThroughNonTraversals = true;
}
}
}
public class SetAudioMixerStep : ISkyboxPipelineStep
{
public void Execute(VolumetricSkyboxContainer _, GameObject skybox)
{
AudioMixerGroup skyboxesMixerGroup = MonoSingleton<VolumetricSkyboxesBootstrap>.Instance.skyboxesMixerGroup;
AudioSource[] componentsInChildren = skybox.GetComponentsInChildren<AudioSource>(true);
for (int i = 0; i < componentsInChildren.Length; i++)
{
componentsInChildren[i].outputAudioMixerGroup = skyboxesMixerGroup;
}
}
}
public class SetLightsCullingMaskStep : ISkyboxPipelineStep
{
public void Execute(VolumetricSkyboxContainer _, 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);
}
}
}
}
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)
orderby file.CreationTime descending
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));
};
}
}
}
}