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) { if (!BlockEngine.GetBlockInfoExists(this.Id)) { throw new BlockTypeException($"Block is not a {this.GetType().Name} block"); } } public Motor(uint id): base(new EGID(id, CommonExclusiveGroups.BUILD_MOTOR_BLOCK_GROUP)) { if (!BlockEngine.GetBlockInfoExists(this.Id)) { throw new BlockTypeException($"Block is not a {this.GetType().Name} block"); } } // custom motor properties /// /// The motor's maximum rotational velocity. /// public float TopSpeed { get { return BlockEngine.GetBlockInfo(Id).maxVelocity; } set { ref MotorReadOnlyStruct motor = ref BlockEngine.GetBlockInfo(Id); motor.maxVelocity = value; } } /// /// The motor's maximum rotational force. /// public float Torque { get { return BlockEngine.GetBlockInfo(Id).maxForce; } set { ref MotorReadOnlyStruct motor = ref BlockEngine.GetBlockInfo(Id); motor.maxForce = value; } } /// /// The motor's direction. /// public bool Reverse { get { return BlockEngine.GetBlockInfo(Id).reverse; } set { ref MotorReadOnlyStruct motor = ref BlockEngine.GetBlockInfo(Id); motor.reverse = value; } } } }