2021-10-15 21:06:51 +01:00
|
|
|
|
using HarmonyLib;
|
2021-12-25 16:10:41 -08:00
|
|
|
|
using QSB.Messaging;
|
2021-02-28 14:43:05 +00:00
|
|
|
|
using QSB.Patches;
|
2021-03-01 09:44:36 +00:00
|
|
|
|
using QSB.Player;
|
2021-12-25 16:10:41 -08:00
|
|
|
|
using QSB.StatueSync.Messages;
|
2021-02-28 14:43:05 +00:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
namespace QSB.StatueSync.Patches;
|
|
|
|
|
|
|
|
|
|
[HarmonyPatch]
|
|
|
|
|
internal class StatuePatches : QSBPatch
|
2021-02-28 14:43:05 +00:00
|
|
|
|
{
|
2022-03-02 19:46:33 -08:00
|
|
|
|
public override QSBPatchTypes Type => QSBPatchTypes.OnClientConnect;
|
2021-06-18 22:38:32 +01:00
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
[HarmonyPrefix]
|
|
|
|
|
[HarmonyPatch(typeof(MemoryUplinkTrigger), nameof(MemoryUplinkTrigger.Update))]
|
|
|
|
|
public static bool MemoryUplinkTrigger_Update(MemoryUplinkTrigger __instance)
|
|
|
|
|
{
|
|
|
|
|
if (StatueManager.Instance.HasStartedStatueLocally)
|
2022-02-24 22:04:54 -08:00
|
|
|
|
{
|
2022-03-02 19:46:33 -08:00
|
|
|
|
return true;
|
|
|
|
|
}
|
2022-02-27 04:40:44 -08:00
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
if (!__instance._waitForPlayerGrounded || !Locator.GetPlayerController().IsGrounded())
|
|
|
|
|
{
|
2021-02-28 14:43:05 +00:00
|
|
|
|
return true;
|
|
|
|
|
}
|
2022-03-02 19:46:33 -08:00
|
|
|
|
|
|
|
|
|
var playerBody = Locator.GetPlayerBody().transform;
|
|
|
|
|
var timberHearth = Locator.GetAstroObject(AstroObject.Name.TimberHearth).transform;
|
|
|
|
|
new StartStatueMessage(
|
|
|
|
|
timberHearth.InverseTransformPoint(playerBody.position),
|
|
|
|
|
Quaternion.Inverse(timberHearth.rotation) * playerBody.rotation,
|
|
|
|
|
Locator.GetPlayerCamera().GetComponent<PlayerCameraController>().GetDegreesY()
|
|
|
|
|
).Send();
|
|
|
|
|
QSBPlayerManager.HideAllPlayers();
|
|
|
|
|
return true;
|
2021-02-28 14:43:05 +00:00
|
|
|
|
}
|
2021-12-25 16:10:41 -08:00
|
|
|
|
}
|