mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-18 13:23:05 +00:00
fixed probe parent issue
This commit is contained in:
parent
cc0df3d7a0
commit
e4e853ead1
@ -58,7 +58,6 @@ namespace QSB.ProbeSync
|
||||
{
|
||||
DebugLog.DebugWrite($"OnWarpComplete");
|
||||
gameObject.SetActive(false);
|
||||
transform.parent = null;
|
||||
transform.localScale = Vector3.one;
|
||||
_isRetrieving = false;
|
||||
}
|
||||
@ -89,7 +88,6 @@ namespace QSB.ProbeSync
|
||||
DebugLog.DebugWrite($"LAUNCH!");
|
||||
|
||||
gameObject.SetActive(true);
|
||||
transform.parent = null;
|
||||
transform.position = _owner.ProbeLauncher.transform.position;
|
||||
transform.rotation = _owner.ProbeLauncher.transform.rotation;
|
||||
|
||||
|
@ -4,6 +4,8 @@ using QSB.Player.TransformSync;
|
||||
using QSB.Utility;
|
||||
using QuantumUNET.Components;
|
||||
using QuantumUNET.Transport;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
@ -16,6 +18,28 @@ namespace QSB.Syncs.TransformSync
|
||||
|
||||
public abstract class BaseTransformSync : QNetworkTransform, ISync<Transform>
|
||||
{
|
||||
private readonly static Dictionary<PlayerInfo, Dictionary<Type, BaseTransformSync>> _storedTransformSyncs = new Dictionary<PlayerInfo, Dictionary<Type, BaseTransformSync>>();
|
||||
|
||||
public static T GetPlayers<T>(PlayerInfo player)
|
||||
where T : BaseTransformSync
|
||||
{
|
||||
var dictOfOwnedSyncs = _storedTransformSyncs[player];
|
||||
var wantedSync = dictOfOwnedSyncs[typeof(T)];
|
||||
if (wantedSync == default)
|
||||
{
|
||||
DebugLog.ToConsole($"Error - _storedTransformSyncs does not contain type:{typeof(T)} under player {player.PlayerId}. Attempting to find manually...", MessageType.Error);
|
||||
var allSyncs = Resources.FindObjectsOfTypeAll<T>();
|
||||
wantedSync = allSyncs.First(x => x.Player == player);
|
||||
if (wantedSync == default)
|
||||
{
|
||||
DebugLog.ToConsole($"Error - Could not find type:{typeof(T)} for player {player.PlayerId} manually!", MessageType.Error);
|
||||
return default;
|
||||
}
|
||||
}
|
||||
|
||||
return (T)wantedSync;
|
||||
}
|
||||
|
||||
public uint AttachedNetId
|
||||
{
|
||||
get
|
||||
@ -75,6 +99,15 @@ namespace QSB.Syncs.TransformSync
|
||||
DontDestroyOnLoad(gameObject);
|
||||
_intermediaryTransform = new IntermediaryTransform(transform);
|
||||
QSBSceneManager.OnSceneLoaded += OnSceneLoaded;
|
||||
|
||||
if (!_storedTransformSyncs.ContainsKey(Player))
|
||||
{
|
||||
_storedTransformSyncs.Add(Player, new Dictionary<Type, BaseTransformSync>());
|
||||
}
|
||||
|
||||
var playerDict = _storedTransformSyncs[Player];
|
||||
playerDict[GetType()] = this;
|
||||
DebugLog.DebugWrite($"Added T:{GetType().Name} to dict of player {Player.PlayerId}", MessageType.Info);
|
||||
}
|
||||
|
||||
protected virtual void OnDestroy()
|
||||
@ -85,6 +118,10 @@ namespace QSB.Syncs.TransformSync
|
||||
}
|
||||
|
||||
QSBSceneManager.OnSceneLoaded -= OnSceneLoaded;
|
||||
|
||||
var playerDict = _storedTransformSyncs[Player];
|
||||
playerDict.Remove(GetType());
|
||||
DebugLog.DebugWrite($"Removed T:{GetType().Name} from dict of player {Player.PlayerId}", MessageType.Info);
|
||||
}
|
||||
|
||||
private void OnSceneLoaded(OWScene scene, bool isInUniverse)
|
||||
@ -285,6 +322,12 @@ namespace QSB.Syncs.TransformSync
|
||||
return;
|
||||
}
|
||||
|
||||
/* Red Cube = Where visible object should be
|
||||
* Green/Yellow Cube = Where visible object is
|
||||
* Red Line = Connection between Red Cube and Green/Yellow Cube
|
||||
* Cyan Line = Connection between Green/Yellow cube and reference transform
|
||||
*/
|
||||
|
||||
Popcron.Gizmos.Cube(_intermediaryTransform.GetTargetPosition_Unparented(), _intermediaryTransform.GetTargetRotation_Unparented(), Vector3.one / 2, Color.red);
|
||||
Popcron.Gizmos.Line(_intermediaryTransform.GetTargetPosition_Unparented(), AttachedObject.transform.position, Color.red);
|
||||
var color = HasMoved() ? Color.green : Color.yellow;
|
||||
|
@ -4,6 +4,7 @@ using QSB.ProbeSync.TransformSync;
|
||||
using QSB.QuantumSync;
|
||||
using QSB.ShipSync;
|
||||
using QSB.ShipSync.TransformSync;
|
||||
using QSB.Syncs.TransformSync;
|
||||
using QSB.TimeSync;
|
||||
using QSB.WorldSync;
|
||||
using System.Linq;
|
||||
@ -40,83 +41,26 @@ namespace QSB.Utility
|
||||
return;
|
||||
}
|
||||
|
||||
var offset3 = 10f;
|
||||
var playerSector = PlayerTransformSync.LocalInstance.ReferenceSector;
|
||||
var playerText = playerSector == null ? "NULL" : playerSector.Name;
|
||||
GUI.Label(new Rect(420, offset3, 400f, 20f), $"Current sector : {playerText}");
|
||||
offset3 += _debugLineSpacing;
|
||||
var probeSector = PlayerProbeSync.LocalInstance.ReferenceSector;
|
||||
var probeText = probeSector == null ? "NULL" : probeSector.Name;
|
||||
|
||||
GUI.Label(new Rect(420, offset3, 200f, 20f), $"Player sectors :");
|
||||
offset3 += _debugLineSpacing;
|
||||
foreach (var sector in PlayerTransformSync.LocalInstance.SectorSync.SectorList)
|
||||
{
|
||||
GUI.Label(new Rect(420, offset3, 400f, 20f), $"- {sector.Name} : {SectorSync.SectorSync.CalculateSectorScore(sector, Locator.GetPlayerTransform(), Locator.GetPlayerBody())}");
|
||||
offset3 += _debugLineSpacing;
|
||||
}
|
||||
|
||||
GUI.Label(new Rect(420, offset3, 200f, 20f), $"Current Flyer : {ShipManager.Instance.CurrentFlyer}");
|
||||
offset3 += _debugLineSpacing;
|
||||
var ship = ShipTransformSync.LocalInstance;
|
||||
if (ship == null)
|
||||
{
|
||||
GUI.Label(new Rect(420, offset3, 200f, 20f), $"SHIP INSTANCE NULL");
|
||||
offset3 += _debugLineSpacing;
|
||||
}
|
||||
else
|
||||
{
|
||||
GUI.Label(new Rect(420, offset3, 200f, 20f), $"In control of ship? : {ship.HasAuthority}");
|
||||
offset3 += _debugLineSpacing;
|
||||
GUI.Label(new Rect(420, offset3, 400f, 20f), $"Ship sector : {(ship.ReferenceSector == null ? "NULL" : ship.ReferenceSector.Name)}");
|
||||
offset3 += _debugLineSpacing;
|
||||
if (ship.ReferenceTransform != null)
|
||||
{
|
||||
GUI.Label(new Rect(420, offset3, 400f, 20f), $"Ship relative velocity : {ship.GetRelativeVelocity()}");
|
||||
offset3 += _debugLineSpacing;
|
||||
GUI.Label(new Rect(420, offset3, 400f, 20f), $"Ship velocity : {ship.AttachedObject.GetVelocity()}");
|
||||
offset3 += _debugLineSpacing;
|
||||
GUI.Label(new Rect(420, offset3, 400f, 20f), $"Static Frame velocity : {Locator.GetCenterOfTheUniverse().GetStaticFrameWorldVelocity()}");
|
||||
offset3 += _debugLineSpacing;
|
||||
GUI.Label(new Rect(420, offset3, 400f, 20f), $"Reference point velocity : {ship.ReferenceTransform.GetAttachedOWRigidbody().GetPointVelocity(ship.AttachedObject.transform.position)}");
|
||||
offset3 += _debugLineSpacing;
|
||||
GUI.Label(new Rect(420, offset3, 400f, 20f), $"Ship velocity mag. : {ship.GetVelocityChangeMagnitude()}");
|
||||
offset3 += _debugLineSpacing;
|
||||
}
|
||||
|
||||
GUI.Label(new Rect(420, offset3, 200f, 20f), $"Ship sectors :");
|
||||
offset3 += _debugLineSpacing;
|
||||
foreach (var sector in ship.SectorSync.SectorList)
|
||||
{
|
||||
GUI.Label(new Rect(420, offset3, 400f, 20f), $"- {sector.Name} : {SectorSync.SectorSync.CalculateSectorScore(sector, Locator.GetShipTransform(), Locator.GetShipBody())}");
|
||||
offset3 += _debugLineSpacing;
|
||||
}
|
||||
}
|
||||
|
||||
var offset2 = 10f;
|
||||
GUI.Label(new Rect(620, offset2, 200f, 20f), $"Owned Objects :");
|
||||
GUI.Label(new Rect(320, offset2, 200f, 20f), $"Player data :");
|
||||
offset2 += _debugLineSpacing;
|
||||
foreach (var obj in QSBWorldSync.GetWorldObjects<IQSBQuantumObject>().Where(x => x.ControllingPlayer == QSBPlayerManager.LocalPlayerId))
|
||||
{
|
||||
GUI.Label(new Rect(620, offset2, 200f, 20f), $"- {(obj as IWorldObject).Name}, {obj.ControllingPlayer}, {obj.IsEnabled}");
|
||||
offset2 += _debugLineSpacing;
|
||||
}
|
||||
|
||||
GUI.Label(new Rect(220, offset, 200f, 20f), $"Player data :");
|
||||
offset += _debugLineSpacing;
|
||||
foreach (var player in QSBPlayerManager.PlayerList.Where(x => x.PlayerStates.IsReady))
|
||||
{
|
||||
var networkTransform = player.TransformSync;
|
||||
var sector = networkTransform.ReferenceSector;
|
||||
|
||||
GUI.Label(new Rect(220, offset, 400f, 20f), $"{player.PlayerId} - L.Pos : {networkTransform.transform.localPosition}");
|
||||
offset += _debugLineSpacing;
|
||||
GUI.Label(new Rect(220, offset, 400f, 20f), $" - Sector : {(sector == null ? "NULL" : sector.Name)}");
|
||||
offset += _debugLineSpacing;
|
||||
GUI.Label(new Rect(220, offset, 400f, 20f), $" - L.Accel : {player.JetpackAcceleration?.LocalAcceleration}");
|
||||
offset += _debugLineSpacing;
|
||||
GUI.Label(new Rect(220, offset, 400f, 20f), $" - Thrusting : {player.JetpackAcceleration?.IsThrusting}");
|
||||
offset += _debugLineSpacing;
|
||||
GUI.Label(new Rect(320, offset2, 400f, 20f), $"{player.PlayerId}.{player.Name}");
|
||||
offset2 += _debugLineSpacing;
|
||||
GUI.Label(new Rect(320, offset2, 400f, 20f), $" - L.Pos : {networkTransform.transform.localPosition}");
|
||||
offset2 += _debugLineSpacing;
|
||||
GUI.Label(new Rect(320, offset2, 400f, 20f), $" - W.Pos : {sector.Transform.InverseTransformPoint(networkTransform.AttachedObject.position)}");
|
||||
offset2 += _debugLineSpacing;
|
||||
GUI.Label(new Rect(320, offset2, 400f, 20f), $" - Sector : {(sector == null ? "NULL" : sector.Name)}");
|
||||
offset2 += _debugLineSpacing;
|
||||
var probeSync = BaseTransformSync.GetPlayers<PlayerProbeSync>(player);
|
||||
var probeSector = probeSync.ReferenceSector;
|
||||
GUI.Label(new Rect(320, offset2, 400f, 20f), $" - Probe Sector : {(probeSector == null ? "NULL" : probeSector.Name)}");
|
||||
offset2 += _debugLineSpacing;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user