qsb network transform child, update prefabs

This commit is contained in:
JohnCorby 2022-01-15 01:54:02 -08:00
parent 1debeb2325
commit 287bc902fe
5 changed files with 47 additions and 7 deletions

Binary file not shown.

View File

@ -1,12 +1,12 @@
ManifestFileVersion: 0
CRC: 3225525052
CRC: 579357437
Hashes:
AssetFileHash:
serializedVersion: 2
Hash: 87f7c3f8f1dad1f9a7b628009679b8a9
Hash: b2d68021be358d61283f066b03d4921c
TypeTreeHash:
serializedVersion: 2
Hash: aea5b327f5eb025bf5354f2e56c088be
Hash: c7e0c4b68194cd411e13354a8f977a46
HashAppended: 0
ClassTypes:
- Class: 1
@ -14,9 +14,7 @@ ClassTypes:
- Class: 4
Script: {instanceID: 0}
- Class: 114
Script: {fileID: -1208705890, guid: 8929207a0d76fd54a8a2a820c652720f, type: 3}
- Class: 114
Script: {fileID: 1142416158, guid: 8929207a0d76fd54a8a2a820c652720f, type: 3}
Script: {fileID: 860895539, guid: b782d36837e164d4e87858bf8f2736c6, type: 3}
- Class: 114
Script: {fileID: -790547616, guid: 27687deae413b90448366870cb0de502, type: 3}
- Class: 114
@ -35,6 +33,8 @@ ClassTypes:
Script: {fileID: 677635994, guid: 27687deae413b90448366870cb0de502, type: 3}
- Class: 114
Script: {fileID: 2036222940, guid: 27687deae413b90448366870cb0de502, type: 3}
- Class: 114
Script: {fileID: -1617191155, guid: 27687deae413b90448366870cb0de502, type: 3}
- Class: 115
Script: {instanceID: 0}
SerializeReferenceClassIdentifiers: []

View File

@ -3,7 +3,7 @@ CRC: 3102539871
Hashes:
AssetFileHash:
serializedVersion: 2
Hash: 520c501e95916cc8415cccee47d482d5
Hash: a82172ddab4ffc78bd7c16996c5f9328
TypeTreeHash:
serializedVersion: 2
Hash: 5ad585dd02dfb5016c0dad519eab8f49

View File

@ -20,6 +20,7 @@ namespace QSB.Player.TransformSync
private Transform _visibleCameraRoot;
private Transform _networkCameraRoot => gameObject.transform.GetChild(0);
// todo? stick root might be the thing that moves instead of roasting system. one of them doesn't, i just don't know which
private Transform _visibleRoastingSystem;
private Transform _networkRoastingSystem => gameObject.transform.GetChild(1);
private Transform _networkStickRoot => _networkRoastingSystem.GetChild(0);
@ -273,6 +274,7 @@ namespace QSB.Player.TransformSync
return;
}
Popcron.Gizmos.Cube(ReferenceTransform.TransformPoint(_networkRoastingSystem.position), ReferenceTransform.TransformRotation(_networkRoastingSystem.rotation), Vector3.one / 4, Color.red);
Popcron.Gizmos.Cube(ReferenceTransform.TransformPoint(_networkRoastingSystem.position), ReferenceTransform.TransformRotation(_networkRoastingSystem.rotation), Vector3.one / 4, Color.red);
Popcron.Gizmos.Cube(ReferenceTransform.TransformPoint(_networkStickPivot.position), ReferenceTransform.TransformRotation(_networkStickPivot.rotation), Vector3.one / 4, Color.red);
Popcron.Gizmos.Cube(ReferenceTransform.TransformPoint(_networkStickTip.position), ReferenceTransform.TransformRotation(_networkStickTip.rotation), Vector3.one / 4, Color.red);

View File

@ -0,0 +1,38 @@
using Mirror;
using QSB.Utility;
using UnityEngine;
namespace QSB.Syncs
{
public class QSBNetworkTransformChild : QSBNetworkBehaviour
{
public Transform Target;
protected override float SendInterval => 0.05f;
protected Vector3 _prevPosition;
protected Quaternion _prevRotation;
protected override void UpdatePrevData()
{
_prevPosition = Target.localPosition;
_prevRotation = Target.localRotation;
}
protected override bool HasChanged() =>
Vector3.Distance(Target.localPosition, _prevPosition) > 1E-05f ||
Quaternion.Angle(Target.localRotation, _prevRotation) > 1E-05f;
protected override void Serialize(NetworkWriter writer, bool initialState)
{
writer.Write(Target.localPosition);
writer.Write(Target.localRotation);
}
protected override void Deserialize(NetworkReader reader, bool initialState)
{
Target.localPosition = reader.ReadVector3();
Target.localRotation = reader.ReadQuaternion();
}
}
}