quantum-space-buddies/QSB/EyeOfTheUniverse/MaskSync/Patches/MaskPatches.cs

53 lines
1.5 KiB
C#
Raw Normal View History

using HarmonyLib;
using QSB.Patches;
2022-01-15 16:22:46 +00:00
using QSB.Player;
using QSB.Utility;
using System.Linq;
using UnityEngine;
2022-03-03 03:46:33 +00:00
namespace QSB.EyeOfTheUniverse.MaskSync.Patches;
internal class MaskPatches : QSBPatch
{
2022-03-03 03:46:33 +00:00
public override QSBPatchTypes Type => QSBPatchTypes.OnClientConnect;
[HarmonyPrefix]
[HarmonyPatch(typeof(EyeShuttleController), nameof(EyeShuttleController.OnLaunchSlotActivated))]
public static bool DontLaunch(EyeShuttleController __instance)
{
2022-03-03 03:46:33 +00:00
QSBPlayerManager.PlayerList.Where(x => x.IsInEyeShuttle).ForEach(x => MaskManager.WentOnSolanumsWildRide.Add(x));
2022-03-03 03:46:33 +00:00
if (__instance._isPlayerInside)
{
2022-03-03 03:46:33 +00:00
return true;
}
2022-01-15 16:22:46 +00:00
2022-03-03 03:46:33 +00:00
MaskManager.FlickerOutShuttle();
__instance._hasLaunched = true;
__instance._hasArrivedAtMask = true;
__instance._hasPlayedOneShot = true;
__instance.enabled = false;
2022-03-03 03:46:33 +00:00
return false;
}
2022-01-15 16:22:46 +00:00
2022-03-03 03:46:33 +00:00
[HarmonyPrefix]
[HarmonyPatch(typeof(MaskZoneController), nameof(MaskZoneController.OnFinishGather))]
public static bool FinishGather(MaskZoneController __instance)
{
__instance._shuttle.OnFinishGather();
2022-01-15 16:22:46 +00:00
2022-03-03 03:46:33 +00:00
if (MaskManager.WentOnSolanumsWildRide.Contains(QSBPlayerManager.LocalPlayer))
2022-01-15 16:22:46 +00:00
{
2022-03-03 03:46:33 +00:00
Locator.GetPlayerBody().SetPosition(__instance._returnSocket.position);
Locator.GetPlayerBody().SetRotation(__instance._returnSocket.rotation);
Locator.GetPlayerBody().SetVelocity(Vector3.zero);
var component = Locator.GetPlayerCamera().GetComponent<PlayerCameraController>();
component.SetDegreesY(component.GetMinDegreesY());
}
2022-03-03 03:46:33 +00:00
__instance.enabled = false;
2022-03-03 03:46:33 +00:00
return false;
}
}