diff --git a/Assets/Scenes/Levels/DefaultCastle.unity b/Assets/Scenes/Levels/DefaultCastle.unity index 8dfe885177..0b2ce48191 100644 --- a/Assets/Scenes/Levels/DefaultCastle.unity +++ b/Assets/Scenes/Levels/DefaultCastle.unity @@ -4231,7 +4231,6 @@ GameObject: - component: {fileID: 361225204} - component: {fileID: 361225200} - component: {fileID: 361225208} - - component: {fileID: 361225205} - component: {fileID: 361225209} m_Layer: 8 m_Name: Tilemap_Squishy @@ -11798,21 +11797,6 @@ TilemapCollider2D: m_MaximumTileChangeCount: 1000 m_ExtrusionFactor: 0.00001 m_UseDelaunayMesh: 0 ---- !u!114 &361225205 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 361225195} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: fedcefda7c82c5f4483ddc0098f43865, type: 3} - m_Name: - m_EditorClassIdentifier: - target: 0 - behaviours: - - {fileID: 361225208} --- !u!114 &361225208 MonoBehaviour: m_ObjectHideFlags: 0 @@ -11903,7 +11887,6 @@ MonoBehaviour: NestedObjects: [] NetworkedBehaviours: - {fileID: 361225208} - - {fileID: 361225205} --- !u!1001 &379146488 PrefabInstance: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/BuildInfo.cs b/Assets/Scripts/BuildInfo.cs index 3a84444c14..9043282f54 100644 --- a/Assets/Scripts/BuildInfo.cs +++ b/Assets/Scripts/BuildInfo.cs @@ -1 +1 @@ -public static class BuildInfo{public static string BUILD_TIME = "12/30/2023 4:30:11 AM";} +public static class BuildInfo{public static string BUILD_TIME = "12/31/2023 4:26:34 AM";} diff --git a/Assets/Scripts/Entity/BigStar.cs b/Assets/Scripts/Entity/BigStar.cs index 87c842a780..0fc987fd57 100644 --- a/Assets/Scripts/Entity/BigStar.cs +++ b/Assets/Scripts/Entity/BigStar.cs @@ -176,7 +176,7 @@ public void Rpc_StarCollected(PlayerController collector) { public override void Despawned(NetworkRunner runner, bool hasState) { - if (GameManager.Instance && GameManager.Instance.GameState == Enums.GameState.Playing && !Collector) { + if (GameManager.Instance && GameManager.Instance.Object && GameManager.Instance.GameState == Enums.GameState.Playing && !Collector) { GameManager.Instance.particleManager.Play(Enums.Particle.Generic_Puff, transform.position); } diff --git a/Assets/Scripts/Entity/Player/PlayerController.cs b/Assets/Scripts/Entity/Player/PlayerController.cs index 4469ca02e6..ffe30eaa03 100644 --- a/Assets/Scripts/Entity/Player/PlayerController.cs +++ b/Assets/Scripts/Entity/Player/PlayerController.cs @@ -332,8 +332,6 @@ public override void Spawned() { Data = Object.InputAuthority.GetPlayerData(Runner); if (HasInputAuthority) { - //body.InterpolationDataSource = InterpolationDataSources.Predicted; - GameManager.Instance.localPlayer = this; GameManager.Instance.spectationManager.Spectating = false; ControlSystem.controls.Player.ReserveItem.performed += OnReserveItem; @@ -466,16 +464,16 @@ public override void FixedUpdateNetwork() { if (!IsProxy) { #if INPUT_BUFFERING_TEST - int inputIndex = Runner.Tick % InputBufferCapacity; - PlayerNetworkInput input = InputBuffer[inputIndex]; - - if (GetInput(out PlayerNetworkInput inputsThisTick)) { - // Add later inputs to the buffer. - InputBuffer.Set(inputIndex, inputsThisTick); - } else if (!IsProxy) { - // Didn't get the inputs, but we *need* them. Interpolate based on what it *could* be? - InputBuffer.Set(inputIndex, HandleMissingInputs()); - } + int inputIndex = Runner.Tick % InputBufferCapacity; + PlayerNetworkInput input = InputBuffer[inputIndex]; + + if (GetInput(out PlayerNetworkInput inputsThisTick)) { + // Add later inputs to the buffer. + InputBuffer.Set(inputIndex, inputsThisTick); + } else if (!IsProxy) { + // Didn't get the inputs, but we *need* them. Interpolate based on what it *could* be? + InputBuffer.Set(inputIndex, HandleMissingInputs()); + } #else PlayerNetworkInput input; if (GetInput(out PlayerNetworkInput currentInputs)) { @@ -495,7 +493,6 @@ public override void FixedUpdateNetwork() { if (IsDead) { HandleDeathTimers(); } else if (!IsFrozen) { - NetworkButtons heldButtons = input.buttons; NetworkButtons pressedButtons = input.buttons.GetPressed(PreviousInputs.buttons); diff --git a/Assets/Scripts/Entity/World Elements/GenericMover.cs b/Assets/Scripts/Entity/World Elements/GenericMover.cs index 4fdde6c8f5..cb70008625 100644 --- a/Assets/Scripts/Entity/World Elements/GenericMover.cs +++ b/Assets/Scripts/Entity/World Elements/GenericMover.cs @@ -28,6 +28,7 @@ public void Start() { public override void Spawned() { Origin = transform.position; + Runner.SetIsSimulated(Object, true); } public void BeforeTick() { diff --git a/Assets/Scripts/Entity/World Elements/GenericMover.cs.meta b/Assets/Scripts/Entity/World Elements/GenericMover.cs.meta index 42ed7ef275..c08f9974e2 100644 --- a/Assets/Scripts/Entity/World Elements/GenericMover.cs.meta +++ b/Assets/Scripts/Entity/World Elements/GenericMover.cs.meta @@ -4,7 +4,7 @@ MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: [] - executionOrder: 0 + executionOrder: -50 icon: {instanceID: 0} userData: assetBundleName: diff --git a/Assets/Scripts/GameManager.cs b/Assets/Scripts/GameManager.cs index cb8c9a29c4..7de0707072 100644 --- a/Assets/Scripts/GameManager.cs +++ b/Assets/Scripts/GameManager.cs @@ -655,6 +655,8 @@ private void Rpc_StartGame() { } private IEnumerator WaitToStartGame() { + GameStartTime = Runner.SimulationTime + 1.3f; + yield return new WaitForSecondsRealtime(1.3f); // Keep track of game timestamps diff --git a/Assets/Scripts/Networking/Fusion/NetworkHandler.cs b/Assets/Scripts/Networking/Fusion/NetworkHandler.cs index ab0320babf..031dfe64ac 100644 --- a/Assets/Scripts/Networking/Fusion/NetworkHandler.cs +++ b/Assets/Scripts/Networking/Fusion/NetworkHandler.cs @@ -22,15 +22,6 @@ public class NetworkHandler : Singleton, INetworkRunnerCallbacks //---Static Variables public static readonly string[] Regions = { "asia", "eu", "jp", "kr", "sa", "us", "usw" }; - public static readonly Dictionary RegionIPs = new() { - ["asia"] = "15.235.132.46", - ["eu"] = "192.36.27.39", - ["jp"] = "139.162.127.196", - ["kr"] = "158.247.198.230", - ["sa"] = "200.25.36.72", - ["us"] = "45.86.230.227", - ["usw"] = "45.145.148.21", - }; public static readonly Dictionary RegionPings = new(); public static readonly string RoomIdValidChars = "BCDFGHJKLMNPRQSTVWXYZ"; private static readonly int RoomIdLength = 8; @@ -456,6 +447,27 @@ public static async Task ConnectToRegion(string region = "") { // And join lobby StartGameResult result = await Runner.JoinSessionLobby(SessionLobby.ClientServer, authentication: authValues, customAppSettings: appSettings); if (result.Ok) { + try { + // Wacky reflection to get the region pings. + object cloudServices = Runner.GetType().GetField("_cloudServices", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).GetValue(Runner); + object communicator = cloudServices.GetType().GetProperty("Communicator", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public).GetValue(cloudServices); + object client = communicator.GetType().GetProperty("Client", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public).GetValue(communicator); + object regionHandler = client.GetType().GetField("RegionHandler", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public).GetValue(client); + IList regions = (IList) regionHandler.GetType().GetProperty("EnabledRegions", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public).GetValue(regionHandler); + + var codeField = regions[0].GetType().GetProperty("Code", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public); + var pingField = regions[0].GetType().GetProperty("Ping", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public); + foreach (object item in regions) { + string code = (string) codeField.GetValue(item); + int ping = (int) pingField.GetValue(item); + RegionPings[code] = ping; + } + + OnRegionPingsUpdated?.Invoke(); + } catch (Exception e) { + Debug.LogError(e); + } + CurrentRegion = Runner.LobbyInfo.Region; Debug.Log($"[Network] Connected to a Lobby ({Runner.LobbyInfo.Name}, {CurrentRegion})"); @@ -595,43 +607,6 @@ public static async Task JoinRoom(string roomId) { } #endregion - private static float pingStartTime; - public static IEnumerator PingRegions() { - foreach ((string region, _) in RegionIPs) { - RegionPings[region] = 0; - } - - pingStartTime = Time.time; - Dictionary pingers = new(); - - foreach ((string region, string ip) in RegionIPs) { - pingers[region] = new(ip); - } - - bool anyRemaining = true; - while (anyRemaining && Time.time - pingStartTime < 4) { - anyRemaining = false; - - foreach ((string region, Ping pinger) in pingers) { - if (pinger == null) { - continue; - } - - if (!pinger.isDone) { - anyRemaining = true; - continue; - } - - // Ping done. - RegionPings[region] = pinger.time; - pinger.DestroyPing(); - } - yield return null; - } - - OnRegionPingsUpdated?.Invoke(); - } - private static void RoomInitialized(NetworkRunner runner) { Instance.playerDatas.Clear(); diff --git a/Assets/Scripts/UI/Menu/MainMenuManager.cs b/Assets/Scripts/UI/Menu/MainMenuManager.cs index 4d59e76ee6..d98157cc1d 100644 --- a/Assets/Scripts/UI/Menu/MainMenuManager.cs +++ b/Assets/Scripts/UI/Menu/MainMenuManager.cs @@ -113,7 +113,7 @@ public void Start() { PreviewLevel(UnityEngine.Random.Range(0, maps.Count)); UpdateRegionDropdown(); - StartCoroutine(NetworkHandler.PingRegions()); + //StartCoroutine(NetworkHandler.PingRegions()); // Photon stuff. if (GlobalController.Instance.firstConnection) { diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index e94a506ead..eb67d04276 100644 --- a/ProjectSettings/ProjectSettings.asset +++ b/ProjectSettings/ProjectSettings.asset @@ -134,8 +134,7 @@ PlayerSettings: vulkanEnableCommandBufferRecycling: 1 loadStoreDebugModeEnabled: 0 bundleVersion: 1.8.0.0 - preloadedAssets: - - {fileID: 11400000, guid: 49335f30d253220488d2d332ade6e901, type: 2} + preloadedAssets: [] metroInputSource: 0 wsaTransparentSwapchain: 0 m_HolographicPauseOnTrackingLoss: 1