mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-02-15 18:39:50 +00:00
add launch probe event
This commit is contained in:
parent
d822b74e93
commit
84544a6834
@ -79,5 +79,6 @@
|
|||||||
public static string QSBProbeEvent = "QSBProbeEvent";
|
public static string QSBProbeEvent = "QSBProbeEvent";
|
||||||
public static string QSBProbeStartRetrieve = "QSBProbeStartRetrieve";
|
public static string QSBProbeStartRetrieve = "QSBProbeStartRetrieve";
|
||||||
public static string QSBRetrieveProbe = "QSBRetrieveProbe";
|
public static string QSBRetrieveProbe = "QSBRetrieveProbe";
|
||||||
|
public static string QSBLaunchProbe = "QSBLaunchProbe";
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -117,5 +117,6 @@
|
|||||||
// Probe Launcher
|
// Probe Launcher
|
||||||
RetrieveProbe,
|
RetrieveProbe,
|
||||||
ProbeLauncherActiveChange,
|
ProbeLauncherActiveChange,
|
||||||
|
LaunchProbe
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -59,6 +59,7 @@ namespace QSB.Events
|
|||||||
new PlayerRespawnEvent(),
|
new PlayerRespawnEvent(),
|
||||||
new ProbeStartRetrieveEvent(),
|
new ProbeStartRetrieveEvent(),
|
||||||
new RetrieveProbeEvent(),
|
new RetrieveProbeEvent(),
|
||||||
|
new LaunchProbeEvent(),
|
||||||
// World Objects
|
// World Objects
|
||||||
new ElevatorEvent(),
|
new ElevatorEvent(),
|
||||||
new GeyserEvent(),
|
new GeyserEvent(),
|
||||||
|
@ -272,6 +272,7 @@
|
|||||||
<Compile Include="Syncs\RigidbodySync\SectoredRigidbodySync.cs" />
|
<Compile Include="Syncs\RigidbodySync\SectoredRigidbodySync.cs" />
|
||||||
<Compile Include="Syncs\SyncBase.cs" />
|
<Compile Include="Syncs\SyncBase.cs" />
|
||||||
<Compile Include="TimeSync\Patches\TimePatches.cs" />
|
<Compile Include="TimeSync\Patches\TimePatches.cs" />
|
||||||
|
<Compile Include="Tools\ProbeLauncherTool\Events\LaunchProbeEvent.cs" />
|
||||||
<Compile Include="Tools\ProbeLauncherTool\Events\RetrieveProbeEvent.cs" />
|
<Compile Include="Tools\ProbeLauncherTool\Events\RetrieveProbeEvent.cs" />
|
||||||
<Compile Include="Tools\ProbeLauncherTool\Patches\LauncherPatches.cs" />
|
<Compile Include="Tools\ProbeLauncherTool\Patches\LauncherPatches.cs" />
|
||||||
<Compile Include="Tools\ProbeLauncherTool\ProbeLauncherManager.cs" />
|
<Compile Include="Tools\ProbeLauncherTool\ProbeLauncherManager.cs" />
|
||||||
|
32
QSB/Tools/ProbeLauncherTool/Events/LaunchProbeEvent.cs
Normal file
32
QSB/Tools/ProbeLauncherTool/Events/LaunchProbeEvent.cs
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
using QSB.Events;
|
||||||
|
using QSB.Tools.ProbeLauncherTool.WorldObjects;
|
||||||
|
using QSB.WorldSync;
|
||||||
|
using QSB.WorldSync.Events;
|
||||||
|
|
||||||
|
namespace QSB.Tools.ProbeLauncherTool.Events
|
||||||
|
{
|
||||||
|
class LaunchProbeEvent : QSBEvent<WorldObjectMessage>
|
||||||
|
{
|
||||||
|
public override EventType Type => EventType.LaunchProbe;
|
||||||
|
|
||||||
|
public override void SetupListener()
|
||||||
|
=> GlobalMessenger<QSBProbeLauncher>.AddListener(EventNames.QSBLaunchProbe, Handler);
|
||||||
|
|
||||||
|
public override void CloseListener()
|
||||||
|
=> GlobalMessenger<QSBProbeLauncher>.RemoveListener(EventNames.QSBLaunchProbe, Handler);
|
||||||
|
|
||||||
|
private void Handler(QSBProbeLauncher launcher) => SendEvent(CreateMessage(launcher));
|
||||||
|
|
||||||
|
private BoolWorldObjectMessage CreateMessage(QSBProbeLauncher launcher) => new BoolWorldObjectMessage
|
||||||
|
{
|
||||||
|
AboutId = LocalPlayerId,
|
||||||
|
ObjectId = launcher.ObjectId
|
||||||
|
};
|
||||||
|
|
||||||
|
public override void OnReceiveRemote(bool server, WorldObjectMessage message)
|
||||||
|
{
|
||||||
|
var worldObject = QSBWorldSync.GetWorldFromId<QSBProbeLauncher>(message.ObjectId);
|
||||||
|
worldObject.LaunchProbe();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,7 +1,6 @@
|
|||||||
using QSB.Events;
|
using QSB.Events;
|
||||||
using QSB.TimeSync.Events;
|
using QSB.TimeSync.Events;
|
||||||
using QSB.Tools.ProbeLauncherTool.WorldObjects;
|
using QSB.Tools.ProbeLauncherTool.WorldObjects;
|
||||||
using QSB.Utility;
|
|
||||||
using QSB.WorldSync;
|
using QSB.WorldSync;
|
||||||
using QSB.WorldSync.Events;
|
using QSB.WorldSync.Events;
|
||||||
|
|
||||||
@ -28,7 +27,6 @@ namespace QSB.Tools.ProbeLauncherTool.Events
|
|||||||
|
|
||||||
public override void OnReceiveRemote(bool server, BoolWorldObjectMessage message)
|
public override void OnReceiveRemote(bool server, BoolWorldObjectMessage message)
|
||||||
{
|
{
|
||||||
DebugLog.DebugWrite($"receive retrieve event id:{message.ObjectId} playEffects:{message.State}");
|
|
||||||
var worldObject = QSBWorldSync.GetWorldFromId<QSBProbeLauncher>(message.ObjectId);
|
var worldObject = QSBWorldSync.GetWorldFromId<QSBProbeLauncher>(message.ObjectId);
|
||||||
worldObject.RetrieveProbe(message.State);
|
worldObject.RetrieveProbe(message.State);
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,8 @@ namespace QSB.Tools.ProbeLauncherTool.Patches
|
|||||||
public override void DoPatches()
|
public override void DoPatches()
|
||||||
{
|
{
|
||||||
Prefix(nameof(ProbeLauncher_RetrieveProbe));
|
Prefix(nameof(ProbeLauncher_RetrieveProbe));
|
||||||
|
Postfix(nameof(ProbeLauncherEffects_PlayRetrievalClip));
|
||||||
|
Postfix(nameof(ProbeLauncherEffects_PlayLaunchClip));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool ProbeLauncher_RetrieveProbe(
|
public static bool ProbeLauncher_RetrieveProbe(
|
||||||
@ -66,5 +68,18 @@ namespace QSB.Tools.ProbeLauncherTool.Patches
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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
|
||||||
|
|
||||||
|
public static void ProbeLauncherEffects_PlayRetrievalClip(OWAudioSource ____owAudioSource)
|
||||||
|
{
|
||||||
|
____owAudioSource.GetAudioSource().spatialBlend = 1f;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void ProbeLauncherEffects_PlayLaunchClip(OWAudioSource ____owAudioSource)
|
||||||
|
{
|
||||||
|
____owAudioSource.GetAudioSource().spatialBlend = 1f;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using OWML.Utils;
|
using OWML.Utils;
|
||||||
|
using QSB.Events;
|
||||||
using QSB.ProbeSync;
|
using QSB.ProbeSync;
|
||||||
using QSB.Utility;
|
using QSB.Utility;
|
||||||
using QSB.WorldSync;
|
using QSB.WorldSync;
|
||||||
@ -21,12 +22,12 @@ namespace QSB.Tools.ProbeLauncherTool.WorldObjects
|
|||||||
_preLaunchProbeProxy = AttachedObject.GetValue<GameObject>("_preLaunchProbeProxy");
|
_preLaunchProbeProxy = AttachedObject.GetValue<GameObject>("_preLaunchProbeProxy");
|
||||||
_effects = AttachedObject.GetValue<ProbeLauncherEffects>("_effects");
|
_effects = AttachedObject.GetValue<ProbeLauncherEffects>("_effects");
|
||||||
_probeRetrievalEffect = AttachedObject.GetValue<SingularityWarpEffect>("_probeRetrievalEffect");
|
_probeRetrievalEffect = AttachedObject.GetValue<SingularityWarpEffect>("_probeRetrievalEffect");
|
||||||
|
|
||||||
|
AttachedObject.OnLaunchProbe += (SurveyorProbe probe) => QSBEventManager.FireEvent(EventNames.QSBLaunchProbe, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RetrieveProbe(bool playEffects)
|
public void RetrieveProbe(bool playEffects)
|
||||||
{
|
{
|
||||||
DebugLog.DebugWrite($"{ObjectId} ({AttachedObject.name}) RETRIEVE");
|
|
||||||
|
|
||||||
_preLaunchProbeProxy.SetActive(true);
|
_preLaunchProbeProxy.SetActive(true);
|
||||||
if (playEffects)
|
if (playEffects)
|
||||||
{
|
{
|
||||||
@ -34,5 +35,14 @@ namespace QSB.Tools.ProbeLauncherTool.WorldObjects
|
|||||||
_probeRetrievalEffect.WarpObjectIn(_probeRetrievalLength);
|
_probeRetrievalEffect.WarpObjectIn(_probeRetrievalLength);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void LaunchProbe()
|
||||||
|
{
|
||||||
|
_preLaunchProbeProxy.SetActive(false);
|
||||||
|
|
||||||
|
// TODO : make this do underwater stuff correctly
|
||||||
|
_effects.PlayLaunchClip(false);
|
||||||
|
_effects.PlayLaunchParticles(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user