private void Update() { TechType tankSlot = Inventory.main.equipment.GetTechTypeInSlot("Tank"); if (Player.main.IsSwimming() && GameModeUtils.RequiresOxygen()) { float playerDepth = Ocean.main.GetDepthOf(Player.main.gameObject); if ((tankSlot == O2TanksCore.PhotosynthesisSmallID || tankSlot == O2TanksCore.PhotosynthesisTankID) && playerDepth < 200f) { if (cachedDayNight == null) // Safety check { cachedDayNight = DayNightCycle.main; return; } float lightScalar = cachedDayNight.GetLocalLightScalar(); if (lightScalar > 0.9f) { lightScalar = 0.9f; } float percentage = (200f - playerDepth) / 200f; cachedOxygenManager.AddOxygen(Time.deltaTime * lightScalar * percentage); } if (tankSlot == O2TanksCore.ChemosynthesisTankID) { if (cachedTemp == null) // Safety check { cachedTemp = WaterTemperatureSimulation.main; return; } else { float waterTemp = cachedTemp.GetTemperature(Player.main.transform.position); if (waterTemp > 30f) { float oxygenAdded = waterTemp * Time.deltaTime * .01f; cachedOxygenManager.AddOxygen(oxygenAdded); } } } } }
public void Update() { if (shouldReplenish == false) { return; } OxygenManager oxygen = Player.main.oxygenMgr; oxygen.AddOxygen(Time.deltaTime * OxygenPerSecond); }
public static void Postfix(OxygenManager __instance) { __instance.AddOxygen(Time.deltaTime); }
public static bool Prefix(MainCameraControl __instance) { var mainCam = MainCameraControl.main; //var cameraToPlayerMan = CameraToPlayerManager.main; bool inVehicleNow = (Player.main.IsPilotingSeatruck() || Player.main.inExosuit); if (isInVehicle) { if (inVehicleNow) { // do nothing } else { isInVehicle = false; } } else { if (inVehicleNow) { isInVehicle = true; isNewlyInVehicle = true; } else { // do nothing } } if (!inVehicleNow) { if (releaseFlag) { cameraRelinquish(); releaseFlag = false; } return(true); } releaseFlag = true; if (isNewlyInVehicle) { isNewlyInVehicle = false; //BasicText message = new BasicText(); //message.ShowMessage("This Message Will Fade In 10 Seconds", 10); } if (Player.main.motorMode == Player.MotorMode.Seaglide) { // hack the controls } bool triggerState = (Input.GetAxisRaw("ControllerAxis3") > 0) || (Input.GetAxisRaw("ControllerAxis3") < 0); if (isTriggerDown) { if (triggerState) { //do nothing } else { isTriggerDown = false; isTriggerNewlyUp = true; } } else { if (triggerState) { isTriggerDown = true; isTriggerNewlyDown = true; } else { //do nothing } } void cameraRelinquish() { mainCam.ResetCamera(); mainCam.cinematicMode = false; mainCam.lookAroundMode = true; FreeLookPatcher.isFreeLooking = false; } if (Input.GetKeyDown(FreeLookPatcher.Config.FreeLookKey) || isTriggerNewlyDown) { Debug.Log("FreeLook: button pressed. Taking control of the camera."); FreeLookPatcher.isFreeLooking = true; isTriggerNewlyDown = false; resetCameraFlag = false; // invoke a camera vulnerability mainCam.cinematicMode = true; mainCam.lookAroundMode = false; return(false); } else if (Input.GetKeyUp(FreeLookPatcher.Config.FreeLookKey) || isTriggerNewlyUp) { isTriggerNewlyUp = false; Debug.Log("FreeLook: button released. Relinquishing control of the camera."); resetCameraFlag = true; } if (!resetCameraFlag && (Input.GetKey(FreeLookPatcher.Config.FreeLookKey) || isTriggerDown)) { resetCameraFlag = false; moveCamera(); // adding oxygen is something vehicle.update would usually do, // so we do it naively here as well. // I'm not sure that Time.deltaTime seconds worth of oxygen per frame is the right amount... OxygenManager oxygenMgr = Player.main.oxygenMgr; oxygenMgr.AddOxygen(Time.deltaTime); return(false); } if (resetCameraFlag) { mainCam.rotationX = Mathf.SmoothDampAngle(mainCam.rotationX, 0f, ref xVelocity, smoothTime); mainCam.rotationY = Mathf.SmoothDampAngle(mainCam.rotationY, 0f, ref yVelocity, smoothTime); mainCam.camRotationX = mainCam.rotationX; mainCam.camRotationY = mainCam.rotationY; mainCam.transform.localEulerAngles = new Vector3(-mainCam.camRotationY, mainCam.camRotationX, 0); double threshold = 1; if (Mathf.Abs(mainCam.camRotationX) < threshold && Mathf.Abs(mainCam.camRotationY) < threshold) { cameraRelinquish(); resetCameraFlag = false; } // need to retain control in order to finish snapping back to center return(false); } // nothing from the key and the camera has been reset, so we don't need control //cameraRelinquish(); return(true); }
public static bool Prefix(Vehicle __instance) { var mainCam = MainCameraControl.main; //var cameraToPlayerMan = CameraToPlayerManager.main; bool inVehicleNow = (Player.main.inSeamoth || Player.main.inExosuit); if (isInVehicle) { if (inVehicleNow) { // do nothing } else { isInVehicle = false; } } else { if (inVehicleNow) { isInVehicle = true; isNewlyInVehicle = true; } else { // do nothing } } if (!inVehicleNow) { if (releaseFlag) { cameraRelinquish(); releaseFlag = false; } return(true); } releaseFlag = true; if (isNewlyInVehicle) { isNewlyInVehicle = false; //BasicText message = new BasicText(); //message.ShowMessage("This Message Will Fade In 10 Seconds", 10); } if (Player.main.motorMode == Player.MotorMode.Seaglide) { // hack the controls } bool triggerState = (Input.GetAxisRaw("ControllerAxis3") > 0) || (Input.GetAxisRaw("ControllerAxis3") < 0); if (isTriggerDown) { if (triggerState) { //do nothing } else { isTriggerDown = false; isTriggerNewlyUp = true; } } else { if (triggerState) { isTriggerDown = true; isTriggerNewlyDown = true; } else { //do nothing } } // add locomotion back in if ((Input.GetKey(Options.freeLookKey) || isTriggerDown) && __instance == Player.main.currentMountedVehicle)// and we're using controller) { Vector3 myDirection = Vector3.zero; myDirection.z = Input.GetAxis("ControllerAxis1"); myDirection.x = -Input.GetAxis("ControllerAxis2"); myDirection.y = GameInput.GetButtonHeld(GameInput.Button.MoveUp) ? (GameInput.GetButtonHeld(GameInput.Button.MoveDown) ? 0 : 1) : (GameInput.GetButtonHeld(GameInput.Button.MoveDown) ? -1 : 0); Vector3 myModDir = __instance.transform.forward * myDirection.x + __instance.transform.right * myDirection.z + __instance.transform.up * myDirection.y; myModDir = Vector3.Normalize(myModDir); __instance.GetComponent <Rigidbody>().velocity += myModDir * Time.deltaTime * 10f; __instance.GetComponent <Rigidbody>().velocity = Vector3.ClampMagnitude(__instance.GetComponent <Rigidbody>().velocity, 10f); } void cameraRelinquish() { mainCam.ResetCamera(); mainCam.cinematicMode = false; mainCam.lookAroundMode = true; VehicleAwakePatch.myFreeMan.isFreeLooking = false; } if (Input.GetKeyDown(Options.freeLookKey) || isTriggerNewlyDown) { Debug.Log("FreeLook: button pressed. Taking control of the camera."); VehicleAwakePatch.myFreeMan.isFreeLooking = true; isTriggerNewlyDown = false; resetCameraFlag = false; // invoke a camera vulnerability mainCam.cinematicMode = true; mainCam.lookAroundMode = false; return(false); } else if (Input.GetKeyUp(Options.freeLookKey) || isTriggerNewlyUp) { isTriggerNewlyUp = false; Debug.Log("FreeLook: button released. Relinquishing control of the camera."); resetCameraFlag = true; } if (!resetCameraFlag && (Input.GetKey(Options.freeLookKey) || isTriggerDown)) { resetCameraFlag = false; moveCamera(Player.main.currentMountedVehicle); // adding oxygen is something vehicle.update would usually do, // so we do it naively here as well. // I'm not sure that Time.deltaTime seconds worth of oxygen per frame is the right amount... OxygenManager oxygenMgr = Player.main.oxygenMgr; oxygenMgr.AddOxygen(Time.deltaTime); return(false); } if (resetCameraFlag) { mainCam.rotationX = Mathf.SmoothDampAngle(mainCam.rotationX, 0f, ref xVelocity, smoothTime); mainCam.rotationY = Mathf.SmoothDampAngle(mainCam.rotationY, 0f, ref yVelocity, smoothTime); mainCam.camRotationX = mainCam.rotationX; mainCam.camRotationY = mainCam.rotationY; mainCam.cameraOffsetTransform.localEulerAngles = new Vector3(-mainCam.camRotationY, mainCam.camRotationX, 0); double threshold = 1; if (Mathf.Abs(mainCam.camRotationX) < threshold && Mathf.Abs(mainCam.camRotationY) < threshold) { cameraRelinquish(); resetCameraFlag = false; } // need to retain control in order to finish snapping back to center return(false); } // nothing from the key and the camera has been reset, so we don't need control //cameraRelinquish(); return(true); }