mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-02-11 06:40:39 +00:00
Sync snapshot and change mode audio for probe launchers
This commit is contained in:
parent
6f6c2f212d
commit
61aed0f6b3
16
QSB/Tools/ProbeLauncherTool/Messages/ChangeModeMessage.cs
Normal file
16
QSB/Tools/ProbeLauncherTool/Messages/ChangeModeMessage.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using QSB.Messaging;
|
||||
using QSB.Tools.ProbeLauncherTool.WorldObjects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace QSB.Tools.ProbeLauncherTool.Messages;
|
||||
|
||||
internal class ChangeModeMessage : QSBWorldObjectMessage<QSBProbeLauncher>
|
||||
{
|
||||
public ChangeModeMessage() : base() { }
|
||||
|
||||
public override void OnReceiveRemote() => WorldObject.ChangeMode();
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
using QSB.Messaging;
|
||||
using QSB.Player;
|
||||
using QSB.WorldSync;
|
||||
|
||||
namespace QSB.Tools.ProbeLauncherTool.Messages;
|
||||
|
||||
internal class PlayerLauncherChangeModeMessage : QSBMessage
|
||||
{
|
||||
public override bool ShouldReceive => QSBWorldSync.AllObjectsReady;
|
||||
|
||||
public override void OnReceiveRemote()
|
||||
{
|
||||
var player = QSBPlayerManager.GetPlayer(From);
|
||||
player.ProbeLauncherTool.ChangeMode();
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
using QSB.Messaging;
|
||||
using QSB.Player;
|
||||
using QSB.WorldSync;
|
||||
|
||||
namespace QSB.Tools.ProbeLauncherTool.Messages;
|
||||
|
||||
internal class PlayerLauncherTakeSnapshotMessage : QSBMessage
|
||||
{
|
||||
public override bool ShouldReceive => QSBWorldSync.AllObjectsReady;
|
||||
|
||||
public override void OnReceiveRemote()
|
||||
{
|
||||
var player = QSBPlayerManager.GetPlayer(From);
|
||||
player.ProbeLauncherTool.TakeSnapshot();
|
||||
}
|
||||
}
|
16
QSB/Tools/ProbeLauncherTool/Messages/TakeSnapshotMessage.cs
Normal file
16
QSB/Tools/ProbeLauncherTool/Messages/TakeSnapshotMessage.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using QSB.Messaging;
|
||||
using QSB.Tools.ProbeLauncherTool.WorldObjects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace QSB.Tools.ProbeLauncherTool.Messages;
|
||||
|
||||
internal class TakeSnapshotMessage : QSBWorldObjectMessage<QSBProbeLauncher>
|
||||
{
|
||||
public TakeSnapshotMessage() : base() { }
|
||||
|
||||
public override void OnReceiveRemote() => WorldObject.TakeSnapshot();
|
||||
}
|
@ -89,4 +89,34 @@ internal class LauncherPatches : QSBPatch
|
||||
__instance._owAudioSource.GetAudioSource().spatialBlend = 1f;
|
||||
return true;
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(ProbeLauncherEffects), nameof(ProbeLauncherEffects.PlayChangeModeClip))]
|
||||
public static void ProbeLauncherEffects_PlayChangeModeClip(ProbeLauncherEffects __instance)
|
||||
{
|
||||
if (__instance != QSBPlayerManager.LocalPlayer.LocalProbeLauncher._effects)
|
||||
{
|
||||
__instance.gameObject.GetComponent<ProbeLauncher>().GetWorldObject<QSBProbeLauncher>()
|
||||
.SendMessage(new ChangeModeMessage());
|
||||
}
|
||||
else
|
||||
{
|
||||
new PlayerLauncherChangeModeMessage().Send();
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(ProbeLauncherEffects), nameof(ProbeLauncherEffects.PlaySnapshotClip))]
|
||||
public static void ProbeLauncherEffects_PlaySnapshotClip(ProbeLauncherEffects __instance)
|
||||
{
|
||||
if (__instance != QSBPlayerManager.LocalPlayer.LocalProbeLauncher._effects)
|
||||
{
|
||||
__instance.gameObject.GetComponent<ProbeLauncher>().GetWorldObject<QSBProbeLauncher>()
|
||||
.SendMessage(new TakeSnapshotMessage());
|
||||
}
|
||||
else
|
||||
{
|
||||
new PlayerLauncherTakeSnapshotMessage().Send();
|
||||
}
|
||||
}
|
||||
}
|
@ -8,12 +8,17 @@ public class QSBProbeLauncherTool : QSBTool
|
||||
public ProbeLauncherEffects Effects;
|
||||
public SingularityWarpEffect ProbeRetrievalEffect;
|
||||
|
||||
public void RetrieveProbe(bool playEffects)
|
||||
private void VerifyAudioSource()
|
||||
{
|
||||
if (Effects._owAudioSource == null)
|
||||
{
|
||||
Effects._owAudioSource = Player.AudioController._repairToolSource;
|
||||
}
|
||||
}
|
||||
|
||||
public void RetrieveProbe(bool playEffects)
|
||||
{
|
||||
VerifyAudioSource();
|
||||
|
||||
PreLaunchProbeProxy.SetActive(true);
|
||||
if (playEffects)
|
||||
@ -27,13 +32,25 @@ public class QSBProbeLauncherTool : QSBTool
|
||||
{
|
||||
PreLaunchProbeProxy.SetActive(false);
|
||||
|
||||
if (Effects._owAudioSource == null)
|
||||
{
|
||||
Effects._owAudioSource = Player.AudioController._repairToolSource;
|
||||
}
|
||||
VerifyAudioSource();
|
||||
|
||||
// TODO : make this do underwater stuff correctly
|
||||
Effects.PlayLaunchClip(false);
|
||||
Effects.PlayLaunchParticles(false);
|
||||
}
|
||||
|
||||
public void ChangeMode()
|
||||
{
|
||||
VerifyAudioSource();
|
||||
|
||||
Effects.PlayChangeModeClip();
|
||||
}
|
||||
|
||||
public void TakeSnapshot()
|
||||
{
|
||||
VerifyAudioSource();
|
||||
|
||||
// Vanilla method uses the global player audio controller -> bad
|
||||
Effects._owAudioSource.PlayOneShot(global::AudioType.ToolProbeTakePhoto, 1f);
|
||||
}
|
||||
}
|
@ -60,4 +60,15 @@ public class QSBProbeLauncher : WorldObject<ProbeLauncher>
|
||||
AttachedObject._effects.PlayLaunchParticles(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void ChangeMode()
|
||||
{
|
||||
AttachedObject._effects.PlayChangeModeClip();
|
||||
}
|
||||
|
||||
public void TakeSnapshot()
|
||||
{
|
||||
// Not using PlaySnapshotClip because that uses Locator.GetPlayerAudioController() instead of owAudioSource for some reason
|
||||
AttachedObject._effects._owAudioSource.PlayOneShot(global::AudioType.ToolProbeTakePhoto, 1f);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user