TechbloxModdingAPI/GamecraftModdingAPI/Blocks/Motor.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

72 lines
1.6 KiB
C#

using System;
using RobocraftX.Blocks;
using RobocraftX.Common;
using Svelto.ECS;
using Unity.Mathematics;
using GamecraftModdingAPI.Utility;
namespace GamecraftModdingAPI.Blocks
{
public class Motor : Block
{
public Motor(EGID id) : base(id)
{
}
public Motor(uint id): base(new EGID(id, CommonExclusiveGroups.BUILD_MOTOR_BLOCK_GROUP))
{
}
// custom motor properties
/// <summary>
/// The motor's maximum rotational velocity.
/// </summary>
public float TopSpeed
{
get
{
return BlockEngine.GetBlockInfo(this, (MotorReadOnlyStruct st) => st.maxVelocity);
}
set
{
BlockEngine.SetBlockInfo(this, (ref MotorReadOnlyStruct st, float val) => st.maxVelocity = val, value);
}
}
/// <summary>
/// The motor's maximum rotational force.
/// </summary>
public float Torque
{
get
{
return BlockEngine.GetBlockInfo(this, (MotorReadOnlyStruct st) => st.maxForce);
}
set
{
BlockEngine.SetBlockInfo(this, (ref MotorReadOnlyStruct st, float val) => st.maxForce = val, value);
}
}
/// <summary>
/// The motor's direction.
/// </summary>
public bool Reverse
{
get
{
return BlockEngine.GetBlockInfo(this, (MotorReadOnlyStruct st) => st.reverse);
}
set
{
BlockEngine.SetBlockInfo(this, (ref MotorReadOnlyStruct st, bool val) => st.reverse = val, value);
}
}
}
}