-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Last minute additions #2217
base: master
Are you sure you want to change the base?
Last minute additions #2217
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,10 +2,13 @@ | |
using System.Collections.Generic; | ||
using NitroxClient.Communication.Abstract; | ||
using NitroxClient.Map; | ||
using NitroxClient.Unity.Helper; | ||
using NitroxModel.Core; | ||
using NitroxModel.DataStructures.GameLogic; | ||
using NitroxModel.Packets; | ||
using NitroxModel_Subnautica.DataStructures; | ||
using UnityEngine; | ||
using UWE; | ||
using WorldStreaming; | ||
|
||
namespace NitroxClient.GameLogic; | ||
|
@@ -77,11 +80,23 @@ public void UpdateVisibility() | |
|
||
} | ||
|
||
public static void WaitForEntities() | ||
{ | ||
// In case the player is spawned in the air, we need to hold them up while all the entities load around them | ||
if (Player.main && !Player.main.IsUnderwater() && !Player.main.groundMotor.grounded) | ||
{ | ||
Player.main.cinematicModeActive = true; | ||
CoroutineHost.StartCoroutine(WaitForWorldLoad(Yielders.WaitFor2Seconds)); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Forces world streamer's to load the terrain around the MainCamera and waits until it's done to unfreeze the player. | ||
/// </summary> | ||
public static IEnumerator WaitForWorldLoad() | ||
public static IEnumerator WaitForWorldLoad(WaitForSeconds initialWait = null) | ||
{ | ||
Entities entities = NitroxServiceLocator.LocateService<Entities>(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should be using dependency injection, this will generate a warning from our analyzers There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It won't work in this static context There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Terrain is already being required inside Mutiplayer mb, so static can be removed |
||
|
||
// In WorldStreamer.CreateStreamers() three coroutines are created to constantly call UpdateCenter() on the streamers | ||
// We force these updates so that the world streamer gets busy instantly | ||
WorldStreamer streamerV2 = LargeWorldStreamer.main.streamerV2; | ||
|
@@ -90,7 +105,9 @@ public static IEnumerator WaitForWorldLoad() | |
streamerV2.lowDetailOctreesStreamer.UpdateCenter(streamerV2.streamingCenter); | ||
streamerV2.clipmapStreamer.UpdateCenter(streamerV2.streamingCenter); | ||
|
||
yield return new WaitUntil(() => LargeWorldStreamer.main.IsWorldSettled()); | ||
yield return initialWait; | ||
|
||
yield return new WaitUntil(() => LargeWorldStreamer.main.IsWorldSettled() && entities.EntitiesToSpawn.Count == 0); | ||
Player.main.cinematicModeActive = false; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note to fix: this should not trigger when inside a subroot/escape pod