Files
ADOFAIRenderer/Component/RenderManager.cs
T
2026-05-21 11:38:31 +09:00

108 lines
3.2 KiB
C#

using System.Collections;
using UnityEngine;
namespace ADOFAIRenderer.Component
{
public class RenderManager : MonoBehaviour
{
public static int Countdown = 0;
public static int FrameCount = 0;
public static bool SkipPressToStart = false;
public static string LevelPath = "";
public static RenderManager Instance = null!;
private static int _originalInputOffset;
public static RenderSettings Configuration;
public struct RenderSettings
{
public double TargetFPS;
public double VideoFPS;
public int RenderWidth;
public int RenderHeight;
public int Bitrate;
public string Codec;
public RenderSettings(double targetFPS, double videoFPS, int renderWidth, int renderHeight, int bitrate, string codec)
{
TargetFPS = targetFPS;
VideoFPS = videoFPS;
RenderWidth = renderWidth;
RenderHeight = renderHeight;
Bitrate = bitrate;
Codec = codec;
}
}
private static bool _renderSetup;
private void Awake()
{
Instance = this;
}
private void Update()
{
if (_renderSetup && ADOBase.lm)
{
ADOBase.lm.hideDifficultyUI = true;
}
if (_renderSetup && scnGame.instance && !scnGame.instance.isLoading)
{
_renderSetup = false;
scrCamera.instance.forceRTCam = true;
scrCamera.instance.SetupRTCam(true);
_originalInputOffset = scrConductor.currentPreset.inputOffset;
scrConductor.currentPreset.inputOffset = 0;
RDC.auto = true;
RenderMod.IsRendering = true;
Countdown = 3;
scrController.instance.StartCoroutine(SetupPlay());
}
if (RenderMod.IsRendering && scrController.instance.state == States.Won)
{
RenderMod.IsRendering = RenderMod.IsCapturing = false;
scrConductor.currentPreset.inputOffset = _originalInputOffset;
}
}
public void SetupGameScene()
{
GCS.customLevelPaths = new[] { LevelPath };
GCS.checkpointNum = 0;
GCS.customLevelId = "";
GCS.nextSpeedRun = 1;
GCS.customLevelIndex = 0;
ADOBase.loader.LoadSceneWithTransition(WipeDirection.StartsFromRight, "scnGame");
SkipPressToStart = true;
_renderSetup = true;
}
private IEnumerator SetupPlay()
{
for (; Countdown > 0; Countdown--)
{
yield return new WaitForSecondsRealtime(1);
}
FrameCount = 0;
RenderMod.IsCapturing = true;
scrController.instance.paused = scrController.instance.audioPaused = false;
scrController.instance.levelWasSkipped = true;
scrConductor.instance.song.clip = null;
scrConductor.instance.song.time = -1000;
}
}
}