using System;
using UnityEngine;

namespace KitsuneCafe.UI
{
    public readonly struct SpawnElementRequest : IEquatable<SpawnElementRequest>
    {
        public readonly ElementId Id;
        public readonly IUIElement Element;
        public readonly Vector3 Position;

        public SpawnElementRequest(ElementId id, IUIElement element, Vector3 position)
        {
            Id = id;
            Element = element;
            Position = position;
        }

        public static SpawnElementRequest Create(ElementId id, IUIElement element, Vector3 position) => new(id, element, position);

        public override bool Equals(object obj)
        {
            return obj is SpawnElementRequest req
                && Equals(req);
        }

        public bool Equals(SpawnElementRequest other)
        {
            return other.Id == Id
                && other.Element == Element
                && other.Position == Position;
        }

        public override int GetHashCode()
        {
            return HashCode.Combine(Id, Element, Position);
        }

        public override string ToString()
        {
            return $"SpawnElementRequest {{ Id = {Id}, Element = \"{Element}\", Position = \"{Position}\" }}";
        }
    }
}