mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2024-12-29 03:28:26 +00:00
(UNTESTED) move exit dream world stuff to ResetPlayer
This commit is contained in:
parent
a35d1a18e9
commit
b0fad4a6d1
@ -62,91 +62,6 @@ public class DeathPatches : QSBPatch
|
||||
return false;
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(DeathManager), nameof(DeathManager.KillPlayer))]
|
||||
public static bool KillPlayer(DeathManager __instance, DeathType deathType)
|
||||
{
|
||||
if (deathType == DeathType.Meditation && __instance.CheckShouldWakeInDreamWorld())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (PlayerState.InDreamWorld() && (deathType == DeathType.Meditation || deathType == DeathType.DreamExplosion))
|
||||
{
|
||||
// BUG : this makes things look broken for a second after meditating in
|
||||
// the dreamworld, because we remove the player from all sectors
|
||||
CustomExitDreamWorld(DreamWakeType.Default);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(DreamWorldController), nameof(DreamWorldController.ExitDreamWorld), typeof(DreamWakeType))]
|
||||
private static void ExitDreamWorld(DreamWorldController __instance, DreamWakeType wakeType = DreamWakeType.Default)
|
||||
{
|
||||
var deadPlayersCount = QSBPlayerManager.PlayerList.Count(x => x.IsDead);
|
||||
if ((deadPlayersCount != QSBPlayerManager.PlayerList.Count - 1 || QSBCore.DebugSettings.DisableLoopDeath) && PlayerState.IsResurrected())
|
||||
{
|
||||
CustomExitDreamWorld(wakeType);
|
||||
}
|
||||
}
|
||||
|
||||
private static void CustomExitDreamWorld(DreamWakeType wakeType)
|
||||
{
|
||||
var __instance = Locator.GetDreamWorldController();
|
||||
|
||||
__instance._wakeType = wakeType;
|
||||
__instance.CheckDreamZone2Completion();
|
||||
__instance.CheckSleepWakeDieAchievement(wakeType);
|
||||
|
||||
__instance._activeGhostGrabController?.ReleasePlayer();
|
||||
__instance._activeZoomPoint?.CancelZoom();
|
||||
|
||||
if (__instance._outsideLanternBounds)
|
||||
{
|
||||
__instance.EnterLanternBounds();
|
||||
}
|
||||
|
||||
__instance._simulationCamera.OnExitDreamWorld();
|
||||
SunLightController.UnregisterSunOverrider(__instance);
|
||||
if (__instance._proxyShadowLight != null)
|
||||
{
|
||||
__instance._proxyShadowLight.enabled = true;
|
||||
}
|
||||
__instance._insideDream = false;
|
||||
__instance._waitingToLightLantern = false;
|
||||
__instance._playerLantern.OnExitDreamWorld();
|
||||
|
||||
// TODO : drop player lantern at campfire
|
||||
|
||||
Locator.GetPlayerSectorDetector().RemoveFromAllSectors();
|
||||
|
||||
__instance._playerLantern.OnExitDreamWorld();
|
||||
__instance._dreamArrivalPoint.OnExitDreamWorld();
|
||||
__instance._dreamCampfire.OnDreamCampfireExtinguished -= __instance.OnDreamCampfireExtinguished;
|
||||
__instance._dreamCampfire = null;
|
||||
|
||||
__instance.ExtinguishDreamRaft();
|
||||
Locator.GetAudioMixer().UnmixDreamWorld();
|
||||
Locator.GetAudioMixer().UnmixSleepAtCampfire(1f);
|
||||
|
||||
if (__instance._playerCamAmbientLightRenderer != null)
|
||||
{
|
||||
__instance._playerCamAmbientLightRenderer.enabled = false;
|
||||
}
|
||||
|
||||
__instance._playerCamera.cullingMask |= 1 << LayerMask.NameToLayer("Sun");
|
||||
__instance._playerCamera.farClipPlane = __instance._prevPlayerCameraFarPlaneDist;
|
||||
__instance._prevPlayerCameraFarPlaneDist = 0f;
|
||||
__instance._playerCamera.mainCamera.backgroundColor = Color.black;
|
||||
__instance._playerCamera.planetaryFog.enabled = true;
|
||||
__instance._playerCamera.postProcessingSettings.screenSpaceReflectionAvailable = false;
|
||||
__instance._playerCamera.postProcessingSettings.ambientOcclusionAvailable = true;
|
||||
|
||||
GlobalMessenger.FireEvent("ExitDreamWorld");
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(DeathManager), nameof(DeathManager.FinishDeathSequence))]
|
||||
public static bool FinishDeathSequence(DeathManager __instance)
|
||||
|
@ -15,7 +15,8 @@ public class RespawnOnDeath : MonoBehaviour
|
||||
{
|
||||
public static RespawnOnDeath Instance;
|
||||
|
||||
public readonly DeathType[] AllowedDeathTypes = {
|
||||
public readonly DeathType[] AllowedDeathTypes =
|
||||
{
|
||||
DeathType.BigBang,
|
||||
DeathType.Supernova,
|
||||
DeathType.TimeLoop
|
||||
@ -81,6 +82,68 @@ public class RespawnOnDeath : MonoBehaviour
|
||||
DeathClosestAstroObject = closest.transform;
|
||||
}
|
||||
|
||||
var deathPosition = Locator.GetPlayerTransform().position;
|
||||
_deathPositionRelative = DeathClosestAstroObject.InverseTransformPoint(deathPosition);
|
||||
DeathPlayerUpVector = Locator.GetPlayerTransform().up;
|
||||
DeathPlayerForwardVector = Locator.GetPlayerTransform().forward;
|
||||
|
||||
// do some exit dream world stuff since real deaths dont do that
|
||||
if (PlayerState.InDreamWorld())
|
||||
{
|
||||
var __instance = Locator.GetDreamWorldController();
|
||||
|
||||
var wakeType = DreamWakeType.Default; // TODO maybe get actual death type? idk
|
||||
__instance._wakeType = wakeType;
|
||||
__instance.CheckDreamZone2Completion();
|
||||
__instance.CheckSleepWakeDieAchievement(wakeType);
|
||||
|
||||
__instance._activeGhostGrabController?.ReleasePlayer();
|
||||
__instance._activeZoomPoint?.CancelZoom();
|
||||
|
||||
if (__instance._outsideLanternBounds)
|
||||
{
|
||||
__instance.EnterLanternBounds();
|
||||
}
|
||||
|
||||
__instance._simulationCamera.OnExitDreamWorld();
|
||||
SunLightController.UnregisterSunOverrider(__instance);
|
||||
if (__instance._proxyShadowLight != null)
|
||||
{
|
||||
__instance._proxyShadowLight.enabled = true;
|
||||
}
|
||||
__instance._insideDream = false;
|
||||
__instance._waitingToLightLantern = false;
|
||||
__instance._playerLantern.OnExitDreamWorld();
|
||||
|
||||
// TODO : drop player lantern at campfire
|
||||
|
||||
Locator.GetPlayerSectorDetector().RemoveFromAllSectors();
|
||||
|
||||
__instance._playerLantern.OnExitDreamWorld();
|
||||
__instance._dreamArrivalPoint.OnExitDreamWorld();
|
||||
__instance._dreamCampfire.OnDreamCampfireExtinguished -= __instance.OnDreamCampfireExtinguished;
|
||||
__instance._dreamCampfire = null;
|
||||
|
||||
__instance.ExtinguishDreamRaft();
|
||||
Locator.GetAudioMixer().UnmixDreamWorld();
|
||||
Locator.GetAudioMixer().UnmixSleepAtCampfire(1f);
|
||||
|
||||
if (__instance._playerCamAmbientLightRenderer != null)
|
||||
{
|
||||
__instance._playerCamAmbientLightRenderer.enabled = false;
|
||||
}
|
||||
|
||||
__instance._playerCamera.cullingMask |= 1 << LayerMask.NameToLayer("Sun");
|
||||
__instance._playerCamera.farClipPlane = __instance._prevPlayerCameraFarPlaneDist;
|
||||
__instance._prevPlayerCameraFarPlaneDist = 0f;
|
||||
__instance._playerCamera.mainCamera.backgroundColor = Color.black;
|
||||
__instance._playerCamera.planetaryFog.enabled = true;
|
||||
__instance._playerCamera.postProcessingSettings.screenSpaceReflectionAvailable = false;
|
||||
__instance._playerCamera.postProcessingSettings.ambientOcclusionAvailable = true;
|
||||
|
||||
GlobalMessenger.FireEvent("ExitDreamWorld");
|
||||
}
|
||||
|
||||
var sectorList = PlayerTransformSync.LocalInstance.SectorDetector.SectorList;
|
||||
if (sectorList.All(x => x.Type != Sector.Name.TimberHearth))
|
||||
{
|
||||
@ -89,6 +152,7 @@ public class RespawnOnDeath : MonoBehaviour
|
||||
Locator.GetPlayerCameraDetector().GetComponent<AudioDetector>().DeactivateAllVolumes(0f);
|
||||
}
|
||||
|
||||
// undo stuff that PlayerDeath event does
|
||||
var cloak = Locator.GetCloakFieldController();
|
||||
cloak._playerInsideCloak = false;
|
||||
cloak._playerCloakFactor = 0f;
|
||||
@ -144,11 +208,6 @@ public class RespawnOnDeath : MonoBehaviour
|
||||
mixer._endTimesVolume.FadeTo(1, 0.5f);
|
||||
mixer.MixMap();
|
||||
|
||||
var deathPosition = Locator.GetPlayerTransform().position;
|
||||
_deathPositionRelative = DeathClosestAstroObject.InverseTransformPoint(deathPosition);
|
||||
DeathPlayerUpVector = Locator.GetPlayerTransform().up;
|
||||
DeathPlayerForwardVector = Locator.GetPlayerTransform().forward;
|
||||
|
||||
var playerBody = Locator.GetPlayerBody();
|
||||
playerBody.WarpToPositionRotation(_playerSpawnPoint.transform.position, _playerSpawnPoint.transform.rotation);
|
||||
playerBody.SetVelocity(_playerSpawnPoint.GetPointVelocity());
|
||||
@ -220,4 +279,4 @@ public class RespawnOnDeath : MonoBehaviour
|
||||
_deadTextStyle);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user