public static bool QuantumObject_IsLockedByPlayerContact(out bool __result, QuantumObject __instance) { var playersEntangled = QuantumManager.GetEntangledPlayers(__instance); __result = playersEntangled.Count() != 0 && __instance.IsIlluminated(); return(false); }
public static bool SocketedQuantumObject_ChangeQuantumState( SocketedQuantumObject __instance, ref bool __result, bool skipInstantVisibilityCheck) { if (QSBWorldSync.AllObjectsReady) { var socketedWorldObject = __instance.GetWorldObject <QSBSocketedQuantumObject>(); if (socketedWorldObject.ControllingPlayer != QSBPlayerManager.LocalPlayerId) { return(false); } } foreach (var socket in __instance._childSockets) { if (socket.IsOccupied()) { __result = false; return(false); } } if (__instance._socketList.Count <= 1) { DebugLog.ToConsole($"Error - Not enough quantum sockets in list for {__instance.name}!", MessageType.Error); __result = false; return(false); } var list = new List <QuantumSocket>(); foreach (var socket in __instance._socketList) { if (!socket.IsOccupied() && socket.IsActive()) { list.Add(socket); } } if (list.Count == 0) { __result = false; return(false); } if (__instance._recentlyObscuredSocket != null) { __instance.MoveToSocket(__instance._recentlyObscuredSocket); __instance._recentlyObscuredSocket = null; __result = true; return(false); } var occupiedSocket = __instance._occupiedSocket; for (var i = 0; i < 20; i++) { var index = Random.Range(0, list.Count); __instance.MoveToSocket(list[index]); if (skipInstantVisibilityCheck) { __result = true; return(false); } bool socketNotSuitable; var isSocketIlluminated = __instance.CheckIllumination(); var playersEntangled = QuantumManager.GetEntangledPlayers(__instance); if (playersEntangled.Count() != 0) { // socket not suitable if illuminated socketNotSuitable = isSocketIlluminated; } else { var checkVisInstant = __instance.CheckVisibilityInstantly(); if (isSocketIlluminated) { // socket not suitable if object is visible socketNotSuitable = checkVisInstant; } else { // socket not suitable if player is inside object socketNotSuitable = playersEntangled.Any(x => __instance.CheckPointInside(x.CameraBody.transform.position)); } } if (!socketNotSuitable) { __result = true; return(false); } list.RemoveAt(index); if (list.Count == 0) { break; } } __instance.MoveToSocket(occupiedSocket); __result = false; return(false); }
public void OnGUI() { if (!DebugMode) { return; } var offset = 10f; GUI.Label(new Rect(220, 10, 200f, 20f), $"FPS : {Mathf.Round(1f / Time.smoothDeltaTime)}"); offset += _debugLineSpacing; GUI.Label(new Rect(220, offset, 200f, 20f), $"HasWokenUp : {HasWokenUp}"); offset += _debugLineSpacing; if (WakeUpSync.LocalInstance != null) { GUI.Label(new Rect(220, offset, 200f, 20f), $"Time Difference : {WakeUpSync.LocalInstance.GetTimeDifference()}"); offset += _debugLineSpacing; GUI.Label(new Rect(220, offset, 200f, 20f), $"Timescale : {OWTime.GetTimeScale()}"); offset += _debugLineSpacing; } if (!HasWokenUp) { return; } var offset3 = 10f; GUI.Label(new Rect(420, offset3, 200f, 20f), $"Current synced sector :"); offset3 += _debugLineSpacing; var sector = PlayerTransformSync.LocalInstance.ReferenceSector; var text = sector == null ? "NULL SECTOR" : $"{sector.AttachedObject.name} : {sector.IsFakeSector}"; GUI.Label(new Rect(420, offset3, 400f, 20f), $"- {text}"); offset3 += _debugLineSpacing; var offset2 = 10f; GUI.Label(new Rect(620, offset2, 200f, 20f), $"Owned Objects :"); 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; } if (QSBSceneManager.CurrentScene != OWScene.SolarSystem) { return; } GUI.Label(new Rect(220, offset, 200f, 20f), $"QM Illuminated : {Locator.GetQuantumMoon().IsIlluminated()}"); offset += _debugLineSpacing; GUI.Label(new Rect(220, offset, 200f, 20f), $"Shrine player in dark? : {QuantumManager.Instance.Shrine.IsPlayerInDarkness()}"); offset += _debugLineSpacing; GUI.Label(new Rect(220, offset, 200f, 20f), $"QM Visible by :"); offset += _debugLineSpacing; var tracker = Locator.GetQuantumMoon().GetValue <ShapeVisibilityTracker>("_visibilityTracker"); foreach (var player in QSBPlayerManager.GetPlayersWithCameras()) { GUI.Label(new Rect(220, offset, 200f, 20f), $" - {player.PlayerId} : {tracker.GetType().GetMethod("IsInFrustum", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(tracker, new object[] { player.Camera.GetFrustumPlanes() })}"); offset += _debugLineSpacing; } if (SocketedObjToDebug == -1) { return; } // Used for diagnosing specific socketed objects. // 110 = Cave Twin entanglement shard // 342 = Timber Hearth museum shard var socketedObject = QSBWorldSync.GetWorldFromId <QSBSocketedQuantumObject>(SocketedObjToDebug); GUI.Label(new Rect(220, offset, 200f, 20f), $"{SocketedObjToDebug} Controller : {socketedObject.ControllingPlayer}"); offset += _debugLineSpacing; GUI.Label(new Rect(220, offset, 200f, 20f), $"{SocketedObjToDebug} Illuminated : {socketedObject.AttachedObject.IsIlluminated()}"); offset += _debugLineSpacing; var socketedTrackers = socketedObject.AttachedObject.GetComponentsInChildren <ShapeVisibilityTracker>(); if (socketedTrackers == null || socketedTrackers.Length == 0) { GUI.Label(new Rect(220, offset, 200f, 20f), $"- List is null or empty."); return; } if (socketedTrackers.Any(x => x is null)) { GUI.Label(new Rect(220, offset, 200f, 20f), $"- Uses a null."); return; } GUI.Label(new Rect(220, offset, 200f, 20f), $"Visible by :"); offset += _debugLineSpacing; foreach (var player in QSBPlayerManager.GetPlayersWithCameras()) { GUI.Label(new Rect(220, offset, 200f, 20f), $" - {player.PlayerId} : {socketedTrackers.Any(x => (bool)x.GetType().GetMethod("IsInFrustum", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(x, new object[] { player.Camera.GetFrustumPlanes() }))}"); offset += _debugLineSpacing; } GUI.Label(new Rect(220, offset, 200f, 20f), $"Entangled Players :"); offset += _debugLineSpacing; foreach (var player in QuantumManager.GetEntangledPlayers(socketedObject.AttachedObject)) { GUI.Label(new Rect(220, offset, 200f, 20f), $" - {player.PlayerId}"); offset += _debugLineSpacing; } var sockets = socketedObject.AttachedObject.GetValue <List <QuantumSocket> >("_socketList"); foreach (var socket in sockets) { GUI.Label(new Rect(220, offset, 200f, 20f), $"- {socket.name} :"); offset += _debugLineSpacing; GUI.Label(new Rect(220, offset, 200f, 20f), $" - Visible:{socket.GetVisibilityObject().IsVisible()}"); offset += _debugLineSpacing; GUI.Label(new Rect(220, offset, 200f, 20f), $" - Illuminated:{socket.GetVisibilityObject().IsIlluminated()}"); offset += _debugLineSpacing; GUI.Label(new Rect(220, offset, 200f, 20f), $" - Occupied?:{socket.IsOccupied()}"); offset += _debugLineSpacing; } }