using UnityEngine;
using System;
using System.Collections.Generic;
using Newtonsoft.Json;

namespace Octopus.Simulator
{
    [Serializable]
    public class SimulationInfo
    {
        public int status;
        public string code;
        public string message;
        public SimulationData data;
        public Meta meta;
        public string timestamp;

    }

    [Serializable]
    public class SimulationData
    {
        public int id;
        public int projectId;
        public int logicId;
        public int userId;
        public string name;
        public string simulationCode;
        public logicData logicData;
        public SimulationParameters parameters;
        public string status;
        public string resultData;
        public string createdAt;
        public string updatedAt;
        public string deletedAt;
        public SimulationProject project;
        public SimulationComponent component;
        public SimulationUser user;
    }

    [Serializable]
    public class logicData
    {
        public string name;
        public bool trace;
        public List<LogicQueue> queues;
        public List<LogicResource> resources;
        public List<LogicComponent> components;
        public int simulation_time;
    }

    public class SimulationParameters
    {
        public int speed;
        public int duration;
        public bool realtime;
    }
    public enum LogicItemType
    {
        Queue,
        Resource,
        Component
    }

    public interface ILogicItem
    {
        string Name { get; }
        string Description { get; }
        LogicItemType ItemType { get; }
    }
    [Serializable]
    public class LogicQueue:ILogicItem
    {
        public string name="";
        public string description="";
        public string Name => name;
        public string Description => description;
        public LogicItemType ItemType => LogicItemType.Queue;
    }

    [Serializable]
    public class LogicResource:ILogicItem
    {
        public string name="";
        public int capacity=0;
        public string description="";
        public int repair_time=0;
        public double speed_factor=0.0;
        public OperationHours OperationHours;
        public int breakdown_interval=0;
        public string Name => name;
        public string Description => description;
        public LogicItemType ItemType => LogicItemType.Resource;
    }

    [Serializable]
    public class OperationHours
    {
        public int end=0;
        public int start=0;
    }

    [Serializable]
    public class LogicComponent:ILogicItem
    {
        public string name="";
        public int rate=0;
        public string type="";
        public string description="";
        public string output_queue="";
        public string output_resource="";
        public int transport_time=0;
        public string required_resource="";
        public int processing_time=0;
        public string Name => name;
        public string Description => description;
        public LogicItemType ItemType => LogicItemType.Component;
    }

    [Serializable]
    public class SimulationProject
    {
        public int id;
        public int userId;
        public string name;
        public string description;
        public string createdAt;
        public string updatedAt;
    }

    [Serializable]
    public class SimulationComponent
    {
        public int id;
        public int userId;
        public string name;
        public string description;
        public string createdAt;
        public string updatedAt;
    }

    public class SimulationUser
    {
        public int id;
        public string ccPositionId;
        public string userid;
        public string name;
        public string auth;
        public string email;
        public bool active;
        public string joinDate;
        public bool activeClassifyRule;
        public string signatureId;
        public string employeeNumber;
        public string resignationDate;
        public string profileId;
        public string createdAt;
        public string updatedAt;
    }

    [Serializable]
    public class Meta
    {
        public Param param;
    }

    [Serializable]
    public class Param
    {
        public int id;
    }
}