mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-02-10 21:40:19 +00:00
start of camera sync
This commit is contained in:
parent
2b39f6b837
commit
57394f34e8
@ -478,4 +478,10 @@ public class QuantumPatches : QSBPatch
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HarmonyPrefix]
|
||||||
|
[HarmonyPatch(typeof(QuantumObject), nameof(QuantumObject.OnProbeSnapshot))]
|
||||||
|
public static bool OnProbeSnapshot()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
@ -126,6 +126,19 @@ internal class QuantumManager : WorldObjectManager
|
|||||||
return QSBPlayerManager.PlayerList.Where(x => x.EntangledObject == worldObj);
|
return QSBPlayerManager.PlayerList.Where(x => x.EntangledObject == worldObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void OnTakeProbeSnapshot(PlayerInfo player, ProbeCamera.ID cameraId)
|
||||||
|
{
|
||||||
|
DebugLog.DebugWrite($"{player} took a probe snapshot with cameraid {cameraId}");
|
||||||
|
|
||||||
|
foreach (var quantumObject in QSBWorldSync.GetWorldObjects<IQSBQuantumObject>())
|
||||||
|
{
|
||||||
|
if (quantumObject.ControllingPlayer == QSBPlayerManager.LocalPlayerId)
|
||||||
|
{
|
||||||
|
quantumObject.OnTakeProbeSnapshot(player, cameraId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#region debug shapes
|
#region debug shapes
|
||||||
|
|
||||||
private static GameObject _debugSphere, _debugCube, _debugCapsule;
|
private static GameObject _debugSphere, _debugCube, _debugCapsule;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using QSB.WorldSync;
|
using QSB.Player;
|
||||||
|
using QSB.WorldSync;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace QSB.QuantumSync.WorldObjects;
|
namespace QSB.QuantumSync.WorldObjects;
|
||||||
@ -12,4 +13,5 @@ public interface IQSBQuantumObject : IWorldObject
|
|||||||
|
|
||||||
void SetIsQuantum(bool isQuantum);
|
void SetIsQuantum(bool isQuantum);
|
||||||
VisibilityObject GetVisibilityObject();
|
VisibilityObject GetVisibilityObject();
|
||||||
|
void OnTakeProbeSnapshot(PlayerInfo player, ProbeCamera.ID cameraId);
|
||||||
}
|
}
|
@ -3,6 +3,7 @@ using OWML.Common;
|
|||||||
using QSB.Messaging;
|
using QSB.Messaging;
|
||||||
using QSB.Player;
|
using QSB.Player;
|
||||||
using QSB.QuantumSync.Messages;
|
using QSB.QuantumSync.Messages;
|
||||||
|
using QSB.Tools.ProbeTool;
|
||||||
using QSB.Utility;
|
using QSB.Utility;
|
||||||
using QSB.WorldSync;
|
using QSB.WorldSync;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -28,6 +29,8 @@ internal abstract class QSBQuantumObject<T> : WorldObject<T>, IQSBQuantumObject
|
|||||||
public uint ControllingPlayer { get; set; }
|
public uint ControllingPlayer { get; set; }
|
||||||
public bool IsEnabled { get; private set; }
|
public bool IsEnabled { get; private set; }
|
||||||
|
|
||||||
|
private List<PlayerInfo> _visibleToProbes = new();
|
||||||
|
|
||||||
public override void OnRemoval()
|
public override void OnRemoval()
|
||||||
{
|
{
|
||||||
if (HostControls)
|
if (HostControls)
|
||||||
@ -174,6 +177,100 @@ internal abstract class QSBQuantumObject<T> : WorldObject<T>, IQSBQuantumObject
|
|||||||
((IQSBQuantumObject)this).SendMessage(new QuantumAuthorityMessage(0u));
|
((IQSBQuantumObject)this).SendMessage(new QuantumAuthorityMessage(0u));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
public void OnTakeProbeSnapshot(PlayerInfo player, ProbeCamera.ID cameraId)
|
||||||
|
{
|
||||||
|
DebugLog.DebugWrite($"{AttachedObject.name} OnTakeProbeSnapshot playerId:{player.PlayerId} cameraId:{cameraId}");
|
||||||
|
if (player.IsLocalPlayer)
|
||||||
|
{
|
||||||
|
DebugLog.DebugWrite($"- is local player");
|
||||||
|
var probe = Locator.GetProbe();
|
||||||
|
ProbeCamera probeCamera = default;
|
||||||
|
switch (cameraId)
|
||||||
|
{
|
||||||
|
case ProbeCamera.ID.Forward:
|
||||||
|
probeCamera = probe.GetForwardCamera();
|
||||||
|
break;
|
||||||
|
case ProbeCamera.ID.Reverse:
|
||||||
|
probeCamera = probe.GetReverseCamera();
|
||||||
|
break;
|
||||||
|
case ProbeCamera.ID.Rotating:
|
||||||
|
probeCamera = probe.GetRotatingCamera();
|
||||||
|
break;
|
||||||
|
case ProbeCamera.ID.PreLaunch:
|
||||||
|
probeCamera = player.LocalProbeLauncher._preLaunchCamera;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
var distance = Vector3.Distance(AttachedObject.transform.position, probeCamera.transform.position);
|
||||||
|
DebugLog.DebugWrite($"- distance is {distance}");
|
||||||
|
if (distance < AttachedObject._maxSnapshotLockRange
|
||||||
|
&& AttachedObject.IsIlluminated()
|
||||||
|
&& !probeCamera.HasInterference()
|
||||||
|
&& AttachedObject.CheckVisibilityFromProbe(probeCamera.GetOWCamera()))
|
||||||
|
{
|
||||||
|
DebugLog.DebugWrite($"- Visible in probe snapshot for local player!");
|
||||||
|
if (!_visibleToProbes.Contains(player))
|
||||||
|
{
|
||||||
|
_visibleToProbes.Add(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
AttachedObject._visibleInProbeSnapshot = _visibleToProbes.Any(x => x != null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DebugLog.DebugWrite($"- not visible :(");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DebugLog.DebugWrite($"- not local player");
|
||||||
|
var probe = player.Probe;
|
||||||
|
QSBProbeCamera probeCamera = default;
|
||||||
|
switch (cameraId)
|
||||||
|
{
|
||||||
|
case ProbeCamera.ID.Forward:
|
||||||
|
probeCamera = probe.GetForwardCamera();
|
||||||
|
break;
|
||||||
|
case ProbeCamera.ID.Reverse:
|
||||||
|
probeCamera = probe.GetReverseCamera();
|
||||||
|
break;
|
||||||
|
case ProbeCamera.ID.Rotating:
|
||||||
|
probeCamera = probe.GetRotatingCamera();
|
||||||
|
break;
|
||||||
|
case ProbeCamera.ID.PreLaunch:
|
||||||
|
//TODO : uhhhh yeah do this lol
|
||||||
|
probeCamera = null;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
var distance = Vector3.Distance(AttachedObject.transform.position, probeCamera.transform.position);
|
||||||
|
if (distance < AttachedObject._maxSnapshotLockRange
|
||||||
|
&& AttachedObject.IsIlluminated()
|
||||||
|
&& !probeCamera.HasInterference()
|
||||||
|
&& AttachedObject.CheckVisibilityFromProbe(probeCamera.GetOWCamera()))
|
||||||
|
{
|
||||||
|
DebugLog.DebugWrite($"Visible in probe snapshot for {player.PlayerId}!");
|
||||||
|
if (!_visibleToProbes.Contains(player))
|
||||||
|
{
|
||||||
|
_visibleToProbes.Add(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
_visibleToProbes.Add(player);
|
||||||
|
AttachedObject._visibleInProbeSnapshot = _visibleToProbes.Any(x => x != null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_visibleToProbes.Contains(player))
|
||||||
|
{
|
||||||
|
DebugLog.DebugWrite($"NOT visible in probe snapshot for {player.PlayerId}!");
|
||||||
|
_visibleToProbes.Remove(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
AttachedObject._visibleInProbeSnapshot = _visibleToProbes.Any(x => x != null);
|
||||||
|
}
|
||||||
|
|
||||||
public override void DisplayLines()
|
public override void DisplayLines()
|
||||||
{
|
{
|
||||||
if (AttachedObject == null)
|
if (AttachedObject == null)
|
||||||
|
@ -1,16 +1,22 @@
|
|||||||
using QSB.Messaging;
|
using QSB.Messaging;
|
||||||
using QSB.Player;
|
using QSB.Player;
|
||||||
|
using QSB.QuantumSync;
|
||||||
using QSB.WorldSync;
|
using QSB.WorldSync;
|
||||||
|
|
||||||
namespace QSB.Tools.ProbeLauncherTool.Messages;
|
namespace QSB.Tools.ProbeLauncherTool.Messages;
|
||||||
|
|
||||||
internal class PlayerLauncherTakeSnapshotMessage : QSBMessage
|
internal class PlayerLauncherTakeSnapshotMessage : QSBMessage<ProbeCamera.ID>
|
||||||
{
|
{
|
||||||
|
public PlayerLauncherTakeSnapshotMessage(ProbeCamera.ID cameraId) : base(cameraId) { }
|
||||||
|
|
||||||
public override bool ShouldReceive => QSBWorldSync.AllObjectsReady;
|
public override bool ShouldReceive => QSBWorldSync.AllObjectsReady;
|
||||||
|
|
||||||
|
public override void OnReceiveLocal() => QuantumManager.OnTakeProbeSnapshot(QSBPlayerManager.LocalPlayer, Data);
|
||||||
|
|
||||||
public override void OnReceiveRemote()
|
public override void OnReceiveRemote()
|
||||||
{
|
{
|
||||||
var player = QSBPlayerManager.GetPlayer(From);
|
var player = QSBPlayerManager.GetPlayer(From);
|
||||||
player.ProbeLauncherTool.TakeSnapshot();
|
player.ProbeLauncherTool.TakeSnapshot();
|
||||||
|
QuantumManager.OnTakeProbeSnapshot(player, Data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
using QSB.Messaging;
|
using QSB.Messaging;
|
||||||
|
using QSB.Player;
|
||||||
|
using QSB.QuantumSync;
|
||||||
using QSB.Tools.ProbeLauncherTool.WorldObjects;
|
using QSB.Tools.ProbeLauncherTool.WorldObjects;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -8,9 +10,11 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace QSB.Tools.ProbeLauncherTool.Messages;
|
namespace QSB.Tools.ProbeLauncherTool.Messages;
|
||||||
|
|
||||||
internal class TakeSnapshotMessage : QSBWorldObjectMessage<QSBProbeLauncher>
|
internal class TakeSnapshotMessage : QSBWorldObjectMessage<QSBProbeLauncher, ProbeCamera.ID>
|
||||||
{
|
{
|
||||||
public TakeSnapshotMessage() : base() { }
|
public TakeSnapshotMessage(ProbeCamera.ID cameraId) : base(cameraId) { }
|
||||||
|
|
||||||
public override void OnReceiveRemote() => WorldObject.TakeSnapshot();
|
public override void OnReceiveLocal() => QuantumManager.OnTakeProbeSnapshot(QSBPlayerManager.LocalPlayer, Data);
|
||||||
|
|
||||||
|
public override void OnReceiveRemote() => WorldObject.TakeSnapshot(QSBPlayerManager.GetPlayer(From), Data);
|
||||||
}
|
}
|
||||||
|
@ -107,7 +107,7 @@ internal class LauncherPatches : QSBPatch
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[HarmonyPostfix]
|
/*[HarmonyPostfix]
|
||||||
[HarmonyPatch(typeof(ProbeLauncherEffects), nameof(ProbeLauncherEffects.PlaySnapshotClip))]
|
[HarmonyPatch(typeof(ProbeLauncherEffects), nameof(ProbeLauncherEffects.PlaySnapshotClip))]
|
||||||
public static void ProbeLauncherEffects_PlaySnapshotClip(ProbeLauncherEffects __instance)
|
public static void ProbeLauncherEffects_PlaySnapshotClip(ProbeLauncherEffects __instance)
|
||||||
{
|
{
|
||||||
@ -122,5 +122,24 @@ internal class LauncherPatches : QSBPatch
|
|||||||
{
|
{
|
||||||
new PlayerLauncherTakeSnapshotMessage().Send();
|
new PlayerLauncherTakeSnapshotMessage().Send();
|
||||||
}
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
|
[HarmonyPostfix]
|
||||||
|
[HarmonyPatch(typeof(ProbeLauncher), nameof(ProbeLauncher.TakeSnapshotWithCamera))]
|
||||||
|
public static void TakeSnapshotWithCamera(ProbeLauncher __instance, ProbeCamera camera)
|
||||||
|
{
|
||||||
|
DebugLog.DebugWrite($"TakeSnapshotWithCamera - cameraid:{camera.GetID()}");
|
||||||
|
if (__instance != QSBPlayerManager.LocalPlayer.LocalProbeLauncher)
|
||||||
|
{
|
||||||
|
DebugLog.DebugWrite($"- not local launcher");
|
||||||
|
__instance
|
||||||
|
?.GetWorldObject<QSBProbeLauncher>()
|
||||||
|
?.SendMessage(new TakeSnapshotMessage(camera.GetID()));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DebugLog.DebugWrite($"- local launcher");
|
||||||
|
new PlayerLauncherTakeSnapshotMessage(camera.GetID()).Send();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,5 +1,7 @@
|
|||||||
using Cysharp.Threading.Tasks;
|
using Cysharp.Threading.Tasks;
|
||||||
using QSB.Messaging;
|
using QSB.Messaging;
|
||||||
|
using QSB.Player;
|
||||||
|
using QSB.QuantumSync;
|
||||||
using QSB.Tools.ProbeLauncherTool.Messages;
|
using QSB.Tools.ProbeLauncherTool.Messages;
|
||||||
using QSB.WorldSync;
|
using QSB.WorldSync;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
@ -66,9 +68,10 @@ public class QSBProbeLauncher : WorldObject<ProbeLauncher>
|
|||||||
AttachedObject._effects.PlayChangeModeClip();
|
AttachedObject._effects.PlayChangeModeClip();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void TakeSnapshot()
|
public void TakeSnapshot(PlayerInfo player, ProbeCamera.ID cameraId)
|
||||||
{
|
{
|
||||||
// Not using PlaySnapshotClip because that uses Locator.GetPlayerAudioController() instead of owAudioSource for some reason
|
// Not using PlaySnapshotClip because that uses Locator.GetPlayerAudioController() instead of owAudioSource for some reason
|
||||||
AttachedObject._effects._owAudioSource.PlayOneShot(global::AudioType.ToolProbeTakePhoto, 1f);
|
AttachedObject._effects._owAudioSource.PlayOneShot(global::AudioType.ToolProbeTakePhoto, 1f);
|
||||||
|
QuantumManager.OnTakeProbeSnapshot(player, cameraId);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,6 +2,7 @@
|
|||||||
using QSB.ItemSync.WorldObjects.Items;
|
using QSB.ItemSync.WorldObjects.Items;
|
||||||
using QSB.Messaging;
|
using QSB.Messaging;
|
||||||
using QSB.Player;
|
using QSB.Player;
|
||||||
|
using QSB.QuantumSync.WorldObjects;
|
||||||
using QSB.RespawnSync;
|
using QSB.RespawnSync;
|
||||||
using QSB.ShipSync;
|
using QSB.ShipSync;
|
||||||
using QSB.Utility.Messages;
|
using QSB.Utility.Messages;
|
||||||
@ -15,7 +16,7 @@ namespace QSB.Utility;
|
|||||||
|
|
||||||
public class DebugActions : MonoBehaviour, IAddComponentOnStart
|
public class DebugActions : MonoBehaviour, IAddComponentOnStart
|
||||||
{
|
{
|
||||||
public static Type WorldObjectSelection;
|
public static Type WorldObjectSelection = typeof(QSBSocketedQuantumObject);
|
||||||
|
|
||||||
private static void GoToVessel()
|
private static void GoToVessel()
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user