예제 #1
0
        internal Workspace(Type backendType, object[] targets, GetAPI getAPI, Action Repaint, Action <Action> Exec)
        {
            this.Repaint = Repaint;
            this.Exec    = Exec;
            this.api     = getAPI(1) as RelationsInspectorAPI;

            graphBackend = (IGraphBackendInternal <T, P>)BackendTypeUtil.CreateBackendDecorator(backendType);
            graphBackend.Awake(getAPI);

            // create new layout params, they are not comming from the cfg yet
            this.layoutType     = (LayoutType)GUIUtil.GetPrefsInt(GetPrefsKeyLayout(), (int)LayoutType.Tree);
            this.graphPosTweens = new TweenCollection();

            this.builderRNG = new RNG(4);               // chosen by fair dice role. guaranteed to be random.

            expectedTargetType = BackendTypeUtil.BackendAttrType(backendType) ?? typeof(T);

            // when targets is null, show the toolbar only. don't create a graph (and view)
            // when rootEntities is empty, create graph and view anyway, so the user can add entities
            if (targets != null)
            {
                seedEntities = targets.SelectMany(graphBackend.Init).ToHashSet();
                InitGraph();
            }
        }