mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2024-12-29 12:21:25 +00:00
fix not being able to open map after dying
This commit is contained in:
parent
7ee8926a0a
commit
1c67801d79
@ -1,6 +1,7 @@
|
||||
using QSB.ClientServerStateSync;
|
||||
using QSB.Events;
|
||||
using QSB.Messaging;
|
||||
using QSB.Patches;
|
||||
using QSB.Utility;
|
||||
|
||||
namespace QSB.DeathSync.Events
|
||||
@ -29,6 +30,8 @@ namespace QSB.DeathSync.Events
|
||||
switch (message.EnumValue)
|
||||
{
|
||||
case EndLoopReason.AllPlayersDead:
|
||||
QSBPatchManager.DoUnpatchType(QSBPatchTypes.RespawnTime);
|
||||
|
||||
Locator.GetDeathManager().KillPlayer(DeathType.TimeLoop);
|
||||
if (QSBCore.IsHost)
|
||||
{
|
||||
|
@ -37,6 +37,7 @@ namespace QSB.Patches
|
||||
public static event Action<QSBPatchTypes> OnUnpatchType;
|
||||
|
||||
private static List<QSBPatch> _patchList = new List<QSBPatch>();
|
||||
private static List<QSBPatchTypes> _patchedTypes = new List<QSBPatchTypes>();
|
||||
|
||||
public static Dictionary<QSBPatchTypes, Harmony> TypeToInstance = new Dictionary<QSBPatchTypes, Harmony>();
|
||||
|
||||
@ -88,6 +89,12 @@ namespace QSB.Patches
|
||||
|
||||
public static void DoPatchType(QSBPatchTypes type)
|
||||
{
|
||||
if (_patchedTypes.Contains(type))
|
||||
{
|
||||
DebugLog.ToConsole($"Warning - Tried to patch type {type}, when it has already been patched!", MessageType.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
OnPatchType?.SafeInvoke(type);
|
||||
//DebugLog.DebugWrite($"Patch block {Enum.GetName(typeof(QSBPatchTypes), type)}", MessageType.Info);
|
||||
foreach (var patch in _patchList.Where(x => x.Type == type))
|
||||
@ -96,6 +103,7 @@ namespace QSB.Patches
|
||||
try
|
||||
{
|
||||
patch.DoPatches(TypeToInstance[type]);
|
||||
_patchedTypes.Add(type);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -106,9 +114,16 @@ namespace QSB.Patches
|
||||
|
||||
public static void DoUnpatchType(QSBPatchTypes type)
|
||||
{
|
||||
if (!_patchedTypes.Contains(type))
|
||||
{
|
||||
DebugLog.ToConsole($"Warning - Tried to unpatch type {type}, when it is either unpatched or was never patched.", MessageType.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
OnUnpatchType?.SafeInvoke(type);
|
||||
//DebugLog.DebugWrite($"Unpatch block {Enum.GetName(typeof(QSBPatchTypes), type)}", MessageType.Info);
|
||||
TypeToInstance[type].UnpatchSelf();
|
||||
_patchedTypes.Remove(type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user