mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2024-12-29 03:28:26 +00:00
cleanup
This commit is contained in:
parent
adb334bfe8
commit
6d2ce234f5
@ -23,7 +23,6 @@ namespace QSB.ConversationSync
|
||||
Instance = this;
|
||||
|
||||
ConversationAssetBundle = QSB.Helper.Assets.LoadBundle("assets/conversation");
|
||||
DebugLog.LogState("ConversationBundle", ConversationAssetBundle);
|
||||
|
||||
BoxPrefab = ConversationAssetBundle.LoadAsset<GameObject>("assets/dialoguebubble.prefab");
|
||||
var font = (Font)Resources.Load(@"fonts\english - latin\spacemono-bold");
|
||||
@ -33,7 +32,6 @@ namespace QSB.ConversationSync
|
||||
}
|
||||
BoxPrefab.GetComponent<Text>().font = font;
|
||||
BoxPrefab.GetComponent<Text>().color = Color.white;
|
||||
DebugLog.LogState("BoxPrefab", BoxPrefab);
|
||||
}
|
||||
|
||||
public uint GetPlayerTalkingToTree(CharacterDialogueTree tree)
|
||||
|
@ -6,7 +6,7 @@
|
||||
ServerTime,
|
||||
AnimTrigger,
|
||||
PlayerState,
|
||||
FullStateRequest,
|
||||
PlayerStatesRequest,
|
||||
FlashlightActiveChange,
|
||||
SignalscopeActiveChange,
|
||||
TranslatorActiveChange,
|
||||
|
@ -13,11 +13,11 @@ namespace QSB.EventsCore
|
||||
{
|
||||
public abstract EventType Type { get; }
|
||||
public uint LocalPlayerId => QSBPlayerManager.LocalPlayerId;
|
||||
private readonly QSBMessageHandler<T> _eventHandler;
|
||||
private readonly MessageHandler<T> _eventHandler;
|
||||
|
||||
protected QSBEvent()
|
||||
{
|
||||
_eventHandler = new QSBMessageHandler<T>(Type);
|
||||
_eventHandler = new MessageHandler<T>(Type);
|
||||
_eventHandler.OnClientReceiveMessage += OnClientReceive;
|
||||
_eventHandler.OnServerReceiveMessage += OnServerReceive;
|
||||
}
|
||||
|
@ -45,14 +45,15 @@ namespace QSB.EventsCore
|
||||
new OrbUserEvent(),
|
||||
new ConversationEvent(),
|
||||
new ConversationStartEndEvent(),
|
||||
new PlayInstrumentEvent()
|
||||
new PlayInstrumentEvent(),
|
||||
new ServerSendPlayerStatesEvent()
|
||||
};
|
||||
|
||||
_eventList.ForEach(ev => ev.SetupListener());
|
||||
|
||||
Ready = true;
|
||||
|
||||
DebugLog.DebugWrite($"Event manager ready.", MessageType.Success);
|
||||
DebugLog.DebugWrite("Event Manager ready.", MessageType.Success);
|
||||
}
|
||||
|
||||
public static void Reset()
|
||||
|
@ -8,14 +8,14 @@ using UnityEngine.Networking;
|
||||
namespace QSB.Messaging
|
||||
{
|
||||
// Extend this to create new message handlers.
|
||||
public class QSBMessageHandler<T> where T : MessageBase, new()
|
||||
public class MessageHandler<T> where T : MessageBase, new()
|
||||
{
|
||||
public event Action<T> OnClientReceiveMessage;
|
||||
public event Action<T> OnServerReceiveMessage;
|
||||
|
||||
private readonly EventType _eventType;
|
||||
|
||||
public QSBMessageHandler(EventType eventType)
|
||||
public MessageHandler(EventType eventType)
|
||||
{
|
||||
_eventType = eventType + MsgType.Highest + 1;
|
||||
if (QSBNetworkManager.Instance.IsReady)
|
||||
@ -33,13 +33,11 @@ namespace QSB.Messaging
|
||||
var eventName = Enum.GetName(typeof(EventType), _eventType - 1 - MsgType.Highest).ToUpper();
|
||||
if (NetworkServer.handlers.Keys.Contains((short)_eventType))
|
||||
{
|
||||
DebugLog.LogState($"({_eventType}) {eventName} HANDLER", false);
|
||||
DebugLog.ToConsole($"Warning - NetworkServer already contains a handler for EventType {_eventType}", MessageType.Warning);
|
||||
NetworkServer.handlers.Remove((short)_eventType);
|
||||
}
|
||||
NetworkServer.RegisterHandler((short)_eventType, OnServerReceiveMessageHandler);
|
||||
NetworkManager.singleton.client.RegisterHandler((short)_eventType, OnClientReceiveMessageHandler);
|
||||
DebugLog.LogState($"({_eventType}) {eventName} HANDLER", true);
|
||||
}
|
||||
|
||||
public void SendToAll(T message)
|
@ -28,7 +28,7 @@ namespace QSB.Patches
|
||||
new ProbePatches()
|
||||
};
|
||||
|
||||
DebugLog.DebugWrite($"Patch manager ready.", MessageType.Success);
|
||||
DebugLog.DebugWrite("Patch Manager ready.", MessageType.Success);
|
||||
}
|
||||
|
||||
public static void DoPatchType(QSBPatchTypes type)
|
||||
|
@ -37,6 +37,11 @@ namespace QSB.Player.Events
|
||||
public override void OnReceiveRemote(ToggleMessage message)
|
||||
{
|
||||
DebugLog.DebugWrite($"Get ready event from {message.FromId}", MessageType.Success);
|
||||
if (!QSBPlayerManager.PlayerExists(message.FromId))
|
||||
{
|
||||
DebugLog.ToConsole("Error - Got ready event for non-existent player! Did we not send a PlayerStatesRequestEvent? Or was it not handled?", MessageType.Error);
|
||||
return;
|
||||
}
|
||||
foreach (var item in QSBPlayerManager.GetSyncObjects<TransformSync.TransformSync>()
|
||||
.Where(x => x != null && x.IsReady && x.ReferenceSector != null && x.PlayerId == LocalPlayerId))
|
||||
{
|
||||
|
@ -8,7 +8,7 @@ namespace QSB.Player.Events
|
||||
{
|
||||
public class PlayerStatesRequestEvent : QSBEvent<PlayerMessage>
|
||||
{
|
||||
public override EventType Type => EventType.FullStateRequest;
|
||||
public override EventType Type => EventType.PlayerStatesRequest;
|
||||
|
||||
public override void SetupListener() => GlobalMessenger.AddListener(EventNames.QSBPlayerStatesRequest, Handler);
|
||||
|
||||
|
@ -1,4 +1,6 @@
|
||||
using QSB.EventsCore;
|
||||
using OWML.Common;
|
||||
using QSB.EventsCore;
|
||||
using QSB.Utility;
|
||||
|
||||
namespace QSB.Player.Events
|
||||
{
|
||||
@ -14,6 +16,7 @@ namespace QSB.Player.Events
|
||||
{
|
||||
foreach (var player in QSBPlayerManager.PlayerList)
|
||||
{
|
||||
DebugLog.DebugWrite($" - Sending playerstate of player ID {player.PlayerId}", MessageType.Info);
|
||||
SendEvent(CreateMessage(player));
|
||||
}
|
||||
}
|
||||
@ -28,6 +31,7 @@ namespace QSB.Player.Events
|
||||
|
||||
public override void OnReceiveRemote(PlayerStateMessage message)
|
||||
{
|
||||
DebugLog.DebugWrite($"Received playerstate of player ID {message.AboutId}", MessageType.Info);
|
||||
QSB.Helper.Events.Unity.RunWhen(
|
||||
() => QSBPlayerManager.GetSyncObject<TransformSync.TransformSync>(message.AboutId) != null,
|
||||
() => QSBPlayerManager.HandleFullStateMessage(message));
|
||||
|
@ -33,7 +33,6 @@ namespace QSB
|
||||
DebugLog.ToConsole($"* Start of QSB version {Helper.Manifest.Version} - authored by {Helper.Manifest.Author}", MessageType.Info);
|
||||
|
||||
NetworkAssetBundle = Helper.Assets.LoadBundle("assets/network");
|
||||
DebugLog.LogState("NetworkBundle", NetworkAssetBundle);
|
||||
|
||||
QSBPatchManager.Init();
|
||||
|
||||
|
@ -205,7 +205,7 @@
|
||||
<Compile Include="DeathSync\Necronomicon.cs" />
|
||||
<Compile Include="Utility\DebugLog.cs" />
|
||||
<Compile Include="MessagesCore\PlayerMessage.cs" />
|
||||
<Compile Include="MessagesCore\QSBMessageHandler.cs" />
|
||||
<Compile Include="MessagesCore\MessageHandler.cs" />
|
||||
<Compile Include="EventsCore\EventType.cs" />
|
||||
<Compile Include="Player\PlayerInfo.cs" />
|
||||
<Compile Include="Player\State.cs" />
|
||||
|
@ -49,27 +49,22 @@ namespace QSB
|
||||
playerPrefab.AddComponent<PlayerTransformSync>();
|
||||
playerPrefab.AddComponent<AnimationSync>();
|
||||
playerPrefab.AddComponent<WakeUpSync>();
|
||||
DebugLog.LogState("PlayerPrefab", playerPrefab);
|
||||
|
||||
_shipPrefab = _assetBundle.LoadAsset<GameObject>("assets/networkship.prefab");
|
||||
_shipPrefab.AddComponent<ShipTransformSync>();
|
||||
spawnPrefabs.Add(_shipPrefab);
|
||||
DebugLog.LogState("ShipPrefab", _shipPrefab);
|
||||
|
||||
_cameraPrefab = _assetBundle.LoadAsset<GameObject>("assets/networkcameraroot.prefab");
|
||||
_cameraPrefab.AddComponent<PlayerCameraSync>();
|
||||
spawnPrefabs.Add(_cameraPrefab);
|
||||
DebugLog.LogState("CameraPrefab", _cameraPrefab);
|
||||
|
||||
_probePrefab = _assetBundle.LoadAsset<GameObject>("assets/networkprobe.prefab");
|
||||
_probePrefab.AddComponent<PlayerProbeSync>();
|
||||
spawnPrefabs.Add(_probePrefab);
|
||||
DebugLog.LogState("ProbePrefab", _probePrefab);
|
||||
|
||||
OrbPrefab = _assetBundle.LoadAsset<GameObject>("assets/networkorb.prefab");
|
||||
OrbPrefab.AddComponent<NomaiOrbTransformSync>();
|
||||
spawnPrefabs.Add(OrbPrefab);
|
||||
DebugLog.LogState("OrbPrefab", OrbPrefab);
|
||||
|
||||
ConfigureNetworkManager();
|
||||
QSBSceneManager.OnSceneLoaded += OnSceneLoaded;
|
||||
@ -102,6 +97,8 @@ namespace QSB
|
||||
this.SetValue("m_MaxBufferedPackets", MaxBufferedPackets);
|
||||
channels.Add(QosType.Reliable);
|
||||
channels.Add(QosType.Unreliable);
|
||||
|
||||
DebugLog.DebugWrite("Network Manager ready.", MessageType.Success);
|
||||
}
|
||||
|
||||
public override void OnStartServer()
|
||||
|
@ -1,4 +1,6 @@
|
||||
using System;
|
||||
using OWML.Common;
|
||||
using QSB.Utility;
|
||||
using System;
|
||||
|
||||
namespace QSB
|
||||
{
|
||||
@ -13,6 +15,7 @@ namespace QSB
|
||||
static QSBSceneManager()
|
||||
{
|
||||
LoadManager.OnCompleteSceneLoad += OnCompleteSceneLoad;
|
||||
DebugLog.DebugWrite("Scene Manager ready.", MessageType.Success);
|
||||
}
|
||||
|
||||
private static void OnCompleteSceneLoad(OWScene oldScene, OWScene newScene)
|
||||
|
@ -1,4 +1,6 @@
|
||||
using QSB.WorldSync;
|
||||
using OWML.Common;
|
||||
using QSB.Utility;
|
||||
using QSB.WorldSync;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
@ -19,10 +21,12 @@ namespace QSB.SectorSync
|
||||
{
|
||||
Instance = this;
|
||||
QSBSceneManager.OnSceneLoaded += (OWScene scene, bool universe) => RebuildSectors();
|
||||
DebugLog.DebugWrite("Sector Manager ready.", MessageType.Success);
|
||||
}
|
||||
|
||||
public void RebuildSectors()
|
||||
{
|
||||
DebugLog.DebugWrite("Rebuilding sectors...", MessageType.Warning);
|
||||
WorldRegistry.RemoveObjects<QSBSector>();
|
||||
var sectors = Resources.FindObjectsOfTypeAll<Sector>().ToList();
|
||||
for (var id = 0; id < sectors.Count; id++)
|
||||
|
@ -43,13 +43,6 @@ namespace QSB.Utility
|
||||
}
|
||||
}
|
||||
|
||||
public static void LogState(string name, bool state)
|
||||
{
|
||||
var status = state ? "OK" : "FAIL";
|
||||
var messageType = state ? MessageType.Success : MessageType.Error;
|
||||
DebugWrite($"* {name} {status}", messageType);
|
||||
}
|
||||
|
||||
private static string GetCallingType(StackTrace frame)
|
||||
{
|
||||
var stackFrame = frame.GetFrames().First(x => x.GetMethod().DeclaringType.Name != "DebugLog");
|
||||
|
Loading…
Reference in New Issue
Block a user