quantum-space-buddies/QSB/EchoesOfTheEye/RaftSync/Patches/RaftPatches.cs

41 lines
1.4 KiB
C#
Raw Normal View History

using HarmonyLib;
using QSB.AuthoritySync;
2022-02-27 21:07:42 +00:00
using QSB.EchoesOfTheEye.RaftSync.Messages;
using QSB.EchoesOfTheEye.RaftSync.WorldObjects;
2022-02-27 21:07:42 +00:00
using QSB.Messaging;
using QSB.Patches;
using QSB.Utility;
using QSB.WorldSync;
using UnityEngine;
2022-03-03 03:46:33 +00:00
namespace QSB.EchoesOfTheEye.RaftSync.Patches;
public class RaftPatches : QSBPatch
{
2022-03-03 03:46:33 +00:00
public override QSBPatchTypes Type => QSBPatchTypes.OnClientConnect;
[HarmonyPrefix]
[HarmonyPatch(typeof(RaftController), nameof(RaftController.OnPressInteract))]
2022-03-11 14:40:00 +00:00
private static bool RaftController_OnPressInteract(RaftController __instance)
{
2022-03-03 03:46:33 +00:00
__instance._interactReceiver.SetInteractionEnabled(false);
2022-03-03 03:46:33 +00:00
var qsbRaft = __instance.GetWorldObject<QSBRaft>();
qsbRaft.TransformSync.netIdentity.UpdateAuthQueue(AuthQueueAction.Force);
Delay.RunWhen(() => qsbRaft.TransformSync.hasAuthority, () =>
{
2022-03-03 03:46:33 +00:00
var normalized = Vector3.ProjectOnPlane(Locator.GetPlayerCamera().transform.forward, __instance.transform.up).normalized;
__instance._raftBody.AddVelocityChange(normalized * 5f);
__instance._effectsController.PlayRaftPush();
__instance._pushTime = Time.time;
});
2022-03-03 03:46:33 +00:00
return false;
}
2022-02-27 21:07:42 +00:00
[HarmonyPostfix]
2022-03-03 03:46:33 +00:00
[HarmonyPatch(typeof(RaftDock), nameof(RaftDock.OnPressInteract))]
2022-03-11 14:40:00 +00:00
private static void RaftDock_OnPressInteract(RaftDock __instance) =>
__instance.GetWorldObject<QSBRaftDock>().SendMessage(new RaftDockOnPressInteractMessage());
}