Skip to content

Commit

Permalink
Merge pull request #587 from misternebula/dev
Browse files Browse the repository at this point in the history
0.24.0
  • Loading branch information
misternebula authored Dec 31, 2022
2 parents c19536e + a93dc99 commit b0fcefe
Show file tree
Hide file tree
Showing 28 changed files with 555 additions and 188 deletions.
2 changes: 1 addition & 1 deletion EpicRerouter/EpicRerouter.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="OuterWildsGameLibs" Version="1.1.13.393" IncludeAssets="compile" />
<PackageReference Include="OWML" Version="2.7.0" IncludeAssets="compile" />
<PackageReference Include="OWML" Version="2.9.0" IncludeAssets="compile" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion MirrorWeaver/MirrorWeaver.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="OuterWildsGameLibs" Version="1.1.13.393" />
<PackageReference Include="OWML" Version="2.7.0" />
<PackageReference Include="OWML" Version="2.9.0" />
<Reference Include="../Mirror/*.dll" />
</ItemGroup>
</Project>
11 changes: 10 additions & 1 deletion QSB/Animation/NPC/Patches/SolanumPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ public class SolanumPatches : QSBPatch
[HarmonyPatch(typeof(SolanumAnimController), nameof(SolanumAnimController.LateUpdate))]
public static bool SolanumLateUpdateReplacement(SolanumAnimController __instance)
{
if (!QSBWorldSync.AllObjectsReady)
{
return true;
}

if (__instance._animatorStateEvents == null)
{
__instance._animatorStateEvents = __instance._animator.GetBehaviour<AnimatorStateEvents>();
Expand All @@ -43,6 +48,10 @@ public static bool SolanumLateUpdateReplacement(SolanumAnimController __instance
[HarmonyPatch(typeof(NomaiConversationManager), nameof(NomaiConversationManager.Update))]
public static bool ReplacementUpdate(NomaiConversationManager __instance)
{
if (!QSBWorldSync.AllObjectsReady)
{
return true;
}
var qsbObj = __instance._solanumAnimController.GetWorldObject<QSBSolanumAnimController>();
__instance._playerInWatchVolume = qsbObj.Trigger.Occupants.Any();

Expand Down Expand Up @@ -206,4 +215,4 @@ public static bool ReplacementUpdate(NomaiConversationManager __instance)

return false;
}
}
}
182 changes: 86 additions & 96 deletions QSB/DeathSync/Patches/DeathPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
using QSB.Messaging;
using QSB.Patches;
using QSB.Player;
using QSB.Utility;
using System.Linq;
using UnityEngine;
using UnityEngine.UI;

namespace QSB.DeathSync.Patches;

Expand Down Expand Up @@ -61,134 +63,122 @@ public static bool HighSpeedImpactSensor_HandlePlayerInsideShip(HighSpeedImpactS
}

[HarmonyPrefix]
[HarmonyPatch(typeof(DeathManager), nameof(DeathManager.KillPlayer))]
private static bool DeathManager_KillPlayer(DeathManager __instance, DeathType deathType)
[HarmonyPatch(typeof(DeathManager), nameof(DeathManager.FinishDeathSequence))]
public static bool FinishDeathSequence(DeathManager __instance)
{
// funny moment for eye
if (QSBSceneManager.CurrentScene != OWScene.SolarSystem)
if (!__instance._isDead)
{
return true;
}

Original(__instance, deathType);
return false;

static void Original(DeathManager @this, DeathType deathType)
{
@this._fakeMeditationDeath = false;
if (deathType == DeathType.Meditation && @this.CheckShouldWakeInDreamWorld())
{
@this._fakeMeditationDeath = true;
OWInput.ChangeInputMode(InputMode.None);
ReticleController.Hide();
Locator.GetPromptManager().SetPromptsVisible(false);
GlobalMessenger.FireEvent("FakePlayerMeditationDeath");
return;
}

if (deathType == DeathType.DreamExplosion)
if (__instance.CheckShouldWakeInDreamWorld())
{
Achievements.Earn(Achievements.Type.EARLY_ADOPTER);
__instance.enabled = true;
__instance._resurrectAfterDelay = true;
__instance._resurrectTime = Time.time + 2f;
return false;
}

if (PlayerState.InDreamWorld() && deathType != DeathType.Dream && deathType != DeathType.DreamExplosion && deathType != DeathType.Supernova && deathType != DeathType.TimeLoop && deathType != DeathType.Meditation)
var deadPlayersCount = QSBPlayerManager.PlayerList.Count(x => x.IsDead);
if (deadPlayersCount == QSBPlayerManager.PlayerList.Count - 1 && !QSBCore.DebugSettings.DisableLoopDeath)
{
Locator.GetDreamWorldController().ExitDreamWorld(deathType);
return;
new EndLoopMessage().Send();
DebugLog.DebugWrite($"- All players are dead.");
}

if (!@this._isDying)
else if (!RespawnOnDeath.Instance.AllowedDeathTypes.Contains(__instance._deathType))
{
if (@this._invincible && deathType != DeathType.Supernova && deathType != DeathType.BigBang && deathType != DeathType.Meditation && deathType != DeathType.TimeLoop && deathType != DeathType.BlackHole)
RespawnOnDeath.Instance.ResetPlayer();
QSBPlayerManager.LocalPlayer.IsDead = true;
new PlayerDeathMessage(__instance._deathType).Send();
if (PlayerAttachWatcher.Current)
{
return;
PlayerAttachWatcher.Current.DetachPlayer();
}

if (!Custom(@this, deathType))
{
return;
}

if (!TimeLoopCoreController.ParadoxExists())
{
var component = Locator.GetPlayerBody().GetComponent<PlayerResources>();
if ((deathType == DeathType.TimeLoop || deathType == DeathType.Supernova) && component.GetTotalDamageThisLoop() > 1000f)
{
Achievements.Earn(Achievements.Type.DIEHARD);
PlayerData.SetPersistentCondition("THERE_IS_BUT_VOID", true);
}

if (((TimeLoop.GetLoopCount() != 1 && TimeLoop.GetSecondsElapsed() < 60f) || (TimeLoop.GetLoopCount() == 1 && Time.timeSinceLevelLoad < 60f && !TimeLoop.IsTimeFlowing())) && deathType != DeathType.Meditation && LoadManager.GetCurrentScene() == OWScene.SolarSystem)
{
Achievements.Earn(Achievements.Type.GONE_IN_60_SECONDS);
}

if (TimeLoop.GetLoopCount() > 1)
{
Achievements.SetHeroStat(Achievements.HeroStat.TIMELOOP_COUNT, (uint)(TimeLoop.GetLoopCount() - 1));
if (deathType == DeathType.TimeLoop || deathType == DeathType.BigBang || deathType == DeathType.Supernova)
{
PlayerData.CompletedFullTimeLoop();
}
}

if (deathType == DeathType.Supernova && !PlayerData.GetPersistentCondition("KILLED_BY_SUPERNOVA_AND_KNOWS_IT") && PlayerData.GetFullTimeLoopsCompleted() > 2U && PlayerData.GetPersistentCondition("HAS_SEEN_SUN_EXPLODE"))
{
PlayerData.SetPersistentCondition("KILLED_BY_SUPERNOVA_AND_KNOWS_IT", true);
MonoBehaviour.print("KILLED_BY_SUPERNOVA_AND_KNOWS_IT");
}
}

@this._isDying = true;
@this._deathType = deathType;
MonoBehaviour.print("Player was killed by " + deathType);
Locator.GetPauseCommandListener().AddPauseCommandLock();
PlayerData.SetLastDeathType(deathType);
GlobalMessenger<DeathType>.FireEvent("PlayerDeath", deathType);
return false;
}
}

static bool Custom(DeathManager @this, DeathType deathType)
{
if (RespawnOnDeath.Instance == null)
__instance._isDead = true;
GlobalMessenger.FireEvent("DeathSequenceComplete");
if (PlayerData.GetPersistentCondition("DESTROYED_TIMELINE_LAST_SAVE"))
{
return true;
PlayerData.SetPersistentCondition("DESTROYED_TIMELINE_LAST_SAVE", false);
}

if (RespawnOnDeath.Instance.AllowedDeathTypes.Contains(deathType))
if (__instance._deathType == DeathType.BigBang)
{
return true;
if (TimeLoopCoreController.ParadoxExists())
{
PlayerData.RevertParadoxLoopCountStates();
}

LoadManager.LoadScene(OWScene.Credits_Final, LoadManager.FadeType.ToWhite, 1f, true);
return false;
}

if (@this.CheckShouldWakeInDreamWorld())
if (TimeLoopCoreController.ParadoxExists())
{
return true;
Locator.GetTimelineObliterationController().BeginTimelineObliteration(TimelineObliterationController.ObliterationType.PARADOX_DEATH, null);
return false;
}

if (QSBPlayerManager.LocalPlayer.IsDead)
if (TimeLoop.IsTimeFlowing() && TimeLoop.IsTimeLoopEnabled())
{
if (__instance._finishedDLC)
{
GlobalMessenger.FireEvent("TriggerEndOfDLC");
return false;
}
GlobalMessenger.FireEvent("TriggerFlashback");
return false;
}

var deadPlayersCount = QSBPlayerManager.PlayerList.Count(x => x.IsDead);
if (deadPlayersCount == QSBPlayerManager.PlayerList.Count - 1)
else
{
new EndLoopMessage().Send();
return true;
if (__instance._deathType == DeathType.Meditation && PlayerState.OnQuantumMoon() && Locator.GetQuantumMoon().GetStateIndex() == 5)
{
__instance._timeloopEscapeType = TimeloopEscapeType.Quantum;
__instance.FinishEscapeTimeLoopSequence();
return false;
}
GlobalMessenger.FireEvent("TriggerDeathOutsideTimeLoop");
}
}

RespawnOnDeath.Instance.ResetPlayer();
return false;
}

QSBPlayerManager.LocalPlayer.IsDead = true;
new PlayerDeathMessage(deathType).Send();
[HarmonyPrefix]
[HarmonyPatch(typeof(PauseMenuManager), nameof(PauseMenuManager.Update))]
public static bool PauseMenuManager_Update(PauseMenuManager __instance)
{
// disable meditate button when in respawn map

if (PlayerAttachWatcher.Current)
{
PlayerAttachWatcher.Current.DetachPlayer();
}
if (__instance._waitingToApplySkipLoopStyle)
{
var disableMeditate = PlayerState.IsSleepingAtCampfire() || PlayerState.IsGrabbedByGhost() || QSBPlayerManager.LocalPlayer.IsDead;
__instance._skipToNextLoopButton.GetComponent<UIStyleApplier>().ChangeState(disableMeditate ? UIElementState.DISABLED : UIElementState.NORMAL, false);
__instance._waitingToApplySkipLoopStyle = false;
}

return false;
if (OWInput.IsNewlyPressed(InputLibrary.pause, InputMode.All) && __instance._isOpen && MenuStackManager.SharedInstance.GetMenuCount() == 1)
{
__instance._pauseMenu.EnableMenu(false);
}

return false;
}

[HarmonyPrefix]
[HarmonyPatch(typeof(PauseMenuManager), nameof(PauseMenuManager.OnActivateMenu))]
public static bool PauseMenuManager_OnActivateMenu(PauseMenuManager __instance)
{
if (__instance._skipToNextLoopButton.activeSelf)
{
bool flag = !PlayerState.IsSleepingAtCampfire() && !PlayerState.IsGrabbedByGhost() && !QSBPlayerManager.LocalPlayer.IsDead;
__instance._endCurrentLoopAction.enabled = flag;
__instance._skipToNextLoopButton.GetComponent<Selectable>().interactable = flag;
__instance._skipToNextLoopButton.GetComponent<UIStyleApplier>().SetAutoInputStateChangesEnabled(flag);
__instance._waitingToApplySkipLoopStyle = true;
}

return false;
}

[HarmonyPrefix]
Expand Down
Loading

0 comments on commit b0fcefe

Please sign in to comment.