Fix PreRender

This commit is contained in:
NotAKidoS 2022-10-25 15:57:27 -05:00
parent f789182d4f
commit 2b4f306040
4 changed files with 13 additions and 13 deletions

View file

@ -59,7 +59,7 @@ public class BlackoutController : MonoBehaviour
Sleeping, Sleeping,
} }
private GameObject activeModeCam; private Camera activeModeCam;
private Quaternion oldHeadRotation = Quaternion.identity; private Quaternion oldHeadRotation = Quaternion.identity;
private float angularMovement = 0f; private float angularMovement = 0f;
private float curTime = 0f; private float curTime = 0f;
@ -114,6 +114,10 @@ public class BlackoutController : MonoBehaviour
blackoutGO.name = "BlackoutInstance"; blackoutGO.name = "BlackoutInstance";
blackoutAnimator = blackoutGO.GetComponent<Animator>(); blackoutAnimator = blackoutGO.GetComponent<Animator>();
SetupBlackoutInstance(); SetupBlackoutInstance();
//we dont want this to ever disable (unless in awake state maybe?
Camera.onPreRender += OnPreRender;
Camera.onPostRender += OnPostRender;
} }
//Automatic State Change //Automatic State Change
@ -151,20 +155,16 @@ public class BlackoutController : MonoBehaviour
{ {
curTime = Time.time; curTime = Time.time;
lastAwakeTime = curTime; lastAwakeTime = curTime;
Camera.onPreRender += OnPreRender;
Camera.onPostRender += OnPostRender;
} }
void OnDisable() void OnDisable()
{ {
ChangeBlackoutState(BlackoutState.Awake); ChangeBlackoutState(BlackoutState.Awake);
Camera.onPreRender -= OnPreRender;
Camera.onPostRender -= OnPostRender;
} }
void OnPreRender(Camera cam) void OnPreRender(Camera cam)
{ {
if (cam != activeModeCam.GetComponent<Camera>()) return; if (cam == activeModeCam) return;
blackoutAnimator.transform.localScale = Vector3.zero; blackoutAnimator.transform.localScale = Vector3.zero;
} }
@ -175,7 +175,7 @@ public class BlackoutController : MonoBehaviour
public void SetupBlackoutInstance() public void SetupBlackoutInstance()
{ {
activeModeCam = PlayerSetup.Instance.GetActiveCamera(); activeModeCam = PlayerSetup.Instance.GetActiveCamera().GetComponent<Camera>();
blackoutAnimator.transform.parent = activeModeCam.transform; blackoutAnimator.transform.parent = activeModeCam.transform;
blackoutAnimator.transform.localPosition = Vector3.zero; blackoutAnimator.transform.localPosition = Vector3.zero;
blackoutAnimator.transform.localRotation = Quaternion.identity; blackoutAnimator.transform.localRotation = Quaternion.identity;

View file

@ -23,8 +23,8 @@ public class Blackout : MelonMod
m_entryDropFPSOnSleep = m_categoryBlackout.CreateEntry<bool>("Lower FPS While Sleep", false, description: "Lowers FPS to 5 while in Sleep State."); m_entryDropFPSOnSleep = m_categoryBlackout.CreateEntry<bool>("Lower FPS While Sleep", false, description: "Lowers FPS to 5 while in Sleep State.");
m_entryDrowsyThreshold = m_categoryBlackout.CreateEntry<float>("Drowsy Threshold", 1f, description: "Degrees of movement to return partial vision."); m_entryDrowsyThreshold = m_categoryBlackout.CreateEntry<float>("Drowsy Threshold", 1f, description: "Degrees of movement to return partial vision.");
m_entryAwakeThreshold = m_categoryBlackout.CreateEntry<float>("Awake Threshold", 12f, description: "Degrees of movement to return full vision."); m_entryAwakeThreshold = m_categoryBlackout.CreateEntry<float>("Awake Threshold", 12f, description: "Degrees of movement to return full vision.");
m_entryDrowsyModeTimer = m_categoryBlackout.CreateEntry<float>("Enter Drowsy Time", 3f, description: "How many minutes without movement until enter drowsy mode."); m_entryDrowsyModeTimer = m_categoryBlackout.CreateEntry<float>("Enter Drowsy Time (Minutes)", 3f, description: "How many minutes without movement until enter drowsy mode.");
m_entrySleepModeTimer = m_categoryBlackout.CreateEntry<float>("Enter Sleep Time", 10f, description: "How many seconds without movement until enter sleep mode."); m_entrySleepModeTimer = m_categoryBlackout.CreateEntry<float>("Enter Sleep Time (Seconds)", 10f, description: "How many seconds without movement until enter sleep mode.");
m_entryDrowsyDimStrength = m_categoryBlackout.CreateEntry<float>("Drowsy Dim Strength", 0.5f, description: "How strong of a dimming effect should drowsy mode have."); m_entryDrowsyDimStrength = m_categoryBlackout.CreateEntry<float>("Drowsy Dim Strength", 0.5f, description: "How strong of a dimming effect should drowsy mode have.");
m_categoryBlackout.SaveToFile(false); m_categoryBlackout.SaveToFile(false);

View file

@ -25,6 +25,6 @@ using System.Reflection;
namespace Blackout.Properties; namespace Blackout.Properties;
internal static class AssemblyInfoParams internal static class AssemblyInfoParams
{ {
public const string Version = "1.0.2"; public const string Version = "1.0.3";
public const string Author = "NotAKidoS"; public const string Author = "NotAKidoS";
} }

View file

@ -1,7 +1,7 @@
{ {
"_id": 106, "_id": 106,
"name": "Blackout", "name": "Blackout",
"modversion": "1.0.2", "modversion": "1.0.3",
"gameversion": "2022r169p1", "gameversion": "2022r169p1",
"loaderversion": "0.5.5", "loaderversion": "0.5.5",
"modtype": "Mod", "modtype": "Mod",
@ -16,8 +16,8 @@
"requirements": [ "requirements": [
"None" "None"
], ],
"downloadlink": "https://github.com/NotAKidOnSteam/Blackout/releases/download/r3/Blackout.dll", "downloadlink": "https://github.com/NotAKidOnSteam/Blackout/releases/download/r4/Blackout.dll",
"sourcelink": "https://github.com/NotAKidOnSteam/Blackout/", "sourcelink": "https://github.com/NotAKidOnSteam/Blackout/",
"changelog": "Fix render queue of sleep mode. Made effect 2x bigger to accommodate extreme FOV & avatar scale. Attempt to render only in active camera.", "changelog": "Fixed rendering in every camera other than player camera. Should now behave in both automatic and manual modes.",
"embedcolor": "#161b22" "embedcolor": "#161b22"
} }