private void InspectEntity(SEntityId entityId) { CEngine engine = CEngine.Instance; engine.Dispatch(EEngineUpdatePriority.BeginFrame, () => { CUpdateScheduler scheduler = engine.CurrentWorld.UpdateScheduler; if (m_updateScope != null && m_updateScope.IsConnected()) { scheduler.Disconnect(m_updateScope); } CEntity entity = entityId.GetEntity(); if (entity != null) { m_selectedObject = new CEditableObject(entityId); m_updateScope = scheduler.Connect(UpdateCallback, EUpdatePriority.ResourceLoading); Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, (Action)(() => { m_desiredTarget = new CEditableObject(entityId); UnmarkEverything(); MarkEntityInInspector(true); })); } }); }
public void SetSelectedObject(CEditableObject obj, bool bForce = false) { if (obj == SelectedEditableObject && !bForce) { return; } CEditableObject oldValue = SelectedEditableObject; SelectedEditableObject = obj; OnSelectedEditableObjectChanged?.Invoke(oldValue, obj); }
private void InspectComponent(SEntityComponentId componentId) { bool bUpdateInspectorObjectList = ShouldUpdateInspectorList(componentId); CEngine engine = CEngine.Instance; CWorldOutlinerViewModel worldOutliner = CWorkspace.Instance.GetTool <CWorldOutlinerViewModel>(); engine.Dispatch(EEngineUpdatePriority.BeginFrame, () => { CUpdateScheduler scheduler = engine.CurrentWorld.UpdateScheduler; if (m_updateScope != null && m_updateScope.IsConnected()) { scheduler.Disconnect(m_updateScope); } CEntityComponent component = componentId.GetComponent(); if (component != null) { m_selectedObject = new CEditableObject(componentId); m_updateScope = scheduler.Connect(UpdateCallback, EUpdatePriority.ResourceLoading); if (bUpdateInspectorObjectList) { UpdateEntityInformation_EngineThread(new SEntityId(component.Owner.Id)); } worldOutliner.PickingComponentId.GetComponent <CScenePickingComponent>().Pick(component as CSceneComponent); Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, (Action)(() => { m_desiredTarget = new CEditableObject(componentId); UnmarkEverything(); MarkComponentInInspector(componentId, true); })); } else { Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, (Action)(() => { m_desiredTarget = null; UnmarkEverything(); })); } }); }
public override void PostWorldLoad() { base.PostWorldLoad(); CEngine.Instance.Dispatch(EEngineUpdatePriority.BeginFrame, () => { Action <CEntity> callback = (entity) => { CHierarchyEntry root = EditorHelpers.FillLevelHierarchy(); Application.Current.Dispatcher.Invoke(() => { UpdateOutliner(root); }); }; Action <CAssetReference <CLevelAsset>, CLevel> levelChanged = (levelAsset, level) => { CHierarchyEntry root = EditorHelpers.FillLevelHierarchy(); SEntityComponentId newPickerId = SpawnScenePicker_EngineThread(CEngine.Instance.CurrentWorld); CWorkspace.Instance.PostLevelLoad(levelAsset); Application.Current.Dispatcher.Invoke(() => { PickingComponentId = newPickerId; UpdateOutliner(root); }); }; CWorld currentWorld = CEngine.Instance.CurrentWorld; currentWorld.OnEntitySpawned += callback; currentWorld.OnEntityDestroyed += callback; currentWorld.OnEntityRevived += callback; currentWorld.OnLevelChanged += levelChanged; currentWorld.OnHierarchyChanged += (child, oldParent, newParent) => { if (child == child.Owner?.RootComponent) { callback(null); } }; SEntityComponentId pickerId = SpawnScenePicker_EngineThread(currentWorld); Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (Action)(() => { PickingComponentId = pickerId; })); CScenePickingComponent.OnComponentPicked += (component) => { if (component == null) { Application.Current.Dispatcher.Invoke(() => { CWorkspace.Instance.SetSelectedObject(null); }); } else { CEntity entity = component.Owner; CEditableObject editObj = null; if (entity.RootComponent == null) { editObj = new CEditableObject(new SEntityId(entity.Id)); } else { editObj = new CEditableObject(new SEntityComponentId(entity.RootComponent)); } Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (Action)(() => { CWorkspace.Instance.SetSelectedObject(editObj); })); } }; callback(null); }); }