using System;

using RobocraftX.Blocks;
using RobocraftX.Common;
using Svelto.ECS;
using Unity.Mathematics;

using TechbloxModdingAPI.Utility;

namespace TechbloxModdingAPI.Blocks
{
	public class Servo : SignalingBlock
    {
		public Servo(EGID id) : base(id)
        {
        }

		public Servo(uint id) : base(new EGID(id, CommonExclusiveGroups.SERVO_BLOCK_GROUP))
        {
        }

        // custom servo properties

        /// <summary>
        /// The servo's minimum angle.
        /// </summary>
        public float MinimumAngle
        {
	        get => BlockEngine.GetBlockInfo<ServoReadOnlyStruct>(this).minDeviation;

			set
			{
				BlockEngine.GetBlockInfo<ServoReadOnlyStruct>(this).minDeviation = value;
			}
		}

		/// <summary>
        /// The servo's maximum angle.
        /// </summary>
        public float MaximumAngle
        {
			get => BlockEngine.GetBlockInfo<ServoReadOnlyStruct>(this).maxDeviation;

			set
			{
				BlockEngine.GetBlockInfo<ServoReadOnlyStruct>(this).maxDeviation = value;
			}
        }

		/// <summary>
        /// The servo's maximum force.
        /// </summary>
        public float MaximumForce
        {
			get => BlockEngine.GetBlockInfo<ServoReadOnlyStruct>(this).servoVelocity;

			set
			{
				BlockEngine.GetBlockInfo<ServoReadOnlyStruct>(this).servoVelocity = value;
			}
        }

		/// <summary>
        /// The servo's direction.
        /// </summary>
        public bool Reverse
        {
			get => BlockEngine.GetBlockInfo<ServoReadOnlyStruct>(this).reverse;

			set
			{
				BlockEngine.GetBlockInfo<ServoReadOnlyStruct>(this).reverse = value;
			}
        }
    }
}