Merge pull request #213 from misternebula/cleanup

Cleanup
This commit is contained in:
Mister_Nebula 2020-11-07 11:20:05 +00:00 committed by GitHub
commit fbf0a978c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
84 changed files with 495 additions and 409 deletions

View File

@ -1,5 +1,6 @@
using OWML.ModHelper.Events;
using QSB.Events;
using QSB.EventsCore;
using QSB.Player;
using System;
using System.Linq;
using UnityEngine;
@ -56,7 +57,7 @@ namespace QSB.Animation
mirror.Init(_anim, _bodyAnim);
}
PlayerRegistry.PlayerSyncObjects.Add(this);
QSBPlayerManager.PlayerSyncObjects.Add(this);
for (var i = 0; i < _anim.parameterCount; i++)
{

View File

@ -1,4 +1,6 @@
using System.Collections.Generic;
using OWML.Common;
using QSB.Utility;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
@ -52,6 +54,11 @@ namespace QSB.Animation
switch (fromParam.type)
{
case AnimatorControllerParameterType.Float:
if (!_floatParams.ContainsKey(fromParam.name))
{
DebugLog.ToConsole($"Warning - Tried to sync anim float that doesn't exist in dict : {fromParam.name}", MessageType.Warning);
break;
}
_floatParams[fromParam.name].Target = _from.GetFloat(fromParam.name);
break;
case AnimatorControllerParameterType.Bool:

View File

@ -1,7 +1,7 @@
using QSB.Events;
using QSB.Messaging;
using QSB.EventsCore;
using QSB.Player;
namespace QSB.Animation
namespace QSB.Animation.Events
{
public class AnimTriggerEvent : QSBEvent<AnimTriggerMessage>
{
@ -22,7 +22,7 @@ namespace QSB.Animation
public override void OnReceiveRemote(AnimTriggerMessage message)
{
var animationSync = PlayerRegistry.GetSyncObject<AnimationSync>(message.AboutId);
var animationSync = QSBPlayerManager.GetSyncObject<AnimationSync>(message.AboutId);
if (animationSync == null)
{
return;

View File

@ -1,7 +1,7 @@
using QSB.Messaging;
using UnityEngine.Networking;
namespace QSB.Animation
namespace QSB.Animation.Events
{
public class AnimTriggerMessage : PlayerMessage
{

View File

@ -1,5 +1,6 @@
using QSB.Events;
using QSB.EventsCore;
using QSB.Messaging;
using QSB.Player;
namespace QSB.Animation
{
@ -30,13 +31,13 @@ namespace QSB.Animation
public override void OnReceiveRemote(ToggleMessage message)
{
var player = PlayerRegistry.GetPlayer(message.AboutId);
var player = QSBPlayerManager.GetPlayer(message.AboutId);
player?.UpdateState(State.Suit, message.ToggleValue);
}
public override void OnReceiveLocal(ToggleMessage message)
{
PlayerRegistry.LocalPlayer.UpdateState(State.Suit, message.ToggleValue);
QSBPlayerManager.LocalPlayer.UpdateState(State.Suit, message.ToggleValue);
}
}
}

View File

@ -1,6 +1,7 @@
using OWML.Common;
using OWML.ModHelper.Events;
using QSB.Events;
using QSB.EventsCore;
using QSB.Player;
using QSB.Utility;
using QSB.WorldSync;
using System.Collections.Generic;
@ -22,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");
@ -32,25 +32,24 @@ namespace QSB.ConversationSync
}
BoxPrefab.GetComponent<Text>().font = font;
BoxPrefab.GetComponent<Text>().color = Color.white;
DebugLog.LogState("BoxPrefab", BoxPrefab);
}
public uint GetPlayerTalkingToTree(CharacterDialogueTree tree)
{
var treeIndex = WorldRegistry.OldDialogueTrees.IndexOf(tree);
if (!PlayerRegistry.PlayerList.Any(x => x.CurrentDialogueID == treeIndex))
if (!QSBPlayerManager.PlayerList.Any(x => x.CurrentDialogueID == treeIndex))
{
// No player talking to tree
return uint.MaxValue;
}
// .First() should be fine here as only one player should be talking to a character.
return PlayerRegistry.PlayerList.First(x => x.CurrentDialogueID == treeIndex).PlayerId;
return QSBPlayerManager.PlayerList.First(x => x.CurrentDialogueID == treeIndex).PlayerId;
}
public void SendPlayerOption(string text)
{
GlobalMessenger<uint, string, ConversationType>
.FireEvent(EventNames.QSBConversation, PlayerRegistry.LocalPlayerId, text, ConversationType.Player);
.FireEvent(EventNames.QSBConversation, QSBPlayerManager.LocalPlayerId, text, ConversationType.Player);
}
public void SendCharacterDialogue(int id, string text)
@ -67,7 +66,7 @@ namespace QSB.ConversationSync
public void CloseBoxPlayer()
{
GlobalMessenger<uint, string, ConversationType>
.FireEvent(EventNames.QSBConversation, PlayerRegistry.LocalPlayerId, "", ConversationType.ClosePlayer);
.FireEvent(EventNames.QSBConversation, QSBPlayerManager.LocalPlayerId, "", ConversationType.ClosePlayer);
}
public void CloseBoxCharacter(int id)
@ -84,18 +83,18 @@ namespace QSB.ConversationSync
return;
}
GlobalMessenger<int, uint, bool>
.FireEvent(EventNames.QSBConversationStartEnd, charId, PlayerRegistry.LocalPlayerId, state);
.FireEvent(EventNames.QSBConversationStartEnd, charId, QSBPlayerManager.LocalPlayerId, state);
}
public void DisplayPlayerConversationBox(uint playerId, string text)
{
if (playerId == PlayerRegistry.LocalPlayerId)
if (playerId == QSBPlayerManager.LocalPlayerId)
{
DebugLog.ToConsole("Error - Cannot display conversation box for local player!", MessageType.Error);
return;
}
var player = PlayerRegistry.GetPlayer(playerId);
var player = QSBPlayerManager.GetPlayer(playerId);
// Destroy old box if it exists
var playerBox = player.CurrentDialogueBox;
@ -104,7 +103,7 @@ namespace QSB.ConversationSync
Destroy(playerBox);
}
PlayerRegistry.GetPlayer(playerId).CurrentDialogueBox = CreateBox(player.Body.transform, 25, text);
QSBPlayerManager.GetPlayer(playerId).CurrentDialogueBox = CreateBox(player.Body.transform, 25, text);
}
public void DisplayCharacterConversationBox(int index, string text)

View File

@ -1,4 +1,5 @@
using OWML.Common;
using QSB.Player;
using QSB.Utility;
using QSB.WorldSync;
using System.Collections.Generic;
@ -6,8 +7,10 @@ using UnityEngine;
namespace QSB.ConversationSync
{
public static class ConversationPatches
public class ConversationPatches : QSBPatch
{
public override QSBPatchTypes Type => QSBPatchTypes.OnClientConnect;
public static void StartConversation(CharacterDialogueTree __instance)
{
var index = WorldRegistry.OldDialogueTrees.FindIndex(x => x == __instance);
@ -15,7 +18,7 @@ namespace QSB.ConversationSync
{
DebugLog.ToConsole($"Warning - Index for tree {__instance.name} was -1.", MessageType.Warning);
}
PlayerRegistry.LocalPlayer.CurrentDialogueID = index;
QSBPlayerManager.LocalPlayer.CurrentDialogueID = index;
ConversationManager.Instance.SendConvState(index, true);
}
@ -25,14 +28,14 @@ namespace QSB.ConversationSync
{
return false;
}
if (PlayerRegistry.LocalPlayer.CurrentDialogueID == -1)
if (QSBPlayerManager.LocalPlayer.CurrentDialogueID == -1)
{
DebugLog.ToConsole($"Warning - Ending conversation with CurrentDialogueId of -1! Called from {__instance.name}", MessageType.Warning);
return false;
}
ConversationManager.Instance.SendConvState(PlayerRegistry.LocalPlayer.CurrentDialogueID, false);
ConversationManager.Instance.CloseBoxCharacter(PlayerRegistry.LocalPlayer.CurrentDialogueID);
PlayerRegistry.LocalPlayer.CurrentDialogueID = -1;
ConversationManager.Instance.SendConvState(QSBPlayerManager.LocalPlayer.CurrentDialogueID, false);
ConversationManager.Instance.CloseBoxCharacter(QSBPlayerManager.LocalPlayer.CurrentDialogueID);
QSBPlayerManager.LocalPlayer.CurrentDialogueID = -1;
ConversationManager.Instance.CloseBoxPlayer();
return true;
}
@ -55,8 +58,8 @@ namespace QSB.ConversationSync
{
var key = ____name + ____listPagesToDisplay[____currentPage];
// Sending key so translation can be done on client side - should make different language-d clients compatible
QSB.Helper.Events.Unity.RunWhen(() => PlayerRegistry.LocalPlayer.CurrentDialogueID != -1,
() => ConversationManager.Instance.SendCharacterDialogue(PlayerRegistry.LocalPlayer.CurrentDialogueID, key));
QSB.Helper.Events.Unity.RunWhen(() => QSBPlayerManager.LocalPlayer.CurrentDialogueID != -1,
() => ConversationManager.Instance.SendCharacterDialogue(QSBPlayerManager.LocalPlayer.CurrentDialogueID, key));
}
public static bool OnAnimatorIK(float ___headTrackingWeight,
@ -78,7 +81,7 @@ namespace QSB.ConversationSync
}
else
{
position = PlayerRegistry.GetPlayer(playerId).Camera.transform.position;
position = QSBPlayerManager.GetPlayer(playerId).Camera.transform.position;
}
float b = ___headTrackingWeight * Mathf.Min(1, (!___lookOnlyWhenTalking) ? ((!____playerInHeadZone) ? 0 : 1) : ((!____inConversation || !____playerInHeadZone) ? 0 : 1));
____currentLookWeight = Mathf.Lerp(____currentLookWeight, b, Time.deltaTime * 2f);
@ -98,7 +101,7 @@ namespace QSB.ConversationSync
return false;
}
public static void AddPatches()
public override void DoPatches()
{
QSB.Helper.HarmonyHelper.AddPostfix<DialogueNode>("GetNextPage", typeof(ConversationPatches), nameof(GetNextPage));
QSB.Helper.HarmonyHelper.AddPrefix<CharacterDialogueTree>("InputDialogueOption", typeof(ConversationPatches), nameof(InputDialogueOption));

View File

@ -1,8 +1,8 @@
using QSB.Events;
using QSB.Messaging;
using QSB.EventsCore;
using QSB.Player;
using QSB.WorldSync;
namespace QSB.ConversationSync
namespace QSB.ConversationSync.Events
{
public class ConversationEvent : QSBEvent<ConversationMessage>
{
@ -42,7 +42,7 @@ namespace QSB.ConversationSync
UnityEngine.Object.Destroy(ConversationManager.Instance.BoxMappings[tree]);
break;
case ConversationType.ClosePlayer:
UnityEngine.Object.Destroy(PlayerRegistry.GetPlayer((uint)message.ObjectId).CurrentDialogueBox);
UnityEngine.Object.Destroy(QSBPlayerManager.GetPlayer((uint)message.ObjectId).CurrentDialogueBox);
break;
}
}

View File

@ -1,7 +1,7 @@
using QSB.Messaging;
using UnityEngine.Networking;
namespace QSB.ConversationSync
namespace QSB.ConversationSync.Events
{
public class ConversationMessage : PlayerMessage
{

View File

@ -1,16 +1,17 @@
using OWML.Common;
using OWML.ModHelper.Events;
using QSB.Events;
using QSB.EventsCore;
using QSB.Player;
using QSB.Utility;
using QSB.WorldSync;
using System.Linq;
using UnityEngine;
namespace QSB.ConversationSync
namespace QSB.ConversationSync.Events
{
public class ConversationStartEndEvent : QSBEvent<ConversationStartEndMessage>
{
public override Messaging.EventType Type => Messaging.EventType.ConversationStartEnd;
public override EventsCore.EventType Type => EventsCore.EventType.ConversationStartEnd;
public override void SetupListener() => GlobalMessenger<int, uint, bool>.AddListener(EventNames.QSBConversationStartEnd, Handler);
@ -42,7 +43,7 @@ namespace QSB.ConversationSync
if (message.State)
{
// Start talking
PlayerRegistry.GetPlayer(message.PlayerId).CurrentDialogueID = message.CharacterId;
QSBPlayerManager.GetPlayer(message.PlayerId).CurrentDialogueID = message.CharacterId;
animController.SetValue("_inConversation", true);
animController.SetValue("_playerInHeadZone", true);
if (animController.GetValue<bool>("_hasTalkAnimation"))
@ -54,7 +55,7 @@ namespace QSB.ConversationSync
else
{
// Stop talking
PlayerRegistry.GetPlayer(message.PlayerId).CurrentDialogueID = -1;
QSBPlayerManager.GetPlayer(message.PlayerId).CurrentDialogueID = -1;
animController.SetValue("_inConversation", false);
animController.SetValue("_playerInHeadZone", false);
if (animController.GetValue<bool>("_hasTalkAnimation"))
@ -72,7 +73,7 @@ namespace QSB.ConversationSync
if (message.State)
{
DebugLog.DebugWrite("start convo faceplayer for " + message.CharacterId);
qsbFacePlayer.StartConversation(PlayerRegistry.GetPlayer(message.PlayerId).Body.transform.position);
qsbFacePlayer.StartConversation(QSBPlayerManager.GetPlayer(message.PlayerId).Body.transform.position);
}
else
{

View File

@ -1,7 +1,7 @@
using QSB.Messaging;
using UnityEngine.Networking;
namespace QSB.ConversationSync
namespace QSB.ConversationSync.Events
{
public class ConversationStartEndMessage : PlayerMessage
{

View File

@ -1,10 +1,12 @@
using QSB.Events;
using QSB.EventsCore;
using System.Linq;
namespace QSB.DeathSync
{
public static class DeathPatches
public class DeathPatches : QSBPatch
{
public override QSBPatchTypes Type => QSBPatchTypes.OnModStart;
public static bool PreFinishDeathSequence(DeathType deathType)
{
if (RespawnOnDeath.Instance.AllowedDeathTypes.Contains(deathType))
@ -25,11 +27,10 @@ namespace QSB.DeathSync
GlobalMessenger<DeathType>.FireEvent(EventNames.QSBPlayerDeath, deathType);
}
public static void DoPatches()
public override void DoPatches()
{
QSB.Helper.HarmonyHelper.AddPrefix<DeathManager>("KillPlayer", typeof(DeathPatches), nameof(PreFinishDeathSequence));
QSB.Helper.HarmonyHelper.AddPostfix<DeathManager>("KillPlayer", typeof(DeathPatches), nameof(BroadcastDeath));
}
}
}

View File

@ -1,8 +1,8 @@
using QSB.Events;
using QSB.Messaging;
using QSB.EventsCore;
using QSB.Player;
using QSB.Utility;
namespace QSB.DeathSync
namespace QSB.DeathSync.Events
{
public class PlayerDeathEvent : QSBEvent<PlayerDeathMessage>
{
@ -22,7 +22,7 @@ namespace QSB.DeathSync
public override void OnReceiveRemote(PlayerDeathMessage message)
{
var playerName = PlayerRegistry.GetPlayer(message.AboutId).Name;
var playerName = QSBPlayerManager.GetPlayer(message.AboutId).Name;
var deathMessage = Necronomicon.GetPhrase(message.DeathType);
DebugLog.ToAll(string.Format(deathMessage, playerName));
}

View File

@ -1,7 +1,7 @@
using QSB.Messaging;
using UnityEngine.Networking;
namespace QSB.DeathSync
namespace QSB.DeathSync.Events
{
public class PlayerDeathMessage : PlayerMessage
{

View File

@ -1,6 +1,6 @@
using OWML.Common;
using OWML.ModHelper.Events;
using QSB.Events;
using QSB.EventsCore;
using QSB.Utility;
using System.Linq;
using UnityEngine;

View File

@ -1,8 +0,0 @@
namespace QSB.ElevatorSync
{
public enum ElevatorDirection
{
Up,
Down
}
}

View File

@ -1,29 +0,0 @@
using QSB.Events;
using QSB.Messaging;
using QSB.WorldSync;
namespace QSB.ElevatorSync
{
public class ElevatorEvent : QSBEvent<ElevatorMessage>
{
public override EventType Type => EventType.Elevator;
public override void SetupListener() => GlobalMessenger<int, ElevatorDirection>.AddListener(EventNames.QSBStartLift, Handler);
public override void CloseListener() => GlobalMessenger<int, ElevatorDirection>.RemoveListener(EventNames.QSBStartLift, Handler);
private void Handler(int id, ElevatorDirection direction) => SendEvent(CreateMessage(id, direction));
private ElevatorMessage CreateMessage(int id, ElevatorDirection direction) => new ElevatorMessage
{
Direction = direction,
ObjectId = id
};
public override void OnReceiveRemote(ElevatorMessage message)
{
var elevator = WorldRegistry.GetObject<QSBElevator>(message.ObjectId);
elevator?.RemoteCall(message.Direction);
}
}
}

View File

@ -15,7 +15,6 @@ namespace QSB.ElevatorSync
{
Instance = this;
QSBSceneManager.OnSceneLoaded += OnSceneLoaded;
QSB.Helper.HarmonyHelper.AddPostfix<Elevator>("StartLift", typeof(ElevatorPatches), nameof(ElevatorPatches.StartLift));
}
private void OnSceneLoaded(OWScene scene, bool isInUniverse)

View File

@ -1,22 +0,0 @@
using QSB.WorldSync;
using UnityEngine.Networking;
namespace QSB.ElevatorSync
{
public class ElevatorMessage : WorldObjectMessage
{
public ElevatorDirection Direction { get; set; }
public override void Deserialize(NetworkReader reader)
{
base.Deserialize(reader);
Direction = (ElevatorDirection)reader.ReadInt32();
}
public override void Serialize(NetworkWriter writer)
{
base.Serialize(writer);
writer.Write((int)Direction);
}
}
}

View File

@ -1,16 +1,22 @@
using OWML.ModHelper.Events;
using QSB.Events;
using QSB.EventsCore;
namespace QSB.ElevatorSync
{
public static class ElevatorPatches
public class ElevatorPatches : QSBPatch
{
public override QSBPatchTypes Type => QSBPatchTypes.OnModStart;
public static void StartLift(Elevator __instance)
{
var isGoingUp = __instance.GetValue<bool>("_goingToTheEnd");
var direction = isGoingUp ? ElevatorDirection.Up : ElevatorDirection.Down;
var id = ElevatorManager.Instance.GetId(__instance);
GlobalMessenger<int, ElevatorDirection>.FireEvent(EventNames.QSBStartLift, id, direction);
GlobalMessenger<int, bool>.FireEvent(EventNames.QSBStartLift, id, isGoingUp);
}
public override void DoPatches()
{
QSB.Helper.HarmonyHelper.AddPostfix<Elevator>("StartLift", typeof(ElevatorPatches), nameof(StartLift));
}
}
}

View File

@ -0,0 +1,29 @@
using QSB.EventsCore;
using QSB.WorldSync;
using QSB.WorldSync.Events;
namespace QSB.ElevatorSync.Events
{
public class ElevatorEvent : QSBEvent<BoolWorldObjectMessage>
{
public override EventType Type => EventType.Elevator;
public override void SetupListener() => GlobalMessenger<int, bool>.AddListener(EventNames.QSBStartLift, Handler);
public override void CloseListener() => GlobalMessenger<int, bool>.RemoveListener(EventNames.QSBStartLift, Handler);
private void Handler(int id, bool direction) => SendEvent(CreateMessage(id, direction));
private BoolWorldObjectMessage CreateMessage(int id, bool direction) => new BoolWorldObjectMessage
{
State = direction,
ObjectId = id
};
public override void OnReceiveRemote(BoolWorldObjectMessage message)
{
var elevator = WorldRegistry.GetObject<QSBElevator>(message.ObjectId);
elevator?.RemoteCall(message.State);
}
}
}

View File

@ -30,15 +30,15 @@ namespace QSB.ElevatorSync
_owAudioSourceLP = _elevator.GetValue<OWAudioSource>("_owAudioSourceLP");
}
public void RemoteCall(ElevatorDirection direction)
public void RemoteCall(bool direction)
{
SetDirection(direction);
RemoteStartLift();
}
private void SetDirection(ElevatorDirection direction)
private void SetDirection(bool direction)
{
var isGoingUp = direction == ElevatorDirection.Up;
var isGoingUp = direction;
var targetPos = isGoingUp ? _endLocalPos : _startLocalPos;
_elevator.SetValue("_goingToTheEnd", isGoingUp);
_elevator.SetValue("_targetLocalPos", targetPos);

View File

@ -1,47 +0,0 @@
using QSB.Messaging;
using UnityEngine.Networking;
namespace QSB.Events
{
public class PlayerState : NetworkBehaviour
{
public static PlayerState LocalInstance { get; private set; }
private MessageHandler<PlayerStateMessage> _messageHandler;
private void Awake()
{
_messageHandler = new MessageHandler<PlayerStateMessage>(EventType.FullState);
_messageHandler.OnClientReceiveMessage += OnClientReceiveMessage;
LocalInstance = this;
}
private void OnClientReceiveMessage(PlayerStateMessage message)
{
if (message.AboutId == PlayerRegistry.LocalPlayerId)
{
return;
}
QSB.Helper.Events.Unity.RunWhen(
() => PlayerRegistry.GetSyncObject<TransformSync.TransformSync>(message.AboutId) != null,
() => PlayerRegistry.HandleFullStateMessage(message));
}
public void Send()
{
foreach (var player in PlayerRegistry.PlayerList)
{
var message = new PlayerStateMessage
{
AboutId = player.PlayerId,
PlayerName = player.Name,
PlayerReady = player.IsReady,
PlayerState = player.State
};
_messageHandler.SendToAll(message);
}
}
}
}

View File

@ -1,4 +1,4 @@
namespace QSB.Events
namespace QSB.EventsCore
{
public static class EventNames
{
@ -35,5 +35,6 @@
public static string QSBConversation = "QSBConversation";
public static string QSBConversationStartEnd = "QSBConversationStartEnd";
public static string QSBPlayInstrument = "QSBPlayInstrument";
public static string QSBServerSendPlayerStates = "QSBServerSendPlayerStates";
}
}

View File

@ -1,12 +1,12 @@
namespace QSB.Messaging
namespace QSB.EventsCore
{
public enum EventType
{
Sector,
ServerTime,
AnimTrigger,
FullState,
FullStateRequest,
PlayerState,
PlayerStatesRequest,
FlashlightActiveChange,
SignalscopeActiveChange,
TranslatorActiveChange,

View File

@ -1,4 +1,4 @@
namespace QSB.Events
namespace QSB.EventsCore
{
public interface IQSBEvent
{

View File

@ -1,8 +1,9 @@
using QSB.Messaging;
using QSB.Player;
using QSB.TransformSync;
using UnityEngine.Networking;
namespace QSB.Events
namespace QSB.EventsCore
{
/// <summary>
/// Abstract class that handles all event code.
@ -11,7 +12,7 @@ namespace QSB.Events
public abstract class QSBEvent<T> : IQSBEvent where T : PlayerMessage, new()
{
public abstract EventType Type { get; }
public uint LocalPlayerId => PlayerRegistry.LocalPlayerId;
public uint LocalPlayerId => QSBPlayerManager.LocalPlayerId;
private readonly MessageHandler<T> _eventHandler;
protected QSBEvent()
@ -58,7 +59,7 @@ namespace QSB.Events
public void SendEvent(T message)
{
message.FromId = PlayerRegistry.LocalPlayerId;
message.FromId = QSBPlayerManager.LocalPlayerId;
QSB.Helper.Events.Unity.RunWhen(() => PlayerTransformSync.LocalInstance != null, () => Send(message));
}
@ -76,8 +77,8 @@ namespace QSB.Events
private void OnClientReceive(T message)
{
if (message.FromId == PlayerRegistry.LocalPlayerId ||
PlayerRegistry.IsBelongingToLocalPlayer(message.AboutId))
if (message.FromId == QSBPlayerManager.LocalPlayerId ||
QSBPlayerManager.IsBelongingToLocalPlayer(message.AboutId))
{
OnReceiveLocal(message);
return;

View File

@ -1,18 +1,21 @@
using QSB.Animation;
using QSB.ConversationSync;
using QSB.DeathSync;
using QSB.ElevatorSync;
using QSB.GeyserSync;
using OWML.Common;
using QSB.Animation;
using QSB.Animation.Events;
using QSB.ConversationSync.Events;
using QSB.DeathSync.Events;
using QSB.ElevatorSync.Events;
using QSB.GeyserSync.Events;
using QSB.Instruments.Events;
using QSB.OrbSync;
using QSB.TimeSync;
using QSB.Tools;
using QSB.TransformSync;
using QSB.OrbSync.Events;
using QSB.Player.Events;
using QSB.TimeSync.Events;
using QSB.Tools.Events;
using QSB.Utility;
using System.Collections.Generic;
namespace QSB.Events
namespace QSB.EventsCore
{
public static class EventList
public static class QSBEventManager
{
public static bool Ready { get; private set; }
@ -42,12 +45,15 @@ namespace QSB.Events
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);
}
public static void Reset()

View File

@ -1,8 +1,8 @@
using QSB.Events;
using QSB.Messaging;
using QSB.EventsCore;
using QSB.WorldSync;
using QSB.WorldSync.Events;
namespace QSB.GeyserSync
namespace QSB.GeyserSync.Events
{
public class GeyserEvent : QSBEvent<BoolWorldObjectMessage>
{

View File

@ -1,4 +1,5 @@
using QSB.WorldSync;
using QSB.Patches;
using QSB.WorldSync;
using UnityEngine;
namespace QSB.GeyserSync
@ -11,6 +12,7 @@ namespace QSB.GeyserSync
{
Instance = this;
QSBSceneManager.OnSceneLoaded += OnSceneLoaded;
QSBPatchManager.OnPatchType += OnPatchType;
}
private void OnSceneLoaded(OWScene scene, bool isInUniverse)
@ -24,10 +26,13 @@ namespace QSB.GeyserSync
}
}
public void EmptyUpdate()
public void OnPatchType(QSBPatchTypes type)
{
if (type != QSBPatchTypes.OnNonServerClientConnect)
{
return;
}
QSB.Helper.HarmonyHelper.EmptyMethod<GeyserController>("Update");
}
}
}

View File

@ -1,4 +1,4 @@
using QSB.Events;
using QSB.EventsCore;
using QSB.WorldSync;
using UnityEngine.Networking;

View File

@ -1,5 +1,5 @@
using QSB.Events;
using QSB.Messaging;
using QSB.EventsCore;
using QSB.Player;
using QSB.Utility;
using System;
@ -23,7 +23,7 @@ namespace QSB.Instruments.Events
public override void OnReceiveRemote(PlayInstrumentMessage message)
{
PlayerRegistry.GetPlayer(message.AboutId).CurrentInstrument = message.Type;
QSBPlayerManager.GetPlayer(message.AboutId).CurrentInstrument = message.Type;
DebugLog.DebugWrite($"Player ID {message.AboutId} now playing instrument {Enum.GetName(typeof(InstrumentType), message.Type)}");
}
}

View File

@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace QSB.Instruments
namespace QSB.Instruments
{
public enum InstrumentType
{

View File

@ -1,6 +1,6 @@
using QSB.Events;
using QSB.EventsCore;
using QSB.Instruments.QSBCamera;
using QSB.Utility;
using QSB.Player;
using UnityEngine;
namespace QSB.Instruments
@ -36,7 +36,7 @@ namespace QSB.Instruments
{
if (Input.GetKeyDown(KeyCode.Keypad9))
{
if (!PlayerRegistry.LocalPlayer.PlayingInstrument)
if (!QSBPlayerManager.LocalPlayer.PlayingInstrument)
{
CameraManager.Instance.SwitchTo3rdPerson();
SwitchToInstrument(InstrumentType.RIEBECK);
@ -54,7 +54,7 @@ namespace QSB.Instruments
public void SwitchToInstrument(InstrumentType type)
{
PlayerRegistry.LocalPlayer.CurrentInstrument = type;
QSBPlayerManager.LocalPlayer.CurrentInstrument = type;
GlobalMessenger<InstrumentType>.FireEvent(EventNames.QSBPlayInstrument, type);
}
}

View File

@ -1,4 +1,5 @@
using OWML.Common;
using QSB.EventsCore;
using QSB.Utility;
using System;
using System.Linq;
@ -32,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)

View File

@ -1,8 +1,8 @@
using QSB.Events;
using QSB.Messaging;
using QSB.EventsCore;
using QSB.WorldSync;
using QSB.WorldSync.Events;
namespace QSB.OrbSync
namespace QSB.OrbSync.Events
{
public class OrbSlotEvent : QSBEvent<BoolWorldObjectMessage>
{

View File

@ -1,13 +1,13 @@
using OWML.Common;
using QSB.Events;
using QSB.Messaging;
using QSB.EventsCore;
using QSB.TransformSync;
using QSB.Utility;
using QSB.WorldSync;
using QSB.WorldSync.Events;
using System.Linq;
using UnityEngine.Networking;
namespace QSB.OrbSync
namespace QSB.OrbSync.Events
{
public class OrbUserEvent : QSBEvent<WorldObjectMessage>
{

View File

@ -1,11 +1,13 @@
using QSB.Events;
using QSB.EventsCore;
using QSB.WorldSync;
using UnityEngine;
namespace QSB.OrbSync
{
public static class OrbPatches
public class OrbPatches : QSBPatch
{
public override QSBPatchTypes Type => QSBPatchTypes.OnClientConnect;
public static void StartDragCallEvent(bool __result, NomaiInterfaceOrb __instance)
{
if (__result)
@ -52,7 +54,7 @@ namespace QSB.OrbSync
return false;
}
public static void AddPatches()
public override void DoPatches()
{
QSB.Helper.HarmonyHelper.AddPostfix<NomaiInterfaceOrb>("StartDragFromPosition", typeof(OrbPatches), nameof(StartDragCallEvent));
QSB.Helper.HarmonyHelper.AddPrefix<NomaiInterfaceSlot>("CheckOrbCollision", typeof(OrbPatches), nameof(CheckOrbCollision));

View File

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

9
QSB/Patches/QSBPatch.cs Normal file
View File

@ -0,0 +1,9 @@
namespace QSB
{
public abstract class QSBPatch
{
public abstract QSBPatchTypes Type { get; }
public abstract void DoPatches();
}
}

View File

@ -0,0 +1,49 @@
using OWML.Common;
using QSB.ConversationSync;
using QSB.DeathSync;
using QSB.ElevatorSync;
using QSB.OrbSync;
using QSB.TimeSync;
using QSB.Tools;
using QSB.Utility;
using System;
using System.Collections.Generic;
using System.Linq;
namespace QSB.Patches
{
public delegate void PatchEvent(QSBPatchTypes type);
public static class QSBPatchManager
{
public static List<QSBPatch> _patchList = new List<QSBPatch>();
public static event PatchEvent OnPatchType;
public static void Init()
{
_patchList = new List<QSBPatch>
{
new ConversationPatches(),
new DeathPatches(),
new ElevatorPatches(),
new OrbPatches(),
new WakeUpPatches(),
new ProbePatches()
};
DebugLog.DebugWrite("Patch Manager ready.", MessageType.Success);
}
public static void DoPatchType(QSBPatchTypes type)
{
OnPatchType?.Invoke(type);
DebugLog.DebugWrite($"Patch block {Enum.GetName(typeof(QSBPatchTypes), type)}", MessageType.Info);
foreach (var patch in _patchList.Where(x => x.Type == type))
{
DebugLog.DebugWrite($" - Patching in {patch.GetType().Name}", MessageType.Info);
patch.DoPatches();
}
}
}
}

View File

@ -0,0 +1,9 @@
namespace QSB
{
public enum QSBPatchTypes
{
OnModStart,
OnClientConnect,
OnNonServerClientConnect
}
}

View File

@ -1,8 +1,8 @@
using OWML.Common;
using QSB.Messaging;
using QSB.EventsCore;
using QSB.Utility;
namespace QSB.Events
namespace QSB.Player.Events
{
public class PlayerJoinEvent : QSBEvent<PlayerJoinMessage>
{
@ -22,7 +22,7 @@ namespace QSB.Events
public override void OnReceiveRemote(PlayerJoinMessage message)
{
var player = PlayerRegistry.GetPlayer(message.AboutId);
var player = QSBPlayerManager.GetPlayer(message.AboutId);
player.Name = message.PlayerName;
DebugLog.ToHud($"{player.Name} joined!");
DebugLog.DebugWrite($"{player.Name} joined as id {player.PlayerId}", MessageType.Info);
@ -30,7 +30,7 @@ namespace QSB.Events
public override void OnReceiveLocal(PlayerJoinMessage message)
{
var player = PlayerRegistry.GetPlayer(PlayerRegistry.LocalPlayerId);
var player = QSBPlayerManager.GetPlayer(QSBPlayerManager.LocalPlayerId);
player.Name = message.PlayerName;
var text = $"Connected to server as {player.Name}.";
DebugLog.ToAll(text, MessageType.Info);

View File

@ -1,6 +1,7 @@
using UnityEngine.Networking;
using QSB.Messaging;
using UnityEngine.Networking;
namespace QSB.Messaging
namespace QSB.Player.Events
{
public class PlayerJoinMessage : PlayerMessage
{

View File

@ -1,9 +1,9 @@
using OWML.Common;
using QSB.Messaging;
using QSB.EventsCore;
using QSB.Utility;
using System.Linq;
namespace QSB.Events
namespace QSB.Player.Events
{
public class PlayerLeaveEvent : QSBEvent<PlayerLeaveMessage>
{
@ -23,10 +23,10 @@ namespace QSB.Events
public override void OnReceiveRemote(PlayerLeaveMessage message)
{
var playerName = PlayerRegistry.GetPlayer(message.AboutId).Name;
var playerName = QSBPlayerManager.GetPlayer(message.AboutId).Name;
DebugLog.ToAll($"{playerName} disconnected.", MessageType.Info);
PlayerRegistry.GetPlayer(message.AboutId).HudMarker?.Remove();
PlayerRegistry.RemovePlayer(message.AboutId);
QSBPlayerManager.GetPlayer(message.AboutId).HudMarker?.Remove();
QSBPlayerManager.RemovePlayer(message.AboutId);
message.NetIds.ToList().ForEach(netId => QSBNetworkManager.Instance.CleanupNetworkBehaviour(netId));
}
}

View File

@ -1,8 +1,9 @@
using System;
using QSB.Messaging;
using System;
using System.Linq;
using UnityEngine.Networking;
namespace QSB.Messaging
namespace QSB.Player.Events
{
public class PlayerLeaveMessage : PlayerMessage
{

View File

@ -1,10 +1,11 @@
using OWML.Common;
using QSB.EventsCore;
using QSB.Messaging;
using QSB.TransformSync;
using QSB.SectorSync;
using QSB.Utility;
using System.Linq;
namespace QSB.Events
namespace QSB.Player.Events
{
public class PlayerReadyEvent : QSBEvent<ToggleMessage>
{
@ -25,18 +26,23 @@ namespace QSB.Events
public override void OnServerReceive(ToggleMessage message)
{
DebugLog.DebugWrite($"[S] Get ready event from {message.FromId}", MessageType.Success);
if (message.FromId == PlayerRegistry.LocalPlayerId)
if (message.FromId == QSBPlayerManager.LocalPlayerId)
{
return;
}
PlayerRegistry.GetPlayer(message.AboutId).IsReady = message.ToggleValue;
PlayerState.LocalInstance.Send();
QSBPlayerManager.GetPlayer(message.AboutId).IsReady = message.ToggleValue;
GlobalMessenger.FireEvent(EventNames.QSBServerSendPlayerStates);
}
public override void OnReceiveRemote(ToggleMessage message)
{
DebugLog.DebugWrite($"Get ready event from {message.FromId}", MessageType.Success);
foreach (var item in PlayerRegistry.GetSyncObjects<TransformSync.TransformSync>()
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))
{
GlobalMessenger<uint, QSBSector>.FireEvent(EventNames.QSBSectorChange, item.netId.Value, item.ReferenceSector);

View File

@ -1,10 +1,11 @@
using OWML.Common;
using QSB.Events;
using QSB.Messaging;
using QSB.EventsCore;
using QSB.SectorSync;
using QSB.Utility;
using QSB.WorldSync;
using QSB.WorldSync.Events;
namespace QSB.TransformSync
namespace QSB.Player.Events
{
public class PlayerSectorEvent : QSBEvent<WorldObjectMessage>
{
@ -42,7 +43,7 @@ namespace QSB.TransformSync
return;
}
var transformSync = PlayerRegistry.GetSyncObject<TransformSync>(message.AboutId);
var transformSync = QSBPlayerManager.GetSyncObject<TransformSync.TransformSync>(message.AboutId);
QSB.Helper.Events.Unity.RunWhen(() => transformSync?.SyncedTransform != null,
() => transformSync?.SetReferenceSector(sector));

View File

@ -1,6 +1,7 @@
using UnityEngine.Networking;
using QSB.Messaging;
using UnityEngine.Networking;
namespace QSB.Messaging
namespace QSB.Player.Events
{
public class PlayerStateMessage : PlayerMessage
{

View File

@ -1,13 +1,14 @@
using QSB.Messaging;
using QSB.TransformSync;
using QSB.EventsCore;
using QSB.Messaging;
using QSB.SectorSync;
using QSB.Utility;
using System.Linq;
namespace QSB.Events
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);
@ -23,8 +24,8 @@ namespace QSB.Events
public override void OnServerReceive(PlayerMessage message)
{
DebugLog.DebugWrite($"[S] Get state request from {message.FromId}");
PlayerState.LocalInstance.Send();
foreach (var item in PlayerRegistry.GetSyncObjects<TransformSync.TransformSync>()
GlobalMessenger.FireEvent(EventNames.QSBServerSendPlayerStates);
foreach (var item in QSBPlayerManager.GetSyncObjects<TransformSync.TransformSync>()
.Where(x => x != null && x.IsReady && x.ReferenceSector != null))
{
GlobalMessenger<uint, QSBSector>.FireEvent(EventNames.QSBSectorChange, item.netId.Value, item.ReferenceSector);

View File

@ -0,0 +1,40 @@
using OWML.Common;
using QSB.EventsCore;
using QSB.Utility;
namespace QSB.Player.Events
{
public class ServerSendPlayerStatesEvent : QSBEvent<PlayerStateMessage>
{
public override EventType Type => EventType.PlayerState;
public override void SetupListener() => GlobalMessenger.AddListener(EventNames.QSBServerSendPlayerStates, Handler);
public override void CloseListener() => GlobalMessenger.RemoveListener(EventNames.QSBServerSendPlayerStates, Handler);
private void Handler()
{
foreach (var player in QSBPlayerManager.PlayerList)
{
DebugLog.DebugWrite($" - Sending playerstate of player ID {player.PlayerId}", MessageType.Info);
SendEvent(CreateMessage(player));
}
}
private PlayerStateMessage CreateMessage(PlayerInfo player) => new PlayerStateMessage
{
AboutId = player.PlayerId,
PlayerName = player.Name,
PlayerReady = player.IsReady,
PlayerState = player.State
};
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));
}
}
}

View File

@ -1,6 +1,6 @@
using UnityEngine;
namespace QSB.TransformSync
namespace QSB.Player
{
public class PlayerHUDMarker : HUDDistanceMarker
{

View File

@ -1,12 +1,11 @@
using QSB.Animation;
using QSB.Instruments;
using QSB.Tools;
using QSB.TransformSync;
using QSB.Utility;
using System.Linq;
using UnityEngine;
namespace QSB
namespace QSB.Player
{
public class PlayerInfo
{
@ -67,8 +66,8 @@ namespace QSB
Translator?.ChangeEquipState(FlagsHelper.IsSet(State, State.Translator));
ProbeLauncher?.ChangeEquipState(FlagsHelper.IsSet(State, State.ProbeLauncher));
Signalscope?.ChangeEquipState(FlagsHelper.IsSet(State, State.Signalscope));
QSB.Helper.Events.Unity.RunWhen(() => PlayerRegistry.GetSyncObject<AnimationSync>(PlayerId) != null,
() => PlayerRegistry.GetSyncObject<AnimationSync>(PlayerId).SetSuitState(FlagsHelper.IsSet(State, State.Suit)));
QSB.Helper.Events.Unity.RunWhen(() => QSBPlayerManager.GetSyncObject<AnimationSync>(PlayerId) != null,
() => QSBPlayerManager.GetSyncObject<AnimationSync>(PlayerId).SetSuitState(FlagsHelper.IsSet(State, State.Suit)));
}
public bool GetState(State state)

View File

@ -1,12 +1,12 @@
using UnityEngine.Networking;
namespace QSB
namespace QSB.Player
{
public abstract class PlayerSyncObject : NetworkBehaviour
{
public uint AttachedNetId => GetComponent<NetworkIdentity>()?.netId.Value ?? uint.MaxValue;
public uint PlayerId => this.GetPlayerOfObject();
public uint PreviousPlayerId { get; set; }
public PlayerInfo Player => PlayerRegistry.GetPlayer(PlayerId);
public PlayerInfo Player => QSBPlayerManager.GetPlayer(PlayerId);
}
}

View File

@ -1,5 +1,5 @@
using OWML.Common;
using QSB.Messaging;
using QSB.Player.Events;
using QSB.TransformSync;
using QSB.Utility;
using System.Collections.Generic;
@ -7,9 +7,9 @@ using System.Diagnostics;
using System.Linq;
using UnityEngine.Networking;
namespace QSB
namespace QSB.Player
{
public static class PlayerRegistry
public static class QSBPlayerManager
{
public static uint LocalPlayerId => PlayerTransformSync.LocalInstance.GetComponent<NetworkIdentity>()?.netId.Value ?? uint.MaxValue;
public static PlayerInfo LocalPlayer => GetPlayer(LocalPlayerId);

View File

@ -1,6 +1,6 @@
using System;
namespace QSB
namespace QSB.Player
{
[Flags]
public enum State

View File

@ -1,13 +1,13 @@
using OWML.Common;
using OWML.ModHelper;
using OWML.ModHelper.Events;
using QSB.ConversationSync;
using QSB.DeathSync;
using QSB.ElevatorSync;
using QSB.GeyserSync;
using QSB.Instruments;
using QSB.OrbSync;
using QSB.Tools;
using QSB.TransformSync;
using QSB.Patches;
using QSB.SectorSync;
using QSB.Utility;
using UnityEngine;
using UnityEngine.Networking;
@ -26,6 +26,9 @@ namespace QSB
private void Awake()
{
Application.runInBackground = true;
var instance = TextTranslation.Get().GetValue<TextTranslation.TranslationTable>("m_table");
instance.theUITable[(int)UITextType.PleaseUseController] = "<color=orange>Outer Wilds</color> is best experienced with fellow travellers...";
}
private void Start()
@ -34,10 +37,10 @@ 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);
ProbePatches.DoPatches();
DeathPatches.DoPatches();
QSBPatchManager.Init();
QSBPatchManager.DoPatchType(QSBPatchTypes.OnModStart);
// Turns out these are very finicky about what order they go. QSBNetworkManager seems to
// want to go first-ish, otherwise the NetworkManager complains about the PlayerPrefab being

View File

@ -123,31 +123,29 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Animation\AnimationSync.cs" />
<Compile Include="Animation\AnimTriggerEvent.cs" />
<Compile Include="Animation\Events\AnimTriggerEvent.cs" />
<Compile Include="Animation\AnimatorMirror.cs" />
<Compile Include="Animation\AnimControllerPatch.cs" />
<Compile Include="Animation\AnimFloatParam.cs" />
<Compile Include="Animation\AnimTrigger.cs" />
<Compile Include="Animation\AnimTriggerMessage.cs" />
<Compile Include="Animation\Events\AnimTriggerMessage.cs" />
<Compile Include="Animation\CrouchSync.cs" />
<Compile Include="ConversationSync\ConversationEvent.cs" />
<Compile Include="ConversationSync\ConversationMessage.cs" />
<Compile Include="ConversationSync\Events\ConversationEvent.cs" />
<Compile Include="ConversationSync\Events\ConversationMessage.cs" />
<Compile Include="ConversationSync\ConversationPatches.cs" />
<Compile Include="ConversationSync\ConversationStartEndEvent.cs" />
<Compile Include="ConversationSync\ConversationStartEndMessage.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="ConversationSync\QSBFacePlayerWhenTalking.cs" />
<Compile Include="DeathSync\DeathPatches.cs" />
<Compile Include="ElevatorSync\ElevatorDirection.cs" />
<Compile Include="ElevatorSync\QSBElevator.cs" />
<Compile Include="ElevatorSync\ElevatorEvent.cs" />
<Compile Include="ElevatorSync\Events\ElevatorEvent.cs" />
<Compile Include="ElevatorSync\ElevatorManager.cs" />
<Compile Include="ElevatorSync\ElevatorMessage.cs" />
<Compile Include="ElevatorSync\ElevatorPatches.cs" />
<Compile Include="Events\EventNames.cs" />
<Compile Include="DeathSync\PlayerDeathEvent.cs" />
<Compile Include="Events\IQSBEvent.cs" />
<Compile Include="EventsCore\EventNames.cs" />
<Compile Include="DeathSync\Events\PlayerDeathEvent.cs" />
<Compile Include="EventsCore\IQSBEvent.cs" />
<Compile Include="Instruments\Events\PlayInstrumentEvent.cs" />
<Compile Include="Instruments\Events\PlayInstrumentMessage.cs" />
<Compile Include="Instruments\InstrumentType.cs" />
@ -156,71 +154,74 @@
<Compile Include="Instruments\QSBCamera\CameraMode.cs" />
<Compile Include="Instruments\InstrumentsManager.cs" />
<Compile Include="OrbSync\OrbManager.cs" />
<Compile Include="OrbSync\OrbSlotEvent.cs" />
<Compile Include="OrbSync\Events\OrbSlotEvent.cs" />
<Compile Include="OrbSync\OrbPatches.cs" />
<Compile Include="OrbSync\OrbUserEvent.cs" />
<Compile Include="OrbSync\Events\OrbUserEvent.cs" />
<Compile Include="OrbSync\QSBOrbSlot.cs" />
<Compile Include="PlayerSyncObject.cs" />
<Compile Include="Patches\QSBPatchManager.cs" />
<Compile Include="Player\Events\ServerSendPlayerStatesEvent.cs" />
<Compile Include="Player\PlayerSyncObject.cs" />
<Compile Include="QSBNetworkLobby.cs" />
<Compile Include="Patches\QSBPatch.cs" />
<Compile Include="Patches\QSBPatchTypes.cs" />
<Compile Include="QSBSceneManager.cs" />
<Compile Include="TimeSync\WakeUpPatches.cs" />
<Compile Include="Tools\PlayerFlashlightEvent.cs" />
<Compile Include="Events\PlayerJoinEvent.cs" />
<Compile Include="Events\PlayerLeaveEvent.cs" />
<Compile Include="Tools\PlayerProbeEvent.cs" />
<Compile Include="Events\PlayerReadyEvent.cs" />
<Compile Include="Tools\Events\PlayerFlashlightEvent.cs" />
<Compile Include="Player\Events\PlayerJoinEvent.cs" />
<Compile Include="Player\Events\PlayerLeaveEvent.cs" />
<Compile Include="Tools\Events\PlayerProbeEvent.cs" />
<Compile Include="Player\Events\PlayerReadyEvent.cs" />
<Compile Include="TransformSync\NomaiOrbTransformSync.cs" />
<Compile Include="TransformSync\PlayerSectorEvent.cs" />
<Compile Include="Events\PlayerStatesRequestEvent.cs" />
<Compile Include="Animation\PlayerSuitEvent.cs" />
<Compile Include="TimeSync\ServerTimeEvent.cs" />
<Compile Include="GeyserSync\GeyserEvent.cs" />
<Compile Include="Player\Events\PlayerSectorEvent.cs" />
<Compile Include="Player\Events\PlayerStatesRequestEvent.cs" />
<Compile Include="Animation\Events\PlayerSuitEvent.cs" />
<Compile Include="TimeSync\Events\ServerTimeEvent.cs" />
<Compile Include="GeyserSync\Events\GeyserEvent.cs" />
<Compile Include="GeyserSync\GeyserManager.cs" />
<Compile Include="GeyserSync\QSBGeyser.cs" />
<Compile Include="DeathSync\PlayerDeathMessage.cs" />
<Compile Include="Messaging\PlayerLeaveMessage.cs" />
<Compile Include="Tools\PlayerProbeLauncherEvent.cs" />
<Compile Include="Tools\PlayerSignalscopeEvent.cs" />
<Compile Include="Tools\PlayerTranslatorEvent.cs" />
<Compile Include="Events\QSBEvent.cs" />
<Compile Include="Messaging\PlayerJoinMessage.cs" />
<Compile Include="Messaging\ToggleMessage.cs" />
<Compile Include="TransformSync\QSBSector.cs" />
<Compile Include="TransformSync\QSBSectorManager.cs" />
<Compile Include="DeathSync\Events\PlayerDeathMessage.cs" />
<Compile Include="Player\Events\PlayerLeaveMessage.cs" />
<Compile Include="Tools\Events\PlayerProbeLauncherEvent.cs" />
<Compile Include="Tools\Events\PlayerSignalscopeEvent.cs" />
<Compile Include="Tools\Events\PlayerTranslatorEvent.cs" />
<Compile Include="EventsCore\QSBEvent.cs" />
<Compile Include="Player\Events\PlayerJoinMessage.cs" />
<Compile Include="MessagesCore\ToggleMessage.cs" />
<Compile Include="SectorSync\QSBSector.cs" />
<Compile Include="SectorSync\QSBSectorManager.cs" />
<Compile Include="TransformSync\TransformSync.cs" />
<Compile Include="Utility\GOExtensions.cs" />
<Compile Include="Utility\ListExtensions.cs" />
<Compile Include="WorldSync\BoolWorldObjectMessage.cs" />
<Compile Include="WorldSync\WorldObjectMessage.cs" />
<Compile Include="WorldSync\Events\BoolWorldObjectMessage.cs" />
<Compile Include="WorldSync\Events\WorldObjectMessage.cs" />
<Compile Include="Tools\QSBFlashlight.cs" />
<Compile Include="Tools\QSBProbe.cs" />
<Compile Include="Tools\QSBTool.cs" />
<Compile Include="Tools\ToolType.cs" />
<Compile Include="TransformSync\PlayerProbeSync.cs" />
<Compile Include="Utility\DebugActions.cs" />
<Compile Include="Events\EventList.cs" />
<Compile Include="Messaging\PlayerStateMessage.cs" />
<Compile Include="Events\PlayerState.cs" />
<Compile Include="EventsCore\QSBEventManager.cs" />
<Compile Include="Player\Events\PlayerStateMessage.cs" />
<Compile Include="DeathSync\Necronomicon.cs" />
<Compile Include="Utility\DebugLog.cs" />
<Compile Include="Messaging\PlayerMessage.cs" />
<Compile Include="Messaging\MessageHandler.cs" />
<Compile Include="Messaging\EventType.cs" />
<Compile Include="PlayerInfo.cs" />
<Compile Include="State.cs" />
<Compile Include="MessagesCore\PlayerMessage.cs" />
<Compile Include="MessagesCore\MessageHandler.cs" />
<Compile Include="EventsCore\EventType.cs" />
<Compile Include="Player\PlayerInfo.cs" />
<Compile Include="Player\State.cs" />
<Compile Include="DeathSync\PreventShipDestruction.cs" />
<Compile Include="DeathSync\RespawnOnDeath.cs" />
<Compile Include="PlayerRegistry.cs" />
<Compile Include="Player\QSBPlayerManager.cs" />
<Compile Include="TransformSync\PlayerCameraSync.cs" />
<Compile Include="Utility\FlagsHelper.cs" />
<Compile Include="TransformSync\PlayerHUDMarker.cs" />
<Compile Include="Player\PlayerHUDMarker.cs" />
<Compile Include="Tools\PlayerToolsManager.cs" />
<Compile Include="Tools\ProbePatches.cs" />
<Compile Include="Utility\QuaternionHelper.cs" />
<Compile Include="TimeSync\PreserveTimeScale.cs" />
<Compile Include="TransformSync\ShipTransformSync.cs" />
<Compile Include="TransformSync\SectorSync.cs" />
<Compile Include="TimeSync\ServerTimeMessage.cs" />
<Compile Include="SectorSync\SectorSync.cs" />
<Compile Include="TimeSync\Events\ServerTimeMessage.cs" />
<Compile Include="TimeSync\WakeUpSync.cs" />
<Compile Include="QSBNetworkManager.cs" />
<Compile Include="QSB.cs" />

View File

@ -4,9 +4,12 @@ using QSB.Animation;
using QSB.ConversationSync;
using QSB.DeathSync;
using QSB.ElevatorSync;
using QSB.Events;
using QSB.EventsCore;
using QSB.GeyserSync;
using QSB.OrbSync;
using QSB.Patches;
using QSB.Player;
using QSB.SectorSync;
using QSB.TimeSync;
using QSB.TransformSync;
using QSB.Utility;
@ -46,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;
@ -100,7 +98,7 @@ namespace QSB
channels.Add(QosType.Reliable);
channels.Add(QosType.Unreliable);
gameObject.AddComponent<Events.PlayerState>();
DebugLog.DebugWrite("Network Manager ready.", MessageType.Success);
}
public override void OnStartServer()
@ -136,7 +134,7 @@ namespace QSB
{
base.OnClientConnect(connection);
gameObject.AddComponent<SectorSync>();
gameObject.AddComponent<SectorSync.SectorSync>();
gameObject.AddComponent<RespawnOnDeath>();
gameObject.AddComponent<PreventShipDestruction>();
@ -145,41 +143,39 @@ namespace QSB
if (NetworkClient.active && !NetworkServer.active)
{
GeyserManager.Instance.EmptyUpdate();
WakeUpPatches.AddPatches();
QSBPatchManager.DoPatchType(QSBPatchTypes.OnNonServerClientConnect);
}
OrbPatches.AddPatches();
ConversationPatches.AddPatches();
QSBPatchManager.DoPatchType(QSBPatchTypes.OnClientConnect);
_lobby.CanEditName = false;
OnNetworkManagerReady?.Invoke();
IsReady = true;
QSB.Helper.Events.Unity.RunWhen(() => PlayerTransformSync.LocalInstance != null, EventList.Init);
QSB.Helper.Events.Unity.RunWhen(() => PlayerTransformSync.LocalInstance != null, QSBEventManager.Init);
QSB.Helper.Events.Unity.RunWhen(() => EventList.Ready,
QSB.Helper.Events.Unity.RunWhen(() => QSBEventManager.Ready,
() => GlobalMessenger<string>.FireEvent(EventNames.QSBPlayerJoin, _lobby.PlayerName));
QSB.Helper.Events.Unity.RunWhen(() => EventList.Ready,
QSB.Helper.Events.Unity.RunWhen(() => QSBEventManager.Ready,
() => GlobalMessenger.FireEvent(EventNames.QSBPlayerStatesRequest));
}
public override void OnStopClient() // Called on the client when closing connection
{
DebugLog.ToConsole("Disconnecting from server...", MessageType.Info);
Destroy(GetComponent<SectorSync>());
Destroy(GetComponent<SectorSync.SectorSync>());
Destroy(GetComponent<RespawnOnDeath>());
Destroy(GetComponent<PreventShipDestruction>());
EventList.Reset();
PlayerRegistry.PlayerList.ForEach(player => player.HudMarker?.Remove());
QSBEventManager.Reset();
QSBPlayerManager.PlayerList.ForEach(player => player.HudMarker?.Remove());
foreach (var player in PlayerRegistry.PlayerList)
foreach (var player in QSBPlayerManager.PlayerList)
{
PlayerRegistry.GetPlayerNetIds(player).ForEach(CleanupNetworkBehaviour);
QSBPlayerManager.GetPlayerNetIds(player).ForEach(CleanupNetworkBehaviour);
}
PlayerRegistry.RemoveAllPlayers();
QSBPlayerManager.RemoveAllPlayers();
WorldRegistry.RemoveObjects<QSBOrbSlot>();
WorldRegistry.RemoveObjects<QSBElevator>();
@ -206,18 +202,18 @@ namespace QSB
}
}
PlayerRegistry.GetPlayer(playerId).HudMarker?.Remove();
QSBPlayerManager.GetPlayer(playerId).HudMarker?.Remove();
CleanupConnection(connection);
}
public override void OnStopServer()
{
Destroy(GetComponent<SectorSync>());
Destroy(GetComponent<SectorSync.SectorSync>());
Destroy(GetComponent<RespawnOnDeath>());
Destroy(GetComponent<PreventShipDestruction>());
EventList.Reset();
QSBEventManager.Reset();
DebugLog.ToConsole("[S] Server stopped!", MessageType.Info);
PlayerRegistry.PlayerList.ForEach(player => player.HudMarker?.Remove());
QSBPlayerManager.PlayerList.ForEach(player => player.HudMarker?.Remove());
NetworkServer.connections.ToList().ForEach(CleanupConnection);
WorldRegistry.RemoveObjects<QSBOrbSlot>();
@ -240,13 +236,13 @@ namespace QSB
DebugLog.ToConsole("Error when getting playerId in CleanupConnection: " + ex.Message, MessageType.Error);
return;
}
if (!PlayerRegistry.PlayerExists(playerId))
if (!QSBPlayerManager.PlayerExists(playerId))
{
return;
}
var playerName = PlayerRegistry.GetPlayer(playerId).Name;
var playerName = QSBPlayerManager.GetPlayer(playerId).Name;
DebugLog.ToConsole($"{playerName} disconnected.", MessageType.Info);
PlayerRegistry.RemovePlayer(playerId);
QSBPlayerManager.RemovePlayer(playerId);
var netIds = connection.clientOwnedObjects?.Select(x => x.Value).ToList();
netIds.ForEach(CleanupNetworkBehaviour);
@ -265,8 +261,8 @@ namespace QSB
if (transformSync != null)
{
DebugLog.DebugWrite($" * Removing TransformSync from syncobjects");
PlayerRegistry.PlayerSyncObjects.Remove(transformSync);
if (transformSync.SyncedTransform != null && netId != PlayerRegistry.LocalPlayerId && !networkBehaviour.hasAuthority)
QSBPlayerManager.PlayerSyncObjects.Remove(transformSync);
if (transformSync.SyncedTransform != null && netId != QSBPlayerManager.LocalPlayerId && !networkBehaviour.hasAuthority)
{
DebugLog.DebugWrite($" * Destroying {transformSync.SyncedTransform.gameObject.name}");
Destroy(transformSync.SyncedTransform.gameObject);
@ -278,7 +274,7 @@ namespace QSB
if (animationSync != null)
{
DebugLog.DebugWrite($" * Removing AnimationSync from syncobjects");
PlayerRegistry.PlayerSyncObjects.Remove(animationSync);
QSBPlayerManager.PlayerSyncObjects.Remove(animationSync);
}
if (!networkBehaviour.hasAuthority)
@ -288,6 +284,5 @@ namespace QSB
}
}
}
}
}

View File

@ -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)

View File

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

View File

@ -1,8 +1,10 @@
using QSB.WorldSync;
using OWML.Common;
using QSB.Utility;
using QSB.WorldSync;
using System.Linq;
using UnityEngine;
namespace QSB.TransformSync
namespace QSB.SectorSync
{
public class QSBSectorManager : MonoBehaviour
{
@ -19,10 +21,16 @@ namespace QSB.TransformSync
{
Instance = this;
QSBSceneManager.OnSceneLoaded += (OWScene scene, bool universe) => RebuildSectors();
DebugLog.DebugWrite("Sector Manager ready.", MessageType.Success);
}
public void RebuildSectors()
{
if (!QSBSceneManager.IsInUniverse)
{
return;
}
DebugLog.DebugWrite("Rebuilding sectors...", MessageType.Warning);
WorldRegistry.RemoveObjects<QSBSector>();
var sectors = Resources.FindObjectsOfTypeAll<Sector>().ToList();
for (var id = 0; id < sectors.Count; id++)

View File

@ -1,8 +1,9 @@
using QSB.Events;
using QSB.EventsCore;
using QSB.Player;
using System.Linq;
using UnityEngine;
namespace QSB.TransformSync
namespace QSB.SectorSync
{
public class SectorSync : MonoBehaviour
{
@ -20,11 +21,11 @@ namespace QSB.TransformSync
{
return;
}
PlayerRegistry.GetSyncObjects<TransformSync>().Where(x => x.hasAuthority).ToList().ForEach(CheckTransformSyncSector);
QSBPlayerManager.GetSyncObjects<TransformSync.TransformSync>().Where(x => x.hasAuthority).ToList().ForEach(CheckTransformSyncSector);
_checkTimer = 0;
}
private void CheckTransformSyncSector(TransformSync transformSync)
private void CheckTransformSyncSector(TransformSync.TransformSync transformSync)
{
var syncedTransform = transformSync.SyncedTransform;
if (syncedTransform == null || syncedTransform.position == Vector3.zero)

View File

@ -1,7 +1,6 @@
using QSB.Events;
using QSB.Messaging;
using QSB.EventsCore;
namespace QSB.TimeSync
namespace QSB.TimeSync.Events
{
public class ServerTimeEvent : QSBEvent<ServerTimeMessage>
{

View File

@ -1,7 +1,7 @@
using QSB.Messaging;
using UnityEngine.Networking;
namespace QSB.TimeSync
namespace QSB.TimeSync.Events
{
public class ServerTimeMessage : PlayerMessage
{

View File

@ -2,12 +2,9 @@
namespace QSB.TimeSync
{
public static class WakeUpPatches
public class WakeUpPatches : QSBPatch
{
public static void AddPatches()
{
QSB.Helper.HarmonyHelper.AddPrefix<PlayerCameraEffectController>("OnStartOfTimeLoop", typeof(WakeUpPatches), nameof(OnStartOfTimeLoopPrefix));
}
public override QSBPatchTypes Type => QSBPatchTypes.OnNonServerClientConnect;
public static bool OnStartOfTimeLoopPrefix(ref PlayerCameraEffectController __instance)
{
@ -17,5 +14,10 @@ namespace QSB.TimeSync
}
return false;
}
public override void DoPatches()
{
QSB.Helper.HarmonyHelper.AddPrefix<PlayerCameraEffectController>("OnStartOfTimeLoop", typeof(WakeUpPatches), nameof(OnStartOfTimeLoopPrefix));
}
}
}

View File

@ -1,6 +1,7 @@
using OWML.ModHelper.Events;
using QSB.DeathSync;
using QSB.Events;
using QSB.EventsCore;
using QSB.TimeSync.Events;
using QSB.Utility;
using UnityEngine;
using UnityEngine.Networking;
@ -263,6 +264,5 @@ namespace QSB.TimeSync
DisableInput();
}
}
}
}

View File

@ -1,7 +1,8 @@
using QSB.Events;
using QSB.EventsCore;
using QSB.Messaging;
using QSB.Player;
namespace QSB.Tools
namespace QSB.Tools.Events
{
public class PlayerFlashlightEvent : QSBEvent<ToggleMessage>
{
@ -30,14 +31,14 @@ namespace QSB.Tools
public override void OnReceiveRemote(ToggleMessage message)
{
var player = PlayerRegistry.GetPlayer(message.AboutId);
var player = QSBPlayerManager.GetPlayer(message.AboutId);
player.UpdateState(State.Flashlight, message.ToggleValue);
player.FlashLight?.UpdateState(message.ToggleValue);
}
public override void OnReceiveLocal(ToggleMessage message)
{
PlayerRegistry.LocalPlayer.UpdateState(State.Flashlight, message.ToggleValue);
QSBPlayerManager.LocalPlayer.UpdateState(State.Flashlight, message.ToggleValue);
}
}
}

View File

@ -1,7 +1,8 @@
using QSB.Events;
using QSB.EventsCore;
using QSB.Messaging;
using QSB.Player;
namespace QSB.Tools
namespace QSB.Tools.Events
{
public class PlayerProbeEvent : QSBEvent<ToggleMessage>
{
@ -30,14 +31,14 @@ namespace QSB.Tools
public override void OnReceiveRemote(ToggleMessage message)
{
var player = PlayerRegistry.GetPlayer(message.AboutId);
var player = QSBPlayerManager.GetPlayer(message.AboutId);
player.UpdateState(State.ProbeActive, message.ToggleValue);
player.Probe?.SetState(message.ToggleValue);
}
public override void OnReceiveLocal(ToggleMessage message)
{
PlayerRegistry.LocalPlayer.UpdateState(State.ProbeActive, message.ToggleValue);
QSBPlayerManager.LocalPlayer.UpdateState(State.ProbeActive, message.ToggleValue);
}
}
}

View File

@ -1,7 +1,8 @@
using QSB.Events;
using QSB.EventsCore;
using QSB.Messaging;
using QSB.Player;
namespace QSB.Tools
namespace QSB.Tools.Events
{
public class PlayerProbeLauncherEvent : QSBEvent<ToggleMessage>
{
@ -30,14 +31,14 @@ namespace QSB.Tools
public override void OnReceiveRemote(ToggleMessage message)
{
var player = PlayerRegistry.GetPlayer(message.AboutId);
var player = QSBPlayerManager.GetPlayer(message.AboutId);
player.UpdateState(State.ProbeLauncher, message.ToggleValue);
player.ProbeLauncher?.ChangeEquipState(message.ToggleValue);
}
public override void OnReceiveLocal(ToggleMessage message)
{
PlayerRegistry.LocalPlayer.UpdateState(State.ProbeLauncher, message.ToggleValue);
QSBPlayerManager.LocalPlayer.UpdateState(State.ProbeLauncher, message.ToggleValue);
}
}
}

View File

@ -1,7 +1,8 @@
using QSB.Events;
using QSB.EventsCore;
using QSB.Messaging;
using QSB.Player;
namespace QSB.Tools
namespace QSB.Tools.Events
{
public class PlayerSignalscopeEvent : QSBEvent<ToggleMessage>
{
@ -30,14 +31,14 @@ namespace QSB.Tools
public override void OnReceiveRemote(ToggleMessage message)
{
var player = PlayerRegistry.GetPlayer(message.AboutId);
var player = QSBPlayerManager.GetPlayer(message.AboutId);
player.UpdateState(State.Signalscope, message.ToggleValue);
player.Signalscope?.ChangeEquipState(message.ToggleValue);
}
public override void OnReceiveLocal(ToggleMessage message)
{
PlayerRegistry.LocalPlayer.UpdateState(State.Signalscope, message.ToggleValue);
QSBPlayerManager.LocalPlayer.UpdateState(State.Signalscope, message.ToggleValue);
}
}
}

View File

@ -1,7 +1,8 @@
using QSB.Events;
using QSB.EventsCore;
using QSB.Messaging;
using QSB.Player;
namespace QSB.Tools
namespace QSB.Tools.Events
{
public class PlayerTranslatorEvent : QSBEvent<ToggleMessage>
{
@ -30,14 +31,14 @@ namespace QSB.Tools
public override void OnReceiveRemote(ToggleMessage message)
{
var player = PlayerRegistry.GetPlayer(message.AboutId);
var player = QSBPlayerManager.GetPlayer(message.AboutId);
player.UpdateState(State.Translator, message.ToggleValue);
player.Translator?.ChangeEquipState(message.ToggleValue);
}
public override void OnReceiveLocal(ToggleMessage message)
{
PlayerRegistry.LocalPlayer.UpdateState(State.Translator, message.ToggleValue);
QSBPlayerManager.LocalPlayer.UpdateState(State.Translator, message.ToggleValue);
}
}
}

View File

@ -1,4 +1,5 @@
using OWML.ModHelper.Events;
using QSB.Player;
using QSB.Utility;
using System.Linq;
using UnityEngine;

View File

@ -1,9 +1,11 @@
using QSB.Events;
using QSB.EventsCore;
namespace QSB.Tools
{
public static class ProbePatches
public class ProbePatches : QSBPatch
{
public override QSBPatchTypes Type => QSBPatchTypes.OnModStart;
private static void ProbeAnchor()
{
GlobalMessenger.FireEvent(EventNames.QSBOnProbeAnchor);
@ -18,7 +20,7 @@ namespace QSB.Tools
return true;
}
public static void DoPatches()
public override void DoPatches()
{
QSB.Helper.HarmonyHelper.AddPostfix<SurveyorProbe>("OnAnchor", typeof(ProbePatches), nameof(ProbeAnchor));
QSB.Helper.HarmonyHelper.AddPrefix<SurveyorProbe>("Retrieve", typeof(ProbePatches), nameof(ProbeWarp));

View File

@ -1,4 +1,5 @@
using QSB.Events;
using QSB.EventsCore;
using QSB.Player;
using QSB.Tools;
using QSB.Utility;
using UnityEngine;
@ -41,7 +42,7 @@ namespace QSB.TransformSync
public override bool IsReady => Locator.GetPlayerTransform() != null
&& Player != null
&& PlayerRegistry.PlayerExists(Player.PlayerId)
&& QSBPlayerManager.PlayerExists(Player.PlayerId)
&& netId.Value != uint.MaxValue
&& netId.Value != 0U;
}

View File

@ -1,4 +1,5 @@
using OWML.Common;
using QSB.Player;
using QSB.Tools;
using QSB.Utility;
using UnityEngine;
@ -97,7 +98,7 @@ namespace QSB.TransformSync
public override bool IsReady => Locator.GetProbe() != null
&& Player != null
&& PlayerRegistry.PlayerExists(Player.PlayerId)
&& QSBPlayerManager.PlayerExists(Player.PlayerId)
&& Player.IsReady
&& netId.Value != uint.MaxValue
&& netId.Value != 0U;

View File

@ -1,4 +1,5 @@
using QSB.Animation;
using QSB.Player;
using UnityEngine;
namespace QSB.TransformSync
@ -49,7 +50,7 @@ namespace QSB.TransformSync
public override bool IsReady => Locator.GetPlayerTransform() != null
&& Player != null
&& PlayerRegistry.PlayerExists(Player.PlayerId)
&& QSBPlayerManager.PlayerExists(Player.PlayerId)
&& Player.IsReady
&& netId.Value != uint.MaxValue
&& netId.Value != 0U;

View File

@ -1,4 +1,5 @@
using UnityEngine;
using QSB.Player;
using UnityEngine;
namespace QSB.TransformSync
{
@ -51,7 +52,7 @@ namespace QSB.TransformSync
public override bool IsReady => GetShipModel() != null
&& Player != null
&& PlayerRegistry.PlayerExists(Player.PlayerId)
&& QSBPlayerManager.PlayerExists(Player.PlayerId)
&& Player.IsReady
&& netId.Value != uint.MaxValue
&& netId.Value != 0U;

View File

@ -1,4 +1,6 @@
using OWML.Common;
using QSB.Player;
using QSB.SectorSync;
using QSB.Utility;
using UnityEngine;
@ -22,7 +24,7 @@ namespace QSB.TransformSync
protected virtual void Awake()
{
DebugLog.DebugWrite($"Awake of {AttachedNetId} ({GetType().Name})");
PlayerRegistry.PlayerSyncObjects.Add(this);
QSBPlayerManager.PlayerSyncObjects.Add(this);
DontDestroyOnLoad(gameObject);
QSBSceneManager.OnSceneLoaded += OnSceneLoaded;
}

View File

@ -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");

View File

@ -1,6 +1,6 @@
using UnityEngine.Networking;
namespace QSB.WorldSync
namespace QSB.WorldSync.Events
{
public class BoolWorldObjectMessage : WorldObjectMessage
{

View File

@ -1,7 +1,7 @@
using QSB.Messaging;
using UnityEngine.Networking;
namespace QSB.WorldSync
namespace QSB.WorldSync.Events
{
public class WorldObjectMessage : PlayerMessage
{