mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-02-20 15:41:01 +00:00
better debug teleport
This commit is contained in:
parent
efcbb6730b
commit
800d4a86bb
@ -56,22 +56,10 @@ namespace QSB.Utility
|
||||
|
||||
if (Keyboard.current[Key.Numpad1].wasPressedThisFrame)
|
||||
{
|
||||
var otherPlayer = QSBPlayerManager.PlayerList.FirstOrDefault(x => x.PlayerId != QSBPlayerManager.LocalPlayerId);
|
||||
if (otherPlayer != null && otherPlayer.Body != null)
|
||||
var otherPlayer = QSBPlayerManager.PlayerList.FirstOrDefault(x => x != QSBPlayerManager.LocalPlayer);
|
||||
if (otherPlayer != null)
|
||||
{
|
||||
var playerBody = Locator.GetPlayerBody();
|
||||
playerBody.WarpToPositionRotation(otherPlayer.Body.transform.position, otherPlayer.Body.transform.rotation);
|
||||
var parentBody = otherPlayer.TransformSync?.ReferenceSector?.AttachedObject?.GetOWRigidbody();
|
||||
if (parentBody != null)
|
||||
{
|
||||
playerBody.SetVelocity(parentBody.GetVelocity());
|
||||
playerBody.SetAngularVelocity(parentBody.GetAngularVelocity());
|
||||
}
|
||||
else
|
||||
{
|
||||
playerBody.SetVelocity(Vector3.zero);
|
||||
playerBody.SetAngularVelocity(Vector3.zero);
|
||||
}
|
||||
new DebugRequestTeleportInfoMessage(otherPlayer.PlayerId).Send();
|
||||
}
|
||||
}
|
||||
|
||||
@ -92,7 +80,7 @@ namespace QSB.Utility
|
||||
|
||||
if (Keyboard.current[Key.Numpad5].wasPressedThisFrame)
|
||||
{
|
||||
new DebugMessage(DebugMessageEnum.TriggerSupernova).Send();
|
||||
new DebugTriggerSupernovaMessage().Send();
|
||||
}
|
||||
|
||||
if (Keyboard.current[Key.Numpad7].wasPressedThisFrame)
|
||||
|
@ -73,7 +73,7 @@ namespace QSB.Utility
|
||||
return;
|
||||
}
|
||||
|
||||
QNetworkServer.SpawnWithClientAuthority(go, QSBPlayerManager.LocalPlayer.TransformSync.gameObject);
|
||||
QNetworkServer.SpawnWithClientAuthority(go, QNetworkServer.localConnection);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@ -1,21 +0,0 @@
|
||||
using QSB.Messaging;
|
||||
|
||||
namespace QSB.Utility.Messages
|
||||
{
|
||||
public class DebugMessage : QSBEnumMessage<DebugMessageEnum>
|
||||
{
|
||||
public DebugMessage(DebugMessageEnum type) => Value = type;
|
||||
|
||||
public override void OnReceiveLocal() => OnReceiveRemote();
|
||||
|
||||
public override void OnReceiveRemote()
|
||||
{
|
||||
switch (Value)
|
||||
{
|
||||
case DebugMessageEnum.TriggerSupernova:
|
||||
TimeLoop.SetSecondsRemaining(0f);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
namespace QSB.Utility.Messages
|
||||
{
|
||||
public enum DebugMessageEnum
|
||||
{
|
||||
TriggerSupernova
|
||||
}
|
||||
}
|
65
QSB/Utility/Messages/DebugTeleportInfoMessage.cs
Normal file
65
QSB/Utility/Messages/DebugTeleportInfoMessage.cs
Normal file
@ -0,0 +1,65 @@
|
||||
using QSB.Messaging;
|
||||
using QSB.Player;
|
||||
using QSB.Player.TransformSync;
|
||||
using QuantumUNET.Transport;
|
||||
using UnityEngine;
|
||||
|
||||
namespace QSB.Utility.Messages
|
||||
{
|
||||
public class DebugRequestTeleportInfoMessage : QSBMessage
|
||||
{
|
||||
public DebugRequestTeleportInfoMessage(uint to) => To = to;
|
||||
|
||||
public override void OnReceiveRemote() => new DebugTeleportInfoMessage(From).Send();
|
||||
}
|
||||
|
||||
public class DebugTeleportInfoMessage : QSBMessage
|
||||
{
|
||||
private float DegreesY;
|
||||
private Vector3 Vel;
|
||||
private Vector3 AngVel;
|
||||
|
||||
public DebugTeleportInfoMessage(uint to)
|
||||
{
|
||||
To = to;
|
||||
|
||||
var body = Locator.GetPlayerBody();
|
||||
var refBody = PlayerTransformSync.LocalInstance.ReferenceSector.AttachedObject.GetOWRigidbody();
|
||||
|
||||
DegreesY = Locator.GetPlayerCameraController().GetDegreesY();
|
||||
Vel = refBody.ToRelVel(body.GetVelocity(), body.GetPosition());
|
||||
AngVel = refBody.ToRelAngVel(body.GetAngularVelocity());
|
||||
}
|
||||
|
||||
public override void Serialize(QNetworkWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
writer.Write(DegreesY);
|
||||
writer.Write(Vel);
|
||||
writer.Write(AngVel);
|
||||
}
|
||||
|
||||
public override void Deserialize(QNetworkReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
DegreesY = reader.ReadSingle();
|
||||
Vel = reader.ReadVector3();
|
||||
AngVel = reader.ReadVector3();
|
||||
}
|
||||
|
||||
public override void OnReceiveRemote()
|
||||
{
|
||||
var otherPlayer = QSBPlayerManager.GetPlayer(From);
|
||||
|
||||
var body = Locator.GetPlayerBody();
|
||||
var refBody = otherPlayer.TransformSync.ReferenceSector.AttachedObject.GetOWRigidbody();
|
||||
|
||||
var pos = otherPlayer.Body.transform.position;
|
||||
var rot = otherPlayer.Body.transform.rotation;
|
||||
body.WarpToPositionRotation(pos, rot);
|
||||
Locator.GetPlayerCameraController().SetDegreesY(DegreesY);
|
||||
body.SetVelocity(refBody.FromRelVel(Vel, pos));
|
||||
body.SetAngularVelocity(refBody.FromRelAngVel(AngVel));
|
||||
}
|
||||
}
|
||||
}
|
10
QSB/Utility/Messages/DebugTriggerSupernovaMessage.cs
Normal file
10
QSB/Utility/Messages/DebugTriggerSupernovaMessage.cs
Normal file
@ -0,0 +1,10 @@
|
||||
using QSB.Messaging;
|
||||
|
||||
namespace QSB.Utility.Messages
|
||||
{
|
||||
public class DebugTriggerSupernovaMessage : QSBMessage
|
||||
{
|
||||
public override void OnReceiveLocal() => OnReceiveRemote();
|
||||
public override void OnReceiveRemote() => TimeLoop.SetSecondsRemaining(0);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user