mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-29 09:32:38 +00:00
add KnownSignals
This commit is contained in:
parent
5b15d26bea
commit
61e43cec21
@ -1,8 +1,6 @@
|
||||
using QSB.Events;
|
||||
using QSB.Menus;
|
||||
using QSB.Utility;
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace QSB.SaveSync.Events
|
||||
{
|
||||
@ -11,18 +9,20 @@ namespace QSB.SaveSync.Events
|
||||
{
|
||||
public override bool RequireWorldObjectsReady => false;
|
||||
|
||||
public override void SetupListener() => GlobalMessenger.AddListener(EventNames.QSBGameDetails, Handler);
|
||||
public override void CloseListener() => GlobalMessenger.RemoveListener(EventNames.QSBGameDetails, Handler);
|
||||
public override void SetupListener() => GlobalMessenger<uint>.AddListener(EventNames.QSBGameDetails, Handler);
|
||||
public override void CloseListener() => GlobalMessenger<uint>.RemoveListener(EventNames.QSBGameDetails, Handler);
|
||||
|
||||
private void Handler() => SendEvent(CreateMessage());
|
||||
private void Handler(uint toId) => SendEvent(CreateMessage(toId));
|
||||
|
||||
private GameStateMessage CreateMessage() => new()
|
||||
private GameStateMessage CreateMessage(uint toId) => new()
|
||||
{
|
||||
AboutId = LocalPlayerId,
|
||||
ToId = toId,
|
||||
InSolarSystem = QSBSceneManager.CurrentScene == OWScene.SolarSystem,
|
||||
InEye = QSBSceneManager.CurrentScene == OWScene.EyeOfTheUniverse,
|
||||
LoopCount = StandaloneProfileManager.SharedInstance.currentProfileGameSave.loopCount,
|
||||
KnownFrequencies = StandaloneProfileManager.SharedInstance.currentProfileGameSave.knownFrequencies
|
||||
KnownFrequencies = StandaloneProfileManager.SharedInstance.currentProfileGameSave.knownFrequencies,
|
||||
KnownSignals = StandaloneProfileManager.SharedInstance.currentProfileGameSave.knownSignals
|
||||
};
|
||||
|
||||
public override void OnReceiveRemote(bool isHost, GameStateMessage message)
|
||||
@ -34,8 +34,16 @@ namespace QSB.SaveSync.Events
|
||||
{
|
||||
DebugLog.DebugWrite($"knowsFrequency{i}:{message.KnownFrequencies[i]}");
|
||||
}
|
||||
|
||||
gameSave.knownFrequencies = message.KnownFrequencies;
|
||||
|
||||
foreach (var item in message.KnownSignals)
|
||||
{
|
||||
DebugLog.DebugWrite($"knowsSignal {item.Key}:{item.Value}");
|
||||
}
|
||||
|
||||
gameSave.knownSignals = message.KnownSignals;
|
||||
|
||||
PlayerData.SaveCurrentGame();
|
||||
|
||||
DebugLog.DebugWrite($"inEye:{message.InEye}");
|
||||
|
@ -2,6 +2,7 @@
|
||||
using QSB.Utility;
|
||||
using QuantumUNET.Transport;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace QSB.SaveSync.Events
|
||||
{
|
||||
@ -11,6 +12,7 @@ namespace QSB.SaveSync.Events
|
||||
public bool InEye { get; set; }
|
||||
public int LoopCount { get; set; }
|
||||
public bool[] KnownFrequencies { get; set; }
|
||||
public Dictionary<int, bool> KnownSignals { get; set; } = new();
|
||||
|
||||
public override void Deserialize(QNetworkReader reader)
|
||||
{
|
||||
@ -33,6 +35,16 @@ namespace QSB.SaveSync.Events
|
||||
{
|
||||
KnownFrequencies[i] = reader.ReadBoolean();
|
||||
}
|
||||
|
||||
// Known signals
|
||||
var signalsLength = reader.ReadInt32();
|
||||
KnownSignals.Clear();
|
||||
for (var i = 0; i < signalsLength; i++)
|
||||
{
|
||||
var key = reader.ReadInt32();
|
||||
var value = reader.ReadBoolean();
|
||||
KnownSignals.Add(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
public override void Serialize(QNetworkWriter writer)
|
||||
@ -53,6 +65,14 @@ namespace QSB.SaveSync.Events
|
||||
{
|
||||
writer.Write(item);
|
||||
}
|
||||
|
||||
// Known signals
|
||||
writer.Write(KnownSignals.Count);
|
||||
foreach (var item in KnownSignals)
|
||||
{
|
||||
writer.Write(item.Key);
|
||||
writer.Write(item.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user