﻿using System;
using UnityEngine;

namespace JLGames.RocketDriver.Editor.Infra
{
    public class TaskDatabase : ScriptableObject
    {
        /// <summary>
        /// The version of the database, typically only used internally by the developer.
        /// </summary>
        public string Version;

        /// <summary>
        /// The author, typically only used internally by the developer.
        /// </summary>
        public string Author;

        /// <summary>
        /// The description of the database, typically only used internally by the developer.
        /// </summary>
        public string Description;

        /// <summary>
        /// 全部任务
        /// </summary>
        public TaskNode[] TaskNodes;

        /// <summary>
        /// 全部任务
        /// </summary>
        public TaskNode[] TaskLists;

        public int MaxNodeId => GetMaxNodeId(TaskNodes);

        public int MaxListId => GetMaxNodeId(TaskLists);

        private int GetMaxNodeId(TaskNode[] nodes)
        {
            if (null == nodes || nodes.Length == 0) return 0;
            var max = 0;
            for (var index = 0; index < nodes.Length; index++)
            {
                max = Math.Max(max, nodes[index].NodeId);
            }

            return max;
        }
    }
}