mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-26 18:35:34 +00:00
Merge pull request #239 from misternebula/signal-learn-sync
Signal/frequency sync
This commit is contained in:
commit
cbf621e070
@ -37,5 +37,7 @@
|
||||
public static string QSBRevealFact = "QSBRevealFact";
|
||||
public static string QSBSocketStateChange = "QSBSocketStateChange";
|
||||
public static string QSBMultiStateChange = "QSBMultiStateChange";
|
||||
public static string QSBIdentifyFrequency = "QSBIdentifyFrequency";
|
||||
public static string QSBIdentifySignal = "QSBIdentifySignal";
|
||||
}
|
||||
}
|
@ -27,6 +27,8 @@
|
||||
DialogueCondition,
|
||||
RevealFact,
|
||||
SocketStateChange,
|
||||
MultiStateChange
|
||||
MultiStateChange,
|
||||
IdentifyFrequency,
|
||||
IdentifySignal
|
||||
}
|
||||
}
|
@ -3,6 +3,7 @@ using QSB.Animation.Events;
|
||||
using QSB.ConversationSync.Events;
|
||||
using QSB.DeathSync.Events;
|
||||
using QSB.ElevatorSync.Events;
|
||||
using QSB.FrequencySync.Events;
|
||||
using QSB.GeyserSync.Events;
|
||||
using QSB.LogSync.Events;
|
||||
using QSB.OrbSync.Events;
|
||||
@ -48,11 +49,13 @@ namespace QSB.Events
|
||||
new OrbUserEvent(),
|
||||
new SocketStateChangeEvent(),
|
||||
new MultiStateChangeEvent(),
|
||||
// Conversation/dialogue
|
||||
// Conversation/dialogue/exploration
|
||||
new ConversationEvent(),
|
||||
new ConversationStartEndEvent(),
|
||||
new DialogueConditionEvent(),
|
||||
new RevealFactEvent()
|
||||
new RevealFactEvent(),
|
||||
new IdentifyFrequencyEvent(),
|
||||
new IdentifySignalEvent()
|
||||
};
|
||||
|
||||
_eventList.ForEach(ev => ev.SetupListener());
|
||||
|
30
QSB/FrequencySync/Events/IdentifyFrequencyEvent.cs
Normal file
30
QSB/FrequencySync/Events/IdentifyFrequencyEvent.cs
Normal file
@ -0,0 +1,30 @@
|
||||
using QSB.Events;
|
||||
using QSB.Messaging;
|
||||
using QSB.Player;
|
||||
|
||||
namespace QSB.FrequencySync.Events
|
||||
{
|
||||
public class IdentifyFrequencyEvent : QSBEvent<EnumMessage<SignalFrequency>>
|
||||
{
|
||||
public override EventType Type => EventType.IdentifyFrequency;
|
||||
|
||||
public override void SetupListener() => GlobalMessenger<SignalFrequency>.AddListener(EventNames.QSBIdentifyFrequency, Handler);
|
||||
public override void CloseListener() => GlobalMessenger<SignalFrequency>.RemoveListener(EventNames.QSBIdentifyFrequency, Handler);
|
||||
|
||||
private void Handler(SignalFrequency frequency) => SendEvent(CreateMessage(frequency));
|
||||
|
||||
private EnumMessage<SignalFrequency> CreateMessage(SignalFrequency frequency) => new EnumMessage<SignalFrequency>
|
||||
{
|
||||
AboutId = QSBPlayerManager.LocalPlayerId,
|
||||
Value = frequency
|
||||
};
|
||||
|
||||
public override void OnReceiveRemote(bool server, EnumMessage<SignalFrequency> message)
|
||||
{
|
||||
PlayerData.LearnFrequency(message.Value);
|
||||
var displayMsg = $"{UITextLibrary.GetString(UITextType.NotificationNewFreq)} <color=orange>{AudioSignal.FrequencyToString(message.Value, false)}</color>";
|
||||
var data = new NotificationData(NotificationTarget.All, displayMsg, 10f, true);
|
||||
NotificationManager.SharedInstance.PostNotification(data, false);
|
||||
}
|
||||
}
|
||||
}
|
31
QSB/FrequencySync/Events/IdentifySignalEvent.cs
Normal file
31
QSB/FrequencySync/Events/IdentifySignalEvent.cs
Normal file
@ -0,0 +1,31 @@
|
||||
using QSB.Events;
|
||||
using QSB.Messaging;
|
||||
using QSB.Player;
|
||||
|
||||
namespace QSB.FrequencySync.Events
|
||||
{
|
||||
public class IdentifySignalEvent : QSBEvent<EnumMessage<SignalName>>
|
||||
{
|
||||
public override EventType Type => EventType.IdentifySignal;
|
||||
|
||||
public override void SetupListener() => GlobalMessenger<SignalName>.AddListener(EventNames.QSBIdentifySignal, Handler);
|
||||
public override void CloseListener() => GlobalMessenger<SignalName>.RemoveListener(EventNames.QSBIdentifySignal, Handler);
|
||||
|
||||
private void Handler(SignalName name) => SendEvent(CreateMessage(name));
|
||||
|
||||
private EnumMessage<SignalName> CreateMessage(SignalName name) => new EnumMessage<SignalName>
|
||||
{
|
||||
AboutId = QSBPlayerManager.LocalPlayerId,
|
||||
Value = name
|
||||
};
|
||||
|
||||
public override void OnReceiveRemote(bool server, EnumMessage<SignalName> message)
|
||||
{
|
||||
PlayerData.LearnSignal(message.Value);
|
||||
GlobalMessenger.FireEvent("IdentifySignal");
|
||||
var displayMsg = $"{UITextLibrary.GetString(UITextType.NotificationSignalIdentified)} <color=orange>{AudioSignal.SignalNameToString(message.Value)}</color>";
|
||||
var data = new NotificationData(NotificationTarget.All, displayMsg, 10f, true);
|
||||
NotificationManager.SharedInstance.PostNotification(data, false);
|
||||
}
|
||||
}
|
||||
}
|
22
QSB/FrequencySync/FrequencyPatches.cs
Normal file
22
QSB/FrequencySync/FrequencyPatches.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using QSB.Events;
|
||||
using QSB.Patches;
|
||||
|
||||
namespace QSB.FrequencySync
|
||||
{
|
||||
public class FrequencyPatches : QSBPatch
|
||||
{
|
||||
public override QSBPatchTypes Type => QSBPatchTypes.OnClientConnect;
|
||||
|
||||
public override void DoPatches()
|
||||
{
|
||||
QSBCore.Helper.HarmonyHelper.AddPostfix<AudioSignal>("IdentifyFrequency", typeof(FrequencyPatches), nameof(IdentifyFrequency));
|
||||
QSBCore.Helper.HarmonyHelper.AddPostfix<AudioSignal>("IdentifySignal", typeof(FrequencyPatches), nameof(IdentifySignal));
|
||||
}
|
||||
|
||||
public static void IdentifyFrequency(SignalFrequency ____frequency)
|
||||
=> GlobalMessenger<SignalFrequency>.FireEvent(EventNames.QSBIdentifyFrequency, ____frequency);
|
||||
|
||||
public static void IdentifySignal(SignalName ____name)
|
||||
=> GlobalMessenger<SignalName>.FireEvent(EventNames.QSBIdentifySignal, ____name);
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@
|
||||
using QSB.ConversationSync;
|
||||
using QSB.DeathSync;
|
||||
using QSB.ElevatorSync;
|
||||
using QSB.FrequencySync;
|
||||
using QSB.LogSync;
|
||||
using QSB.OrbSync;
|
||||
using QSB.QuantumSync;
|
||||
@ -33,7 +34,8 @@ namespace QSB.Patches
|
||||
new LogPatches(),
|
||||
new QuantumVisibilityPatches(),
|
||||
new ServerQuantumStateChangePatches(),
|
||||
new ClientQuantumStateChangePatches()
|
||||
new ClientQuantumStateChangePatches(),
|
||||
new FrequencyPatches()
|
||||
};
|
||||
|
||||
DebugLog.DebugWrite("Patch Manager ready.", MessageType.Success);
|
||||
|
@ -163,6 +163,9 @@
|
||||
<Compile Include="DeathSync\Events\PlayerDeathEvent.cs" />
|
||||
<Compile Include="Events\IQSBEvent.cs" />
|
||||
<Compile Include="Animation\Events\ChangeAnimTypeEvent.cs" />
|
||||
<Compile Include="FrequencySync\Events\IdentifyFrequencyEvent.cs" />
|
||||
<Compile Include="FrequencySync\Events\IdentifySignalEvent.cs" />
|
||||
<Compile Include="FrequencySync\FrequencyPatches.cs" />
|
||||
<Compile Include="Instruments\QSBCamera\CameraController.cs" />
|
||||
<Compile Include="Instruments\QSBCamera\CameraManager.cs" />
|
||||
<Compile Include="Instruments\QSBCamera\CameraMode.cs" />
|
||||
|
Loading…
x
Reference in New Issue
Block a user