Add OnModStart patch type, fix funny collision bug with AvoidTimeSync

This commit is contained in:
Mister_Nebula 2022-03-11 10:21:27 +00:00
parent 99cf46a23f
commit bf8b1530cd
5 changed files with 18 additions and 21 deletions

View File

@ -24,21 +24,10 @@ public static class QSBPatchManager
_patchList.Add((QSBPatch)Activator.CreateInstance(type)); _patchList.Add((QSBPatch)Activator.CreateInstance(type));
} }
TypeToInstance = new Dictionary<QSBPatchTypes, Harmony> foreach (QSBPatchTypes type in Enum.GetValues(typeof(QSBPatchTypes)))
{ {
{ TypeToInstance.Add(type, new Harmony(type.ToString()));
QSBPatchTypes.OnClientConnect, new Harmony("QSB.Client") }
},
{
QSBPatchTypes.OnServerClientConnect, new Harmony("QSB.Server")
},
{
QSBPatchTypes.OnNonServerClientConnect, new Harmony("QSB.NonServer")
},
{
QSBPatchTypes.RespawnTime, new Harmony("QSB.Death")
}
};
DebugLog.DebugWrite("Patch Manager ready.", MessageType.Success); DebugLog.DebugWrite("Patch Manager ready.", MessageType.Success);
} }

View File

@ -5,5 +5,6 @@ public enum QSBPatchTypes
OnClientConnect, OnClientConnect,
OnNonServerClientConnect, OnNonServerClientConnect,
OnServerClientConnect, OnServerClientConnect,
RespawnTime RespawnTime,
OnModStart
} }

View File

@ -108,6 +108,8 @@ public class QSBCore : ModBehaviour
QSBWorldSync.Managers = components.OfType<WorldObjectManager>().ToArray(); QSBWorldSync.Managers = components.OfType<WorldObjectManager>().ToArray();
QSBPatchManager.OnPatchType += OnPatchType; QSBPatchManager.OnPatchType += OnPatchType;
QSBPatchManager.OnUnpatchType += OnUnpatchType; QSBPatchManager.OnUnpatchType += OnUnpatchType;
QSBPatchManager.DoPatchType(QSBPatchTypes.OnModStart);
} }
private static void OnPatchType(QSBPatchTypes type) private static void OnPatchType(QSBPatchTypes type)

View File

@ -1,4 +1,5 @@
using HarmonyLib; using HarmonyLib;
using QSB.Patches;
using QSB.Utility; using QSB.Utility;
using UnityEngine; using UnityEngine;
@ -8,13 +9,9 @@ namespace QSB;
/// TODO: remove this when the bug is fixed in vanilla /// TODO: remove this when the bug is fixed in vanilla
/// </summary> /// </summary>
[HarmonyPatch(typeof(StreamingGroup))] [HarmonyPatch(typeof(StreamingGroup))]
internal class TEMP_ShipBugFix : MonoBehaviour, IAddComponentOnStart internal class TEMP_ShipBugFix : QSBPatch
{ {
private void Awake() public override QSBPatchTypes Type => QSBPatchTypes.OnModStart;
{
Harmony.CreateAndPatchAll(typeof(TEMP_ShipBugFix));
Destroy(this);
}
[HarmonyPrefix] [HarmonyPrefix]
[HarmonyPatch(nameof(StreamingGroup.LoadRequiredColliders))] [HarmonyPatch(nameof(StreamingGroup.LoadRequiredColliders))]

View File

@ -9,6 +9,7 @@ using QSB.Player;
using QSB.Player.Messages; using QSB.Player.Messages;
using QSB.TimeSync.Messages; using QSB.TimeSync.Messages;
using QSB.Utility; using QSB.Utility;
using QSB.WorldSync;
using System; using System;
using UnityEngine; using UnityEngine;
@ -126,6 +127,13 @@ public class WakeUpSync : NetworkBehaviour
{ {
WakeUpOrSleep(); WakeUpOrSleep();
} }
else
{
if (!_hasWokenUp)
{
Delay.RunWhen(() => QSBWorldSync.AllObjectsReady, WakeUp);
}
}
} }
} }