Example #1
0
        private static void SetupIntro(On.RoR2.StartEvent.orig_Start orig, StartEvent self)
        {
            if (self.GetComponent <IntroCutsceneController>() != null)
            {
                GameObject cameraRigObject = GameObject.Find("Menu Main Camera");

                if (cameraRigObject)
                {
                    cameraRigObject.transform.localScale /= 6;

                    CameraRigController cameraRig = cameraRigObject.GetComponent <CameraRigController>();

                    Vector3 offset = new Vector3(-0.3387751f, 0.1797891f, -0.5321155f) * 5 / 6;

                    if (ModConfig.InitialRoomscaleValue)
                    {
                        offset.y -= ModConfig.PlayerHeight.Value / 6;
                    }

                    cameraRig.desiredCameraState = new CameraState
                    {
                        position = offset,
                        rotation = Quaternion.Euler(3.899f, -180, 0)
                    };

                    cameraRig.currentCameraState = cameraRig.desiredCameraState;

                    GameObject.Destroy(cameraRig.sceneCam.GetComponent <MatchCamera>());

                    Transform  cameraParent      = cameraRig.sceneCam.transform.parent;
                    GameObject newSceneCamObject = GameObject.Instantiate(cameraRig.sceneCam.gameObject, cameraParent.position, cameraParent.rotation, cameraParent);
                    GameObject.Destroy(cameraRig.sceneCam.gameObject);

                    Camera newCam = newSceneCamObject.GetComponent <Camera>();
                    newCam.cullingMask = newCam.cullingMask & ~(1 << LayerIndex.ui.intVal);
                    cameraRig.sceneCam = newCam;
                    cameraRig.sprintingParticleSystem = newSceneCamObject.GetComponentInChildren <ParticleSystem>();

                    if (CameraFixes.liv)
                    {
                        CameraFixes.liv.HMDCamera = newCam;
                    }

                    FixIntroCanvas(cameraRig);
                    AdjustIntroElements();
                }
            }
            orig(self);
        }