﻿using System;
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;

#endif

namespace JLGames.RocketDriver.Actions.Service
{
    [Serializable]
    public sealed class ServiceNode : ScriptableObject
    {
        [SerializeField] private string m_Uid;
        [SerializeField] private string m_ServiceName;
        [SerializeField] private string m_AssemblyName;
        [SerializeField] private string m_FullName;
        [SerializeField] private Vector2 m_Position;

        public string Uid => m_Uid;

        public string ServiceName => m_ServiceName;

        public string AssemblyName => m_AssemblyName;

        public string FullName => m_FullName;

        public ServiceNode()
        {
        }

        public ServiceNode(string serviceName, string assemblyName, string fullName)
        {
            m_ServiceName = serviceName;
            m_AssemblyName = assemblyName;
            m_FullName = fullName;
        }

        public void SetServiceName(string serviceName)
        {
            m_ServiceName = serviceName;
        }

        public void SetAssemblyName(string assemblyName)
        {
            m_AssemblyName = assemblyName;
        }

        public void SetFullName(string fullName)
        {
            m_FullName = fullName;
        }

        public object GenInstance()
        {
            return null;
        }

#if UNITY_EDITOR

        public Vector2 Position => m_Position;

        public float PositionX
        {
            get { return m_Position.x; }
            set { m_Position.x = value; }
        }

        public float PositionY
        {
            get { return m_Position.y; }
            set { m_Position.y = value; }
        }

        public void SetPosition(Vector2 position)
        {
            m_Position = position;
        }

        public void GenUid()
        {
            m_Uid = GUID.Generate().ToString();
        }
#endif
    }
}