mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-16 16:15:24 +00:00
Raft: wait until has authority before actually pushing the raft
This commit is contained in:
parent
09d7d63774
commit
36f73ff25c
33
QSB/EchoesOfTheEye/RaftSync/Patches/RaftPatches.cs
Normal file
33
QSB/EchoesOfTheEye/RaftSync/Patches/RaftPatches.cs
Normal file
@ -0,0 +1,33 @@
|
||||
using HarmonyLib;
|
||||
using QSB.AuthoritySync;
|
||||
using QSB.EchoesOfTheEye.RaftSync.WorldObjects;
|
||||
using QSB.Patches;
|
||||
using QSB.Utility;
|
||||
using QSB.WorldSync;
|
||||
using UnityEngine;
|
||||
|
||||
namespace QSB.EchoesOfTheEye.RaftSync.Patches;
|
||||
|
||||
public class RaftPatches : QSBPatch
|
||||
{
|
||||
public override QSBPatchTypes Type => QSBPatchTypes.OnClientConnect;
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(RaftController), nameof(RaftController.OnPressInteract))]
|
||||
private static bool OnPressInteract(RaftController __instance)
|
||||
{
|
||||
__instance._interactReceiver.SetInteractionEnabled(false);
|
||||
|
||||
var qsbRaft = __instance.GetWorldObject<QSBRaft>();
|
||||
qsbRaft.TransformSync.netIdentity.UpdateAuthQueue(AuthQueueAction.Force);
|
||||
Delay.RunWhen(() => qsbRaft.TransformSync.hasAuthority, () =>
|
||||
{
|
||||
var normalized = Vector3.ProjectOnPlane(Locator.GetPlayerCamera().transform.forward, __instance.transform.up).normalized;
|
||||
__instance._raftBody.AddVelocityChange(normalized * 5f);
|
||||
__instance._effectsController.PlayRaftPush();
|
||||
__instance._pushTime = Time.time;
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
using Cysharp.Threading.Tasks;
|
||||
using Mirror;
|
||||
using QSB.AuthoritySync;
|
||||
using QSB.EchoesOfTheEye.RaftSync.TransformSync;
|
||||
using QSB.Utility;
|
||||
using QSB.WorldSync;
|
||||
@ -23,8 +22,6 @@ public class QSBRaft : WorldObject<RaftController>
|
||||
}
|
||||
|
||||
await UniTask.WaitUntil(() => TransformSync, cancellationToken: ct);
|
||||
|
||||
AttachedObject._interactReceiver.OnPressInteract += OnPressInteract;
|
||||
}
|
||||
|
||||
public override void OnRemoval()
|
||||
@ -33,15 +30,10 @@ public class QSBRaft : WorldObject<RaftController>
|
||||
{
|
||||
NetworkServer.Destroy(TransformSync.gameObject);
|
||||
}
|
||||
|
||||
AttachedObject._interactReceiver.OnPressInteract -= OnPressInteract;
|
||||
}
|
||||
|
||||
public override void SendInitialState(uint to)
|
||||
{
|
||||
// todo?? SendInitialState
|
||||
}
|
||||
|
||||
private void OnPressInteract() =>
|
||||
TransformSync.netIdentity.UpdateAuthQueue(AuthQueueAction.Force);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user