Exemple #1
0
 public void PartAttached(VehiclePart_Config _part, Workshop _workshop)
 {
     attachedParts[_part]++;
     //Debug.Log(_workshop.workshopIndex + " attached " + _part + "  " + attachedParts[_part] + " / " + requiredParts[_part]);
     if (attachedParts[_part] == requiredParts[_part])
     {
         if (factoryMode == FactoryMode.DOD)
         {
             workshopTasks.Remove(_workshop.currentTask);
             if (workshopTasks.Count > 0)
             {
                 WorkshopTask _NEXT_TASK = Get_inactive_workshop_task();
                 if (_NEXT_TASK != null)
                 {
                     _workshop.Set_current_task(_NEXT_TASK);
                 }
                 else
                 {
                     _workshop.gameObject.active = false;
                 }
                 Debug.Log(_workshop.workshopIndex + " TASK COMPLETE: " + _part + ",   new task: " + _workshop.currentTask.requiredParts.First().Key);
             }
         }
     }
 }
        public async Task <IActionResult> PutWorkshopTask([FromRoute] int id, [FromBody] WorkshopTask workshopTask)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != workshopTask.Id)
            {
                return(BadRequest());
            }

            _context.Entry(workshopTask).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!WorkshopTaskExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemple #3
0
 public void Set_current_task(WorkshopTask _task)
 {
     if (_task != null)
     {
         currentTask = _task;
         if (factoryMode == FactoryMode.DOD)
         {
             currentTaskPart = currentTask.requiredParts.First().Key;
         }
     }
 }
        public async Task <IActionResult> PostWorkshopTask([FromBody] WorkshopTask workshopTask)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.Tasks.Add(workshopTask);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetWorkshopTask", new { id = workshopTask.Id }, workshopTask));
        }
Exemple #5
0
 public static async Task DeleteTask(WorkshopTask task, WorkshopContext context)
 {
     context.Tasks.Remove(task);
     await context.SaveChangesAsync();
 }