Spiral sync (#242)

* add stuff

* extract patches

* extract worldobjects (#241)

* add spiral sync

* cleanup

* cleanup

* fix

* rename

* add computers

* remove qnet flagshelper

* Update README.md

* cleanup
This commit is contained in:
Mister_Nebula 2020-12-31 12:10:55 +00:00 committed by GitHub
parent cbf621e070
commit 53974485c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
64 changed files with 593 additions and 273 deletions

View File

@ -118,7 +118,7 @@ namespace QSB.ConversationSync
{
var newBox = Instantiate(_boxPrefab);
newBox.SetActive(false);
newBox.transform.parent = parent;
newBox.transform.SetParent(parent);
newBox.transform.localPosition = new Vector3(0, vertOffset, 0);
newBox.transform.rotation = parent.rotation;
var lookAt = newBox.AddComponent<FaceActiveCamera>();

View File

@ -6,7 +6,7 @@ using QSB.WorldSync;
using System.Collections.Generic;
using UnityEngine;
namespace QSB.ConversationSync
namespace QSB.ConversationSync.Patches
{
public class ConversationPatches : QSBPatch
{

View File

@ -2,7 +2,7 @@
using QSB.Patches;
using System.Linq;
namespace QSB.DeathSync
namespace QSB.DeathSync.Patches
{
public class DeathPatches : QSBPatch
{

View File

@ -1,4 +1,5 @@
using QSB.WorldSync;
using QSB.ElevatorSync.WorldObjects;
using QSB.WorldSync;
using System.Collections.Generic;
using UnityEngine;

View File

@ -1,4 +1,5 @@
using QSB.Events;
using QSB.ElevatorSync.WorldObjects;
using QSB.Events;
using QSB.WorldSync;
using QSB.WorldSync.Events;

View File

@ -2,7 +2,7 @@
using QSB.Events;
using QSB.Patches;
namespace QSB.ElevatorSync
namespace QSB.ElevatorSync.Patches
{
public class ElevatorPatches : QSBPatch
{

View File

@ -2,7 +2,7 @@
using QSB.WorldSync;
using UnityEngine;
namespace QSB.ElevatorSync
namespace QSB.ElevatorSync.WorldObjects
{
public class QSBElevator : WorldObject<Elevator>
{

View File

@ -2,6 +2,7 @@
{
public static class EventNames
{
// Built into Outer Wilds -- don't change unless they change in-game!
public static string TurnOnFlashlight = "TurnOnFlashlight";
public static string TurnOffFlashlight = "TurnOffFlashlight";
public static string LaunchProbe = "LaunchProbe";
@ -19,6 +20,8 @@
public static string WakeUp = "WakeUp";
public static string DialogueCondition = "DialogueConditionChanged";
// Custom event names -- change if you want! These can be anything, as long as both
// sides of the GlobalMessenger (fireevent and setuplistener) reference the same thing.
public static string QSBPlayerDeath = "QSBPlayerDeath";
public static string QSBPlayerJoin = "QSBPlayerJoin";
public static string QSBPlayerReady = "QSBPlayerReady";
@ -39,5 +42,6 @@
public static string QSBMultiStateChange = "QSBMultiStateChange";
public static string QSBIdentifyFrequency = "QSBIdentifyFrequency";
public static string QSBIdentifySignal = "QSBIdentifySignal";
public static string QSBTextTranslated = "QSBTextTranslated";
}
}

View File

@ -29,6 +29,7 @@
SocketStateChange,
MultiStateChange,
IdentifyFrequency,
IdentifySignal
IdentifySignal,
TextTranslated
}
}

View File

@ -11,6 +11,7 @@ using QSB.Player.Events;
using QSB.QuantumSync.Events;
using QSB.TimeSync.Events;
using QSB.Tools.Events;
using QSB.TranslationSync.Events;
using QSB.Utility;
using System.Collections.Generic;
@ -49,6 +50,7 @@ namespace QSB.Events
new OrbUserEvent(),
new SocketStateChangeEvent(),
new MultiStateChangeEvent(),
new SetAsTranslatedEvent(),
// Conversation/dialogue/exploration
new ConversationEvent(),
new ConversationStartEndEvent(),

View File

@ -1,7 +1,7 @@
using QSB.Events;
using QSB.Patches;
namespace QSB.FrequencySync
namespace QSB.FrequencySync.Patches
{
public class FrequencyPatches : QSBPatch
{

View File

@ -1,4 +1,5 @@
using QSB.Events;
using QSB.GeyserSync.WorldObjects;
using QSB.WorldSync;
using QSB.WorldSync.Events;

View File

@ -1,4 +1,5 @@
using QSB.Patches;
using QSB.GeyserSync.WorldObjects;
using QSB.Patches;
using QSB.WorldSync;
using UnityEngine;

View File

@ -2,7 +2,7 @@
using QSB.WorldSync;
using QuantumUNET;
namespace QSB.GeyserSync
namespace QSB.GeyserSync.WorldObjects
{
public class QSBGeyser : WorldObject<GeyserController>
{

View File

@ -1,7 +1,7 @@
using QSB.Events;
using QSB.Patches;
namespace QSB.LogSync
namespace QSB.LogSync.Patches
{
public class LogPatches : QSBPatch
{

View File

@ -1,4 +1,5 @@
using QSB.Events;
using QSB.OrbSync.WorldObjects;
using QSB.WorldSync;
namespace QSB.OrbSync.Events

View File

@ -1,4 +1,5 @@
using OWML.Common;
using QSB.OrbSync.WorldObjects;
using QSB.Utility;
using QSB.WorldSync;
using QuantumUNET;

View File

@ -3,7 +3,7 @@ using QSB.Patches;
using QSB.WorldSync;
using UnityEngine;
namespace QSB.OrbSync
namespace QSB.OrbSync.Patches
{
public class OrbPatches : QSBPatch
{

View File

@ -4,7 +4,7 @@ using QSB.Utility;
using QSB.WorldSync;
using UnityEngine.UI;
namespace QSB.OrbSync
namespace QSB.OrbSync.WorldObjects
{
public class QSBOrbSlot : WorldObject<NomaiInterfaceSlot>
{

View File

@ -1,12 +1,13 @@
using OWML.Common;
using QSB.ConversationSync;
using QSB.DeathSync;
using QSB.ElevatorSync;
using QSB.FrequencySync;
using QSB.LogSync;
using QSB.OrbSync;
using QSB.QuantumSync;
using QSB.TimeSync;
using QSB.ConversationSync.Patches;
using QSB.DeathSync.Patches;
using QSB.ElevatorSync.Patches;
using QSB.FrequencySync.Patches;
using QSB.LogSync.Patches;
using QSB.OrbSync.Patches;
using QSB.QuantumSync.Patches;
using QSB.TimeSync.Patches;
using QSB.TranslationSync.Patches;
using QSB.Utility;
using System;
using System.Collections.Generic;
@ -35,7 +36,8 @@ namespace QSB.Patches
new QuantumVisibilityPatches(),
new ServerQuantumStateChangePatches(),
new ClientQuantumStateChangePatches(),
new FrequencyPatches()
new FrequencyPatches(),
new SpiralPatches()
};
DebugLog.DebugWrite("Patch Manager ready.", MessageType.Success);

View File

@ -1,7 +1,7 @@
using OWML.Common;
using QSB.Events;
using QSB.Messaging;
using QSB.SectorSync;
using QSB.SectorSync.WorldObjects;
using QSB.Utility;
using System.Linq;

View File

@ -1,6 +1,6 @@
using OWML.Common;
using QSB.Events;
using QSB.SectorSync;
using QSB.SectorSync.WorldObjects;
using QSB.Utility;
using QSB.WorldSync;
using QSB.WorldSync.Events;

View File

@ -1,6 +1,9 @@
using QSB.Events;
using OWML.Utils;
using QSB.Events;
using QSB.Messaging;
using QSB.SectorSync;
using QSB.SectorSync.WorldObjects;
using QSB.TranslationSync;
using QSB.TranslationSync.WorldObjects;
using QSB.Utility;
using QSB.WorldSync;
using System.Linq;
@ -46,6 +49,30 @@ namespace QSB.Player.Events
{
GlobalMessenger<string, bool, bool>.FireEvent(EventNames.QSBRevealFact, fact.Id, fact.SaveGame, false);
}
foreach (var wallText in QSBWorldSync.GetWorldObjects<QSBWallText>().Where(x => x.AttachedObject.GetValue<bool>("_initialized") && x.AttachedObject.GetNumTextBlocks() > 0))
{
foreach (var id in wallText.GetTranslatedIds())
{
GlobalMessenger<NomaiTextType, int, int>.FireEvent(EventNames.QSBTextTranslated, NomaiTextType.WallText, wallText.ObjectId, id);
}
}
foreach (var computer in QSBWorldSync.GetWorldObjects<QSBComputer>().Where(x => x.AttachedObject.GetValue<bool>("_initialized") && x.AttachedObject.GetNumTextBlocks() > 0))
{
foreach (var id in computer.GetTranslatedIds())
{
GlobalMessenger<NomaiTextType, int, int>.FireEvent(EventNames.QSBTextTranslated, NomaiTextType.Computer, computer.ObjectId, id);
}
}
foreach (var vesselComputer in QSBWorldSync.GetWorldObjects<QSBVesselComputer>().Where(x => x.AttachedObject.GetValue<bool>("_initialized") && x.AttachedObject.GetNumTextBlocks() > 0))
{
foreach (var id in vesselComputer.GetTranslatedIds())
{
GlobalMessenger<NomaiTextType, int, int>.FireEvent(EventNames.QSBTextTranslated, NomaiTextType.VesselComputer, vesselComputer.ObjectId, id);
}
}
}
}
}

View File

@ -149,38 +149,38 @@
<Compile Include="ConversationSync\Events\DialogueConditionMessage.cs" />
<Compile Include="ConversationSync\Events\ConversationEvent.cs" />
<Compile Include="ConversationSync\Events\ConversationMessage.cs" />
<Compile Include="ConversationSync\ConversationPatches.cs" />
<Compile Include="ConversationSync\Patches\ConversationPatches.cs" />
<Compile Include="ConversationSync\Events\ConversationStartEndEvent.cs" />
<Compile Include="ConversationSync\Events\ConversationStartEndMessage.cs" />
<Compile Include="ConversationSync\ConversationType.cs" />
<Compile Include="ConversationSync\ConversationManager.cs" />
<Compile Include="DeathSync\DeathPatches.cs" />
<Compile Include="ElevatorSync\QSBElevator.cs" />
<Compile Include="DeathSync\Patches\DeathPatches.cs" />
<Compile Include="ElevatorSync\WorldObjects\QSBElevator.cs" />
<Compile Include="ElevatorSync\Events\ElevatorEvent.cs" />
<Compile Include="ElevatorSync\ElevatorManager.cs" />
<Compile Include="ElevatorSync\ElevatorPatches.cs" />
<Compile Include="ElevatorSync\Patches\ElevatorPatches.cs" />
<Compile Include="Events\EventNames.cs" />
<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="FrequencySync\Patches\FrequencyPatches.cs" />
<Compile Include="Instruments\QSBCamera\CameraController.cs" />
<Compile Include="Instruments\QSBCamera\CameraManager.cs" />
<Compile Include="Instruments\QSBCamera\CameraMode.cs" />
<Compile Include="Instruments\InstrumentsManager.cs" />
<Compile Include="LogSync\Events\RevealFactEvent.cs" />
<Compile Include="LogSync\Events\RevealFactMessage.cs" />
<Compile Include="LogSync\LogPatches.cs" />
<Compile Include="LogSync\Patches\LogPatches.cs" />
<Compile Include="Messaging\EnumMessage.cs" />
<Compile Include="Messaging\FloatMessage.cs" />
<Compile Include="OrbSync\Events\OrbSlotMessage.cs" />
<Compile Include="OrbSync\OrbManager.cs" />
<Compile Include="OrbSync\Events\OrbSlotEvent.cs" />
<Compile Include="OrbSync\OrbPatches.cs" />
<Compile Include="OrbSync\Patches\OrbPatches.cs" />
<Compile Include="OrbSync\Events\OrbUserEvent.cs" />
<Compile Include="OrbSync\QSBOrbSlot.cs" />
<Compile Include="OrbSync\WorldObjects\QSBOrbSlot.cs" />
<Compile Include="Patches\QSBPatchManager.cs" />
<Compile Include="Player\Events\ServerSendPlayerStatesEvent.cs" />
<Compile Include="Player\PlayerMapMarker.cs" />
@ -190,20 +190,28 @@
<Compile Include="Patches\QSBPatch.cs" />
<Compile Include="Patches\QSBPatchTypes.cs" />
<Compile Include="QSBSceneManager.cs" />
<Compile Include="QuantumSync\ClientQuantumStateChangePatches.cs" />
<Compile Include="QuantumSync\Patches\ClientQuantumStateChangePatches.cs" />
<Compile Include="QuantumSync\Events\MultiStateChangeEvent.cs" />
<Compile Include="QuantumSync\Events\MultiStateChangeMessage.cs" />
<Compile Include="QuantumSync\Events\SocketStateChangeEvent.cs" />
<Compile Include="QuantumSync\Events\SocketStateChangeMessage.cs" />
<Compile Include="QuantumSync\QSBMultiStateQuantumObject.cs" />
<Compile Include="QuantumSync\QSBSocketedQuantumObject.cs" />
<Compile Include="QuantumSync\QSBQuantumSocket.cs" />
<Compile Include="QuantumSync\WorldObjects\QSBMultiStateQuantumObject.cs" />
<Compile Include="QuantumSync\WorldObjects\QSBSocketedQuantumObject.cs" />
<Compile Include="QuantumSync\WorldObjects\QSBQuantumSocket.cs" />
<Compile Include="QuantumSync\QuantumManager.cs" />
<Compile Include="QuantumSync\QuantumVisibilityPatches.cs" />
<Compile Include="QuantumSync\ServerQuantumStateChangePatches.cs" />
<Compile Include="QuantumSync\Patches\QuantumVisibilityPatches.cs" />
<Compile Include="QuantumSync\Patches\ServerQuantumStateChangePatches.cs" />
<Compile Include="TranslationSync\Events\SetAsTranslatedEvent.cs" />
<Compile Include="TranslationSync\Events\SetAsTranslatedMessage.cs" />
<Compile Include="TranslationSync\NomaiTextType.cs" />
<Compile Include="TranslationSync\WorldObjects\QSBComputer.cs" />
<Compile Include="TranslationSync\WorldObjects\QSBVesselComputer.cs" />
<Compile Include="TranslationSync\WorldObjects\QSBWallText.cs" />
<Compile Include="TranslationSync\SpiralManager.cs" />
<Compile Include="TranslationSync\Patches\SpiralPatches.cs" />
<Compile Include="TimeSync\TimeSyncType.cs" />
<Compile Include="TimeSync\TimeSyncUI.cs" />
<Compile Include="TimeSync\WakeUpPatches.cs" />
<Compile Include="TimeSync\Patches\WakeUpPatches.cs" />
<Compile Include="Tools\Events\PlayerFlashlightEvent.cs" />
<Compile Include="Player\Events\PlayerJoinEvent.cs" />
<Compile Include="Tools\Events\PlayerProbeEvent.cs" />
@ -215,14 +223,14 @@
<Compile Include="TimeSync\Events\ServerTimeEvent.cs" />
<Compile Include="GeyserSync\Events\GeyserEvent.cs" />
<Compile Include="GeyserSync\GeyserManager.cs" />
<Compile Include="GeyserSync\QSBGeyser.cs" />
<Compile Include="GeyserSync\WorldObjects\QSBGeyser.cs" />
<Compile Include="Tools\Events\PlayerProbeLauncherEvent.cs" />
<Compile Include="Tools\Events\PlayerSignalscopeEvent.cs" />
<Compile Include="Tools\Events\PlayerTranslatorEvent.cs" />
<Compile Include="Events\QSBEvent.cs" />
<Compile Include="Player\Events\PlayerJoinMessage.cs" />
<Compile Include="Messaging\ToggleMessage.cs" />
<Compile Include="SectorSync\QSBSector.cs" />
<Compile Include="SectorSync\WorldObjects\QSBSector.cs" />
<Compile Include="SectorSync\QSBSectorManager.cs" />
<Compile Include="TransformSync\TransformSync.cs" />
<Compile Include="Utility\DebugBoxManager.cs" />

View File

@ -9,6 +9,7 @@ using QSB.Patches;
using QSB.QuantumSync;
using QSB.SectorSync;
using QSB.TimeSync;
using QSB.TranslationSync;
using QSB.Utility;
using QuantumUNET;
using QuantumUNET.Components;
@ -79,6 +80,7 @@ namespace QSB
gameObject.AddComponent<QSBInputManager>();
gameObject.AddComponent<TimeSyncUI>();
gameObject.AddComponent<QuantumManager>();
gameObject.AddComponent<SpiralManager>();
DebugBoxManager.Init();

View File

@ -2,14 +2,16 @@
using OWML.Utils;
using QSB.Animation;
using QSB.DeathSync;
using QSB.ElevatorSync;
using QSB.ElevatorSync.WorldObjects;
using QSB.Events;
using QSB.GeyserSync;
using QSB.GeyserSync.WorldObjects;
using QSB.Instruments;
using QSB.OrbSync;
using QSB.OrbSync.WorldObjects;
using QSB.Patches;
using QSB.Player;
using QSB.SectorSync;
using QSB.SectorSync.WorldObjects;
using QSB.TimeSync;
using QSB.TransformSync;
using QSB.Utility;

View File

@ -1,5 +1,6 @@
using OWML.Utils;
using QSB.Events;
using QSB.QuantumSync.WorldObjects;
using QSB.WorldSync;
namespace QSB.QuantumSync.Events

View File

@ -1,4 +1,5 @@
using QSB.Events;
using QSB.QuantumSync.WorldObjects;
using QSB.WorldSync;
using System.Reflection;
using UnityEngine;

View File

@ -1,6 +1,6 @@
using QSB.Patches;
namespace QSB.QuantumSync
namespace QSB.QuantumSync.Patches
{
public class ClientQuantumStateChangePatches : QSBPatch
{

View File

@ -4,7 +4,7 @@ using System.Linq;
using System.Reflection;
using UnityEngine;
namespace QSB.QuantumSync
namespace QSB.QuantumSync.Patches
{
public class QuantumVisibilityPatches : QSBPatch
{

View File

@ -1,11 +1,12 @@
using QSB.Events;
using QSB.Patches;
using QSB.QuantumSync.WorldObjects;
using QSB.WorldSync;
using System;
using System.Linq;
using UnityEngine;
namespace QSB.QuantumSync
namespace QSB.QuantumSync.Patches
{
public class ServerQuantumStateChangePatches : QSBPatch
{

View File

@ -1,4 +1,5 @@
using QSB.WorldSync;
using QSB.QuantumSync.WorldObjects;
using QSB.WorldSync;
using System.Collections.Generic;
using UnityEngine;

View File

@ -3,7 +3,7 @@ using QSB.Utility;
using QSB.WorldSync;
using UnityEngine.UI;
namespace QSB.QuantumSync
namespace QSB.QuantumSync.WorldObjects
{
public class QSBMultiStateQuantumObject : WorldObject<MultiStateQuantumObject>
{

View File

@ -1,7 +1,7 @@
using OWML.Utils;
using QSB.WorldSync;
namespace QSB.QuantumSync
namespace QSB.QuantumSync.WorldObjects
{
internal class QSBQuantumSocket : WorldObject<QuantumSocket>
{

View File

@ -1,6 +1,6 @@
using QSB.WorldSync;
namespace QSB.QuantumSync
namespace QSB.QuantumSync.WorldObjects
{
internal class QSBSocketedQuantumObject : WorldObject<SocketedQuantumObject>
{

View File

@ -1,4 +1,5 @@
using OWML.Common;
using QSB.SectorSync.WorldObjects;
using QSB.Utility;
using QSB.WorldSync;
using System.Linq;

View File

@ -1,5 +1,6 @@
using QSB.Events;
using QSB.Player;
using QSB.SectorSync.WorldObjects;
using System.Linq;
using UnityEngine;

View File

@ -1,7 +1,7 @@
using QSB.WorldSync;
using UnityEngine;
namespace QSB.SectorSync
namespace QSB.SectorSync.WorldObjects
{
public class QSBSector : WorldObject<Sector>
{

View File

@ -1,7 +1,7 @@
using OWML.Utils;
using QSB.Patches;
namespace QSB.TimeSync
namespace QSB.TimeSync.Patches
{
public class WakeUpPatches : QSBPatch
{

View File

@ -37,7 +37,7 @@ namespace QSB.TimeSync
public void OnDestroy()
{
QSBSceneManager.OnUniverseSceneLoaded -= OnUniverseSceneLoad;
if (_canvas.enabled)
if (_canvas != null & _canvas.enabled)
{
Canvas.willRenderCanvases -= OnWillRenderCanvases;
}

View File

@ -1,6 +1,7 @@
using OWML.Common;
using QSB.Player;
using QSB.SectorSync;
using QSB.SectorSync.WorldObjects;
using QSB.Utility;
using System.Linq;
using UnityEngine;

View File

@ -0,0 +1,51 @@
using QSB.Events;
using QSB.TranslationSync.WorldObjects;
using QSB.WorldSync;
namespace QSB.TranslationSync.Events
{
public class SetAsTranslatedEvent : QSBEvent<SetAsTranslatedMessage>
{
public override EventType Type => EventType.TextTranslated;
public override void SetupListener() => GlobalMessenger<NomaiTextType, int, int>.AddListener(EventNames.QSBTextTranslated, Handler);
public override void CloseListener() => GlobalMessenger<NomaiTextType, int, int>.RemoveListener(EventNames.QSBTextTranslated, Handler);
private void Handler(NomaiTextType type, int objId, int textId) => SendEvent(CreateMessage(type, objId, textId));
private SetAsTranslatedMessage CreateMessage(NomaiTextType type, int objId, int textId) => new SetAsTranslatedMessage
{
AboutId = LocalPlayerId,
ObjectId = objId,
TextId = textId,
TextType = type
};
public override void OnReceiveRemote(bool server, SetAsTranslatedMessage message)
{
if (!QSBCore.HasWokenUp)
{
return;
}
if (message.TextType == NomaiTextType.WallText)
{
var obj = QSBWorldSync.GetWorldObject<QSBWallText>(message.ObjectId);
obj.HandleSetAsTranslated(message.TextId);
}
else if (message.TextType == NomaiTextType.Computer)
{
var obj = QSBWorldSync.GetWorldObject<QSBComputer>(message.ObjectId);
obj.HandleSetAsTranslated(message.TextId);
}
else if (message.TextType == NomaiTextType.VesselComputer)
{
var obj = QSBWorldSync.GetWorldObject<QSBVesselComputer>(message.ObjectId);
obj.HandleSetAsTranslated(message.TextId);
}
else
{
throw new System.NotImplementedException($"TextType <{message.TextType}> not implemented.");
}
}
}
}

View File

@ -0,0 +1,25 @@
using QSB.WorldSync.Events;
using QuantumUNET.Transport;
namespace QSB.TranslationSync.Events
{
public class SetAsTranslatedMessage : WorldObjectMessage
{
public int TextId { get; set; }
public NomaiTextType TextType { get; set; }
public override void Deserialize(QNetworkReader reader)
{
base.Deserialize(reader);
TextId = reader.ReadInt32();
TextType = (NomaiTextType)reader.ReadInt16();
}
public override void Serialize(QNetworkWriter writer)
{
base.Serialize(writer);
writer.Write(TextId);
writer.Write((short)TextType);
}
}
}

View File

@ -0,0 +1,9 @@
namespace QSB.TranslationSync
{
public enum NomaiTextType
{
Computer = 0,
VesselComputer = 1,
WallText = 2
}
}

View File

@ -0,0 +1,62 @@
using QSB.Events;
using QSB.Patches;
namespace QSB.TranslationSync.Patches
{
internal class SpiralPatches : QSBPatch
{
public override QSBPatchTypes Type => QSBPatchTypes.OnClientConnect;
public override void DoPatches()
{
QSBCore.Helper.HarmonyHelper.AddPrefix<NomaiWallText>("SetAsTranslated", typeof(SpiralPatches), nameof(Wall_SetAsTranslated));
QSBCore.Helper.HarmonyHelper.AddPrefix<NomaiComputer>("SetAsTranslated", typeof(SpiralPatches), nameof(Computer_SetAsTranslated));
QSBCore.Helper.HarmonyHelper.AddPrefix<NomaiVesselComputer>("SetAsTranslated", typeof(SpiralPatches), nameof(VesselComputer_SetAsTranslated));
}
public static bool Wall_SetAsTranslated(NomaiWallText __instance, int id)
{
if (__instance.IsTranslated(id))
{
return true;
}
GlobalMessenger<NomaiTextType, int, int>
.FireEvent(
EventNames.QSBTextTranslated,
NomaiTextType.WallText,
SpiralManager.Instance.GetId(__instance),
id);
return true;
}
public static bool Computer_SetAsTranslated(NomaiComputer __instance, int id)
{
if (__instance.IsTranslated(id))
{
return true;
}
GlobalMessenger<NomaiTextType, int, int>
.FireEvent(
EventNames.QSBTextTranslated,
NomaiTextType.Computer,
SpiralManager.Instance.GetId(__instance),
id);
return true;
}
public static bool VesselComputer_SetAsTranslated(NomaiVesselComputer __instance, int id)
{
if (__instance.IsTranslated(id))
{
return true;
}
GlobalMessenger<NomaiTextType, int, int>
.FireEvent(
EventNames.QSBTextTranslated,
NomaiTextType.VesselComputer,
SpiralManager.Instance.GetId(__instance),
id);
return true;
}
}
}

View File

@ -0,0 +1,35 @@
using QSB.TranslationSync.WorldObjects;
using QSB.WorldSync;
using System.Collections.Generic;
using UnityEngine;
namespace QSB.TranslationSync
{
internal class SpiralManager : MonoBehaviour
{
public static SpiralManager Instance { get; private set; }
private List<NomaiWallText> _nomaiWallTexts;
private List<NomaiComputer> _nomaiComputers;
private List<NomaiVesselComputer> _nomaiVesselComputers;
public void Awake()
{
Instance = this;
QSBSceneManager.OnUniverseSceneLoaded += OnSceneLoaded;
}
public void OnDestroy() => QSBSceneManager.OnUniverseSceneLoaded -= OnSceneLoaded;
private void OnSceneLoaded(OWScene scene)
{
_nomaiWallTexts = QSBWorldSync.Init<QSBWallText, NomaiWallText>();
_nomaiComputers = QSBWorldSync.Init<QSBComputer, NomaiComputer>();
_nomaiVesselComputers = QSBWorldSync.Init<QSBVesselComputer, NomaiVesselComputer>();
}
public int GetId(NomaiWallText obj) => _nomaiWallTexts.IndexOf(obj);
public int GetId(NomaiComputer obj) => _nomaiComputers.IndexOf(obj);
public int GetId(NomaiVesselComputer obj) => _nomaiVesselComputers.IndexOf(obj);
}
}

View File

@ -0,0 +1,44 @@
using OWML.Utils;
using QSB.WorldSync;
using System.Collections.Generic;
namespace QSB.TranslationSync.WorldObjects
{
internal class QSBComputer : WorldObject<NomaiComputer>
{
public override void Init(NomaiComputer computer, int id)
{
ObjectId = id;
AttachedObject = computer;
}
public void HandleSetAsTranslated(int id)
{
if (AttachedObject.IsTranslated(id))
{
return;
}
AttachedObject.SetAsTranslated(id);
}
public IEnumerable<int> GetTranslatedIds()
{
var activeList = AttachedObject.GetValue<List<NomaiComputerRing>>("_activeRingList");
foreach (var item in activeList)
{
if (AttachedObject.IsTranslated(item.GetEntryID()))
{
yield return item.GetEntryID();
}
}
var inactiveList = AttachedObject.GetValue<List<NomaiComputerRing>>("_inactiveRingList");
foreach (var item in inactiveList)
{
if (AttachedObject.IsTranslated(item.GetEntryID()))
{
yield return item.GetEntryID();
}
}
}
}
}

View File

@ -0,0 +1,33 @@
using OWML.Utils;
using QSB.WorldSync;
using System.Collections.Generic;
using System.Linq;
namespace QSB.TranslationSync.WorldObjects
{
internal class QSBVesselComputer : WorldObject<NomaiVesselComputer>
{
public override void Init(NomaiVesselComputer computer, int id)
{
ObjectId = id;
AttachedObject = computer;
}
public void HandleSetAsTranslated(int id)
{
if (AttachedObject.IsTranslated(id))
{
return;
}
AttachedObject.SetAsTranslated(id);
}
public IEnumerable<int> GetTranslatedIds()
{
var rings = AttachedObject.GetValue<NomaiVesselComputerRing[]>("_computerRings");
return rings
.Where(ring => AttachedObject.IsTranslated(ring.GetEntryID()))
.Select(ring => ring.GetEntryID());
}
}
}

View File

@ -0,0 +1,31 @@
using OWML.Utils;
using QSB.WorldSync;
using System.Collections.Generic;
using System.Linq;
namespace QSB.TranslationSync.WorldObjects
{
internal class QSBWallText : WorldObject<NomaiWallText>
{
public override void Init(NomaiWallText wallText, int id)
{
ObjectId = id;
AttachedObject = wallText;
}
public void HandleSetAsTranslated(int id)
{
if (AttachedObject.IsTranslated(id))
{
return;
}
AttachedObject.SetAsTranslated(id);
}
public IEnumerable<int> GetTranslatedIds()
{
var dict = AttachedObject.GetValue<Dictionary<int, OWTreeNode<NomaiTextLine>>>("_idToNodeDict");
return dict.Keys.Where(key => AttachedObject.IsTranslated(key));
}
}
}

View File

@ -25,7 +25,7 @@ namespace QSB.Utility
{
var newBox = Object.Instantiate(_boxPrefab);
newBox.SetActive(false);
newBox.transform.parent = parent;
newBox.transform.SetParent(parent);
newBox.transform.localPosition = new Vector3(0, vertOffset, 0);
newBox.transform.rotation = parent.rotation;
var lookAt = newBox.AddComponent<FaceActiveCamera>();

View File

@ -1,5 +1,5 @@
using OWML.Common;
using QSB.OrbSync;
using QSB.OrbSync.WorldObjects;
using QSB.TransformSync;
using QSB.Utility;
using System;

View File

@ -61,7 +61,7 @@ namespace QuantumUNET.Components
}
else
{
QLog.LogWarning($"SetDynamicAssetId object already has an assetId <{m_AssetId}>");
QLog.Warning($"SetDynamicAssetId object already has an assetId <{m_AssetId}>");
}
}
@ -69,7 +69,7 @@ namespace QuantumUNET.Components
{
if (ClientAuthorityOwner != null)
{
QLog.LogError("SetClientOwner m_ClientAuthorityOwner already set!");
QLog.Error("SetClientOwner m_ClientAuthorityOwner already set!");
}
ClientAuthorityOwner = conn;
ClientAuthorityOwner.AddOwnedObject(this);
@ -198,7 +198,7 @@ namespace QuantumUNET.Components
}
else if (!allowNonZeroNetId)
{
QLog.LogWarning($"Object has non-zero netId {NetId} for {gameObject}");
QLog.Warning($"Object has non-zero netId {NetId} for {gameObject}");
return;
}
QNetworkServer.instance.SetLocalObjectOnServer(NetId, gameObject);
@ -210,7 +210,7 @@ namespace QuantumUNET.Components
}
catch (Exception ex)
{
QLog.LogFatalError($"Exception in OnStartServer:{ex.Message} {ex.StackTrace}");
QLog.FatalError($"Exception in OnStartServer:{ex.Message} {ex.StackTrace}");
}
}
if (QNetworkClient.active && QNetworkServer.localClientActive)
@ -232,7 +232,7 @@ namespace QuantumUNET.Components
IsClient = true;
}
CacheBehaviours();
QLog.LogDebug($"OnStartClient {gameObject} GUID:{NetId} localPlayerAuthority:{LocalPlayerAuthority}");
QLog.Debug($"OnStartClient {gameObject} GUID:{NetId} localPlayerAuthority:{LocalPlayerAuthority}");
foreach (var networkBehaviour in m_NetworkBehaviours)
{
try
@ -242,7 +242,7 @@ namespace QuantumUNET.Components
}
catch (Exception ex)
{
QLog.LogFatalError($"Exception in OnStartClient:{ex.Message} {ex.StackTrace}");
QLog.FatalError($"Exception in OnStartClient:{ex.Message} {ex.StackTrace}");
}
}
}
@ -272,7 +272,7 @@ namespace QuantumUNET.Components
}
catch (Exception ex)
{
QLog.LogFatalError($"Exception in OnStopAuthority:{ex.Message} {ex.StackTrace}");
QLog.FatalError($"Exception in OnStopAuthority:{ex.Message} {ex.StackTrace}");
}
}
}
@ -287,7 +287,7 @@ namespace QuantumUNET.Components
}
catch (Exception ex)
{
QLog.LogFatalError($"Exception in OnSetLocalVisibility:{ex.Message} {ex.StackTrace}");
QLog.FatalError($"Exception in OnSetLocalVisibility:{ex.Message} {ex.StackTrace}");
}
}
}
@ -305,7 +305,7 @@ namespace QuantumUNET.Components
}
catch (Exception ex)
{
QLog.LogFatalError($"Exception in OnCheckObserver:{ex.Message} {ex.StackTrace}");
QLog.FatalError($"Exception in OnCheckObserver:{ex.Message} {ex.StackTrace}");
}
}
@ -324,7 +324,7 @@ namespace QuantumUNET.Components
{
if (!LocalPlayerAuthority)
{
QLog.LogError($"HandleClientAuthority {gameObject} does not have localPlayerAuthority");
QLog.Error($"HandleClientAuthority {gameObject} does not have localPlayerAuthority");
}
else
{
@ -347,7 +347,7 @@ namespace QuantumUNET.Components
if (networkBehaviour == null)
{
var cmdHashHandlerName = QNetworkBehaviour.GetCmdHashHandlerName(cmdHash);
QLog.LogFatalError(
QLog.FatalError(
$"Found no behaviour for incoming [{cmdHashHandlerName}] on {gameObject}, the server and client should have the same NetworkBehaviour instances [netId={NetId}].");
invokeComponent = null;
result = false;
@ -365,18 +365,18 @@ namespace QuantumUNET.Components
if (gameObject == null)
{
var cmdHashHandlerName = QNetworkBehaviour.GetCmdHashHandlerName(cmdHash);
QLog.LogWarning($"SyncEvent [{cmdHashHandlerName}] received for deleted object [netId={NetId}]");
QLog.Warning($"SyncEvent [{cmdHashHandlerName}] received for deleted object [netId={NetId}]");
}
else if (!QNetworkBehaviour.GetInvokerForHashSyncEvent(cmdHash, out var invokeClass, out var cmdDelegate))
{
var cmdHashHandlerName2 = QNetworkBehaviour.GetCmdHashHandlerName(cmdHash);
QLog.LogFatalError(
QLog.FatalError(
$"Found no receiver for incoming [{cmdHashHandlerName2}] on {gameObject}, the server and client should have the same NetworkBehaviour instances [netId={NetId}].");
}
else if (!GetInvokeComponent(cmdHash, invokeClass, out var obj))
{
var cmdHashHandlerName3 = QNetworkBehaviour.GetCmdHashHandlerName(cmdHash);
QLog.LogWarning($"SyncEvent [{cmdHashHandlerName3}] handler not found [netId={NetId}]");
QLog.Warning($"SyncEvent [{cmdHashHandlerName3}] handler not found [netId={NetId}]");
}
else
{
@ -389,18 +389,18 @@ namespace QuantumUNET.Components
if (gameObject == null)
{
var cmdHashHandlerName = QNetworkBehaviour.GetCmdHashHandlerName(cmdHash);
QLog.LogWarning($"SyncList [{cmdHashHandlerName}] received for deleted object [netId={NetId}]");
QLog.Warning($"SyncList [{cmdHashHandlerName}] received for deleted object [netId={NetId}]");
}
else if (!QNetworkBehaviour.GetInvokerForHashSyncList(cmdHash, out var invokeClass, out var cmdDelegate))
{
var cmdHashHandlerName2 = QNetworkBehaviour.GetCmdHashHandlerName(cmdHash);
QLog.LogFatalError(
QLog.FatalError(
$"Found no receiver for incoming [{cmdHashHandlerName2}] on {gameObject}, the server and client should have the same NetworkBehaviour instances [netId={NetId}].");
}
else if (!GetInvokeComponent(cmdHash, invokeClass, out var obj))
{
var cmdHashHandlerName3 = QNetworkBehaviour.GetCmdHashHandlerName(cmdHash);
QLog.LogWarning($"SyncList [{cmdHashHandlerName3}] handler not found [netId={NetId}]");
QLog.Warning($"SyncList [{cmdHashHandlerName3}] handler not found [netId={NetId}]");
}
else
{
@ -413,18 +413,18 @@ namespace QuantumUNET.Components
if (gameObject == null)
{
var cmdHashHandlerName = QNetworkBehaviour.GetCmdHashHandlerName(cmdHash);
QLog.LogWarning($"Command [{cmdHashHandlerName}] received for deleted object [netId={NetId}]");
QLog.Warning($"Command [{cmdHashHandlerName}] received for deleted object [netId={NetId}]");
}
else if (!QNetworkBehaviour.GetInvokerForHashCommand(cmdHash, out var invokeClass, out var cmdDelegate))
{
var cmdHashHandlerName2 = QNetworkBehaviour.GetCmdHashHandlerName(cmdHash);
QLog.LogFatalError(
QLog.FatalError(
$"Found no receiver for incoming [{cmdHashHandlerName2}] on {gameObject}, the server and client should have the same NetworkBehaviour instances [netId={NetId}].");
}
else if (!GetInvokeComponent(cmdHash, invokeClass, out var obj))
{
var cmdHashHandlerName3 = QNetworkBehaviour.GetCmdHashHandlerName(cmdHash);
QLog.LogWarning($"Command [{cmdHashHandlerName3}] handler not found [netId={NetId}]");
QLog.Warning($"Command [{cmdHashHandlerName3}] handler not found [netId={NetId}]");
}
else
{
@ -437,18 +437,18 @@ namespace QuantumUNET.Components
if (gameObject == null)
{
var cmdHashHandlerName = QNetworkBehaviour.GetCmdHashHandlerName(cmdHash);
QLog.LogWarning($"ClientRpc [{cmdHashHandlerName}] received for deleted object [netId={NetId}]");
QLog.Warning($"ClientRpc [{cmdHashHandlerName}] received for deleted object [netId={NetId}]");
}
else if (!QNetworkBehaviour.GetInvokerForHashClientRpc(cmdHash, out var invokeClass, out var cmdDelegate))
{
var cmdHashHandlerName2 = QNetworkBehaviour.GetCmdHashHandlerName(cmdHash);
QLog.LogFatalError(
QLog.FatalError(
$"Found no receiver for incoming [{cmdHashHandlerName2}] on {gameObject}, the server and client should have the same NetworkBehaviour instances [netId={NetId}].");
}
else if (!GetInvokeComponent(cmdHash, invokeClass, out var obj))
{
var cmdHashHandlerName3 = QNetworkBehaviour.GetCmdHashHandlerName(cmdHash);
QLog.LogWarning($"ClientRpc [{cmdHashHandlerName3}] handler not found [netId={NetId}]");
QLog.Warning($"ClientRpc [{cmdHashHandlerName3}] handler not found [netId={NetId}]");
}
else
{
@ -494,7 +494,7 @@ namespace QuantumUNET.Components
var maxPacketSize = QNetworkServer.maxPacketSize;
if (s_UpdateWriter.Position - position > maxPacketSize)
{
QLog.LogWarning(
QLog.Warning(
$"Large state update of {s_UpdateWriter.Position - position} bytes for netId:{NetId} from script:{networkBehaviour}");
}
}
@ -581,15 +581,15 @@ namespace QuantumUNET.Components
{
if (m_Observers == null)
{
QLog.LogError($"AddObserver for {gameObject} observer list is null");
QLog.Error($"AddObserver for {gameObject} observer list is null");
}
else if (m_ObserverConnections.Contains(conn.connectionId))
{
QLog.LogWarning($"Duplicate observer {conn.address} added for {gameObject}");
QLog.Warning($"Duplicate observer {conn.address} added for {gameObject}");
}
else
{
QLog.LogDebug($"Added observer {conn.address} added for {gameObject}");
QLog.Debug($"Added observer {conn.address} added for {gameObject}");
m_Observers.Add(conn);
m_ObserverConnections.Add(conn.connectionId);
conn.AddToVisList(this);
@ -653,7 +653,7 @@ namespace QuantumUNET.Components
{
if (!networkConnection3.isReady)
{
QLog.LogWarning($"Observer is not ready for {gameObject} {networkConnection3}");
QLog.Warning($"Observer is not ready for {gameObject} {networkConnection3}");
}
else if (initialize || !hashSet2.Contains(networkConnection3))
{
@ -699,22 +699,22 @@ namespace QuantumUNET.Components
{
if (!IsServer)
{
QLog.LogWarning($"Cannot remove authority on client-side. (NetId:{NetId}, Gameobject:{gameObject.name})");
QLog.Warning($"Cannot remove authority on client-side. (NetId:{NetId}, Gameobject:{gameObject.name})");
return false;
}
else if (ConnectionToClient != null)
{
QLog.LogWarning("RemoveClientAuthority cannot remove authority for a player object");
QLog.Warning("RemoveClientAuthority cannot remove authority for a player object");
return false;
}
else if (ClientAuthorityOwner == null)
{
QLog.LogWarning($"RemoveClientAuthority for {gameObject} has no clientAuthority owner.");
QLog.Warning($"RemoveClientAuthority for {gameObject} has no clientAuthority owner.");
return false;
}
else if (ClientAuthorityOwner != conn)
{
QLog.LogWarning($"RemoveClientAuthority for {gameObject} has different owner.");
QLog.Warning($"RemoveClientAuthority for {gameObject} has different owner.");
return false;
}
ClientAuthorityOwner.RemoveOwnedObject(this);
@ -733,22 +733,22 @@ namespace QuantumUNET.Components
{
if (!IsServer)
{
QLog.LogWarning($"Cannot assign authority on client-side. (NetId:{NetId}, Gameobject:{gameObject.name})");
QLog.Warning($"Cannot assign authority on client-side. (NetId:{NetId}, Gameobject:{gameObject.name})");
return false;
}
else if (!LocalPlayerAuthority)
{
QLog.LogWarning($"Cannot assign authority on object without LocalPlayerAuthority. (NetId:{NetId}, Gameobject:{gameObject.name})");
QLog.Warning($"Cannot assign authority on object without LocalPlayerAuthority. (NetId:{NetId}, Gameobject:{gameObject.name})");
return false;
}
else if (ClientAuthorityOwner != null && conn != ClientAuthorityOwner)
{
QLog.LogWarning($"AssignClientAuthority for {gameObject} already has an owner. Use RemoveClientAuthority() first.");
QLog.Warning($"AssignClientAuthority for {gameObject} already has an owner. Use RemoveClientAuthority() first.");
return false;
}
else if (conn == null)
{
QLog.LogWarning($"AssignClientAuthority for {gameObject} owner cannot be null. Use RemoveClientAuthority() instead.");
QLog.Warning($"AssignClientAuthority for {gameObject} owner cannot be null. Use RemoveClientAuthority() instead.");
return false;
}
ClientAuthorityOwner = conn;

View File

@ -105,7 +105,7 @@ namespace QuantumUNET.Components
{
if (singleton != null)
{
QLog.LogWarning("Multiple NetworkManagers detected in the scene. Only one NetworkManager can exist at a time. The duplicate NetworkManager will not be used.");
QLog.Warning("Multiple NetworkManagers detected in the scene. Only one NetworkManager can exist at a time. The duplicate NetworkManager will not be used.");
Destroy(gameObject);
return;
}
@ -175,13 +175,13 @@ namespace QuantumUNET.Components
{
if (!QNetworkServer.Listen(serverBindAddress, networkPort))
{
QLog.LogFatalError($"StartServer listen on {serverBindAddress} failed.");
QLog.FatalError($"StartServer listen on {serverBindAddress} failed.");
return false;
}
}
else if (!QNetworkServer.Listen(networkPort))
{
QLog.LogFatalError("StartServer listen failed.");
QLog.FatalError("StartServer listen failed.");
return false;
}
RegisterServerMessages();
@ -286,7 +286,7 @@ namespace QuantumUNET.Components
RegisterClientMessages(client);
if (string.IsNullOrEmpty(networkAddress))
{
QLog.LogError("Must set the Network Address field in the manager");
QLog.Error("Must set the Network Address field in the manager");
return null;
}
if (useSimulator)
@ -396,7 +396,7 @@ namespace QuantumUNET.Components
{
if (string.IsNullOrEmpty(newSceneName))
{
QLog.LogError("ServerChangeScene empty scene name");
QLog.Error("ServerChangeScene empty scene name");
}
else
{
@ -421,7 +421,7 @@ namespace QuantumUNET.Components
{
if (string.IsNullOrEmpty(newSceneName))
{
QLog.LogError("ClientChangeScene empty scene name");
QLog.Error("ClientChangeScene empty scene name");
}
else
{
@ -452,7 +452,7 @@ namespace QuantumUNET.Components
}
else
{
QLog.LogError("FinishLoadScene client is null");
QLog.Error("FinishLoadScene client is null");
}
if (QNetworkServer.active)
{
@ -623,7 +623,7 @@ namespace QuantumUNET.Components
QNetworkServer.DestroyPlayersForConnection(conn);
if (conn.LastError != NetworkError.Ok)
{
QLog.LogError($"ServerDisconnected due to error: {conn.LastError}");
QLog.Error($"ServerDisconnected due to error: {conn.LastError}");
}
}
@ -631,7 +631,7 @@ namespace QuantumUNET.Components
{
if (conn.PlayerControllers.Count == 0)
{
QLog.LogWarning("Ready with no player object");
QLog.Warning("Ready with no player object");
}
QNetworkServer.SetClientReady(conn);
}
@ -644,15 +644,15 @@ namespace QuantumUNET.Components
{
if (playerPrefab == null)
{
QLog.LogFatalError("The PlayerPrefab is empty on the QSBNetworkManager. Please setup a PlayerPrefab object.");
QLog.FatalError("The PlayerPrefab is empty on the QSBNetworkManager. Please setup a PlayerPrefab object.");
}
else if (playerPrefab.GetComponent<QNetworkIdentity>() == null)
{
QLog.LogFatalError("The PlayerPrefab does not have a QSBNetworkIdentity. Please add a QSBNetworkIdentity to the player prefab.");
QLog.FatalError("The PlayerPrefab does not have a QSBNetworkIdentity. Please add a QSBNetworkIdentity to the player prefab.");
}
else if (playerControllerId < conn.PlayerControllers.Count && conn.PlayerControllers[playerControllerId].IsValid && conn.PlayerControllers[playerControllerId].Gameobject != null)
{
QLog.LogWarning("There is already a player at that playerControllerId for this connections.");
QLog.Warning("There is already a player at that playerControllerId for this connections.");
}
else
{
@ -694,7 +694,7 @@ namespace QuantumUNET.Components
StopClient();
if (conn.LastError != NetworkError.Ok)
{
QLog.LogError($"ClientDisconnected due to error: {conn.LastError}");
QLog.Error($"ClientDisconnected due to error: {conn.LastError}");
}
}

View File

@ -196,22 +196,22 @@ namespace QuantumUNET.Components
var gameObject = QNetworkServer.FindLocalObject(networkInstanceId);
if (gameObject == null)
{
QLog.LogWarning("Received NetworkTransform data for GameObject that doesn't exist");
QLog.Warning("Received NetworkTransform data for GameObject that doesn't exist");
}
else
{
var component = gameObject.GetComponent<QNetworkTransform>();
if (component == null)
{
QLog.LogWarning("HandleTransform null target");
QLog.Warning("HandleTransform null target");
}
else if (!component.LocalPlayerAuthority)
{
QLog.LogWarning("HandleTransform no localPlayerAuthority");
QLog.Warning("HandleTransform no localPlayerAuthority");
}
else if (netMsg.Connection.ClientOwnedObjects == null)
{
QLog.LogWarning("HandleTransform object not owned by connection");
QLog.Warning("HandleTransform object not owned by connection");
}
else if (netMsg.Connection.ClientOwnedObjects.Contains(networkInstanceId))
{
@ -220,7 +220,7 @@ namespace QuantumUNET.Components
}
else
{
QLog.LogWarning(
QLog.Warning(
$"HandleTransform netId:{networkInstanceId} is not for a valid player");
}
}

View File

@ -1,31 +0,0 @@
namespace QuantumUNET.Logging
{
// Stolen from here : https://stackoverflow.com/questions/3261451/using-a-bitmask-in-c-sharp
public static class FlagsHelper
{
public static bool IsSet<T>(T flags, T flag) where T : struct
{
var flagsValue = (int)(object)flags;
var flagValue = (int)(object)flag;
return (flagsValue & flagValue) != 0;
}
public static void Set<T>(ref T flags, T flag) where T : struct
{
var flagsValue = (int)(object)flags;
var flagValue = (int)(object)flag;
flags = (T)(object)(flagsValue | flagValue);
}
public static void Unset<T>(ref T flags, T flag) where T : struct
{
var flagsValue = (int)(object)flags;
var flagValue = (int)(object)flag;
flags = (T)(object)(flagsValue & ~flagValue);
}
}
}

View File

@ -1,67 +1,66 @@
using UnityEngine;
namespace QuantumUNET.Logging
namespace QuantumUNET.Logging
{
public static class QLog
{
private static QLogType LogType = QLogType.Warning | QLogType.Error | QLogType.FatalError;
public const int DebugType = 0;
public const int LogType = 1;
public const int WarningType = 2;
public const int ErrorType = 3;
public const int FatalErrorType = 4;
public static void SetLogType(QLogType flags)
=> LogType = flags;
private static int _currentLog;
private static bool _logDebug => _currentLog <= 0;
private static bool _logLog => _currentLog <= 1;
private static bool _logWarning => _currentLog <= 2;
private static bool _logError => _currentLog <= 3;
private static bool _logFatal => _currentLog <= 4;
public static void SetSpecifcLogType(QLogType flag, bool state)
{
if (state)
{
FlagsHelper.Set(ref LogType, flag);
return;
}
FlagsHelper.Unset(ref LogType, flag);
}
public static void SetLogType(int level)
=> _currentLog = level;
public static void LogDebug(string message)
public static void Debug(string message)
{
if (!FlagsHelper.IsSet(LogType, QLogType.Debug))
if (_logDebug)
{
return;
}
Debug.Log($"DEBUG : {message}");
UnityEngine.Debug.Log($"DEBUG : {message}");
}
public static void Log(string message)
{
if (!FlagsHelper.IsSet(LogType, QLogType.Log))
if (_logLog)
{
return;
}
Debug.Log($"LOG : {message}");
UnityEngine.Debug.Log($"LOG : {message}");
}
public static void LogWarning(string message)
public static void Warning(string message)
{
if (!FlagsHelper.IsSet(LogType, QLogType.Warning))
if (_logWarning)
{
return;
}
Debug.LogWarning($"WARN : {message}");
UnityEngine.Debug.LogWarning($"WARN : {message}");
}
public static void LogError(string message)
public static void Error(string message)
{
if (!FlagsHelper.IsSet(LogType, QLogType.Error))
if (_logError)
{
return;
}
Debug.LogError($"ERROR : {message}");
UnityEngine.Debug.LogError($"ERROR : {message}");
}
public static void LogFatalError(string message)
public static void FatalError(string message)
{
if (!FlagsHelper.IsSet(LogType, QLogType.FatalError))
if (_logFatal)
{
return;
}
Debug.LogError($"FATAL : {message}");
UnityEngine.Debug.LogError($"FATAL : {message}");
}
}
}

View File

@ -1,14 +0,0 @@
using System;
namespace QuantumUNET.Logging
{
[Flags]
public enum QLogType
{
Debug,
Log,
Warning,
Error,
FatalError
}
}

View File

@ -36,7 +36,7 @@ namespace QuantumUNET
m_MyView = GetComponent<QNetworkIdentity>();
if (m_MyView == null)
{
QLog.LogFatalError($"There is no QNetworkIdentity on this object (name={name}). Please add one.");
QLog.FatalError($"There is no QNetworkIdentity on this object (name={name}). Please add one.");
}
myView = m_MyView;
}
@ -52,11 +52,11 @@ namespace QuantumUNET
{
if (!IsLocalPlayer && !HasAuthority)
{
QLog.LogWarning("Trying to send command for object without authority.");
QLog.Warning("Trying to send command for object without authority.");
}
else if (QClientScene.readyConnection == null)
{
QLog.LogError($"Send command attempted with no client running [client={ConnectionToServer}].");
QLog.Error($"Send command attempted with no client running [client={ConnectionToServer}].");
}
else
{
@ -71,7 +71,7 @@ namespace QuantumUNET
{
if (!IsServer)
{
QLog.LogWarning("ClientRpc call on un-spawned object");
QLog.Warning("ClientRpc call on un-spawned object");
return;
}
writer.FinishMessage();
@ -82,7 +82,7 @@ namespace QuantumUNET
{
if (!IsServer)
{
QLog.LogWarning("TargetRpc call on un-spawned object");
QLog.Warning("TargetRpc call on un-spawned object");
return;
}
writer.FinishMessage();
@ -95,7 +95,7 @@ namespace QuantumUNET
{
if (!QNetworkServer.active)
{
QLog.LogError($"Tried to send event {eventName} on channel {channelId} but QSBNetworkServer isn't active.");
QLog.Error($"Tried to send event {eventName} on channel {channelId} but QSBNetworkServer isn't active.");
return;
}
writer.FinishMessage();
@ -194,21 +194,21 @@ namespace QuantumUNET
bool result;
if (!s_CmdHandlerDelegates.TryGetValue(cmdHash, out var invoker))
{
QLog.LogError($"GetInvokerForHash hash:{cmdHash} not found");
QLog.Error($"GetInvokerForHash hash:{cmdHash} not found");
invokeClass = null;
invokeFunction = null;
result = false;
}
else if (invoker == null)
{
QLog.LogError($"GetInvokerForHash hash:{cmdHash} invoker null");
QLog.Error($"GetInvokerForHash hash:{cmdHash} invoker null");
invokeClass = null;
invokeFunction = null;
result = false;
}
else if (invoker.invokeType != invokeType)
{
QLog.LogError($"GetInvokerForHash hash:{cmdHash} mismatched invokeType");
QLog.Error($"GetInvokerForHash hash:{cmdHash} mismatched invokeType");
invokeClass = null;
invokeFunction = null;
result = false;
@ -405,7 +405,7 @@ namespace QuantumUNET
networkInstanceId = component.NetId;
if (networkInstanceId.IsEmpty())
{
QLog.LogWarning(
QLog.Warning(
$"SetSyncVarGameObject GameObject {newGameObject} has a zero netId. Maybe it is not spawned yet?");
}
}

View File

@ -92,12 +92,12 @@ namespace QuantumUNET
bool result;
if (!active)
{
QLog.LogError("Reconnect - NetworkClient must be active");
QLog.Error("Reconnect - NetworkClient must be active");
result = false;
}
else if (m_Connection == null)
{
QLog.LogError("Reconnect - no old connection exists");
QLog.Error("Reconnect - no old connection exists");
result = false;
}
else
@ -135,12 +135,12 @@ namespace QuantumUNET
bool result;
if (!active)
{
QLog.LogError("Reconnect - NetworkClient must be active");
QLog.Error("Reconnect - NetworkClient must be active");
result = false;
}
else if (m_Connection == null)
{
QLog.LogError("Reconnect - no old connection exists");
QLog.Error("Reconnect - no old connection exists");
result = false;
}
else
@ -153,13 +153,13 @@ namespace QuantumUNET
hostId = NetworkTransport.AddHost(hostTopology, m_HostPort);
if (secureTunnelEndPoint == null)
{
QLog.LogError("Reconnect failed: null endpoint passed in");
QLog.Error("Reconnect failed: null endpoint passed in");
m_AsyncConnect = ConnectState.Failed;
result = false;
}
else if (secureTunnelEndPoint.AddressFamily != AddressFamily.InterNetwork && secureTunnelEndPoint.AddressFamily != AddressFamily.InterNetworkV6)
{
QLog.LogError("Reconnect failed: Endpoint AddressFamily must be either InterNetwork or InterNetworkV6");
QLog.Error("Reconnect failed: Endpoint AddressFamily must be either InterNetwork or InterNetworkV6");
m_AsyncConnect = ConnectState.Failed;
result = false;
}
@ -174,7 +174,7 @@ namespace QuantumUNET
}
else if (fullName != "UnityEngine.XboxOne.XboxOneEndPoint" && fullName != "UnityEngine.PS4.SceEndPoint")
{
QLog.LogError("Reconnect failed: invalid Endpoint (not IPEndPoint or XboxOneEndPoint or SceEndPoint)");
QLog.Error("Reconnect failed: invalid Endpoint (not IPEndPoint or XboxOneEndPoint or SceEndPoint)");
m_AsyncConnect = ConnectState.Failed;
result = false;
}
@ -189,13 +189,13 @@ namespace QuantumUNET
}
catch (Exception arg)
{
QLog.LogError($"Reconnect failed: Exception when trying to connect to EndPoint: {arg}");
QLog.Error($"Reconnect failed: Exception when trying to connect to EndPoint: {arg}");
m_AsyncConnect = ConnectState.Failed;
return false;
}
if (m_ClientConnectionId == 0)
{
QLog.LogError($"Reconnect failed: Unable to connect to EndPoint ({b})");
QLog.Error($"Reconnect failed: Unable to connect to EndPoint ({b})");
m_AsyncConnect = ConnectState.Failed;
result = false;
}
@ -257,12 +257,12 @@ namespace QuantumUNET
QLog.Log("Client Connect to remoteSockAddr");
if (secureTunnelEndPoint == null)
{
QLog.LogError("Connect failed: null endpoint passed in");
QLog.Error("Connect failed: null endpoint passed in");
m_AsyncConnect = ConnectState.Failed;
}
else if (secureTunnelEndPoint.AddressFamily != AddressFamily.InterNetwork && secureTunnelEndPoint.AddressFamily != AddressFamily.InterNetworkV6)
{
QLog.LogError("Connect failed: Endpoint AddressFamily must be either InterNetwork or InterNetworkV6");
QLog.Error("Connect failed: Endpoint AddressFamily must be either InterNetwork or InterNetworkV6");
m_AsyncConnect = ConnectState.Failed;
}
else
@ -275,7 +275,7 @@ namespace QuantumUNET
}
else if (fullName != "UnityEngine.XboxOne.XboxOneEndPoint" && fullName != "UnityEngine.PS4.SceEndPoint" && fullName != "UnityEngine.PSVita.SceEndPoint")
{
QLog.LogError("Connect failed: invalid Endpoint (not IPEndPoint or XboxOneEndPoint or SceEndPoint)");
QLog.Error("Connect failed: invalid Endpoint (not IPEndPoint or XboxOneEndPoint or SceEndPoint)");
m_AsyncConnect = ConnectState.Failed;
}
else
@ -289,13 +289,13 @@ namespace QuantumUNET
}
catch (Exception arg)
{
QLog.LogError($"Connect failed: Exception when trying to connect to EndPoint: {arg}");
QLog.Error($"Connect failed: Exception when trying to connect to EndPoint: {arg}");
m_AsyncConnect = ConnectState.Failed;
return;
}
if (m_ClientConnectionId == 0)
{
QLog.LogError($"Connect failed: Unable to connect to EndPoint ({b})");
QLog.Error($"Connect failed: Unable to connect to EndPoint ({b})");
m_AsyncConnect = ConnectState.Failed;
}
else
@ -345,7 +345,7 @@ namespace QuantumUNET
var networkClient = (QNetworkClient)ar.AsyncState;
if (array.Length == 0)
{
QLog.LogError($"DNS lookup failed for:{networkClient.m_RequestedServerHost}");
QLog.Error($"DNS lookup failed for:{networkClient.m_RequestedServerHost}");
networkClient.m_AsyncConnect = ConnectState.Failed;
}
else
@ -359,8 +359,8 @@ namespace QuantumUNET
catch (SocketException ex)
{
var networkClient2 = (QNetworkClient)ar.AsyncState;
QLog.LogError($"DNS resolution failed: {ex.GetErrorCode()}");
QLog.LogError($"Exception:{ex}");
QLog.Error($"DNS resolution failed: {ex.GetErrorCode()}");
QLog.Error($"Exception:{ex}");
networkClient2.m_AsyncConnect = ConnectState.Failed;
}
}
@ -412,7 +412,7 @@ namespace QuantumUNET
{
if (m_AsyncConnect != ConnectState.Connected)
{
QLog.LogError("NetworkClient Send when not connected to a server");
QLog.Error("NetworkClient Send when not connected to a server");
result = false;
}
else
@ -422,7 +422,7 @@ namespace QuantumUNET
}
else
{
QLog.LogError("NetworkClient Send with no connection");
QLog.Error("NetworkClient Send with no connection");
result = false;
}
return result;
@ -435,7 +435,7 @@ namespace QuantumUNET
{
if (m_AsyncConnect != ConnectState.Connected)
{
QLog.LogError("NetworkClient SendWriter when not connected to a server");
QLog.Error("NetworkClient SendWriter when not connected to a server");
result = false;
}
else
@ -445,7 +445,7 @@ namespace QuantumUNET
}
else
{
QLog.LogError("NetworkClient SendWriter with no connection");
QLog.Error("NetworkClient SendWriter with no connection");
result = false;
}
return result;
@ -458,7 +458,7 @@ namespace QuantumUNET
{
if (m_AsyncConnect != ConnectState.Connected)
{
QLog.LogError("NetworkClient SendBytes when not connected to a server");
QLog.Error("NetworkClient SendBytes when not connected to a server");
result = false;
}
else
@ -468,7 +468,7 @@ namespace QuantumUNET
}
else
{
QLog.LogError("NetworkClient SendBytes with no connection");
QLog.Error("NetworkClient SendBytes with no connection");
result = false;
}
return result;
@ -481,7 +481,7 @@ namespace QuantumUNET
{
if (m_AsyncConnect != ConnectState.Connected)
{
QLog.LogError("NetworkClient SendUnreliable when not connected to a server");
QLog.Error("NetworkClient SendUnreliable when not connected to a server");
result = false;
}
else
@ -491,7 +491,7 @@ namespace QuantumUNET
}
else
{
QLog.LogError("NetworkClient SendUnreliable with no connection");
QLog.Error("NetworkClient SendUnreliable with no connection");
result = false;
}
return result;
@ -504,7 +504,7 @@ namespace QuantumUNET
{
if (m_AsyncConnect != ConnectState.Connected)
{
QLog.LogError("NetworkClient SendByChannel when not connected to a server");
QLog.Error("NetworkClient SendByChannel when not connected to a server");
result = false;
}
else
@ -514,7 +514,7 @@ namespace QuantumUNET
}
else
{
QLog.LogError("NetworkClient SendByChannel with no connection");
QLog.Error("NetworkClient SendByChannel with no connection");
result = false;
}
return result;
@ -524,7 +524,7 @@ namespace QuantumUNET
{
if (m_Connection == null)
{
QLog.LogWarning("SetMaxDelay failed, not connected.");
QLog.Warning("SetMaxDelay failed, not connected.");
}
else
{
@ -622,7 +622,7 @@ namespace QuantumUNET
break;
default:
QLog.LogError($"Unknown network message type received: {networkEventType}");
QLog.Error($"Unknown network message type received: {networkEventType}");
break;
}
if (++num >= 500)
@ -657,19 +657,19 @@ namespace QuantumUNET
private void GenerateConnectError(int error)
{
QLog.LogError($"UNet Client Error Connect Error: {error}");
QLog.Error($"UNet Client Error Connect Error: {error}");
GenerateError(error);
}
private void GenerateDataError(int error)
{
QLog.LogError($"UNet Client Data Error: {(NetworkError)error}");
QLog.Error($"UNet Client Data Error: {(NetworkError)error}");
GenerateError(error);
}
private void GenerateDisconnectError(int error)
{
QLog.LogError($"UNet Client Disconnect Error: {(NetworkError)error}");
QLog.Error($"UNet Client Disconnect Error: {(NetworkError)error}");
GenerateError(error);
}

View File

@ -196,7 +196,7 @@ namespace QuantumUNET
return;
}
}
QLog.LogError($"RemovePlayer player at playerControllerId {playerControllerId} not found");
QLog.Error($"RemovePlayer player at playerControllerId {playerControllerId} not found");
}
internal bool GetPlayerController(short playerControllerId, out QPlayerController playerController)
@ -284,12 +284,12 @@ namespace QuantumUNET
bool result;
if (m_Channels == null)
{
QLog.LogWarning($"Channels not initialized sending on id '{channelId}");
QLog.Warning($"Channels not initialized sending on id '{channelId}");
result = false;
}
else if (channelId < 0 || channelId >= m_Channels.Length)
{
QLog.LogError(
QLog.Error(
$"Invalid channel when sending buffered data, '{channelId}'. Current channel count is {m_Channels.Length}");
result = false;
}
@ -325,7 +325,7 @@ namespace QuantumUNET
}
if (networkMessageDelegate == null)
{
QLog.LogError($"Unknown message ID {num2} connId:{connectionId}");
QLog.Error($"Unknown message ID {num2} connId:{connectionId}");
break;
}
m_NetMsg.MsgType = num2;

View File

@ -12,11 +12,11 @@ namespace QuantumUNET
{
if (handler == null)
{
QLog.LogError($"RegisterHandlerSafe id:{msgType} handler is null");
QLog.Error($"RegisterHandlerSafe id:{msgType} handler is null");
}
else
{
QLog.LogDebug($"RegisterHandlerSafe id:{msgType} handler:{handler.GetMethodName()}");
QLog.Debug($"RegisterHandlerSafe id:{msgType} handler:{handler.GetMethodName()}");
if (!_msgHandlers.ContainsKey(msgType))
{
_msgHandlers.Add(msgType, handler);
@ -28,11 +28,11 @@ namespace QuantumUNET
{
if (handler == null)
{
QLog.LogError($"RegisterHandler id:{msgType} handler is null");
QLog.Error($"RegisterHandler id:{msgType} handler is null");
}
else if (msgType <= 31)
{
QLog.LogError($"RegisterHandler: Cannot replace system message handler {msgType}");
QLog.Error($"RegisterHandler: Cannot replace system message handler {msgType}");
}
else
{
@ -41,7 +41,7 @@ namespace QuantumUNET
QLog.Log($"RegisterHandler replacing {msgType}");
_msgHandlers.Remove(msgType);
}
QLog.LogDebug($"RegisterHandler id:{msgType} handler:{handler.GetMethodName()}");
QLog.Debug($"RegisterHandler id:{msgType} handler:{handler.GetMethodName()}");
_msgHandlers.Add(msgType, handler);
}
}

View File

@ -164,7 +164,7 @@ namespace QuantumUNET
int result;
if (m_LocalConnectionsFakeList.Count != 0)
{
QLog.LogError("Local Connection already exists");
QLog.Error("Local Connection already exists");
result = -1;
}
else
@ -203,7 +203,7 @@ namespace QuantumUNET
internal void SetLocalObjectOnServer(NetworkInstanceId netId, GameObject obj)
{
QLog.LogDebug($"SetLocalObjectOnServer {netId} {obj}");
QLog.Debug($"SetLocalObjectOnServer {netId} {obj}");
m_NetworkScene.SetLocalObject(netId, obj, false, true);
}
@ -226,7 +226,7 @@ namespace QuantumUNET
public static bool SendToAll(short msgType, QMessageBase msg)
{
QLog.LogDebug($"Server.SendToAll msgType:{msgType}");
QLog.Debug($"Server.SendToAll msgType:{msgType}");
var flag = true;
foreach (var networkConnection in connections)
{
@ -240,7 +240,7 @@ namespace QuantumUNET
private static bool SendToObservers(GameObject contextObj, short msgType, QMessageBase msg)
{
QLog.LogDebug($"Server.SendToObservers id:{msgType}");
QLog.Debug($"Server.SendToObservers id:{msgType}");
var flag = true;
var component = contextObj.GetComponent<QNetworkIdentity>();
bool result;
@ -263,7 +263,7 @@ namespace QuantumUNET
public static bool SendToReady(GameObject contextObj, short msgType, QMessageBase msg)
{
QLog.LogDebug($"Server.SendToReady id:{msgType}");
QLog.Debug($"Server.SendToReady id:{msgType}");
bool result;
if (contextObj == null)
{
@ -329,7 +329,7 @@ namespace QuantumUNET
}
if (!flag)
{
QLog.LogError("SendBytesToReady failed");
QLog.Error("SendBytesToReady failed");
}
}
else
@ -352,12 +352,12 @@ namespace QuantumUNET
}
if (!flag2)
{
QLog.LogError($"SendBytesToReady failed for {contextObj}");
QLog.Error($"SendBytesToReady failed for {contextObj}");
}
}
catch (NullReferenceException)
{
QLog.LogError($"SendBytesToReady object {contextObj} has not been spawned");
QLog.Error($"SendBytesToReady object {contextObj} has not been spawned");
}
}
}
@ -558,7 +558,7 @@ namespace QuantumUNET
{
if (controller.Gameobject != null)
{
QLog.LogWarning("Player not destroyed when connection disconnected.");
QLog.Warning("Player not destroyed when connection disconnected.");
}
}
QLog.Log($"Server lost client:{conn.connectionId}");
@ -570,19 +570,19 @@ namespace QuantumUNET
private void GenerateConnectError(int error)
{
QLog.LogError($"UNet Server Connect Error: {error}");
QLog.Error($"UNet Server Connect Error: {error}");
GenerateError(null, error);
}
private void GenerateDataError(QNetworkConnection conn, int error)
{
QLog.LogError($"UNet Server Data Error: {(NetworkError)error}");
QLog.Error($"UNet Server Data Error: {(NetworkError)error}");
GenerateError(conn, error);
}
private void GenerateDisconnectError(QNetworkConnection conn, int error)
{
QLog.LogError($"UNet Server Disconnect Error: {(NetworkError)error} conn:[{conn}]:{conn.connectionId}");
QLog.Error($"UNet Server Disconnect Error: {(NetworkError)error} conn:[{conn}]:{conn.connectionId}");
GenerateError(conn, error);
}
@ -659,7 +659,7 @@ namespace QuantumUNET
}
}
}
QLog.LogError($"Failed to send message to player object '{player.name}, not found in connection list");
QLog.Error($"Failed to send message to player object '{player.name}, not found in connection list");
}
public static void SendToClient(int connectionId, short msgType, QMessageBase msg)
@ -673,7 +673,7 @@ namespace QuantumUNET
return;
}
}
QLog.LogError($"Failed to send message to connection ID '{connectionId}, not found in connection list");
QLog.Error($"Failed to send message to connection ID '{connectionId}, not found in connection list");
}
public static bool AddPlayerForConnection(QNetworkConnection conn, GameObject player, short playerControllerId) => instance.InternalAddPlayerForConnection(conn, player, playerControllerId);
@ -739,7 +739,7 @@ namespace QuantumUNET
bool result;
if (playerControllerId < 0)
{
QLog.LogError($"AddPlayer: playerControllerId of {playerControllerId} is negative");
QLog.Error($"AddPlayer: playerControllerId of {playerControllerId} is negative");
result = false;
}
else if (playerControllerId > 32)
@ -751,7 +751,7 @@ namespace QuantumUNET
{
if (playerControllerId > 16)
{
QLog.LogWarning($"AddPlayer: playerControllerId of {playerControllerId} is unusually high");
QLog.Warning($"AddPlayer: playerControllerId of {playerControllerId} is unusually high");
}
result = true;
}
@ -802,7 +802,7 @@ namespace QuantumUNET
bool result;
if (!GetNetworkIdentity(playerGameObject, out var networkIdentity))
{
QLog.LogError($"ReplacePlayer: playerGameObject has no NetworkIdentity. Please add a NetworkIdentity to {playerGameObject}");
QLog.Error($"ReplacePlayer: playerGameObject has no NetworkIdentity. Please add a NetworkIdentity to {playerGameObject}");
result = false;
}
else if (!CheckPlayerControllerIdForConnection(conn, playerControllerId))
@ -846,7 +846,7 @@ namespace QuantumUNET
bool result;
if (view == null)
{
QLog.LogError("UNET failure. GameObject doesn't have NetworkIdentity.");
QLog.Error("UNET failure. GameObject doesn't have NetworkIdentity.");
result = false;
}
else
@ -869,7 +869,7 @@ namespace QuantumUNET
{
if (conn.PlayerControllers.Count == 0)
{
QLog.LogWarning("Ready with no player object");
QLog.Warning("Ready with no player object");
}
conn.isReady = true;
if (conn is QULocalConnectionToClient)
@ -904,11 +904,11 @@ namespace QuantumUNET
{
if (networkIdentity2 == null)
{
QLog.LogWarning("Invalid object found in server local object list (null NetworkIdentity).");
QLog.Warning("Invalid object found in server local object list (null NetworkIdentity).");
}
else if (networkIdentity2.gameObject.activeSelf)
{
QLog.LogDebug(
QLog.Debug(
$"Sending spawn message for current server objects name='{networkIdentity2.gameObject.name}' netId={networkIdentity2.NetId}");
var flag2 = networkIdentity2.OnCheckObserver(conn);
if (flag2)
@ -981,7 +981,7 @@ namespace QuantumUNET
}
else
{
QLog.LogError(
QLog.Error(
$"Received remove player message but could not find the player ID: {s_RemovePlayerMessage.PlayerControllerId}");
}
}
@ -993,14 +993,14 @@ namespace QuantumUNET
var gameObject = FindLocalObject(networkInstanceId);
if (gameObject == null)
{
QLog.LogWarning($"Instance not found when handling Command message [netId={networkInstanceId}]");
QLog.Warning($"Instance not found when handling Command message [netId={networkInstanceId}]");
}
else
{
var component = gameObject.GetComponent<QNetworkIdentity>();
if (component == null)
{
QLog.LogWarning(
QLog.Warning(
$"NetworkIdentity deleted when handling Command message [netId={networkInstanceId}]");
}
else
@ -1018,7 +1018,7 @@ namespace QuantumUNET
{
if (component.ClientAuthorityOwner != netMsg.Connection)
{
QLog.LogWarning($"Command for object without authority [netId={networkInstanceId}]");
QLog.Warning($"Command for object without authority [netId={networkInstanceId}]");
return;
}
}
@ -1032,12 +1032,12 @@ namespace QuantumUNET
{
if (!active)
{
QLog.LogError(
QLog.Error(
$"SpawnObject for {obj}, NetworkServer is not active. Cannot spawn objects without an active server.");
}
else if (!GetNetworkIdentity(obj, out var networkIdentity))
{
QLog.LogError($"SpawnObject {obj} has no QSBNetworkIdentity. Please add a NetworkIdentity to {obj}");
QLog.Error($"SpawnObject {obj} has no QSBNetworkIdentity. Please add a NetworkIdentity to {obj}");
}
else
{
@ -1105,7 +1105,7 @@ namespace QuantumUNET
{
if (conn.PlayerControllers.Count == 0)
{
QLog.LogWarning("Empty player list given to NetworkServer.Destroy(), nothing to do.");
QLog.Warning("Empty player list given to NetworkServer.Destroy(), nothing to do.");
}
else
{
@ -1202,7 +1202,7 @@ namespace QuantumUNET
bool result;
if (CheckForPrefab(obj))
{
QLog.LogError($"GameObject {obj.name} is a prefab, it can't be spawned. This will cause errors in builds.");
QLog.Error($"GameObject {obj.name} is a prefab, it can't be spawned. This will cause errors in builds.");
result = false;
}
else
@ -1218,12 +1218,12 @@ namespace QuantumUNET
bool result;
if (component == null)
{
QLog.LogError("SpawnWithClientAuthority player object has no NetworkIdentity");
QLog.Error("SpawnWithClientAuthority player object has no NetworkIdentity");
result = false;
}
else if (component.ConnectionToClient == null)
{
QLog.LogError("SpawnWithClientAuthority player object is not a player.");
QLog.Error("SpawnWithClientAuthority player object is not a player.");
result = false;
}
else
@ -1238,7 +1238,7 @@ namespace QuantumUNET
bool result;
if (!conn.isReady)
{
QLog.LogError("SpawnWithClientAuthority NetworkConnection is not ready!");
QLog.Error("SpawnWithClientAuthority NetworkConnection is not ready!");
result = false;
}
else
@ -1304,7 +1304,7 @@ namespace QuantumUNET
}
else
{
QLog.LogError($"Local invoke: Failed to find local connection to invoke handler on [connectionId={conn.connectionId}] for MsgId:{msgType}");
QLog.Error($"Local invoke: Failed to find local connection to invoke handler on [connectionId={conn.connectionId}] for MsgId:{msgType}");
result = false;
}
return result;

View File

@ -64,7 +64,6 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Logging\FlagsHelper.cs" />
<Compile Include="Messages\QMsgType.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Messages\QAddPlayerMessage.cs" />
@ -72,7 +71,6 @@
<Compile Include="Messages\QAnimationParametersMessage.cs" />
<Compile Include="Messages\QAnimationTriggerMessage.cs" />
<Compile Include="Logging\QLog.cs" />
<Compile Include="Logging\QLogType.cs" />
<Compile Include="Transport\QChannelBuffer.cs" />
<Compile Include="Transport\QChannelPacket.cs" />
<Compile Include="Messages\QClientAuthorityMessage.cs" />

View File

@ -22,6 +22,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
<!-- TOC -->
- [FAQs](#frequently-asked-questions)
- [Requirements](#requirements)
- [What is synced?](#what-is-currently-synced)
- [Why can't I connect?](#why-cant-i-connect-to-a-server)
- [Installation](#installation)
@ -37,6 +38,14 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
## Frequently Asked Questions
### Requirements
- Latest version of OWML.
- Latest version of Mod Manager. (If using)
- Latest version of Outer Wilds. (Epic version preferred, as Steam version is untestable.)
- Fast and stable internet connection, upload and download.
- Should be able to run on minimum Outer Wilds system requirements.
- Ability to port forward.
### What is currently synced?
QSB does not operate on a strict server-client relationship. Each player's game is left as a completely seperate game, and individual elemets are synced or patched so they can be controlled though network messages. Right now, the list of synced objects are :
- Geysers
@ -47,6 +56,14 @@ QSB does not operate on a strict server-client relationship. Each player's game
- Player ships
- Player probes
- NPC heads in conversations
- Ship log
- Discovering frequencies / signals
- Nomai text (Spirals + Computers)
QSB also changes some mechanics of the base game, to better fit a multiplayer experience. These include :
- Adding dialogue boxes above NPC and player heads, so other players can "listen in" on conversations.
- Quantum objects check observations from all players and all player probes.
- When dying from any cause other than the supernova, the ATP black hole, or the end of the game, the player respawns instantly at Timber Hearth.
### Why can't I connect to a server?
#### For the host :