Exemple #1
0
 public void ShowMenu(bool enableBackButton)
 {
     actionPointMenu.CurrentActionPoint = this;
     actionPointMenu.UpdateMenu();
     actionPointMenu.EnableBackButton(enableBackButton);
     MenuManager.Instance.ShowMenu(MenuManager.Instance.ActionPointMenu);
 }
Exemple #2
0
        /// <summary>
        /// Updates actions of ActionPoint and ProjectActionPoint received from server.
        /// </summary>
        /// <param name="projectActionPoint"></param>
        /// <returns></returns>
        public virtual (List <string>, Dictionary <string, string>) UpdateActionPoint(IO.Swagger.Model.ActionPoint projectActionPoint)
        {
            if (Data.Parent != projectActionPoint.Parent)
            {
                ChangeParent(projectActionPoint.Parent);
            }
            Data = projectActionPoint;
            transform.localPosition = GetScenePosition();
            transform.localRotation = GetSceneOrientation();
            List <string> currentA = new List <string>();

            foreach (NamedOrientation orientation in Data.Orientations)
            {
                UpdateOrientation(orientation);
            }
            // Connections between actions (action -> output --- input <- action2)
            Dictionary <string, string> connections = new Dictionary <string, string>();

            if (projectActionPoint.Actions != null)
            {
                //update actions
                foreach (IO.Swagger.Model.Action projectAction in projectActionPoint.Actions)
                {
                    // if action exist, just update it, otherwise create new
                    if (!Actions.TryGetValue(projectAction.Id, out Action action))
                    {
                        try {
                            action = ProjectManager.Instance.SpawnAction(projectAction, this);
                        } catch (RequestFailedException ex) {
                            Debug.LogError(ex);
                            continue;
                        }
                    }
                    // updates name of the action
                    action.ActionUpdateBaseData(DataHelper.ActionToBareAction(projectAction));
                    // updates parameters of the action
                    action.ActionUpdate(projectAction);

                    // Add current connection from the server, we will only map the outputs

                    /*foreach (IO.Swagger.Model.ActionIO actionIO in projectAction.Outputs) {
                     *  //if(!connections.ContainsKey(projectAction.Id))
                     *  connections.Add(projectAction.Id, actionIO.Default);
                     * }*/

                    // local list of all actions for current action point
                    currentA.Add(projectAction.Id);
                }
            }


            if (Parent != null)
            {
                if (ConnectionToParent != null)
                {
                    ConnectionToParent.UpdateLine();
                }
                else
                {
                    SetConnectionToParent(Parent);
                }
            }

            if (actionPointMenu != null && actionPointMenu.CurrentActionPoint == this)
            {
                actionPointMenu.UpdateMenu();
            }
            return(currentA, connections);
        }
Exemple #3
0
        /// <summary>
        /// Updates actions of ActionPoint and ProjectActionPoint received from server.
        /// </summary>
        /// <param name="projectActionPoint"></param>
        /// <returns></returns>
        public virtual (List <string>, Dictionary <string, string>) UpdateActionPoint(IO.Swagger.Model.ProjectActionPoint projectActionPoint)
        {
            if (Data.Parent != projectActionPoint.Parent)
            {
                ChangeParent(projectActionPoint.Parent);
            }
            Data = projectActionPoint;
            transform.localPosition = GetScenePosition();
            transform.localRotation = GetSceneOrientation();
            List <string> currentA = new List <string>();
            // Connections between actions (action -> output --- input <- action2)
            Dictionary <string, string> connections = new Dictionary <string, string>();

            //update actions
            foreach (IO.Swagger.Model.Action projectAction in projectActionPoint.Actions)
            {
                string          providerName = projectAction.Type.Split('/').First();
                string          actionType   = projectAction.Type.Split('/').Last();
                IActionProvider actionProvider;
                try {
                    actionProvider = SceneManager.Instance.GetActionObject(providerName);
                } catch (KeyNotFoundException ex) {
                    if (SceneManager.Instance.ServicesData.TryGetValue(providerName, out Service originalService))
                    {
                        actionProvider = originalService;
                    }
                    else
                    {
                        Debug.LogError("PROVIDER NOT FOUND EXCEPTION: " + providerName + " " + actionType);
                        continue; //TODO: throw exception
                    }
                }


                // if action exist, just update it, otherwise create new
                if (!Actions.TryGetValue(projectAction.Id, out Action action))
                {
                    action = ProjectManager.Instance.SpawnAction(projectAction.Id, projectAction.Name, actionType, this, actionProvider);
                }
                // updates name of the action
                action.ActionUpdateBaseData(projectAction);
                // updates parameters of the action
                action.ActionUpdate(projectAction);

                // Add current connection from the server, we will only map the outputs
                foreach (IO.Swagger.Model.ActionIO actionIO in projectAction.Outputs)
                {
                    //if(!connections.ContainsKey(projectAction.Id))
                    connections.Add(projectAction.Id, actionIO.Default);
                }

                // local list of all actions for current action point
                currentA.Add(projectAction.Id);
            }


            if (Parent != null)
            {
                if (ConnectionToParent != null)
                {
                    ConnectionToParent.UpdateLine();
                }
                else
                {
                    SetConnectionToActionObject(Parent);
                }
            }

            if (actionPointMenu != null && actionPointMenu.CurrentActionPoint == this)
            {
                actionPointMenu.UpdateMenu();
            }
            return(currentA, connections);
        }