SHA256
Refactor
This commit is contained in:
4 files changed
+18
-16
No files matched your search
@@ -40,7 +40,6 @@ public static class EndscreenLanternsPatch
|
||||
for (var i = 0; i < lampSequencesArray.Length; i++)
|
||||
{
|
||||
var item = lampSequencesArray.GetValue(i);
|
||||
if (item == null) continue;
|
||||
try
|
||||
{
|
||||
var killMethod = item.GetType().GetMethod("Kill", new[] { typeof(bool) });
|
||||
|
||||
@@ -78,10 +78,8 @@ public static class scnGamePatch
|
||||
{
|
||||
// Remove FFmpeg player if it was attached previously
|
||||
var oldPlayer = __instance.videoBG.gameObject.GetComponent<FFmpegVideoBGPlayer>();
|
||||
if (oldPlayer != null)
|
||||
{
|
||||
Object.Destroy(oldPlayer);
|
||||
}
|
||||
if (oldPlayer) Object.Destroy(oldPlayer);
|
||||
|
||||
// Re-enable native player component
|
||||
__instance.videoBG.enabled = true;
|
||||
return true; // Execute original
|
||||
@@ -125,8 +123,7 @@ public static class scnGamePatch
|
||||
__instance.videoBG.enabled = false;
|
||||
|
||||
// Add or retrieve our custom FFmpeg video background player
|
||||
var player = __instance.videoBG.gameObject.GetComponent<FFmpegVideoBGPlayer>();
|
||||
if (player == null)
|
||||
if (!__instance.videoBG.gameObject.TryGetComponent<FFmpegVideoBGPlayer>(out var player))
|
||||
{
|
||||
player = __instance.videoBG.gameObject.AddComponent<FFmpegVideoBGPlayer>();
|
||||
}
|
||||
@@ -134,7 +131,7 @@ public static class scnGamePatch
|
||||
var isLooping = __instance.levelData.miscSettings.GetBool("loopVideo");
|
||||
|
||||
// Initialize player. If targetTexture is null (CameraFarPlane mode), it will build a quad in front of targetCamera.
|
||||
player.Init(videoPath, __instance.videoBG.targetTexture, isLooping, targetCamera, __instance.videoBG.gameObject);
|
||||
player.Init(videoPath, __instance.videoBG?.targetTexture, isLooping, targetCamera, __instance.videoBG.gameObject);
|
||||
|
||||
return false; // Skip original UpdateVideo
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user