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