mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-02-20 15:41:01 +00:00
add retrieve probe event (from non-player probe launchers)
This commit is contained in:
parent
6150d2b919
commit
1e4c0048c6
@ -78,5 +78,6 @@
|
||||
public static string QSBPlayerRespawn = "QSBPlayerRespawn";
|
||||
public static string QSBProbeEvent = "QSBProbeEvent";
|
||||
public static string QSBProbeStartRetrieve = "QSBProbeStartRetrieve";
|
||||
public static string QSBRetrieveProbe = "QSBRetrieveProbe";
|
||||
}
|
||||
}
|
@ -55,6 +55,7 @@
|
||||
ComponentRepaired,
|
||||
ComponentRepairTick,
|
||||
PlayerRespawn,
|
||||
ProbeStartRetrieve
|
||||
ProbeStartRetrieve,
|
||||
RetrieveProbe
|
||||
}
|
||||
}
|
@ -20,6 +20,7 @@ using QSB.ShipSync.Events.Hull;
|
||||
using QSB.StatueSync.Events;
|
||||
using QSB.TimeSync.Events;
|
||||
using QSB.Tools.Events;
|
||||
using QSB.Tools.ProbeLauncherTool.Events;
|
||||
using QSB.TranslationSync.Events;
|
||||
using QSB.Utility;
|
||||
using System.Collections.Generic;
|
||||
@ -57,6 +58,7 @@ namespace QSB.Events
|
||||
new AnimationTriggerEvent(),
|
||||
new PlayerRespawnEvent(),
|
||||
new ProbeStartRetrieveEvent(),
|
||||
new RetrieveProbeEvent(),
|
||||
// World Objects
|
||||
new ElevatorEvent(),
|
||||
new GeyserEvent(),
|
||||
|
@ -18,6 +18,7 @@ using QSB.RoastingSync.Patches;
|
||||
using QSB.ShipSync.Patches;
|
||||
using QSB.StatueSync.Patches;
|
||||
using QSB.TimeSync.Patches;
|
||||
using QSB.Tools.ProbeLauncherTool.Patches;
|
||||
using QSB.TranslationSync.Patches;
|
||||
using QSB.Utility;
|
||||
using System;
|
||||
@ -61,7 +62,8 @@ namespace QSB.Patches
|
||||
new InputPatches(),
|
||||
new TimePatches(),
|
||||
new MapPatches(),
|
||||
new RespawnPatches()
|
||||
new RespawnPatches(),
|
||||
new LauncherPatches()
|
||||
};
|
||||
|
||||
DebugLog.DebugWrite("Patch Manager ready.", MessageType.Success);
|
||||
|
@ -272,6 +272,11 @@
|
||||
<Compile Include="Syncs\RigidbodySync\SectoredRigidbodySync.cs" />
|
||||
<Compile Include="Syncs\SyncBase.cs" />
|
||||
<Compile Include="TimeSync\Patches\TimePatches.cs" />
|
||||
<Compile Include="Tools\ProbeLauncherTool\Events\RetrieveProbeEvent.cs" />
|
||||
<Compile Include="Tools\ProbeLauncherTool\Patches\LauncherPatches.cs" />
|
||||
<Compile Include="Tools\ProbeLauncherTool\ProbeLauncherManager.cs" />
|
||||
<Compile Include="Tools\ProbeLauncherTool\QSBRemotePlayerProbeLauncher.cs" />
|
||||
<Compile Include="Tools\ProbeLauncherTool\WorldObjects\QSBProbeLauncher.cs" />
|
||||
<Compile Include="Utility\CustomRelativisticParticleSystem.cs" />
|
||||
<Compile Include="RoastingSync\QSBMarshmallow.cs" />
|
||||
<Compile Include="RoastingSync\Events\EnterExitRoastingEvent.cs" />
|
||||
|
@ -20,6 +20,7 @@ using QSB.SectorSync;
|
||||
using QSB.ShipSync;
|
||||
using QSB.StatueSync;
|
||||
using QSB.TimeSync;
|
||||
using QSB.Tools.ProbeLauncherTool;
|
||||
using QSB.TranslationSync;
|
||||
using QSB.Utility;
|
||||
using QSB.WorldSync;
|
||||
@ -105,6 +106,7 @@ namespace QSB
|
||||
gameObject.AddComponent<CampfireManager>();
|
||||
gameObject.AddComponent<CharacterAnimManager>();
|
||||
gameObject.AddComponent<ShipManager>();
|
||||
gameObject.AddComponent<ProbeLauncherManager>();
|
||||
|
||||
DebugBoxManager.Init();
|
||||
|
||||
|
36
QSB/Tools/ProbeLauncherTool/Events/RetrieveProbeEvent.cs
Normal file
36
QSB/Tools/ProbeLauncherTool/Events/RetrieveProbeEvent.cs
Normal file
@ -0,0 +1,36 @@
|
||||
using QSB.Events;
|
||||
using QSB.TimeSync.Events;
|
||||
using QSB.Tools.ProbeLauncherTool.WorldObjects;
|
||||
using QSB.Utility;
|
||||
using QSB.WorldSync;
|
||||
using QSB.WorldSync.Events;
|
||||
|
||||
namespace QSB.Tools.ProbeLauncherTool.Events
|
||||
{
|
||||
class RetrieveProbeEvent : QSBEvent<BoolWorldObjectMessage>
|
||||
{
|
||||
public override EventType Type => EventType.RetrieveProbe;
|
||||
|
||||
public override void SetupListener()
|
||||
=> GlobalMessenger<QSBProbeLauncher, bool>.AddListener(EventNames.QSBRetrieveProbe, Handler);
|
||||
|
||||
public override void CloseListener()
|
||||
=> GlobalMessenger<QSBProbeLauncher, bool>.RemoveListener(EventNames.QSBRetrieveProbe, Handler);
|
||||
|
||||
private void Handler(QSBProbeLauncher launcher, bool playEffects) => SendEvent(CreateMessage(launcher, playEffects));
|
||||
|
||||
private BoolWorldObjectMessage CreateMessage(QSBProbeLauncher launcher, bool playEffects) => new BoolWorldObjectMessage
|
||||
{
|
||||
AboutId = LocalPlayerId,
|
||||
ObjectId = launcher.ObjectId,
|
||||
State = playEffects
|
||||
};
|
||||
|
||||
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);
|
||||
worldObject.RetrieveProbe(message.State);
|
||||
}
|
||||
}
|
||||
}
|
70
QSB/Tools/ProbeLauncherTool/Patches/LauncherPatches.cs
Normal file
70
QSB/Tools/ProbeLauncherTool/Patches/LauncherPatches.cs
Normal file
@ -0,0 +1,70 @@
|
||||
using QSB.Events;
|
||||
using QSB.Patches;
|
||||
using QSB.Player;
|
||||
using QSB.Tools.ProbeLauncherTool.WorldObjects;
|
||||
using QSB.Utility;
|
||||
using QSB.WorldSync;
|
||||
using UnityEngine;
|
||||
|
||||
namespace QSB.Tools.ProbeLauncherTool.Patches
|
||||
{
|
||||
class LauncherPatches : QSBPatch
|
||||
{
|
||||
public override QSBPatchTypes Type => QSBPatchTypes.OnClientConnect;
|
||||
|
||||
public override void DoPatches()
|
||||
{
|
||||
Prefix(nameof(ProbeLauncher_RetrieveProbe));
|
||||
}
|
||||
|
||||
public static bool ProbeLauncher_RetrieveProbe(
|
||||
ProbeLauncher __instance,
|
||||
bool playEffects,
|
||||
bool forcedRetrieval,
|
||||
ref bool ____isRetrieving,
|
||||
SurveyorProbe ____activeProbe,
|
||||
NotificationTarget ____notificationFilter,
|
||||
GameObject ____preLaunchProbeProxy,
|
||||
ProbeLauncherEffects ____effects,
|
||||
SingularityWarpEffect ____probeRetrievalEffect,
|
||||
float ____probeRetrievalLength)
|
||||
{
|
||||
if (__instance == QSBPlayerManager.LocalPlayer.LocalProbeLauncher)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (____isRetrieving)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (____activeProbe != null)
|
||||
{
|
||||
if (____activeProbe.IsLaunched() && TimelineObliterationController.IsParadoxProbeActive() && !forcedRetrieval)
|
||||
{
|
||||
var data = new NotificationData(____notificationFilter, UITextLibrary.GetString(UITextType.NotificationMultProbe), 3f, true);
|
||||
NotificationManager.SharedInstance.PostNotification(data, false);
|
||||
Locator.GetPlayerAudioController().PlayNegativeUISound();
|
||||
return false;
|
||||
}
|
||||
|
||||
____activeProbe.GetRotatingCamera().ResetRotation();
|
||||
____preLaunchProbeProxy.SetActive(true);
|
||||
if (playEffects)
|
||||
{
|
||||
____effects.PlayRetrievalClip();
|
||||
____probeRetrievalEffect.WarpObjectIn(____probeRetrievalLength);
|
||||
}
|
||||
|
||||
DebugLog.DebugWrite($"{__instance.name} retrieve probe playEffects:{playEffects}");
|
||||
|
||||
QSBEventManager.FireEvent(EventNames.QSBRetrieveProbe, QSBWorldSync.GetWorldFromUnity<QSBProbeLauncher, ProbeLauncher>(__instance), playEffects);
|
||||
____activeProbe.Retrieve(____probeRetrievalLength);
|
||||
____isRetrieving = true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
11
QSB/Tools/ProbeLauncherTool/ProbeLauncherManager.cs
Normal file
11
QSB/Tools/ProbeLauncherTool/ProbeLauncherManager.cs
Normal file
@ -0,0 +1,11 @@
|
||||
using QSB.Tools.ProbeLauncherTool.WorldObjects;
|
||||
using QSB.WorldSync;
|
||||
|
||||
namespace QSB.Tools.ProbeLauncherTool
|
||||
{
|
||||
class ProbeLauncherManager : WorldObjectManager
|
||||
{
|
||||
protected override void RebuildWorldObjects(OWScene scene)
|
||||
=> QSBWorldSync.Init<QSBProbeLauncher, ProbeLauncher>();
|
||||
}
|
||||
}
|
11
QSB/Tools/ProbeLauncherTool/QSBRemotePlayerProbeLauncher.cs
Normal file
11
QSB/Tools/ProbeLauncherTool/QSBRemotePlayerProbeLauncher.cs
Normal file
@ -0,0 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace QSB.Tools.ProbeLauncherTool
|
||||
{
|
||||
class QSBRemotePlayerProbeLauncher
|
||||
{
|
||||
}
|
||||
}
|
44
QSB/Tools/ProbeLauncherTool/WorldObjects/QSBProbeLauncher.cs
Normal file
44
QSB/Tools/ProbeLauncherTool/WorldObjects/QSBProbeLauncher.cs
Normal file
@ -0,0 +1,44 @@
|
||||
using OWML.Utils;
|
||||
using QSB.ProbeSync;
|
||||
using QSB.Utility;
|
||||
using QSB.WorldSync;
|
||||
using UnityEngine;
|
||||
|
||||
namespace QSB.Tools.ProbeLauncherTool.WorldObjects
|
||||
{
|
||||
class QSBProbeLauncher : WorldObject<ProbeLauncher>
|
||||
{
|
||||
private bool _isRetrieving;
|
||||
private float _probeRetrievalLength;
|
||||
private GameObject _preLaunchProbeProxy;
|
||||
private ProbeLauncherEffects _effects;
|
||||
private SingularityWarpEffect _probeRetrievalEffect;
|
||||
|
||||
public override void Init(ProbeLauncher launcher, int id)
|
||||
{
|
||||
ObjectId = id;
|
||||
AttachedObject = launcher;
|
||||
_probeRetrievalLength = AttachedObject.GetValue<float>("_probeRetrievalLength");
|
||||
_preLaunchProbeProxy = AttachedObject.GetValue<GameObject>("_preLaunchProbeProxy");
|
||||
_effects = AttachedObject.GetValue<ProbeLauncherEffects>("_effects");
|
||||
_probeRetrievalEffect = AttachedObject.GetValue<SingularityWarpEffect>("_probeRetrievalEffect");
|
||||
}
|
||||
|
||||
public void RetrieveProbe(bool playEffects)
|
||||
{
|
||||
DebugLog.DebugWrite($"{ObjectId} ({AttachedObject.name}) RETRIEVE");
|
||||
if (_isRetrieving)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_preLaunchProbeProxy.SetActive(true);
|
||||
if (playEffects)
|
||||
{
|
||||
_effects.PlayRetrievalClip();
|
||||
_probeRetrievalEffect.WarpObjectIn(_probeRetrievalLength);
|
||||
}
|
||||
_isRetrieving = true;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user