using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ProcessManager : BaseManager<ProcessManager>
{
    /// <summary>
    /// 构造函数
    /// </summary>
    private ProcessManager() { }

    /// <summary>
    /// 实操项目id
    /// </summary>
    public int id;

    /// <summary>
    /// 模式
    /// </summary>
    public E_ModeType mode;

    /// <summary>
    /// 当前的项目/方案
    /// </summary>
    public D_Scheme d_Scheme;

    /// <summary>
    /// 当前流程Id
    /// </summary>
    public int processId = -1;

    /// <summary>
    /// 当前子流程Id
    /// </summary>
    public int subProcessId = -1;

    /// <summary>
    /// 当前子流程步骤Id
    /// </summary>
    public int subProcessStepId = -1;

    /// <summary>
    /// 初始化
    /// 根据方案id 生成流程数据
    /// </summary>
    /// <param name="id">方案id</param>
    public void Init(int id, E_ModeType mode)
    {
        this.id = id;
        this.mode = mode;
        d_Scheme = DataManager.Instance.GetSchemeData(id);
        ReportManager.Instance.creport = DataManager.Instance.GetSchemeReport(id);
        d_Scheme.Init();
        Debug.Log("流程初始化完成");
    }

    /// <summary>
    /// 切换流程
    /// </summary>
    public void HandoverProcess(int processId, int subProcessId, int subProcessStepId)
    {
        if (processId == -1 || subProcessId == -1 || subProcessStepId == -1)
            return;
        d_Scheme.HandoverProcess(processId, subProcessId, subProcessStepId);
    }

    /// <summary>
    /// 切换流程
    /// </summary>
    public void HandoverSubProcess(int subProcessId, int subProcessStepId)
    {
        if (processId == -1 || subProcessId == -1 || subProcessStepId == -1)
            return;
        d_Scheme.HandoverProcess(processId, subProcessId, subProcessStepId);
    }

    /// <summary>
    /// 切换流程
    /// </summary>
    public void HandoverSubProcessStep(int subProcessStepId)
    {
        if (processId == -1 || subProcessId == -1 || subProcessStepId == -1)
            return;
        d_Scheme.HandoverProcess(processId, subProcessId, subProcessStepId);
    }

    /// <summary>
    /// 结束
    /// </summary>
    public void End()
    {
        id = -1;
        mode = E_ModeType.None;
        d_Scheme = null;
    }
}
