private static bool ApplyRotation(NeckLookControllerVer2 __instance) { if (POVEnabled) { if (!currentChara) { POVEnabled = false; return(true); } Vector3 rot; if (LookRotation.TryGetValue(currentCharaGo, out var val)) { rot = val; } else { LookRotation[currentCharaGo] = rot = currentChara.objHeadBone.transform.rotation.eulerAngles; } if (__instance.neckLookScript && currentChara.neckLookCtrl == __instance) { __instance.neckLookScript.aBones[0].neckBone.rotation = Quaternion.identity; __instance.neckLookScript.aBones[1].neckBone.rotation = Quaternion.identity; __instance.neckLookScript.aBones[1].neckBone.Rotate(rot); var eyeObjs = currentChara.eyeLookCtrl.eyeLookScript.eyeObjs; GameCamera.transform.position = Vector3.Lerp(eyeObjs[0].eyeTransform.position, eyeObjs[1].eyeTransform.position, 0.5f); GameCamera.transform.rotation = currentChara.objHeadBone.transform.rotation; GameCamera.transform.Translate(Vector3.forward * ViewOffset.Value); GameCamera.fieldOfView = CurrentFOV.Value; return(false); } } return(true); }
protected override void EnablePov() { if (!currentChara) { if (isStudio) { var selectedCharas = GuideObjectManager.Instance.selectObjectKey.Select(x => Studio.Studio.GetCtrlInfo(x) as OCIChar).Where(x => x != null).ToList(); if (selectedCharas.Count > 0) { var ociChar = selectedCharas.First(); currentChara = ociChar.charInfo; currentCharaId = ociChar.objectInfo.dicKey; currentCharaGo = currentChara.gameObject; } else { Logger.LogMessage("Select a character in workspace to enter its POV"); } } else { Queue <ChaControl> CreateQueue() { return(new Queue <ChaControl>(FindObjectsOfType <ChaControl>())); } ChaControl GetCurrentChara() { for (int i = 0; i < charaQueue.Count; i++) { var chaControl = charaQueue.Dequeue(); // Remove destroyed if (!chaControl) { continue; } // Rotate the queue charaQueue.Enqueue(chaControl); if (chaControl.sex == 0 && hFlag && (hFlag.mode == HFlag.EMode.aibu || hFlag.mode == HFlag.EMode.lesbian || hFlag.mode == HFlag.EMode.masturbation)) { continue; } // Found a valid character, otherwise skip (needed for story mode H because roam mode characters are in the queue too, just disabled) if (chaControl.objTop.activeInHierarchy) { return(chaControl); } } return(null); } if (charaQueue == null) { charaQueue = CreateQueue(); } currentChara = GetCurrentChara(); if (!currentChara) { charaQueue = CreateQueue(); currentChara = GetCurrentChara(); } currentCharaGo = currentChara?.gameObject; } } if (currentChara) { prevVisibleHeadAlways = currentChara.fileStatus.visibleHeadAlways; if (HideHead.Value) { currentChara.fileStatus.visibleHeadAlways = false; } GameCamera = Camera.main; var cc = (MonoBehaviour)GameCamera.GetComponent <CameraControl_Ver2>() ?? GameCamera.GetComponent <Studio.CameraControl>(); if (cc) { cc.enabled = false; } // Fix depth of field being completely out of focus var depthOfField = GameCamera.GetComponent <UnityStandardAssets.ImageEffects.DepthOfField>(); dofOrigSize = depthOfField.focalSize; dofOrigAperature = depthOfField.aperture; if (depthOfField.enabled) { depthOfField.focalTransform.localPosition = new Vector3(0, 0, 0.25f); depthOfField.focalSize = 0.9f; depthOfField.aperture = 0.6f; } // only use head rotation if there is no existing rotation if (!LookRotation.TryGetValue(currentCharaGo, out _)) { LookRotation[currentCharaGo] = currentChara.objHeadBone.transform.rotation.eulerAngles; } else { // always get z axis from head var rot = LookRotation[currentCharaGo]; LookRotation[currentCharaGo] = new Vector3(rot.x, rot.y, currentChara.objHeadBone.transform.rotation.eulerAngles.z); } base.EnablePov(); backupLayer = GameCamera.gameObject.layer; GameCamera.gameObject.layer = 0; } }