Ejemplo n.º 1
0
        /// <summary>
        /// Updates action point GameObject in ActionObjects.ActionPoints dict based on the data present in IO.Swagger.Model.ActionPoint Data.
        /// </summary>
        /// <param name="project"></param>
        public void UpdateActionPoints(IO.Swagger.Model.Project project)
        {
            List <string> currentAP                 = new List <string>();
            List <string> currentActions            = new List <string>();
            Dictionary <string, string> connections = new Dictionary <string, string>();



            foreach (IO.Swagger.Model.ProjectActionPoint projectActionPoint in project.ActionPoints)
            {
                // if action point exist, just update it
                if (ActionPoints.TryGetValue(projectActionPoint.Id, out ActionPoint actionPoint))
                {
                    actionPoint.ActionPointBaseUpdate(projectActionPoint);
                }
                // if action point doesn't exist, create new one
                else
                {
                    ActionObject actionObject = null;
                    if (projectActionPoint.Parent != null)
                    {
                        ActionObjects.TryGetValue(projectActionPoint.Parent, out actionObject);
                    }
                    //TODO: update spawn action point to not need action object
                    actionPoint = SpawnActionPoint(projectActionPoint, actionObject);
                }

                // update actions in current action point
                (List <string>, Dictionary <string, string>)updateActionsResult = actionPoint.UpdateActionPoint(projectActionPoint);
                currentActions.AddRange(updateActionsResult.Item1);
                // merge dictionaries
                connections = connections.Concat(updateActionsResult.Item2).GroupBy(i => i.Key).ToDictionary(i => i.Key, i => i.First().Value);

                actionPoint.UpdatePositionsOfPucks();

                currentAP.Add(actionPoint.Data.Id);
            }



            UpdateActionConnections(project.ActionPoints, connections);

            // Remove deleted actions
            foreach (string actionId in GetAllActionsDict().Keys.ToList <string>())
            {
                if (!currentActions.Contains(actionId))
                {
                    RemoveAction(actionId);
                }
            }

            // Remove deleted action points
            foreach (string actionPointId in GetAllActionPointsDict().Keys.ToList <string>())
            {
                if (!currentAP.Contains(actionPointId))
                {
                    RemoveActionPoint(actionPointId);
                }
            }
        }
Ejemplo n.º 2
0
 public bool DestroyProject()
 {
     ProjectLoaded = false;
     Project       = null;
     foreach (ActionPoint ap in ActionPoints.Values)
     {
         ap.DeleteAP(false);
     }
     ActionPoints.Clear();
     return(true);
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Updates project from given json
        /// </summary>
        /// <param name="project"></param>
        public bool UpdateProject(IO.Swagger.Model.Project project, bool forceEdit = false)
        {
            if (project.Id != Project.Id)
            {
                return(false);
            }
            if (!AllowEdit && !forceEdit)
            {
                Debug.LogError("Editation of this project is not allowed!");
                Notifications.Instance.SaveLogs(SceneManager.Instance.Scene, project, "Editation of this project is not allowed!");
                return(false);
            }

            Project = project;
            UpdateActionPoints();
            OnActionPointsChanged?.Invoke(this, EventArgs.Empty);
            return(true);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Creates project from given json
        /// </summary>
        /// <param name="project"></param>
        public bool CreateProject(IO.Swagger.Model.Project project, bool allowEdit)
        {
            Debug.Assert(ActionsManager.Instance.ActionsReady);
            if (Project != null)
            {
                return(false);
            }

            Project        = project;
            this.AllowEdit = allowEdit;
            LoadSettings();
            bool success = UpdateProject(project, true);

            if (success)
            {
                ProjectChanged = false;
                OnLoadProject?.Invoke(this, EventArgs.Empty);
            }
            ProjectLoaded = success;
            return(success);
        }
Ejemplo n.º 5
0
 public static IO.Swagger.Model.BareProject ProjectToBareProject(IO.Swagger.Model.Project project)
 {
     return(new IO.Swagger.Model.BareProject(description: project.Description, hasLogic: project.HasLogic, id: project.Id,
                                             intModified: project.IntModified, modified: project.Modified, name: project.Name, sceneId: project.SceneId));
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Update an existing project 
        /// </summary>
        /// <param name="body">JSON that will be used to update the project</param>
        /// <param name="projectId">ID or Name of the project to update</param>
        /// <returns></returns>
        public async System.Threading.Tasks.Task UpdateProjectAsync (Project body, string projectId)
        {
            // verify the required parameter 'body' is set
            if (body == null) throw new ApiException(400, "Missing required parameter 'body' when calling UpdateProject");
            // verify the required parameter 'projectId' is set
            if (projectId == null) throw new ApiException(400, "Missing required parameter 'projectId' when calling UpdateProject");
            
    
            var path = "/projects/{projectId}";
    
            var pathParams = new Dictionary<String, String>();
            var queryParams = new Dictionary<String, String>();
            var headerParams = new Dictionary<String, String>();
            var formParams = new Dictionary<String, String>();
            var fileParams = new Dictionary<String, FileParameter>();
            String postBody = null;
    
            pathParams.Add("format", "json");
            if (projectId != null) pathParams.Add("projectId", ApiClient.ParameterToString(projectId)); // path parameter
            
            
            
            
            postBody = ApiClient.Serialize(body); // http body (model) parameter
            
    
            // authentication setting, if any
            String[] authSettings = new String[] {  };
    
            // make the HTTP request
            IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path, Method.PUT, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings);
            if (((int)response.StatusCode) >= 400)
                throw new ApiException ((int)response.StatusCode, "Error calling UpdateProject: " + response.Content, response.Content);

            
            return;
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Add a new project to the system Adds a new project
        /// </summary>
        /// <param name="body">Project object that needs to be added to the datastorage</param> 
        /// <returns></returns>            
        public void AddProject (Project body)
        {
            
            // verify the required parameter 'body' is set
            if (body == null) throw new ApiException(400, "Missing required parameter 'body' when calling AddProject");
            
    
            var path = "/projects/";
    
            var pathParams = new Dictionary<String, String>();
            var queryParams = new Dictionary<String, String>();
            var headerParams = new Dictionary<String, String>();
            var formParams = new Dictionary<String, String>();
            var fileParams = new Dictionary<String, FileParameter>();
            String postBody = null;

            pathParams.Add("format", "json");
            
            
            
            
            postBody = ApiClient.Serialize(body); // http body (model) parameter
            
    
            // authentication setting, if any
            String[] authSettings = new String[] {  };
    
            // make the HTTP request
            IRestResponse response = (IRestResponse) ApiClient.CallApi(path, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings);
    
            if (((int)response.StatusCode) >= 400)
                throw new ApiException ((int)response.StatusCode, "Error calling AddProject: " + response.Content, response.Content);
            else if (((int)response.StatusCode) == 0)
                throw new ApiException ((int)response.StatusCode, "Error calling AddProject: " + response.ErrorMessage, response.ErrorMessage);
    
            return;
        }