using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HG.Reflection;
using RiskOfOptions;
using RiskOfOptions.OptionConfigs;
using RiskOfOptions.Options;
using RoR2;
using RoR2.ContentManagement;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Rendering.PostProcessing;
using UnityEngine.ResourceManagement.AsyncOperations;
using UnityEngine.ResourceManagement.ResourceProviders;
using UnityEngine.SceneManagement;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: OptIn]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
public class SceneLoader : MonoBehaviour
{
public string sceneName;
public GameObject cameraPrefab;
private void Start()
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
AsyncOperationHandle<SceneInstance> val = Addressables.LoadSceneAsync((object)sceneName, (LoadSceneMode)0, true, 100);
val.Completed += OnSceneLoaded;
}
private void OnSceneLoaded(AsyncOperationHandle<SceneInstance> obj)
{
Object.Instantiate<GameObject>(cameraPrefab);
}
}
namespace ProceduralStages
{
public class DelayedInstantier : MonoBehaviour
{
public GameObject prefab;
private bool instantied;
public void OnDisable()
{
instantied = false;
}
public void Update()
{
if (!instantied)
{
Object.Instantiate<GameObject>(prefab);
instantied = true;
}
}
}
public class FlyCamera : MonoBehaviour
{
public float acceleration = 300f;
public float accSprintMultiplier = 8f;
public float lookSensitivity = 2f;
public float dampingCoefficient = 5f;
public bool focusOnEnable = true;
[Range(0f, 180f)]
public float fov = 90f;
public PostProcessProfile postProcessProfile;
private Vector3 velocity;
private GameObject cameraObject;
private static bool Focused
{
get
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Invalid comparison between Unknown and I4
return (int)Cursor.lockState == 1;
}
set
{
Cursor.lockState = (CursorLockMode)(value ? 1 : 0);
Cursor.visible = !value;
}
}
private void Awake()
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
if (!Application.isPlaying)
{
return;
}
GameObject val = Object.Instantiate<GameObject>(Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Core/Main Camera.prefab").WaitForCompletion(), ((Component)this).transform);
CameraRigController component = val.GetComponent<CameraRigController>();
val.GetComponent<CameraRigController>().isCutscene = true;
component.sceneCam.fieldOfView = fov;
cameraObject = ((Component)val.transform.GetChild(0)).gameObject;
PostProcessVolume component2 = ((Component)cameraObject.transform.Find("GlobalPostProcessVolume")).GetComponent<PostProcessVolume>();
foreach (PostProcessEffectSettings setting in postProcessProfile.settings)
{
component2.profile.AddSettings(setting);
}
}
private void OnEnable()
{
if (focusOnEnable)
{
Focused = true;
}
}
private void OnDisable()
{
Focused = false;
}
private void Update()
{
//IL_003c: 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_0052: 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_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: 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_007d: Unknown result type (might be due to invalid IL or missing references)
if (Application.isPlaying)
{
GameObject obj = GameObject.Find("HUDSimple(Clone)");
if (obj != null)
{
obj.SetActive(false);
}
}
if (Focused)
{
UpdateInput();
}
else if (Input.GetMouseButtonDown(0))
{
Focused = true;
}
velocity = Vector3.Lerp(velocity, Vector3.zero, dampingCoefficient * Time.deltaTime);
Transform transform = cameraObject.transform;
transform.position += velocity * Time.deltaTime;
}
private void UpdateInput()
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: 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_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: 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_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: 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_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)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//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)
//IL_0077: 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_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
velocity += GetAccelerationVector() * Time.deltaTime;
Vector2 val = lookSensitivity * new Vector2(Input.GetAxis("Mouse X"), 0f - Input.GetAxis("Mouse Y"));
Quaternion rotation = cameraObject.transform.rotation;
Quaternion val2 = Quaternion.AngleAxis(val.x, Vector3.up);
Quaternion val3 = Quaternion.AngleAxis(val.y, Vector3.right);
cameraObject.transform.rotation = val2 * rotation * val3;
if (Input.GetKeyDown((KeyCode)27))
{
Focused = false;
}
}
private Vector3 GetAccelerationVector()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: 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_002b: 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_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: 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_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: 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)
Vector3 moveInput = default(Vector3);
AddMovement((KeyCode)119, Vector3.forward);
AddMovement((KeyCode)115, Vector3.back);
AddMovement((KeyCode)100, Vector3.right);
AddMovement((KeyCode)97, Vector3.left);
AddMovement((KeyCode)304, Vector3.down);
AddMovement((KeyCode)32, Vector3.up);
Vector3 val = cameraObject.transform.TransformVector(((Vector3)(ref moveInput)).normalized);
if (Input.GetKey((KeyCode)306))
{
return val * (acceleration * accSprintMultiplier);
}
return val * acceleration;
void AddMovement(KeyCode key, Vector3 dir)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: 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_0015: Unknown result type (might be due to invalid IL or missing references)
if (Input.GetKey(key))
{
moveInput += dir;
}
}
}
}
}
namespace RoR2Shaders
{
public static class Commands
{
[ConCommand(/*Could not decode attribute arguments.*/)]
public static void ToggleReport(ConCommandArgs args)
{
}
}
public class ContentProvider : IContentPackProvider
{
public static ContentPack ContentPack = new ContentPack();
public string identifier => "Lawlzee.RoR2Shaders.ContentProvider";
public IEnumerator LoadStaticContentAsync(LoadStaticContentAsyncArgs args)
{
ContentPack.identifier = identifier;
string directoryName = Path.GetDirectoryName(typeof(ContentProvider).Assembly.Location);
AssetBundle stageReportBundle = null;
yield return LoadAssetBundle(Path.Combine(directoryName, "ror2shaders"), args.progressReceiver, delegate(AssetBundle assetBundle)
{
stageReportBundle = assetBundle;
});
yield return LoadAllAssetsAsync<Shader>(stageReportBundle, args.progressReceiver, (Action<Shader[]>)delegate(Shader[] shaders)
{
Dictionary<string, Shader> dictionary = (Dictionary<string, Shader>)typeof(LegacyShaderAPI).GetField("shaderNameToShaderCache", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null);
foreach (Shader val in shaders)
{
dictionary.Add(((Object)val).name, val);
}
});
}
private IEnumerator LoadAssetBundle(string assetBundleFullPath, IProgress<float> progress, Action<AssetBundle> onAssetBundleLoaded)
{
AssetBundleCreateRequest assetBundleCreateRequest = AssetBundle.LoadFromFileAsync(assetBundleFullPath);
while (!((AsyncOperation)assetBundleCreateRequest).isDone)
{
progress.Report(((AsyncOperation)assetBundleCreateRequest).progress);
yield return null;
}
onAssetBundleLoaded(assetBundleCreateRequest.assetBundle);
}
private static IEnumerator LoadAllAssetsAsync<T>(AssetBundle assetBundle, IProgress<float> progress, Action<T[]> onAssetsLoaded) where T : Object
{
AssetBundleRequest sceneDefsRequest = assetBundle.LoadAllAssetsAsync<T>();
while (!((AsyncOperation)sceneDefsRequest).isDone)
{
progress.Report(((AsyncOperation)sceneDefsRequest).progress);
yield return null;
}
onAssetsLoaded(sceneDefsRequest.allAssets.Cast<T>().ToArray());
}
public IEnumerator GenerateContentPackAsync(GetContentPackAsyncArgs args)
{
ContentPack.Copy(ContentPack, args.output);
args.ReportProgress(1f);
yield break;
}
public IEnumerator FinalizeAsync(FinalizeAsyncArgs args)
{
args.ReportProgress(1f);
yield break;
}
}
public static class Log
{
private static ManualLogSource _logSource;
public static void Init(ManualLogSource logSource)
{
_logSource = logSource;
}
public static void Debug(object data)
{
if (_logSource == null)
{
Debug.Log(data);
}
else
{
_logSource.LogDebug(data);
}
}
public static void Error(object data)
{
if (_logSource == null)
{
Debug.LogError(data);
}
else
{
_logSource.LogError(data);
}
}
public static void Fatal(object data)
{
if (_logSource == null)
{
Debug.LogError(data);
}
else
{
_logSource.LogFatal(data);
}
}
public static void Info(object data)
{
if (_logSource == null)
{
Debug.Log(data);
}
else
{
_logSource.LogInfo(data);
}
}
public static void Message(object data)
{
if (_logSource == null)
{
Debug.Log(data);
}
else
{
_logSource.LogMessage(data);
}
}
public static void Warning(object data)
{
if (_logSource == null)
{
Debug.LogWarning(data);
}
else
{
_logSource.LogWarning(data);
}
}
}
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("Lawlzee.RoR2Shaders", "RoR2Shaders", "1.0.0")]
public class Main : BaseUnityPlugin
{
public const string PluginGUID = "Lawlzee.RoR2Shaders";
public const string PluginAuthor = "Lawlzee";
public const string PluginName = "RoR2Shaders";
public const string PluginVersion = "1.0.0";
public void Awake()
{
//IL_0030: 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_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Expected O, but got Unknown
Log.Init(((BaseUnityPlugin)this).Logger);
Texture2D val = LoadTexture("icon.png");
ModSettingsManager.SetModIcon(Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0f, 0f)));
ModSettingsManager.SetModDescription("This mod adds custom shaders to Risk of Rain 2. Currently, only a grayscale shader is available.");
PostProcessProfileManager.Init();
RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, (Action)delegate
{
Grayscale.Init(((BaseUnityPlugin)this).Config);
});
ContentManager.collectContentPackProviders += new CollectContentPackProvidersDelegate(GiveToRoR2OurContentPackProviders);
}
private Texture2D LoadTexture(string name)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Expected O, but got Unknown
//IL_002a: Expected O, but got Unknown
Texture2D val = new Texture2D(2, 2);
ImageConversion.LoadImage(val, File.ReadAllBytes(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), name)));
return val;
}
private void GiveToRoR2OurContentPackProviders(AddContentPackProviderDelegate addContentPackProvider)
{
addContentPackProvider.Invoke((IContentPackProvider)(object)new ContentProvider());
}
}
public class SemanticVersion
{
public int Major;
public int Minor;
public int Patch;
public static SemanticVersion Parse(string version)
{
string[] array = version.Split('.');
return new SemanticVersion
{
Major = int.Parse(array[0]),
Minor = int.Parse(array[1]),
Patch = int.Parse(array[2])
};
}
public static bool operator <(SemanticVersion a, SemanticVersion b)
{
if (a.Major < b.Major)
{
return true;
}
if (a.Major > b.Major)
{
return false;
}
if (a.Minor < b.Minor)
{
return true;
}
if (a.Minor > b.Minor)
{
return false;
}
if (a.Patch < b.Patch)
{
return true;
}
return false;
}
public static bool operator >(SemanticVersion a, SemanticVersion b)
{
if (a.Major > b.Major)
{
return true;
}
if (a.Major < b.Major)
{
return false;
}
if (a.Minor > b.Minor)
{
return true;
}
if (a.Minor < b.Minor)
{
return false;
}
if (a.Patch > b.Patch)
{
return true;
}
return false;
}
public static bool operator ==(SemanticVersion a, SemanticVersion b)
{
if (a.Major == b.Major && a.Minor == b.Minor)
{
return a.Patch == b.Patch;
}
return false;
}
public static bool operator !=(SemanticVersion a, SemanticVersion b)
{
if (a.Major == b.Major && a.Minor == b.Minor)
{
return a.Patch != b.Patch;
}
return true;
}
public override bool Equals(object obj)
{
if (obj is SemanticVersion semanticVersion && Major == semanticVersion.Major && Minor == semanticVersion.Minor)
{
return Patch == semanticVersion.Patch;
}
return false;
}
public override int GetHashCode()
{
return ((-639545495 * -1521134295 + Major.GetHashCode()) * -1521134295 + Minor.GetHashCode()) * -1521134295 + Patch.GetHashCode();
}
}
[Serializable]
[PostProcess(/*Could not decode attribute arguments.*/)]
public sealed class Grayscale : PostProcessEffectSettings
{
[Range(0f, 1f)]
[Tooltip("Grayscale effect intensity.")]
public FloatParameter blend;
public static void Init(ConfigFile config)
{
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Expected O, but got Unknown
//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_0067: 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)
//IL_0082: Expected O, but got Unknown
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Expected O, but got Unknown
ConfigEntry<bool> grayscaleEnabled = config.Bind<bool>("Grayscale", "Grayscale Enabled", true, "Toggles the grayscale shader on or off");
ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(grayscaleEnabled));
ConfigEntry<float> grayscaleBlend = config.Bind<float>("Grayscale", "Grayscale Blend", 1f, "Adjusts the intensity of the grayscale effect. 1 = full grayscale, 0 = no effect");
ModSettingsManager.AddOption((BaseOption)new SliderOption(grayscaleBlend, new SliderConfig
{
min = 0f,
max = 1f,
formatString = "{0:0.##}"
}));
PostProcessProfileManager.AddHandler<Grayscale>(delegate(PostProcessProfile profile)
{
Grayscale grayscale = default(Grayscale);
if (!profile.TryGetSettings<Grayscale>(ref grayscale))
{
grayscale = ScriptableObject.CreateInstance<Grayscale>();
profile.AddSettings((PostProcessEffectSettings)(object)grayscale);
}
((ParameterOverride<bool>)(object)((PostProcessEffectSettings)grayscale).enabled).Override(grayscaleEnabled.Value);
((ParameterOverride<float>)(object)grayscale.blend).Override(grayscaleBlend.Value);
});
grayscaleEnabled.SettingChanged += delegate
{
PostProcessProfileManager.OnChange<Grayscale>();
};
grayscaleBlend.SettingChanged += delegate
{
PostProcessProfileManager.OnChange<Grayscale>();
};
}
public Grayscale()
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
//IL_0016: Expected O, but got Unknown
FloatParameter val = new FloatParameter();
((ParameterOverride<float>)val).value = 0.5f;
blend = val;
((PostProcessEffectSettings)this)..ctor();
}
}
public sealed class GrayscaleRenderer : PostProcessEffectRenderer<Grayscale>
{
public override void Render(PostProcessRenderContext context)
{
//IL_003d: 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)
PropertySheet val = context.propertySheets.Get(Shader.Find("Hidden/Custom/Grayscale"));
val.properties.SetFloat("_Blend", ParameterOverride<float>.op_Implicit((ParameterOverride<float>)(object)base.settings.blend));
RuntimeUtilities.BlitFullscreenTriangle(context.command, context.source, context.destination, val, 0, false, (Rect?)null);
}
}
public class PostProcessProfileManager
{
private static readonly List<PostProcessProfile> _postProcessProfiles = new List<PostProcessProfile>();
private static readonly Dictionary<Type, Action<PostProcessProfile>> _shaderHandler = new Dictionary<Type, Action<PostProcessProfile>>();
public static void Init()
{
CameraRigController.onCameraEnableGlobal += delegate(CameraRigController cameraRig)
{
PostProcessProfile profile2 = ((Component)((Component)cameraRig).transform.GetChild(0).Find("GlobalPostProcessVolume")).GetComponent<PostProcessVolume>().profile;
bool num = _postProcessProfiles.Contains(profile2);
_postProcessProfiles.Add(profile2);
if (num)
{
return;
}
foreach (Action<PostProcessProfile> value in _shaderHandler.Values)
{
value(profile2);
}
};
CameraRigController.onCameraDisableGlobal += delegate(CameraRigController cameraRig)
{
PostProcessProfile profile = ((Component)((Component)cameraRig).transform.GetChild(0).Find("GlobalPostProcessVolume")).GetComponent<PostProcessVolume>().profile;
if (_postProcessProfiles.Remove(profile) && !_postProcessProfiles.Contains(profile))
{
foreach (Type key in _shaderHandler.Keys)
{
profile.RemoveSettings(key);
}
}
};
}
public static void AddHandler<T>(Action<PostProcessProfile> handler)
{
_shaderHandler[typeof(T)] = handler;
OnChange<T>();
}
public static void OnChange<T>()
{
if (!_shaderHandler.TryGetValue(typeof(T), out var value))
{
return;
}
foreach (PostProcessProfile item in _postProcessProfiles.Distinct())
{
value(item);
}
}
}
}