public IglooMediator(EventDispatcher eventDispatcher, CPDataEntityCollection dataEntityCollection, SceneLayoutDataManager sceneLayoutDataManager, SceneLayoutSyncService sceneLayoutSyncService, INetworkServicesManager networkServicesManager) { this.dataEntityCollection = dataEntityCollection; this.networkServicesManager = networkServicesManager; eventDispatcher.AddListener <PlayerStateServiceEvents.LocalPlayerDataReceived>(onLocalPlayerDataReceived); eventDispatcher.AddListener <IglooUIEvents.AddNewDecoration>(onAddNewDecoration); eventDispatcher.AddListener <IglooUIEvents.AddNewStructure>(onAddNewStructure); eventDispatcher.AddListener <IglooUIEvents.DuplicateSelectedObject>(onDuplicateSelectedObject); eventDispatcher.AddListener <IglooUIEvents.ClearCurrentLayout>(onClearCurrentLayout); layoutManager = sceneLayoutDataManager; layoutSyncService = sceneLayoutSyncService; layoutSyncService.AddExtraLayoutInfoLoader(loadSittingLocations); eventDispatcher.AddListener <ZoneTransitionEvents.ZoneTransition>(onZoneTransition); eventDispatcher.AddListener <WorldServiceEvents.SelfRoomJoinedEvent>(onIglooJoined); eventDispatcher.AddListener <IglooServiceEvents.ForceLeave>(onForceLeave, EventDispatcher.Priority.FIRST); eventDispatcher.AddListener <IglooServiceEvents.IglooLayoutCreated>(onIglooCreated, EventDispatcher.Priority.FIRST); eventDispatcher.AddListener <IglooServiceEvents.IglooDataUpdated>(onIglooDataUpdated, EventDispatcher.Priority.FIRST); eventDispatcher.AddListener <IglooServiceEvents.IglooLayoutUpdated>(onIglooLayoutUpdated, EventDispatcher.Priority.FIRST); eventDispatcher.AddListener <IglooServiceEvents.IglooLayoutDeleted>(onIglooLayoutDeleted, EventDispatcher.Priority.FIRST); eventDispatcher.AddListener <ObjectManipulationEvents.RemovingStructureWithItemsEvent>(onRemovingStructureWithItems); eventDispatcher.AddListener <IglooEvents.ChangeZone>(onChangeZone); eventDispatcher.AddListener <IglooEvents.ReloadLayout>(onReloadLayout); eventDispatcher.AddListener <IglooEvents.PlayIglooSound>(onPlayPlacedDecorationSoundEffect); eventDispatcher.AddListener <SceneLayoutEvents.SceneMaxItemsEvent>(onSceneMaxItemsEncountered); eventDispatcher.AddListener <IglooUIEvents.MaxItemsLimitReached>(onMaxLayoutItemsReached); DataEntityHandle activeHandle = layoutManager.GetActiveHandle(); dataEntityCollection.Whenever <SceneLayoutData>(activeHandle, onLayoutAdded, onLayoutRemoved); }
private void Awake() { layoutManager = Service.Get <SceneLayoutDataManager>(); syncService = Service.Get <SceneLayoutSyncService>(); iglooService = Service.Get <INetworkServicesManager>().IglooService; eventChannel = new EventChannel(Service.Get <EventDispatcher>()); savedIgloosListener = Service.Get <CPDataEntityCollection>().When <SavedIgloosMetaData>(Service.Get <CPDataEntityCollection>().LocalPlayerHandle, onSavedIgloosMetaData); }
public void CreateIgloo(Action <bool, SceneLayoutData> callback) { createCallback = callback; SceneLayoutData activeSceneLayoutData = layoutManager.GetActiveSceneLayoutData(); if (activeSceneLayoutData != null) { MutableSceneLayout mutableSceneLayout = new MutableSceneLayout(); SceneLayoutSyncService.ConvertToMutableSceneLayout(mutableSceneLayout, activeSceneLayoutData); eventChannel.AddListener <IglooServiceEvents.IglooLayoutCreated>(onIglooCreated); iglooService.CreateIglooLayout(mutableSceneLayout, this); return; } Log.LogError(this, "Unable to create igloo. Scene layout data not in data model"); if (createCallback != null) { createCallback.InvokeSafe(arg1: false, null); createCallback = null; } }
public void UpdateAndPublishActiveLayout(Action <bool, SceneLayoutData> callback = null) { updateAndPublishCallback = callback; SceneLayoutData activeSceneLayoutData = layoutManager.GetActiveSceneLayoutData(); MutableSceneLayout mutableSceneLayout = new MutableSceneLayout(); SceneLayoutSyncService.ConvertToMutableSceneLayout(mutableSceneLayout, activeSceneLayoutData); IglooVisibility?visibility = null; if (savedIgloosMetaData.IsDirty) { visibility = savedIgloosMetaData.IglooVisibility; } if (updateAndPublishCallback != null) { eventChannel.AddListener <IglooServiceEvents.IglooPublished>(onIglooPublished); } iglooService.UpdateAndPublish(activeSceneLayoutData.LayoutId, visibility, mutableSceneLayout, this); logBIForSavingIglooLayout(activeSceneLayoutData); }