2020-05-21 19:04:55 +00:00
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
using RobocraftX.Blocks;
|
2020-07-10 22:30:58 +00:00
|
|
|
|
using RobocraftX.Common;
|
2020-05-21 19:04:55 +00:00
|
|
|
|
using Svelto.ECS;
|
|
|
|
|
using Unity.Mathematics;
|
|
|
|
|
|
|
|
|
|
using GamecraftModdingAPI.Utility;
|
|
|
|
|
|
|
|
|
|
namespace GamecraftModdingAPI.Blocks
|
|
|
|
|
{
|
2020-08-23 13:59:13 +00:00
|
|
|
|
public class Servo : SignalingBlock
|
2020-05-21 19:04:55 +00:00
|
|
|
|
{
|
|
|
|
|
public Servo(EGID id) : base(id)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-10 22:30:58 +00:00
|
|
|
|
public Servo(uint id) : base(new EGID(id, CommonExclusiveGroups.BUILD_SERVO_BLOCK_GROUP))
|
2020-05-21 19:04:55 +00:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// custom servo properties
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The servo's minimum angle.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public float MinimumAngle
|
2020-07-15 19:58:24 +00:00
|
|
|
|
{
|
|
|
|
|
get => BlockEngine.GetBlockInfo(this, (ServoReadOnlyStruct st) => st.minDeviation);
|
2020-05-21 19:04:55 +00:00
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
{
|
2020-07-15 19:58:24 +00:00
|
|
|
|
BlockEngine.SetBlockInfo(this, (ref ServoReadOnlyStruct st, float val) => st.minDeviation = val, value);
|
2020-05-21 19:04:55 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The servo's maximum angle.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public float MaximumAngle
|
|
|
|
|
{
|
2020-07-15 19:58:24 +00:00
|
|
|
|
get => BlockEngine.GetBlockInfo(this, (ServoReadOnlyStruct st) => st.maxDeviation);
|
2020-05-21 19:04:55 +00:00
|
|
|
|
|
2020-07-15 19:58:24 +00:00
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
BlockEngine.SetBlockInfo(this, (ref ServoReadOnlyStruct st, float val) => st.maxDeviation = val, value);
|
|
|
|
|
}
|
2020-05-21 19:04:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The servo's maximum force.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public float MaximumForce
|
|
|
|
|
{
|
2020-07-15 19:58:24 +00:00
|
|
|
|
get => BlockEngine.GetBlockInfo(this, (ServoReadOnlyStruct st) => st.maxForce);
|
2020-05-21 19:04:55 +00:00
|
|
|
|
|
2020-07-15 19:58:24 +00:00
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
BlockEngine.SetBlockInfo(this, (ref ServoReadOnlyStruct st, float val) => st.maxForce = val, value);
|
|
|
|
|
}
|
2020-05-21 19:04:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The servo's direction.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool Reverse
|
|
|
|
|
{
|
2020-07-15 19:58:24 +00:00
|
|
|
|
get => BlockEngine.GetBlockInfo(this, (ServoReadOnlyStruct st) => st.reverse);
|
2020-05-21 19:04:55 +00:00
|
|
|
|
|
2020-07-15 19:58:24 +00:00
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
BlockEngine.SetBlockInfo(this, (ref ServoReadOnlyStruct st, bool val) => st.reverse = val, value);
|
|
|
|
|
}
|
2020-05-21 19:04:55 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|