public override void LateUpdate(FlybyCameraMFDPage mfdPage) { if (SCamPlus.player != null) { Vector3 offset = (SCamPlus.player.transform.position - SCamPlus.GetTargetPos()).normalized * Mathf.Tan((90 - SCamPlus.lastFov) * Mathf.Deg2Rad) * 30; Vector3 average = (SCamPlus.player.transform.position + SCamPlus.GetTargetPos()) / 2; if (offset.magnitude > SCamPlus.aceMaxDistance) { offset = offset.normalized * SCamPlus.aceMaxDistance; } Vector3 targetOffset = offset; Quaternion targetRotation = Quaternion.LookRotation(average - SCamPlus.player.transform.position + targetOffset); targetOffset += targetRotation * (SCamPlus.GetUpVector() * 10); targetRotation = Quaternion.LookRotation(average - (SCamPlus.player.transform.position + targetOffset)); float distance = ((SCamPlus.player.transform.position + SCamPlus.lastOffset) - SCamPlus.GetTargetPos()).magnitude + Vector3.Dot(-offset.normalized, SCamPlus.GetTargetVel() - SCamPlus.player.velocity) * SCamPlus.aceZoomLead; float targetFov = Mathf.Clamp(Mathf.Atan2(50, distance) * Mathf.Rad2Deg, SCamPlus.aceFovRange.min, SCamPlus.aceFovRange.max); mfdPage.flybyCam.fieldOfView = Mathf.Lerp(SCamPlus.lastFov, targetFov, Time.deltaTime * SCamPlus.aceZoomLerp); SCamPlus.lastOffset = Vector3.Slerp(SCamPlus.lastOffset, targetOffset, Time.deltaTime * SCamPlus.acePosLerp); mfdPage.flybyCam.transform.position = SCamPlus.player.transform.position + SCamPlus.lastOffset; mfdPage.flybyCam.transform.rotation = Quaternion.Slerp(SCamPlus.lastRotation, targetRotation, Time.deltaTime * SCamPlus.aceRotLerp); SCamPlus.lastRotation = mfdPage.flybyCam.transform.rotation; SCamPlus.lastFov = mfdPage.flybyCam.fieldOfView; if (SCamPlus.targetActor != null) { shownName = "AceCombat"; } else { shownName = "NoTgt"; } } else { shownName = "NoPlayer"; } }
public static bool Prefix(FlybyCameraMFDPage __instance) { if ((bool)SCamPlus.sCamTraverse.Field("randomModes").GetValue()) { return(false); } Debug.Log("Incrementing S-Cam mode"); SCamPlus.currentBehaviour++; if ((int)SCamPlus.currentBehaviour > 6 + SCamPlus.cameraModes.Count) { SCamPlus.currentBehaviour = 0; Debug.Log("Too large, reseting to 0"); } Debug.Log("S-Cam Mode is now " + SCamPlus.currentBehaviour.ToString()); //SCamPlus.sCamTraverse.Method("UpdateBehaviorText"); SCamPlus.UpdateBehaviourText(__instance); if ((bool)SCamPlus.sCamTraverse.Field("flyCamEnabled").GetValue()) { if ((int)SCamPlus.currentBehaviour <= 6) { //SCamPlus.sCamTraverse.Method("SetupFlybyPosition").GetValue(); SCamPlus.sCamTraverse.Field("behavior").SetValue((int)SCamPlus.currentBehaviour);//we can only update this value to be within the range the game normally expects, or it causes issues when loading saves __instance.EnableCamera(); } else { __instance.flybyCam.cullingMask = SCamPlus.normalBitmask; __instance.cameraModel.SetActive(false); SCamPlus.cameraModes[(int)SCamPlus.currentBehaviour - 7].Start(__instance); } } return(false); }
public static bool Prefix(FlybyCameraMFDPage __instance) { SCamPlus.UpdateBehaviourText(__instance); return(false); }
public static void Postfix(FlybyCameraMFDPage __instance) { if (SCamPlus.upType == SCamPlus.UpType.Stock) { return; } else { __instance.flybyCam.transform.LookAt(__instance.flybyCam.transform.position + __instance.flybyCam.transform.forward, SCamPlus.GetUpVector()); SCamPlus.lastUp = __instance.flybyCam.transform.up; } }