Merge pull request #427 from misternebula/initial-eye-stuff

add picking up instruments, starting instruments playing
This commit is contained in:
_nebula 2021-12-21 21:31:51 +00:00 committed by GitHub
commit 8cf584c48e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
46 changed files with 250 additions and 65 deletions

View File

@ -6,6 +6,8 @@ namespace QSB.Anglerfish
{ {
public class AnglerManager : WorldObjectManager public class AnglerManager : WorldObjectManager
{ {
public override WorldObjectType WorldObjectType => WorldObjectType.SolarSystem;
public static readonly List<AnglerfishController> Anglers = new(); public static readonly List<AnglerfishController> Anglers = new();
protected override void RebuildWorldObjects(OWScene scene) protected override void RebuildWorldObjects(OWScene scene)

View File

@ -1,4 +1,5 @@
using QSB.Anglerfish.TransformSync; using QSB.Anglerfish.TransformSync;
using QSB.Utility;
using QSB.WorldSync; using QSB.WorldSync;
using QuantumUNET; using QuantumUNET;
using UnityEngine; using UnityEngine;
@ -17,7 +18,7 @@ namespace QSB.Anglerfish.WorldObjects
{ {
if (QSBCore.IsHost) if (QSBCore.IsHost)
{ {
QNetworkServer.Spawn(Object.Instantiate(QSBNetworkManager.Instance.AnglerPrefab)); Object.Instantiate(QSBNetworkManager.Instance.AnglerPrefab).SpawnWithServerAuthority();
} }
StartDelayedReady(); StartDelayedReady();

View File

@ -1,11 +1,13 @@
using QSB.Animation.NPC.WorldObjects; using QSB.Animation.NPC.WorldObjects;
using QSB.WorldSync; using QSB.WorldSync;
using System.Linq;
namespace QSB.Animation.NPC namespace QSB.Animation.NPC
{ {
internal class CharacterAnimManager : WorldObjectManager internal class CharacterAnimManager : WorldObjectManager
{ {
// im assuming this is used in the eye as well
public override WorldObjectType WorldObjectType => WorldObjectType.Both;
protected override void RebuildWorldObjects(OWScene scene) protected override void RebuildWorldObjects(OWScene scene)
{ {
QSBWorldSync.Init<QSBCharacterAnimController, CharacterAnimController>(); QSBWorldSync.Init<QSBCharacterAnimController, CharacterAnimController>();
@ -13,6 +15,7 @@ namespace QSB.Animation.NPC
QSBWorldSync.Init<QSBSolanumController, NomaiConversationManager>(); QSBWorldSync.Init<QSBSolanumController, NomaiConversationManager>();
QSBWorldSync.Init<QSBSolanumAnimController, SolanumAnimController>(); QSBWorldSync.Init<QSBSolanumAnimController, SolanumAnimController>();
QSBWorldSync.Init<QSBHearthianRecorderEffects, HearthianRecorderEffects>(); QSBWorldSync.Init<QSBHearthianRecorderEffects, HearthianRecorderEffects>();
QSBWorldSync.Init<QSBTravelerEyeController, TravelerEyeController>();
//MOVE : this is the wrong place to put this... move it to Conversations? //MOVE : this is the wrong place to put this... move it to Conversations?
QSBWorldSync.OldDialogueTrees.Clear(); QSBWorldSync.OldDialogueTrees.Clear();

View File

@ -15,6 +15,7 @@ namespace QSB.Animation.NPC.WorldObjects
public virtual void EndConversation() public virtual void EndConversation()
=> GetDialogueTree().RaiseEvent("OnEndConversation"); => GetDialogueTree().RaiseEvent("OnEndConversation");
public abstract bool InConversation(); public virtual bool InConversation()
=> false;
} }
} }

View File

@ -2,9 +2,6 @@
{ {
internal class QSBHearthianRecorderEffects : NpcAnimController<HearthianRecorderEffects> internal class QSBHearthianRecorderEffects : NpcAnimController<HearthianRecorderEffects>
{ {
public override bool InConversation()
=> AttachedObject._characterDialogueTree.InConversation();
public override CharacterDialogueTree GetDialogueTree() public override CharacterDialogueTree GetDialogueTree()
=> AttachedObject._characterDialogueTree; => AttachedObject._characterDialogueTree;
} }

View File

@ -4,8 +4,5 @@
{ {
public override CharacterDialogueTree GetDialogueTree() public override CharacterDialogueTree GetDialogueTree()
=> AttachedObject._characterDialogueTree; => AttachedObject._characterDialogueTree;
public override bool InConversation()
=> AttachedObject._solanumAnimController._animator.GetBool("ListeningToPlayer");
} }
} }

View File

@ -4,8 +4,5 @@
{ {
public override CharacterDialogueTree GetDialogueTree() public override CharacterDialogueTree GetDialogueTree()
=> AttachedObject._dialogueSystem; => AttachedObject._dialogueSystem;
public override bool InConversation()
=> AttachedObject._talking;
} }
} }

View File

@ -0,0 +1,8 @@
namespace QSB.Animation.NPC.WorldObjects
{
internal class QSBTravelerEyeController : NpcAnimController<TravelerEyeController>
{
public override CharacterDialogueTree GetDialogueTree()
=> AttachedObject._dialogueTree;
}
}

View File

@ -5,6 +5,8 @@ namespace QSB.CampfireSync
{ {
internal class CampfireManager : WorldObjectManager internal class CampfireManager : WorldObjectManager
{ {
public override WorldObjectType WorldObjectType => WorldObjectType.Both;
protected override void RebuildWorldObjects(OWScene scene) protected override void RebuildWorldObjects(OWScene scene)
=> QSBWorldSync.Init<QSBCampfire, Campfire>(); => QSBWorldSync.Init<QSBCampfire, Campfire>();
} }

View File

@ -7,8 +7,8 @@
AliveInSolarSystem, AliveInSolarSystem,
DeadInSolarSystem, DeadInSolarSystem,
AliveInEye, AliveInEye,
WaitingForOthersToDieInSolarSystem, WaitingForOthersToDie,
WaitingForOthersToReadyInSolarSystem, WaitingForOthersToBeReady,
WatchingLongCredits, WatchingLongCredits,
WatchingShortCredits WatchingShortCredits
} }

View File

@ -64,7 +64,7 @@ namespace QSB.ClientServerStateSync
if (oldScene == OWScene.SolarSystem) if (oldScene == OWScene.SolarSystem)
{ {
// reloading scene // reloading scene
newState = ClientState.WaitingForOthersToReadyInSolarSystem; newState = ClientState.WaitingForOthersToBeReady;
} }
else else
{ {
@ -98,21 +98,21 @@ namespace QSB.ClientServerStateSync
case OWScene.SolarSystem: case OWScene.SolarSystem:
if (serverState == ServerState.WaitingForAllPlayersToDie) if (serverState == ServerState.WaitingForAllPlayersToDie)
{ {
newState = ClientState.WaitingForOthersToReadyInSolarSystem; newState = ClientState.WaitingForOthersToBeReady;
break; break;
} }
if (oldScene == OWScene.SolarSystem) if (oldScene == OWScene.SolarSystem)
{ {
// reloading scene // reloading scene
newState = ClientState.WaitingForOthersToReadyInSolarSystem; newState = ClientState.WaitingForOthersToBeReady;
} }
else else
{ {
// loading in from title screen // loading in from title screen
if (serverState == ServerState.WaitingForAllPlayersToReady) if (serverState == ServerState.WaitingForAllPlayersToReady)
{ {
newState = ClientState.WaitingForOthersToReadyInSolarSystem; newState = ClientState.WaitingForOthersToBeReady;
} }
else else
{ {
@ -122,7 +122,14 @@ namespace QSB.ClientServerStateSync
break; break;
case OWScene.EyeOfTheUniverse: case OWScene.EyeOfTheUniverse:
newState = ClientState.WaitingForOthersToReadyInSolarSystem; if (serverState == ServerState.WaitingForAllPlayersToReady)
{
newState = ClientState.WaitingForOthersToBeReady;
}
else
{
newState = ClientState.AliveInEye;
}
break; break;
default: default:
newState = ClientState.NotLoaded; newState = ClientState.NotLoaded;

View File

@ -128,7 +128,7 @@ namespace QSB.ClientServerStateSync
if (_currentState == ServerState.WaitingForAllPlayersToReady) if (_currentState == ServerState.WaitingForAllPlayersToReady)
{ {
if (QSBPlayerManager.PlayerList.All(x if (QSBPlayerManager.PlayerList.All(x
=> x.State is ClientState.WaitingForOthersToReadyInSolarSystem => x.State is ClientState.WaitingForOthersToBeReady
or ClientState.AliveInSolarSystem or ClientState.AliveInSolarSystem
or ClientState.AliveInEye)) or ClientState.AliveInEye))
{ {

View File

@ -13,6 +13,8 @@ namespace QSB.ConversationSync
{ {
public class ConversationManager : WorldObjectManager public class ConversationManager : WorldObjectManager
{ {
public override WorldObjectType WorldObjectType => WorldObjectType.Both;
public static ConversationManager Instance { get; private set; } public static ConversationManager Instance { get; private set; }
public Dictionary<CharacterDialogueTree, GameObject> BoxMappings { get; } = new Dictionary<CharacterDialogueTree, GameObject>(); public Dictionary<CharacterDialogueTree, GameObject> BoxMappings { get; } = new Dictionary<CharacterDialogueTree, GameObject>();

View File

@ -5,6 +5,9 @@ namespace QSB.EchoesOfTheEye.AirlockSync
{ {
internal class AirlockManager : WorldObjectManager internal class AirlockManager : WorldObjectManager
{ {
// is this used in the prisoner sequence in the eye?
public override WorldObjectType WorldObjectType => WorldObjectType.SolarSystem;
protected override void RebuildWorldObjects(OWScene scene) => QSBWorldSync.Init<QSBGhostAirlock, GhostAirlock>(); protected override void RebuildWorldObjects(OWScene scene) => QSBWorldSync.Init<QSBGhostAirlock, GhostAirlock>();
} }
} }

View File

@ -5,6 +5,9 @@ namespace QSB.EchoesOfTheEye.LightSensorSync
{ {
internal class LightSensorManager : WorldObjectManager internal class LightSensorManager : WorldObjectManager
{ {
// see AirlockManager question
public override WorldObjectType WorldObjectType => WorldObjectType.SolarSystem;
protected override void RebuildWorldObjects(OWScene scene) => QSBWorldSync.Init<QSBSingleLightSensor, SingleLightSensor>(); protected override void RebuildWorldObjects(OWScene scene) => QSBWorldSync.Init<QSBSingleLightSensor, SingleLightSensor>();
} }
} }

View File

@ -5,6 +5,8 @@ namespace QSB.ElevatorSync
{ {
public class ElevatorManager : WorldObjectManager public class ElevatorManager : WorldObjectManager
{ {
public override WorldObjectType WorldObjectType => WorldObjectType.SolarSystem;
protected override void RebuildWorldObjects(OWScene scene) protected override void RebuildWorldObjects(OWScene scene)
=> QSBWorldSync.Init<QSBElevator, Elevator>(); => QSBWorldSync.Init<QSBElevator, Elevator>();
} }

View File

@ -106,5 +106,6 @@
public const string QSBRequestGameDetails = nameof(QSBRequestGameDetails); public const string QSBRequestGameDetails = nameof(QSBRequestGameDetails);
public const string QSBGameDetails = nameof(QSBGameDetails); public const string QSBGameDetails = nameof(QSBGameDetails);
public const string QSBEnterRemoteDialogue = nameof(QSBEnterRemoteDialogue); public const string QSBEnterRemoteDialogue = nameof(QSBEnterRemoteDialogue);
public const string QSBGatherInstrument = nameof(QSBGatherInstrument);
} }
} }

View File

@ -0,0 +1,29 @@
using QSB.Events;
using QSB.EyeOfTheUniverse.InstrumentSync.WorldObjects;
using QSB.WorldSync;
using QSB.WorldSync.Events;
namespace QSB.EyeOfTheUniverse.InstrumentSync.Event
{
internal class GatherInstrumentEvent : QSBEvent<WorldObjectMessage>
{
public override bool RequireWorldObjectsReady => true;
public override void SetupListener() => GlobalMessenger<QSBQuantumInstrument>.AddListener(EventNames.QSBGatherInstrument, Handler);
public override void CloseListener() => GlobalMessenger<QSBQuantumInstrument>.RemoveListener(EventNames.QSBGatherInstrument, Handler);
private void Handler(QSBQuantumInstrument instrument) => SendEvent(CreateMessage(instrument));
private BoolWorldObjectMessage CreateMessage(QSBQuantumInstrument instrument) => new()
{
AboutId = LocalPlayerId,
ObjectId = instrument.ObjectId
};
public override void OnReceiveRemote(bool isHost, WorldObjectMessage message)
{
var qsbObj = QSBWorldSync.GetWorldFromId<QSBQuantumInstrument>(message.ObjectId);
qsbObj.AttachedObject.Gather();
}
}
}

View File

@ -0,0 +1,17 @@
using HarmonyLib;
using QSB.Events;
using QSB.EyeOfTheUniverse.InstrumentSync.WorldObjects;
using QSB.Patches;
using QSB.WorldSync;
namespace QSB.EyeOfTheUniverse.InstrumentSync.Patches
{
internal class QuantumInstrumentPatches : QSBPatch
{
public override QSBPatchTypes Type => QSBPatchTypes.OnClientConnect;
[HarmonyPostfix]
[HarmonyPatch(typeof(QuantumInstrument), nameof(QuantumInstrument.OnPressInteract))]
public static void Gather(QuantumInstrument __instance)
=> QSBEventManager.FireEvent(EventNames.QSBGatherInstrument, QSBWorldSync.GetWorldFromUnity<QSBQuantumInstrument>(__instance));
}
}

View File

@ -0,0 +1,13 @@
using QSB.EyeOfTheUniverse.InstrumentSync.WorldObjects;
using QSB.WorldSync;
namespace QSB.EyeOfTheUniverse.InstrumentSync
{
internal class QuantumInstrumentManager : WorldObjectManager
{
public override WorldObjectType WorldObjectType => WorldObjectType.Eye;
protected override void RebuildWorldObjects(OWScene scene)
=> QSBWorldSync.Init<QSBQuantumInstrument, QuantumInstrument>();
}
}

View File

@ -0,0 +1,8 @@
using QSB.WorldSync;
namespace QSB.EyeOfTheUniverse.InstrumentSync.WorldObjects
{
internal class QSBQuantumInstrument : WorldObject<QuantumInstrument>
{
}
}

View File

@ -5,6 +5,8 @@ namespace QSB.GeyserSync
{ {
public class GeyserManager : WorldObjectManager public class GeyserManager : WorldObjectManager
{ {
public override WorldObjectType WorldObjectType => WorldObjectType.SolarSystem;
protected override void RebuildWorldObjects(OWScene scene) protected override void RebuildWorldObjects(OWScene scene)
=> QSBWorldSync.Init<QSBGeyser, GeyserController>(); => QSBWorldSync.Init<QSBGeyser, GeyserController>();
} }

View File

@ -8,6 +8,8 @@ namespace QSB.ItemSync
{ {
internal class ItemManager : WorldObjectManager internal class ItemManager : WorldObjectManager
{ {
public override WorldObjectType WorldObjectType => WorldObjectType.Both;
protected override void RebuildWorldObjects(OWScene scene) protected override void RebuildWorldObjects(OWScene scene)
{ {
DebugLog.DebugWrite("Rebuilding OWItems...", MessageType.Info); DebugLog.DebugWrite("Rebuilding OWItems...", MessageType.Info);

View File

@ -6,6 +6,8 @@ namespace QSB.JellyfishSync
{ {
public class JellyfishManager : WorldObjectManager public class JellyfishManager : WorldObjectManager
{ {
public override WorldObjectType WorldObjectType => WorldObjectType.SolarSystem;
public static readonly List<JellyfishController> Jellyfish = new(); public static readonly List<JellyfishController> Jellyfish = new();
protected override void RebuildWorldObjects(OWScene scene) protected override void RebuildWorldObjects(OWScene scene)

View File

@ -1,4 +1,5 @@
using QSB.JellyfishSync.TransformSync; using QSB.JellyfishSync.TransformSync;
using QSB.Utility;
using QSB.WorldSync; using QSB.WorldSync;
using QuantumUNET; using QuantumUNET;
using UnityEngine; using UnityEngine;
@ -16,7 +17,7 @@ namespace QSB.JellyfishSync.WorldObjects
if (QSBCore.IsHost) if (QSBCore.IsHost)
{ {
QNetworkServer.Spawn(Object.Instantiate(QSBNetworkManager.Instance.JellyfishPrefab)); Object.Instantiate(QSBNetworkManager.Instance.JellyfishPrefab).SpawnWithServerAuthority();
} }
StartDelayedReady(); StartDelayedReady();

View File

@ -6,6 +6,8 @@ namespace QSB.MeteorSync
{ {
public class MeteorManager : WorldObjectManager public class MeteorManager : WorldObjectManager
{ {
public override WorldObjectType WorldObjectType => WorldObjectType.SolarSystem;
public static WhiteHoleVolume WhiteHoleVolume; public static WhiteHoleVolume WhiteHoleVolume;
protected override void RebuildWorldObjects(OWScene scene) protected override void RebuildWorldObjects(OWScene scene)

View File

@ -6,6 +6,8 @@ namespace QSB.OrbSync
{ {
public class OrbManager : WorldObjectManager public class OrbManager : WorldObjectManager
{ {
public override WorldObjectType WorldObjectType => WorldObjectType.Both;
public static readonly List<NomaiInterfaceOrb> Orbs = new(); public static readonly List<NomaiInterfaceOrb> Orbs = new();
protected override void RebuildWorldObjects(OWScene scene) protected override void RebuildWorldObjects(OWScene scene)

View File

@ -14,7 +14,7 @@ namespace QSB.OrbSync.WorldObjects
{ {
if (QSBCore.IsHost) if (QSBCore.IsHost)
{ {
QNetworkServer.Spawn(Object.Instantiate(QSBNetworkManager.Instance.OrbPrefab)); Object.Instantiate(QSBNetworkManager.Instance.OrbPrefab).SpawnWithServerAuthority();
} }
StartDelayedReady(); StartDelayedReady();

View File

@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using HarmonyLib; using HarmonyLib;

View File

@ -4,6 +4,8 @@ namespace QSB.PoolSync
{ {
internal class PoolManager : WorldObjectManager internal class PoolManager : WorldObjectManager
{ {
public override WorldObjectType WorldObjectType => WorldObjectType.SolarSystem;
protected override void RebuildWorldObjects(OWScene scene) protected override void RebuildWorldObjects(OWScene scene)
{ {
foreach (var streaming in QSBWorldSync.GetUnityObjects<NomaiRemoteCameraStreaming>()) foreach (var streaming in QSBWorldSync.GetUnityObjects<NomaiRemoteCameraStreaming>())

View File

@ -14,6 +14,8 @@ namespace QSB.QuantumSync
{ {
internal class QuantumManager : WorldObjectManager internal class QuantumManager : WorldObjectManager
{ {
public override WorldObjectType WorldObjectType => WorldObjectType.Both;
public static QuantumShrine Shrine { get; private set; } public static QuantumShrine Shrine { get; private set; }
public static QuantumManager Instance { get; private set; } public static QuantumManager Instance { get; private set; }

View File

@ -14,17 +14,23 @@ namespace QSB.SaveSync.Events
private void Handler(uint toId) => SendEvent(CreateMessage(toId)); private void Handler(uint toId) => SendEvent(CreateMessage(toId));
private GameStateMessage CreateMessage(uint toId) => new() private GameStateMessage CreateMessage(uint toId)
{ {
AboutId = LocalPlayerId, var gameSave = StandaloneProfileManager.SharedInstance.currentProfileGameSave;
ForId = toId, return new()
InSolarSystem = QSBSceneManager.CurrentScene == OWScene.SolarSystem, {
InEye = QSBSceneManager.CurrentScene == OWScene.EyeOfTheUniverse, AboutId = LocalPlayerId,
LaunchCodesGiven = PlayerData.KnowsLaunchCodes(), ForId = toId,
LoopCount = StandaloneProfileManager.SharedInstance.currentProfileGameSave.loopCount, InSolarSystem = QSBSceneManager.CurrentScene == OWScene.SolarSystem,
KnownFrequencies = StandaloneProfileManager.SharedInstance.currentProfileGameSave.knownFrequencies, InEye = QSBSceneManager.CurrentScene == OWScene.EyeOfTheUniverse,
KnownSignals = StandaloneProfileManager.SharedInstance.currentProfileGameSave.knownSignals WarpedToTheEye = gameSave.warpedToTheEye,
}; SecondsRemainingOnWarp = gameSave.secondsRemainingOnWarp,
LaunchCodesGiven = PlayerData.KnowsLaunchCodes(),
LoopCount = gameSave.loopCount,
KnownFrequencies = gameSave.knownFrequencies,
KnownSignals = gameSave.knownSignals,
};
}
public override void OnReceiveRemote(bool isHost, GameStateMessage message) public override void OnReceiveRemote(bool isHost, GameStateMessage message)
{ {
@ -40,6 +46,8 @@ namespace QSB.SaveSync.Events
gameSave.loopCount = message.LoopCount; gameSave.loopCount = message.LoopCount;
gameSave.knownFrequencies = message.KnownFrequencies; gameSave.knownFrequencies = message.KnownFrequencies;
gameSave.knownSignals = message.KnownSignals; gameSave.knownSignals = message.KnownSignals;
gameSave.warpedToTheEye = message.WarpedToTheEye;
gameSave.secondsRemainingOnWarp = message.SecondsRemainingOnWarp;
PlayerData.SetPersistentCondition("LAUNCH_CODES_GIVEN", message.LaunchCodesGiven); PlayerData.SetPersistentCondition("LAUNCH_CODES_GIVEN", message.LaunchCodesGiven);

View File

@ -9,6 +9,8 @@ namespace QSB.SaveSync.Events
{ {
public bool InSolarSystem { get; set; } public bool InSolarSystem { get; set; }
public bool InEye { get; set; } public bool InEye { get; set; }
public bool WarpedToTheEye { get; set; }
public float SecondsRemainingOnWarp { get; set; }
public bool LaunchCodesGiven { get; set; } public bool LaunchCodesGiven { get; set; }
public int LoopCount { get; set; } public int LoopCount { get; set; }
public bool[] KnownFrequencies { get; set; } public bool[] KnownFrequencies { get; set; }
@ -19,6 +21,8 @@ namespace QSB.SaveSync.Events
base.Deserialize(reader); base.Deserialize(reader);
InSolarSystem = reader.ReadBoolean(); InSolarSystem = reader.ReadBoolean();
InEye = reader.ReadBoolean(); InEye = reader.ReadBoolean();
WarpedToTheEye = reader.ReadBoolean();
SecondsRemainingOnWarp = reader.ReadSingle();
LaunchCodesGiven = reader.ReadBoolean(); LaunchCodesGiven = reader.ReadBoolean();
LoopCount = reader.ReadInt32(); LoopCount = reader.ReadInt32();
@ -46,6 +50,8 @@ namespace QSB.SaveSync.Events
base.Serialize(writer); base.Serialize(writer);
writer.Write(InSolarSystem); writer.Write(InSolarSystem);
writer.Write(InEye); writer.Write(InEye);
writer.Write(WarpedToTheEye);
writer.Write(SecondsRemainingOnWarp);
writer.Write(LaunchCodesGiven); writer.Write(LaunchCodesGiven);
writer.Write(LoopCount); writer.Write(LoopCount);

View File

@ -11,6 +11,8 @@ namespace QSB.SectorSync
{ {
public class QSBSectorManager : WorldObjectManager public class QSBSectorManager : WorldObjectManager
{ {
public override WorldObjectType WorldObjectType => WorldObjectType.Both;
public static QSBSectorManager Instance { get; private set; } public static QSBSectorManager Instance { get; private set; }
public bool IsReady { get; private set; } public bool IsReady { get; private set; }
public readonly List<QSBSector> FakeSectors = new(); public readonly List<QSBSector> FakeSectors = new();

View File

@ -14,6 +14,8 @@ namespace QSB.ShipSync
{ {
internal class ShipManager : WorldObjectManager internal class ShipManager : WorldObjectManager
{ {
public override WorldObjectType WorldObjectType => WorldObjectType.SolarSystem;
public static ShipManager Instance; public static ShipManager Instance;
public InteractZone HatchInteractZone; public InteractZone HatchInteractZone;

View File

@ -273,7 +273,7 @@ namespace QSB.TimeSync
var serverState = ServerStateManager.Instance.GetServerState(); var serverState = ServerStateManager.Instance.GetServerState();
var clientState = QSBPlayerManager.LocalPlayer.State; var clientState = QSBPlayerManager.LocalPlayer.State;
if (serverState == ServerState.WaitingForAllPlayersToReady && clientState == ClientState.WaitingForOthersToReadyInSolarSystem) if (serverState == ServerState.WaitingForAllPlayersToReady && clientState == ClientState.WaitingForOthersToBeReady)
{ {
if (CurrentState != State.Pausing) if (CurrentState != State.Pausing)
{ {
@ -289,7 +289,7 @@ namespace QSB.TimeSync
} }
} }
if (serverState == ServerState.WaitingForAllPlayersToDie && clientState == ClientState.WaitingForOthersToReadyInSolarSystem) if (serverState == ServerState.WaitingForAllPlayersToDie && clientState == ClientState.WaitingForOthersToBeReady)
{ {
if (CurrentState == State.Pausing && (PauseReason)CurrentReason == PauseReason.WaitingForAllPlayersToBeReady) if (CurrentState == State.Pausing && (PauseReason)CurrentReason == PauseReason.WaitingForAllPlayersToBeReady)
{ {
@ -352,12 +352,12 @@ namespace QSB.TimeSync
StartPausing(PauseReason.ServerNotStarted); StartPausing(PauseReason.ServerNotStarted);
} }
if (serverState == ServerState.WaitingForAllPlayersToReady && CurrentState != State.Pausing && clientState == ClientState.WaitingForOthersToReadyInSolarSystem) if (serverState == ServerState.WaitingForAllPlayersToReady && CurrentState != State.Pausing && clientState == ClientState.WaitingForOthersToBeReady)
{ {
StartPausing(PauseReason.WaitingForAllPlayersToBeReady); StartPausing(PauseReason.WaitingForAllPlayersToBeReady);
} }
if (serverState == ServerState.WaitingForAllPlayersToDie && clientState == ClientState.WaitingForOthersToReadyInSolarSystem) if (serverState == ServerState.WaitingForAllPlayersToDie && clientState == ClientState.WaitingForOthersToBeReady)
{ {
StartPausing(PauseReason.WaitingForAllPlayersToBeReady); StartPausing(PauseReason.WaitingForAllPlayersToBeReady);
} }

View File

@ -5,6 +5,8 @@ namespace QSB.Tools.ProbeLauncherTool
{ {
internal class ProbeLauncherManager : WorldObjectManager internal class ProbeLauncherManager : WorldObjectManager
{ {
public override WorldObjectType WorldObjectType => WorldObjectType.Both;
protected override void RebuildWorldObjects(OWScene scene) protected override void RebuildWorldObjects(OWScene scene)
=> QSBWorldSync.Init<QSBProbeLauncher, ProbeLauncher>(typeof(PlayerProbeLauncher)); => QSBWorldSync.Init<QSBProbeLauncher, ProbeLauncher>(typeof(PlayerProbeLauncher));
} }

View File

@ -5,6 +5,8 @@ namespace QSB.Tools.TranslatorTool.TranslationSync
{ {
internal class SpiralManager : WorldObjectManager internal class SpiralManager : WorldObjectManager
{ {
public override WorldObjectType WorldObjectType => WorldObjectType.Both;
protected override void RebuildWorldObjects(OWScene scene) protected override void RebuildWorldObjects(OWScene scene)
{ {
QSBWorldSync.Init<QSBWallText, NomaiWallText>(); QSBWorldSync.Init<QSBWallText, NomaiWallText>();

View File

@ -8,6 +8,8 @@ namespace QSB.TornadoSync
{ {
public class TornadoManager : WorldObjectManager public class TornadoManager : WorldObjectManager
{ {
public override WorldObjectType WorldObjectType => WorldObjectType.SolarSystem;
protected override void RebuildWorldObjects(OWScene scene) protected override void RebuildWorldObjects(OWScene scene)
{ {
QSBWorldSync.Init<QSBTornado, TornadoController>(); QSBWorldSync.Init<QSBTornado, TornadoController>();

View File

@ -39,6 +39,45 @@ namespace QSB.Utility
return; return;
} }
/*
* 1 - Warp to first player
* 2 - Set time flowing
* 3 -
* 4 - Damage ship electricals
* 5 - Trigger supernova
* 6 -
* 7 - Warp to vessel
* 8 - Place warp core into vessel
* 9 - Load eye scene
* 0 -
*/
if (Keyboard.current[Key.Numpad1].wasPressedThisFrame)
{
var otherPlayer = QSBPlayerManager.PlayerList.FirstOrDefault(x => x.PlayerId != QSBPlayerManager.LocalPlayerId);
if (otherPlayer != null && otherPlayer.Body != null)
{
var playerBody = Locator.GetPlayerBody();
playerBody.WarpToPositionRotation(otherPlayer.Body.transform.position, otherPlayer.Body.transform.rotation);
var parentBody = otherPlayer.TransformSync?.ReferenceSector?.AttachedObject?.GetOWRigidbody();
if (parentBody != null)
{
playerBody.SetVelocity(parentBody.GetVelocity());
playerBody.SetAngularVelocity(parentBody.GetAngularVelocity());
}
else
{
playerBody.SetVelocity(Vector3.zero);
playerBody.SetAngularVelocity(Vector3.zero);
}
}
}
if (Keyboard.current[Key.Numpad1].wasPressedThisFrame)
{
TimeLoop._isTimeFlowing = true;
}
if (Keyboard.current[Key.Numpad4].wasPressedThisFrame) if (Keyboard.current[Key.Numpad4].wasPressedThisFrame)
{ {
DamageShipElectricalSystem(); DamageShipElectricalSystem();
@ -64,27 +103,6 @@ namespace QSB.Utility
PlayerData.SaveWarpedToTheEye(60); PlayerData.SaveWarpedToTheEye(60);
LoadManager.LoadSceneAsync(OWScene.EyeOfTheUniverse, true, LoadManager.FadeType.ToWhite); LoadManager.LoadSceneAsync(OWScene.EyeOfTheUniverse, true, LoadManager.FadeType.ToWhite);
} }
if (Keyboard.current[Key.Numpad1].wasPressedThisFrame)
{
var otherPlayer = QSBPlayerManager.PlayerList.FirstOrDefault(x => x.PlayerId != QSBPlayerManager.LocalPlayerId);
if (otherPlayer != null && otherPlayer.Body != null)
{
var playerBody = Locator.GetPlayerBody();
playerBody.WarpToPositionRotation(otherPlayer.Body.transform.position, otherPlayer.Body.transform.rotation);
var parentBody = otherPlayer.TransformSync?.ReferenceSector?.AttachedObject?.GetOWRigidbody();
if (parentBody != null)
{
playerBody.SetVelocity(parentBody.GetVelocity());
playerBody.SetAngularVelocity(parentBody.GetAngularVelocity());
}
else
{
playerBody.SetVelocity(Vector3.zero);
playerBody.SetAngularVelocity(Vector3.zero);
}
}
}
} }
} }
} }

View File

@ -0,0 +1,13 @@
namespace System.Runtime.CompilerServices
{
public static class IsExternalInit
{
/*
* You might think this class isn't used. And you'd be right!
* But if you delete this file, the project will refuse to compile.
* This is because IsExternalInit is only included in net5 and above.
* So we have to create this dummy file to make it happy.
* Yay.
*/
}
}

View File

@ -53,19 +53,19 @@ namespace QSB.WorldSync
return default; return default;
} }
if (!WorldObjectsToUnityObjects.TryGetValue(unityObject, out var returnObject)) if (!WorldObjectsToUnityObjects.TryGetValue(unityObject, out var worldObject))
{ {
DebugLog.ToConsole($"Error - WorldObjectsToUnityObjects does not contain \"{unityObject.name}\"! TWorldObject:{typeof(TWorldObject).Name}, TUnityObject:{unityObject.GetType().Name}, Stacktrace:\r\n{Environment.StackTrace}", MessageType.Error); DebugLog.ToConsole($"Error - WorldObjectsToUnityObjects does not contain \"{unityObject.name}\"! TWorldObject:{typeof(TWorldObject).Name}, TUnityObject:{unityObject.GetType().Name}, Stacktrace:\r\n{Environment.StackTrace}", MessageType.Error);
return default; return default;
} }
if (returnObject == null) if (worldObject == null)
{ {
DebugLog.ToConsole($"Error - World object for unity object {unityObject.name} is null! TWorldObject:{typeof(TWorldObject).Name}, TUnityObject:{unityObject.GetType().Name}, Stacktrace:\r\n{Environment.StackTrace}", MessageType.Error); DebugLog.ToConsole($"Error - World object for unity object {unityObject.name} is null! TWorldObject:{typeof(TWorldObject).Name}, TUnityObject:{unityObject.GetType().Name}, Stacktrace:\r\n{Environment.StackTrace}", MessageType.Error);
return default; return default;
} }
return (TWorldObject)returnObject; return (TWorldObject)worldObject;
} }
public static int GetIdFromUnity<TWorldObject>(MonoBehaviour unityObject) public static int GetIdFromUnity<TWorldObject>(MonoBehaviour unityObject)

View File

@ -6,8 +6,8 @@ namespace QSB.WorldSync
public abstract class WorldObject<T> : IWorldObject public abstract class WorldObject<T> : IWorldObject
where T : MonoBehaviour where T : MonoBehaviour
{ {
public int ObjectId { get; set; } public int ObjectId { get; init; }
public T AttachedObject { get; set; } public T AttachedObject { get; init; }
public string Name => AttachedObject == null ? "<NullObject!>" : AttachedObject.name; public string Name => AttachedObject == null ? "<NullObject!>" : AttachedObject.name;
public string LogName => $"{QSBPlayerManager.LocalPlayerId}.{ObjectId}:{GetType().Name}"; public string LogName => $"{QSBPlayerManager.LocalPlayerId}.{ObjectId}:{GetType().Name}";

View File

@ -7,6 +7,13 @@ using UnityEngine;
namespace QSB.WorldSync namespace QSB.WorldSync
{ {
public enum WorldObjectType
{
Both,
SolarSystem,
Eye
}
public abstract class WorldObjectManager : MonoBehaviour public abstract class WorldObjectManager : MonoBehaviour
{ {
private static readonly List<WorldObjectManager> _managers = new(); private static readonly List<WorldObjectManager> _managers = new();
@ -21,6 +28,11 @@ namespace QSB.WorldSync
/// </summary> /// </summary>
public static bool AllObjectsReady { get; private set; } public static bool AllObjectsReady { get; private set; }
/// <summary>
/// when the scene does not match the type, this manager will not build its world objects
/// </summary>
public abstract WorldObjectType WorldObjectType { get; }
public virtual void Awake() public virtual void Awake()
{ {
QSBSceneManager.OnSceneLoaded += OnSceneLoaded; QSBSceneManager.OnSceneLoaded += OnSceneLoaded;
@ -73,6 +85,14 @@ namespace QSB.WorldSync
AllObjectsReady = false; AllObjectsReady = false;
foreach (var manager in _managers) foreach (var manager in _managers)
{ {
switch (manager.WorldObjectType)
{
case WorldObjectType.SolarSystem when QSBSceneManager.CurrentScene != OWScene.SolarSystem:
case WorldObjectType.Eye when QSBSceneManager.CurrentScene != OWScene.EyeOfTheUniverse:
DebugLog.DebugWrite($"skipping {manager.GetType().Name} as it is type {manager.WorldObjectType} and scene is {QSBSceneManager.CurrentScene}");
continue;
}
try try
{ {
DebugLog.DebugWrite($"Rebuilding {manager.GetType().Name}", MessageType.Info); DebugLog.DebugWrite($"Rebuilding {manager.GetType().Name}", MessageType.Info);

View File

@ -5,6 +5,8 @@ namespace QSB.ZeroGCaveSync
{ {
internal class ZeroGCaveManager : WorldObjectManager internal class ZeroGCaveManager : WorldObjectManager
{ {
public override WorldObjectType WorldObjectType => WorldObjectType.SolarSystem;
protected override void RebuildWorldObjects(OWScene scene) protected override void RebuildWorldObjects(OWScene scene)
=> QSBWorldSync.Init<QSBSatelliteNode, SatelliteNode>(); => QSBWorldSync.Init<QSBSatelliteNode, SatelliteNode>();
} }

View File

@ -1,8 +1,8 @@
{ {
"debugMode": false, "debugMode": false,
"drawLines": false, "drawLines": false,
"showQuantumVisibilityObjects": false, "showQuantumVisibilityObjects": true,
"showQuantumDebugBoxes": false, "showQuantumDebugBoxes": true,
"avoidTimeSync": false, "avoidTimeSync": false,
"skipTitleScreen": false "skipTitleScreen": false
} }