This repository has been archived by the owner on Jan 10, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
WorldVolumes.cs
74 lines (68 loc) · 2.43 KB
/
WorldVolumes.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.Rendering.PostProcessing;
namespace Dawn.PostProcessing
{
internal static class WorldVolumes
{
internal static bool WorldPostProcessing;
internal static bool WorldQMToggle;
private static List<OriginalVolume> OriginalVolumes;
private struct OriginalVolume // Credits to Psychloor for this Big Brain Snippet.
{
internal PostProcessVolume postProcessVolume;
internal bool defaultState;
}
private static void GrabWorldVolumes() //Credits to Psychloor for Method
{
OriginalVolumes = new List<OriginalVolume>();
foreach (var volume in Resources.FindObjectsOfTypeAll<PostProcessVolume>().Where(p => p.priority is < 1223 or > 1250 ))
{
OriginalVolumes.Add(new OriginalVolume { postProcessVolume = volume, defaultState = volume.enabled });
}
}
internal static void WorldJoin()
{
GrabWorldVolumes();
ToggleWorldVolumes();
}
internal static void ToggleWorldVolumes()
{
try
{
if (OriginalVolumes == null || !Core.IsInWorld) return;
if (!WorldPostProcessing)
{
foreach (var originalVolume in OriginalVolumes.Where(originalVolume => originalVolume.postProcessVolume))
{
originalVolume.postProcessVolume.enabled = false;
}
}
else
{
Reset();
}
}
catch (Exception e)
{
Core.Log($"ToggleMethod Error: {e}", Core.LogType.Error);
}
}
private static void Reset() //Credits to Psychloor for Method
{
try
{
foreach (var originalVolume in OriginalVolumes.Where(originalVolume => originalVolume.postProcessVolume))
{
originalVolume.postProcessVolume.enabled = originalVolume.defaultState;
}
}
catch (Exception e)
{
Core.Log($"Reset Error: {e}", Core.LogType.Error);
}
}
}
}