mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-03-10 16:14:45 +00:00
stuffz
This commit is contained in:
parent
82ce041fb8
commit
9356a4f704
Binary file not shown.
@ -2,6 +2,7 @@
|
||||
using QSB.ItemSync.WorldObjects.Items;
|
||||
using QSB.Player.TransformSync;
|
||||
using QSB.Tools.FlashlightTool;
|
||||
using QSB.Tools.ProbeTool;
|
||||
using QSB.Utility;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -87,6 +88,9 @@ public static class QSBPlayerManager
|
||||
public static Tuple<Flashlight, IEnumerable<QSBFlashlight>> GetPlayerFlashlights()
|
||||
=> new(Locator.GetFlashlight(), PlayerList.Where(x => x.FlashLight != null).Select(x => x.FlashLight));
|
||||
|
||||
public static Tuple<SurveyorProbe, IEnumerable<QSBProbe>> GetPlayerProbes()
|
||||
=> new(Locator.GetProbe(), PlayerList.Where(x => x.Probe != null).Select(x => x.Probe));
|
||||
|
||||
public static void ShowAllPlayers()
|
||||
=> PlayerList.ForEach(x => x.SetVisible(true, 2));
|
||||
|
||||
|
@ -44,6 +44,8 @@ public class QuantumPatches : QSBPatch
|
||||
ref bool __result,
|
||||
bool skipInstantVisibilityCheck)
|
||||
{
|
||||
DebugLog.DebugWrite($"SocketedQuantumObject {__instance.name} - ChangeQuantumState");
|
||||
|
||||
if (QSBWorldSync.AllObjectsReady)
|
||||
{
|
||||
var socketedWorldObject = __instance.GetWorldObject<QSBSocketedQuantumObject>();
|
||||
|
@ -70,22 +70,31 @@ public class QuantumVisibilityPatches : QSBPatch
|
||||
var localFlashlight = tupleFlashlights.Item1;
|
||||
var playerFlashlights = tupleFlashlights.Item2;
|
||||
|
||||
// local player flashlight
|
||||
var tupleProbes = QSBPlayerManager.GetPlayerProbes();
|
||||
var localProbe = tupleProbes.Item1;
|
||||
var playerProbes = tupleProbes.Item2;
|
||||
|
||||
if (localFlashlight.CheckIlluminationAtPoint(point, __instance._illuminationRadius))
|
||||
{
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
// all other player flashlights
|
||||
if (playerFlashlights.Any(x => x.CheckIlluminationAtPoint(point, __instance._illuminationRadius)))
|
||||
{
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
// BUG : Implement checking for other probes!
|
||||
if (Locator.GetProbe() != null && Locator.GetProbe().IsLaunched() && Locator.GetProbe().CheckIlluminationAtPoint(point, __instance._illuminationRadius))
|
||||
if (localProbe != null
|
||||
&& localProbe.IsLaunched()
|
||||
&& localProbe.CheckIlluminationAtPoint(point, __instance._illuminationRadius))
|
||||
{
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (playerProbes.Any(x => x.IsLaunched() && x.CheckIlluminationAtPoint(point, __instance._illuminationRadius)))
|
||||
{
|
||||
__result = true;
|
||||
return false;
|
||||
|
@ -110,10 +110,11 @@ internal class QuantumManager : WorldObjectManager
|
||||
return new Tuple<bool, List<PlayerInfo>>(foundPlayers, playersWhoCanSee);
|
||||
}
|
||||
|
||||
public static bool IsVisible(ShapeVisibilityTracker tracker, bool ignoreLocalCamera) => tracker.gameObject.activeInHierarchy
|
||||
&& IsVisibleUsingCameraFrustum(tracker, ignoreLocalCamera).Item1
|
||||
&& QSBPlayerManager.GetPlayersWithCameras(!ignoreLocalCamera)
|
||||
.Any(x => VisibilityOccluder.CanYouSee(tracker, x.Camera.mainCamera.transform.position));
|
||||
public static bool IsVisible(ShapeVisibilityTracker tracker, bool ignoreLocalCamera)
|
||||
=> tracker.gameObject.activeInHierarchy
|
||||
&& IsVisibleUsingCameraFrustum(tracker, ignoreLocalCamera).Item1
|
||||
&& QSBPlayerManager.GetPlayersWithCameras(!ignoreLocalCamera)
|
||||
.Any(x => VisibilityOccluder.CanYouSee(tracker, x.Camera.mainCamera.transform.position));
|
||||
|
||||
public static IEnumerable<PlayerInfo> GetEntangledPlayers(QuantumObject obj)
|
||||
{
|
||||
|
@ -11,4 +11,5 @@ public interface IQSBQuantumObject : IWorldObject
|
||||
List<Shape> GetAttachedShapes();
|
||||
|
||||
void SetIsQuantum(bool isQuantum);
|
||||
VisibilityObject GetVisibilityObject();
|
||||
}
|
@ -28,7 +28,7 @@ internal class QSBMultiStateQuantumObject : QSBQuantumObject<MultiStateQuantumOb
|
||||
}
|
||||
|
||||
public override string ReturnLabel()
|
||||
=> $"{this}{Environment.NewLine}StateIndex:{AttachedObject._stateIndex}";
|
||||
=> $"{base.ReturnLabel()}StateIndex:{AttachedObject._stateIndex}";
|
||||
|
||||
public override void SendInitialState(uint to)
|
||||
{
|
||||
|
@ -114,6 +114,8 @@ internal abstract class QSBQuantumObject<T> : WorldObject<T>, IQSBQuantumObject
|
||||
|
||||
public void SetIsQuantum(bool isQuantum) => AttachedObject._isQuantum = isQuantum;
|
||||
|
||||
public VisibilityObject GetVisibilityObject() => AttachedObject;
|
||||
|
||||
private void OnEnable(Shape s)
|
||||
{
|
||||
if (IsEnabled)
|
||||
@ -218,4 +220,15 @@ internal abstract class QSBQuantumObject<T> : WorldObject<T>, IQSBQuantumObject
|
||||
playerBody.transform.position,
|
||||
Color.magenta);
|
||||
}
|
||||
|
||||
public override string ReturnLabel()
|
||||
{
|
||||
var label = $"{this}\r\n";
|
||||
foreach (var tracker in AttachedObject._visibilityTrackers)
|
||||
{
|
||||
label += $"{tracker.name}:\r\n IsVisible:{tracker.IsVisible()}\r\n VisibleUsingCamera:{tracker.IsVisibleUsingCameraFrustum()}\r\n";
|
||||
}
|
||||
|
||||
return label;
|
||||
}
|
||||
}
|
@ -2,7 +2,7 @@
|
||||
|
||||
internal class QSBQuantumSkeletonTower : QSBQuantumObject<QuantumSkeletonTower>
|
||||
{
|
||||
public override string ReturnLabel() => $"{base.ReturnLabel()}\n"
|
||||
public override string ReturnLabel() => $"{base.ReturnLabel()}"
|
||||
+ $"{AttachedObject._index} {AttachedObject._waitForPlayerToLookAtTower}\n"
|
||||
+ $"{AttachedObject._waitForFlicker} {AttachedObject._flickering}";
|
||||
|
||||
|
@ -23,11 +23,11 @@ internal class QSBSocketedQuantumObject : QSBQuantumObject<SocketedQuantumObject
|
||||
if (socket != null)
|
||||
{
|
||||
var socketObj = socket.GetWorldObject<QSBQuantumSocket>();
|
||||
return $"{this}{Environment.NewLine}SocketId:{socketObj.ObjectId}";
|
||||
return $"{base.ReturnLabel()}SocketId:{socketObj.ObjectId}";
|
||||
}
|
||||
else
|
||||
{
|
||||
return $"{this}{Environment.NewLine}SocketId:NULL";
|
||||
return $"{base.ReturnLabel()}SocketId:NULL";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,9 @@ public class QSBProbe : MonoBehaviour
|
||||
public delegate void SurveyorProbeEvent();
|
||||
public delegate void RetrieveEvent(float retrieveLength);
|
||||
|
||||
[SerializeField]
|
||||
private OWLight2[] _illuminationCheckLights;
|
||||
|
||||
public event SurveyorProbeEvent OnLaunchProbe;
|
||||
public event SurveyorProbeEvent OnAnchorProbe;
|
||||
public event SurveyorProbeEvent OnUnanchorProbe;
|
||||
@ -152,4 +155,17 @@ public class QSBProbe : MonoBehaviour
|
||||
OnStartRetrieveProbe(duration);
|
||||
}
|
||||
}
|
||||
|
||||
public bool CheckIlluminationAtPoint(Vector3 point, float buffer = 0f, float maxDistance = float.PositiveInfinity)
|
||||
{
|
||||
for (var i = 0; i < _illuminationCheckLights.Length; i++)
|
||||
{
|
||||
if (_illuminationCheckLights[i].CheckIlluminationAtPoint(point, buffer, maxDistance))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
@ -224,6 +224,14 @@ internal class DebugGUI : MonoBehaviour, IAddComponentOnStart
|
||||
foreach (var quantumObject in ownedQuantumObjects)
|
||||
{
|
||||
WriteLine(4, $"{quantumObject.Name} ({quantumObject.ObjectId})");
|
||||
WriteLine(4, $" - IsIlluminated{quantumObject.GetVisibilityObject().IsIlluminated()}");
|
||||
WriteLine(4, $" - IsVisible{quantumObject.GetVisibilityObject().IsVisible()}");
|
||||
foreach (var tracker in quantumObject.GetVisibilityObject()._visibilityTrackers)
|
||||
{
|
||||
WriteLine(4, $" - {tracker.name}");
|
||||
WriteLine(4, $" - IsVisible:{tracker.IsVisible()}");
|
||||
WriteLine(4, $" - IsVisibleUsingCameraFrustum:{tracker.IsVisibleUsingCameraFrustum()}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user