TechbloxModdingAPI/TechbloxModdingAPI/Blocks/Servo.cs
NorbiPeti d238c97906
Remove block info getters and setters
Regex is great

GetBlockInfo\(this, \((\w+) (\w+)\) ?=> ?\2(.+)\);
GetBlockInfo<$1>(this)$3;

SetBlockInfo\(this, \(ref (\w+) (\w+), \w+ (\w+)\) ?=> \2(.*) = \3,\s*value\);
GetBlockInfo<$1>(this)$4 = value;
2021-05-10 23:08:15 +02:00

76 lines
1.6 KiB
C#

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;
}
}
}
}