| | 1 | | using DCL.Controllers; |
| | 2 | | using DCL.Helpers; |
| | 3 | | using DCL.Interface; |
| | 4 | | using DCL.Models; |
| | 5 | | using DCL.Configuration; |
| | 6 | | using System; |
| | 7 | | using System.Collections; |
| | 8 | | using System.Collections.Concurrent; |
| | 9 | | using System.ComponentModel; |
| | 10 | | using System.Linq; |
| | 11 | | using System.Threading; |
| | 12 | | using Cysharp.Threading.Tasks; |
| | 13 | | using DCL.Components; |
| | 14 | | using UnityEngine; |
| | 15 | | using Debug = UnityEngine.Debug; |
| | 16 | |
|
| | 17 | | namespace DCL |
| | 18 | | { |
| | 19 | | public class SceneController : ISceneController |
| | 20 | | { |
| | 21 | | public static bool VERBOSE = false; |
| | 22 | | const int SCENE_MESSAGES_PREWARM_COUNT = 100000; |
| | 23 | |
|
| 675 | 24 | | public bool enabled { get; set; } = true; |
| 0 | 25 | | internal BaseVariable<Transform> isPortableExperiencesInitialized => DataStore.i.experiencesViewer.isInitialized |
| | 26 | |
|
| | 27 | | //TODO(Brian): Move to WorldRuntimePlugin later |
| | 28 | | private LoadingFeedbackController loadingFeedbackController; |
| | 29 | | private Coroutine deferredDecodingCoroutine; |
| | 30 | |
|
| | 31 | | private CancellationTokenSource tokenSource; |
| 848 | 32 | | private IMessagingControllersManager messagingControllersManager => Environment.i.messaging.manager; |
| | 33 | |
|
| | 34 | | public void Initialize() |
| | 35 | | { |
| 652 | 36 | | tokenSource = new CancellationTokenSource(); |
| 652 | 37 | | sceneSortDirty = true; |
| 652 | 38 | | positionDirty = true; |
| 652 | 39 | | lastSortFrame = 0; |
| 652 | 40 | | enabled = true; |
| | 41 | |
|
| 652 | 42 | | loadingFeedbackController = new LoadingFeedbackController(); |
| | 43 | |
|
| 652 | 44 | | DataStore.i.debugConfig.isDebugMode.OnChange += OnDebugModeSet; |
| | 45 | |
|
| 652 | 46 | | SetupDeferredRunners(); |
| | 47 | |
|
| 652 | 48 | | DCLCharacterController.OnCharacterMoved += SetPositionDirty; |
| | 49 | |
|
| 652 | 50 | | CommonScriptableObjects.sceneID.OnChange += OnCurrentSceneIdChange; |
| | 51 | |
|
| | 52 | | // TODO(Brian): Move this later to Main.cs |
| 652 | 53 | | if ( !EnvironmentSettings.RUNNING_TESTS ) |
| | 54 | | { |
| 0 | 55 | | PrewarmSceneMessagesPool(); |
| | 56 | | } |
| | 57 | |
|
| 652 | 58 | | Environment.i.platform.updateEventHandler.AddListener(IUpdateEventHandler.EventType.Update, Update); |
| 652 | 59 | | Environment.i.platform.updateEventHandler.AddListener(IUpdateEventHandler.EventType.LateUpdate, LateUpdate); |
| 652 | 60 | | } |
| | 61 | | private void SetupDeferredRunners() |
| | 62 | | { |
| | 63 | | #if UNITY_WEBGL |
| | 64 | | deferredDecodingCoroutine = CoroutineStarter.Start(DeferredDecodingAndEnqueue()); |
| | 65 | | #else |
| 652 | 66 | | CancellationToken tokenSourceToken = tokenSource.Token; |
| 2608 | 67 | | TaskUtils.Run(async () => await WatchForNewChunksToDecode(tokenSourceToken), cancellationToken: tokenSourceT |
| | 68 | | #endif |
| 652 | 69 | | } |
| | 70 | |
|
| | 71 | | private void PrewarmSceneMessagesPool() |
| | 72 | | { |
| 0 | 73 | | if (prewarmSceneMessagesPool) |
| | 74 | | { |
| 0 | 75 | | for (int i = 0; i < SCENE_MESSAGES_PREWARM_COUNT; i++) |
| | 76 | | { |
| 0 | 77 | | sceneMessagesPool.Enqueue(new QueuedSceneMessage_Scene()); |
| | 78 | | } |
| | 79 | | } |
| | 80 | |
|
| 0 | 81 | | if (prewarmEntitiesPool) |
| | 82 | | { |
| 0 | 83 | | PoolManagerFactory.EnsureEntityPool(prewarmEntitiesPool); |
| | 84 | | } |
| 0 | 85 | | } |
| | 86 | |
|
| | 87 | | private void OnDebugModeSet(bool current, bool previous) |
| | 88 | | { |
| 9 | 89 | | if (current == previous) |
| 0 | 90 | | return; |
| | 91 | |
|
| 9 | 92 | | if (current) |
| | 93 | | { |
| 9 | 94 | | Environment.i.world.sceneBoundsChecker.SetFeedbackStyle(new SceneBoundsFeedbackStyle_RedBox()); |
| 9 | 95 | | } |
| | 96 | | else |
| | 97 | | { |
| 0 | 98 | | Environment.i.world.sceneBoundsChecker.SetFeedbackStyle(new SceneBoundsFeedbackStyle_Simple()); |
| | 99 | | } |
| 0 | 100 | | } |
| | 101 | |
|
| | 102 | | public void Dispose() |
| | 103 | | { |
| 652 | 104 | | tokenSource.Cancel(); |
| 652 | 105 | | tokenSource.Dispose(); |
| 652 | 106 | | loadingFeedbackController.Dispose(); |
| | 107 | |
|
| 652 | 108 | | Environment.i.platform.updateEventHandler.RemoveListener(IUpdateEventHandler.EventType.Update, Update); |
| 652 | 109 | | Environment.i.platform.updateEventHandler.RemoveListener(IUpdateEventHandler.EventType.LateUpdate, LateUpdat |
| | 110 | |
|
| 652 | 111 | | PoolManager.i.OnGet -= Environment.i.platform.physicsSyncController.MarkDirty; |
| 652 | 112 | | PoolManager.i.OnGet -= Environment.i.platform.cullingController.objectsTracker.MarkDirty; |
| | 113 | |
|
| 652 | 114 | | DCLCharacterController.OnCharacterMoved -= SetPositionDirty; |
| 652 | 115 | | DataStore.i.debugConfig.isDebugMode.OnChange -= OnDebugModeSet; |
| | 116 | |
|
| 652 | 117 | | CommonScriptableObjects.sceneID.OnChange -= OnCurrentSceneIdChange; |
| | 118 | |
|
| 652 | 119 | | UnloadAllScenes(includePersistent: true); |
| | 120 | |
|
| 652 | 121 | | if (deferredDecodingCoroutine != null) |
| 0 | 122 | | CoroutineStarter.Stop(deferredDecodingCoroutine); |
| 652 | 123 | | } |
| | 124 | |
|
| | 125 | | public void Update() |
| | 126 | | { |
| 6967 | 127 | | if (!enabled) |
| 161 | 128 | | return; |
| | 129 | |
|
| 6806 | 130 | | InputController_Legacy.i.Update(); |
| | 131 | |
|
| 6806 | 132 | | if (lastSortFrame != Time.frameCount && sceneSortDirty) |
| | 133 | | { |
| 648 | 134 | | lastSortFrame = Time.frameCount; |
| 648 | 135 | | sceneSortDirty = false; |
| 648 | 136 | | SortScenesByDistance(); |
| | 137 | | } |
| 6806 | 138 | | } |
| | 139 | |
|
| | 140 | | public void LateUpdate() |
| | 141 | | { |
| 6967 | 142 | | if (!enabled) |
| 161 | 143 | | return; |
| | 144 | |
|
| 6806 | 145 | | Environment.i.platform.physicsSyncController.Sync(); |
| 6806 | 146 | | } |
| | 147 | |
|
| | 148 | | //====================================================================== |
| | 149 | |
|
| | 150 | | #region MESSAGES_HANDLING |
| | 151 | |
|
| | 152 | | //====================================================================== |
| | 153 | |
|
| | 154 | | #if UNITY_EDITOR |
| | 155 | | public delegate void ProcessDelegate(string sceneId, string method); |
| | 156 | |
|
| | 157 | | public event ProcessDelegate OnMessageProcessInfoStart; |
| | 158 | | public event ProcessDelegate OnMessageProcessInfoEnds; |
| | 159 | | #endif |
| 0 | 160 | | public bool deferredMessagesDecoding { get; set; } = false; |
| | 161 | |
|
| 652 | 162 | | readonly ConcurrentQueue<string> chunksToDecode = new ConcurrentQueue<string>(); |
| 652 | 163 | | private readonly ConcurrentQueue<QueuedSceneMessage_Scene> messagesToProcess = new ConcurrentQueue<QueuedSceneMe |
| | 164 | |
|
| | 165 | | const float MAX_TIME_FOR_DECODE = 0.005f; |
| | 166 | |
|
| | 167 | | public bool ProcessMessage(QueuedSceneMessage_Scene msgObject, out CustomYieldInstruction yieldInstruction) |
| | 168 | | { |
| 0 | 169 | | string sceneId = msgObject.sceneId; |
| 0 | 170 | | string method = msgObject.method; |
| | 171 | |
|
| 0 | 172 | | yieldInstruction = null; |
| | 173 | |
|
| | 174 | | IParcelScene scene; |
| 0 | 175 | | bool res = false; |
| 0 | 176 | | IWorldState worldState = Environment.i.world.state; |
| 0 | 177 | | DebugConfig debugConfig = DataStore.i.debugConfig; |
| | 178 | |
|
| 0 | 179 | | if (worldState.loadedScenes.TryGetValue(sceneId, out scene)) |
| | 180 | | { |
| | 181 | | #if UNITY_EDITOR |
| 0 | 182 | | if (debugConfig.soloScene && scene is GlobalScene && debugConfig.ignoreGlobalScenes) |
| | 183 | | { |
| 0 | 184 | | return false; |
| | 185 | | } |
| | 186 | | #endif |
| 0 | 187 | | if (!scene.GetSceneTransform().gameObject.activeInHierarchy) |
| | 188 | | { |
| 0 | 189 | | return true; |
| | 190 | | } |
| | 191 | |
|
| | 192 | | #if UNITY_EDITOR |
| 0 | 193 | | OnMessageProcessInfoStart?.Invoke(sceneId, method); |
| | 194 | | #endif |
| 0 | 195 | | ProfilingEvents.OnMessageProcessStart?.Invoke(method); |
| | 196 | |
|
| 0 | 197 | | ProcessMessage(scene as ParcelScene, method, msgObject.payload, out yieldInstruction); |
| | 198 | |
|
| 0 | 199 | | ProfilingEvents.OnMessageProcessEnds?.Invoke(method); |
| | 200 | |
|
| | 201 | | #if UNITY_EDITOR |
| 0 | 202 | | OnMessageProcessInfoEnds?.Invoke(sceneId, method); |
| | 203 | | #endif |
| | 204 | |
|
| 0 | 205 | | res = true; |
| 0 | 206 | | } |
| | 207 | |
|
| | 208 | | else |
| | 209 | | { |
| 0 | 210 | | res = false; |
| | 211 | | } |
| | 212 | |
|
| 0 | 213 | | sceneMessagesPool.Enqueue(msgObject); |
| | 214 | |
|
| 0 | 215 | | return res; |
| | 216 | | } |
| | 217 | |
|
| | 218 | | private void ProcessMessage(ParcelScene scene, string method, object msgPayload, |
| | 219 | | out CustomYieldInstruction yieldInstruction) |
| | 220 | | { |
| 0 | 221 | | yieldInstruction = null; |
| 0 | 222 | | IDelayedComponent delayedComponent = null; |
| | 223 | |
|
| | 224 | | try |
| | 225 | | { |
| | 226 | | switch (method) |
| | 227 | | { |
| | 228 | | case MessagingTypes.ENTITY_CREATE: |
| | 229 | | { |
| 0 | 230 | | if (msgPayload is Protocol.CreateEntity payload) |
| 0 | 231 | | scene.CreateEntity(payload.entityId); |
| | 232 | |
|
| 0 | 233 | | break; |
| | 234 | | } |
| | 235 | | case MessagingTypes.ENTITY_REPARENT: |
| | 236 | | { |
| 0 | 237 | | if (msgPayload is Protocol.SetEntityParent payload) |
| 0 | 238 | | scene.SetEntityParent(payload.entityId, payload.parentId); |
| | 239 | |
|
| 0 | 240 | | break; |
| | 241 | | } |
| | 242 | |
|
| | 243 | | case MessagingTypes.ENTITY_COMPONENT_CREATE_OR_UPDATE: |
| | 244 | | { |
| 0 | 245 | | if (msgPayload is Protocol.EntityComponentCreateOrUpdate payload) |
| | 246 | | { |
| 0 | 247 | | delayedComponent = scene.EntityComponentCreateOrUpdate(payload.entityId, |
| | 248 | | (CLASS_ID_COMPONENT) payload.classId, payload.json) as IDelayedComponent; |
| | 249 | | } |
| | 250 | |
|
| 0 | 251 | | break; |
| | 252 | | } |
| | 253 | |
|
| | 254 | | case MessagingTypes.ENTITY_COMPONENT_DESTROY: |
| | 255 | | { |
| 0 | 256 | | if (msgPayload is Protocol.EntityComponentDestroy payload) |
| 0 | 257 | | scene.EntityComponentRemove(payload.entityId, payload.name); |
| | 258 | |
|
| 0 | 259 | | break; |
| | 260 | | } |
| | 261 | |
|
| | 262 | | case MessagingTypes.SHARED_COMPONENT_ATTACH: |
| | 263 | | { |
| 0 | 264 | | if (msgPayload is Protocol.SharedComponentAttach payload) |
| 0 | 265 | | scene.SharedComponentAttach(payload.entityId, payload.id); |
| | 266 | |
|
| 0 | 267 | | break; |
| | 268 | | } |
| | 269 | |
|
| | 270 | | case MessagingTypes.SHARED_COMPONENT_CREATE: |
| | 271 | | { |
| 0 | 272 | | if (msgPayload is Protocol.SharedComponentCreate payload) |
| 0 | 273 | | scene.SharedComponentCreate(payload.id, payload.classId); |
| | 274 | |
|
| 0 | 275 | | break; |
| | 276 | | } |
| | 277 | |
|
| | 278 | | case MessagingTypes.SHARED_COMPONENT_DISPOSE: |
| | 279 | | { |
| 0 | 280 | | if (msgPayload is Protocol.SharedComponentDispose payload) |
| 0 | 281 | | scene.SharedComponentDispose(payload.id); |
| | 282 | |
|
| 0 | 283 | | break; |
| | 284 | | } |
| | 285 | |
|
| | 286 | | case MessagingTypes.SHARED_COMPONENT_UPDATE: |
| | 287 | | { |
| 0 | 288 | | if (msgPayload is Protocol.SharedComponentUpdate payload) |
| 0 | 289 | | delayedComponent = scene.SharedComponentUpdate(payload.componentId, payload.json) as IDe |
| | 290 | |
|
| 0 | 291 | | break; |
| | 292 | | } |
| | 293 | |
|
| | 294 | | case MessagingTypes.ENTITY_DESTROY: |
| | 295 | | { |
| 0 | 296 | | if (msgPayload is Protocol.RemoveEntity payload) |
| 0 | 297 | | scene.RemoveEntity(payload.entityId); |
| | 298 | |
|
| 0 | 299 | | break; |
| | 300 | | } |
| | 301 | |
|
| | 302 | | case MessagingTypes.INIT_DONE: |
| | 303 | | { |
| 0 | 304 | | scene.sceneLifecycleHandler.SetInitMessagesDone(); |
| | 305 | |
|
| 0 | 306 | | break; |
| | 307 | | } |
| | 308 | |
|
| | 309 | | case MessagingTypes.QUERY: |
| | 310 | | { |
| 0 | 311 | | if (msgPayload is QueryMessage queryMessage) |
| 0 | 312 | | ParseQuery(queryMessage.payload, scene.sceneData.id); |
| | 313 | |
|
| 0 | 314 | | break; |
| | 315 | | } |
| | 316 | |
|
| | 317 | | case MessagingTypes.OPEN_EXTERNAL_URL: |
| | 318 | | { |
| 0 | 319 | | if (msgPayload is Protocol.OpenExternalUrl payload) |
| 0 | 320 | | OnOpenExternalUrlRequest?.Invoke(scene, payload.url); |
| | 321 | |
|
| 0 | 322 | | break; |
| | 323 | | } |
| | 324 | |
|
| | 325 | | case MessagingTypes.OPEN_NFT_DIALOG: |
| | 326 | | { |
| 0 | 327 | | if (msgPayload is Protocol.OpenNftDialog payload) |
| 0 | 328 | | DataStore.i.common.onOpenNFTPrompt.Set(new NFTPromptModel(payload.contactAddress, payloa |
| | 329 | | payload.comment), true); |
| | 330 | |
|
| 0 | 331 | | break; |
| | 332 | | } |
| | 333 | |
|
| | 334 | | default: |
| 0 | 335 | | Debug.LogError($"Unknown method {method}"); |
| | 336 | |
|
| | 337 | | break; |
| | 338 | | } |
| 0 | 339 | | } |
| 0 | 340 | | catch (Exception e) |
| | 341 | | { |
| 0 | 342 | | throw new Exception( |
| | 343 | | $"Scene message error. scene: {scene.sceneData.id} method: {method} payload: {JsonUtility.ToJson(msg |
| | 344 | | } |
| | 345 | |
|
| 0 | 346 | | if (delayedComponent != null) |
| | 347 | | { |
| 0 | 348 | | if (delayedComponent.isRoutineRunning) |
| 0 | 349 | | yieldInstruction = delayedComponent.yieldInstruction; |
| | 350 | | } |
| 0 | 351 | | } |
| | 352 | |
|
| | 353 | | public void ParseQuery(object payload, string sceneId) |
| | 354 | | { |
| 0 | 355 | | IParcelScene scene = Environment.i.world.state.loadedScenes[sceneId]; |
| | 356 | |
|
| 0 | 357 | | if (!(payload is RaycastQuery raycastQuery)) |
| 0 | 358 | | return; |
| | 359 | |
|
| 0 | 360 | | Vector3 worldOrigin = raycastQuery.ray.origin + Utils.GridToWorldPosition(scene.sceneData.basePosition.x, sc |
| | 361 | |
|
| 0 | 362 | | raycastQuery.ray.unityOrigin = PositionUtils.WorldToUnityPosition(worldOrigin); |
| 0 | 363 | | raycastQuery.sceneId = sceneId; |
| 0 | 364 | | PhysicsCast.i.Query(raycastQuery); |
| 0 | 365 | | } |
| | 366 | |
|
| | 367 | | public void SendSceneMessage(string chunk) |
| | 368 | | { |
| 0 | 369 | | var renderer = CommonScriptableObjects.rendererState.Get(); |
| | 370 | |
|
| 0 | 371 | | if (!renderer) |
| | 372 | | { |
| 0 | 373 | | EnqueueChunk(chunk); |
| 0 | 374 | | } |
| | 375 | | else |
| | 376 | | { |
| 0 | 377 | | chunksToDecode.Enqueue(chunk); |
| | 378 | | } |
| 0 | 379 | | } |
| | 380 | |
|
| | 381 | | private QueuedSceneMessage_Scene Decode(string payload, QueuedSceneMessage_Scene queuedMessage) |
| | 382 | | { |
| 0 | 383 | | ProfilingEvents.OnMessageDecodeStart?.Invoke("Misc"); |
| | 384 | |
|
| 0 | 385 | | if (!MessageDecoder.DecodePayloadChunk(payload, |
| | 386 | | out string sceneId, |
| | 387 | | out string message, |
| | 388 | | out string messageTag, |
| | 389 | | out PB_SendSceneMessage sendSceneMessage)) |
| | 390 | | { |
| 0 | 391 | | return null; |
| | 392 | | } |
| | 393 | |
|
| 0 | 394 | | MessageDecoder.DecodeSceneMessage(sceneId, message, messageTag, sendSceneMessage, ref queuedMessage); |
| | 395 | |
|
| 0 | 396 | | ProfilingEvents.OnMessageDecodeEnds?.Invoke("Misc"); |
| | 397 | |
|
| 0 | 398 | | return queuedMessage; |
| | 399 | | } |
| | 400 | |
|
| | 401 | | private IEnumerator DeferredDecodingAndEnqueue() |
| | 402 | | { |
| 0 | 403 | | float start = Time.realtimeSinceStartup; |
| | 404 | | float maxTimeForDecode; |
| | 405 | |
|
| 0 | 406 | | while (true) |
| | 407 | | { |
| 0 | 408 | | maxTimeForDecode = CommonScriptableObjects.rendererState.Get() ? MAX_TIME_FOR_DECODE : float.MaxValue; |
| | 409 | |
|
| 0 | 410 | | if (chunksToDecode.Count > 0) |
| | 411 | | { |
| 0 | 412 | | if (chunksToDecode.TryDequeue(out string chunk)) |
| | 413 | | { |
| 0 | 414 | | EnqueueChunk(chunk); |
| | 415 | |
|
| 0 | 416 | | if (Time.realtimeSinceStartup - start < maxTimeForDecode) |
| | 417 | | continue; |
| | 418 | | } |
| | 419 | | } |
| | 420 | |
|
| 0 | 421 | | yield return null; |
| | 422 | |
|
| 0 | 423 | | start = Time.unscaledTime; |
| | 424 | | } |
| | 425 | | } |
| | 426 | | private void EnqueueChunk(string chunk) |
| | 427 | | { |
| 0 | 428 | | string[] payloads = chunk.Split(new [] { '\n' }, StringSplitOptions.RemoveEmptyEntries); |
| 0 | 429 | | var count = payloads.Length; |
| | 430 | |
|
| 0 | 431 | | for (int i = 0; i < count; i++) |
| | 432 | | { |
| 0 | 433 | | bool availableMessage = sceneMessagesPool.TryDequeue(out QueuedSceneMessage_Scene freeMessage); |
| | 434 | |
|
| 0 | 435 | | if (availableMessage) |
| | 436 | | { |
| 0 | 437 | | EnqueueSceneMessage(Decode(payloads[i], freeMessage)); |
| 0 | 438 | | } |
| | 439 | | else |
| | 440 | | { |
| 0 | 441 | | EnqueueSceneMessage(Decode(payloads[i], new QueuedSceneMessage_Scene())); |
| | 442 | | } |
| | 443 | | } |
| 0 | 444 | | } |
| | 445 | | private async UniTask WatchForNewChunksToDecode(CancellationToken cancellationToken) |
| | 446 | | { |
| 8472 | 447 | | while (!cancellationToken.IsCancellationRequested) |
| | 448 | | { |
| | 449 | | try |
| | 450 | | { |
| 7820 | 451 | | if (chunksToDecode.Count > 0) |
| | 452 | | { |
| 0 | 453 | | ThreadedDecodeAndEnqueue(cancellationToken); |
| | 454 | | } |
| 7820 | 455 | | } |
| | 456 | | catch (Exception e) |
| | 457 | | { |
| 0 | 458 | | Debug.LogException(e); |
| 0 | 459 | | } |
| | 460 | |
|
| 23460 | 461 | | await UniTask.Yield(); |
| | 462 | | } |
| 652 | 463 | | } |
| | 464 | | private void ThreadedDecodeAndEnqueue(CancellationToken cancellationToken) |
| | 465 | | { |
| 0 | 466 | | while (chunksToDecode.TryDequeue(out string chunk)) |
| | 467 | | { |
| 0 | 468 | | cancellationToken.ThrowIfCancellationRequested(); |
| | 469 | |
|
| 0 | 470 | | string[] payloads = chunk.Split(new [] { '\n' }, StringSplitOptions.RemoveEmptyEntries); |
| 0 | 471 | | var count = payloads.Length; |
| | 472 | |
|
| 0 | 473 | | for (int i = 0; i < count; i++) |
| | 474 | | { |
| 0 | 475 | | var payload = payloads[i]; |
| 0 | 476 | | bool availableMessage = sceneMessagesPool.TryDequeue(out QueuedSceneMessage_Scene freeMessage); |
| | 477 | |
|
| 0 | 478 | | if (availableMessage) |
| | 479 | | { |
| 0 | 480 | | EnqueueSceneMessage(Decode(payload, freeMessage)); |
| 0 | 481 | | } |
| | 482 | | else |
| | 483 | | { |
| 0 | 484 | | EnqueueSceneMessage(Decode(payload, new QueuedSceneMessage_Scene())); |
| | 485 | | } |
| | 486 | | } |
| 0 | 487 | | } |
| 0 | 488 | | } |
| | 489 | |
|
| | 490 | | public void EnqueueSceneMessage(QueuedSceneMessage_Scene message) |
| | 491 | | { |
| 0 | 492 | | bool isGlobalScene = WorldStateUtils.IsGlobalScene(message.sceneId); |
| 0 | 493 | | messagingControllersManager.AddControllerIfNotExists(this, message.sceneId); |
| 0 | 494 | | messagingControllersManager.Enqueue(isGlobalScene, message); |
| 0 | 495 | | } |
| | 496 | |
|
| | 497 | | //====================================================================== |
| | 498 | |
|
| | 499 | | #endregion |
| | 500 | |
|
| | 501 | | //====================================================================== |
| | 502 | |
|
| | 503 | | //====================================================================== |
| | 504 | |
|
| | 505 | | #region SCENES_MANAGEMENT |
| | 506 | |
|
| | 507 | | //====================================================================== |
| | 508 | | public event Action<string> OnReadyScene; |
| | 509 | |
|
| | 510 | | public IParcelScene CreateTestScene(LoadParcelScenesMessage.UnityParcelScene data = null) |
| | 511 | | { |
| 0 | 512 | | IParcelScene result = WorldStateUtils.CreateTestScene(data); |
| 0 | 513 | | messagingControllersManager.AddControllerIfNotExists(this, data.id); |
| 0 | 514 | | OnNewSceneAdded?.Invoke(result); |
| | 515 | |
|
| 0 | 516 | | return result; |
| | 517 | | } |
| | 518 | |
|
| | 519 | | public void SendSceneReady(string sceneId) |
| | 520 | | { |
| 389 | 521 | | Environment.i.world.state.readyScenes.Add(sceneId); |
| | 522 | |
|
| 389 | 523 | | messagingControllersManager.SetSceneReady(sceneId); |
| | 524 | |
|
| 389 | 525 | | WebInterface.ReportControlEvent(new WebInterface.SceneReady(sceneId)); |
| 389 | 526 | | WebInterface.ReportCameraChanged(CommonScriptableObjects.cameraMode.Get(), sceneId); |
| | 527 | |
|
| 389 | 528 | | Environment.i.world.blockersController.SetupWorldBlockers(); |
| | 529 | |
|
| 389 | 530 | | OnReadyScene?.Invoke(sceneId); |
| 2 | 531 | | } |
| | 532 | |
|
| 10 | 533 | | public void ActivateBuilderInWorldEditScene() { Environment.i.world.sceneBoundsChecker.SetFeedbackStyle(new Scen |
| | 534 | |
|
| 2 | 535 | | public void DeactivateBuilderInWorldEditScene() { Environment.i.world.sceneBoundsChecker.SetFeedbackStyle(new Sc |
| | 536 | |
|
| | 537 | | private void SetPositionDirty(DCLCharacterPosition character) |
| | 538 | | { |
| 5004 | 539 | | var currentX = (int) Math.Floor(character.worldPosition.x / ParcelSettings.PARCEL_SIZE); |
| 5004 | 540 | | var currentY = (int) Math.Floor(character.worldPosition.z / ParcelSettings.PARCEL_SIZE); |
| | 541 | |
|
| 5004 | 542 | | positionDirty = currentX != currentGridSceneCoordinate.x || currentY != currentGridSceneCoordinate.y; |
| | 543 | |
|
| 5004 | 544 | | if (positionDirty) |
| | 545 | | { |
| 578 | 546 | | sceneSortDirty = true; |
| 578 | 547 | | currentGridSceneCoordinate.x = currentX; |
| 578 | 548 | | currentGridSceneCoordinate.y = currentY; |
| | 549 | |
|
| | 550 | | // Since the first position for the character is not sent from Kernel until just-before calling |
| | 551 | | // the rendering activation from Kernel, we need to sort the scenes to get the current scene id |
| | 552 | | // to lock the rendering accordingly... |
| 578 | 553 | | if (!CommonScriptableObjects.rendererState.Get()) |
| | 554 | | { |
| 0 | 555 | | SortScenesByDistance(); |
| | 556 | | } |
| | 557 | | } |
| 5004 | 558 | | } |
| | 559 | |
|
| | 560 | | public void SortScenesByDistance() |
| | 561 | | { |
| 648 | 562 | | if (DCLCharacterController.i == null) |
| 63 | 563 | | return; |
| | 564 | |
|
| 585 | 565 | | IWorldState worldState = Environment.i.world.state; |
| | 566 | |
|
| 585 | 567 | | worldState.currentSceneId = null; |
| 585 | 568 | | worldState.scenesSortedByDistance.Sort(SortScenesByDistanceMethod); |
| | 569 | |
|
| 585 | 570 | | using (var iterator = Environment.i.world.state.scenesSortedByDistance.GetEnumerator()) |
| | 571 | | { |
| | 572 | | IParcelScene scene; |
| | 573 | | bool characterIsInsideScene; |
| | 574 | |
|
| 603 | 575 | | while (iterator.MoveNext()) |
| | 576 | | { |
| 23 | 577 | | scene = iterator.Current; |
| | 578 | |
|
| 23 | 579 | | if (scene == null) |
| | 580 | | continue; |
| | 581 | |
|
| 23 | 582 | | characterIsInsideScene = WorldStateUtils.IsCharacterInsideScene(scene); |
| | 583 | |
|
| 23 | 584 | | if (!worldState.globalSceneIds.Contains(scene.sceneData.id) && characterIsInsideScene) |
| | 585 | | { |
| 5 | 586 | | worldState.currentSceneId = scene.sceneData.id; |
| | 587 | |
|
| 5 | 588 | | break; |
| | 589 | | } |
| | 590 | | } |
| 580 | 591 | | } |
| | 592 | |
|
| 585 | 593 | | if (!DataStore.i.debugConfig.isDebugMode.Get() && string.IsNullOrEmpty(worldState.currentSceneId)) |
| | 594 | | { |
| | 595 | | // When we don't know the current scene yet, we must lock the rendering from enabling until it is set |
| 577 | 596 | | CommonScriptableObjects.rendererState.AddLock(this); |
| 577 | 597 | | } |
| | 598 | | else |
| | 599 | | { |
| | 600 | | // 1. Set current scene id |
| 8 | 601 | | CommonScriptableObjects.sceneID.Set(worldState.currentSceneId); |
| | 602 | |
|
| | 603 | | // 2. Attempt to remove SceneController's lock on rendering |
| 8 | 604 | | CommonScriptableObjects.rendererState.RemoveLock(this); |
| | 605 | | } |
| | 606 | |
|
| 585 | 607 | | OnSortScenes?.Invoke(); |
| 585 | 608 | | } |
| | 609 | |
|
| | 610 | | private int SortScenesByDistanceMethod(IParcelScene sceneA, IParcelScene sceneB) |
| | 611 | | { |
| 21 | 612 | | sortAuxiliaryVector = sceneA.sceneData.basePosition - currentGridSceneCoordinate; |
| 21 | 613 | | int dist1 = sortAuxiliaryVector.sqrMagnitude; |
| | 614 | |
|
| 21 | 615 | | sortAuxiliaryVector = sceneB.sceneData.basePosition - currentGridSceneCoordinate; |
| 21 | 616 | | int dist2 = sortAuxiliaryVector.sqrMagnitude; |
| | 617 | |
|
| 21 | 618 | | return dist1 - dist2; |
| | 619 | | } |
| | 620 | |
|
| | 621 | | private void OnCurrentSceneIdChange(string newSceneId, string prevSceneId) |
| | 622 | | { |
| 15 | 623 | | if (Environment.i.world.state.TryGetScene(newSceneId, out IParcelScene newCurrentScene) |
| | 624 | | && !(newCurrentScene as ParcelScene).sceneLifecycleHandler.isReady) |
| | 625 | | { |
| 0 | 626 | | CommonScriptableObjects.rendererState.AddLock(newCurrentScene); |
| | 627 | |
|
| 0 | 628 | | (newCurrentScene as ParcelScene).sceneLifecycleHandler.OnSceneReady += (readyScene) => { CommonScriptabl |
| | 629 | | } |
| 15 | 630 | | } |
| | 631 | |
|
| | 632 | | public void LoadParcelScenesExecute(string scenePayload) |
| | 633 | | { |
| | 634 | | LoadParcelScenesMessage.UnityParcelScene scene; |
| | 635 | |
|
| 26 | 636 | | ProfilingEvents.OnMessageDecodeStart?.Invoke(MessagingTypes.SCENE_LOAD); |
| 26 | 637 | | scene = Utils.SafeFromJson<LoadParcelScenesMessage.UnityParcelScene>(scenePayload); |
| 26 | 638 | | ProfilingEvents.OnMessageDecodeEnds?.Invoke(MessagingTypes.SCENE_LOAD); |
| | 639 | |
|
| 26 | 640 | | if (scene == null || scene.id == null) |
| 0 | 641 | | return; |
| | 642 | |
|
| 26 | 643 | | var sceneToLoad = scene; |
| | 644 | |
|
| 26 | 645 | | DebugConfig debugConfig = DataStore.i.debugConfig; |
| | 646 | | #if UNITY_EDITOR |
| 26 | 647 | | if (debugConfig.soloScene && sceneToLoad.basePosition.ToString() != debugConfig.soloSceneCoords.ToString()) |
| | 648 | | { |
| 0 | 649 | | SendSceneReady(sceneToLoad.id); |
| | 650 | |
|
| 0 | 651 | | return; |
| | 652 | | } |
| | 653 | | #endif |
| | 654 | |
|
| 26 | 655 | | ProfilingEvents.OnMessageProcessStart?.Invoke(MessagingTypes.SCENE_LOAD); |
| | 656 | |
|
| 26 | 657 | | IWorldState worldState = Environment.i.world.state; |
| | 658 | |
|
| 26 | 659 | | if (!worldState.loadedScenes.ContainsKey(sceneToLoad.id)) |
| | 660 | | { |
| 26 | 661 | | var newGameObject = new GameObject("New Scene"); |
| | 662 | |
|
| 26 | 663 | | var newScene = newGameObject.AddComponent<ParcelScene>(); |
| 26 | 664 | | newScene.SetData(sceneToLoad); |
| | 665 | |
|
| 26 | 666 | | if (debugConfig.isDebugMode.Get()) |
| | 667 | | { |
| 26 | 668 | | newScene.InitializeDebugPlane(); |
| | 669 | | } |
| | 670 | |
|
| 26 | 671 | | worldState.loadedScenes.Add(sceneToLoad.id, newScene); |
| 26 | 672 | | worldState.scenesSortedByDistance.Add(newScene); |
| | 673 | |
|
| 26 | 674 | | sceneSortDirty = true; |
| | 675 | |
|
| 26 | 676 | | OnNewSceneAdded?.Invoke(newScene); |
| | 677 | |
|
| 26 | 678 | | messagingControllersManager.AddControllerIfNotExists(this, newScene.sceneData.id); |
| | 679 | |
|
| 26 | 680 | | if (VERBOSE) |
| 0 | 681 | | Debug.Log($"{Time.frameCount} : Load parcel scene {newScene.sceneData.basePosition}"); |
| | 682 | | } |
| | 683 | |
|
| 26 | 684 | | ProfilingEvents.OnMessageProcessEnds?.Invoke(MessagingTypes.SCENE_LOAD); |
| 0 | 685 | | } |
| | 686 | |
|
| | 687 | | public void UpdateParcelScenesExecute(string sceneId) |
| | 688 | | { |
| | 689 | | LoadParcelScenesMessage.UnityParcelScene sceneData; |
| | 690 | |
|
| 0 | 691 | | ProfilingEvents.OnMessageDecodeStart?.Invoke(MessagingTypes.SCENE_UPDATE); |
| 0 | 692 | | sceneData = Utils.SafeFromJson<LoadParcelScenesMessage.UnityParcelScene>(sceneId); |
| 0 | 693 | | ProfilingEvents.OnMessageDecodeEnds?.Invoke(MessagingTypes.SCENE_UPDATE); |
| | 694 | |
|
| 0 | 695 | | IWorldState worldState = Environment.i.world.state; |
| | 696 | |
|
| 0 | 697 | | if (worldState.TryGetScene(sceneData.id, out IParcelScene sceneInterface)) |
| | 698 | | { |
| 0 | 699 | | ParcelScene scene = sceneInterface as ParcelScene; |
| 0 | 700 | | scene.SetUpdateData(sceneData); |
| 0 | 701 | | } |
| | 702 | | else |
| | 703 | | { |
| 0 | 704 | | LoadParcelScenesExecute(sceneId); |
| | 705 | | } |
| 0 | 706 | | } |
| | 707 | |
|
| | 708 | | public void UpdateParcelScenesExecute(LoadParcelScenesMessage.UnityParcelScene scene) |
| | 709 | | { |
| 15 | 710 | | if (scene == null || scene.id == null) |
| 0 | 711 | | return; |
| | 712 | |
|
| 15 | 713 | | var sceneToLoad = scene; |
| | 714 | |
|
| 15 | 715 | | ProfilingEvents.OnMessageProcessStart?.Invoke(MessagingTypes.SCENE_UPDATE); |
| | 716 | |
|
| 15 | 717 | | ParcelScene parcelScene = Environment.i.world.state.GetScene(sceneToLoad.id) as ParcelScene; |
| | 718 | |
|
| 15 | 719 | | if (parcelScene != null) |
| 15 | 720 | | parcelScene.SetUpdateData(sceneToLoad); |
| | 721 | |
|
| 15 | 722 | | ProfilingEvents.OnMessageProcessEnds?.Invoke(MessagingTypes.SCENE_UPDATE); |
| 0 | 723 | | } |
| | 724 | |
|
| | 725 | | public void UnloadScene(string sceneKey) |
| | 726 | | { |
| 1 | 727 | | var queuedMessage = new QueuedSceneMessage() |
| | 728 | | { type = QueuedSceneMessage.Type.UNLOAD_PARCEL, message = sceneKey }; |
| | 729 | |
|
| 1 | 730 | | ProfilingEvents.OnMessageWillQueue?.Invoke(MessagingTypes.SCENE_DESTROY); |
| | 731 | |
|
| 1 | 732 | | messagingControllersManager.ForceEnqueueToGlobal(MessagingBusType.INIT, queuedMessage); |
| | 733 | |
|
| 1 | 734 | | messagingControllersManager.RemoveController(sceneKey); |
| | 735 | |
|
| 1 | 736 | | IWorldState worldState = Environment.i.world.state; |
| | 737 | |
|
| 1 | 738 | | if (worldState.loadedScenes.ContainsKey(sceneKey)) |
| | 739 | | { |
| 1 | 740 | | ParcelScene sceneToUnload = worldState.GetScene(sceneKey) as ParcelScene; |
| 1 | 741 | | sceneToUnload.isPersistent = false; |
| | 742 | |
|
| 1 | 743 | | if (sceneToUnload is GlobalScene globalScene && globalScene.isPortableExperience) |
| 0 | 744 | | OnNewPortableExperienceSceneRemoved?.Invoke(sceneKey); |
| | 745 | | } |
| 1 | 746 | | } |
| | 747 | |
|
| | 748 | | public void UnloadParcelSceneExecute(string sceneId) |
| | 749 | | { |
| 413 | 750 | | ProfilingEvents.OnMessageProcessStart?.Invoke(MessagingTypes.SCENE_DESTROY); |
| | 751 | |
|
| 413 | 752 | | IWorldState worldState = Environment.i.world.state; |
| | 753 | |
|
| 413 | 754 | | if (!worldState.Contains(sceneId) || worldState.loadedScenes[sceneId].isPersistent) |
| | 755 | | { |
| 0 | 756 | | return; |
| | 757 | | } |
| | 758 | |
|
| 413 | 759 | | var scene = worldState.loadedScenes[sceneId] as ParcelScene; |
| | 760 | |
|
| 413 | 761 | | if (scene == null) |
| 9 | 762 | | return; |
| | 763 | |
|
| 404 | 764 | | worldState.loadedScenes.Remove(sceneId); |
| 404 | 765 | | worldState.globalSceneIds.Remove(sceneId); |
| | 766 | |
|
| | 767 | | // Remove the scene id from the msg. priorities list |
| 404 | 768 | | worldState.scenesSortedByDistance.Remove(scene); |
| | 769 | |
|
| | 770 | | // Remove messaging controller for unloaded scene |
| 404 | 771 | | messagingControllersManager.RemoveController(scene.sceneData.id); |
| | 772 | |
|
| 404 | 773 | | scene.Cleanup(!CommonScriptableObjects.rendererState.Get()); |
| | 774 | |
|
| 404 | 775 | | if (VERBOSE) |
| | 776 | | { |
| 0 | 777 | | Debug.Log($"{Time.frameCount} : Destroying scene {scene.sceneData.basePosition}"); |
| | 778 | | } |
| | 779 | |
|
| 404 | 780 | | Environment.i.world.blockersController.SetupWorldBlockers(); |
| | 781 | |
|
| 404 | 782 | | ProfilingEvents.OnMessageProcessEnds?.Invoke(MessagingTypes.SCENE_DESTROY); |
| 0 | 783 | | } |
| | 784 | |
|
| | 785 | | public void UnloadAllScenes(bool includePersistent = false) |
| | 786 | | { |
| 654 | 787 | | var worldState = Environment.i.world.state; |
| | 788 | |
|
| 654 | 789 | | if (includePersistent) |
| | 790 | | { |
| 1066 | 791 | | var persistentScenes = worldState.loadedScenes.Where(x => x.Value.isPersistent); |
| | 792 | |
|
| 2082 | 793 | | foreach (var kvp in persistentScenes) |
| | 794 | | { |
| 387 | 795 | | if (kvp.Value is ParcelScene scene) |
| | 796 | | { |
| 387 | 797 | | scene.isPersistent = false; |
| | 798 | | } |
| | 799 | | } |
| | 800 | | } |
| | 801 | |
|
| 654 | 802 | | var list = worldState.loadedScenes.ToArray(); |
| | 803 | |
|
| 2132 | 804 | | for (int i = 0; i < list.Length; i++) |
| | 805 | | { |
| 412 | 806 | | UnloadParcelSceneExecute(list[i].Key); |
| | 807 | | } |
| 654 | 808 | | } |
| | 809 | |
|
| | 810 | | public void LoadParcelScenes(string decentralandSceneJSON) |
| | 811 | | { |
| 26 | 812 | | var queuedMessage = new QueuedSceneMessage() |
| | 813 | | { |
| | 814 | | type = QueuedSceneMessage.Type.LOAD_PARCEL, |
| | 815 | | message = decentralandSceneJSON |
| | 816 | | }; |
| | 817 | |
|
| 26 | 818 | | ProfilingEvents.OnMessageWillQueue?.Invoke(MessagingTypes.SCENE_LOAD); |
| | 819 | |
|
| 26 | 820 | | messagingControllersManager.ForceEnqueueToGlobal(MessagingBusType.INIT, queuedMessage); |
| | 821 | |
|
| 26 | 822 | | if (VERBOSE) |
| 0 | 823 | | Debug.Log($"{Time.frameCount} : Load parcel scene queue {decentralandSceneJSON}"); |
| 26 | 824 | | } |
| | 825 | |
|
| | 826 | | public void UpdateParcelScenes(string decentralandSceneJSON) |
| | 827 | | { |
| 0 | 828 | | var queuedMessage = new QueuedSceneMessage() |
| | 829 | | { type = QueuedSceneMessage.Type.UPDATE_PARCEL, message = decentralandSceneJSON }; |
| | 830 | |
|
| 0 | 831 | | ProfilingEvents.OnMessageWillQueue?.Invoke(MessagingTypes.SCENE_UPDATE); |
| | 832 | |
|
| 0 | 833 | | messagingControllersManager.ForceEnqueueToGlobal(MessagingBusType.INIT, queuedMessage); |
| 0 | 834 | | } |
| | 835 | |
|
| | 836 | | public void UnloadAllScenesQueued() |
| | 837 | | { |
| 0 | 838 | | var queuedMessage = new QueuedSceneMessage() { type = QueuedSceneMessage.Type.UNLOAD_SCENES }; |
| | 839 | |
|
| 0 | 840 | | ProfilingEvents.OnMessageWillQueue?.Invoke(MessagingTypes.SCENE_DESTROY); |
| | 841 | |
|
| 0 | 842 | | Environment.i.messaging.manager.ForceEnqueueToGlobal(MessagingBusType.INIT, queuedMessage); |
| 0 | 843 | | } |
| | 844 | |
|
| | 845 | | public void CreateGlobalScene(string json) |
| | 846 | | { |
| | 847 | | #if UNITY_EDITOR |
| 1 | 848 | | DebugConfig debugConfig = DataStore.i.debugConfig; |
| | 849 | |
|
| 1 | 850 | | if (debugConfig.soloScene && debugConfig.ignoreGlobalScenes) |
| 0 | 851 | | return; |
| | 852 | | #endif |
| 1 | 853 | | CreateGlobalSceneMessage globalScene = Utils.SafeFromJson<CreateGlobalSceneMessage>(json); |
| | 854 | |
|
| 1 | 855 | | if (globalScene.isPortableExperience && !isPortableExperiencesInitialized.Get()) |
| 0 | 856 | | return; |
| | 857 | |
|
| 1 | 858 | | string newGlobalSceneId = globalScene.id; |
| | 859 | |
|
| 1 | 860 | | IWorldState worldState = Environment.i.world.state; |
| | 861 | |
|
| 1 | 862 | | if (worldState.loadedScenes.ContainsKey(newGlobalSceneId)) |
| 0 | 863 | | return; |
| | 864 | |
|
| 1 | 865 | | var newGameObject = new GameObject("Global Scene - " + newGlobalSceneId); |
| | 866 | |
|
| 1 | 867 | | var newScene = newGameObject.AddComponent<GlobalScene>(); |
| 1 | 868 | | newScene.unloadWithDistance = false; |
| 1 | 869 | | newScene.isPersistent = true; |
| 1 | 870 | | newScene.sceneName = globalScene.name; |
| 1 | 871 | | newScene.isPortableExperience = globalScene.isPortableExperience; |
| | 872 | |
|
| 1 | 873 | | LoadParcelScenesMessage.UnityParcelScene data = new LoadParcelScenesMessage.UnityParcelScene |
| | 874 | | { |
| | 875 | | id = newGlobalSceneId, |
| | 876 | | basePosition = new Vector2Int(0, 0), |
| | 877 | | baseUrl = globalScene.baseUrl, |
| | 878 | | contents = globalScene.contents |
| | 879 | | }; |
| | 880 | |
|
| 1 | 881 | | newScene.SetData(data); |
| | 882 | |
|
| 1 | 883 | | if (!string.IsNullOrEmpty(globalScene.icon)) |
| | 884 | | { |
| 0 | 885 | | newScene.iconUrl = newScene.contentProvider.GetContentsUrl(globalScene.icon); |
| | 886 | | } |
| | 887 | |
|
| 1 | 888 | | worldState.loadedScenes.Add(newGlobalSceneId, newScene); |
| 1 | 889 | | OnNewSceneAdded?.Invoke(newScene); |
| | 890 | |
|
| 1 | 891 | | if (newScene.isPortableExperience) |
| 0 | 892 | | OnNewPortableExperienceSceneAdded?.Invoke(newScene); |
| | 893 | |
|
| 1 | 894 | | worldState.globalSceneIds.Add(newGlobalSceneId); |
| | 895 | |
|
| 1 | 896 | | messagingControllersManager.AddControllerIfNotExists(this, newGlobalSceneId, isGlobal: true); |
| | 897 | |
|
| 1 | 898 | | if (VERBOSE) |
| | 899 | | { |
| 0 | 900 | | Debug.Log($"Creating Global scene {newGlobalSceneId}"); |
| | 901 | | } |
| 1 | 902 | | } |
| | 903 | |
|
| | 904 | | public void IsolateScene(IParcelScene sceneToActive) |
| | 905 | | { |
| 152 | 906 | | foreach (IParcelScene scene in Environment.i.world.state.scenesSortedByDistance) |
| | 907 | | { |
| 38 | 908 | | if (scene != sceneToActive) |
| 0 | 909 | | scene.GetSceneTransform().gameObject.SetActive(false); |
| | 910 | | } |
| 38 | 911 | | } |
| | 912 | |
|
| | 913 | | public void ReIntegrateIsolatedScene() |
| | 914 | | { |
| 20 | 915 | | foreach (IParcelScene scene in Environment.i.world.state.scenesSortedByDistance) |
| | 916 | | { |
| 5 | 917 | | scene.GetSceneTransform().gameObject.SetActive(true); |
| | 918 | | } |
| 5 | 919 | | } |
| | 920 | |
|
| | 921 | | //====================================================================== |
| | 922 | |
|
| | 923 | | #endregion |
| | 924 | |
|
| | 925 | | //====================================================================== |
| | 926 | |
|
| 652 | 927 | | public ConcurrentQueue<QueuedSceneMessage_Scene> sceneMessagesPool { get; } = new ConcurrentQueue<QueuedSceneMes |
| | 928 | |
|
| 652 | 929 | | public bool prewarmSceneMessagesPool { get; set; } = true; |
| 652 | 930 | | public bool prewarmEntitiesPool { get; set; } = true; |
| | 931 | |
|
| | 932 | | private bool sceneSortDirty = false; |
| 652 | 933 | | private bool positionDirty = true; |
| | 934 | | private int lastSortFrame = 0; |
| | 935 | |
|
| | 936 | | public event Action OnSortScenes; |
| | 937 | | public event Action<IParcelScene, string> OnOpenExternalUrlRequest; |
| | 938 | | public event Action<IParcelScene> OnNewSceneAdded; |
| | 939 | | public event Action<IParcelScene> OnNewPortableExperienceSceneAdded; |
| | 940 | | public event Action<string> OnNewPortableExperienceSceneRemoved; |
| | 941 | |
|
| 652 | 942 | | private Vector2Int currentGridSceneCoordinate = new Vector2Int(EnvironmentSettings.MORDOR_SCALAR, EnvironmentSet |
| 652 | 943 | | private Vector2Int sortAuxiliaryVector = new Vector2Int(EnvironmentSettings.MORDOR_SCALAR, EnvironmentSettings.M |
| | 944 | | } |
| | 945 | | } |