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 Motor : SignalingBlock
|
2020-05-21 19:04:55 +00:00
|
|
|
|
{
|
|
|
|
|
public Motor(EGID id) : base(id)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-10 22:30:58 +00:00
|
|
|
|
public Motor(uint id): base(new EGID(id, CommonExclusiveGroups.BUILD_MOTOR_BLOCK_GROUP))
|
2020-05-21 19:04:55 +00:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// custom motor properties
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The motor's maximum rotational velocity.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public float TopSpeed
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2020-07-15 19:58:24 +00:00
|
|
|
|
return BlockEngine.GetBlockInfo(this, (MotorReadOnlyStruct st) => st.maxVelocity);
|
2020-05-21 19:04:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
{
|
2020-07-15 19:58:24 +00:00
|
|
|
|
BlockEngine.SetBlockInfo(this, (ref MotorReadOnlyStruct st, float val) => st.maxVelocity = val, value);
|
2020-05-21 19:04:55 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The motor's maximum rotational force.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public float Torque
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2020-07-15 19:58:24 +00:00
|
|
|
|
return BlockEngine.GetBlockInfo(this, (MotorReadOnlyStruct st) => st.maxForce);
|
2020-05-21 19:04:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
{
|
2020-07-15 19:58:24 +00:00
|
|
|
|
BlockEngine.SetBlockInfo(this, (ref MotorReadOnlyStruct st, float val) => st.maxForce = val, value);
|
2020-05-21 19:04:55 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The motor's direction.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool Reverse
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2020-07-15 19:58:24 +00:00
|
|
|
|
return BlockEngine.GetBlockInfo(this, (MotorReadOnlyStruct st) => st.reverse);
|
2020-05-21 19:04:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
{
|
2020-07-15 19:58:24 +00:00
|
|
|
|
BlockEngine.SetBlockInfo(this, (ref MotorReadOnlyStruct st, bool val) => st.reverse = val, value);
|
2020-05-21 19:04:55 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|