using System;

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

using GamecraftModdingAPI.Utility;

namespace GamecraftModdingAPI.Blocks
{
	public class Motor : Block
    {
        public Motor(EGID id) : base(id)
        {
        }

        public Motor(uint id): base(new EGID(id, CommonExclusiveGroups.BUILD_MOTOR_BLOCK_GROUP))
        {
        }

        // custom motor properties

        /// <summary>
        /// The motor's maximum rotational velocity.
        /// </summary>
        public float TopSpeed
		{
			get
			{
				return BlockEngine.GetBlockInfo(this, (MotorReadOnlyStruct st) => st.maxVelocity);
			}

			set
			{
				BlockEngine.SetBlockInfo(this, (ref MotorReadOnlyStruct st, float val) => st.maxVelocity = val, value);
			}
		}

		/// <summary>
        /// The motor's maximum rotational force.
        /// </summary>
        public float Torque
        {
            get
            {
	            return BlockEngine.GetBlockInfo(this, (MotorReadOnlyStruct st) => st.maxForce);
            }

            set
            {
	            BlockEngine.SetBlockInfo(this, (ref MotorReadOnlyStruct st, float val) => st.maxForce = val, value);
            }
        }

		/// <summary>
        /// The motor's direction.
        /// </summary>
        public bool Reverse
        {
            get
            {
	            return BlockEngine.GetBlockInfo(this, (MotorReadOnlyStruct st) => st.reverse);
            }

            set
            {
	            BlockEngine.SetBlockInfo(this, (ref MotorReadOnlyStruct st, bool val) => st.reverse = val, value);
            }
        }
    }
}