2020-11-04 20:01:28 +00:00
|
|
|
|
using QSB.Patches;
|
|
|
|
|
using QSB.WorldSync;
|
2020-08-16 15:15:36 +00:00
|
|
|
|
using UnityEngine;
|
2020-08-13 17:25:12 +00:00
|
|
|
|
|
|
|
|
|
namespace QSB.GeyserSync
|
|
|
|
|
{
|
2020-12-02 21:23:01 +00:00
|
|
|
|
public class GeyserManager : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
private void Awake()
|
|
|
|
|
{
|
|
|
|
|
QSBSceneManager.OnSceneLoaded += OnSceneLoaded;
|
|
|
|
|
QSBPatchManager.OnPatchType += OnPatchType;
|
|
|
|
|
}
|
2020-08-13 17:25:12 +00:00
|
|
|
|
|
2020-12-02 21:23:01 +00:00
|
|
|
|
private void OnDestroy()
|
|
|
|
|
{
|
|
|
|
|
QSBSceneManager.OnSceneLoaded -= OnSceneLoaded;
|
|
|
|
|
QSBPatchManager.OnPatchType -= OnPatchType;
|
|
|
|
|
}
|
2020-11-25 09:54:52 +00:00
|
|
|
|
|
2020-12-02 21:23:01 +00:00
|
|
|
|
private void OnSceneLoaded(OWScene scene, bool isInUniverse)
|
|
|
|
|
{
|
|
|
|
|
var geyserControllers = Resources.FindObjectsOfTypeAll<GeyserController>();
|
|
|
|
|
for (var id = 0; id < geyserControllers.Length; id++)
|
|
|
|
|
{
|
2020-12-11 13:14:58 +00:00
|
|
|
|
var qsbGeyser = QSBWorldSync.GetWorldObject<QSBGeyser>(id) ?? new QSBGeyser();
|
2020-12-02 21:23:01 +00:00
|
|
|
|
qsbGeyser.Init(geyserControllers[id], id);
|
2020-12-11 13:14:58 +00:00
|
|
|
|
QSBWorldSync.AddWorldObject(qsbGeyser);
|
2020-12-02 21:23:01 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2020-08-20 18:31:10 +00:00
|
|
|
|
|
2020-12-02 21:23:01 +00:00
|
|
|
|
public void OnPatchType(QSBPatchTypes type)
|
|
|
|
|
{
|
|
|
|
|
if (type != QSBPatchTypes.OnNonServerClientConnect)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
2020-12-14 16:24:52 +00:00
|
|
|
|
QSBCore.Helper.HarmonyHelper.EmptyMethod<GeyserController>("Update");
|
2020-12-02 21:23:01 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2020-08-13 17:25:12 +00:00
|
|
|
|
}
|