mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-02-21 18:40:03 +00:00
Actually fix initial model ship position (I think)
This commit is contained in:
parent
8d0ed3c815
commit
fe9624ed90
@ -1,6 +1,7 @@
|
||||
using QSB.AuthoritySync;
|
||||
using QSB.Messaging;
|
||||
using QSB.ModelShip.TransformSync;
|
||||
using QSB.Patches;
|
||||
using QSB.Player;
|
||||
using QSB.Player.TransformSync;
|
||||
using QSB.Utility;
|
||||
@ -26,31 +27,10 @@ internal class UseFlightConsoleMessage : QSBMessage<bool>
|
||||
|
||||
private UseFlightConsoleMessage(bool active) : base(active) { }
|
||||
|
||||
public override void OnReceiveLocal()
|
||||
{
|
||||
ModelShipManager.Instance.CurrentFlyer = Data
|
||||
? From
|
||||
: uint.MaxValue;
|
||||
|
||||
if (QSBCore.IsHost)
|
||||
{
|
||||
ModelShipTransformSync.LocalInstance.netIdentity.SetAuthority(Data
|
||||
? From
|
||||
: QSBPlayerManager.LocalPlayerId);
|
||||
}
|
||||
|
||||
// Client messes up its position when they start flying it
|
||||
// We can just recall it immediately so its in the right place.
|
||||
var console = QSBWorldSync.GetUnityObject<RemoteFlightConsole>();
|
||||
console.RespawnModelShip(false);
|
||||
}
|
||||
public override void OnReceiveLocal() => SetCurrentFlyer(From, Data);
|
||||
|
||||
public override void OnReceiveRemote()
|
||||
{
|
||||
ModelShipManager.Instance.CurrentFlyer = Data
|
||||
? From
|
||||
: uint.MaxValue;
|
||||
|
||||
var console = QSBWorldSync.GetUnityObject<RemoteFlightConsole>();
|
||||
|
||||
if (Data)
|
||||
@ -76,11 +56,25 @@ internal class UseFlightConsoleMessage : QSBMessage<bool>
|
||||
QSBWorldSync.GetUnityObject<ModelShipController>()._detector.SetActive(Data);
|
||||
QSBWorldSync.GetUnityObjects<ModelShipLandingSpot>().ForEach(x => x._owCollider.SetActivation(Data));
|
||||
|
||||
SetCurrentFlyer(From, Data);
|
||||
}
|
||||
|
||||
private void SetCurrentFlyer(uint flyer, bool isFlying)
|
||||
{
|
||||
ModelShipManager.Instance.CurrentFlyer = isFlying
|
||||
? flyer
|
||||
: uint.MaxValue;
|
||||
|
||||
if (QSBCore.IsHost)
|
||||
{
|
||||
ModelShipTransformSync.LocalInstance.netIdentity.SetAuthority(Data
|
||||
? From
|
||||
: QSBPlayerManager.LocalPlayerId);
|
||||
ModelShipTransformSync.LocalInstance.netIdentity.SetAuthority(isFlying
|
||||
? flyer
|
||||
: QSBPlayerManager.LocalPlayerId); // Host gets authority when its not in use
|
||||
}
|
||||
|
||||
// Client messes up its position when they start flying it
|
||||
// We can just recall it immediately so its in the right place.
|
||||
var console = QSBWorldSync.GetUnityObject<RemoteFlightConsole>();
|
||||
QSBPatch.RemoteCall(() => console.RespawnModelShip(false));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user