| | 1 | | using System; |
| | 2 | | using System.Collections; |
| | 3 | | using System.Collections.Generic; |
| | 4 | | using System.Linq; |
| | 5 | | using DCL.Camera; |
| | 6 | | using DCL.Configuration; |
| | 7 | | using DCL.Controllers; |
| | 8 | | using UnityEngine; |
| | 9 | |
|
| | 10 | | namespace DCL.Builder |
| | 11 | | { |
| | 12 | | public class SceneManager : ISceneManager |
| | 13 | | { |
| | 14 | | internal static bool BYPASS_LAND_OWNERSHIP_CHECK = false; |
| | 15 | | private const float MAX_DISTANCE_STOP_TRYING_TO_ENTER = 16; |
| | 16 | |
|
| | 17 | | private const string SOURCE_BUILDER_PANEl = "BuilderPanel"; |
| | 18 | | private const string SOURCE_SHORTCUT = "Shortcut"; |
| | 19 | |
|
| | 20 | | public enum State |
| | 21 | | { |
| | 22 | | IDLE = 0, |
| | 23 | | LOADING_CATALOG = 1, |
| | 24 | | CATALOG_LOADED = 2, |
| | 25 | | PREPARE_SCENE = 3, |
| | 26 | | LOADING_SCENE = 4, |
| | 27 | | SCENE_LOADED = 5, |
| | 28 | | EDITING = 6 |
| | 29 | | } |
| | 30 | |
|
| | 31 | | internal State currentState = State.IDLE; |
| | 32 | | public ISceneManager.SceneType sceneType = ISceneManager.SceneType.PROJECT; |
| | 33 | |
|
| | 34 | | private InputAction_Trigger editModeChangeInputAction; |
| | 35 | |
|
| | 36 | | internal IContext context; |
| | 37 | | internal string sceneToEditId; |
| | 38 | | private UserProfile userProfile; |
| | 39 | | internal Coroutine updateLandsWithAcessCoroutine; |
| | 40 | |
|
| | 41 | | private bool alreadyAskedForLandPermissions = false; |
| | 42 | | private Vector3 askPermissionLastPosition; |
| | 43 | | private IWebRequestAsyncOperation catalogAsyncOp; |
| | 44 | | internal bool isWaitingForPermission = false; |
| | 45 | | internal IParcelScene sceneToEdit; |
| | 46 | | private BiwSceneMetricsAnalyticsHelper sceneMetricsAnalyticsHelper; |
| | 47 | | private InputController inputController; |
| | 48 | | internal BuilderInWorldBridge builderInWorldBridge; |
| | 49 | | internal IBuilderInWorldLoadingController initialLoadingController; |
| | 50 | | private float beginStartFlowTimeStamp = 0; |
| | 51 | |
|
| | 52 | | internal bool catalogLoaded = false; |
| | 53 | | internal Manifest.Manifest currentManifest; |
| | 54 | |
|
| | 55 | | public void Initialize(IContext context) |
| | 56 | | { |
| 14 | 57 | | this.context = context; |
| 14 | 58 | | editModeChangeInputAction = context.inputsReferencesAsset.editModeChangeInputAction; |
| 14 | 59 | | editModeChangeInputAction.OnTriggered += ChangeEditModeStatusByShortcut; |
| 14 | 60 | | inputController = context.sceneReferences.inputController; |
| | 61 | |
|
| | 62 | |
|
| 14 | 63 | | builderInWorldBridge = context.sceneReferences.biwBridgeGameObject.GetComponent<BuilderInWorldBridge>(); |
| 14 | 64 | | userProfile = UserProfile.GetOwnUserProfile(); |
| | 65 | |
|
| | 66 | |
|
| 14 | 67 | | context.editorContext.editorHUD.OnPublishAction += TakeSceneScreenshotForPublish; |
| 14 | 68 | | context.editorContext.editorHUD.OnStartExitAction += StartExitMode; |
| 14 | 69 | | context.editorContext.editorHUD.OnLogoutAction += ExitEditMode; |
| | 70 | |
|
| 14 | 71 | | BIWTeleportAndEdit.OnTeleportEnd += OnPlayerTeleportedToEditScene; |
| 14 | 72 | | context.builderAPIController.OnWebRequestCreated += WebRequestCreated; |
| | 73 | |
|
| 14 | 74 | | ConfigureLoadingController(); |
| 14 | 75 | | } |
| | 76 | |
|
| | 77 | | public void Dispose() |
| | 78 | | { |
| 14 | 79 | | if (context.editorContext.editorHUD != null) |
| | 80 | | { |
| 14 | 81 | | context.editorContext.editorHUD.OnPublishAction -= TakeSceneScreenshotForPublish; |
| 14 | 82 | | context.editorContext.editorHUD.OnStartExitAction -= StartExitMode; |
| 14 | 83 | | context.editorContext.editorHUD.OnLogoutAction -= ExitEditMode; |
| | 84 | | } |
| | 85 | |
|
| 14 | 86 | | sceneMetricsAnalyticsHelper?.Dispose(); |
| | 87 | |
|
| 14 | 88 | | initialLoadingController?.Dispose(); |
| | 89 | |
|
| 14 | 90 | | Environment.i.world.sceneController.OnNewSceneAdded -= NewSceneAdded; |
| 14 | 91 | | Environment.i.world.sceneController.OnReadyScene -= NewSceneReady; |
| 14 | 92 | | BIWTeleportAndEdit.OnTeleportEnd -= OnPlayerTeleportedToEditScene; |
| 14 | 93 | | DCLCharacterController.OnPositionSet -= ExitAfterCharacterTeleport; |
| | 94 | |
|
| 14 | 95 | | if (sceneToEdit != null) |
| 7 | 96 | | sceneToEdit.OnLoadingStateUpdated -= UpdateSceneLoadingProgress; |
| | 97 | |
|
| 14 | 98 | | editModeChangeInputAction.OnTriggered -= ChangeEditModeStatusByShortcut; |
| 14 | 99 | | context.builderAPIController.OnWebRequestCreated -= WebRequestCreated; |
| | 100 | |
|
| 14 | 101 | | CoroutineStarter.Stop(updateLandsWithAcessCoroutine); |
| 14 | 102 | | } |
| | 103 | |
|
| | 104 | | private void ConfigureLoadingController() |
| | 105 | | { |
| 14 | 106 | | initialLoadingController = new BuilderInWorldLoadingController(); |
| 14 | 107 | | initialLoadingController.Initialize(); |
| 14 | 108 | | } |
| | 109 | |
|
| | 110 | | public void NextState() |
| | 111 | | { |
| 21 | 112 | | currentState++; |
| 21 | 113 | | switch (currentState) |
| | 114 | | { |
| | 115 | | case State.LOADING_CATALOG: |
| 4 | 116 | | if (!catalogLoaded) |
| 1 | 117 | | GetCatalog(); |
| | 118 | | else |
| 3 | 119 | | NextState(); |
| 3 | 120 | | break; |
| | 121 | |
|
| | 122 | | case State.CATALOG_LOADED: |
| 5 | 123 | | NextState(); |
| 5 | 124 | | break; |
| | 125 | |
|
| | 126 | | //TODO: This step wil be implemented in the future |
| | 127 | | case State.PREPARE_SCENE: |
| 5 | 128 | | NextState(); |
| 5 | 129 | | break; |
| | 130 | |
|
| | 131 | | case State.LOADING_SCENE: |
| 5 | 132 | | LoadScene(); |
| 5 | 133 | | break; |
| | 134 | |
|
| | 135 | | case State.SCENE_LOADED: |
| 2 | 136 | | EnterEditMode(); |
| | 137 | | break; |
| | 138 | | } |
| 2 | 139 | | } |
| | 140 | |
|
| | 141 | | public void WebRequestCreated(IWebRequestAsyncOperation webRequest) |
| | 142 | | { |
| 0 | 143 | | if (currentState == State.LOADING_CATALOG) |
| 0 | 144 | | catalogAsyncOp = webRequest; |
| 0 | 145 | | } |
| | 146 | |
|
| | 147 | | public void Update() |
| | 148 | | { |
| 0 | 149 | | if (currentState != State.LOADING_CATALOG) |
| 0 | 150 | | return; |
| | 151 | |
|
| 0 | 152 | | if (catalogAsyncOp?.webRequest != null) |
| 0 | 153 | | UpdateCatalogLoadingProgress(catalogAsyncOp.webRequest.downloadProgress * 100); |
| 0 | 154 | | } |
| | 155 | |
|
| | 156 | | private void OnPlayerTeleportedToEditScene(Vector2Int coords) |
| | 157 | | { |
| 0 | 158 | | var targetScene = Environment.i.world.state.scenesSortedByDistance |
| 0 | 159 | | .FirstOrDefault(scene => scene.sceneData.parcels.Contains(coords)); |
| 0 | 160 | | StartFlowWithPermission(targetScene, SOURCE_BUILDER_PANEl); |
| 0 | 161 | | } |
| | 162 | |
|
| | 163 | | public void StartEditorFromManifest(Manifest.Manifest manifest) |
| | 164 | | { |
| 0 | 165 | | DataStore.i.HUDs.loadingHUD.visible.Set(true); |
| | 166 | |
|
| | 167 | | //We set the manifest for future saves |
| 0 | 168 | | currentManifest = manifest; |
| 0 | 169 | | context.editorContext.saveController.SetManifest(manifest); |
| | 170 | |
|
| 0 | 171 | | ParcelScene convertedScene = ManifestTranslator.TranslateManifestToScene(manifest); |
| 0 | 172 | | StartFlow(convertedScene, SOURCE_BUILDER_PANEl, ISceneManager.SceneType.PROJECT); |
| 0 | 173 | | } |
| | 174 | |
|
| | 175 | | internal void TakeSceneScreenshotForPublish() |
| | 176 | | { |
| 0 | 177 | | context.cameraController.TakeSceneScreenshot((sceneSnapshot) => |
| | 178 | | { |
| 0 | 179 | | context.editorContext.editorHUD?.SetBuilderProjectScreenshot(sceneSnapshot); |
| 0 | 180 | | }); |
| 0 | 181 | | } |
| | 182 | |
|
| | 183 | | public void StartExitMode() |
| | 184 | | { |
| 1 | 185 | | if (context.editorContext.saveController.GetSaveTimes() > 0) |
| | 186 | | { |
| 1 | 187 | | context.cameraController.TakeSceneScreenshotFromResetPosition((sceneSnapshot) => |
| | 188 | | { |
| 0 | 189 | | if (sceneSnapshot != null) |
| | 190 | | { |
| | 191 | | //This should dissapear when we migrate completely the scene lifecycle to unity |
| 0 | 192 | | context.editorContext.editorHUD?.SaveSceneInfo(); |
| 0 | 193 | | if (currentManifest != null) |
| 0 | 194 | | context.builderAPIController.SetThumbnail(currentManifest.project.id, sceneSnapshot); |
| | 195 | | } |
| 0 | 196 | | }); |
| | 197 | |
|
| 1 | 198 | | if (context.editorContext.editorHUD != null) |
| 1 | 199 | | context.editorContext.editorHUD.ConfigureConfirmationModal( |
| | 200 | | BIWSettings.EXIT_MODAL_TITLE, |
| | 201 | | BIWSettings.EXIT_WITHOUT_PUBLISH_MODAL_SUBTITLE, |
| | 202 | | BIWSettings.EXIT_WITHOUT_PUBLISH_MODAL_CANCEL_BUTTON, |
| | 203 | | BIWSettings.EXIT_WITHOUT_PUBLISH_MODAL_CONFIRM_BUTTON); |
| 1 | 204 | | } |
| | 205 | | else |
| | 206 | | { |
| 0 | 207 | | context.editorContext.editorHUD.ConfigureConfirmationModal( |
| | 208 | | BIWSettings.EXIT_MODAL_TITLE, |
| | 209 | | BIWSettings.EXIT_MODAL_SUBTITLE, |
| | 210 | | BIWSettings.EXIT_MODAL_CANCEL_BUTTON, |
| | 211 | | BIWSettings.EXIT_MODAL_CONFIRM_BUTTON); |
| | 212 | | } |
| 0 | 213 | | } |
| | 214 | |
|
| | 215 | | public IParcelScene FindSceneToEdit() |
| | 216 | | { |
| 6 | 217 | | foreach (IParcelScene scene in Environment.i.world.state.scenesSortedByDistance) |
| | 218 | | { |
| 2 | 219 | | if (WorldStateUtils.IsCharacterInsideScene(scene)) |
| 2 | 220 | | return scene; |
| | 221 | | } |
| | 222 | |
|
| 0 | 223 | | return null; |
| 2 | 224 | | } |
| | 225 | |
|
| | 226 | | private void UpdateLandsWithAccess() |
| | 227 | | { |
| 2 | 228 | | ICatalyst catalyst = Environment.i.platform.serviceProviders.catalyst; |
| 2 | 229 | | ITheGraph theGraph = Environment.i.platform.serviceProviders.theGraph; |
| | 230 | |
|
| 2 | 231 | | DeployedScenesFetcher.FetchLandsFromOwner( |
| | 232 | | catalyst, |
| | 233 | | theGraph, |
| | 234 | | userProfile.ethAddress, |
| | 235 | | KernelConfig.i.Get().network, |
| | 236 | | BIWSettings.CACHE_TIME_LAND, |
| | 237 | | BIWSettings.CACHE_TIME_SCENES) |
| | 238 | | .Then(lands => |
| | 239 | | { |
| 0 | 240 | | DataStore.i.builderInWorld.landsWithAccess.Set(lands.ToArray(), true); |
| 0 | 241 | | if (isWaitingForPermission && Vector3.Distance(askPermissionLastPosition, DCLCharacterController.i.c |
| | 242 | | { |
| 0 | 243 | | CheckSceneToEditByShorcut(); |
| | 244 | | } |
| | 245 | |
|
| 0 | 246 | | isWaitingForPermission = false; |
| 0 | 247 | | alreadyAskedForLandPermissions = true; |
| 0 | 248 | | }); |
| 2 | 249 | | } |
| | 250 | |
|
| | 251 | | internal void CatalogLoaded() |
| | 252 | | { |
| 5 | 253 | | catalogLoaded = true; |
| 5 | 254 | | if ( context.editorContext.editorHUD != null) |
| 5 | 255 | | context.editorContext.editorHUD.RefreshCatalogContent(); |
| 5 | 256 | | NextState(); |
| 5 | 257 | | } |
| | 258 | |
|
| | 259 | | internal void StartFlow(IParcelScene targetScene, string source, ISceneManager.SceneType sceneType) |
| | 260 | | { |
| 1 | 261 | | if (currentState != State.IDLE || targetScene == null) |
| 0 | 262 | | return; |
| | 263 | |
|
| 1 | 264 | | sceneToEdit = targetScene; |
| 1 | 265 | | this.sceneType = sceneType; |
| | 266 | |
|
| 1 | 267 | | NotificationsController.i.allowNotifications = false; |
| 1 | 268 | | CommonScriptableObjects.allUIHidden.Set(true); |
| 1 | 269 | | NotificationsController.i.allowNotifications = true; |
| 1 | 270 | | inputController.inputTypeMode = InputTypeMode.BUILD_MODE_LOADING; |
| | 271 | |
|
| | 272 | | //We configure the loading part |
| 1 | 273 | | initialLoadingController.SetLoadingType(sceneType); |
| 1 | 274 | | initialLoadingController.Show(); |
| 1 | 275 | | initialLoadingController.SetPercentage(0f); |
| | 276 | |
|
| 1 | 277 | | DataStore.i.common.appMode.Set(AppMode.BUILDER_IN_WORLD_EDITION); |
| 1 | 278 | | DataStore.i.virtualAudioMixer.sceneSFXVolume.Set(0f); |
| 1 | 279 | | BIWAnalytics.StartEditorFlow(source); |
| 1 | 280 | | beginStartFlowTimeStamp = Time.realtimeSinceStartup; |
| | 281 | |
|
| 1 | 282 | | context.cameraController.ActivateCamera(sceneToEdit); |
| | 283 | |
|
| 1 | 284 | | NextState(); |
| 1 | 285 | | } |
| | 286 | |
|
| | 287 | | internal void GetCatalog() |
| | 288 | | { |
| 3 | 289 | | BIWNFTController.i.StartFetchingNft(); |
| 3 | 290 | | var catalogPromise = context.builderAPIController.GetCompleteCatalog(userProfile.ethAddress); |
| 3 | 291 | | catalogPromise.Then(x => |
| | 292 | | { |
| 3 | 293 | | CatalogLoaded(); |
| 3 | 294 | | }); |
| 3 | 295 | | catalogPromise.Catch(error => |
| | 296 | | { |
| 0 | 297 | | BIWUtils.ShowGenericNotification(error); |
| 0 | 298 | | }); |
| 3 | 299 | | } |
| | 300 | |
|
| | 301 | | public void ChangeEditModeStatusByShortcut(DCLAction_Trigger action) |
| | 302 | | { |
| 1 | 303 | | if (currentState != State.EDITING && currentState != State.IDLE) |
| 0 | 304 | | return; |
| | 305 | |
|
| 1 | 306 | | if (currentState == State.EDITING ) |
| | 307 | | { |
| 0 | 308 | | context.editorContext.editorHUD.ExitStart(); |
| 0 | 309 | | return; |
| | 310 | | } |
| | 311 | |
|
| 1 | 312 | | if (DataStore.i.builderInWorld.landsWithAccess.Get().Length == 0 && !alreadyAskedForLandPermissions) |
| | 313 | | { |
| 1 | 314 | | ActivateLandAccessBackgroundChecker(); |
| 1 | 315 | | BIWUtils.ShowGenericNotification(BIWSettings.LAND_EDITION_WAITING_FOR_PERMISSIONS_MESSAGE, DCL.Notificat |
| 1 | 316 | | isWaitingForPermission = true; |
| 1 | 317 | | askPermissionLastPosition = DCLCharacterController.i.characterPosition.unityPosition; |
| 1 | 318 | | } |
| | 319 | | else |
| | 320 | | { |
| 0 | 321 | | CheckSceneToEditByShorcut(); |
| | 322 | | } |
| 0 | 323 | | } |
| | 324 | |
|
| | 325 | | internal void CheckSceneToEditByShorcut() |
| | 326 | | { |
| 1 | 327 | | var scene = FindSceneToEdit(); |
| 1 | 328 | | StartFlowWithPermission(scene, SOURCE_SHORTCUT); |
| 1 | 329 | | } |
| | 330 | |
|
| | 331 | | internal void NewSceneAdded(IParcelScene newScene) |
| | 332 | | { |
| 1 | 333 | | if (newScene.sceneData.id != sceneToEditId) |
| 0 | 334 | | return; |
| | 335 | |
|
| 1 | 336 | | Environment.i.world.sceneController.OnNewSceneAdded -= NewSceneAdded; |
| | 337 | |
|
| 1 | 338 | | sceneToEdit = (ParcelScene)Environment.i.world.state.GetScene(sceneToEditId); |
| 1 | 339 | | sceneMetricsAnalyticsHelper = new BiwSceneMetricsAnalyticsHelper(sceneToEdit); |
| 1 | 340 | | sceneToEdit.OnLoadingStateUpdated += UpdateSceneLoadingProgress; |
| 1 | 341 | | } |
| | 342 | |
|
| | 343 | | private void NewSceneReady(string id) |
| | 344 | | { |
| 2 | 345 | | if (sceneToEditId != id) |
| 0 | 346 | | return; |
| | 347 | |
|
| 2 | 348 | | sceneToEdit.OnLoadingStateUpdated -= UpdateSceneLoadingProgress; |
| 2 | 349 | | Environment.i.world.sceneController.OnReadyScene -= NewSceneReady; |
| 2 | 350 | | sceneToEditId = null; |
| 2 | 351 | | NextState(); |
| 2 | 352 | | } |
| | 353 | |
|
| | 354 | | internal bool UserHasPermissionOnParcelScene(IParcelScene sceneToCheck) |
| | 355 | | { |
| 2 | 356 | | if (BYPASS_LAND_OWNERSHIP_CHECK) |
| 0 | 357 | | return true; |
| | 358 | |
|
| 4 | 359 | | List<Vector2Int> allParcelsWithAccess = DataStore.i.builderInWorld.landsWithAccess.Get().SelectMany(land => |
| 6 | 360 | | foreach (Vector2Int parcel in allParcelsWithAccess) |
| | 361 | | { |
| 4 | 362 | | if (sceneToCheck.sceneData.parcels.Any(currentParcel => currentParcel.x == parcel.x && currentParcel.y = |
| 2 | 363 | | return true; |
| | 364 | | } |
| | 365 | |
|
| 0 | 366 | | return false; |
| 2 | 367 | | } |
| | 368 | |
|
| | 369 | | internal bool IsParcelSceneDeployedFromSDK(IParcelScene sceneToCheck) |
| | 370 | | { |
| 4 | 371 | | List<Scene> allDeployedScenesWithAccess = DataStore.i.builderInWorld.landsWithAccess.Get().SelectMany(land = |
| 5 | 372 | | foreach (Scene scene in allDeployedScenesWithAccess) |
| | 373 | | { |
| 1 | 374 | | if (scene.source != Scene.Source.SDK) |
| | 375 | | continue; |
| | 376 | |
|
| 1 | 377 | | List<Vector2Int> parcelsDeployedFromSDK = scene.parcels.ToList(); |
| 3 | 378 | | foreach (Vector2Int parcel in parcelsDeployedFromSDK) |
| | 379 | | { |
| 2 | 380 | | if (sceneToCheck.sceneData.parcels.Any(currentParcel => currentParcel.x == parcel.x && currentParcel |
| 1 | 381 | | return true; |
| | 382 | | } |
| | 383 | | } |
| | 384 | |
|
| 1 | 385 | | return false; |
| 1 | 386 | | } |
| | 387 | |
|
| | 388 | | internal void EnterEditMode() |
| | 389 | | { |
| 2 | 390 | | if (sceneType == ISceneManager.SceneType.DEPLOYED) |
| 0 | 391 | | DataStore.i.HUDs.loadingHUD.visible.Set(false); |
| | 392 | |
|
| 2 | 393 | | initialLoadingController.SetPercentage(100f); |
| 2 | 394 | | initialLoadingController.Hide(true, onHideAction: () => |
| | 395 | | { |
| 0 | 396 | | inputController.inputTypeMode = InputTypeMode.BUILD_MODE; |
| 0 | 397 | | context.editorContext.editorHUD?.SetVisibility(true); |
| 0 | 398 | | CommonScriptableObjects.allUIHidden.Set(true); |
| 0 | 399 | | OpenNewProjectDetails(); |
| 0 | 400 | | }); |
| | 401 | |
|
| 2 | 402 | | DCLCharacterController.OnPositionSet += ExitAfterCharacterTeleport; |
| | 403 | |
|
| 2 | 404 | | context.editor.EnterEditMode(sceneToEdit); |
| 2 | 405 | | BIWAnalytics.EnterEditor( Time.realtimeSinceStartup - beginStartFlowTimeStamp); |
| 2 | 406 | | } |
| | 407 | |
|
| | 408 | | internal void ExitEditMode() |
| | 409 | | { |
| 2 | 410 | | currentState = State.IDLE; |
| 2 | 411 | | initialLoadingController.Hide(true); |
| 2 | 412 | | inputController.inputTypeMode = InputTypeMode.GENERAL; |
| 2 | 413 | | CommonScriptableObjects.allUIHidden.Set(false); |
| 2 | 414 | | context.cameraController.DeactivateCamera(); |
| 2 | 415 | | context.editor.ExitEditMode(); |
| | 416 | |
|
| 2 | 417 | | DCLCharacterController.OnPositionSet -= ExitAfterCharacterTeleport; |
| 2 | 418 | | } |
| | 419 | |
|
| | 420 | | internal void OpenNewProjectDetails() |
| | 421 | | { |
| 1 | 422 | | if (!builderInWorldBridge.builderProject.isNewEmptyProject) |
| 0 | 423 | | return; |
| | 424 | |
|
| 1 | 425 | | context.cameraController.TakeSceneScreenshot((sceneSnapshot) => |
| | 426 | | { |
| 0 | 427 | | context.editorContext.editorHUD?.NewProjectStart(sceneSnapshot); |
| 0 | 428 | | }); |
| 1 | 429 | | } |
| | 430 | |
|
| | 431 | | public void StartFlowWithPermission(IParcelScene targetScene, string source) |
| | 432 | | { |
| 3 | 433 | | if (currentState != State.IDLE || targetScene == null) |
| 2 | 434 | | return; |
| | 435 | |
|
| 1 | 436 | | if (!UserHasPermissionOnParcelScene(targetScene)) |
| | 437 | | { |
| 0 | 438 | | BIWUtils.ShowGenericNotification(BIWSettings.LAND_EDITION_NOT_ALLOWED_BY_PERMISSIONS_MESSAGE); |
| 0 | 439 | | return; |
| | 440 | | } |
| 1 | 441 | | else if (IsParcelSceneDeployedFromSDK(targetScene)) |
| | 442 | | { |
| 0 | 443 | | BIWUtils.ShowGenericNotification(BIWSettings.LAND_EDITION_NOT_ALLOWED_BY_SDK_LIMITATION_MESSAGE); |
| 0 | 444 | | return; |
| | 445 | | } |
| | 446 | |
|
| 1 | 447 | | StartFlow(targetScene, source, ISceneManager.SceneType.DEPLOYED); |
| 1 | 448 | | } |
| | 449 | |
|
| | 450 | | private void LoadScene() |
| | 451 | | { |
| 5 | 452 | | Environment.i.platform.cullingController.Stop(); |
| | 453 | |
|
| 5 | 454 | | sceneToEditId = sceneToEdit.sceneData.id; |
| | 455 | |
|
| | 456 | | // In this point we're sure that the catalog loading (the first half of our progress bar) has already finish |
| 5 | 457 | | initialLoadingController.SetPercentage(50f); |
| 5 | 458 | | Environment.i.world.sceneController.OnNewSceneAdded += NewSceneAdded; |
| 5 | 459 | | Environment.i.world.sceneController.OnReadyScene += NewSceneReady; |
| 5 | 460 | | Environment.i.world.blockersController.SetEnabled(false); |
| | 461 | |
|
| 5 | 462 | | if (sceneType == ISceneManager.SceneType.DEPLOYED) |
| 1 | 463 | | builderInWorldBridge.StartKernelEditMode(sceneToEdit); |
| 5 | 464 | | } |
| | 465 | |
|
| | 466 | | internal void ActivateLandAccessBackgroundChecker() |
| | 467 | | { |
| 2 | 468 | | userProfile = UserProfile.GetOwnUserProfile(); |
| 2 | 469 | | if (!string.IsNullOrEmpty(userProfile.userId)) |
| | 470 | | { |
| 2 | 471 | | if (updateLandsWithAcessCoroutine != null) |
| 0 | 472 | | CoroutineStarter.Stop(updateLandsWithAcessCoroutine); |
| 2 | 473 | | updateLandsWithAcessCoroutine = CoroutineStarter.Start(CheckLandsAccess()); |
| | 474 | | } |
| 2 | 475 | | } |
| | 476 | |
|
| 0 | 477 | | private void UpdateSceneLoadingProgress(float sceneLoadingProgress) { initialLoadingController.SetPercentage(50f |
| | 478 | |
|
| 0 | 479 | | private void UpdateCatalogLoadingProgress(float catalogLoadingProgress) { initialLoadingController.SetPercentage |
| | 480 | |
|
| 2 | 481 | | internal void ExitAfterCharacterTeleport(DCLCharacterPosition position) { ExitEditMode(); } |
| | 482 | |
|
| | 483 | | private IEnumerator CheckLandsAccess() |
| | 484 | | { |
| 0 | 485 | | while (true) |
| | 486 | | { |
| 2 | 487 | | UpdateLandsWithAccess(); |
| 2 | 488 | | yield return WaitForSecondsCache.Get(BIWSettings.REFRESH_LANDS_WITH_ACCESS_INTERVAL); |
| | 489 | | } |
| | 490 | | } |
| | 491 | | } |
| | 492 | | } |