TechbloxModdingAPI/GamecraftModdingAPI/Blocks/Servo.cs
NorbiPeti 3592c6f464 Add support for initializing blocks with properties
Newly created blocks use the initializer to set properties, allowing the user to set per-block properties
2020-07-15 21:58:24 +02:00

76 lines
1.8 KiB
C#

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)
{
}
public Servo(uint id) : base(new EGID(id, CommonExclusiveGroups.BUILD_SERVO_BLOCK_GROUP))
{
}
// custom servo properties
/// <summary>
/// The servo's minimum angle.
/// </summary>
public float MinimumAngle
{
get => BlockEngine.GetBlockInfo(this, (ServoReadOnlyStruct st) => st.minDeviation);
set
{
BlockEngine.SetBlockInfo(this, (ref ServoReadOnlyStruct st, float val) => st.minDeviation = val, value);
}
}
/// <summary>
/// The servo's maximum angle.
/// </summary>
public float MaximumAngle
{
get => BlockEngine.GetBlockInfo(this, (ServoReadOnlyStruct st) => st.maxDeviation);
set
{
BlockEngine.SetBlockInfo(this, (ref ServoReadOnlyStruct st, float val) => st.maxDeviation = val, value);
}
}
/// <summary>
/// The servo's maximum force.
/// </summary>
public float MaximumForce
{
get => BlockEngine.GetBlockInfo(this, (ServoReadOnlyStruct st) => st.maxForce);
set
{
BlockEngine.SetBlockInfo(this, (ref ServoReadOnlyStruct st, float val) => st.maxForce = val, value);
}
}
/// <summary>
/// The servo's direction.
/// </summary>
public bool Reverse
{
get => BlockEngine.GetBlockInfo(this, (ServoReadOnlyStruct st) => st.reverse);
set
{
BlockEngine.SetBlockInfo(this, (ref ServoReadOnlyStruct st, bool val) => st.reverse = val, value);
}
}
}
}