mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-02-10 03:40:01 +00:00
fixed some stuff
This commit is contained in:
parent
88119389d0
commit
8c38fe46ac
@ -1,4 +1,6 @@
|
||||
using UnityEngine;
|
||||
using OWML.Common;
|
||||
using QSB.Utility;
|
||||
using UnityEngine;
|
||||
|
||||
namespace QSB.Animation
|
||||
{
|
||||
@ -21,6 +23,16 @@ namespace QSB.Animation
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (_attachedAnimator == null)
|
||||
{
|
||||
DebugLog.ToConsole($"Error - _attachedAnimator is null!", MessageType.Error);
|
||||
return;
|
||||
}
|
||||
if (_lookBase == null)
|
||||
{
|
||||
DebugLog.ToConsole($"Error - _lookBase is null!", MessageType.Error);
|
||||
return;
|
||||
}
|
||||
var bone = _attachedAnimator.GetBoneTransform(HumanBodyBones.Head);
|
||||
// Get the camera's local rotation with respect to the player body
|
||||
var lookLocalRotation = Quaternion.Inverse(_attachedAnimator.transform.rotation) * _lookBase.rotation;
|
||||
|
@ -20,9 +20,10 @@ namespace QSB.Player.TransformSync
|
||||
Player.TransformSync = this;
|
||||
}
|
||||
|
||||
protected void OnDestroy()
|
||||
protected override void OnDestroy()
|
||||
{
|
||||
QSBPlayerManager.OnRemovePlayer?.Invoke(PlayerId);
|
||||
base.OnDestroy();
|
||||
if (QSBPlayerManager.PlayerExists(PlayerId))
|
||||
{
|
||||
Player.HudMarker?.Remove();
|
||||
|
@ -1,6 +1,7 @@
|
||||
using OWML.Utils;
|
||||
using QSB.Player;
|
||||
using QSB.TransformSync;
|
||||
using QSB.Utility;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
@ -58,7 +59,6 @@ namespace QSB.RoastingSync.TransformSync
|
||||
return newPivot.gameObject;
|
||||
}
|
||||
|
||||
/*
|
||||
protected override void UpdateTransform()
|
||||
{
|
||||
base.UpdateTransform();
|
||||
@ -78,7 +78,6 @@ namespace QSB.RoastingSync.TransformSync
|
||||
_stickTip.localPosition = Vector3.SmoothDamp(_stickTip.localPosition, _networkStickTip.localPosition, ref _positionSmoothVelocity, SmoothTime);
|
||||
_stickTip.localRotation = QuaternionHelper.SmoothDamp(_stickTip.localRotation, _networkStickTip.localRotation, ref _rotationSmoothVelocity, SmoothTime);
|
||||
}
|
||||
*/
|
||||
|
||||
public override bool IsReady => Locator.GetPlayerTransform() != null
|
||||
&& Player != null
|
||||
|
@ -24,6 +24,7 @@ namespace QSB.SectorSync
|
||||
{
|
||||
if (sync.AttachedObject == null)
|
||||
{
|
||||
DebugLog.ToConsole($"Warning - AttachedObject for {sync.PlayerId}.{sync.name} is null.", MessageType.Warning);
|
||||
continue;
|
||||
}
|
||||
if (sync.HasAuthority && sync.AttachedObject.activeInHierarchy)
|
||||
@ -64,12 +65,8 @@ namespace QSB.SectorSync
|
||||
|
||||
private void CheckTransformSyncSector(QSBNetworkTransform transformSync)
|
||||
{
|
||||
var syncedTransform = transformSync.AttachedObject;
|
||||
if (syncedTransform == null || syncedTransform.transform.position == Vector3.zero)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var closestSector = transformSync.SectorSync.GetClosestSector(syncedTransform.transform);
|
||||
var attachedObject = transformSync.AttachedObject;
|
||||
var closestSector = transformSync.SectorSync.GetClosestSector(attachedObject.transform);
|
||||
if (closestSector == default(QSBSector))
|
||||
{
|
||||
return;
|
||||
|
@ -42,8 +42,26 @@ namespace QSB.TransformSync
|
||||
SectorSync = gameObject.AddComponent<SectorSync.SectorSync>();
|
||||
|
||||
DontDestroyOnLoad(gameObject);
|
||||
QSBSceneManager.OnSceneLoaded += OnSceneLoaded;
|
||||
}
|
||||
|
||||
protected virtual void OnDestroy()
|
||||
{
|
||||
if (!HasAuthority && AttachedObject != null)
|
||||
{
|
||||
DebugLog.DebugWrite($"Destroying {AttachedObject.name}");
|
||||
Destroy(AttachedObject);
|
||||
}
|
||||
QSBSceneManager.OnSceneLoaded -= OnSceneLoaded;
|
||||
if (SectorSync != null)
|
||||
{
|
||||
Destroy(SectorSync);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnSceneLoaded(OWScene scene, bool isInUniverse) =>
|
||||
_isInitialized = false;
|
||||
|
||||
protected void Init()
|
||||
{
|
||||
AttachedObject = HasAuthority ? InitLocalTransform() : InitRemoteTransform();
|
||||
@ -109,12 +127,10 @@ namespace QSB.TransformSync
|
||||
{
|
||||
if (!_isInitialized && IsReady)
|
||||
{
|
||||
DebugLog.ToConsole($"Warning - {PlayerId}.{GetType().Name} is not initialized and ready.", MessageType.Warning);
|
||||
Init();
|
||||
}
|
||||
else if (_isInitialized && !IsReady)
|
||||
{
|
||||
DebugLog.ToConsole($"Warning - {PlayerId}.{GetType().Name} is initialized and not ready.", MessageType.Warning);
|
||||
_isInitialized = false;
|
||||
return;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user