using RobotNet.MapShares.Enums;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;

namespace RobotNet.MapManager.Data;

#nullable disable

[Table("Maps")]
public class Map
{
    [Column("Id", TypeName = "uniqueidentifier")]
    [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
    [Key]
    [Required]
    public Guid Id { get; set; }

    [Column("Name", TypeName = "nvarchar(64)")]
    [Required]
    public string Name { get; set; }

    [Column("Description", TypeName = "ntext")]
    public string Description { get; set; } = "";

    [Column("VersionId", TypeName = "uniqueidentifier")]
    [Required]
    public Guid VersionId { get; set; }

    [Column("OriginX", TypeName = "float")]
    [Required]
    public double OriginX { get; set; }

    [Column("OriginY", TypeName = "float")]
    [Required]
    public double OriginY { get; set; }

    [Column("Resolution", TypeName = "float")]
    [Required]
    public double Resolution { get; set; }

    [Column("ViewX", TypeName = "float")]
    [Required]
    public double ViewX { get; set; }

    [Column("ViewY", TypeName = "float")]
    [Required]
    public double ViewY { get; set; }

    [Column("ViewWidth", TypeName = "float")]
    [Required]
    public double ViewWidth { get; set; }

    [Column("ViewHeight", TypeName = "float")]
    [Required]
    public double ViewHeight { get; set; }

    [Column("ImageWidth", TypeName = "float")]
    [Required]
    public double ImageWidth { get; set; }

    [Column("ImageHeight", TypeName = "float")]
    [Required]
    public double ImageHeight { get; set; }

    [Column("NodeCount", TypeName = "BigInt")]
    public Int64 NodeCount { get; set; }

    [Column("Active", TypeName = "bit")]
    public bool Active { get; set; }

    [Column("VDA5050", TypeName = "nvarchar(max)")]
    public string VDA5050 { get; set; } = ""; //AdditionalAttributes

    [Column("NodeNameAutoGenerate", TypeName = "bit")]
    public bool NodeNameAutoGenerate { get; set; }

    [Column("NodeNameTemplateDefault", TypeName = "nvarchar(64)")]
    public string NodeNameTemplateDefault { get; set; }

    [Column("NodeAllowedDeviationXyDefault", TypeName = "float")]
    public double NodeAllowedDeviationXyDefault { get; set; }

    [Column("NodeAllowedDeviationThetaDefault", TypeName = "float")]
    public double NodeAllowedDeviationThetaDefault { get; set; }

    [Column("EdgeMinLengthDefault", TypeName = "float")]
    public double EdgeMinLengthDefault { get; set; }

    [Column("EdgeStraightMaxSpeedDefault", TypeName = "float")]
    public double EdgeStraightMaxSpeedDefault { get; set; }

    [Column("EdgeCurveMaxSpeedDefault", TypeName = "float")]
    public double EdgeCurveMaxSpeedDefault { get; set; }

    [Column("EdgeMaxHeightDefault", TypeName = "float")]
    public double EdgeMaxHeightDefault { get; set; }

    [Column("EdgeMinHeightDefault", TypeName = "float")]
    public double EdgeMinHeightDefault { get; set; }

    [Column("EdgeMaxRoataionSpeedDefault", TypeName = "float")]
    public double EdgeMaxRotationSpeedDefault { get; set; }

    [Column("EdgeDirectionAllowedDefault", TypeName = "tinyint")]
    public DirectionAllowed EdgeDirectionAllowedDefault { get; set; }

    [Column("EdgeRotationAllowedDefault", TypeName = "bit")]
    public bool EdgeRotationAllowedDefault { get; set; }

    [Column("EdgeAllowedDeviationXyDefault", TypeName = "float")]
    public double EdgeAllowedDeviationXyDefault { get; set; }

    [Column("EdgeAllowedDeviationThetaDefault", TypeName = "float")]
    public double EdgeAllowedDeviationThetaDefault { get; set; }

    [Column("ZoneMinSquareDefault", TypeName = "float")]
    public double ZoneMinSquareDefault { get; set; }

    public virtual ICollection<Node> Nodes { get; } = [];
    public virtual ICollection<Edge> Edges { get; } = [];
    public virtual ICollection<Action> Actions { get; } = [];
    public virtual ICollection<Zone> Zones { get; } = [];
    public virtual ICollection<ElementModel> ElementModels { get; } = [];
    public virtual ICollection<Element> Elements { get; } = [];
}
