using System; using RobocraftX.Blocks; using RobocraftX.Common; using Svelto.ECS; using Unity.Mathematics; using GamecraftModdingAPI.Utility; namespace GamecraftModdingAPI.Blocks { public class Servo : Block { public Servo(EGID id) : base(id) { if (!BlockEngine.GetBlockInfoExists(this.Id)) { throw new BlockTypeException($"Block is not a {this.GetType().Name} block"); } } public Servo(uint id) : base(new EGID(id, CommonExclusiveGroups.BUILD_SERVO_BLOCK_GROUP)) { if (!BlockEngine.GetBlockInfoExists(this.Id)) { throw new BlockTypeException($"Block is not a {this.GetType().Name} block"); } } // custom servo properties /// /// The servo's minimum angle. /// public float MinimumAngle { get => BlockEngine.GetBlockInfo(Id).minDeviation; set { ref ServoReadOnlyStruct servo = ref BlockEngine.GetBlockInfo(Id); servo.minDeviation = value; } } /// /// The servo's maximum angle. /// public float MaximumAngle { get => BlockEngine.GetBlockInfo(Id).maxDeviation; set { ref ServoReadOnlyStruct servo = ref BlockEngine.GetBlockInfo(Id); servo.maxDeviation = value; } } /// /// The servo's maximum force. /// public float MaximumForce { get => BlockEngine.GetBlockInfo(Id).maxForce; set { ref ServoReadOnlyStruct servo = ref BlockEngine.GetBlockInfo(Id); servo.maxForce = value; } } /// /// The servo's direction. /// public bool Reverse { get => BlockEngine.GetBlockInfo(Id).reverse; set { ref ServoReadOnlyStruct servo = ref BlockEngine.GetBlockInfo(Id); servo.reverse = value; } } } }