SHA256
forked from ADOFAIEditorForum/ADOFAIRenderer
Initial Commit
This commit is contained in:
commit
44a22ae103
19 files changed
+772
No files matched your search
@@ -0,0 +1,43 @@
|
||||
using HarmonyLib;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace ADOFAIRenderer.Patch.ClassPatch
|
||||
{
|
||||
[HarmonyPatch(typeof(scnEditor))]
|
||||
// ReSharper disable once InconsistentNaming
|
||||
public static class scnEditorPatch
|
||||
{
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch("Start")]
|
||||
// ReSharper disable once InconsistentNaming
|
||||
public static void AddButtonRender(scnEditor __instance)
|
||||
{
|
||||
var cloneTarget = __instance.buttonExit!.gameObject;
|
||||
var buttonContainer = cloneTarget.transform.parent!;
|
||||
|
||||
var buttonObj = Object.Instantiate(cloneTarget, buttonContainer)!;
|
||||
buttonObj.name = "buttonRender";
|
||||
|
||||
var button = buttonObj.GetComponent<Button>()!;
|
||||
// Clear persistent and non-persistent listeners from the original button
|
||||
button.onClick = new Button.ButtonClickedEvent();
|
||||
button.onClick.AddListener(RenderMod.StartRender);
|
||||
|
||||
// The button root has an Image component for the background (rounded box).
|
||||
// We want to change the icon sprite, which is on a child GameObject.
|
||||
var images = buttonObj.GetComponentsInChildren<Image>();
|
||||
if (images.Length <= 1) return;
|
||||
|
||||
// ReSharper disable once Unity.UnknownResource
|
||||
// images[0] is the background on the root, images[1] is the icon on the child
|
||||
var sprite = Resources.Load<Sprite>("LevelEditor/LevelEvents/MoveCamera");
|
||||
if (sprite != null)
|
||||
{
|
||||
var iconImage = images[1];
|
||||
iconImage.sprite = sprite;
|
||||
iconImage.rectTransform.sizeDelta = new Vector2(24, 24);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using HarmonyLib;
|
||||
|
||||
namespace ADOFAIRenderer.Patch.ClassPatch
|
||||
{
|
||||
[HarmonyPatch(typeof(scrController))]
|
||||
// ReSharper disable once InconsistentNaming
|
||||
public static class scrControllerPatch
|
||||
{
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch("TogglePauseGame")]
|
||||
public static bool PreventPause()
|
||||
{
|
||||
return !RenderMod.IsRendering;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using ADOFAIRenderer.Component;
|
||||
using HarmonyLib;
|
||||
|
||||
namespace ADOFAIRenderer.Patch.ClassPatch
|
||||
{
|
||||
[HarmonyPatch(typeof(scrPlayerManager))]
|
||||
// ReSharper disable once InconsistentNaming
|
||||
public static class scrPlayerManagerPatch
|
||||
{
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch("AnyValidInputWasTriggered")]
|
||||
// ReSharper disable once InconsistentNaming
|
||||
private static bool IgnoreInput(ref bool __result)
|
||||
{
|
||||
if (!RenderMod.IsRendering) return true;
|
||||
|
||||
__result = RenderManager.Countdown == 0;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using ADOFAIRenderer.Component;
|
||||
using HarmonyLib;
|
||||
|
||||
namespace ADOFAIRenderer.Patch.ClassPatch
|
||||
{
|
||||
[HarmonyPatch(typeof(scrPressToStart))]
|
||||
// ReSharper disable once InconsistentNaming
|
||||
public class scrPressToStartPatch
|
||||
{
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch("ShowText")]
|
||||
private static bool PreventShowText()
|
||||
{
|
||||
if (!RenderManager.SkipPressToStart) return true;
|
||||
|
||||
RenderManager.SkipPressToStart = false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using ADOFAIRenderer.Component;
|
||||
using HarmonyLib;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace ADOFAIRenderer.Patch.ClassPatch
|
||||
{
|
||||
[HarmonyPatch(typeof(scrShowIfDebug))]
|
||||
// ReSharper disable once InconsistentNaming
|
||||
public static class scrShowIfDebugPatch
|
||||
{
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch("Update")]
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
private static void IgnoreInput(Text ___txt, Color ___defaultColor)
|
||||
{
|
||||
if (!RenderMod.IsRendering) return;
|
||||
|
||||
___txt.text = "Rendering";
|
||||
if (RenderManager.Countdown > 0) ___txt.text += $" in {RenderManager.Countdown}..";
|
||||
|
||||
___txt.color = ___defaultColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using ADOFAIRenderer.Component;
|
||||
using HarmonyLib;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ADOFAIRenderer.Patch
|
||||
{
|
||||
public static class RenderEnvironmentPatches
|
||||
{
|
||||
private const bool RenderPatch = true;
|
||||
|
||||
[HarmonyPatch(typeof(Time), "time", MethodType.Getter)]
|
||||
public static class TimePatch
|
||||
{
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public static bool Prefix(ref float __result)
|
||||
{
|
||||
if (!RenderMod.IsCapturing || !RenderPatch) return true;
|
||||
__result = (float)(RenderManager.FrameCount / RenderManager.Configuration.TargetFPS);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(Time), "timeAsDouble", MethodType.Getter)]
|
||||
public static class TimeAsDoublePatch
|
||||
{
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public static bool Prefix(ref double __result)
|
||||
{
|
||||
if (!RenderMod.IsCapturing || !RenderPatch) return true;
|
||||
__result = RenderManager.FrameCount / RenderManager.Configuration.TargetFPS;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(Time), "unscaledTime", MethodType.Getter)]
|
||||
public static class UnscaledTimePatch
|
||||
{
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public static bool Prefix(ref float __result)
|
||||
{
|
||||
if (!RenderMod.IsCapturing || !RenderPatch) return true;
|
||||
__result = (float)(RenderManager.FrameCount / RenderManager.Configuration.TargetFPS);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(Time), "unscaledTimeAsDouble", MethodType.Getter)]
|
||||
public static class UnscaledTimeAsDoublePatch
|
||||
{
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public static bool Prefix(ref double __result)
|
||||
{
|
||||
if (!RenderMod.IsCapturing || !RenderPatch) return true;
|
||||
__result = RenderManager.FrameCount / RenderManager.Configuration.TargetFPS;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(AudioSettings), "dspTime", MethodType.Getter)]
|
||||
public static class DspTimePatch
|
||||
{
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public static bool Prefix(ref double __result)
|
||||
{
|
||||
if (!RenderMod.IsCapturing || !RenderPatch) return true;
|
||||
__result = RenderManager.FrameCount / RenderManager.Configuration.TargetFPS;
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(AudioSource), "PlayScheduled")]
|
||||
public static class PlayScheduledPatch
|
||||
{
|
||||
// ReSharper disable once InconsistentNaming
|
||||
public static bool Prefix(AudioSource __instance, double time)
|
||||
{
|
||||
return !RenderMod.IsRendering || !RenderPatch;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(Time), "frameCount", MethodType.Getter)]
|
||||
public static class FrameCountPatch
|
||||
{
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public static bool Prefix(ref int __result)
|
||||
{
|
||||
if (!RenderMod.IsCapturing || !RenderPatch) return true;
|
||||
__result = RenderManager.FrameCount;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(Time), "deltaTime", MethodType.Getter)]
|
||||
public static class DeltaTimePatch
|
||||
{
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public static bool Prefix(ref float __result)
|
||||
{
|
||||
if (!RenderMod.IsCapturing || !RenderPatch) return true;
|
||||
__result = (float)(1 / RenderManager.Configuration.TargetFPS);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(Time), "unscaledDeltaTime", MethodType.Getter)]
|
||||
public static class UnscaledDeltaTimePatch
|
||||
{
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public static bool Prefix(ref float __result)
|
||||
{
|
||||
if (!RenderMod.IsCapturing || !RenderPatch) return true;
|
||||
__result = (float)(1 / RenderManager.Configuration.TargetFPS);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(Screen), "width", MethodType.Getter)]
|
||||
public static class ScreenWidthPatch
|
||||
{
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public static bool Prefix(ref int __result)
|
||||
{
|
||||
if (!RenderMod.IsRendering || !RenderPatch) return true;
|
||||
__result = RenderManager.Configuration.RenderWidth;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(Screen), "height", MethodType.Getter)]
|
||||
public static class ScreenHeightPatch
|
||||
{
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public static bool Prefix(ref int __result)
|
||||
{
|
||||
if (!RenderMod.IsRendering || !RenderPatch) return true;
|
||||
__result = RenderManager.Configuration.RenderHeight;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using HarmonyLib;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ADOFAIRenderer.Patch
|
||||
{
|
||||
[HarmonyPatch(typeof(scrCamera), "SetCustomFrameRate")]
|
||||
public class SetCustomFrameRatePatch
|
||||
{
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
private static bool Prefix(scrCamera __instance, bool enable, float frame, ref MeshRenderer ___camQuadMesh, ref RenderTexture ___camRT)
|
||||
{
|
||||
// There is an issue that `mainTexture.Release` triggers even if `mainTexture` is `camRT`, so mod tries to fix it
|
||||
if (enable || __instance.enableCustomFPS != enable) return true;
|
||||
|
||||
__instance.enableCustomFPS = enable;
|
||||
__instance.frameRate = frame;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using HarmonyLib;
|
||||
|
||||
namespace ADOFAIRenderer.Patch
|
||||
{
|
||||
[HarmonyPatch(typeof(scrHitTextManager), "ShowHitText")]
|
||||
public class ShowHitTextPatch
|
||||
{
|
||||
public static bool Prefix()
|
||||
{
|
||||
return !RenderMod.IsRendering;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user