Please disclose if your mod was created primarily using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of LCCutscene v2.0.1
LCCutscene/LCCutscene.dll
Decompiled a year agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using LCCutscene.Patches; using UnityEngine; using UnityEngine.Animations; using UnityEngine.Animations.Rigging; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("LCCutscene")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("LCCutscene")] [assembly: AssemblyCopyright("Copyright © 2024")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("ab36879c-13c9-4bbe-ad1f-d5d9f31d2b8b")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] public enum EndPosition { Camera, Custom } public enum SceneType { Cutscene, QuickScene } public enum Transition { Fade, FadeIn, FadeOut, Instant } namespace LCCutscene { public class Content { public static AssetBundle MainAssets; public static void TryLoadAssets() { if ((Object)(object)MainAssets == (Object)null) { MainAssets = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "cutsceneasset")); Plugin.mls.LogInfo((object)"Loaded asset bundle!"); } } } public class Cutscene { public Transform CameraTransform { get; private set; } public float Time { get; private set; } public Transition TransitionIn { get; set; } = Transition.Fade; public Transition TransitionOut { get; set; } = Transition.Fade; public float TransitionInSpeed { get; set; } = 1f; public float TransitionOutSpeed { get; set; } = 1f; public bool AllowPlayerDeath { get; set; } = false; public bool AllowPlayerMovement { get; set; } = false; public Cutscene(Transform cameraTransform, float time) { CameraTransform = cameraTransform; Time = time; } } public class CutsceneManager : MonoBehaviour { [CompilerGenerated] private sealed class <DoCutscene>d__54 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public Cutscene cutscene; public CutsceneManager <>4__this; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <DoCutscene>d__54(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Expected O, but got Unknown //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Expected O, but got Unknown //IL_02a4: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Expected O, but got Unknown //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>4__this.currentCutscene = cutscene; <>4__this.currentSceneTime = 0f; <>4__this.sceneType = SceneType.Cutscene; if (cutscene.TransitionIn != Transition.Instant) { <>4__this.inTransition = true; CutsceneManager.OnSceneTransitionIn?.Invoke(<>4__this, EventArgs.Empty); } if (cutscene.TransitionIn == Transition.Fade || cutscene.TransitionIn == Transition.FadeIn) { <>2__current = (object)new WaitForSeconds(1f / cutscene.TransitionInSpeed); <>1__state = 1; return true; } goto IL_0104; case 1: <>1__state = -1; goto IL_0104; case 2: <>1__state = -1; <>4__this.OutTransition = true; CutsceneManager.OnSceneTransitionOut?.Invoke(<>4__this, EventArgs.Empty); <>2__current = (object)new WaitForSeconds(1f / cutscene.TransitionOutSpeed); <>1__state = 3; return true; case 3: <>1__state = -1; break; case 4: { <>1__state = -1; break; } IL_0104: <>4__this.cutscenePlaying = true; CutsceneManager.OnSceneStart?.Invoke(<>4__this, EventArgs.Empty); StartOfRound.Instance.allowLocalPlayerDeath = cutscene.AllowPlayerDeath; if (!cutscene.AllowPlayerMovement) { IngamePlayerSettings.Instance.playerInput.actions.FindAction("Move", false).Disable(); } if (!cutscene.AllowPlayerMovement) { IngamePlayerSettings.Instance.playerInput.actions.FindAction("Jump", false).Disable(); } if (!cutscene.AllowPlayerMovement) { IngamePlayerSettings.Instance.playerInput.actions.FindAction("Look", false).Disable(); } if (cutscene.TransitionOut != Transition.Instant && cutscene.TransitionOut != Transition.FadeOut) { <>2__current = (object)new WaitForSeconds(cutscene.Time - 1f / cutscene.TransitionOutSpeed); <>1__state = 2; return true; } <>2__current = (object)new WaitForSeconds(cutscene.Time); <>1__state = 4; return true; } if (((Behaviour)<>4__this.CutsceneCamera).enabled) { ((Behaviour)<>4__this.CutsceneCamera).enabled = false; } if (!((Behaviour)StartOfRound.Instance.localPlayerController.gameplayCamera).enabled) { ((Behaviour)StartOfRound.Instance.localPlayerController.gameplayCamera).enabled = true; } <>4__this.cutscenePlaying = false; <>4__this.currentSceneTime = 0f; <>4__this.sceneType = null; <>4__this.timeSinceStart = 0f; CutsceneManager.OnSceneEnd?.Invoke(<>4__this, EventArgs.Empty); if (!StartOfRound.Instance.allowLocalPlayerDeath) { StartOfRound.Instance.allowLocalPlayerDeath = true; } if (!cutscene.AllowPlayerMovement) { IngamePlayerSettings.Instance.playerInput.actions.FindAction("Move", false).Enable(); } if (!cutscene.AllowPlayerMovement) { IngamePlayerSettings.Instance.playerInput.actions.FindAction("Jump", false).Enable(); } if (!cutscene.AllowPlayerMovement) { IngamePlayerSettings.Instance.playerInput.actions.FindAction("Look", false).Enable(); } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <DoCutscene>d__55 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public QuickScene quickScene; public CutsceneManager <>4__this; private PlayerControllerB <player>5__1; private ConstraintSource <source>5__2; private float <sceneStartTime>5__3; private PlayerPose <>s__4; private PlayerPose <>s__5; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <DoCutscene>d__55(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) <player>5__1 = null; <source>5__2 = default(ConstraintSource); <>1__state = -2; } private bool MoveNext() { //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_0348: Unknown result type (might be due to invalid IL or missing references) //IL_0352: Expected O, but got Unknown //IL_02b8: Unknown result type (might be due to invalid IL or missing references) //IL_02c2: Expected O, but got Unknown //IL_04b7: Unknown result type (might be due to invalid IL or missing references) //IL_04bc: Unknown result type (might be due to invalid IL or missing references) //IL_04bf: Unknown result type (might be due to invalid IL or missing references) //IL_04e0: Unknown result type (might be due to invalid IL or missing references) //IL_057e: Unknown result type (might be due to invalid IL or missing references) //IL_0553: Unknown result type (might be due to invalid IL or missing references) Quaternion rotation; switch (<>1__state) { default: return false; case 0: { <>1__state = -1; <>4__this.currentQuickScene = quickScene; <>4__this.currentSceneTime = 0f; <>4__this.sceneType = SceneType.QuickScene; <player>5__1 = StartOfRound.Instance.localPlayerController; IngamePlayerSettings.Instance.playerInput.actions.FindAction("Move", false).Disable(); IngamePlayerSettings.Instance.playerInput.actions.FindAction("Jump", false).Disable(); IngamePlayerSettings.Instance.playerInput.actions.FindAction("Look", false).Disable(); <player>5__1.disableLookInput = true; <source>5__2 = default(ConstraintSource); ((ConstraintSource)(ref <source>5__2)).weight = 1f; ((ConstraintSource)(ref <source>5__2)).sourceTransform = quickScene.TargetPosition; if (quickScene.SnapPlayerToPositions) { <>4__this.playerConstraint.AddSource(<source>5__2); <>4__this.playerConstraint.locked = true; ParentConstraint playerConstraint2 = <>4__this.playerConstraint; rotation = ((Component)<player>5__1).gameObject.transform.rotation; playerConstraint2.rotationAtRest = ((Quaternion)(ref rotation)).eulerAngles; <>4__this.playerConstraint.translationAtRest = ((Component)<player>5__1).gameObject.transform.localPosition; <>4__this.playerConstraint.constraintActive = true; } <>4__this.inTransition = true; if (quickScene.POV == POVType.Full) { <>4__this.SetPlayerInFPS(state: true); } <>4__this.timeSinceStart = Time.realtimeSinceStartup; Plugin.mls.LogDebug((object)"Transitioning the player..."); PlayerPose startingPose = quickScene.StartingPose; <>s__4 = startingPose; switch (<>s__4) { case PlayerPose.Standing: if (<player>5__1.isCrouching) { <player>5__1.Crouch(!<player>5__1.isCrouching); } break; case PlayerPose.Crouched: if (!<player>5__1.isCrouching) { <player>5__1.Crouch(!<player>5__1.isCrouching); } break; } CutsceneManager.OnSceneTransitionIn?.Invoke(<>4__this, EventArgs.Empty); <>2__current = (object)new WaitUntil((Func<bool>)(() => !<>4__this.inTransition)); <>1__state = 1; return true; } case 1: <>1__state = -1; Plugin.mls.LogDebug((object)"Starting Quickscene..."); <sceneStartTime>5__3 = Time.realtimeSinceStartup; <>4__this.cutscenePlaying = true; CutsceneManager.OnSceneStart?.Invoke(<>4__this, EventArgs.Empty); if (quickScene.POV == POVType.Full) { <>4__this.StartQuickSceneAnimation(quickScene); } <>2__current = (object)new WaitForSeconds(quickScene.Time); <>1__state = 2; return true; case 2: { <>1__state = -1; if (quickScene.POV == POVType.Full) { <>4__this.StopQuickSceneAnimation(quickScene); } if (quickScene.POV == POVType.Full) { <>4__this.SetPlayerInFPS(state: false); } <>4__this.cutscenePlaying = false; <>4__this.currentSceneTime = 0f; <>4__this.sceneType = null; <>4__this.timeSinceStart = 0f; CutsceneManager.OnSceneEnd?.Invoke(<>4__this, EventArgs.Empty); PlayerPose endingPose = quickScene.EndingPose; <>s__5 = endingPose; switch (<>s__5) { case PlayerPose.Standing: if (<player>5__1.isCrouching) { <player>5__1.Crouch(!<player>5__1.isCrouching); } break; case PlayerPose.Crouched: if (!<player>5__1.isCrouching) { <player>5__1.Crouch(!<player>5__1.isCrouching); } break; } if (quickScene.SnapPlayerToPositions) { ParentConstraint playerConstraint = <>4__this.playerConstraint; rotation = ((Component)<player>5__1).transform.rotation; playerConstraint.rotationAtRest = ((Quaternion)(ref rotation)).eulerAngles; <>4__this.playerConstraint.translationAtRest = ((Component)<player>5__1).transform.position; <>4__this.playerConstraint.weight = 0f; <>4__this.playerConstraint.constraintActive = false; <>4__this.playerConstraint.RemoveSource(0); } if ((Object)(object)quickScene.TargetEndPosition != (Object)null) { ((Component)<player>5__1).transform.position = quickScene.TargetEndPosition.position; } ((Component)<player>5__1).transform.rotation = Quaternion.Euler(0f, quickScene.TargetEndRotation, 0f); IngamePlayerSettings.Instance.playerInput.actions.FindAction("Move", false).Enable(); IngamePlayerSettings.Instance.playerInput.actions.FindAction("Jump", false).Enable(); IngamePlayerSettings.Instance.playerInput.actions.FindAction("Look", false).Enable(); <player>5__1.disableLookInput = false; return false; } } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private Volume fadeVolume; private bool inTransition; private bool OutTransition; private float transitionTime = 0f; private SceneType? sceneType = null; private Cutscene currentCutscene; private QuickScene currentQuickScene; private float currentSceneTime = 0f; private bool initialized = false; private float timeSinceStart = 0f; private PlayerControllerB player; private Animation playerAnim; private RigBuilder rigs; private List<ParentConstraint> constraints = new List<ParentConstraint>(); private ParentConstraint playerConstraint; private bool localPlayerSet = false; private bool inFPS = false; public static CutsceneManager Instance { get; private set; } public Camera CutsceneCamera { get; private set; } public bool cutscenePlaying { get; private set; } = false; public static event EventHandler OnSceneStart; public static event EventHandler OnSceneEnd; public static event EventHandler OnSceneTransitionIn; public static event EventHandler OnSceneTransitionOut; private void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; } else { Object.Destroy((Object)(object)((Component)this).gameObject); } } private void Start() { Init(); } private void Init() { //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown if (!initialized) { if (!Object.op_Implicit((Object)(object)fadeVolume)) { GameObject val = new GameObject("Fade Volume"); fadeVolume = val.AddComponent<Volume>(); fadeVolume.profile = Content.MainAssets.LoadAsset<VolumeProfile>("Assets/Cutscene/fade.asset"); fadeVolume.isGlobal = true; fadeVolume.weight = 0f; fadeVolume.sharedProfile = Content.MainAssets.LoadAsset<VolumeProfile>("Assets/Cutscene/fade.asset"); } CutsceneCamera = new GameObject("Cutscene_Camera").AddComponent<Camera>(); ((Component)CutsceneCamera).gameObject.tag = "MainCamera"; CutsceneCamera.cullingMask = 557520895; ((Behaviour)CutsceneCamera).enabled = false; initialized = true; Plugin.mls.LogInfo((object)"Cutscene Manager initialized!"); } else { Plugin.mls.LogWarning((object)"Tried to initialize Cutscene Manager when already initialized!"); } } private void SetLocalPlayer() { playerAnim = ((Component)((Component)player).transform.Find("ScavengerModel/metarig")).gameObject.GetComponent<Animation>(); playerConstraint = ((Component)player).gameObject.GetComponent<ParentConstraint>(); rigs = ((Component)((Component)player).transform.Find("ScavengerModel/metarig")).gameObject.GetComponent<RigBuilder>(); constraints.Add(((Component)player.gameplayCamera).gameObject.GetComponent<ParentConstraint>()); constraints.Add(((Component)((Component)player).transform.Find("ScavengerModel/metarig/ScavengerModelArmsOnly")).gameObject.GetComponent<ParentConstraint>()); localPlayerSet = true; } private void Update() { //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_07a9: Unknown result type (might be due to invalid IL or missing references) //IL_07ca: Unknown result type (might be due to invalid IL or missing references) //IL_0829: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)null) { player = StartOfRound.Instance.localPlayerController; } else if (!localPlayerSet) { SetLocalPlayer(); } if ((Object)(object)player != (Object)null && localPlayerSet) { foreach (ParentConstraint constraint in constraints) { constraint.weight = Mathf.Lerp(constraint.weight, inFPS ? 1f : 0f, (currentQuickScene == null) ? 0f : (currentQuickScene.SnapSpeed * Time.deltaTime)); } constraints[0].constraintActive = constraints[0].weight > 0.05f; } if (inTransition) { if (sceneType.GetValueOrDefault() == SceneType.QuickScene && currentQuickScene != null) { playerConstraint.weight = Mathf.Lerp(playerConstraint.weight, 1f, currentQuickScene.SnapSpeed * Time.deltaTime); ((Component)player).transform.rotation = Quaternion.Lerp(((Component)player).transform.rotation, Quaternion.Euler(0f, currentQuickScene.TargetRotation, 0f), currentQuickScene.SnapSpeed * Time.deltaTime); if (playerConstraint.weight > 0.95f) { inTransition = false; playerConstraint.weight = 1f; } if (Time.realtimeSinceStartup - timeSinceStart >= 5f) { inTransition = false; } } else if (sceneType == SceneType.Cutscene && currentCutscene != null) { if (currentCutscene.TransitionIn == Transition.Fade) { if (transitionTime < 1f) { fadeVolume.weight = Mathf.Lerp(0f, 1f, transitionTime); transitionTime += Time.deltaTime * currentCutscene.TransitionInSpeed; } else if (transitionTime >= 1f && transitionTime < 2f) { fadeVolume.weight = Mathf.Lerp(1f, 0f, transitionTime - 1f); transitionTime += Time.deltaTime * currentCutscene.TransitionInSpeed; } else if (transitionTime >= 2f && !OutTransition) { inTransition = false; transitionTime = 0f; } } else if (currentCutscene.TransitionIn == Transition.FadeIn) { if (transitionTime < 1f) { fadeVolume.weight = Mathf.Lerp(0f, 1f, transitionTime); transitionTime += Time.deltaTime * currentCutscene.TransitionInSpeed; } else if (transitionTime >= 1f) { inTransition = false; transitionTime = 0f; } } else if (currentCutscene.TransitionIn == Transition.FadeOut) { if (transitionTime < 1f) { fadeVolume.weight = Mathf.Lerp(1f, 0f, transitionTime); transitionTime += Time.deltaTime * currentCutscene.TransitionInSpeed; } else if (transitionTime >= 1f) { inTransition = false; transitionTime = 0f; } } } } else if (OutTransition) { if (currentCutscene.TransitionOut == Transition.Fade) { if (transitionTime < 1f) { fadeVolume.weight = Mathf.Lerp(0f, 1f, transitionTime); transitionTime += Time.deltaTime * currentCutscene.TransitionOutSpeed; } else if (transitionTime >= 1f && transitionTime < 2f) { fadeVolume.weight = Mathf.Lerp(1f, 0f, transitionTime - 1f); transitionTime += Time.deltaTime * currentCutscene.TransitionOutSpeed; } else if (transitionTime >= 2f) { OutTransition = false; transitionTime = 0f; } } else if (currentCutscene.TransitionOut == Transition.FadeIn) { if (transitionTime < 1f) { fadeVolume.weight = Mathf.Lerp(0f, 1f, transitionTime); transitionTime += Time.deltaTime * currentCutscene.TransitionOutSpeed; } else if (transitionTime >= 1f) { OutTransition = false; transitionTime = 0f; } } else if (currentCutscene.TransitionOut == Transition.FadeOut) { if (transitionTime < 1f) { fadeVolume.weight = Mathf.Lerp(1f, 0f, transitionTime); transitionTime += Time.deltaTime * currentCutscene.TransitionOutSpeed; } else if (transitionTime >= 1f) { OutTransition = false; transitionTime = 0f; } } } else { fadeVolume.weight = 0f; } if (!cutscenePlaying) { return; } if (sceneType == SceneType.Cutscene && currentCutscene != null) { if (((Behaviour)StartOfRound.Instance.localPlayerController.gameplayCamera).enabled) { ((Behaviour)player.gameplayCamera).enabled = false; } if (!((Behaviour)CutsceneCamera).enabled) { ((Behaviour)CutsceneCamera).enabled = true; } ((Component)CutsceneCamera).transform.position = currentCutscene.CameraTransform.position; ((Component)CutsceneCamera).transform.rotation = currentCutscene.CameraTransform.rotation; currentSceneTime += Time.deltaTime; } if (sceneType.GetValueOrDefault() == SceneType.QuickScene && currentQuickScene != null) { ((Component)player).transform.rotation = Quaternion.Euler(0f, currentQuickScene.TargetRotation, 0f); } } private void SetPlayerInFPS(bool state) { if ((Object)(object)player == (Object)null) { return; } inFPS = state; ((Renderer)player.thisPlayerModelArms).enabled = !state; ((Renderer)player.thisPlayerModel).shadowCastingMode = (ShadowCastingMode)(state ? 1 : 3); foreach (RigLayer layer in rigs.layers) { layer.active = !state; } } public void PlayAnimationOnOtherPlayer(PlayerControllerB _player, QuickScene _quickScene) { if ((Object)(object)_player == (Object)null) { return; } Animation component = ((Component)((Component)_player).transform.Find("ScavengerModel/metarig")).gameObject.GetComponent<Animation>(); RigBuilder component2 = ((Component)((Component)_player).transform.Find("ScavengerModel/metarig")).gameObject.GetComponent<RigBuilder>(); component.Stop(); if (_quickScene.Clips.Count > 0) { for (int i = 0; i < _quickScene.Clips.Count; i++) { AnimationClip val = _quickScene.Clips[i]; val.legacy = true; component.AddClip(val, "Animation" + (i + 1)); } for (int j = 0; j < _quickScene.Clips.Count; j++) { if (j == 0) { component.Play("Animation1"); } component.PlayQueued("Animation" + (j + 1)); AnimationClip val2 = _quickScene.Clips[j]; val2.legacy = false; } } foreach (RigLayer layer in component2.layers) { layer.active = false; } ((Behaviour)_player.playerBodyAnimator).enabled = false; } public void PlayAnimationOnOtherPlayer(PlayerControllerB _player, List<AnimationClip> clips) { if ((Object)(object)_player == (Object)null) { return; } Animation component = ((Component)((Component)_player).transform.Find("ScavengerModel/metarig")).gameObject.GetComponent<Animation>(); RigBuilder component2 = ((Component)((Component)_player).transform.Find("ScavengerModel/metarig")).gameObject.GetComponent<RigBuilder>(); component.Stop(); if (clips.Count > 0) { for (int i = 0; i < clips.Count; i++) { AnimationClip val = clips[i]; val.legacy = true; component.AddClip(val, "Animation" + (i + 1)); } for (int j = 0; j < clips.Count; j++) { if (j == 0) { component.Play("Animation1"); } component.PlayQueued("Animation" + (j + 1)); AnimationClip val2 = clips[j]; val2.legacy = false; } } foreach (RigLayer layer in component2.layers) { layer.active = false; } ((Behaviour)_player.playerBodyAnimator).enabled = false; } public void StopAnimationOnOtherPlayer(PlayerControllerB _player) { if ((Object)(object)_player == (Object)null) { return; } Animation component = ((Component)((Component)_player).transform.Find("ScavengerModel/metarig")).gameObject.GetComponent<Animation>(); RigBuilder component2 = ((Component)((Component)_player).transform.Find("ScavengerModel/metarig")).gameObject.GetComponent<RigBuilder>(); foreach (RigLayer layer in component2.layers) { layer.active = true; } ((Behaviour)_player.playerBodyAnimator).enabled = true; component.Stop(); for (int i = 0; i < playerAnim.GetClipCount(); i++) { component.RemoveClip("Animation" + (i + 1)); } component.clip = null; } private void StartQuickSceneAnimation(QuickScene scene) { if (scene == null) { return; } playerAnim.Stop("Animation"); if (scene.useAnimationList) { for (int i = 0; i < scene.Clips.Count; i++) { AnimationClip val = scene.Clips[i]; val.legacy = true; playerAnim.AddClip(val, "Animation" + (i + 1)); } } else if (scene.Clips.Count > 0) { scene.Clips[0].legacy = true; playerAnim.AddClip(scene.Clips[0], "Animation1"); } if (scene.useAnimationList) { for (int j = 0; j < scene.Clips.Count; j++) { if (j == 0) { playerAnim.Play("Animation1"); } playerAnim.PlayQueued("Animation" + (j + 1)); AnimationClip val2 = scene.Clips[j]; val2.legacy = false; } } else { scene.Clips[0].legacy = false; if (scene.Clips.Count > 0) { playerAnim.Play("Animation1"); } } ((Behaviour)player.playerBodyAnimator).enabled = false; } public void StopQuickSceneAnimation(QuickScene scene) { if (scene != null) { playerAnim.Stop(); for (int i = 0; i < playerAnim.GetClipCount(); i++) { playerAnim.RemoveClip("Animation" + (i + 1)); } ((Behaviour)player.playerBodyAnimator).enabled = true; playerAnim.clip = null; } } public void PlayScene(Cutscene cutscene) { if (!Object.op_Implicit((Object)(object)cutscene.CameraTransform) || (Object)(object)cutscene.CameraTransform == (Object)null) { Plugin.mls.LogError((object)$"Camera is {cutscene.CameraTransform}! Cutscene aborted."); } else if (!Object.op_Implicit((Object)(object)StartOfRound.Instance.localPlayerController) || (Object)(object)StartOfRound.Instance.localPlayerController == (Object)null) { Plugin.mls.LogError((object)$"Player is {StartOfRound.Instance.localPlayerController}! Cutscene aborted."); } else if (cutscene.Time <= 0f) { Plugin.mls.LogError((object)"Cutscene time can't be 0 or lower! Cutscene aborted."); } else if (cutscenePlaying) { Plugin.mls.LogError((object)"A cutscene is already playing! Cutscene aborted."); } else { ((MonoBehaviour)this).StartCoroutine(DoCutscene(cutscene)); } } public void PlayScene(QuickScene quickScene) { if ((Object)(object)quickScene.TargetPosition == (Object)null) { Plugin.mls.LogError((object)$"Target view is {quickScene.TargetPosition}! Cutscene aborted."); } else if (!Object.op_Implicit((Object)(object)StartOfRound.Instance.localPlayerController) || (Object)(object)StartOfRound.Instance.localPlayerController == (Object)null) { Plugin.mls.LogError((object)$"Player is {StartOfRound.Instance.localPlayerController}! Cutscene aborted."); } else if (quickScene.Time <= 0f) { Plugin.mls.LogError((object)"Cutscene time can't be 0 or lower! Cutscene aborted."); } else if (cutscenePlaying) { Plugin.mls.LogError((object)"A cutscene is already playing! Cutscene aborted."); } else { ((MonoBehaviour)this).StartCoroutine(DoCutscene(quickScene)); } } [IteratorStateMachine(typeof(<DoCutscene>d__54))] private IEnumerator DoCutscene(Cutscene cutscene) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <DoCutscene>d__54(0) { <>4__this = this, cutscene = cutscene }; } [IteratorStateMachine(typeof(<DoCutscene>d__55))] private IEnumerator DoCutscene(QuickScene quickScene) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <DoCutscene>d__55(0) { <>4__this = this, quickScene = quickScene }; } } [BepInPlugin("Chaos.LCCutscene", "LCCutscene", "2.0.1")] public class Plugin : BaseUnityPlugin { private const string modGUID = "Chaos.LCCutscene"; private const string modName = "LCCutscene"; private const string modVersion = "2.0.1"; private readonly Harmony harmony = new Harmony("Chaos.LCCutscene"); public static Plugin Instance; public static ManualLogSource mls; public static ConfigFile config; private void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; } mls = ((BaseUnityPlugin)this).Logger; Content.TryLoadAssets(); harmony.PatchAll(typeof(PlayerPatch)); harmony.PatchAll(typeof(StartOfRoundPatch)); mls.LogInfo((object)"LCCutscene started."); } } public class QuickScene { public float Time { get; private set; } public Transform TargetPosition { get; private set; } public Transform TargetEndPosition { get; private set; } public float TargetRotation { get; private set; } public float TargetEndRotation { get; private set; } public List<AnimationClip> Clips { get; private set; } public POVType POV { get; private set; } public PlayerPose StartingPose { get; private set; } public PlayerPose EndingPose { get; private set; } public bool SnapPlayerToPositions { get; private set; } public float SnapSpeed { get; private set; } public bool useAnimationList { get; private set; } = false; public QuickScene(float time, Transform targetPosition, float targetRotation, AnimationClip clip, Transform targetEndPosition = null, float? targetEndRotation = null, bool snapPlayersToPositions = true, float snapSpeed = 10f, PlayerPose startingPose = PlayerPose.Standing, PlayerPose endingPose = PlayerPose.Standing) { Time = time; TargetPosition = targetPosition; TargetEndPosition = targetEndPosition; TargetRotation = targetRotation; Clips = new List<AnimationClip>(); Clips.Add(clip); if (targetEndRotation.HasValue) { TargetEndRotation = targetEndRotation.Value; } else { TargetEndRotation = TargetRotation; } POV = POVType.Full; StartingPose = startingPose; EndingPose = endingPose; SnapPlayerToPositions = snapPlayersToPositions; SnapSpeed = snapSpeed; } public QuickScene(float time, Transform targetPosition, float targetRotation, List<AnimationClip> clips, Transform targetEndPosition = null, float? targetEndRotation = null, bool snapPlayersToPositions = true, float snapSpeed = 10f, PlayerPose startingPose = PlayerPose.Standing, PlayerPose endingPose = PlayerPose.Standing) { Time = time; TargetPosition = targetPosition; TargetEndPosition = targetEndPosition; TargetRotation = targetRotation; Clips = clips; useAnimationList = true; if (targetEndRotation.HasValue) { TargetEndRotation = targetEndRotation.Value; } else { TargetEndRotation = TargetRotation; } POV = POVType.Full; StartingPose = startingPose; EndingPose = endingPose; SnapPlayerToPositions = snapPlayersToPositions; SnapSpeed = snapSpeed; } } public enum PlayerPose { Standing, Crouched } public enum POVType { Full, ArmsOnly } } namespace LCCutscene.Patches { [HarmonyPatch(typeof(PlayerControllerB))] internal class PlayerPatch { [HarmonyPatch(typeof(PlayerControllerB), "Awake")] [HarmonyPostfix] public static void Awake(PlayerControllerB __instance) { //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Expected O, but got Unknown //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: Unknown result type (might be due to invalid IL or missing references) //IL_02cd: Unknown result type (might be due to invalid IL or missing references) //IL_02f3: Unknown result type (might be due to invalid IL or missing references) //IL_0301: Unknown result type (might be due to invalid IL or missing references) bool flag = IsPlayerSetup(__instance); Plugin.mls.LogDebug((object)(__instance.playerUsername + " is setup? : " + flag)); if (!flag) { Animation val = ((Component)((Component)__instance).transform.Find("ScavengerModel/metarig")).gameObject.GetComponent<Animation>(); if ((Object)(object)val == (Object)null) { val = ((Component)((Component)__instance).transform.Find("ScavengerModel/metarig")).gameObject.AddComponent<Animation>(); } val.playAutomatically = true; ParentConstraint val2 = ((Component)__instance).gameObject.GetComponent<ParentConstraint>(); if ((Object)(object)val2 == (Object)null) { val2 = ((Component)__instance).gameObject.AddComponent<ParentConstraint>(); } val2.constraintActive = false; val2.weight = 0f; val2.locked = false; val2.rotationAxis = (Axis)0; ParentConstraint val3 = ((Component)__instance.gameplayCamera).gameObject.GetComponent<ParentConstraint>(); if ((Object)(object)val3 == (Object)null) { val3 = ((Component)__instance.gameplayCamera).gameObject.AddComponent<ParentConstraint>(); } ConstraintSource val4 = default(ConstraintSource); Transform obj = ((Component)__instance).transform.Find("ScavengerModel/metarig/spine/spine.001/spine.002/spine.003/spine.004/CamPoint"); GameObject val5 = ((obj != null) ? ((Component)obj).gameObject : null); if ((Object)(object)val5 == (Object)null) { val5 = new GameObject("CamPoint"); } val5.transform.SetParent(((Component)__instance).transform.Find("ScavengerModel/metarig/spine/spine.001/spine.002/spine.003/spine.004")); val5.transform.localPosition = new Vector3(0f, 0.20460416f, 0.1370099f); val5.transform.localScale = Vector3.one; val5.transform.localRotation = Quaternion.identity; ((ConstraintSource)(ref val4)).weight = 1f; ((ConstraintSource)(ref val4)).sourceTransform = val5.transform; val3.AddSource(val4); val3.translationAtRest = Vector3.zero; val3.rotationAtRest = Vector3.zero; val3.locked = true; val3.SetTranslationOffset(0, new Vector3(0f, 0.22934699f, 0.022789001f)); val3.SetRotationOffset(0, new Vector3(-1.4772427f, 0f, 0f)); val3.weight = 0f; val3.constraintActive = false; ParentConstraint val6 = ((Component)((Component)__instance).transform.Find("ScavengerModel/metarig/ScavengerModelArmsOnly")).gameObject.GetComponent<ParentConstraint>(); if ((Object)(object)val6 == (Object)null) { val6 = ((Component)((Component)__instance).transform.Find("ScavengerModel/metarig/ScavengerModelArmsOnly")).gameObject.AddComponent<ParentConstraint>(); } ConstraintSource val7 = default(ConstraintSource); ((ConstraintSource)(ref val7)).weight = 1f; ((ConstraintSource)(ref val7)).sourceTransform = ((Component)__instance.gameplayCamera).transform; val6.AddSource(val7); val6.translationAtRest = Vector3.zero; val6.rotationAtRest = new Vector3(89.980225f, 0f, 0f); val6.locked = true; val6.SetTranslationOffset(0, new Vector3(0f, -2.359903f, -0.013459206f)); val6.SetRotationOffset(0, Vector3.zero); val6.weight = 0f; val6.constraintActive = false; } } private static bool IsPlayerSetup(PlayerControllerB player) { bool flag = Object.op_Implicit((Object)(object)((Component)((Component)player).transform.Find("ScavengerModel/metarig")).gameObject.GetComponent<Animation>()); bool flag2 = Object.op_Implicit((Object)(object)((Component)player).transform.Find("ScavengerModel/metarig/spine/spine.001/spine.002/spine.003/spine.004/CamPoint")); bool flag3 = Object.op_Implicit((Object)(object)((Component)player).gameObject.GetComponent<ParentConstraint>()); bool flag4 = Object.op_Implicit((Object)(object)((Component)player.gameplayCamera).gameObject.GetComponent<ParentConstraint>()); Transform obj = ((Component)player).transform.Find("ScavengerModel/metarig/ScavengerModelArmsOnly"); bool flag5 = Object.op_Implicit((Object)(object)((obj != null) ? ((Component)obj).gameObject.GetComponent<ParentConstraint>() : null)); return flag && flag2 && flag3 && flag4 && flag5; } } [HarmonyPatch(typeof(StartOfRound))] public class StartOfRoundPatch { [HarmonyPatch(typeof(StartOfRound), "Awake")] [HarmonyPrefix] private static void Awake(ref StartOfRound __instance) { CutsceneManager component = ((Component)__instance).gameObject.GetComponent<CutsceneManager>(); if (!Object.op_Implicit((Object)(object)component)) { ((Component)__instance).gameObject.AddComponent<CutsceneManager>(); } } } }