mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-02-28 12:40:28 +00:00
satellite projector stuffz
This commit is contained in:
parent
a53e599364
commit
838940942f
@ -89,5 +89,8 @@
|
|||||||
public static string QSBDebugEvent = "QSBDebugEvent";
|
public static string QSBDebugEvent = "QSBDebugEvent";
|
||||||
public static string QSBEnterNomaiHeadZone = "QSBEnterNomaiHeadZone";
|
public static string QSBEnterNomaiHeadZone = "QSBEnterNomaiHeadZone";
|
||||||
public static string QSBExitNomaiHeadZone = "QSBExitNomaiHeadZone";
|
public static string QSBExitNomaiHeadZone = "QSBExitNomaiHeadZone";
|
||||||
|
public static string QSBEnterSatelliteCamera = "QSBEnterSatelliteCamera";
|
||||||
|
public static string QSBExitSatelliteCamera = "QSBExitSatelliteCamera";
|
||||||
|
public static string QSBSatelliteSnapshot = "QSBSatelliteSnapshot";
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -6,6 +6,8 @@
|
|||||||
* MISC.
|
* MISC.
|
||||||
*/
|
*/
|
||||||
DebugEvent,
|
DebugEvent,
|
||||||
|
SatelliteProjector,
|
||||||
|
SatelliteProjectorSnapshot,
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* SERVER EVENTS
|
* SERVER EVENTS
|
||||||
|
@ -15,6 +15,7 @@ using QSB.Player.Events;
|
|||||||
using QSB.ProbeSync.Events;
|
using QSB.ProbeSync.Events;
|
||||||
using QSB.QuantumSync.Events;
|
using QSB.QuantumSync.Events;
|
||||||
using QSB.RoastingSync.Events;
|
using QSB.RoastingSync.Events;
|
||||||
|
using QSB.SatelliteSync.Events;
|
||||||
using QSB.ShipSync.Events;
|
using QSB.ShipSync.Events;
|
||||||
using QSB.ShipSync.Events.Component;
|
using QSB.ShipSync.Events.Component;
|
||||||
using QSB.ShipSync.Events.Hull;
|
using QSB.ShipSync.Events.Hull;
|
||||||
@ -69,6 +70,7 @@ namespace QSB.Events
|
|||||||
new ServerStateEvent(),
|
new ServerStateEvent(),
|
||||||
new ClientStateEvent(),
|
new ClientStateEvent(),
|
||||||
new DebugEvent(),
|
new DebugEvent(),
|
||||||
|
new SatelliteProjectorEvent(),
|
||||||
// World Objects
|
// World Objects
|
||||||
new ElevatorEvent(),
|
new ElevatorEvent(),
|
||||||
new GeyserEvent(),
|
new GeyserEvent(),
|
||||||
|
@ -16,6 +16,7 @@ using QSB.Player.Patches;
|
|||||||
using QSB.PoolSync.Patches;
|
using QSB.PoolSync.Patches;
|
||||||
using QSB.QuantumSync.Patches;
|
using QSB.QuantumSync.Patches;
|
||||||
using QSB.RoastingSync.Patches;
|
using QSB.RoastingSync.Patches;
|
||||||
|
using QSB.SatelliteSync.Patches;
|
||||||
using QSB.ShipSync.Patches;
|
using QSB.ShipSync.Patches;
|
||||||
using QSB.StatueSync.Patches;
|
using QSB.StatueSync.Patches;
|
||||||
using QSB.TimeSync.Patches;
|
using QSB.TimeSync.Patches;
|
||||||
@ -67,7 +68,8 @@ namespace QSB.Patches
|
|||||||
new MapPatches(),
|
new MapPatches(),
|
||||||
new RespawnPatches(),
|
new RespawnPatches(),
|
||||||
new LauncherPatches(),
|
new LauncherPatches(),
|
||||||
new SolanumPatches()
|
new SolanumPatches(),
|
||||||
|
new SatelliteProjectorPatches()
|
||||||
};
|
};
|
||||||
|
|
||||||
TypeToInstance = new Dictionary<QSBPatchTypes, Harmony>
|
TypeToInstance = new Dictionary<QSBPatchTypes, Harmony>
|
||||||
|
@ -200,6 +200,10 @@
|
|||||||
<Compile Include="QuantumSync\QuantumManager.cs" />
|
<Compile Include="QuantumSync\QuantumManager.cs" />
|
||||||
<Compile Include="QuantumSync\Patches\QuantumVisibilityPatches.cs" />
|
<Compile Include="QuantumSync\Patches\QuantumVisibilityPatches.cs" />
|
||||||
<Compile Include="QuantumSync\Patches\ServerQuantumPatches.cs" />
|
<Compile Include="QuantumSync\Patches\ServerQuantumPatches.cs" />
|
||||||
|
<Compile Include="SatelliteSync\Events\SatelliteProjectorEvent.cs" />
|
||||||
|
<Compile Include="SatelliteSync\Events\SatelliteProjectorSnapshotEvent.cs" />
|
||||||
|
<Compile Include="SatelliteSync\Patches\SatelliteProjectorPatches.cs" />
|
||||||
|
<Compile Include="SatelliteSync\SatelliteProjectorManager.cs" />
|
||||||
<Compile Include="SectorSync\TargetType.cs" />
|
<Compile Include="SectorSync\TargetType.cs" />
|
||||||
<Compile Include="ClientServerStateSync\Events\ServerStateEvent.cs" />
|
<Compile Include="ClientServerStateSync\Events\ServerStateEvent.cs" />
|
||||||
<Compile Include="ClientServerStateSync\ServerState.cs" />
|
<Compile Include="ClientServerStateSync\ServerState.cs" />
|
||||||
|
@ -16,6 +16,7 @@ using QSB.Player;
|
|||||||
using QSB.Player.TransformSync;
|
using QSB.Player.TransformSync;
|
||||||
using QSB.PoolSync;
|
using QSB.PoolSync;
|
||||||
using QSB.QuantumSync;
|
using QSB.QuantumSync;
|
||||||
|
using QSB.SatelliteSync;
|
||||||
using QSB.SectorSync;
|
using QSB.SectorSync;
|
||||||
using QSB.ShipSync;
|
using QSB.ShipSync;
|
||||||
using QSB.StatueSync;
|
using QSB.StatueSync;
|
||||||
@ -102,6 +103,7 @@ namespace QSB
|
|||||||
gameObject.AddComponent<DebugGUI>();
|
gameObject.AddComponent<DebugGUI>();
|
||||||
gameObject.AddComponent<MenuManager>();
|
gameObject.AddComponent<MenuManager>();
|
||||||
gameObject.AddComponent<RespawnManager>();
|
gameObject.AddComponent<RespawnManager>();
|
||||||
|
gameObject.AddComponent<SatelliteProjectorManager>();
|
||||||
|
|
||||||
// WorldObject managers
|
// WorldObject managers
|
||||||
gameObject.AddComponent<QuantumManager>();
|
gameObject.AddComponent<QuantumManager>();
|
||||||
|
42
QSB/SatelliteSync/Events/SatelliteProjectorEvent.cs
Normal file
42
QSB/SatelliteSync/Events/SatelliteProjectorEvent.cs
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
using QSB.Events;
|
||||||
|
using QSB.Messaging;
|
||||||
|
|
||||||
|
namespace QSB.SatelliteSync.Events
|
||||||
|
{
|
||||||
|
class SatelliteProjectorEvent : QSBEvent<BoolMessage>
|
||||||
|
{
|
||||||
|
public override EventType Type => EventType.SatelliteProjector;
|
||||||
|
|
||||||
|
public override void SetupListener()
|
||||||
|
{
|
||||||
|
GlobalMessenger.AddListener(EventNames.QSBEnterSatelliteCamera, () => Handler(true));
|
||||||
|
GlobalMessenger.AddListener(EventNames.QSBExitSatelliteCamera, () => Handler(false));
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void CloseListener()
|
||||||
|
{
|
||||||
|
GlobalMessenger.RemoveListener(EventNames.QSBEnterSatelliteCamera, () => Handler(true));
|
||||||
|
GlobalMessenger.RemoveListener(EventNames.QSBExitSatelliteCamera, () => Handler(false));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Handler(bool usingProjector) => SendEvent(CreateMessage(usingProjector));
|
||||||
|
|
||||||
|
private BoolMessage CreateMessage(bool usingProjector) => new BoolMessage
|
||||||
|
{
|
||||||
|
AboutId = LocalPlayerId,
|
||||||
|
Value = usingProjector
|
||||||
|
};
|
||||||
|
|
||||||
|
public override void OnReceiveRemote(bool isHost, BoolMessage message)
|
||||||
|
{
|
||||||
|
if (message.Value)
|
||||||
|
{
|
||||||
|
SatelliteProjectorManager.Instance.RemoteEnter();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SatelliteProjectorManager.Instance.RemoteExit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
34
QSB/SatelliteSync/Events/SatelliteProjectorSnapshotEvent.cs
Normal file
34
QSB/SatelliteSync/Events/SatelliteProjectorSnapshotEvent.cs
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
using QSB.Events;
|
||||||
|
using QSB.Messaging;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace QSB.SatelliteSync.Events
|
||||||
|
{
|
||||||
|
class SatelliteProjectorSnapshotEvent : QSBEvent<BoolMessage>
|
||||||
|
{
|
||||||
|
public override EventType Type => EventType.SatelliteProjectorSnapshot;
|
||||||
|
|
||||||
|
public override void SetupListener()
|
||||||
|
{
|
||||||
|
GlobalMessenger<bool>.AddListener(EventNames.QSBSatelliteSnapshot, (bool forward) => Handler(forward));
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void CloseListener()
|
||||||
|
{
|
||||||
|
GlobalMessenger<bool>.RemoveListener(EventNames.QSBSatelliteSnapshot, (bool forward) => Handler(forward));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Handler(bool forward) => SendEvent(CreateMessage(forward));
|
||||||
|
|
||||||
|
private BoolMessage CreateMessage(bool forward) => new BoolMessage
|
||||||
|
{
|
||||||
|
AboutId = LocalPlayerId,
|
||||||
|
Value = forward
|
||||||
|
};
|
||||||
|
|
||||||
|
public override void OnReceiveRemote(bool isHost, BoolMessage message) => SatelliteProjectorManager.Instance.RemoteTakeSnapshot(message.Value);
|
||||||
|
}
|
||||||
|
}
|
28
QSB/SatelliteSync/Patches/SatelliteProjectorPatches.cs
Normal file
28
QSB/SatelliteSync/Patches/SatelliteProjectorPatches.cs
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
using HarmonyLib;
|
||||||
|
using QSB.Events;
|
||||||
|
using QSB.Patches;
|
||||||
|
|
||||||
|
namespace QSB.SatelliteSync.Patches
|
||||||
|
{
|
||||||
|
[HarmonyPatch]
|
||||||
|
class SatelliteProjectorPatches : QSBPatch
|
||||||
|
{
|
||||||
|
public override QSBPatchTypes Type => QSBPatchTypes.OnClientConnect;
|
||||||
|
|
||||||
|
[HarmonyPrefix]
|
||||||
|
[HarmonyPatch(typeof(SatelliteSnapshotController), nameof(SatelliteSnapshotController.OnPressInteract))]
|
||||||
|
public static bool UseProjector()
|
||||||
|
{
|
||||||
|
QSBEventManager.FireEvent(EventNames.QSBEnterSatelliteCamera);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HarmonyPrefix]
|
||||||
|
[HarmonyPatch(typeof(SatelliteSnapshotController), nameof(SatelliteSnapshotController.TurnOffProjector))]
|
||||||
|
public static bool LeaveProjector()
|
||||||
|
{
|
||||||
|
QSBEventManager.FireEvent(EventNames.QSBExitSatelliteCamera);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
89
QSB/SatelliteSync/SatelliteProjectorManager.cs
Normal file
89
QSB/SatelliteSync/SatelliteProjectorManager.cs
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
using QSB.Utility;
|
||||||
|
using System.Linq;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace QSB.SatelliteSync
|
||||||
|
{
|
||||||
|
class SatelliteProjectorManager : MonoBehaviour
|
||||||
|
{
|
||||||
|
public static SatelliteProjectorManager Instance { get; private set; }
|
||||||
|
|
||||||
|
public SatelliteSnapshotController Projector { get; private set; }
|
||||||
|
|
||||||
|
public void Start()
|
||||||
|
{
|
||||||
|
Instance = this;
|
||||||
|
QSBSceneManager.OnUniverseSceneLoaded += OnSceneLoaded;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnDestroy()
|
||||||
|
{
|
||||||
|
QSBSceneManager.OnUniverseSceneLoaded -= OnSceneLoaded;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnSceneLoaded(OWScene oldScene, OWScene newScene)
|
||||||
|
{
|
||||||
|
if (newScene == OWScene.SolarSystem)
|
||||||
|
{
|
||||||
|
Projector = Resources.FindObjectsOfTypeAll<SatelliteSnapshotController>().First();
|
||||||
|
Projector._loopingSource.spatialBlend = 1f;
|
||||||
|
Projector._oneShotSource.spatialBlend = 1f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RemoteEnter()
|
||||||
|
{
|
||||||
|
DebugLog.DebugWrite($"Remote Enter");
|
||||||
|
|
||||||
|
Projector.enabled = true;
|
||||||
|
Projector._interactVolume.DisableInteraction();
|
||||||
|
|
||||||
|
if (Projector._showSplashTexture)
|
||||||
|
{
|
||||||
|
Projector._splashObject.SetActive(false);
|
||||||
|
Projector._diagramObject.SetActive(true);
|
||||||
|
Projector._projectionScreen.gameObject.SetActive(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Projector._fadeLight != null)
|
||||||
|
{
|
||||||
|
Projector._fadeLight.StartFade(0f, 2f, 0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
var audioClip = Projector._oneShotSource.PlayOneShot(AudioType.TH_ProjectorActivate, 1f);
|
||||||
|
Projector._loopingSource.FadeIn(audioClip.length, false, false, 1f);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RemoteExit()
|
||||||
|
{
|
||||||
|
DebugLog.DebugWrite($"Remote Exit");
|
||||||
|
|
||||||
|
Projector.enabled = false;
|
||||||
|
Projector._interactVolume.ResetInteraction();
|
||||||
|
|
||||||
|
if (Projector._showSplashTexture)
|
||||||
|
{
|
||||||
|
Projector._splashObject.SetActive(true);
|
||||||
|
Projector._diagramObject.SetActive(false);
|
||||||
|
Projector._projectionScreen.gameObject.SetActive(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Projector._fadeLight != null)
|
||||||
|
{
|
||||||
|
Projector._fadeLight.StartFade(Projector._initLightIntensity, 2f, 0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
var audioClip = Projector._oneShotSource.PlayOneShot(AudioType.TH_ProjectorStop, 1f);
|
||||||
|
Projector._loopingSource.FadeOut(audioClip.length, OWAudioSource.FadeOutCompleteAction.STOP, 0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RemoteTakeSnapshot(bool forward)
|
||||||
|
{
|
||||||
|
Projector._satelliteCamera.transform.localEulerAngles = forward
|
||||||
|
? Projector._initCamLocalRot
|
||||||
|
: Projector._initCamLocalRot + new Vector3(0f, 180f, 0f);
|
||||||
|
|
||||||
|
Projector.RenderSnapshot();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -71,12 +71,20 @@ namespace QSB.Tools.ProbeLauncherTool.Patches
|
|||||||
// TODO : ehhhh idk about this. maybe copy each sound source so we have a 2d version (for local) and a 3d version (for remote)?
|
// TODO : ehhhh idk about this. maybe copy each sound source so we have a 2d version (for local) and a 3d version (for remote)?
|
||||||
// this would probably be a whole qsb version on it's own
|
// this would probably be a whole qsb version on it's own
|
||||||
|
|
||||||
[HarmonyPostfix]
|
[HarmonyPrefix]
|
||||||
[HarmonyPatch(typeof(ProbeLauncherEffects), nameof(ProbeLauncherEffects.PlayRetrievalClip))]
|
[HarmonyPatch(typeof(ProbeLauncherEffects), nameof(ProbeLauncherEffects.PlayRetrievalClip))]
|
||||||
public static void ProbeLauncherEffects_PlayRetrievalClip(OWAudioSource ____owAudioSource) => ____owAudioSource.GetAudioSource().spatialBlend = 1f;
|
public static bool ProbeLauncherEffects_PlayRetrievalClip(OWAudioSource ____owAudioSource)
|
||||||
|
{
|
||||||
|
____owAudioSource.GetAudioSource().spatialBlend = 1f;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
[HarmonyPostfix]
|
[HarmonyPrefix]
|
||||||
[HarmonyPatch(typeof(ProbeLauncherEffects), nameof(ProbeLauncherEffects.PlayLaunchClip))]
|
[HarmonyPatch(typeof(ProbeLauncherEffects), nameof(ProbeLauncherEffects.PlayLaunchClip))]
|
||||||
public static void ProbeLauncherEffects_PlayLaunchClip(OWAudioSource ____owAudioSource) => ____owAudioSource.GetAudioSource().spatialBlend = 1f;
|
public static bool ProbeLauncherEffects_PlayLaunchClip(OWAudioSource ____owAudioSource)
|
||||||
|
{
|
||||||
|
____owAudioSource.GetAudioSource().spatialBlend = 1f;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
"settings": {
|
"settings": {
|
||||||
"defaultServerIP": "localhost",
|
"defaultServerIP": "localhost",
|
||||||
"port": 7777,
|
"port": 7777,
|
||||||
"debugMode": false,
|
"debugMode": true,
|
||||||
"showLinesInDebug": false
|
"showLinesInDebug": false
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user