Merge branch 'dev' into update-epic-transport

This commit is contained in:
Mister_Nebula 2022-08-26 12:53:14 +01:00
commit 9c397fb100
20 changed files with 92 additions and 145 deletions

Binary file not shown.

View File

@ -4,6 +4,9 @@ using QSB.WorldSync;
namespace QSB.ConversationSync.WorldObjects;
/// <summary>
/// BUG: do conversation leave on player leave so other people can actually talk lol
/// </summary>
public class QSBCharacterDialogueTree : WorldObject<CharacterDialogueTree>
{
public override void SendInitialState(uint to)

View File

@ -111,6 +111,11 @@ internal class LightSensorPatches : QSBPatch
_illuminatingDreamLanternList.AddRange(__instance._illuminatingDreamLanternList);
}
__instance.UpdateIllumination();
if (__instance._illuminatingDreamLanternList != null &&
!__instance._illuminatingDreamLanternList.SequenceEqual(_illuminatingDreamLanternList))
{
qsbLightSensor.SendMessage(new IlluminatingLanternsMessage(__instance._illuminatingDreamLanternList));
}
if (!illuminated && __instance._illuminated)
{
__instance.OnDetectLight.Invoke();
@ -121,11 +126,6 @@ internal class LightSensorPatches : QSBPatch
__instance.OnDetectDarkness.Invoke();
qsbLightSensor.SendMessage(new SetIlluminatedMessage(false));
}
if (__instance._illuminatingDreamLanternList != null &&
!__instance._illuminatingDreamLanternList.SequenceEqual(_illuminatingDreamLanternList))
{
qsbLightSensor.SendMessage(new IlluminatingLanternsMessage(__instance._illuminatingDreamLanternList));
}
}
var locallyIlluminated = qsbLightSensor._locallyIlluminated;
@ -165,6 +165,11 @@ internal class LightSensorPatches : QSBPatch
_illuminatingDreamLanternList.AddRange(__instance._illuminatingDreamLanternList);
}
__instance.UpdateIllumination();
if (__instance._illuminatingDreamLanternList != null &&
!__instance._illuminatingDreamLanternList.SequenceEqual(_illuminatingDreamLanternList))
{
new PlayerIlluminatingLanternsMessage(QSBPlayerManager.LocalPlayerId, __instance._illuminatingDreamLanternList).Send();
}
if (!illuminated && __instance._illuminated)
{
__instance.OnDetectLight.Invoke();
@ -175,11 +180,6 @@ internal class LightSensorPatches : QSBPatch
__instance.OnDetectDarkness.Invoke();
new PlayerSetIlluminatedMessage(QSBPlayerManager.LocalPlayerId, false).Send();
}
if (__instance._illuminatingDreamLanternList != null &&
!__instance._illuminatingDreamLanternList.SequenceEqual(_illuminatingDreamLanternList))
{
new PlayerIlluminatingLanternsMessage(QSBPlayerManager.LocalPlayerId, __instance._illuminatingDreamLanternList).Send();
}
return false;
}

View File

@ -10,7 +10,8 @@ namespace QSB.EchoesOfTheEye.RaftSync.TransformSync;
public class RaftTransformSync : UnsectoredRigidbodySync, ILinkedNetworkBehaviour
{
protected override bool UseInterpolation => false;
private bool IsRidingRaft => Locator.GetPlayerController() && Locator.GetPlayerController().GetGroundBody() == AttachedRigidbody;
protected override bool UseInterpolation => !IsRidingRaft;
private float _lastSetPositionTime;
private const float ForcePositionAfterTime = 1;
@ -74,11 +75,10 @@ public class RaftTransformSync : UnsectoredRigidbodySync, ILinkedNetworkBehaviou
/// </summary>
protected override void ApplyToAttached()
{
var targetPos = ReferenceTransform.FromRelPos(transform.position);
var targetRot = ReferenceTransform.FromRelRot(transform.rotation);
var targetPos = ReferenceTransform.FromRelPos(UseInterpolation ? SmoothPosition : transform.position);
var targetRot = ReferenceTransform.FromRelRot(UseInterpolation ? SmoothRotation : transform.rotation);
var onRaft = Locator.GetPlayerController().GetGroundBody() == AttachedRigidbody;
if (onRaft)
if (IsRidingRaft)
{
if (Time.unscaledTime >= _lastSetPositionTime + ForcePositionAfterTime)
{

View File

@ -361,7 +361,13 @@ internal class MenuManager : MonoBehaviour, IAddComponentOnStart
ConnectPopup.EnableMenu(false);
Connect();
};
ConnectPopup.OnActivateMenu += () => _connectPopupOpenTime = Time.time;
ConnectPopup.OnActivateMenu += () =>
{
_connectPopupOpenTime = Time.time;
// ClearInputTextField is called AFTER OnActivateMenu
Delay.RunNextFrame(() => ConnectPopup._inputField.SetTextWithoutNotify(GUIUtility.systemCopyBuffer));
};
OneButtonInfoPopup = QSBCore.MenuApi.MakeInfoPopup("", "");
OneButtonInfoPopup.OnPopupConfirm += () => OnCloseInfoPopup(true);
@ -566,8 +572,8 @@ internal class MenuManager : MonoBehaviour, IAddComponentOnStart
private void PreHost()
{
bool doesSingleplayerSaveExist = false;
bool doesMultiplayerSaveExist = false;
var doesSingleplayerSaveExist = false;
var doesMultiplayerSaveExist = false;
if (!QSBCore.IsStandalone)
{
var manager = QSBMSStoreProfileManager.SharedInstance;
@ -681,7 +687,7 @@ internal class MenuManager : MonoBehaviour, IAddComponentOnStart
PlayerData.Init(manager.currentProfileMultiplayerGameSave, manager.currentProfileGameSettings, manager.currentProfileGraphicsSettings, manager.currentProfileInputJSON);
}
var address = ConnectPopup.GetInputText();
var address = ConnectPopup.GetInputText().Trim();
if (address == string.Empty)
{
address = QSBCore.DefaultServerIP;
@ -695,7 +701,7 @@ internal class MenuManager : MonoBehaviour, IAddComponentOnStart
Locator.GetMenuInputModule().DisableInputs();
QSBNetworkManager.singleton.networkAddress = address;
// hack to get disconnect call if start client fails immediately
// hack to get disconnect call if start client fails immediately (happens on kcp transport when failing to resolve host name)
typeof(NetworkClient).GetProperty(nameof(NetworkClient.connection))!.SetValue(null, new NetworkConnectionToServer());
QSBNetworkManager.singleton.StartClient();
}

View File

@ -71,6 +71,13 @@ public class PlayerJoinMessage : QSBMessage
{
if (QSBCore.IsHost)
{
if (QSBCore.DebugSettings.KickEveryone)
{
DebugLog.ToConsole($"Kicking {PlayerName} because of DebugSettings.KickEveryone", MessageType.Error);
new PlayerKickMessage(From, "This server has DebugSettings.KickEveryone enabled.").Send();
return;
}
if (QSBVersion != QSBCore.QSBVersion)
{
DebugLog.ToConsole($"Error - Client {PlayerName} connecting with wrong QSB version. (Client:{QSBVersion}, Server:{QSBCore.QSBVersion})", MessageType.Error);
@ -92,7 +99,7 @@ public class PlayerJoinMessage : QSBMessage
return;
}
if (QSBPlayerManager.PlayerList.Any(x => x.EyeState >= EyeState.Observatory))
if (QSBPlayerManager.PlayerList.Any(x => x.EyeState > EyeState.Observatory))
{
DebugLog.ToConsole($"Error - Client {PlayerName} connecting too late into eye scene.", MessageType.Error);
new PlayerKickMessage(From, QSBLocalization.Current.GameProgressLimit).Send();

View File

@ -33,7 +33,7 @@ public class PlayerHUDMarker : HUDDistanceMarker
return false;
}
return _player.IsReady && !_player.IsDead && !_player.InDreamWorld && _player.Visible;
return _player.IsReady && !_player.IsDead && (!_player.InDreamWorld || QSBPlayerManager.LocalPlayer.InDreamWorld) && _player.Visible;
}
private void Update()

View File

@ -31,7 +31,7 @@ public partial class PlayerInfo
public bool IsInEyeShuttle { get; set; }
public IQSBQuantumObject EntangledObject { get; set; }
public QSBPlayerAudioController AudioController { get; set; }
public bool IsLocalPlayer => TransformSync.isLocalPlayer;
public bool IsLocalPlayer => TransformSync.isLocalPlayer; // if TransformSync is ever null, i give permission for nebula to make fun of me about it for the rest of time - johncorby
public ThrusterLightTracker ThrusterLightTracker;
public bool FlyingShip => ShipManager.Instance.CurrentFlyer == PlayerId;
@ -155,4 +155,4 @@ public partial class PlayerInfo
}
public override string ToString() => $"{PlayerId}:{GetType().Name} ({Name})";
}
}

View File

@ -58,7 +58,7 @@ public class PlayerMapMarker : MonoBehaviour
var playerScreenPos = Locator.GetActiveCamera().WorldToScreenPoint(transform.position);
var isInfrontOfCamera = playerScreenPos.z > 0f;
return _player.IsReady && !_player.IsDead && !_player.InDreamWorld && _player.Visible && isInfrontOfCamera;
return _player.IsReady && !_player.IsDead && (!_player.InDreamWorld || QSBPlayerManager.LocalPlayer.InDreamWorld) && _player.Visible && isInfrontOfCamera;
}
public void LateUpdate()

View File

@ -5,7 +5,6 @@ using QSB.Tools.FlashlightTool;
using QSB.Tools.ProbeTool;
using QSB.Utility;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
@ -22,7 +21,7 @@ public static class QSBPlayerManager
if (localInstance == null)
{
DebugLog.ToConsole("Error - Trying to get LocalPlayer when the local PlayerTransformSync instance is null." +
$"{Environment.NewLine} Stacktrace : {Environment.StackTrace} ", MessageType.Error);
$"{Environment.NewLine} Stacktrace : {Environment.StackTrace} ", MessageType.Error);
return null;
}
@ -66,8 +65,8 @@ public static class QSBPlayerManager
{
var cameraList = PlayerList.Where(x => x.Camera != null && x.PlayerId != LocalPlayerId).ToList();
if (includeLocalCamera
&& LocalPlayer != default
&& LocalPlayer.Camera != null)
&& LocalPlayer != default
&& LocalPlayer.Camera != null)
{
cameraList.Add(LocalPlayer);
}
@ -75,11 +74,11 @@ public static class QSBPlayerManager
{
if (LocalPlayer == default)
{
DebugLog.ToConsole($"Error - LocalPlayer is null.", MessageType.Error);
DebugLog.ToConsole("Error - LocalPlayer is null.", MessageType.Error);
return cameraList;
}
DebugLog.ToConsole($"Error - LocalPlayer.Camera is null.", MessageType.Error);
DebugLog.ToConsole("Error - LocalPlayer.Camera is null.", MessageType.Error);
LocalPlayer.Camera = Locator.GetPlayerCamera();
}
@ -109,7 +108,7 @@ public static class QSBPlayerManager
{
if (playerList == null)
{
DebugLog.ToConsole($"Error - Cannot get closest player from null player list.", MessageType.Error);
DebugLog.ToConsole("Error - Cannot get closest player from null player list.", MessageType.Error);
return null;
}
@ -117,7 +116,7 @@ public static class QSBPlayerManager
if (playerList.Count == 0)
{
DebugLog.ToConsole($"Error - Cannot get closest player from empty (ready) player list.", MessageType.Error);
DebugLog.ToConsole("Error - Cannot get closest player from empty (ready) player list.", MessageType.Error);
return null;
}
@ -126,67 +125,4 @@ public static class QSBPlayerManager
public static IEnumerable<(PlayerInfo Player, IQSBItem HeldItem)> GetPlayerCarryItems()
=> PlayerList.Select(x => (x, x.HeldItem));
private static Dictionary<int, PlayerInfo> _connectionIdToPlayer = new();
public static IEnumerator ValidatePlayers()
{
while (true)
{
if (QSBCore.IsInMultiplayer && QSBCore.IsHost)
{
_connectionIdToPlayer.Clear();
var playersToRemove = new List<PlayerInfo>();
foreach (var player in PlayerList)
{
var transformSync = player.TransformSync;
if (transformSync == null)
{
DebugLog.ToConsole($"Error - {player.PlayerId}'s TransformSync is null.", MessageType.Error);
playersToRemove.Add(player);
continue;
}
var networkIdentity = transformSync.netIdentity;
if (networkIdentity == null)
{
DebugLog.ToConsole($"Error - {player.PlayerId}'s TransformSync's NetworkIdentity is null.", MessageType.Error);
playersToRemove.Add(player);
continue;
}
var connectionToClient = networkIdentity.connectionToClient;
if (_connectionIdToPlayer.ContainsKey(connectionToClient.connectionId))
{
// oh god oh fuck
DebugLog.ToConsole($"Error - {player.PlayerId}'s connectionToClient.connectionId is already being used?!?", MessageType.Error);
playersToRemove.Add(player);
continue;
}
_connectionIdToPlayer.Add(connectionToClient.connectionId, player);
}
if (playersToRemove.Count != 0)
{
DebugLog.DebugWrite($"Removing {playersToRemove.Count} invalid players.", MessageType.Success);
foreach (var player in playersToRemove)
{
OnRemovePlayer?.Invoke(player);
player.HudMarker?.Remove();
PlayerList.Remove(player);
DebugLog.DebugWrite($"Remove Invalid Player : {player}", MessageType.Info);
}
}
}
yield return new WaitForSecondsRealtime(5);
}
}
}
}

View File

@ -29,25 +29,8 @@ public class PlayerTransformSync : SectoredTransformSync
private Transform _visibleStickTip;
private Transform _networkStickTip => _networkStickPivot.GetChild(0);
private bool _hasRanOnStartClient;
public override void OnStartClient()
{
if (_hasRanOnStartClient)
{
DebugLog.ToConsole($"ERROR - OnStartClient is being called AGAIN for {Player.PlayerId}'s PlayerTransformSync!", MessageType.Error);
return;
}
_hasRanOnStartClient = true;
if (QSBPlayerManager.PlayerList.Any(x => x.TransformSync == this))
{
// this really shouldnt happen...
DebugLog.ToConsole($"Error - A PlayerInfo already exists with TransformSync {name}", MessageType.Error);
Destroy(gameObject); // probably bad
return;
}
var player = new PlayerInfo(this);
QSBPlayerManager.PlayerList.SafeAdd(player);
base.OnStartClient();
@ -57,19 +40,7 @@ public class PlayerTransformSync : SectoredTransformSync
JoinLeaveSingularity.Create(Player, true);
}
public override void OnStartLocalPlayer()
{
if (LocalInstance != null)
{
DebugLog.ToConsole($"ERROR - LocalInstance is already non-null in OnStartLocalPlayer!", MessageType.Error);
Destroy(gameObject); // probably bad
return;
}
LocalInstance = this;
}
public override void OnStopLocalPlayer() => LocalInstance = null;
public override void OnStartLocalPlayer() => LocalInstance = this;
public override void OnStopClient()
{

View File

@ -138,6 +138,23 @@ internal class CustomNomaiRemoteCameraPlatform : NomaiShared
QSBPlayerManager.OnRemovePlayer -= OnRemovePlayer;
}
private void LateUpdate()
{
// can't put this stuff in Update/UpdateHologramTransforms as
// manual bone rotations need to happen after the animator has changed them
if ((_platformActive && _anyoneStillOnPlatform) || _cameraState == CameraState.Disconnecting_FadeIn)
{
foreach (var item in _playerToHologram)
{
var hologram = item.Value.transform;
var anim = hologram.GetChild(0).gameObject.GetComponent<Animator>();
var cameraRotation = item.Key.CameraBody.transform.localRotation.eulerAngles;
var rotation = Quaternion.Euler(-cameraRotation.y, -cameraRotation.z, cameraRotation.x); // wtf why
anim.GetBoneTransform(HumanBodyBones.Head).localRotation = rotation;
}
}
}
private void Update()
{
if (_platformActive)
@ -719,10 +736,6 @@ internal class CustomNomaiRemoteCameraPlatform : NomaiShared
hologramCopy.GetChild(0).Find("player_mesh_noSuit:Traveller_HEA_Player/player_mesh_noSuit:Player_Head").gameObject.layer = 0;
hologramCopy.GetChild(0).Find("Traveller_Mesh_v01:Traveller_Geo/Traveller_Mesh_v01:PlayerSuit_Helmet").gameObject.layer = 0;
// BUG : Look at this again... probably need to sync head rotation to something else
//var ikSync = hologramCopy.GetChild(0).gameObject.AddComponent<PlayerHeadRotationSync>();
//ikSync.Init(player.CameraBody.transform);
if (player.AnimationSync.VisibleAnimator == null)
{
DebugLog.ToConsole($"Warning - {playerId}'s VisibleAnimator is null!", MessageType.Error);

View File

@ -5,7 +5,6 @@ using OWML.ModHelper;
using QSB.Localization;
using QSB.Menus;
using QSB.Patches;
using QSB.Player;
using QSB.QuantumSync;
using QSB.SaveSync;
using QSB.Utility;
@ -79,7 +78,6 @@ public class QSBCore : ModBehaviour
"_nebula.StopTime",
"Leadpogrommer.PeacefulGhosts",
"PacificEngine.OW_Randomizer",
"xen.DayDream"
};
private static void DetermineGameVendor()
@ -188,8 +186,6 @@ public class QSBCore : ModBehaviour
QSBWorldSync.Managers = components.OfType<WorldObjectManager>().ToArray();
QSBPatchManager.OnPatchType += OnPatchType;
QSBPatchManager.OnUnpatchType += OnUnpatchType;
StartCoroutine(QSBPlayerManager.ValidatePlayers());
}
private static void OnPatchType(QSBPatchTypes type)

View File

@ -15,7 +15,11 @@ internal class ShipLegTransformSync : SectoredRigidbodySync, ILinkedNetworkBehav
=> AttachedTransform
&& base.CheckValid();
protected override bool CheckReady() => base.CheckReady() && _qsbModule.AttachedObject.isDetached;
protected override bool CheckReady()
=> base.CheckReady()
&& _qsbModule != null // not sure how either of these can be null, but i guess better safe than sorry
&& _qsbModule.AttachedObject != null
&& _qsbModule.AttachedObject.isDetached;
protected override bool UseInterpolation => true;

View File

@ -15,7 +15,11 @@ internal class ShipModuleTransformSync : SectoredRigidbodySync, ILinkedNetworkBe
=> AttachedTransform
&& base.CheckValid();
protected override bool CheckReady() => base.CheckReady() && _qsbModule.AttachedObject.isDetached;
protected override bool CheckReady()
=> base.CheckReady()
&& _qsbModule != null // not sure how either of these can be null, but i guess better safe than sorry
&& _qsbModule.AttachedObject != null
&& _qsbModule.AttachedObject.isDetached;
protected override bool UseInterpolation => true;

View File

@ -56,10 +56,10 @@ public class ShipTransformSync : SectoredRigidbodySync
return;
}
var targetPos = ReferenceTransform.FromRelPos(transform.position);
var targetRot = ReferenceTransform.FromRelRot(transform.rotation);
var targetPos = ReferenceTransform.FromRelPos(UseInterpolation ? SmoothPosition : transform.position);
var targetRot = ReferenceTransform.FromRelRot(UseInterpolation ? SmoothRotation : transform.rotation);
if (PlayerState.IsInsideShip())
if (IsInsideShip)
{
if (Time.unscaledTime >= _lastSetPositionTime + ForcePositionAfterTime)
{
@ -98,5 +98,6 @@ public class ShipTransformSync : SectoredRigidbodySync
rigidbody._currentVelocity = newVelocity;
}
protected override bool UseInterpolation => false;
private static bool IsInsideShip => PlayerState.IsInsideShip();
protected override bool UseInterpolation => !IsInsideShip;
}

View File

@ -146,7 +146,11 @@ public class WakeUpSync : NetworkBehaviour
{
_serverTime = time;
_serverLoopCount = count;
QSBPatch.RemoteCall(() => TimeLoop.SetSecondsRemaining(secondsRemaining));
// prevents accidental supernova at start of loop
if (_serverLoopCount == PlayerData.LoadLoopCount())
{
QSBPatch.RemoteCall(() => TimeLoop.SetSecondsRemaining(secondsRemaining));
}
}
private void WakeUpOrSleep()

View File

@ -223,7 +223,7 @@ public class DebugActions : MonoBehaviour, IAddComponentOnStart
var player = new PlayerInfo(QSBPlayerManager.LocalPlayer.TransformSync);
QSBPlayerManager.PlayerList.SafeAdd(player);
QSBPlayerManager.OnAddPlayer?.Invoke(player);
DebugLog.DebugWrite($"Create Player : {player}", MessageType.Info);
DebugLog.DebugWrite($"CREATING FAKE PLAYER : {player}", MessageType.Info);
JoinLeaveSingularity.Create(player, true);
}

View File

@ -26,6 +26,9 @@ public class DebugSettings
[JsonProperty("skipTitleScreen")]
public bool SkipTitleScreen;
[JsonProperty("kickEveryone")]
public bool KickEveryone;
[JsonProperty("debugMode")]
public bool DebugMode;

View File

@ -40,8 +40,7 @@ Spoilers within!
#### Hosting a server
- Enter a game. This can be a new expedition or an existing save file.
- On the pause screen, click the option `OPEN TO MULTIPLAYER`.
- On the title screen, click the option `OPEN TO MULTIPLAYER`.
- Share your Product User ID with the people who want to connect.
- Enjoy!